共用方式為


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
)

參數

傳回值

類型:WebSvcAdmin.TimesheetAuditExportDataSet
包含指定之日期的稽核資料。

備註

舊版的 Project Server 所需的 SQL 查詢收集稽核記錄檔交易報表資料庫上執行。使用ReadTimesheetAuditLog提供,查詢方法呼叫。

Project Server 權限

權限

描述

ManageTimesheetAndFinancialPeriods

可讓使用者建立及修改時程表定義和會計週期定義。通用權限。

範例

下列範例會讀取目前的時程表稽核記錄,並將結果寫入至 XML 檔案。範例 ProjectServerServices.dll proxy 組件中使用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 Prerequisites for WCF-Based Code Samples.

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>

請參閱

參照

Admin 類別

Admin 成員

WebSvcAdmin 命名空間