Admin.UpdateTimeSheetSettings method

Office 2013 and later

Updates the timesheet settings.

Namespace:  WebSvcAdmin
Assembly:  ProjectServerServices (in ProjectServerServices.dll)

[SoapDocumentMethodAttribute("", RequestNamespace = "", 
	ResponseNamespace = "", 
	Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
public void UpdateTimeSheetSettings(
	TimeSheetSettingsDataSet dsDelta


Type: WebSvcAdmin.TimeSheetSettingsDataSet

Contains the new timesheet settings.

Timesheet settings can be set on the Timesheet Settings and Defaults page in Project Web App (http:///ServerName/ProjectServerName/_layouts/pwa/Admin/TSSettings.aspx).

Properties in the TimeSheetSettingsDataSet.TimeSheetSettings[0] row have constraints; they cannot be null. Use the ReadTimeSheetSettings method to get the current settings, and then make changes.

Project Server Permissions




Allows the user to manage timesheets that are submitted by resources. Global permission.

The following example reads the current timesheet settings, changes the values of WADMIN_TS_MAX_HR_PER_TS and WADMIN_TS_MIN_HR_PER_TS in the TimeSheetSettingsDataSet, and then uses the UpdateTimeSheetSettings method to change the maximum hours and minimum hours per timesheet. The example uses the SvcAdmin namespace in the ProjectServerServices.dll proxy assembly. The example also writes the updates that are in the new TimeSheetSettingsDataSet to an XML file.


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 in Project 2013.

using System;
using System.Text;
using System.ServiceModel;
using System.Xml;
using PSLibrary = Microsoft.Office.Project.Server.Library;

namespace Microsoft.SDK.Project.Samples.UpdateTimeSheetSettings
    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 + "TimesheetSettings.xml";

            Console.WriteLine("Retrieving the timesheet settings...");
            SvcAdmin.TimeSheetSettingsDataSet timesheetSettingsDS =
                new SvcAdmin.TimeSheetSettingsDataSet();

            // Get the current timesheet settings, and then make changes to 
            // two settings: maximum and minimum hours per timesheet. 
                timesheetSettingsDS = adminClient.ReadTimeSheetSettings();

               // Changes the timesheet settings to be 50 hours per week maximum
                // and 15 hours per week minimum.
                timesheetSettingsDS.TimeSheetSettings[0].WADMIN_TS_MAX_HR_PER_TS = 3000000;
                timesheetSettingsDS.TimeSheetSettings[0].WADMIN_TS_MIN_HR_PER_TS = 900000;

                // Write the changed dataset to an output file, for debugging purposes.

                // Update the timesheet settings with the changes.

            catch (FaultException fault)
                // Use the WCF FaultException, because the ASMX SoapException does not 
                // exist in a WCF-based application.
                Console.Write("\nThe attempt to update the timesheet settings has failed.");

            Console.WriteLine("\nSee XML output of the updated TimeSheetSettingsDataSet at:\n\t{0}",
            Console.Write("\nPress any key to exit... ");


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

        // 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;
                // Get a ServiceModel.MessageFault object.
                var messageFault = e.CreateMessageFault();

                if (messageFault.HasDetail)
                    using (var xmlReader = messageFault.GetReaderAtDetailContents())
                        var xml = new XmlDocument();

                        var serverExecutionFault = xml["ServerExecutionFault"];
                        if (serverExecutionFault != null)
                            var exceptionDetails = serverExecutionFault["ExceptionDetails"];
                            if (exceptionDetails != null)
                                    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;
                                errOut = PREFIX + "The FaultException e is a ServerExecutionFault, "
                                    + "but does not have ExceptionDetails.";
                            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 the UpdateTimesheetSettings.xml file that the application saves. The WADMIN_TS_MIN_HR_PER_TS element and the WADMIN_TS_MAX_HR_PER_TS element are updated.

<?xml version="1.0" standalone="yes"?>
<TimeSheetSettingsDataSet xmlns="">