次の方法で共有


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
)

パラメーター

  • auditType
    型: WebSvcAdmin.AuditType

    損害調査担当、リソース、またはその両方を監査します。

戻り値

型: WebSvcAdmin.TimesheetAuditExportDataSet
指定した日付の監査データを格納します。

注釈

以前のバージョンの Project Server 監査ログのトランザクションを収集するには、レポート データベースに対して SQL クエリを実行する必要があります。ReadTimesheetAuditLogを使用すると、クエリの代わりに使用するメソッドの呼び出しを提供します。

プロジェクト サーバーのアクセス許可

権限

説明

ManageTimesheetAndFinancialPeriods

作成および定義のタイムシートおよび会計期間の定義を変更することができます。グローバル アクセス権。

次の使用例は、現在のタイムシート監査ログを読み取り、結果を XML ファイルに書き込みます例では、ProjectServerServices.dll プロキシ アセンブリ内のSvcAdminの名前空間を使用します。

注意

ConfigClientEndpointsメソッドは、WCF のバインディング、動作、およびエンドポイントの設定を app.config ファイルを使用します。PSI プロキシ アセンブリと app.config ファイルを作成する方法の詳細については、 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>

関連項目

参照先

Admin クラス

Admin メンバー

WebSvcAdmin 名前空間