Admin.ReadTimesheetAuditLog 方法
读取时间表审核期间指定的审核和时间表时段的时间范围内发生的日志事务。
命名空间: WebSvcAdmin
程序集: ProjectServerServices(位于 ProjectServerServices.dll 中)
语法
声明
<SoapDocumentMethodAttribute("https://schemas.microsoft.com/office/project/server/webservices/Admin/ReadTimesheetAuditLog", RequestNamespace := "https://schemas.microsoft.com/office/project/server/webservices/Admin/", _
ResponseNamespace := "https://schemas.microsoft.com/office/project/server/webservices/Admin/", _
Use := SoapBindingUse.Literal, ParameterStyle := SoapParameterStyle.Wrapped)> _
Public Function ReadTimesheetAuditLog ( _
auditStart As DateTime, _
auditFinish As DateTime, _
periodStart As DateTime, _
periodFinish As DateTime, _
auditType As AuditType _
) As TimesheetAuditExportDataSet
用法
Dim instance As Admin
Dim auditStart As DateTime
Dim auditFinish As DateTime
Dim periodStart As DateTime
Dim periodFinish As DateTime
Dim auditType As AuditType
Dim returnValue As TimesheetAuditExportDataSet
returnValue = instance.ReadTimesheetAuditLog(auditStart, _
auditFinish, periodStart, periodFinish, _
auditType)
[SoapDocumentMethodAttribute("https://schemas.microsoft.com/office/project/server/webservices/Admin/ReadTimesheetAuditLog", RequestNamespace = "https://schemas.microsoft.com/office/project/server/webservices/Admin/",
ResponseNamespace = "https://schemas.microsoft.com/office/project/server/webservices/Admin/",
Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
public TimesheetAuditExportDataSet ReadTimesheetAuditLog(
DateTime auditStart,
DateTime auditFinish,
DateTime periodStart,
DateTime periodFinish,
AuditType auditType
)
参数
auditStart
类型:System.DateTime审核的开始日期。
auditFinish
类型:System.DateTime审核的结束日期。
periodStart
类型:System.DateTime审核时间段的开始日期。
periodFinish
类型:System.DateTime要审核期结束的日期。
auditType
类型:WebSvcAdmin.AuditType审计调整、 资源或两者。
返回值
类型:WebSvcAdmin.TimesheetAuditExportDataSet
包含在指定日期的审核数据。
备注
早期版本的 Project Server 所必需的在要收集审核日志事务的报告数据库上运行的 SQL 查询。使用ReadTimesheetAuditLog提供一个方法调用,以代替查询。
Project Server 权限
权限 |
说明 |
---|---|
允许用户创建和修改时间表定义和财务周期定义。全局权限。 |
示例
下面的示例读取当前时间表审核日志,并将结果写入到 XML 文件。该示例使用 ProjectServerServices.dll 代理程序集在SvcAdmin命名空间。
备注
The ConfigClientEndpoints method uses an app.config file for setting the WCF binding, behavior, and endpoint. For information about creating a PSI proxy assembly and an app.config file, see Project 2013 中基于 WCF 的代码示例的先决条件.
using System;
using System.Text;
using System.ServiceModel;
using System.Xml;
using PSLibrary = Microsoft.Office.Project.Server.Library;
using SvcAdmin;
namespace Microsoft.SDK.Project.Samples.TestAdmin
{
class Program
{
private const string ENDPOINT = "basicHttp_Admin";
private const string OUTPUT_FILES = @"C:\Project\Samples\Output\";
private static SvcAdmin.AdminClient adminClient;
private static string outFilePath;
static void Main(string[] args)
{
outFilePath = OUTPUT_FILES + "TimeSheetAuditLog.xml";
ConfigClientEndpoints(ENDPOINT);
Console.WriteLine("Retrieving the timesheet audit log...");
// Get the audit log transactions for the current instance of Project Web Access.
try
{
// To set the parameters for reading the audit log, define
// the start date and end date for the audit and for the
// associated timesheet period. This sample uses the same
// dates for both, so that for the specified timesheet period,
// all of the log entries are read.
// The audit type indicates that both the resource and the adjuster are involved in the audit.
int startmonth = 2;
int startday = 1;
int startyear = 2011;
int finishmonth = 2;
int finishday = 28;
int finishyear = 2011;
DateTime auditStart = new DateTime(startyear, startmonth, startday);
DateTime auditFinish = new DateTime(finishyear, finishmonth, finishday);
DateTime periodStart = new DateTime(startyear, startmonth, startday);
DateTime periodFinish = new DateTime(finishyear, finishmonth, finishday);
SvcAdmin.TimesheetAuditExportDataSet timeSheetAuditLog = adminClient.ReadTimesheetAuditLog(auditStart, auditFinish, periodStart, periodFinish, AuditType.ByBoth);
// Write the audit log to an XML file.
timeSheetAuditLog.WriteXml(outFilePath);
}
catch (FaultException fault)
{
// Use the WCF FaultException, because the ASMX SoapException does not
// exist in a WCF-based application.
WriteFaultOutput(fault);
Console.Write("\nThe attempt to access the timesheet audit log has failed.");
}
Console.WriteLine("\nSee XML output of the timesheet audit log at:\n\t{0}",
outFilePath);
Console.Write("\nPress any key to exit... ");
Console.ReadLine();
}
// Extract a PSClientError object from the WCF FaultException object, and
// then display the exception details and each error in the PSClientError stack.
private static void WriteFaultOutput(FaultException fault)
{
string errAttributeName;
string errAttribute;
string errOut;
string errMess = "".PadRight(30, '=') + "\r\n"
+ "Error details: " + "\r\n";
PSLibrary.PSClientError error = Helpers.GetPSClientError(fault, out errOut);
errMess += errOut;
PSLibrary.PSErrorInfo[] errors = error.GetAllErrors();
PSLibrary.PSErrorInfo thisError;
for (int i = 0; i < errors.Length; i++)
{
thisError = errors[i];
errMess += "\r\n".PadRight(30, '=') + "\r\nPSClientError output:\r\n";
errMess += thisError.ErrId.ToString() + "\n";
for (int j = 0; j < thisError.ErrorAttributes.Length; j++)
{
errAttributeName = thisError.ErrorAttributeNames()[j];
errAttribute = thisError.ErrorAttributes[j];
errMess += "\r\n\t" + errAttributeName
+ ": " + errAttribute;
}
}
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(errMess);
Console.ResetColor();
}
// Use the endpoints that are defined in app.config to configure the client.
public static void ConfigClientEndpoints(string endpt)
{
adminClient = new SvcAdmin.AdminClient(endpt);
}
}
// Helper method: GetPSClientError.
class Helpers
{
/// <summary>
/// Extract a PSClientError object from the ServiceModel.FaultException,
/// for use in output of the GetPSClientError stack of errors.
/// </summary>
/// <param name="e"></param>
/// <param name="errOut">Shows that FaultException has more information
/// about the errors than PSClientError has. FaultException can also contain
/// other types of errors, such as failure to connect to the server.</param>
/// <returns>PSClientError object, for enumerating errors.</returns>
public static PSLibrary.PSClientError GetPSClientError(FaultException e,
out string errOut)
{
const string PREFIX = "GetPSClientError() returns null: ";
errOut = string.Empty;
PSLibrary.PSClientError psClientError = null;
if (e == null)
{
errOut = PREFIX + "Null parameter (FaultException e) passed in.";
psClientError = null;
}
else
{
// Get a ServiceModel.MessageFault object.
var messageFault = e.CreateMessageFault();
if (messageFault.HasDetail)
{
using (var xmlReader = messageFault.GetReaderAtDetailContents())
{
var xml = new XmlDocument();
xml.Load(xmlReader);
var serverExecutionFault = xml["ServerExecutionFault"];
if (serverExecutionFault != null)
{
var exceptionDetails = serverExecutionFault["ExceptionDetails"];
if (exceptionDetails != null)
{
try
{
errOut = exceptionDetails.InnerXml + "\r\n";
psClientError =
new PSLibrary.PSClientError(exceptionDetails.InnerXml);
}
catch (InvalidOperationException ex)
{
errOut = PREFIX + "Unable to convert fault exception info ";
errOut += "a valid Project Server error message. Message: \n\t";
errOut += ex.Message;
psClientError = null;
}
}
else
{
errOut = PREFIX + "The FaultException e is a ServerExecutionFault, "
+ "but does not have ExceptionDetails.";
}
}
else
{
errOut = PREFIX + "The FaultException e is not a ServerExecutionFault.";
}
}
}
else // No detail in the MessageFault.
{
errOut = PREFIX + "The FaultException e does not have any detail.";
}
}
errOut += "\r\n" + e.ToString() + "\r\n";
return psClientError;
}
}
}
下面是一部分的应用程序保存 ReadTimesheetAuditLog.xml 文件的示例。
备注
返回在示例中的审核日志信息是特定于Project Web App实例中已定义的项目。
<?xml version="1.0" standalone="yes"?>
<TimesheetAuditExportDataSet xmlns="https://schemas.microsoft.com/office/project/server/webservices/TimesheetAuditExportDataSet/">
<AuditExports>
<TS_LINE_UID>621da0b8-a428-4bb8-9eff-d4dc629a3e98</TS_LINE_UID>
<TS_UID>4776d822-5982-4c45-b2be-7c22be69d336</TS_UID>
<ASSN_UID>20492c14-d411-4e3c-9c64-e17151104486</ASSN_UID>
<TASK_UID>20492c14-d411-4e3c-9c64-e17151104486</TASK_UID>
<PROJ_UID>e38038fa-f8ca-47d1-bfd4-6b45b8462972</PROJ_UID>
<TS_LINE_CLASS_UID>20492c14-d411-4e3c-9c64-e17151104486</TS_LINE_CLASS_UID>
<TS_LINE_VALIDATION_TYPE>0</TS_LINE_VALIDATION_TYPE>
<TS_LINE_CACHED_ASSIGN_NAME>Administrative</TS_LINE_CACHED_ASSIGN_NAME>
<TS_LINE_CACHED_PROJ_NAME>Administrative</TS_LINE_CACHED_PROJ_NAME>
<TS_ACT_AUD_UID>0b7fb2dc-171e-45ec-93d1-02ce767ae139</TS_ACT_AUD_UID>
<TS_ACT_AUD_OPERATION_ENUM>1</TS_ACT_AUD_OPERATION_ENUM>
<TS_ACT_START_DATE>2011-02-07T00:00:00-08:00</TS_ACT_START_DATE>
<TS_ACT_FINISH_DATE>2011-02-07T23:59:59-08:00</TS_ACT_FINISH_DATE>
<TS_ACT_AUD_SEQUENCE>1</TS_ACT_AUD_SEQUENCE>
<RES_UID>2e0fdcc1-85fc-4bde-9593-78a2789c66af</RES_UID>
<TS_ACT_AUD_DELTA_VALUE>480000.000000</TS_ACT_AUD_DELTA_VALUE>
<TS_ACT_AUD_OVT_DELTA_VALUE>0.000000</TS_ACT_AUD_OVT_DELTA_VALUE>
<TS_ACT_AUD_NONBILL_DELTA_VALUE>0.000000</TS_ACT_AUD_NONBILL_DELTA_VALUE>
<TS_ACT_AUD_NONBILL_OVT_DELTA_VALUE>0.000000</TS_ACT_AUD_NONBILL_OVT_DELTA_VALUE>
<TS_ACT_AUD_CACHED_RES_NAME>Mina Edison</TS_ACT_AUD_CACHED_RES_NAME>
<TS_ACT_AUD_RES_ROLE>2</TS_ACT_AUD_RES_ROLE>
</AuditExports>
<AuditExports>
<TS_LINE_UID>621da0b8-a428-4bb8-9eff-d4dc629a3e98</TS_LINE_UID>
<TS_UID>4776d822-5982-4c45-b2be-7c22be69d336</TS_UID>
<ASSN_UID>20492c14-d411-4e3c-9c64-e17151104486</ASSN_UID>
<TASK_UID>20492c14-d411-4e3c-9c64-e17151104486</TASK_UID>
<PROJ_UID>e38038fa-f8ca-47d1-bfd4-6b45b8462972</PROJ_UID>
<TS_LINE_CLASS_UID>20492c14-d411-4e3c-9c64-e17151104486</TS_LINE_CLASS_UID>
<TS_LINE_VALIDATION_TYPE>0</TS_LINE_VALIDATION_TYPE>
<TS_LINE_CACHED_ASSIGN_NAME>Administrative</TS_LINE_CACHED_ASSIGN_NAME>
<TS_LINE_CACHED_PROJ_NAME>Administrative</TS_LINE_CACHED_PROJ_NAME>
<TS_ACT_AUD_UID>0b7fb2dc-171e-45ec-93d1-02ce767ae139</TS_ACT_AUD_UID>
<TS_ACT_AUD_OPERATION_ENUM>1</TS_ACT_AUD_OPERATION_ENUM>
<TS_ACT_START_DATE>2011-02-08T00:00:00-08:00</TS_ACT_START_DATE>
<TS_ACT_FINISH_DATE>2011-02-08T23:59:59-08:00</TS_ACT_FINISH_DATE>
<TS_ACT_AUD_SEQUENCE>2</TS_ACT_AUD_SEQUENCE>
<RES_UID>2e0fdcc1-85fc-4bde-9593-78a2789c66af</RES_UID>
<TS_ACT_AUD_DELTA_VALUE>480000.000000</TS_ACT_AUD_DELTA_VALUE>
<TS_ACT_AUD_OVT_DELTA_VALUE>0.000000</TS_ACT_AUD_OVT_DELTA_VALUE>
<TS_ACT_AUD_NONBILL_DELTA_VALUE>0.000000</TS_ACT_AUD_NONBILL_DELTA_VALUE>
<TS_ACT_AUD_NONBILL_OVT_DELTA_VALUE>0.000000</TS_ACT_AUD_NONBILL_OVT_DELTA_VALUE>
<TS_ACT_AUD_CACHED_RES_NAME>Mina Edison</TS_ACT_AUD_CACHED_RES_NAME>
<TS_ACT_AUD_RES_ROLE>2</TS_ACT_AUD_RES_ROLE>
</AuditExports>
<AuditExports>
<TS_LINE_UID>621da0b8-a428-4bb8-9eff-d4dc629a3e98</TS_LINE_UID>
<TS_UID>4776d822-5982-4c45-b2be-7c22be69d336</TS_UID>
<ASSN_UID>20492c14-d411-4e3c-9c64-e17151104486</ASSN_UID>
<TASK_UID>20492c14-d411-4e3c-9c64-e17151104486</TASK_UID>
<PROJ_UID>e38038fa-f8ca-47d1-bfd4-6b45b8462972</PROJ_UID>
<TS_LINE_CLASS_UID>20492c14-d411-4e3c-9c64-e17151104486</TS_LINE_CLASS_UID>
<TS_LINE_VALIDATION_TYPE>0</TS_LINE_VALIDATION_TYPE>
<TS_LINE_CACHED_ASSIGN_NAME>Administrative</TS_LINE_CACHED_ASSIGN_NAME>
<TS_LINE_CACHED_PROJ_NAME>Administrative</TS_LINE_CACHED_PROJ_NAME>
<TS_ACT_AUD_UID>0b7fb2dc-171e-45ec-93d1-02ce767ae139</TS_ACT_AUD_UID>
<TS_ACT_AUD_OPERATION_ENUM>1</TS_ACT_AUD_OPERATION_ENUM>
<TS_ACT_START_DATE>2011-02-09T00:00:00-08:00</TS_ACT_START_DATE>
<TS_ACT_FINISH_DATE>2011-02-09T23:59:59-08:00</TS_ACT_FINISH_DATE>
<TS_ACT_AUD_SEQUENCE>3</TS_ACT_AUD_SEQUENCE>
<RES_UID>2e0fdcc1-85fc-4bde-9593-78a2789c66af</RES_UID>
<TS_ACT_AUD_DELTA_VALUE>300000.000000</TS_ACT_AUD_DELTA_VALUE>
<TS_ACT_AUD_OVT_DELTA_VALUE>0.000000</TS_ACT_AUD_OVT_DELTA_VALUE>
<TS_ACT_AUD_NONBILL_DELTA_VALUE>0.000000</TS_ACT_AUD_NONBILL_DELTA_VALUE>
<TS_ACT_AUD_NONBILL_OVT_DELTA_VALUE>0.000000</TS_ACT_AUD_NONBILL_OVT_DELTA_VALUE>
<TS_ACT_AUD_CACHED_RES_NAME>Mina Edison</TS_ACT_AUD_CACHED_RES_NAME>
<TS_ACT_AUD_RES_ROLE>2</TS_ACT_AUD_RES_ROLE>
</AuditExports>
</TimesheetAuditExportDataSet>