Compartilhar via


TimeSheet.ReadTimesheetList método

Lê um quadro de horários resumo destinadas ao recurso especificado dentro do intervalo de datas especificado.

Namespace:  WebSvcTimeSheet
Assembly:  ProjectServerServices (em ProjectServerServices.dll)

Sintaxe

'Declaração
<SoapDocumentMethodAttribute("https://schemas.microsoft.com/office/project/server/webservices/TimeSheet/ReadTimesheetList", RequestNamespace := "https://schemas.microsoft.com/office/project/server/webservices/TimeSheet/",  _
    ResponseNamespace := "https://schemas.microsoft.com/office/project/server/webservices/TimeSheet/",  _
    Use := SoapBindingUse.Literal, ParameterStyle := SoapParameterStyle.Wrapped)> _
Public Function ReadTimesheetList ( _
    resUID As Guid, _
    startDate As DateTime, _
    finishDate As DateTime, _
    select As Integer _
) As TimesheetListDataSet
'Uso
Dim instance As TimeSheet
Dim resUID As Guid
Dim startDate As DateTime
Dim finishDate As DateTime
Dim select As Integer
Dim returnValue As TimesheetListDataSet

returnValue = instance.ReadTimesheetList(resUID, _
    startDate, finishDate, select)
[SoapDocumentMethodAttribute("https://schemas.microsoft.com/office/project/server/webservices/TimeSheet/ReadTimesheetList", RequestNamespace = "https://schemas.microsoft.com/office/project/server/webservices/TimeSheet/", 
    ResponseNamespace = "https://schemas.microsoft.com/office/project/server/webservices/TimeSheet/", 
    Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
public TimesheetListDataSet ReadTimesheetList(
    Guid resUID,
    DateTime startDate,
    DateTime finishDate,
    int select
)

Parâmetros

  • startDate
    Tipo: System.DateTime

    A data de quadro de horários mais antiga para retornar.

  • finishDate
    Tipo: System.DateTime

    A data de quadro de horários mais recente para retornar.

Valor retornado

Tipo: WebSvcTimeSheet.TimesheetListDataSet
DataSet com uma lista resumida de quadros de horários que satisfazem os parâmetros.

Comentários

Use um valor de Microsoft.Office.Project.Server.Library.TimesheetEnum.ListSelect para o parâmetro select . Você pode combinar os valores de ListSelect com a operação OR filtrar uma combinação das propriedades. Por exemplo, para selecionar todos os quadros de horários que criou o usuário que estejam em andamento, defina o parâmetro selectCreatedByMeORInProgress.

Para retornar todos os quadros de horários mais de um registro vazio por um período em que não há nenhum quadro de horários, defina select como TimeSheetEnum.ListSelect.AllPeriods.

ReadTimesheetList ignora resUID se o valor de select é apenas CreatedByMe. Para obter uma lista de quadros de horários de outra pessoa que foram criados por você — ou seja, quadros de horários para os quais você é o substituto — passar o GUID de recurso do outro usuário no resUID e um valor para select que é uma operação OR entre CreatedByMe e InProgress, Submitted, Acceptable, Approved, Rejectedou AllExisting.

Datas válidas no Project Server são 1 de janeiro de 1984 até 31 de dezembro de 2049.

Este método usa o objeto QueueSystem . A propriedade CorrelationGUID para o trabalho é igual ao valor da propriedade TS_UID .

Permissões do Project Server

Permissão

Descrição

Não padrão

O usuário atual é o proprietário do quadro de horários, ou o valor de select é CreatedByMe.

ViewResourceTimesheet

Permite ao usuário exibir os quadros de horários para um recurso. Aplica-se apenas se o usuário atual não é o proprietário do quadro de horários. Permissão global.

Exemplos

O exemplo de código a seguir lê todos os quadros de horários intervalo de datas especificado que são criados pelo usuário e que estejam em andamento. O exemplo usa a classe TimeSheetUtils e a classe de ExceptionHandlers para separar a funcionalidade da classe Program . O método TimeSheetUtils.GetMyTimeSheetsInProgress usa o método GetCurrentUserUid no serviço da web de recurso para retornar o GUID do usuário.

For information about compiling the sample, see Prerequisites for Reference Code Samples.

using System;
using System.Net;
using System.Web.Services.Protocols;
using PSLibrary = Microsoft.Office.Project.Server.Library;

namespace Microsoft.SDK.Project.Samples.TestTimesheet
{
   class Program
   {
      private static TimeSheetWebSvc.TimeSheet timesheet =
         new TimeSheetWebSvc.TimeSheet();
      private static ResourceWebSvc.Resource resource =
         new ResourceWebSvc.Resource();

      private static TimeSheetUtils timeSheetUtils = new TimeSheetUtils();
      private static ExceptionHandlers exceptionHandlers = new ExceptionHandlers();

      [STAThread]
      static void Main()
      {
         try
         {
            const string PROJECT_SERVER_URI = "http:// ServerName/ProjectServerName/";
            const string RESOURCE_SERVICE_PATH = "_vti_bin/psi/resource.asmx";
            const string TIMESHEET_SERVICE_PATH = "_vti_bin/psi/timesheet.asmx";

            // Set up the web service objects.
            resource.Url = PROJECT_SERVER_URI + RESOURCE_SERVICE_PATH;
            resource.Credentials = CredentialCache.DefaultCredentials;

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

            // Get timesheet information for the specified dates.
            DateTime startDate = new DateTime(2006, 11, 27);
            DateTime finishDate = new DateTime(2006, 12, 1);
            Guid resUid;

            TimeSheetWebSvc.TimesheetListDataSet dsTimeSheetList = 
               timeSheetUtils.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);
            }
         }
         catch (SoapException ex)
         { exceptionHandlers.HandleSoapException(ex); }
         catch (WebException ex)
         { exceptionHandlers.HandleWebException(ex); }
         catch (Exception ex)
         { exceptionHandlers.HandleException(ex); }
         finally
         { exceptionHandlers.ResetConsole(); }
      }
   }

   class TimeSheetUtils
   {
      public TimeSheetUtils()
      {
      }

      // Get a list of timesheets that were created by the user and that are in progress.
      public TimeSheetWebSvc.TimesheetListDataSet GetMyTimeSheetsInProgress(
          TimeSheetWebSvc.TimeSheet timesheet,
          ResourceWebSvc.Resource resource,
          DateTime startDate,
          DateTime finishDate,
         out Guid resUid)
      {
         int select = Convert.ToInt32(
                         PSLibrary.TimesheetEnum.ListSelect.CreatedByMe
                       | PSLibrary.TimesheetEnum.ListSelect.InProgress);

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

   class ExceptionHandlers
   {
      public ExceptionHandlers()
      {
      }

      public void HandleSoapException(SoapException ex)
      {
         PSLibrary.PSClientError error = new PSLibrary.PSClientError(ex);
         PSLibrary.PSErrorInfo[] errors = error.GetAllErrors();
         string errMess = "==============================\r\nError: \r\n";
         for (int i = 0; i < errors.Length; i++)
         {
            errMess += "\n" + ex.Message.ToString() + "\r\n";
            errMess += "".PadRight(30, '=') + "\r\nPSCLientError Output:\r\n \r\n";
            errMess += errors[i].ErrId.ToString() + "\n";

            for (int j = 0; j < errors[i].ErrorAttributes.Length; j++)
            {
               errMess += "\r\n\t" + errors[i].ErrorAttributeNames()[j] + ": "
                  + errors[i].ErrorAttributes[j];
            }
            errMess += "\r\n".PadRight(30, '=');
         }
         Console.ForegroundColor = ConsoleColor.Red;
         Console.WriteLine(errMess);
      }

      public void HandleWebException(WebException ex)
      {
         string errMess = ex.Message.ToString() +
            "\n\nLog on, or check the Project Server Queuing Service";
         Console.ForegroundColor = ConsoleColor.Red;
         Console.WriteLine("Error: " + errMess);
      }

      public void HandleException(Exception ex)
      {
         Console.ForegroundColor = ConsoleColor.Red;
         Console.WriteLine("Error: " + ex.Message);
      }

      public void ResetConsole()
      {
         Console.ResetColor();
         Console.WriteLine("\r\n\r\nPress any key...");
         Console.ReadKey();
      }
   }
}

Ver também

Referência

TimeSheet classe

TimeSheet membros

WebSvcTimeSheet namespace