private void SaveTimesheet(Guid userId, string userName,SvcTimeSheet.TimesheetDataSet tsDs, Guid tsGuid)
        {
            try
            {
                Guid jobGuid = Guid.NewGuid();

                using (OperationContextScope scope = new OperationContextScope(timesheetClient.InnerChannel))
                {
                    SetImpersonation(userId,userName);
                    var temp = tsDs.GetChanges();
                    timesheetClient.QueueUpdateTimesheet(jobGuid,
                         tsGuid,
                        (SvcTimeSheet.TimesheetDataSet)tsDs);  //Saves the specified timesheet data to the Published database
                }
                bool res = QueueHelper.WaitForQueueJobCompletion(jobGuid, (int)SvcQueueSystem.QueueMsgType.TimesheetUpdate, queueClient);
                if (!res) throw new Exception();
            }
            catch (Exception tex) { throw new Exception(); }
        }
        private void CreateTimesheet(Guid userUid,string userName, Guid periodUID, ref Guid tuid, ref SvcTimeSheet.TimesheetDataSet tsDs)
        {
            tsDs = new SvcTimeSheet.TimesheetDataSet();
            SvcTimeSheet.TimesheetDataSet.HeadersRow headersRow = tsDs.Headers.NewHeadersRow();
            headersRow.RES_UID = userUid;  // cant be null.
            tuid = Guid.NewGuid();
            headersRow.TS_UID = tuid;
            headersRow.WPRD_UID = periodUID;
            headersRow.TS_NAME = "Timesheet";
            headersRow.TS_COMMENTS = "Timesheet Created via custom Prepopulation";
            headersRow.TS_ENTRY_MODE_ENUM = (byte)PSLib.TimesheetEnum.EntryMode.Daily;
            tsDs.Headers.AddHeadersRow(headersRow);

            using (OperationContextScope scope = new OperationContextScope(timesheetClient.InnerChannel))
            {
                SetImpersonation(userUid,userName);
                timesheetClient.CreateTimesheet(tsDs, SvcTimeSheet.PreloadType.None);
            }
            using (OperationContextScope scope = new OperationContextScope(timesheetClient.InnerChannel))
            {
                SetImpersonation(userUid,userName);
                tsDs = timesheetClient.ReadTimesheet(tuid); //calling ReadTimesheet to pre populate with default server settings
            }
        }