Метод TimeSheet.ReadTimesheetList
Считывает сводки для заданного ресурса в пределах за указанный диапазон дат расписания.
Пространство имен: WebSvcTimeSheet
Сборка: ProjectServerServices (в ProjectServerServices.dll)
Синтаксис
'Декларация
<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
'Применение
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
)
Параметры
resUID
Тип: System.GuidGUID ресурса.
startDate
Тип: System.DateTimeДата раннюю табеля учета рабочего времени для возвращения.
finishDate
Тип: System.DateTimeДата последней табеля учета рабочего времени для возвращения.
select
Тип: System.Int32Фильтр для состояние расписания; с помощью TimesheetEnum.ListSelect.
Возвращаемое значение
Тип: WebSvcTimeSheet.TimesheetListDataSet
DataSet с сводный список расписаний, удовлетворяют параметры.
Замечания
Используйте Microsoft.Office.Project.Server.Library.TimesheetEnum.ListSelect значение для параметра select . Значения ListSelect можно объединить с OR операции для фильтрации для сочетания свойств. Например чтобы выбрать все расписания, которые созданы пользователя, которые находятся в процессе выполнения, установите для параметра selectORCreatedByMeInProgress.
Для возврата всех расписаний, а также пустую запись для периода Если нет табеля учета рабочего времени, значение selectTimeSheetEnum.ListSelect.AllPeriods.
ReadTimesheetList игнорирует resUID , если значение select только CreatedByMe. Чтобы получить список расписаний другого пользователя, которые были созданы вами — то есть, расписаний, для которого вы являетесь заменяющего — передать другим пользователем GUID ресурса в resUID и значение для select , который является операции OR между CreatedByMe и InProgress, Submitted, Acceptable, Approved, Rejectedили AllExisting.
Допустимый даты в Project Server — 1 января 1984 до 31 декабря 2049.
Этот метод использует объект QueueSystem . Свойство CorrelationGUID для задания равно значению свойства TS_UID .
Разрешения Project Server
Разрешение |
Описание |
---|---|
Нестандартные |
Текущий пользователь является владельцем табеля учета рабочего времени или CreatedByMeимеет значение select . |
Позволяет пользователям просматривать расписания для ресурса. Применяется только в том случае, если текущий пользователь не является его владельцем. Глобальное разрешение. |
Примеры
В следующем примере кода считывает все расписания в указанный диапазон дат, созданные пользователем, и в число которых входят в стадии разработки. В примере используется класс TimeSheetUtils и ExceptionHandlers classe отделения функциональные возможности от класса Program . Метод TimeSheetUtils.GetMyTimeSheetsInProgress использует метод GetCurrentUserUid в веб-службе ресурсов возвращает идентификатор GUID пользователя.
For information about compiling the sample, see Необходимые условия для образцов кода на основе ASMX в Project 2013.
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();
}
}
}