locked
PSI ERROR RRS feed

  • Question

  • Hello:

    I am using Project Server 2007.

    I keep on getting this error.  I am using the example on the sdk to get an idea how to use the PSI.  I am trying to read the timesheet on our project server.   Error Message:  The value for column 'TS_UID' in table 'Timesheets' is DBNull.  I know we have two timesheets in project server.   I have tried to use a different column.  It still throws an exception. 

      I appreciate any assistance or idea to fix this issue. 

    Thanks,

    kkmick

    using

     

    System;

    using

     

    System.Collections.Generic;

    using

     

    System.Net;

    using

     

    System.Web.Services.Protocols;

    using

     

    PSLibrary = Microsoft.Office.Project.Server.Library;

    using

     

    System.Text;

    namespace

     

    ABCTimesheet

    {

     

    class TimesheetUtil

    {

     

    const string PROJECT_SERVER_URI = "http://Server/pwa/";

     

    const string RESOURCE_SERVICE_PATH = "_vti_bin/PSI/resource.asmx";

     

    const string TIMESHEET_SERVICE_PATH = "_vti_bin/PSI/timesheet.asmx";

     

    string uid;

     

    private static WebSvcTimesheet.TimeSheet timesheet =

     

    new WebSvcTimesheet.TimeSheet();

     

    private static WebSvcResource.Resource resource =

     

    new WebSvcResource.Resource();

     

     

    public TimesheetUtil()

    {

    }

     

     

     

    private WebSvcTimesheet.TimesheetListDataSet GetMyTimeSheetsInProgress

    (WebSvcTimesheet.

    TimeSheet timesheet,

    WebSvcResource.

    Resource resource,

     

    DateTime startDate,

     

    DateTime finishDate,

     

    out Guid resUid)

    {

     

    int select = Convert.ToInt32(

    PSLibrary.

    TimesheetEnum.ListSelect.AllPeriods

    | PSLibrary.

    TimesheetEnum.ListSelect.InProgress);

     

    Guid objguid;

     

    string myguidString = "6ADC0A32-1B6D-489B-B5BF-C02DAB514450";

    objguid =

    new Guid(myguidString);

    resUid = objguid;

     

    //resUid = resource.GetCurrentUserUid();

     

    return timesheet.ReadTimesheetList(resUid, startDate, finishDate, select);

     

     

    }

     

    public string DisplayData()

    {

     

     

    try

    {

     

    //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;

     

    DateTime startDate = new DateTime(2010, 05, 01);

     

    DateTime finishDate = new DateTime(2010, 05, 31);

     

    Guid resUid;

     

    WebSvcTimesheet.

    TimesheetListDataSet dsTimeSheetList =

    GetMyTimeSheetsInProgress(timesheet, resource, startDate, finishDate,

    out resUid);

     

     

     

    Console.WriteLine("Active timesheets for resource: " + resUid.ToString());

     

    Console.WriteLine(string.Format("\tStart date: {0}\r\n\tFinish date: {1}",

    startDate.ToString(), finishDate.ToString()));

     

    for (int i = 0; i < dsTimeSheetList.Timesheets.Count; i++)

    {

     

    Console.WriteLine(dsTimeSheetList.Timesheets[i].TS_UID.ToString(),

    dsTimeSheetList.Timesheets[i].TS_NAME);

    uid = dsTimeSheetList.Timesheets[i].TS_NAME;

    }

     

     

    }

     

    catch (SoapException ex)

    { ex.Message.ToString(); }

     

    catch (WebException ex)

    { ex.Message.ToString(); }

     

    return uid;

    }

     

    }

     

     

    }

     

     

     

     

     

     

     

     

    Thursday, June 3, 2010 3:00 PM

Answers

  • Thanks Boaz.  I used the ReadTimesheetperiod instead.  It seems that works  better for me.  Thank you for giving me an idea. 

     

    Thanks

    kkmick

    • Marked as answer by kkmick Monday, June 14, 2010 8:31 PM
    Monday, June 14, 2010 8:31 PM

All replies

  • Hi kkmick,

    Unfortunately your code hasn't formatted well and is a little difficult to read.  You say you have two timesheets in Project Server - are they your timesheets?  Do they have any lines in them?  If you are just beggining with the pSi you might want to try some of the more complete examples such as projtool and the logindemo first, if you haven't already.

    best regards,

    Brian.

    Friday, June 4, 2010 2:16 PM
  • Brian:

    I tried to delete the post.  That did not work out with the code portion.   I was using the code format button in html . It still came up like that. Let me try to post the code again without clicking on it. 

    They are not my timesheets.  I used the person resource id to try to retrieve it. 

    I am using the login demo code to loginto the server.  But I was not able to locate the code to read the timesheet. 

    Sorry about the code situation.   I should have try to repost it the third time. 

    Thanks,

    kkmick

    using System;
    using System.Collections.Generic;
    using System.Net;
    using System.Web.Services.Protocols;
    using PSLibrary = Microsoft.Office.Project.Server.Library;
    using System.Text;
    using System.Windows.Forms;


    namespace XXXTimesheet
    {
        class TimesheetUtil
        {

            const string PROJECT_SERVER_URI = "http://Server/pwa/";
            const string RESOURCE_SERVICE_PATH = "_vti_bin/PSI/resource.asmx";
            const string TIMESHEET_SERVICE_PATH = "_vti_bin/PSI/timesheet.asmx";
            string uid;

            private static WebSvcTimesheet.TimeSheet timesheet =
                new WebSvcTimesheet.TimeSheet();

            private static WebSvcResource.Resource resource =
                new WebSvcResource.Resource();

        

            public TimesheetUtil()
            {
            }

     

            private WebSvcTimesheet.TimesheetListDataSet GetMyTimeSheetsInProgress
            (WebSvcTimesheet.TimeSheet timesheet,
             WebSvcResource.Resource resource,
             DateTime startDate,
             DateTime finishDate,
             out Guid resUid)
            {

                int select = Convert.ToInt32(
                    PSLibrary.TimesheetEnum.ListSelect.AllPeriods
                  | PSLibrary.TimesheetEnum.ListSelect.InProgress);

                Guid objguid;         
                string myguidString = "6ADC0A32-1B6D-489B-B5BF-C02DAB514450";
                objguid = new Guid(myguidString);
                resUid = objguid;

                //resUid = resource.GetCurrentUserUid();
                return timesheet.ReadTimesheetList(resUid, startDate, finishDate, select);

     

            }

            public string DisplayData()
            {

              

                try
                {
                    //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;

                   

                    DateTime startDate = new DateTime(2010, 05, 01);
                    DateTime finishDate = new DateTime(2010, 05, 31);
                    Guid resUid;

       
               


                    WebSvcTimesheet.TimesheetListDataSet dsTimeSheetList =
                    GetMyTimeSheetsInProgress(timesheet, resource, startDate, finishDate, out resUid);
                       
                  

                    Console.WriteLine("Active timesheets for resource: " + resUid.ToString());
                    Console.WriteLine(string.Format("\tStart date: {0}\r\n\tFinish date: {1}",
                       startDate.ToString(), finishDate.ToString()));

                    for (int i = 0; i < dsTimeSheetList.Timesheets.Count; i++)
                    {
                        //MessageBox.Show(dsTimeSheetList.Timesheets[i].Table.Columns[0].ToString());
                        Console.WriteLine(dsTimeSheetList.Timesheets[i].TS_UID.ToString(),
                           dsTimeSheetList.Timesheets[i].TS_NAME);
                           //uid = dsTimeSheetList.Timesheets[i].TS_NAME;
                    }

                  
                        
                }
                catch (SoapException ex)
                { ex.Message.ToString(); }
                catch (WebException ex)
                { ex.Message.ToString(); }

                return uid;

            }
     
            }

     

    }

     

      

     

     

    Friday, June 4, 2010 3:17 PM
  • At what line in your code do you get the exception? If the UID of the timesheet data returned to you is DBNull, then I think doing a ToString() on it will certainly fail.

    Thanks,

    Boaz Lev

    Saturday, June 5, 2010 10:09 PM
  • Hi Boaz:

    It fails on   Console.WriteLine(dsTimeSheetList.Timesheets[i].TS_UID.ToString(),  dsTimeSheetList.Timesheets[i].TS_NAME).  I got this code from the logindemo from the 2007 project server sdk.  I had tried to take uid.tostring off.  Just leave ts_name.  It still fails.   I thought it fails because of it is a guid.  I used another column name .  It throws an exception as well. 

    Thanks,

    kkmick

     

    Monday, June 7, 2010 7:43 PM
  • What exception are you getting? You could try to inspect the returned data set in Visual Studio to see if it makes sense.

    Hope this helps,

    Boaz Lev

    MSFT

    Sunday, June 13, 2010 3:40 AM
  • Thanks Boaz.  I used the ReadTimesheetperiod instead.  It seems that works  better for me.  Thank you for giving me an idea. 

     

    Thanks

    kkmick

    • Marked as answer by kkmick Monday, June 14, 2010 8:31 PM
    Monday, June 14, 2010 8:31 PM