次の方法で共有


Admin.ReadTimesheetAuditLog Method

Reads the timesheet audit log transactions that occur during the specified audit and timesheet period time spans.

Namespace:  [Admin Web service]
Service reference: http://ServerName:32843/[Project Service Application GUID]/PSI/Admin.svc
Web service reference: http://ServerName/ProjectServerName/_vti_bin/PSI/Admin.asmx?wsdl

Syntax

'Declaration
<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
'Usage
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
)

Parameters

Return Value

Type: [Admin Web service].TimesheetAuditExportDataSet
Contains audit data for the specified dates.

Remarks

Previous versions of Project Server required that a SQL query be run on the Reporting database to collect audit log transactions. The use of ReadTimesheetAuditLog provides a method call to use in place of a query.

Project Server Permissions

Permission

Description

ManageTimesheetAndFinancialPeriods

Allows a user to create and modify timesheet definitions and fiscal period definitions. Global permission.

Examples

The following example reads the current timesheet audit log and writes the results to an XML file. The example uses the SvcAdmin namespace in the ProjectServerServices.dll proxy assembly.

Note

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;
        }
    }
}

Following is an example of part of the ReadTimesheetAuditLog.xml file that the application saves.

Note

The audit log information returned in the example is specific to the project that was defined in a Project Web App instance.

<?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>

See Also

Reference

Admin Class

Admin Members

Admin Web Service