none
How can i enter time to a project using CSOM or PSI interfases in a Programm made in .NET (VS2013) RRS feed

  • Question

  • English...

    Hi every body, merry christmas to all of you and a Happy new year 2015.

    Today i have a question about, how can i report time to a task in Project Server 2013 (through pwa 2013), using programming techniques like CSOM or ODATA or PSI Interfases, I'm totally noob to this kind of programmatic interfaces... I plan to use VStudio 2013 IDE to this project.

    Spanish...

    Hola a todos, feliz navidad y próspero año nuevo 2015.

    Hoy tengo una pregunta, acerca de cómo puedo reportar tiempo a una tarea de Project Server 2013 (mediante pwa 2013), usando técnicas de programación como CSOM, oData, o PSI. Debo admitir que soy totalmente novato para este tipo de integraciones de programación... Planeo usar la IDE de VStudio 2013 para este proyecto.

    Cordialmente.

    Camilo Villa.


    Camilo Villa

    Friday, December 26, 2014 3:05 PM

Answers

  • Hi,

    If you are going thru PSI approach then first go through below link

    Prerequisites for WCF-based code samples in Project 2013

    Then there are few things you have to consider while working with time-sheet operations.

    1) If current week timesheet is not created, create new one

    SvcTimeSheet.TimesheetDataSet tsCurr_ds = new SvcTimeSheet.TimesheetDataSet();
    
    tsCurr_ds = timesheetClient.ReadTimesheetByPeriod(ResourceUID, currentTPUID, SvcTimeSheet.Navigation.Current);
    
     if (tsCurr_ds.Headers.Count < 1)
    
    then create new one
    
    {
    
    tsCurr_ds = new TimesheetDataSet();
                    TimesheetDataSet.HeadersRow headersRow = tsCurr_ds.Headers.NewHeadersRow();
                    headersRow.RES_UID = ResourceUID;
                    headersRow.TS_UID = Guid.NewGuid();
                    headersRow.WPRD_UID = currentTPUID;
                    headersRow.TS_CREATOR_RES_UID = ResourceUID;
                    headersRow.TS_NAME = "My Timesheet";
                    headersRow.TS_COMMENTS = "Auto created by PS-Admin";
                    headersRow.TS_ENTRY_MODE_ENUM = (byte)PSLibrary.TimesheetEnum.EntryMode.Daily;
                    tsCurr_ds.Headers.AddHeadersRow(headersRow);
                    timesheetClient.CreateTimesheet(tsCurr_ds, PreloadType.Default);
    
    }


    else update existing one

    {
    
    TimesheetDataSet.LinesRow line = tsCurr_ds.Lines.NewLinesRow();
                    line.TS_UID = CurrTS_guid;
                    line.TS_LINE_UID = Guid.NewGuid();
                    line.TS_LINE_CLASS_UID = Class_UID;
                    line.PROJ_UID = PROJ_UID;
                    line.ASSN_UID = ASSN_UID;
                    line.TASK_UID = TASK_UID;
                    line.TS_LINE_CACHED_PROJ_NAME = PROJ_NAME;
                    line.TS_LINE_COMMENT = "";
                    line.TS_LINE_STATUS = LINE_STATUS;
                    line.TS_LINE_VALIDATION_TYPE = VALIDATION_TYPE;
                    line.TS_LINE_CACHED_ASSIGN_NAME = ASSIGNEE_NAME;
                    tsCurr_ds.Lines.AddLinesRow(line);
                    timesheetClient.PrepareTimesheetLine(CurrTS_guid, ref tsCurr_ds, new Guid[] { line.TS_LINE_UID });
    
    Guid jobUID = Guid.NewGuid();
                        timesheetClient.QueueUpdateTimesheet(jobUID, CurrTS_guid, tsCurr_ds);
                        WaitForQueue(queuesystemClient, jobUID);
                        myLog.WriteEntry("Timesheet has been updated for: " + ResourceName, EventLogEntryType.Information, 3211);
    
    }
    
    


    Note: Above is small code snippet just a part of one of my custom timesheet application where I am automating the timecard creation and updation process weekly.

    Please go through the above link, and also go through WebSvcTimeSheet namespace and its containing timesheet classes.

    Thanks and let me know in case need further details



    Sachin Vashishth MCTS

    Tuesday, December 30, 2014 8:31 AM

All replies

  • Hi Camilo,

    You can use CSOM and PSI to report you time to a task assigned to you. CSOM seems to be little bit easier approach comparing to using PSI.

    Because the CSOM internally calls the PSI; therefore, if the PSI cannot do a job, neither can the CSOM.

    For detail understanding you can access below links

    http://msdn.microsoft.com/en-us/library/office/ms504195%28v=office.15%29.aspx

    Getting started with the Project Server CSOM and .NET

    Project 2013 PSI reference overview

    Download Project Server 2013 SDK and go through the examples

    Project Server 2013 SDK

    Hope this will help !!!

    Thanks !!!


    Sachin Vashishth MCTS

    Monday, December 29, 2014 8:18 AM
  • Hi Sachin

    Thanks for your response, I read the links that you comment me; but in the middle of all this, I can't find an especific site, or place, or example where they say how can I connect with an especific project-task to report time; for the other hand, I don't know what configurations has to be present on the environment (SharePoint - Project Server) to permit report time hourly... 


    Camilo Villa

    Monday, December 29, 2014 2:35 PM
  • Hi,

    If you are going thru PSI approach then first go through below link

    Prerequisites for WCF-based code samples in Project 2013

    Then there are few things you have to consider while working with time-sheet operations.

    1) If current week timesheet is not created, create new one

    SvcTimeSheet.TimesheetDataSet tsCurr_ds = new SvcTimeSheet.TimesheetDataSet();
    
    tsCurr_ds = timesheetClient.ReadTimesheetByPeriod(ResourceUID, currentTPUID, SvcTimeSheet.Navigation.Current);
    
     if (tsCurr_ds.Headers.Count < 1)
    
    then create new one
    
    {
    
    tsCurr_ds = new TimesheetDataSet();
                    TimesheetDataSet.HeadersRow headersRow = tsCurr_ds.Headers.NewHeadersRow();
                    headersRow.RES_UID = ResourceUID;
                    headersRow.TS_UID = Guid.NewGuid();
                    headersRow.WPRD_UID = currentTPUID;
                    headersRow.TS_CREATOR_RES_UID = ResourceUID;
                    headersRow.TS_NAME = "My Timesheet";
                    headersRow.TS_COMMENTS = "Auto created by PS-Admin";
                    headersRow.TS_ENTRY_MODE_ENUM = (byte)PSLibrary.TimesheetEnum.EntryMode.Daily;
                    tsCurr_ds.Headers.AddHeadersRow(headersRow);
                    timesheetClient.CreateTimesheet(tsCurr_ds, PreloadType.Default);
    
    }


    else update existing one

    {
    
    TimesheetDataSet.LinesRow line = tsCurr_ds.Lines.NewLinesRow();
                    line.TS_UID = CurrTS_guid;
                    line.TS_LINE_UID = Guid.NewGuid();
                    line.TS_LINE_CLASS_UID = Class_UID;
                    line.PROJ_UID = PROJ_UID;
                    line.ASSN_UID = ASSN_UID;
                    line.TASK_UID = TASK_UID;
                    line.TS_LINE_CACHED_PROJ_NAME = PROJ_NAME;
                    line.TS_LINE_COMMENT = "";
                    line.TS_LINE_STATUS = LINE_STATUS;
                    line.TS_LINE_VALIDATION_TYPE = VALIDATION_TYPE;
                    line.TS_LINE_CACHED_ASSIGN_NAME = ASSIGNEE_NAME;
                    tsCurr_ds.Lines.AddLinesRow(line);
                    timesheetClient.PrepareTimesheetLine(CurrTS_guid, ref tsCurr_ds, new Guid[] { line.TS_LINE_UID });
    
    Guid jobUID = Guid.NewGuid();
                        timesheetClient.QueueUpdateTimesheet(jobUID, CurrTS_guid, tsCurr_ds);
                        WaitForQueue(queuesystemClient, jobUID);
                        myLog.WriteEntry("Timesheet has been updated for: " + ResourceName, EventLogEntryType.Information, 3211);
    
    }
    
    


    Note: Above is small code snippet just a part of one of my custom timesheet application where I am automating the timecard creation and updation process weekly.

    Please go through the above link, and also go through WebSvcTimeSheet namespace and its containing timesheet classes.

    Thanks and let me know in case need further details



    Sachin Vashishth MCTS

    Tuesday, December 30, 2014 8:31 AM