none
Timesheet data is returning no value with psi RRS feed

  • Question

  • To whom it may concern:

    I had been using the sdk to work with psi.  I am new to psi.  Trying to read some data off the project server.  I was able to read it with no problem.  Now, I am putting the program together.   It does contains two records in the database.  But with the current code I have, I am not returning any value.  Am I doing something wrong?  Any help will my truly appreciate. 

    Thanks,

    kkmick

     

          public static void ReadTimeSheet()
            {
              
                List<string> timesheethold = new List<string>();
                SqlConnection conn;
                SqlDataReader sdr;

                conn = new SqlConnection("Data Source=xxx;Initial Catalog=Prod_ProjectServer_Reporting; Integrated Security=SSPI");           
                conn.Open();

                string sqlString = "select t.perioduid, startdate, enddate, timesheetuid,  OwnerResourceNameUID from msp_timesheetperiod t        inner join msp_timesheet m on t.perioduid= m.perioduid and m.timesheetstatusid=3";
                SqlCommand cmd = new SqlCommand(sqlString, conn);

                sdr = cmd.ExecuteReader();

                while(sdr.Read())
                {
                    sPeriodGuid =sdr[0].ToString();
                    sStartDate = sdr[1].ToString();
                    sEndDate = sdr[2].ToString();
                    sTimesheetUid = sdr[3].ToString();
                    sResourceUid = sdr[4].ToString(); 
                 
                    timesheethold.Add (sPeriodGuid);
                    timesheethold.Add(sStartDate);
                    timesheethold.Add(sEndDate);
                    timesheethold.Add(sTimesheetUid);
                    timesheethold.Add(sResourceUid);

                    
                }

                string str;
                foreach (object obj in timesheethold)
                {
                  
                    sPeriodGuid = timesheethold[0].ToString();
                    sStartDate = timesheethold[1].ToString();
                    sEndDate = timesheethold[2].ToString();
                    sTimesheetUid = timesheethold[3].ToString();
                    sResourceUid = timesheethold[4].ToString();


                    //declare the dataset
                    WebSvcTimesheet.TimesheetDataSet timesheetDs;

                    //Resource Credentials
                    resource.Url = PROJECT_SERVER_URI + RESOURCE_SERVICE_PATH;
                    resource.Credentials = CredentialCache.DefaultCredentials;

                    //Timesheet Credentials
                    timesheet.Url = PROJECT_SERVER_URI + TIMESHEET_SERVICE_PATH;
                    timesheet.Credentials = CredentialCache.DefaultCredentials;


                    // AdminWebSvc.Admin adminSvc = new AdminWebSvc.Admin();
                    admin.Url = PROJECT_SERVER_URI + ADMIN_SERVICE_PATH;
                    admin.UseDefaultCredentials = true;

                    DateTime startDate = Convert.ToDateTime(sStartDate);
                    DateTime finishDate = Convert.ToDateTime(sEndDate);

                    Guid gPeriodGuid = new Guid(sPeriodGuid);
                    Guid gResourceGuid = new Guid(sResourceUid);


                    XXXProjectServerExport.WebSvcAdmin.TimePeriodDataSet timeperiodDs = admin.ReadPeriods(xxxProjectServerExport.WebSvcAdmin.PeriodState.All);

                    timesheetDs = timesheet.ReadTimesheetByPeriod(gResourceGuid, gPeriodGuid, xxxProjectServerExport.WebSvcTimesheet.Navigation.Current);


                    foreach (WebSvcTimesheet.TimesheetDataSet.ActualsRow actual in timesheetDs.Actuals)

                    {

                        decimal billable_overtime_milliseconds = actual.TS_ACT_OVT_VALUE;

                        decimal billable_milliseconds = actual.TS_ACT_VALUE;

                        decimal non_billable_overtime_milliseconds = actual.TS_ACT_NON_BILLABLE_OVT_VALUE;

                        decimal non_billable_milliseconds = actual.TS_ACT_NON_BILLABLE_VALUE;


                    }


                }

     

    Friday, June 18, 2010 2:11 PM

Answers

  • Hi kkmick,

    try this code to read your timesheet.

    public static void ReadTimeSheet()
    {
     //Timesheet Credentials
        timeSheetWS.Url = PROJECT_SERVER_URI + TIMESHEET_SERVICE_PATH;
        timeSheetWS.Credentials = CredentialCache.DefaultCredentials;
      
     WebSvcTimesheet.TimesheetListDataSet timeSheetList = timeSheetWS.ReadTimesheetList(userUID, date, date, 1);
        Guid timeSheetUID = (Guid)timeSheetList.Tables[0].Rows[timeSheetList.Tables[0].Rows.Count - 1]["TS_UID"];    
        WebSvcTimesheet.TimesheetDataSet timeSheetDS = timeSheetWS.ReadTimesheet(timeSheetUID);

        foreach (WebSvcTimesheet.TimesheetDataSet.ActualsRow actual in timesheetDs.Actuals)
        {
           decimal billable_overtime_milliseconds = actual.TS_ACT_OVT_VALUE;

            decimal billable_milliseconds = actual.TS_ACT_VALUE;

            decimal non_billable_overtime_milliseconds = actual.TS_ACT_NON_BILLABLE_OVT_VALUE;

            decimal non_billable_milliseconds = actual.TS_ACT_NON_BILLABLE_VALUE;
        }
    }

    Best regards,

    Jorge.

    [ The ultimate for Project Server 2007 || http://www.projecttimesheet.com/about-en.php ]

    Tuesday, June 22, 2010 9:41 AM
  • Hi Jorge:

    The code that you gave me it works perfectly.  I really appreciate your help with it. 

    Thanks,

    kkmick

     

     

     

    • Marked as answer by kkmick Wednesday, June 23, 2010 8:36 PM
    Wednesday, June 23, 2010 8:36 PM

All replies

  • Hi kkmick,

    try this code to read your timesheet.

    public static void ReadTimeSheet()
    {
     //Timesheet Credentials
        timeSheetWS.Url = PROJECT_SERVER_URI + TIMESHEET_SERVICE_PATH;
        timeSheetWS.Credentials = CredentialCache.DefaultCredentials;
      
     WebSvcTimesheet.TimesheetListDataSet timeSheetList = timeSheetWS.ReadTimesheetList(userUID, date, date, 1);
        Guid timeSheetUID = (Guid)timeSheetList.Tables[0].Rows[timeSheetList.Tables[0].Rows.Count - 1]["TS_UID"];    
        WebSvcTimesheet.TimesheetDataSet timeSheetDS = timeSheetWS.ReadTimesheet(timeSheetUID);

        foreach (WebSvcTimesheet.TimesheetDataSet.ActualsRow actual in timesheetDs.Actuals)
        {
           decimal billable_overtime_milliseconds = actual.TS_ACT_OVT_VALUE;

            decimal billable_milliseconds = actual.TS_ACT_VALUE;

            decimal non_billable_overtime_milliseconds = actual.TS_ACT_NON_BILLABLE_OVT_VALUE;

            decimal non_billable_milliseconds = actual.TS_ACT_NON_BILLABLE_VALUE;
        }
    }

    Best regards,

    Jorge.

    [ The ultimate for Project Server 2007 || http://www.projecttimesheet.com/about-en.php ]

    Tuesday, June 22, 2010 9:41 AM
  • Hi Jorge:

    Thanks again.  I really appreicate your assistance.  You have been absolutely very helpful. 

    Thanks,

    kkmick.

     

     

    Tuesday, June 22, 2010 1:31 PM
  • Hi Jorge:

    The code that you gave me it works perfectly.  I really appreciate your help with it. 

    Thanks,

    kkmick

     

     

     

    • Marked as answer by kkmick Wednesday, June 23, 2010 8:36 PM
    Wednesday, June 23, 2010 8:36 PM