Create Custom Approval Center Project Server using PSI

Create Custom Approval Center Project Server using PSI

Create Custom Approval Center Project Server using PSI. Approval Center in Project server is the center point where project task of particular resources approve and reject them respective project manager.

Below is code for Getting Approval Center Task:-

Firstly add projectserverservice web reference. if you don’t know how to create and add¬†projectserverservice.dll in gac and add reference then go to my previous post.

How to Create Project Server Service dll

How to Register a dll in GAC

If you don’t know how to add service reference then follow my post. Add PSI Web Reference in Solution file

[AdSense-A]

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using PSLibrary = Microsoft.Office.Project.Server.Library;
using System.ServiceModel;
using System.Xml;
using SvcAdmin;
using System.Security.Principal;
using SvcTimeSheet;
using System.Data.SqlClient;
using System.ServiceModel.Web;

namespace CreateCustomApprovalCenter
{
    class Program
    {
        public static string PWAURL = "http://ServerName/PWAPath/";
        public static string ENDPOINT_PROJECT = "basicHttp_Project";
        public static string ENDPOINT_RESOURCE = "basicHttp_Resource";
        public static string ENDPOINT_TIMESHEET = "basicHttp_TimeSheet";
        public static string ENDPOINT_ADMIN = "basicHttp_Admin";
        public static string ENDPOINT_QUEUESYSTEM = "basicHttp_QueueSystem";
        public static Guid CurrentUserUID = Guid.Empty;
        public static SvcResource.ResourceClient resourceClient;
        private static SvcStatusing.StatusingClient statusingClient;
        public static SvcTimeSheet.TimeSheetClient timesheetClient;
        public static SvcQueueSystem.QueueSystemClient queueSystemClient;
        static void Main(string[] args)
        {
            GetApprovalCenter();
        }
        public static List<ApprovalCenter> GetApprovalCenter()
        {
            List<ApprovalCenter> ApprovalCenterList = new List<ApprovalCenter>();
            string _keyColumn = string.Empty;
            string _keyColumn1 = string.Empty;
            DataTable DT_ActualPlanned = new DataTable();

            DataTable ProjectDt = DT_BindGridview(PWAURL).Keys.ElementAt(0);
            DT_ActualPlanned = DT_BindGridview(PWAURL).Values.ElementAt(0);
            Dictionary<DataTable, DataTable> resultDic = DT_TimesheetGrid(PWAURL, ProjectDt, DT_ActualPlanned);
            ProjectDt = resultDic.Keys.ElementAt(0);// DT_TimesheetGrid(PWAPath, ProjectDt, DT_ActualPlanned).Keys.ElementAt(0);
            var query = from xy in ProjectDt.AsEnumerable()
                        where !xy.Field<string>("Approval_Type").Contains("Timesheet")
                        select xy;
            foreach (var item in query)
            {
                DataTable dt = item.Table;
                ApprovalCenter approv = new ApprovalCenter();
                approv.ApprovalType = dt.Rows[0]["Approval_Type"].ToString();
                approv.ASSNUID = dt.Rows[0]["ASSN_UID"].ToString();
                approv.ProjectUid = dt.Rows[0]["PROJ_UID"].ToString();
                approv.TaskName = dt.Rows[0]["TASK_NAME"].ToString();
                approv.ProjectName = dt.Rows[0]["PROJ_NAME"].ToString();
                approv.Resource = dt.Rows[0]["RES_NAME"].ToString();
                approv.Owner = dt.Rows[0]["RES_NAME_OWNER"].ToString();
                approv.TransectionComment = dt.Rows[0]["ASSN_TRANS_COMMENT"].ToString();
                approv.SentDate = dt.Rows[0]["ASSN_TRANS_SUBMIT_DATE"].ToString();
                approv.StartDate = dt.Rows[0]["ASSN_START_DATE"].ToString();
                approv.FinishDate = dt.Rows[0]["ASSN_FINISH_DATE"].ToString();
                approv.Total = dt.Rows[0]["ASSN_ACT_WORK"].ToString();
                approv.percentageComplete = dt.Rows[0]["ASSN_PCT_WORK_COMPLETE"].ToString();
                approv.RemainingWork = dt.Rows[0]["ASSN_REM_WORK"].ToString();
                ApprovalCenterList.Add(approv);
                //approv.ProjectName = item.ItemArray;
            }
            return ApprovalCenterList;

        }

        public static Dictionary<DataTable, DataTable> DT_BindGridview(string pwaPath)
        {

            SetClientEndpoint(PWAURL);
            //***************Variable Declaration***********************//
            #region Variable Declarations
            DataTable GBind = new DataTable();
            DataRow GR = null;
            DataTable DT_PreFormatTable = new DataTable();
            int Count = 0;
            int Gcount = 0;
            string TASK_UID = string.Empty;
            string TASK_NAME = string.Empty;
            string PROJ_NAME = string.Empty;
            string RES_NAME = string.Empty;
            string ListID = string.Empty;
            string Get_DocName = string.Empty;
            string RES_NAME_OWNER = string.Empty;
            string TransComment = string.Empty;
            string ASSN_TRANS_SUBMIT_DATE = string.Empty;
            string ASSN_START_DATE = string.Empty;
            string ASSN_FINISH_DATE = string.Empty;
            string ASSN_ACT_WORK = string.Empty;
            string ASSN_PCT_WORK = string.Empty;
            string ASSN_REM_WORK = string.Empty;
            string TASK_HIER = string.Empty;
            string DocUrl = string.Empty;
            // string UserId = WebOperationContext.Current.IncomingRequest.UriTemplateMatch.QueryParameters["UserId"].ToString().Trim();// which user's task you want update
            string CurrentUser = "Donald"; //Approver user name.Approval center of user.
            CurrentUser = string.Concat("i:0#.w|epm", @"", CurrentUser); //enter your domain name here epm is domain name

            #endregion

            //***************Dataset Declaration************************//
            #region Datasets
            SvcResource.ResourceDataSet ResourceDS = new SvcResource.ResourceDataSet();
            SvcStatusing.StatusApprovalDataSet StatusApprovallDS = new SvcStatusing.StatusApprovalDataSet();
            SvcStatusing.StatusingTimephasedActualsDataSet StatusingTimephasedActualDs = new SvcStatusing.StatusingTimephasedActualsDataSet();

            DataTable Dt_PreforTimesheetView = new DataTable();
            DataTable FinalTable = new DataTable();
            #endregion
            //********Call References**********************************//
            #region Read References
            ResourceDS = resourceClient.ReadResources("", false);
            CurrentUserUID = new Guid(ResourceDS.Resources.Select("WRES_ACCOUNT='" + CurrentUser + "'").Length > 0 ? ResourceDS.Resources.Select("WRES_ACCOUNT='" + CurrentUser + "'")[0][ResourceDS.Resources.RES_UIDColumn].ToString() : "00000000-0000-0000-0000-000000000000");

            // Guid UserGuid = new Guid("7efe60ec-311f-4339-88e8-ba048473131b"); //ajay
            Guid JobGuid = Guid.NewGuid();
            #endregion

            //********Format Ready for Add Columns**************************//
            #region Preformat for ShowStatusApprovals
            GBind.Columns.Add("Approval_Type", typeof(string));
            GBind.Columns.Add("ASSN_UID", typeof(string));
            GBind.Columns.Add("PROJ_UID", typeof(string));
            GBind.Columns.Add("TASK_NAME", typeof(string));
            GBind.Columns.Add("PROJ_NAME", typeof(string));
            GBind.Columns.Add("Title", typeof(string));
            GBind.Columns.Add("Update_Type", typeof(string));
            GBind.Columns.Add("RES_NAME", typeof(string));
            GBind.Columns.Add("RES_NAME_OWNER", typeof(string));
            GBind.Columns.Add("ASSN_TRANS_COMMENT", typeof(string));
            GBind.Columns.Add("ASSN_TRANS_SUBMIT_DATE", typeof(string));
            GBind.Columns.Add("ASSN_START_DATE", typeof(string));
            GBind.Columns.Add("ASSN_FINISH_DATE", typeof(string));
            GBind.Columns.Add("ASSN_ACT_WORK", typeof(string));
            GBind.Columns.Add("ASSN_PCT_WORK_COMPLETE", typeof(string));
            GBind.Columns.Add("ASSN_REM_WORK", typeof(string));
            GBind.Columns.Add("Document", typeof(string));
            GBind.Columns.Add("TASK_HIERARCHY", typeof(string));
            GBind.Columns.Add("Gid", typeof(string));
            GBind.Columns.Add("IsTimeSheet", typeof(bool));
            DT_PreFormatTable.Columns.Add("ASSN_UID", typeof(string));
            DT_PreFormatTable.Columns.Add("PROJ_UID", typeof(string));
            DT_PreFormatTable.Columns.Add("TASK_UID", typeof(string));

            FinalTable.Columns.Add("Type", typeof(string));
            FinalTable.Columns.Add("Total", typeof(string));
            FinalTable.Columns.Add("id", typeof(int));
            #endregion

            PSLibrary.PSContextInfo contextInfo = new PSLibrary.PSContextInfo(true, CurrentUser, CurrentUserUID, Guid.Empty, Guid.Empty, null, null);
            string contextInfoString = PSLibrary.PSContextInfo.SerializeToString(contextInfo);
            try
            {
                using (OperationContextScope scope = new OperationContextScope(statusingClient.InnerChannel))
                {
                    // Use WebOperationContext in the HTTP channel, not the OperationContext.
                    WebOperationContext.Current.OutgoingRequest.Headers.Remove("PjAuth");
                    WebOperationContext.Current.OutgoingRequest.Headers.Add("PjAuth", contextInfoString);
                    // Disable Forms authentication, to enable Windows authentication.
                    WebOperationContext.Current.OutgoingRequest.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f");

                    StatusApprovallDS = statusingClient.ReadStatusApprovalsSubmitted(true);
                }
            }
            catch (Exception ex)
            { }
            /***********************Read Status ApprovalDataset******************************/
            if (StatusApprovallDS.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow Drow in StatusApprovallDS.Tables[0].Rows)
                {
                    Get_DocName = string.Empty;
                    DocUrl = string.Empty;
                    string PROJ_UID = Drow["PROJ_UID"].ToString();
                    string ASSN_UID = Drow["ASSN_UID"].ToString();
                    TASK_UID = Drow["TASK_UID"].ToString();
                    TASK_NAME = Drow["TASK_NAME"].ToString();
                    PROJ_NAME = Drow["PROJ_NAME"].ToString();
                    RES_NAME = Drow["RES_NAME"].ToString();
                    RES_NAME_OWNER = Drow["RES_NAME_OWNER"].ToString();
                    TransComment = Drow["ASSN_TRANS_COMMENT"].ToString();
                    ASSN_TRANS_SUBMIT_DATE = Drow["ASSN_TRANS_SUBMIT_DATE"].ToString();
                    ASSN_START_DATE = Drow["ASSN_START_DATE"].ToString();
                    ASSN_FINISH_DATE = Drow["ASSN_FINISH_DATE"].ToString();
                    ASSN_ACT_WORK = Drow["ASSN_ACT_WORK"].ToString();
                    ASSN_PCT_WORK = Drow["ASSN_PCT_WORK_COMPLETE"].ToString();
                    ASSN_REM_WORK = Drow["ASSN_REM_WORK"].ToString();
                    TASK_HIER = Drow["TASK_HIERARCHY"].ToString();
                    /****************************Read TimePhase Dataset*************************************/
                    using (OperationContextScope scope = new OperationContextScope(statusingClient.InnerChannel))
                    {
                        // Use WebOperationContext in the HTTP channel, not the OperationContext.
                        WebOperationContext.Current.OutgoingRequest.Headers.Remove("PjAuth");
                        WebOperationContext.Current.OutgoingRequest.Headers.Add("PjAuth", contextInfoString);
                        // Disable Forms authentication, to enable Windows authentication.
                        WebOperationContext.Current.OutgoingRequest.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f");

                        StatusingTimephasedActualDs = statusingClient.ReadStatusTimephasedData(new Guid(PROJ_UID), new Guid(ASSN_UID), Convert.ToDateTime(ASSN_START_DATE), Convert.ToDateTime(ASSN_FINISH_DATE), 60);
                    }

                    if (StatusingTimephasedActualDs.Tables[0].Rows.Count > 0)
                    {
                        DateTime maxDate = Convert.ToDateTime(((from DataRow dr in StatusingTimephasedActualDs.Tables[0].Rows orderby Convert.ToDateTime(dr["TimeByDay"]) descending select dr).FirstOrDefault()["TimeByDay"]));
                        DateTime minDate = Convert.ToDateTime(((from DataRow dr in StatusingTimephasedActualDs.Tables[0].Rows orderby Convert.ToDateTime(dr["TimeByDay"]) ascending select dr).FirstOrDefault()["TimeByDay"]));

                        var SMaxDate = maxDate.Date;
                        var SMinDate = minDate.Date;
                        double _PlanTotal = 0;
                        double _ActualTotal = 0;
                        int i = 0;
                        int TDays = SMaxDate.Subtract(SMinDate).Days;
                        DataTable DT_GetSingleDate = new DataTable();
                        DataRow _ThisTaskRowPlanned = null;
                        DataRow _ThistaskRowActuals = null;
                        _ThisTaskRowPlanned = FinalTable.NewRow();
                        _ThistaskRowActuals = FinalTable.NewRow();
                        while (i <= TDays)
                        {
                            DateTime StartDate = SMinDate;
                            if (!FinalTable.Columns.Contains(StartDate.AddDays(i).ToShortDateString()))
                            {
                                FinalTable.Columns.Add(StartDate.AddDays(i).ToShortDateString().ToString(), typeof(string));
                            }
                            if (StatusingTimephasedActualDs.Tables[0].Select("TimeByDay >= '" + Convert.ToDateTime(StartDate.AddDays(i).ToString()) + "' and TimeByDay <= '" + Convert.ToDateTime(StartDate.AddDays(i).ToString()).AddHours(23) + "'").Length > 0)
                            {
                                DT_GetSingleDate = (DataTable)StatusingTimephasedActualDs.Tables[0].Select("TimeByDay >= '" + Convert.ToDateTime(StartDate.AddDays(i).ToString()) + "' and TimeByDay <= '" + Convert.ToDateTime(StartDate.AddDays(i).ToString()).AddHours(23) + "'").CopyToDataTable();

                                if (DT_GetSingleDate.Rows.Count > 0)
                                {
                                    int r = 0;
                                    double SumOfPlanValue = 0;
                                    double SumOfActualValue = 0;
                                    foreach (DataRow row1 in DT_GetSingleDate.Rows)
                                    {
                                        double PlanWork = Convert.ToDouble(row1["AssignmentWork"].ToString());
                                        double ActualWork = Convert.ToDouble(row1["AssignmentActualWork"].ToString());
                                        SumOfPlanValue = SumOfPlanValue + Convert.ToDouble(PlanWork);
                                        SumOfActualValue = SumOfActualValue + Convert.ToDouble(ActualWork);
                                        r++;
                                    }
                                    double PlanHours = (double)(SumOfPlanValue / 60000);
                                    double ActualHours = (double)(SumOfActualValue / 60000);
                                    _ThisTaskRowPlanned[i + 3] = PlanHours + "h";
                                    _ThistaskRowActuals[i + 3] = ActualHours + "h";
                                    _PlanTotal = _PlanTotal + PlanHours;
                                    _ActualTotal = _ActualTotal + ActualHours;
                                    _ThisTaskRowPlanned[1] = _PlanTotal + "h";
                                    _ThistaskRowActuals[1] = _ActualTotal + "h";
                                    _ThisTaskRowPlanned[0] = "Planned";
                                    _ThistaskRowActuals[0] = "Actual";
                                }
                            }
                            i++;

                        }
                        _ThistaskRowActuals[2] = Count;
                        _ThisTaskRowPlanned[2] = Count = Count + 1;
                        FinalTable.Rows.Add(_ThistaskRowActuals);
                        FinalTable.Rows.Add(_ThisTaskRowPlanned);
                        Count++;
                    }
                    else
                    {
                        DataRow _ThisTaskRowPlanned = null;
                        DataRow _ThistaskRowActuals = null;
                        _ThisTaskRowPlanned = FinalTable.NewRow();
                        _ThistaskRowActuals = FinalTable.NewRow();

                        _ThisTaskRowPlanned[1] = "0h";
                        _ThistaskRowActuals[1] = "0h";
                        _ThisTaskRowPlanned[0] = "Planned";
                        _ThistaskRowActuals[0] = "Actual";
                        FinalTable.Rows.Add(_ThistaskRowActuals);
                        FinalTable.Rows.Add(_ThisTaskRowPlanned);

                    }

                    string LinkItem = string.Empty;
                    if (LinkItem != string.Empty)
                    {
                        try
                        {

                        }
                        catch (Exception ex)
                        { }
                    }
                    /*******************Fill Datarow*************************/

                    GR = GBind.NewRow();
                    String TaskUrl = "" + PWAURL + "/TaskDetails.aspx?Proj=" + PROJ_UID + "&Assn=" + ASSN_UID + "&Source=" + PWAURL + "tasks.aspx";
                    GR["Approval_Type"] = "Status Update";
                    GR["Update_Type"] = "Task Update";
                    GR["TASK_NAME"] = TASK_NAME;
                    GR["PROJ_NAME"] = PROJ_NAME;
                    GR["RES_NAME"] = RES_NAME;
                    GR["ASSN_UID"] = ASSN_UID;
                    GR["PROJ_UID"] = PROJ_UID;
                    GR["Gid"] = Gcount;
                    GR["RES_NAME_OWNER"] = RES_NAME_OWNER;
                    GR["ASSN_TRANS_COMMENT"] = TransComment;
                    GR["ASSN_TRANS_SUBMIT_DATE"] = Convert.ToDateTime(ASSN_TRANS_SUBMIT_DATE).ToShortDateString();
                    GR["ASSN_START_DATE"] = Convert.ToDateTime(ASSN_START_DATE).ToShortDateString();
                    GR["ASSN_FINISH_DATE"] = Convert.ToDateTime(ASSN_FINISH_DATE).ToShortDateString();
                    GR["ASSN_ACT_WORK"] = ((Convert.ToDouble(ASSN_ACT_WORK) / 60000).ToString() + "h");
                    GR["ASSN_PCT_WORK_COMPLETE"] = ASSN_PCT_WORK + "%";
                    GR["ASSN_REM_WORK"] = (Convert.ToDouble(ASSN_REM_WORK) / 60000).ToString() + "h";
                    GR["TASK_HIERARCHY"] = TASK_HIER;
                    if (DocUrl != string.Empty)
                    {
                        GR["Document"] = DocUrl;
                    }
                    else
                    {
                        GR["Document"] = "";
                    }
                    if (Get_DocName != string.Empty)
                    {
                        GR["Title"] = Get_DocName;
                    }
                    /**********Add Row in DataTable*************/
                    GBind.Rows.Add(GR);
                    Gcount++;
                }
            }
            Dictionary<DataTable, DataTable> result = new Dictionary<DataTable, DataTable>();
            result.Add(GBind, FinalTable);
            return result;
        }

        public static Dictionary<DataTable, DataTable> DT_TimesheetGrid(string pwaPath, DataTable ProjectDt, DataTable DT_ActualPlanned)
        {
            SetClientEndpoint(PWAURL);

            Guid TS_ID;
            int Count = DT_ActualPlanned.Rows.Count;
            int Gcount = ProjectDt.Rows.Count;
            string ProjName = string.Empty;
            string TaskUrl = string.Empty;
            string TaskName = string.Empty;
            string PeriodStartDate = string.Empty;
            string PeriodFinishDate = string.Empty;
            DataRow GR = null;
            DataTable FinalTable = new DataTable();
            DataTable DTActuals = new DataTable();
            SvcTimeSheet.TimesheetDataSet timeDS = new SvcTimeSheet.TimesheetDataSet();

            try
            {
                DataTable DT_GetRecords = new DataTable();
                SqlConnection cn = new SqlConnection("Data Source=ServerName;Initial Catalog=ProjectWebApp;Integrated Security=True"); //Create database connection
                cn.Open();
                string query = "Select DISTINCT [TS_UID] FROM [pub].[MSP_TIMESHEET_ACTIONS] where RES_UID = '" + CurrentUserUID + "' and TS_LINE_UID <> NEWID()";
                SqlDataAdapter adr = new SqlDataAdapter(query, cn);
                adr.Fill(DT_GetRecords);
                cn.Close();
                bool IsExist = false;
                for (int counter = 0; counter < DT_GetRecords.Rows.Count; counter++)
                {
                    TS_ID = new Guid(DT_GetRecords.Rows[counter]["TS_UID"].ToString());
                    timeDS = timesheetClient.ReadTimesheet(TS_ID);

                    for (int j = 0; j < timeDS.Headers.Rows.Count; j++)
                    {
                        if (timeDS.Headers[j][timeDS.Headers.TS_STATUS_ENUMColumn].ToString() == "5")
                        {
                            DateTime minDate = Convert.ToDateTime(((from DataRow dr in timeDS.Actuals.Rows
                                                                    orderby Convert.ToDateTime(dr["TS_ACT_START_DATE"]) ascending
                                                                    select dr).FirstOrDefault()["TS_ACT_START_DATE"]));

                            DateTime maxDate = Convert.ToDateTime(((from DataRow dr in timeDS.Actuals.Rows
                                                                    orderby Convert.ToDateTime(dr["TS_ACT_FINISH_DATE"]) descending
                                                                    select dr).FirstOrDefault()["TS_ACT_FINISH_DATE"]));
                            int i = 0;
                            var SMaxDate = maxDate.Date;
                            var SMinDate = minDate.Date;
                            int TDays = SMaxDate.Subtract(SMinDate).Days;
                            DataRow ThisTaskRowActual = DT_ActualPlanned.NewRow();
                            DataRow ThisTaskRowPlan = DT_ActualPlanned.NewRow();
                            double _PlanTotal = 0;
                            double _ActualTotal = 0;
                            int k = 3;
                            while (i <= TDays)
                            {
                                DateTime StartDate = SMinDate;
                                if (!DT_ActualPlanned.Columns.Contains(StartDate.AddDays(i).ToShortDateString()))
                                {
                                    DT_ActualPlanned.Columns.Add(StartDate.AddDays(i).ToShortDateString().ToString(), typeof(string));
                                }
                                if (timeDS.Actuals.Select("TS_ACT_START_DATE >= '" + Convert.ToDateTime(StartDate.AddDays(i).ToString()) + "' and TS_ACT_START_DATE <= '" + Convert.ToDateTime(StartDate.AddDays(i).ToString()).AddHours(23) + "'").Length > 0)
                                {
                                    IsExist = true;
                                    DataTable DT_GetSingleDay = (DataTable)timeDS.Actuals.Select("TS_ACT_START_DATE >= '" + Convert.ToDateTime(StartDate.AddDays(i).ToString()) + "' and TS_ACT_START_DATE <= '" + Convert.ToDateTime(StartDate.AddDays(i).ToString()).AddHours(23) + "'").CopyToDataTable();
                                    List<double> AWork = new List<double>();
                                    List<double> PWork = new List<double>();
                                    foreach (DataRow DateRow in DT_GetSingleDay.Rows)
                                    {
                                        double Actualwork = Convert.ToDouble(DateRow["TS_ACT_VALUE"].ToString());
                                        double Planwork = Convert.ToDouble(DateRow["TS_ACT_PLAN_VALUE"].ToString());
                                        double ACTWork = (double)(Actualwork / 60000);
                                        double PLANWork = (double)(Planwork / 60000);
                                        AWork.Add(ACTWork);
                                        PWork.Add(PLANWork);
                                    }
                                    var ActualDateSum = Math.Round(AWork.Sum(), 2);
                                    var PlanDateSum = Math.Round(PWork.Sum(), 2);
                                    ThisTaskRowPlan[k] = PlanDateSum + "h";
                                    ThisTaskRowActual[k] = ActualDateSum + "h";
                                    _PlanTotal = _PlanTotal + PlanDateSum;
                                    _ActualTotal = _ActualTotal + ActualDateSum;
                                    ThisTaskRowPlan[1] = (double)(_PlanTotal) + "h";
                                    ThisTaskRowActual[1] = (double)(_ActualTotal) + "h";
                                    ThisTaskRowPlan[0] = "Planned";
                                    ThisTaskRowActual[0] = "Actual";
                                }
                                k++;
                                i++;
                            }
                            if (IsExist != false)
                            {
                                ThisTaskRowActual[2] = Count;
                                ThisTaskRowPlan[2] = Count = Count + 1;
                                DT_ActualPlanned.Rows.Add(ThisTaskRowActual);
                                DT_ActualPlanned.Rows.Add(ThisTaskRowPlan);
                                IsExist = false;
                            }

                            /******************************/
                            string wprd = timeDS.Headers.Rows[0]["WPRD_UID"].ToString();
                            if (timeDS.Tables[7].Select("WPRD_UID = '" + wprd + "'").Length > 0)
                            {
                                PeriodStartDate = timeDS.Tables[7].Select("WPRD_UID = '" + wprd + "'")[0]["WPRD_START_DATE"].ToString();
                                PeriodFinishDate = timeDS.Tables[7].Select("WPRD_UID = '" + wprd + "'")[0]["WPRD_FINISH_DATE"].ToString();

                            }
                            GR = ProjectDt.NewRow();
                            TaskUrl = "" + PWAURL + "/ReviewTSDetail.aspx?TSUID=" + TS_ID + "&Source=2";
                            TaskName = "My Timesheet";//timeDS.Lines[j][timeDS.Lines.TS_LINE_CACHED_ASSIGN_NAMEColumn].ToString();
                            GR["IsTimeSheet"] = true;
                            GR["Approval_Type"] = "Timesheet";
                            ProjName = timeDS.Lines[j][timeDS.Lines.TS_LINE_CACHED_PROJ_NAMEColumn].ToString();
                            GR["TASK_NAME"] = TaskName;
                            GR["PROJ_NAME"] = ProjName;
                            GR["Update_Type"] = string.Empty;
                            GR["RES_NAME"] = timeDS.Headers[counter][timeDS.Headers.TS_CACHED_RES_NAMEColumn].ToString();
                            GR["ASSN_UID"] = timeDS.Headers[counter][timeDS.Headers.TS_UIDColumn].ToString();
                            GR["PROJ_UID"] = string.Empty;
                            GR["Gid"] = Gcount;
                            GR["RES_NAME_OWNER"] = string.Empty;
                            GR["ASSN_TRANS_COMMENT"] = string.Empty;
                            GR["ASSN_TRANS_SUBMIT_DATE"] = string.Empty;
                            GR["ASSN_START_DATE"] = Convert.ToDateTime(PeriodStartDate).ToShortDateString();
                            GR["ASSN_FINISH_DATE"] = Convert.ToDateTime(PeriodFinishDate).ToShortDateString();
                            GR["ASSN_ACT_WORK"] = ((Convert.ToDouble(timeDS.Lines[j][timeDS.Lines.TS_LINE_ACT_SUM_VALUEColumn]) / 60000).ToString() + "h");
                            GR["ASSN_PCT_WORK_COMPLETE"] = string.Empty;
                            GR["ASSN_REM_WORK"] = string.Empty;
                            GR["TASK_HIERARCHY"] = string.Empty;
                            /**********Add Row in DataTable*************/
                            ProjectDt.Rows.Add(GR);
                            Gcount++;
                        }
                    }
                }
            }
            catch (Exception ex)
            { }

            Dictionary<DataTable, DataTable> result = new Dictionary<DataTable, DataTable>();
            result.Add(ProjectDt, DT_ActualPlanned);
            return result;
        }
       
    }
    public class ApprovalCenter
    {
        public string ApprovalType { get; set; }
        public string ASSNUID { get; set; }
        public string ProjectUid { get; set; }
        public string TaskName { get; set; }
        public string ProjectName { get; set; }
        public string UpdateType { get; set; }
        public string Resource { get; set; }
        public string Owner { get; set; }
        public string TransectionComment { get; set; }
        public string SentDate { get; set; }
        public string StartDate { get; set; }
        public string FinishDate { get; set; }
        public string Total { get; set; }
        public string percentageComplete { get; set; }
        public string RemainingWork { get; set; }
    }
}

 

Click here to download code


Comments

  1. Hello, i’m interested to implement my own Approval Center with additional functionality and your post looks like a good starting point.

    It would be great if you have screenshots of how your Approval Center implementation looks in working environment, could you please post them?

    1. This is a console application, now it’s up to you on which format you want to show data. If you need design same as default custom approval center, I can help you.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

error: Content is protected !!