Problems with Inpersonations

P

paul

We have written a windows service that is responsible for synchronising
Timesheet Lines for all Resources from an external source to PWA via the
Project Server Interface (PSI). The windows service runs as a user that has
All Administrator Rights in Project Server. The Service is able to create
Timesheets and Timesheet Lines for the user that it is running as,however
fails to create Timesheet Lines for any other Resource in PWA. Below is the
error message that is return by the Queuing Service:

Error summary/areas:
There has been an error processing a timesheet for which you are/were
responsible. Check your approvals list to locate the offending timesheet if
one exists. The error condidtion may be related to the fact that Timesheets
are a state driven feature; therefore, the allowable values for processing
are dependent upon the existing value which for this transaction was 0. Refer
to the documentation to determine which status transitions are allowable and
submit the transaction.
TimesheetIncorrectMode
Queue
GeneralQueueJobFailed
Error details:
<?xml version="1.0" encoding="utf-16"?>
<errinfo>
<general>
<class name="There has been an error processing a timesheet for which
you are/were responsible. Check your approvals list to locate the offending
timesheet if one exists. The error condidtion may be related to the fact that
Timesheets are a state driven feature; therefore, the allowable values for
processing are dependent upon the existing value which for this transaction
was 0. Refer to the documentation to determine which status transitions are
allowable and submit the transaction.">
<error id="3204" name="TimesheetIncorrectMode"
uid="e7d928f7-8941-4004-ba7e-81ebfe9058cb" mode="0" />
</class>
<class name="Queue">
<error id="26000" name="GeneralQueueJobFailed"
uid="87687593-ef03-4c04-acc9-3f0b97730b44"
JobUID="8f499647-b2f4-4d1f-bdfc-9b515af8820c" ComputerName="1IBRMSP06"
GroupType="TimesheetUpdate" MessageType="UpdateTimesheetMessage"
MessageId="1" Stage="" />
</class>
</general>
</errinfo>

Below is the code snippet and in the line in bold is where it breaks:
TimesheetDataSet.LinesRow line =
this.TimesheetDataSet.Lines.NewLinesRow();
line.TS_UID = this.ID;
line.TS_LINE_UID = Guid.NewGuid();
line.TS_LINE_CLASS_UID = LineClass.ID;
line.TS_LINE_COMMENT = Comment;
line.TS_LINE_STATUS =
(byte)PSLibrary.TimesheetEnum.LineStatus.NotApplicable;
line.TS_LINE_VALIDATION_TYPE =
(byte)PSLibrary.TimesheetEnum.ValidationType.Unverified;
if ((NameDesc!=null) && (NameDesc.Length>0))
line.TS_LINE_CACHED_ASSIGN_NAME = NameDesc;
else
line.TS_LINE_CACHED_ASSIGN_NAME = ExternalTaskId;
line.TS_LINE_CACHED_PROJ_NAME = ProjectName;
line.ASSN_UID = this.ResourceID;
this.TimesheetDataSet.Lines.AddLinesRow(line);
TimesheetSvc.Timesheetservice.PrepareTimesheetLine(this.ID,
ref this.m_TimesheetDataSet, new Guid[] { line.TS_LINE_UID });
Guid jobUid = Guid.NewGuid();
TimesheetSvc.Timesheetservice.QueueUpdateTimesheet(jobUid,
this.ID, this.m_TimesheetDataSet);
Queue.WaitForQueue(jobUid);

I have checked the user's permissions in PWA via the "Manage Users" and the
has Administrator Priviledges.
 
C

Chris Boyd

Can you show us a code snippet of your impersonation code?
--
Chris Boyd
MS Project
Program Manager

Blog: http://blogs.msdn.com/project_programmability/


paul said:
We have written a windows service that is responsible for synchronising
Timesheet Lines for all Resources from an external source to PWA via the
Project Server Interface (PSI). The windows service runs as a user that has
All Administrator Rights in Project Server. The Service is able to create
Timesheets and Timesheet Lines for the user that it is running as,however
fails to create Timesheet Lines for any other Resource in PWA. Below is the
error message that is return by the Queuing Service:

Error summary/areas:
There has been an error processing a timesheet for which you are/were
responsible. Check your approvals list to locate the offending timesheet if
one exists. The error condidtion may be related to the fact that Timesheets
are a state driven feature; therefore, the allowable values for processing
are dependent upon the existing value which for this transaction was 0. Refer
to the documentation to determine which status transitions are allowable and
submit the transaction.
TimesheetIncorrectMode
Queue
GeneralQueueJobFailed
Error details:
<?xml version="1.0" encoding="utf-16"?>
<errinfo>
<general>
<class name="There has been an error processing a timesheet for which
you are/were responsible. Check your approvals list to locate the offending
timesheet if one exists. The error condidtion may be related to the fact that
Timesheets are a state driven feature; therefore, the allowable values for
processing are dependent upon the existing value which for this transaction
was 0. Refer to the documentation to determine which status transitions are
allowable and submit the transaction.">
<error id="3204" name="TimesheetIncorrectMode"
uid="e7d928f7-8941-4004-ba7e-81ebfe9058cb" mode="0" />
</class>
<class name="Queue">
<error id="26000" name="GeneralQueueJobFailed"
uid="87687593-ef03-4c04-acc9-3f0b97730b44"
JobUID="8f499647-b2f4-4d1f-bdfc-9b515af8820c" ComputerName="1IBRMSP06"
GroupType="TimesheetUpdate" MessageType="UpdateTimesheetMessage"
MessageId="1" Stage="" />
</class>
</general>
</errinfo>

Below is the code snippet and in the line in bold is where it breaks:
TimesheetDataSet.LinesRow line =
this.TimesheetDataSet.Lines.NewLinesRow();
line.TS_UID = this.ID;
line.TS_LINE_UID = Guid.NewGuid();
line.TS_LINE_CLASS_UID = LineClass.ID;
line.TS_LINE_COMMENT = Comment;
line.TS_LINE_STATUS =
(byte)PSLibrary.TimesheetEnum.LineStatus.NotApplicable;
line.TS_LINE_VALIDATION_TYPE =
(byte)PSLibrary.TimesheetEnum.ValidationType.Unverified;
if ((NameDesc!=null) && (NameDesc.Length>0))
line.TS_LINE_CACHED_ASSIGN_NAME = NameDesc;
else
line.TS_LINE_CACHED_ASSIGN_NAME = ExternalTaskId;
line.TS_LINE_CACHED_PROJ_NAME = ProjectName;
line.ASSN_UID = this.ResourceID;
this.TimesheetDataSet.Lines.AddLinesRow(line);
TimesheetSvc.Timesheetservice.PrepareTimesheetLine(this.ID,
ref this.m_TimesheetDataSet, new Guid[] { line.TS_LINE_UID });
Guid jobUid = Guid.NewGuid();
TimesheetSvc.Timesheetservice.QueueUpdateTimesheet(jobUid,
this.ID, this.m_TimesheetDataSet);
Queue.WaitForQueue(jobUid);

I have checked the user's permissions in PWA via the "Manage Users" and the
has Administrator Priviledges.
 
P

paul

Hi Chris, Thanks for your response. Please find code below:
using System;
using System.Data;
using System.Collections.Specialized;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using Microsoft.SharePoint;
using PSLibrary = Microsoft.Office.Project.Server.Library;
using MNR.Framework.TimesheetWebSvc;
using MNR.Data;
using MNR.MiddleTier.Data;

namespace MNR.Reporting.PSI.Data.Timesheets
{
[Serializable]
public class TimesheetDataObject : ObjectBase
{
#region Constants

#endregion

#region Data Members
public static TimesheetListDataSet.TimesheetsDataTable Timesheet =
new TimesheetListDataSet.TimesheetsDataTable();

private TimesheetListDataSet m_TimesheetListDataSet = null;
private TimesheetDataSet m_TimesheetDataSet = null;
private TimesheetListDataSet.TimesheetsDataTable
m_TimesheetDataTable = null;
private TimesheetListDataSet.TimesheetsRow m_TimesheetRow = null;
private TimesheetHeaderDataObjectCollection m_Headers = null;
private TimesheetLineDataObjectCollection m_Lines = null;
#endregion

#region Constructors
public TimesheetDataObject() : base() { }
public TimesheetDataObject(DataRow WsTimesheetRow)
{
this.LoadData(WsTimesheetRow);
}
#endregion

#region Properties
public TimesheetListDataSet TimesheetListDataSet
{
get { return this.m_TimesheetListDataSet; }
}

public TimesheetDataSet TimesheetDataSet
{
get { return this.m_TimesheetDataSet; }
}

public TimesheetListDataSet.TimesheetsDataTable TimesheetDataTable
{
get { return this.m_TimesheetDataTable; }
}

public TimesheetListDataSet.TimesheetsRow TimesheetRow
{
get { return this.m_TimesheetRow; }
set { this.LoadData(value); }
}

public Guid ID
{
get { return (Guid)this[Timesheet.TS_UIDColumn.ColumnName]; }
set { this[Timesheet.TS_UIDColumn.ColumnName] = value; }
}

public Guid ResourceID
{
get { return (Guid)this[Timesheet.RES_UIDColumn.ColumnName]; }
set { this[Timesheet.RES_UIDColumn.ColumnName] = value; }
}

public string Name
{
get { return (string)this[Timesheet.TS_NAMEColumn.ColumnName]; }
set { this[Timesheet.TS_NAMEColumn.ColumnName] = value; }
}

public Guid TimePeriodID
{
get { return (Guid)this[Timesheet.WPRD_UIDColumn.ColumnName]; }
set { this[Timesheet.WPRD_UIDColumn.ColumnName] = value; }
}

public string TimePeriodName
{
get { return (string)this[Timesheet.WPRD_NAMEColumn.ColumnName]; }
set { this[Timesheet.WPRD_NAMEColumn.ColumnName] = value; }
}

public DateTime StartDate
{
get { return
(DateTime)this[Timesheet.WPRD_START_DATEColumn.ColumnName]; }
set { this[Timesheet.WPRD_START_DATEColumn.ColumnName] = value; }
}

public DateTime FinishDate
{
get { return
(DateTime)this[Timesheet.WPRD_FINISH_DATEColumn.ColumnName]; }
set { this[Timesheet.WPRD_FINISH_DATEColumn.ColumnName] = value; }
}

public TimesheetHeaderDataObjectCollection Headers
{
get { return this.m_Headers; }
}

public TimesheetLineDataObjectCollection Lines
{
get { return this.m_Lines; }
}
#endregion

#region Methods
protected override void OnInitialise()
{
this.AddProperty(Timesheet.TS_UIDColumn.ColumnName,
typeof(Guid), Guid.Empty);
this.AddProperty(Timesheet.RES_UIDColumn.ColumnName,
typeof(Guid), Guid.Empty);
this.AddProperty(Timesheet.TS_NAMEColumn.ColumnName,
typeof(string), string.Empty);
this.AddProperty(Timesheet.WPRD_UIDColumn.ColumnName,
typeof(Guid), Guid.Empty);
this.AddProperty(Timesheet.WPRD_NAMEColumn.ColumnName,
typeof(string), string.Empty);
this.AddProperty(Timesheet.WPRD_START_DATEColumn.ColumnName,
typeof(DateTime), DateTime.MinValue);
this.AddProperty(Timesheet.WPRD_FINISH_DATEColumn.ColumnName,
typeof(DateTime), DateTime.MinValue);
}

protected override void OnPostLoad(object DataSource)
{
base.OnPostLoad(DataSource);
if ((DataSource!=null) && (DataSource is
TimesheetListDataSet.TimesheetsRow))
{
this.m_TimesheetRow =
(TimesheetListDataSet.TimesheetsRow)DataSource;
if ((this.m_TimesheetRow.Table!=null) &&
(this.m_TimesheetRow.Table is TimesheetListDataSet.TimesheetsDataTable))
this.m_TimesheetDataTable =
(TimesheetListDataSet.TimesheetsDataTable)this.m_TimesheetRow.Table;
if ((this.m_TimesheetDataTable != null) &&
(this.m_TimesheetDataTable.DataSet != null) &&
(this.m_TimesheetDataTable.DataSet is TimesheetListDataSet))
this.m_TimesheetListDataSet =
(TimesheetListDataSet)this.m_TimesheetDataTable.DataSet;
}
}

public void ReadData(Timesheets TimesheetSvc)
{
if ((TimesheetSvc != null) && (TimesheetSvc.Timesheetservice !=
null) && (!this.ID.Equals(Guid.Empty)))
{
if (this.m_Headers != null)
{
this.m_Headers.Dispose();
this.m_Headers = null;
}

if (this.m_Headers != null)
{
this.m_Lines.Dispose();
this.m_Lines = null;
}

TimesheetDataSet TimesheetDataSet =
TimesheetSvc.Timesheetservice.ReadTimesheet(this.ID);

this.m_Headers = new
TimesheetHeaderDataObjectCollection(TimesheetDataSet);
this.m_Lines = new
TimesheetLineDataObjectCollection(TimesheetDataSet);
this.m_TimesheetDataSet = TimesheetDataSet;
}
}

public void Create(Guid CreatorId, Timesheets TimesheetSvc, string
Name, string Comments)
{
if ((TimesheetSvc!=null) && ((this.Headers == null) ||
(this.Headers.Count < 1)))
{
this.m_TimesheetDataSet = new TimesheetDataSet();
this.ID = Guid.NewGuid();
TimesheetDataSet.HeadersRow headersRow =
this.m_TimesheetDataSet.Headers.NewHeadersRow();
headersRow.RES_UID = this.ResourceID;
headersRow.TS_UID = this.ID;
headersRow.WPRD_UID = this.TimePeriodID;
headersRow.TS_CREATOR_RES_UID = CreatorId;
headersRow.TS_NAME = Name;
headersRow.TS_COMMENTS = Comments;
headersRow.TS_ENTRY_MODE_ENUM =
(byte)PSLibrary.TimesheetEnum.EntryMode.Daily;
headersRow.TS_STATUS_ENUM =
(byte)PSLibrary.TimesheetEnum.Status.InProgress;
this.m_TimesheetDataSet.Headers.AddHeadersRow(headersRow);

// Create the timesheet with the default line types
specified by the admin

TimesheetSvc.Timesheetservice.CreateTimesheet(this.m_TimesheetDataSet,
MNR.Framework.TimesheetWebSvc.PreloadType.Default);
this.ReadData(TimesheetSvc);
}
}

public System.Guid
AddUnverifiedLine(MNR.Reporting.PSI.Data.QueueSystems Queue, Timesheets
TimesheetSvc,string ProjectName,string ExternalTaskId, string NameDesc,
string Comment, Admins.TimesheetLineClassDataObject LineClass)
{
if ((TimesheetSvc != null) && (this.TimesheetDataSet != null) &&
(!this.ID.Equals(Guid.Empty)) && (LineClass!=null) &&
(!LineClass.ID.Equals(Guid.Empty)))
{
TimesheetDataSet.LinesRow line =
this.TimesheetDataSet.Lines.NewLinesRow();
line.TS_UID = this.ID;
line.TS_LINE_UID = Guid.NewGuid();
line.TS_LINE_CLASS_UID = LineClass.ID;
line.TS_LINE_COMMENT = Comment;
line.TS_LINE_STATUS =
(byte)PSLibrary.TimesheetEnum.LineStatus.NotApplicable;
line.TS_LINE_VALIDATION_TYPE =
(byte)PSLibrary.TimesheetEnum.ValidationType.Unverified;
if ((NameDesc!=null) && (NameDesc.Length>0))
line.TS_LINE_CACHED_ASSIGN_NAME = NameDesc;
else
line.TS_LINE_CACHED_ASSIGN_NAME = ExternalTaskId;
line.TS_LINE_CACHED_PROJ_NAME = ProjectName;
this.TimesheetDataSet.Lines.AddLinesRow(line);

TimesheetSvc.Timesheetservice.PrepareTimesheetLine(this.ID,
ref this.m_TimesheetDataSet, new Guid[] { line.TS_LINE_UID });
Guid jobUid = Guid.NewGuid();
TimesheetSvc.Timesheetservice.QueueUpdateTimesheet(jobUid,
this.ID, this.m_TimesheetDataSet);
Queue.WaitForQueue(jobUid);
return line.TS_LINE_UID;
}

return Guid.Empty;
}

protected override void OnDispose()
{
base.OnDispose();
if (this.m_Headers != null)
{
this.m_Headers.Dispose();
this.m_Headers = null;
}

if (this.m_Headers != null)
{
this.m_Lines.Dispose();
this.m_Lines = null;
}
}
#endregion
}

/// <summary>
/// Summary description for TimesheetDataObjectCollection
/// Author, Date: Administrator, 2006/11/26 10:23:51 PM
/// Purpose:
/// </summary>
[Serializable]
public class TimesheetDataObjectCollection : ObjectBaseCollection
{
#region Data Members
private TimesheetListDataSet m_TimesheetDataSet = null;
private TimesheetListDataSet.TimesheetsDataTable
m_TimesheetDataTable = null;
#endregion

#region Constructor
public TimesheetDataObjectCollection()
: base(typeof(TimesheetDataObject))
{ }

public TimesheetDataObjectCollection(TimesheetListDataSet
TimesheetsDs)
: this()
{ this.Retrieve(TimesheetsDs); }

public
TimesheetDataObjectCollection(TimesheetListDataSet.TimesheetsDataTable
Timesheets)
: this()
{ this.Retrieve(Timesheets); }
#endregion

#region Properties
public TimesheetListDataSet TimesheetListDataSet
{
get { return this.m_TimesheetDataSet; }
}

public TimesheetListDataSet.TimesheetsDataTable TimesheetDataTable
{
get { return this.m_TimesheetDataTable; }
set { this.Retrieve(value); }
}

public new TimesheetDataObject this[int index]
{
get
{
return (TimesheetDataObject)base[index];
}

set
{
base[index] = value;
}

}

public TimesheetDataObject this[string Name]
{
get
{
if ((Name != null) && (Name.Length > 0))
{
for (int index = 0; index < this.Count; index++)
{
if (this[index].Name.ToUpper() == Name.ToUpper())
return this[index];
}
}
return null;
}
}

public TimesheetDataObject this[Guid UID]
{
get
{
for (int index = 0; index < this.Count; index++)
{
if (this[index].ID == UID)
return this[index];
}
return null;
}
}
#endregion

#region Protected/Overriden Methods
protected override void OnInitialise()
{
base.OnInitialise();
}

protected override void OnPostRetrieve(object DataSource)
{
base.OnPostRetrieve(DataSource);
if ((DataSource != null) && (DataSource is
TimesheetListDataSet.TimesheetsDataTable))
{
this.m_TimesheetDataTable =
(TimesheetListDataSet.TimesheetsDataTable)DataSource;
if ((this.m_TimesheetDataTable != null) &&
(this.m_TimesheetDataTable.DataSet != null) &&
(this.m_TimesheetDataTable.DataSet is TimesheetListDataSet))
this.m_TimesheetDataSet =
(TimesheetListDataSet)this.m_TimesheetDataTable.DataSet;
}
}
#endregion

#region DataObjectCollection Methods
/// <summary>Add an Object to the List
/// </summary>
/// <param name="value">Object to add to the list</param>
/// <returns>Index of the Object</returns>
public int Add(TimesheetDataObject value)
{
return base.Add(value);
}

/// <summary>Get the Index of an object in the List
/// </summary>
/// <param name="value">Object to Find</param>
/// <returns>Index of the Object</returns>
public int IndexOf(TimesheetDataObject value)
{
return base.IndexOf(value);
}

/// <summary>Insert an Object into a specific position
/// </summary>
/// <param name="value">Position</param>
/// <returns>Object to insert</returns>
public void Insert(int index, TimesheetDataObject value)
{
base.Insert(index, value);
}

/// <summary>Remove An Object From the List
/// </summary>
/// <param name="value">Object to Remove</param>
/// <returns></returns>
public void Remove(TimesheetDataObject value)
{
base.Remove(value);
}

/// <summary>Check if an Object exists in the List
/// </summary>
/// <param name="value">Object to Check for</param>
/// <returns></returns>
public bool Contains(TimesheetDataObject value)
{
return (List.Contains(value));
}

#endregion

#region Public Methods
public void Retrieve(TimesheetListDataSet TimesheetsDs)
{
if ((TimesheetsDs != null) && (TimesheetsDs.Timesheets != null))
this.Retrieve(TimesheetsDs.Timesheets);
}
#endregion

#region Private Methods
#endregion
}
}


Chris Boyd said:
Can you show us a code snippet of your impersonation code?
--
Chris Boyd
MS Project
Program Manager

Blog: http://blogs.msdn.com/project_programmability/


paul said:
We have written a windows service that is responsible for synchronising
Timesheet Lines for all Resources from an external source to PWA via the
Project Server Interface (PSI). The windows service runs as a user that has
All Administrator Rights in Project Server. The Service is able to create
Timesheets and Timesheet Lines for the user that it is running as,however
fails to create Timesheet Lines for any other Resource in PWA. Below is the
error message that is return by the Queuing Service:

Error summary/areas:
There has been an error processing a timesheet for which you are/were
responsible. Check your approvals list to locate the offending timesheet if
one exists. The error condidtion may be related to the fact that Timesheets
are a state driven feature; therefore, the allowable values for processing
are dependent upon the existing value which for this transaction was 0. Refer
to the documentation to determine which status transitions are allowable and
submit the transaction.
TimesheetIncorrectMode
Queue
GeneralQueueJobFailed
Error details:
<?xml version="1.0" encoding="utf-16"?>
<errinfo>
<general>
<class name="There has been an error processing a timesheet for which
you are/were responsible. Check your approvals list to locate the offending
timesheet if one exists. The error condidtion may be related to the fact that
Timesheets are a state driven feature; therefore, the allowable values for
processing are dependent upon the existing value which for this transaction
was 0. Refer to the documentation to determine which status transitions are
allowable and submit the transaction.">
<error id="3204" name="TimesheetIncorrectMode"
uid="e7d928f7-8941-4004-ba7e-81ebfe9058cb" mode="0" />
</class>
<class name="Queue">
<error id="26000" name="GeneralQueueJobFailed"
uid="87687593-ef03-4c04-acc9-3f0b97730b44"
JobUID="8f499647-b2f4-4d1f-bdfc-9b515af8820c" ComputerName="1IBRMSP06"
GroupType="TimesheetUpdate" MessageType="UpdateTimesheetMessage"
MessageId="1" Stage="" />
</class>
</general>
</errinfo>

Below is the code snippet and in the line in bold is where it breaks:
TimesheetDataSet.LinesRow line =
this.TimesheetDataSet.Lines.NewLinesRow();
line.TS_UID = this.ID;
line.TS_LINE_UID = Guid.NewGuid();
line.TS_LINE_CLASS_UID = LineClass.ID;
line.TS_LINE_COMMENT = Comment;
line.TS_LINE_STATUS =
(byte)PSLibrary.TimesheetEnum.LineStatus.NotApplicable;
line.TS_LINE_VALIDATION_TYPE =
(byte)PSLibrary.TimesheetEnum.ValidationType.Unverified;
if ((NameDesc!=null) && (NameDesc.Length>0))
line.TS_LINE_CACHED_ASSIGN_NAME = NameDesc;
else
line.TS_LINE_CACHED_ASSIGN_NAME = ExternalTaskId;
line.TS_LINE_CACHED_PROJ_NAME = ProjectName;
line.ASSN_UID = this.ResourceID;
this.TimesheetDataSet.Lines.AddLinesRow(line);
TimesheetSvc.Timesheetservice.PrepareTimesheetLine(this.ID,
ref this.m_TimesheetDataSet, new Guid[] { line.TS_LINE_UID });
Guid jobUid = Guid.NewGuid();
TimesheetSvc.Timesheetservice.QueueUpdateTimesheet(jobUid,
this.ID, this.m_TimesheetDataSet);
Queue.WaitForQueue(jobUid);

I have checked the user's permissions in PWA via the "Manage Users" and the
has Administrator Priviledges.
 
C

Chris Boyd

Hey,

I can't seem to find in your code where you are setting up the
impersonation. Have you read:
http://msdn2.microsoft.com/en-us/library/aa974413.aspx. It goes over how to
impersonate a user via the PSI.

--
Chris Boyd
MS Project
Program Manager

Blog: http://blogs.msdn.com/project_programmability/


paul said:
Hi Chris, Thanks for your response. Please find code below:
using System;
using System.Data;
using System.Collections.Specialized;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using Microsoft.SharePoint;
using PSLibrary = Microsoft.Office.Project.Server.Library;
using MNR.Framework.TimesheetWebSvc;
using MNR.Data;
using MNR.MiddleTier.Data;

namespace MNR.Reporting.PSI.Data.Timesheets
{
[Serializable]
public class TimesheetDataObject : ObjectBase
{
#region Constants

#endregion

#region Data Members
public static TimesheetListDataSet.TimesheetsDataTable Timesheet =
new TimesheetListDataSet.TimesheetsDataTable();

private TimesheetListDataSet m_TimesheetListDataSet = null;
private TimesheetDataSet m_TimesheetDataSet = null;
private TimesheetListDataSet.TimesheetsDataTable
m_TimesheetDataTable = null;
private TimesheetListDataSet.TimesheetsRow m_TimesheetRow = null;
private TimesheetHeaderDataObjectCollection m_Headers = null;
private TimesheetLineDataObjectCollection m_Lines = null;
#endregion

#region Constructors
public TimesheetDataObject() : base() { }
public TimesheetDataObject(DataRow WsTimesheetRow)
{
this.LoadData(WsTimesheetRow);
}
#endregion

#region Properties
public TimesheetListDataSet TimesheetListDataSet
{
get { return this.m_TimesheetListDataSet; }
}

public TimesheetDataSet TimesheetDataSet
{
get { return this.m_TimesheetDataSet; }
}

public TimesheetListDataSet.TimesheetsDataTable TimesheetDataTable
{
get { return this.m_TimesheetDataTable; }
}

public TimesheetListDataSet.TimesheetsRow TimesheetRow
{
get { return this.m_TimesheetRow; }
set { this.LoadData(value); }
}

public Guid ID
{
get { return (Guid)this[Timesheet.TS_UIDColumn.ColumnName]; }
set { this[Timesheet.TS_UIDColumn.ColumnName] = value; }
}

public Guid ResourceID
{
get { return (Guid)this[Timesheet.RES_UIDColumn.ColumnName]; }
set { this[Timesheet.RES_UIDColumn.ColumnName] = value; }
}

public string Name
{
get { return (string)this[Timesheet.TS_NAMEColumn.ColumnName]; }
set { this[Timesheet.TS_NAMEColumn.ColumnName] = value; }
}

public Guid TimePeriodID
{
get { return (Guid)this[Timesheet.WPRD_UIDColumn.ColumnName]; }
set { this[Timesheet.WPRD_UIDColumn.ColumnName] = value; }
}

public string TimePeriodName
{
get { return (string)this[Timesheet.WPRD_NAMEColumn.ColumnName]; }
set { this[Timesheet.WPRD_NAMEColumn.ColumnName] = value; }
}

public DateTime StartDate
{
get { return
(DateTime)this[Timesheet.WPRD_START_DATEColumn.ColumnName]; }
set { this[Timesheet.WPRD_START_DATEColumn.ColumnName] = value; }
}

public DateTime FinishDate
{
get { return
(DateTime)this[Timesheet.WPRD_FINISH_DATEColumn.ColumnName]; }
set { this[Timesheet.WPRD_FINISH_DATEColumn.ColumnName] = value; }
}

public TimesheetHeaderDataObjectCollection Headers
{
get { return this.m_Headers; }
}

public TimesheetLineDataObjectCollection Lines
{
get { return this.m_Lines; }
}
#endregion

#region Methods
protected override void OnInitialise()
{
this.AddProperty(Timesheet.TS_UIDColumn.ColumnName,
typeof(Guid), Guid.Empty);
this.AddProperty(Timesheet.RES_UIDColumn.ColumnName,
typeof(Guid), Guid.Empty);
this.AddProperty(Timesheet.TS_NAMEColumn.ColumnName,
typeof(string), string.Empty);
this.AddProperty(Timesheet.WPRD_UIDColumn.ColumnName,
typeof(Guid), Guid.Empty);
this.AddProperty(Timesheet.WPRD_NAMEColumn.ColumnName,
typeof(string), string.Empty);
this.AddProperty(Timesheet.WPRD_START_DATEColumn.ColumnName,
typeof(DateTime), DateTime.MinValue);
this.AddProperty(Timesheet.WPRD_FINISH_DATEColumn.ColumnName,
typeof(DateTime), DateTime.MinValue);
}

protected override void OnPostLoad(object DataSource)
{
base.OnPostLoad(DataSource);
if ((DataSource!=null) && (DataSource is
TimesheetListDataSet.TimesheetsRow))
{
this.m_TimesheetRow =
(TimesheetListDataSet.TimesheetsRow)DataSource;
if ((this.m_TimesheetRow.Table!=null) &&
(this.m_TimesheetRow.Table is TimesheetListDataSet.TimesheetsDataTable))
this.m_TimesheetDataTable =
(TimesheetListDataSet.TimesheetsDataTable)this.m_TimesheetRow.Table;
if ((this.m_TimesheetDataTable != null) &&
(this.m_TimesheetDataTable.DataSet != null) &&
(this.m_TimesheetDataTable.DataSet is TimesheetListDataSet))
this.m_TimesheetListDataSet =
(TimesheetListDataSet)this.m_TimesheetDataTable.DataSet;
}
}

public void ReadData(Timesheets TimesheetSvc)
{
if ((TimesheetSvc != null) && (TimesheetSvc.Timesheetservice !=
null) && (!this.ID.Equals(Guid.Empty)))
{
if (this.m_Headers != null)
{
this.m_Headers.Dispose();
this.m_Headers = null;
}

if (this.m_Headers != null)
{
this.m_Lines.Dispose();
this.m_Lines = null;
}

TimesheetDataSet TimesheetDataSet =
TimesheetSvc.Timesheetservice.ReadTimesheet(this.ID);

this.m_Headers = new
TimesheetHeaderDataObjectCollection(TimesheetDataSet);
this.m_Lines = new
TimesheetLineDataObjectCollection(TimesheetDataSet);
this.m_TimesheetDataSet = TimesheetDataSet;
}
}

public void Create(Guid CreatorId, Timesheets TimesheetSvc, string
Name, string Comments)
{
if ((TimesheetSvc!=null) && ((this.Headers == null) ||
(this.Headers.Count < 1)))
{
this.m_TimesheetDataSet = new TimesheetDataSet();
this.ID = Guid.NewGuid();
TimesheetDataSet.HeadersRow headersRow =
this.m_TimesheetDataSet.Headers.NewHeadersRow();
headersRow.RES_UID = this.ResourceID;
headersRow.TS_UID = this.ID;
headersRow.WPRD_UID = this.TimePeriodID;
headersRow.TS_CREATOR_RES_UID = CreatorId;
headersRow.TS_NAME = Name;
headersRow.TS_COMMENTS = Comments;
headersRow.TS_ENTRY_MODE_ENUM =
(byte)PSLibrary.TimesheetEnum.EntryMode.Daily;
headersRow.TS_STATUS_ENUM =
(byte)PSLibrary.TimesheetEnum.Status.InProgress;
this.m_TimesheetDataSet.Headers.AddHeadersRow(headersRow);

// Create the timesheet with the default line types
specified by the admin

TimesheetSvc.Timesheetservice.CreateTimesheet(this.m_TimesheetDataSet,
MNR.Framework.TimesheetWebSvc.PreloadType.Default);
this.ReadData(TimesheetSvc);
}
}

public System.Guid
AddUnverifiedLine(MNR.Reporting.PSI.Data.QueueSystems Queue, Timesheets
TimesheetSvc,string ProjectName,string ExternalTaskId, string NameDesc,
string Comment, Admins.TimesheetLineClassDataObject LineClass)
{
if ((TimesheetSvc != null) && (this.TimesheetDataSet != null) &&
(!this.ID.Equals(Guid.Empty)) && (LineClass!=null) &&
(!LineClass.ID.Equals(Guid.Empty)))
{
TimesheetDataSet.LinesRow line =
this.TimesheetDataSet.Lines.NewLinesRow();
line.TS_UID = this.ID;
line.TS_LINE_UID = Guid.NewGuid();
line.TS_LINE_CLASS_UID = LineClass.ID;
line.TS_LINE_COMMENT = Comment;
line.TS_LINE_STATUS =
(byte)PSLibrary.TimesheetEnum.LineStatus.NotApplicable;
line.TS_LINE_VALIDATION_TYPE =
(byte)PSLibrary.TimesheetEnum.ValidationType.Unverified;
if ((NameDesc!=null) && (NameDesc.Length>0))
line.TS_LINE_CACHED_ASSIGN_NAME = NameDesc;
else
line.TS_LINE_CACHED_ASSIGN_NAME = ExternalTaskId;
line.TS_LINE_CACHED_PROJ_NAME = ProjectName;
this.TimesheetDataSet.Lines.AddLinesRow(line);

TimesheetSvc.Timesheetservice.PrepareTimesheetLine(this.ID,
ref this.m_TimesheetDataSet, new Guid[] { line.TS_LINE_UID });
Guid jobUid = Guid.NewGuid();
TimesheetSvc.Timesheetservice.QueueUpdateTimesheet(jobUid,
this.ID, this.m_TimesheetDataSet);
Queue.WaitForQueue(jobUid);
return line.TS_LINE_UID;
}

return Guid.Empty;
}

protected override void OnDispose()
{
base.OnDispose();
if (this.m_Headers != null)
{
this.m_Headers.Dispose();
this.m_Headers = null;
}

if (this.m_Headers != null)
{
this.m_Lines.Dispose();
this.m_Lines = null;
}
}
#endregion
}

/// <summary>
/// Summary description for TimesheetDataObjectCollection
/// Author, Date: Administrator, 2006/11/26 10:23:51 PM
/// Purpose:
/// </summary>
[Serializable]
public class TimesheetDataObjectCollection : ObjectBaseCollection
{
#region Data Members
private TimesheetListDataSet m_TimesheetDataSet = null;
private TimesheetListDataSet.TimesheetsDataTable
m_TimesheetDataTable = null;
#endregion

#region Constructor
public TimesheetDataObjectCollection()
: base(typeof(TimesheetDataObject))
{ }

public TimesheetDataObjectCollection(TimesheetListDataSet
TimesheetsDs)
: this()
{ this.Retrieve(TimesheetsDs); }

public
TimesheetDataObjectCollection(TimesheetListDataSet.TimesheetsDataTable
 
T

tfz

I am having the same problem, but do you actually need to impersonate here?
Don't you just need to have "CreateSurrogateTimesheet" permissions?

Chris Boyd said:
Hey,

I can't seem to find in your code where you are setting up the
impersonation. Have you read:
http://msdn2.microsoft.com/en-us/library/aa974413.aspx. It goes over how to
impersonate a user via the PSI.

--
Chris Boyd
MS Project
Program Manager

Blog: http://blogs.msdn.com/project_programmability/


paul said:
Hi Chris, Thanks for your response. Please find code below:
using System;
using System.Data;
using System.Collections.Specialized;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using Microsoft.SharePoint;
using PSLibrary = Microsoft.Office.Project.Server.Library;
using MNR.Framework.TimesheetWebSvc;
using MNR.Data;
using MNR.MiddleTier.Data;

namespace MNR.Reporting.PSI.Data.Timesheets
{
[Serializable]
public class TimesheetDataObject : ObjectBase
{
#region Constants

#endregion

#region Data Members
public static TimesheetListDataSet.TimesheetsDataTable Timesheet =
new TimesheetListDataSet.TimesheetsDataTable();

private TimesheetListDataSet m_TimesheetListDataSet = null;
private TimesheetDataSet m_TimesheetDataSet = null;
private TimesheetListDataSet.TimesheetsDataTable
m_TimesheetDataTable = null;
private TimesheetListDataSet.TimesheetsRow m_TimesheetRow = null;
private TimesheetHeaderDataObjectCollection m_Headers = null;
private TimesheetLineDataObjectCollection m_Lines = null;
#endregion

#region Constructors
public TimesheetDataObject() : base() { }
public TimesheetDataObject(DataRow WsTimesheetRow)
{
this.LoadData(WsTimesheetRow);
}
#endregion

#region Properties
public TimesheetListDataSet TimesheetListDataSet
{
get { return this.m_TimesheetListDataSet; }
}

public TimesheetDataSet TimesheetDataSet
{
get { return this.m_TimesheetDataSet; }
}

public TimesheetListDataSet.TimesheetsDataTable TimesheetDataTable
{
get { return this.m_TimesheetDataTable; }
}

public TimesheetListDataSet.TimesheetsRow TimesheetRow
{
get { return this.m_TimesheetRow; }
set { this.LoadData(value); }
}

public Guid ID
{
get { return (Guid)this[Timesheet.TS_UIDColumn.ColumnName]; }
set { this[Timesheet.TS_UIDColumn.ColumnName] = value; }
}

public Guid ResourceID
{
get { return (Guid)this[Timesheet.RES_UIDColumn.ColumnName]; }
set { this[Timesheet.RES_UIDColumn.ColumnName] = value; }
}

public string Name
{
get { return (string)this[Timesheet.TS_NAMEColumn.ColumnName]; }
set { this[Timesheet.TS_NAMEColumn.ColumnName] = value; }
}

public Guid TimePeriodID
{
get { return (Guid)this[Timesheet.WPRD_UIDColumn.ColumnName]; }
set { this[Timesheet.WPRD_UIDColumn.ColumnName] = value; }
}

public string TimePeriodName
{
get { return (string)this[Timesheet.WPRD_NAMEColumn.ColumnName]; }
set { this[Timesheet.WPRD_NAMEColumn.ColumnName] = value; }
}

public DateTime StartDate
{
get { return
(DateTime)this[Timesheet.WPRD_START_DATEColumn.ColumnName]; }
set { this[Timesheet.WPRD_START_DATEColumn.ColumnName] = value; }
}

public DateTime FinishDate
{
get { return
(DateTime)this[Timesheet.WPRD_FINISH_DATEColumn.ColumnName]; }
set { this[Timesheet.WPRD_FINISH_DATEColumn.ColumnName] = value; }
}

public TimesheetHeaderDataObjectCollection Headers
{
get { return this.m_Headers; }
}

public TimesheetLineDataObjectCollection Lines
{
get { return this.m_Lines; }
}
#endregion

#region Methods
protected override void OnInitialise()
{
this.AddProperty(Timesheet.TS_UIDColumn.ColumnName,
typeof(Guid), Guid.Empty);
this.AddProperty(Timesheet.RES_UIDColumn.ColumnName,
typeof(Guid), Guid.Empty);
this.AddProperty(Timesheet.TS_NAMEColumn.ColumnName,
typeof(string), string.Empty);
this.AddProperty(Timesheet.WPRD_UIDColumn.ColumnName,
typeof(Guid), Guid.Empty);
this.AddProperty(Timesheet.WPRD_NAMEColumn.ColumnName,
typeof(string), string.Empty);
this.AddProperty(Timesheet.WPRD_START_DATEColumn.ColumnName,
typeof(DateTime), DateTime.MinValue);
this.AddProperty(Timesheet.WPRD_FINISH_DATEColumn.ColumnName,
typeof(DateTime), DateTime.MinValue);
}

protected override void OnPostLoad(object DataSource)
{
base.OnPostLoad(DataSource);
if ((DataSource!=null) && (DataSource is
TimesheetListDataSet.TimesheetsRow))
{
this.m_TimesheetRow =
(TimesheetListDataSet.TimesheetsRow)DataSource;
if ((this.m_TimesheetRow.Table!=null) &&
(this.m_TimesheetRow.Table is TimesheetListDataSet.TimesheetsDataTable))
this.m_TimesheetDataTable =
(TimesheetListDataSet.TimesheetsDataTable)this.m_TimesheetRow.Table;
if ((this.m_TimesheetDataTable != null) &&
(this.m_TimesheetDataTable.DataSet != null) &&
(this.m_TimesheetDataTable.DataSet is TimesheetListDataSet))
this.m_TimesheetListDataSet =
(TimesheetListDataSet)this.m_TimesheetDataTable.DataSet;
}
}

public void ReadData(Timesheets TimesheetSvc)
{
if ((TimesheetSvc != null) && (TimesheetSvc.Timesheetservice !=
null) && (!this.ID.Equals(Guid.Empty)))
{
if (this.m_Headers != null)
{
this.m_Headers.Dispose();
this.m_Headers = null;
}

if (this.m_Headers != null)
{
this.m_Lines.Dispose();
this.m_Lines = null;
}

TimesheetDataSet TimesheetDataSet =
TimesheetSvc.Timesheetservice.ReadTimesheet(this.ID);

this.m_Headers = new
TimesheetHeaderDataObjectCollection(TimesheetDataSet);
this.m_Lines = new
TimesheetLineDataObjectCollection(TimesheetDataSet);
this.m_TimesheetDataSet = TimesheetDataSet;
}
}

public void Create(Guid CreatorId, Timesheets TimesheetSvc, string
Name, string Comments)
{
if ((TimesheetSvc!=null) && ((this.Headers == null) ||
(this.Headers.Count < 1)))
{
this.m_TimesheetDataSet = new TimesheetDataSet();
this.ID = Guid.NewGuid();
TimesheetDataSet.HeadersRow headersRow =
this.m_TimesheetDataSet.Headers.NewHeadersRow();
headersRow.RES_UID = this.ResourceID;
headersRow.TS_UID = this.ID;
headersRow.WPRD_UID = this.TimePeriodID;
headersRow.TS_CREATOR_RES_UID = CreatorId;
headersRow.TS_NAME = Name;
headersRow.TS_COMMENTS = Comments;
headersRow.TS_ENTRY_MODE_ENUM =
(byte)PSLibrary.TimesheetEnum.EntryMode.Daily;
headersRow.TS_STATUS_ENUM =
(byte)PSLibrary.TimesheetEnum.Status.InProgress;
this.m_TimesheetDataSet.Headers.AddHeadersRow(headersRow);

// Create the timesheet with the default line types
specified by the admin

TimesheetSvc.Timesheetservice.CreateTimesheet(this.m_TimesheetDataSet,
MNR.Framework.TimesheetWebSvc.PreloadType.Default);
this.ReadData(TimesheetSvc);
}
}

public System.Guid
AddUnverifiedLine(MNR.Reporting.PSI.Data.QueueSystems Queue, Timesheets
TimesheetSvc,string ProjectName,string ExternalTaskId, string NameDesc,
string Comment, Admins.TimesheetLineClassDataObject LineClass)
{
if ((TimesheetSvc != null) && (this.TimesheetDataSet != null) &&
(!this.ID.Equals(Guid.Empty)) && (LineClass!=null) &&
(!LineClass.ID.Equals(Guid.Empty)))
{
TimesheetDataSet.LinesRow line =
this.TimesheetDataSet.Lines.NewLinesRow();
line.TS_UID = this.ID;
line.TS_LINE_UID = Guid.NewGuid();
line.TS_LINE_CLASS_UID = LineClass.ID;
line.TS_LINE_COMMENT = Comment;
line.TS_LINE_STATUS =
(byte)PSLibrary.TimesheetEnum.LineStatus.NotApplicable;
line.TS_LINE_VALIDATION_TYPE =
(byte)PSLibrary.TimesheetEnum.ValidationType.Unverified;
if ((NameDesc!=null) && (NameDesc.Length>0))
line.TS_LINE_CACHED_ASSIGN_NAME = NameDesc;
else
line.TS_LINE_CACHED_ASSIGN_NAME = ExternalTaskId;
line.TS_LINE_CACHED_PROJ_NAME = ProjectName;
this.TimesheetDataSet.Lines.AddLinesRow(line);

TimesheetSvc.Timesheetservice.PrepareTimesheetLine(this.ID,
ref this.m_TimesheetDataSet, new Guid[] { line.TS_LINE_UID });
Guid jobUid = Guid.NewGuid();
TimesheetSvc.Timesheetservice.QueueUpdateTimesheet(jobUid,
this.ID, this.m_TimesheetDataSet);
Queue.WaitForQueue(jobUid);
return line.TS_LINE_UID;
}

return Guid.Empty;
}

protected override void OnDispose()
{
base.OnDispose();
if (this.m_Headers != null)
{
this.m_Headers.Dispose();
this.m_Headers = null;
}

if (this.m_Headers != null)
{
this.m_Lines.Dispose();
this.m_Lines = null;
}
}
#endregion
}

/// <summary>
/// Summary description for TimesheetDataObjectCollection
/// Author, Date: Administrator, 2006/11/26 10:23:51 PM
/// Purpose:
/// </summary>
[Serializable]
public class TimesheetDataObjectCollection : ObjectBaseCollection
{
#region Data Members
 
J

Johnny

Has anyone found a solution for this yet? I'm running into the same error in
a similiar situation. I have timelines from previous timesheets im adding to
a new timesheet when the oncreated event is fired. this works fine when im
logged in as the box admin but when I log in as a regular user I get the same
error and none of the timelines are added. I dont see the need for
impersonation so I'm not sure if it's really needed or not. Can someone
please elaborate on this?

thanks!!!


tfz said:
I am having the same problem, but do you actually need to impersonate here?
Don't you just need to have "CreateSurrogateTimesheet" permissions?

Chris Boyd said:
Hey,

I can't seem to find in your code where you are setting up the
impersonation. Have you read:
http://msdn2.microsoft.com/en-us/library/aa974413.aspx. It goes over how to
impersonate a user via the PSI.

--
Chris Boyd
MS Project
Program Manager

Blog: http://blogs.msdn.com/project_programmability/


paul said:
Hi Chris, Thanks for your response. Please find code below:
using System;
using System.Data;
using System.Collections.Specialized;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using Microsoft.SharePoint;
using PSLibrary = Microsoft.Office.Project.Server.Library;
using MNR.Framework.TimesheetWebSvc;
using MNR.Data;
using MNR.MiddleTier.Data;

namespace MNR.Reporting.PSI.Data.Timesheets
{
[Serializable]
public class TimesheetDataObject : ObjectBase
{
#region Constants

#endregion

#region Data Members
public static TimesheetListDataSet.TimesheetsDataTable Timesheet =
new TimesheetListDataSet.TimesheetsDataTable();

private TimesheetListDataSet m_TimesheetListDataSet = null;
private TimesheetDataSet m_TimesheetDataSet = null;
private TimesheetListDataSet.TimesheetsDataTable
m_TimesheetDataTable = null;
private TimesheetListDataSet.TimesheetsRow m_TimesheetRow = null;
private TimesheetHeaderDataObjectCollection m_Headers = null;
private TimesheetLineDataObjectCollection m_Lines = null;
#endregion

#region Constructors
public TimesheetDataObject() : base() { }
public TimesheetDataObject(DataRow WsTimesheetRow)
{
this.LoadData(WsTimesheetRow);
}
#endregion

#region Properties
public TimesheetListDataSet TimesheetListDataSet
{
get { return this.m_TimesheetListDataSet; }
}

public TimesheetDataSet TimesheetDataSet
{
get { return this.m_TimesheetDataSet; }
}

public TimesheetListDataSet.TimesheetsDataTable TimesheetDataTable
{
get { return this.m_TimesheetDataTable; }
}

public TimesheetListDataSet.TimesheetsRow TimesheetRow
{
get { return this.m_TimesheetRow; }
set { this.LoadData(value); }
}

public Guid ID
{
get { return (Guid)this[Timesheet.TS_UIDColumn.ColumnName]; }
set { this[Timesheet.TS_UIDColumn.ColumnName] = value; }
}

public Guid ResourceID
{
get { return (Guid)this[Timesheet.RES_UIDColumn.ColumnName]; }
set { this[Timesheet.RES_UIDColumn.ColumnName] = value; }
}

public string Name
{
get { return (string)this[Timesheet.TS_NAMEColumn.ColumnName]; }
set { this[Timesheet.TS_NAMEColumn.ColumnName] = value; }
}

public Guid TimePeriodID
{
get { return (Guid)this[Timesheet.WPRD_UIDColumn.ColumnName]; }
set { this[Timesheet.WPRD_UIDColumn.ColumnName] = value; }
}

public string TimePeriodName
{
get { return (string)this[Timesheet.WPRD_NAMEColumn.ColumnName]; }
set { this[Timesheet.WPRD_NAMEColumn.ColumnName] = value; }
}

public DateTime StartDate
{
get { return
(DateTime)this[Timesheet.WPRD_START_DATEColumn.ColumnName]; }
set { this[Timesheet.WPRD_START_DATEColumn.ColumnName] = value; }
}

public DateTime FinishDate
{
get { return
(DateTime)this[Timesheet.WPRD_FINISH_DATEColumn.ColumnName]; }
set { this[Timesheet.WPRD_FINISH_DATEColumn.ColumnName] = value; }
}

public TimesheetHeaderDataObjectCollection Headers
{
get { return this.m_Headers; }
}

public TimesheetLineDataObjectCollection Lines
{
get { return this.m_Lines; }
}
#endregion

#region Methods
protected override void OnInitialise()
{
this.AddProperty(Timesheet.TS_UIDColumn.ColumnName,
typeof(Guid), Guid.Empty);
this.AddProperty(Timesheet.RES_UIDColumn.ColumnName,
typeof(Guid), Guid.Empty);
this.AddProperty(Timesheet.TS_NAMEColumn.ColumnName,
typeof(string), string.Empty);
this.AddProperty(Timesheet.WPRD_UIDColumn.ColumnName,
typeof(Guid), Guid.Empty);
this.AddProperty(Timesheet.WPRD_NAMEColumn.ColumnName,
typeof(string), string.Empty);
this.AddProperty(Timesheet.WPRD_START_DATEColumn.ColumnName,
typeof(DateTime), DateTime.MinValue);
this.AddProperty(Timesheet.WPRD_FINISH_DATEColumn.ColumnName,
typeof(DateTime), DateTime.MinValue);
}

protected override void OnPostLoad(object DataSource)
{
base.OnPostLoad(DataSource);
if ((DataSource!=null) && (DataSource is
TimesheetListDataSet.TimesheetsRow))
{
this.m_TimesheetRow =
(TimesheetListDataSet.TimesheetsRow)DataSource;
if ((this.m_TimesheetRow.Table!=null) &&
(this.m_TimesheetRow.Table is TimesheetListDataSet.TimesheetsDataTable))
this.m_TimesheetDataTable =
(TimesheetListDataSet.TimesheetsDataTable)this.m_TimesheetRow.Table;
if ((this.m_TimesheetDataTable != null) &&
(this.m_TimesheetDataTable.DataSet != null) &&
(this.m_TimesheetDataTable.DataSet is TimesheetListDataSet))
this.m_TimesheetListDataSet =
(TimesheetListDataSet)this.m_TimesheetDataTable.DataSet;
}
}

public void ReadData(Timesheets TimesheetSvc)
{
if ((TimesheetSvc != null) && (TimesheetSvc.Timesheetservice !=
null) && (!this.ID.Equals(Guid.Empty)))
{
if (this.m_Headers != null)
{
this.m_Headers.Dispose();
this.m_Headers = null;
}

if (this.m_Headers != null)
{
this.m_Lines.Dispose();
this.m_Lines = null;
}

TimesheetDataSet TimesheetDataSet =
TimesheetSvc.Timesheetservice.ReadTimesheet(this.ID);

this.m_Headers = new
TimesheetHeaderDataObjectCollection(TimesheetDataSet);
this.m_Lines = new
TimesheetLineDataObjectCollection(TimesheetDataSet);
this.m_TimesheetDataSet = TimesheetDataSet;
}
}

public void Create(Guid CreatorId, Timesheets TimesheetSvc, string
Name, string Comments)
{
if ((TimesheetSvc!=null) && ((this.Headers == null) ||
(this.Headers.Count < 1)))
{
this.m_TimesheetDataSet = new TimesheetDataSet();
this.ID = Guid.NewGuid();
TimesheetDataSet.HeadersRow headersRow =
this.m_TimesheetDataSet.Headers.NewHeadersRow();
headersRow.RES_UID = this.ResourceID;
headersRow.TS_UID = this.ID;
headersRow.WPRD_UID = this.TimePeriodID;
headersRow.TS_CREATOR_RES_UID = CreatorId;
headersRow.TS_NAME = Name;
headersRow.TS_COMMENTS = Comments;
headersRow.TS_ENTRY_MODE_ENUM =
(byte)PSLibrary.TimesheetEnum.EntryMode.Daily;
headersRow.TS_STATUS_ENUM =
(byte)PSLibrary.TimesheetEnum.Status.InProgress;
this.m_TimesheetDataSet.Headers.AddHeadersRow(headersRow);

// Create the timesheet with the default line types
specified by the admin

TimesheetSvc.Timesheetservice.CreateTimesheet(this.m_TimesheetDataSet,
MNR.Framework.TimesheetWebSvc.PreloadType.Default);
this.ReadData(TimesheetSvc);
}
}

public System.Guid
AddUnverifiedLine(MNR.Reporting.PSI.Data.QueueSystems Queue, Timesheets
TimesheetSvc,string ProjectName,string ExternalTaskId, string NameDesc,
string Comment, Admins.TimesheetLineClassDataObject LineClass)
{
if ((TimesheetSvc != null) && (this.TimesheetDataSet != null) &&
(!this.ID.Equals(Guid.Empty)) && (LineClass!=null) &&
(!LineClass.ID.Equals(Guid.Empty)))
{
TimesheetDataSet.LinesRow line =
this.TimesheetDataSet.Lines.NewLinesRow();
line.TS_UID = this.ID;
line.TS_LINE_UID = Guid.NewGuid();
line.TS_LINE_CLASS_UID = LineClass.ID;
line.TS_LINE_COMMENT = Comment;
line.TS_LINE_STATUS =
(byte)PSLibrary.TimesheetEnum.LineStatus.NotApplicable;
line.TS_LINE_VALIDATION_TYPE =
(byte)PSLibrary.TimesheetEnum.ValidationType.Unverified;
if ((NameDesc!=null) && (NameDesc.Length>0))
line.TS_LINE_CACHED_ASSIGN_NAME = NameDesc;
else
line.TS_LINE_CACHED_ASSIGN_NAME = ExternalTaskId;
line.TS_LINE_CACHED_PROJ_NAME = ProjectName;
this.TimesheetDataSet.Lines.AddLinesRow(line);

TimesheetSvc.Timesheetservice.PrepareTimesheetLine(this.ID,
ref this.m_TimesheetDataSet, new Guid[] { line.TS_LINE_UID });
Guid jobUid = Guid.NewGuid();
TimesheetSvc.Timesheetservice.QueueUpdateTimesheet(jobUid,
this.ID, this.m_TimesheetDataSet);
Queue.WaitForQueue(jobUid);
return line.TS_LINE_UID;
}

return Guid.Empty;
}

protected override void OnDispose()
{
base.OnDispose();
if (this.m_Headers != null)
{
this.m_Headers.Dispose();
this.m_Headers = null;
}

if (this.m_Headers != null)
{
this.m_Lines.Dispose();
this.m_Lines = null;
}
}
#endregion
}

/// <summary>
/// Summary description for TimesheetDataObjectCollection
/// Author, Date: Administrator, 2006/11/26 10:23:51 PM
/// Purpose:
 
J

jlandry

Hello,

I did use the impersonation technique that Chris is mentioning in a solution
which is importing progrmmatically the timisheet in the statusing, when user
is submitting his timesheet and it works just fine. I able to impersonate the
current user to go one level higher in order to perform the importation when
the user isn't his timesheet manager.

Here is a bit of what it looks like:

// Check if surrogate timesheet
//
if (tsHeader.CreatorResUID != tsHeader.ResUID)
{

statusingWS.SetImpersonationContext(resourcePSI.IsWindowsUser,
resourcePSI.WindowsAccount, resourceUID, Guid.Empty, contextInfo.SiteGuid,
contextInfo.Lcid);
}
else
{
// Faster check that calling the resource web service
//
bool isWindowsUser =
contextInfo.UserName.StartsWith("AspNetSqlMembershipProvider") ? false : true;
statusingWS.SetImpersonationContext(isWindowsUser,
contextInfo.UserName, resourceUID, Guid.Empty, contextInfo.SiteGuid,
contextInfo.Lcid);
}

Here is what the "SetImpersonationContext()" method is doing (I haven't
change a thing from Chris sample):

public void SetImpersonationContext(bool isWindowsUser, String
userNTAccount, Guid userGuid, Guid trackingGuid, Guid siteId, String lcid)
{
contextString = GetImpersonationContext(isWindowsUser,
userNTAccount, userGuid, trackingGuid, siteId, lcid);
}

It is working correctly and I have already installed it within our
production environment while I implemented the Timesheet Tie-Mode sample
provided on Codeplex Web site.

However, it is easier to have a better overall view of this solution when
reading the whole class file.

If you need more informations, feel free to ask.

Jean


Johnny said:
Has anyone found a solution for this yet? I'm running into the same error in
a similiar situation. I have timelines from previous timesheets im adding to
a new timesheet when the oncreated event is fired. this works fine when im
logged in as the box admin but when I log in as a regular user I get the same
error and none of the timelines are added. I dont see the need for
impersonation so I'm not sure if it's really needed or not. Can someone
please elaborate on this?

thanks!!!


tfz said:
I am having the same problem, but do you actually need to impersonate here?
Don't you just need to have "CreateSurrogateTimesheet" permissions?

Chris Boyd said:
Hey,

I can't seem to find in your code where you are setting up the
impersonation. Have you read:
http://msdn2.microsoft.com/en-us/library/aa974413.aspx. It goes over how to
impersonate a user via the PSI.

--
Chris Boyd
MS Project
Program Manager

Blog: http://blogs.msdn.com/project_programmability/


:

Hi Chris, Thanks for your response. Please find code below:
using System;
using System.Data;
using System.Collections.Specialized;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using Microsoft.SharePoint;
using PSLibrary = Microsoft.Office.Project.Server.Library;
using MNR.Framework.TimesheetWebSvc;
using MNR.Data;
using MNR.MiddleTier.Data;

namespace MNR.Reporting.PSI.Data.Timesheets
{
[Serializable]
public class TimesheetDataObject : ObjectBase
{
#region Constants

#endregion

#region Data Members
public static TimesheetListDataSet.TimesheetsDataTable Timesheet =
new TimesheetListDataSet.TimesheetsDataTable();

private TimesheetListDataSet m_TimesheetListDataSet = null;
private TimesheetDataSet m_TimesheetDataSet = null;
private TimesheetListDataSet.TimesheetsDataTable
m_TimesheetDataTable = null;
private TimesheetListDataSet.TimesheetsRow m_TimesheetRow = null;
private TimesheetHeaderDataObjectCollection m_Headers = null;
private TimesheetLineDataObjectCollection m_Lines = null;
#endregion

#region Constructors
public TimesheetDataObject() : base() { }
public TimesheetDataObject(DataRow WsTimesheetRow)
{
this.LoadData(WsTimesheetRow);
}
#endregion

#region Properties
public TimesheetListDataSet TimesheetListDataSet
{
get { return this.m_TimesheetListDataSet; }
}

public TimesheetDataSet TimesheetDataSet
{
get { return this.m_TimesheetDataSet; }
}

public TimesheetListDataSet.TimesheetsDataTable TimesheetDataTable
{
get { return this.m_TimesheetDataTable; }
}

public TimesheetListDataSet.TimesheetsRow TimesheetRow
{
get { return this.m_TimesheetRow; }
set { this.LoadData(value); }
}

public Guid ID
{
get { return (Guid)this[Timesheet.TS_UIDColumn.ColumnName]; }
set { this[Timesheet.TS_UIDColumn.ColumnName] = value; }
}

public Guid ResourceID
{
get { return (Guid)this[Timesheet.RES_UIDColumn.ColumnName]; }
set { this[Timesheet.RES_UIDColumn.ColumnName] = value; }
}

public string Name
{
get { return (string)this[Timesheet.TS_NAMEColumn.ColumnName]; }
set { this[Timesheet.TS_NAMEColumn.ColumnName] = value; }
}

public Guid TimePeriodID
{
get { return (Guid)this[Timesheet.WPRD_UIDColumn.ColumnName]; }
set { this[Timesheet.WPRD_UIDColumn.ColumnName] = value; }
}

public string TimePeriodName
{
get { return (string)this[Timesheet.WPRD_NAMEColumn.ColumnName]; }
set { this[Timesheet.WPRD_NAMEColumn.ColumnName] = value; }
}

public DateTime StartDate
{
get { return
(DateTime)this[Timesheet.WPRD_START_DATEColumn.ColumnName]; }
set { this[Timesheet.WPRD_START_DATEColumn.ColumnName] = value; }
}

public DateTime FinishDate
{
get { return
(DateTime)this[Timesheet.WPRD_FINISH_DATEColumn.ColumnName]; }
set { this[Timesheet.WPRD_FINISH_DATEColumn.ColumnName] = value; }
}

public TimesheetHeaderDataObjectCollection Headers
{
get { return this.m_Headers; }
}

public TimesheetLineDataObjectCollection Lines
{
get { return this.m_Lines; }
}
#endregion

#region Methods
protected override void OnInitialise()
{
this.AddProperty(Timesheet.TS_UIDColumn.ColumnName,
typeof(Guid), Guid.Empty);
this.AddProperty(Timesheet.RES_UIDColumn.ColumnName,
typeof(Guid), Guid.Empty);
this.AddProperty(Timesheet.TS_NAMEColumn.ColumnName,
typeof(string), string.Empty);
this.AddProperty(Timesheet.WPRD_UIDColumn.ColumnName,
typeof(Guid), Guid.Empty);
this.AddProperty(Timesheet.WPRD_NAMEColumn.ColumnName,
typeof(string), string.Empty);
this.AddProperty(Timesheet.WPRD_START_DATEColumn.ColumnName,
typeof(DateTime), DateTime.MinValue);
this.AddProperty(Timesheet.WPRD_FINISH_DATEColumn.ColumnName,
typeof(DateTime), DateTime.MinValue);
}

protected override void OnPostLoad(object DataSource)
{
base.OnPostLoad(DataSource);
if ((DataSource!=null) && (DataSource is
TimesheetListDataSet.TimesheetsRow))
{
this.m_TimesheetRow =
(TimesheetListDataSet.TimesheetsRow)DataSource;
if ((this.m_TimesheetRow.Table!=null) &&
(this.m_TimesheetRow.Table is TimesheetListDataSet.TimesheetsDataTable))
this.m_TimesheetDataTable =
(TimesheetListDataSet.TimesheetsDataTable)this.m_TimesheetRow.Table;
if ((this.m_TimesheetDataTable != null) &&
(this.m_TimesheetDataTable.DataSet != null) &&
(this.m_TimesheetDataTable.DataSet is TimesheetListDataSet))
this.m_TimesheetListDataSet =
(TimesheetListDataSet)this.m_TimesheetDataTable.DataSet;
}
}

public void ReadData(Timesheets TimesheetSvc)
{
if ((TimesheetSvc != null) && (TimesheetSvc.Timesheetservice !=
null) && (!this.ID.Equals(Guid.Empty)))
{
if (this.m_Headers != null)
{
this.m_Headers.Dispose();
this.m_Headers = null;
}

if (this.m_Headers != null)
{
this.m_Lines.Dispose();
this.m_Lines = null;
}

TimesheetDataSet TimesheetDataSet =
TimesheetSvc.Timesheetservice.ReadTimesheet(this.ID);

this.m_Headers = new
TimesheetHeaderDataObjectCollection(TimesheetDataSet);
this.m_Lines = new
TimesheetLineDataObjectCollection(TimesheetDataSet);
this.m_TimesheetDataSet = TimesheetDataSet;
}
}

public void Create(Guid CreatorId, Timesheets TimesheetSvc, string
Name, string Comments)
{
if ((TimesheetSvc!=null) && ((this.Headers == null) ||
(this.Headers.Count < 1)))
{
this.m_TimesheetDataSet = new TimesheetDataSet();
this.ID = Guid.NewGuid();
TimesheetDataSet.HeadersRow headersRow =
this.m_TimesheetDataSet.Headers.NewHeadersRow();
headersRow.RES_UID = this.ResourceID;
headersRow.TS_UID = this.ID;
headersRow.WPRD_UID = this.TimePeriodID;
headersRow.TS_CREATOR_RES_UID = CreatorId;
headersRow.TS_NAME = Name;
headersRow.TS_COMMENTS = Comments;
headersRow.TS_ENTRY_MODE_ENUM =
(byte)PSLibrary.TimesheetEnum.EntryMode.Daily;
headersRow.TS_STATUS_ENUM =
(byte)PSLibrary.TimesheetEnum.Status.InProgress;
this.m_TimesheetDataSet.Headers.AddHeadersRow(headersRow);

// Create the timesheet with the default line types
specified by the admin

TimesheetSvc.Timesheetservice.CreateTimesheet(this.m_TimesheetDataSet,
MNR.Framework.TimesheetWebSvc.PreloadType.Default);
this.ReadData(TimesheetSvc);
}
}

public System.Guid
AddUnverifiedLine(MNR.Reporting.PSI.Data.QueueSystems Queue, Timesheets
TimesheetSvc,string ProjectName,string ExternalTaskId, string NameDesc,
string Comment, Admins.TimesheetLineClassDataObject LineClass)
{
if ((TimesheetSvc != null) && (this.TimesheetDataSet != null) &&
(!this.ID.Equals(Guid.Empty)) && (LineClass!=null) &&
(!LineClass.ID.Equals(Guid.Empty)))
{
TimesheetDataSet.LinesRow line =
this.TimesheetDataSet.Lines.NewLinesRow();
line.TS_UID = this.ID;
line.TS_LINE_UID = Guid.NewGuid();
line.TS_LINE_CLASS_UID = LineClass.ID;
line.TS_LINE_COMMENT = Comment;
line.TS_LINE_STATUS =
(byte)PSLibrary.TimesheetEnum.LineStatus.NotApplicable;
line.TS_LINE_VALIDATION_TYPE =
(byte)PSLibrary.TimesheetEnum.ValidationType.Unverified;
if ((NameDesc!=null) && (NameDesc.Length>0))
line.TS_LINE_CACHED_ASSIGN_NAME = NameDesc;
else
line.TS_LINE_CACHED_ASSIGN_NAME = ExternalTaskId;
line.TS_LINE_CACHED_PROJ_NAME = ProjectName;
this.TimesheetDataSet.Lines.AddLinesRow(line);

TimesheetSvc.Timesheetservice.PrepareTimesheetLine(this.ID,
ref this.m_TimesheetDataSet, new Guid[] { line.TS_LINE_UID });
Guid jobUid = Guid.NewGuid();
TimesheetSvc.Timesheetservice.QueueUpdateTimesheet(jobUid,
this.ID, this.m_TimesheetDataSet);
Queue.WaitForQueue(jobUid);
return line.TS_LINE_UID;
}

return Guid.Empty;
}

protected override void OnDispose()
{
base.OnDispose();
if (this.m_Headers != null)
{
this.m_Headers.Dispose();
this.m_Headers = null;
}
 
A

ArvindCalifornia

I am working on a requirement which requires updating the actual hour against
resources and actual cost against the task for a particular projcet.
We are using Statusing web service to update the actual hour of the
resources on date basis.
We are using status method to update the actuals.
We can only invoke this method if the user is an administrator otherwise we
encounter General Security Exception. And only the resource can update
his\her own actuals. if using some other resource account we try to update
the actuals we again get General Security Exception.

Currently we are using a single dedicated account to call the web service
and method. After googling we came up with impersonation to actually update
the actuals for all the resources using a single dedicated account. We are
trying to achieve impersontaion in PSI using SSP in Project Server.

But while calling SSP from my .net component which runs on the Project
Server where PWA is hosted i am getting HTTP 401 error.
The account which i am using to call the SSP web service has administrator
previliges in Project Web Access.
Please suggest me the resolution.

Please do the needful.


--
ArvindCalifornia


jlandry said:
Hello,

I did use the impersonation technique that Chris is mentioning in a solution
which is importing progrmmatically the timisheet in the statusing, when user
is submitting his timesheet and it works just fine. I able to impersonate the
current user to go one level higher in order to perform the importation when
the user isn't his timesheet manager.

Here is a bit of what it looks like:

// Check if surrogate timesheet
//
if (tsHeader.CreatorResUID != tsHeader.ResUID)
{

statusingWS.SetImpersonationContext(resourcePSI.IsWindowsUser,
resourcePSI.WindowsAccount, resourceUID, Guid.Empty, contextInfo.SiteGuid,
contextInfo.Lcid);
}
else
{
// Faster check that calling the resource web service
//
bool isWindowsUser =
contextInfo.UserName.StartsWith("AspNetSqlMembershipProvider") ? false : true;
statusingWS.SetImpersonationContext(isWindowsUser,
contextInfo.UserName, resourceUID, Guid.Empty, contextInfo.SiteGuid,
contextInfo.Lcid);
}

Here is what the "SetImpersonationContext()" method is doing (I haven't
change a thing from Chris sample):

public void SetImpersonationContext(bool isWindowsUser, String
userNTAccount, Guid userGuid, Guid trackingGuid, Guid siteId, String lcid)
{
contextString = GetImpersonationContext(isWindowsUser,
userNTAccount, userGuid, trackingGuid, siteId, lcid);
}

It is working correctly and I have already installed it within our
production environment while I implemented the Timesheet Tie-Mode sample
provided on Codeplex Web site.

However, it is easier to have a better overall view of this solution when
reading the whole class file.

If you need more informations, feel free to ask.

Jean


Johnny said:
Has anyone found a solution for this yet? I'm running into the same error in
a similiar situation. I have timelines from previous timesheets im adding to
a new timesheet when the oncreated event is fired. this works fine when im
logged in as the box admin but when I log in as a regular user I get the same
error and none of the timelines are added. I dont see the need for
impersonation so I'm not sure if it's really needed or not. Can someone
please elaborate on this?

thanks!!!


tfz said:
I am having the same problem, but do you actually need to impersonate here?
Don't you just need to have "CreateSurrogateTimesheet" permissions?

:

Hey,

I can't seem to find in your code where you are setting up the
impersonation. Have you read:
http://msdn2.microsoft.com/en-us/library/aa974413.aspx. It goes over how to
impersonate a user via the PSI.

--
Chris Boyd
MS Project
Program Manager

Blog: http://blogs.msdn.com/project_programmability/


:

Hi Chris, Thanks for your response. Please find code below:
using System;
using System.Data;
using System.Collections.Specialized;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using Microsoft.SharePoint;
using PSLibrary = Microsoft.Office.Project.Server.Library;
using MNR.Framework.TimesheetWebSvc;
using MNR.Data;
using MNR.MiddleTier.Data;

namespace MNR.Reporting.PSI.Data.Timesheets
{
[Serializable]
public class TimesheetDataObject : ObjectBase
{
#region Constants

#endregion

#region Data Members
public static TimesheetListDataSet.TimesheetsDataTable Timesheet =
new TimesheetListDataSet.TimesheetsDataTable();

private TimesheetListDataSet m_TimesheetListDataSet = null;
private TimesheetDataSet m_TimesheetDataSet = null;
private TimesheetListDataSet.TimesheetsDataTable
m_TimesheetDataTable = null;
private TimesheetListDataSet.TimesheetsRow m_TimesheetRow = null;
private TimesheetHeaderDataObjectCollection m_Headers = null;
private TimesheetLineDataObjectCollection m_Lines = null;
#endregion

#region Constructors
public TimesheetDataObject() : base() { }
public TimesheetDataObject(DataRow WsTimesheetRow)
{
this.LoadData(WsTimesheetRow);
}
#endregion

#region Properties
public TimesheetListDataSet TimesheetListDataSet
{
get { return this.m_TimesheetListDataSet; }
}

public TimesheetDataSet TimesheetDataSet
{
get { return this.m_TimesheetDataSet; }
}

public TimesheetListDataSet.TimesheetsDataTable TimesheetDataTable
{
get { return this.m_TimesheetDataTable; }
}

public TimesheetListDataSet.TimesheetsRow TimesheetRow
{
get { return this.m_TimesheetRow; }
set { this.LoadData(value); }
}

public Guid ID
{
get { return (Guid)this[Timesheet.TS_UIDColumn.ColumnName]; }
set { this[Timesheet.TS_UIDColumn.ColumnName] = value; }
}

public Guid ResourceID
{
get { return (Guid)this[Timesheet.RES_UIDColumn.ColumnName]; }
set { this[Timesheet.RES_UIDColumn.ColumnName] = value; }
}

public string Name
{
get { return (string)this[Timesheet.TS_NAMEColumn.ColumnName]; }
set { this[Timesheet.TS_NAMEColumn.ColumnName] = value; }
}

public Guid TimePeriodID
{
get { return (Guid)this[Timesheet.WPRD_UIDColumn.ColumnName]; }
set { this[Timesheet.WPRD_UIDColumn.ColumnName] = value; }
}

public string TimePeriodName
{
get { return (string)this[Timesheet.WPRD_NAMEColumn.ColumnName]; }
set { this[Timesheet.WPRD_NAMEColumn.ColumnName] = value; }
}

public DateTime StartDate
{
get { return
(DateTime)this[Timesheet.WPRD_START_DATEColumn.ColumnName]; }
set { this[Timesheet.WPRD_START_DATEColumn.ColumnName] = value; }
}

public DateTime FinishDate
{
get { return
(DateTime)this[Timesheet.WPRD_FINISH_DATEColumn.ColumnName]; }
set { this[Timesheet.WPRD_FINISH_DATEColumn.ColumnName] = value; }
}

public TimesheetHeaderDataObjectCollection Headers
{
get { return this.m_Headers; }
}

public TimesheetLineDataObjectCollection Lines
{
get { return this.m_Lines; }
}
#endregion

#region Methods
protected override void OnInitialise()
{
this.AddProperty(Timesheet.TS_UIDColumn.ColumnName,
typeof(Guid), Guid.Empty);
this.AddProperty(Timesheet.RES_UIDColumn.ColumnName,
typeof(Guid), Guid.Empty);
this.AddProperty(Timesheet.TS_NAMEColumn.ColumnName,
typeof(string), string.Empty);
this.AddProperty(Timesheet.WPRD_UIDColumn.ColumnName,
typeof(Guid), Guid.Empty);
this.AddProperty(Timesheet.WPRD_NAMEColumn.ColumnName,
typeof(string), string.Empty);
this.AddProperty(Timesheet.WPRD_START_DATEColumn.ColumnName,
typeof(DateTime), DateTime.MinValue);
this.AddProperty(Timesheet.WPRD_FINISH_DATEColumn.ColumnName,
typeof(DateTime), DateTime.MinValue);
}

protected override void OnPostLoad(object DataSource)
{
base.OnPostLoad(DataSource);
if ((DataSource!=null) && (DataSource is
TimesheetListDataSet.TimesheetsRow))
{
this.m_TimesheetRow =
(TimesheetListDataSet.TimesheetsRow)DataSource;
if ((this.m_TimesheetRow.Table!=null) &&
(this.m_TimesheetRow.Table is TimesheetListDataSet.TimesheetsDataTable))
this.m_TimesheetDataTable =
(TimesheetListDataSet.TimesheetsDataTable)this.m_TimesheetRow.Table;
if ((this.m_TimesheetDataTable != null) &&
(this.m_TimesheetDataTable.DataSet != null) &&
(this.m_TimesheetDataTable.DataSet is TimesheetListDataSet))
this.m_TimesheetListDataSet =
(TimesheetListDataSet)this.m_TimesheetDataTable.DataSet;
}
}

public void ReadData(Timesheets TimesheetSvc)
{
if ((TimesheetSvc != null) && (TimesheetSvc.Timesheetservice !=
null) && (!this.ID.Equals(Guid.Empty)))
{
if (this.m_Headers != null)
{
this.m_Headers.Dispose();
this.m_Headers = null;
}

if (this.m_Headers != null)
{
this.m_Lines.Dispose();
this.m_Lines = null;
}

TimesheetDataSet TimesheetDataSet =
TimesheetSvc.Timesheetservice.ReadTimesheet(this.ID);

this.m_Headers = new
TimesheetHeaderDataObjectCollection(TimesheetDataSet);
this.m_Lines = new
TimesheetLineDataObjectCollection(TimesheetDataSet);
this.m_TimesheetDataSet = TimesheetDataSet;
}
}

public void Create(Guid CreatorId, Timesheets TimesheetSvc, string
Name, string Comments)
{
if ((TimesheetSvc!=null) && ((this.Headers == null) ||
(this.Headers.Count < 1)))
{
this.m_TimesheetDataSet = new TimesheetDataSet();
this.ID = Guid.NewGuid();
TimesheetDataSet.HeadersRow headersRow =
this.m_TimesheetDataSet.Headers.NewHeadersRow();
headersRow.RES_UID = this.ResourceID;
headersRow.TS_UID = this.ID;
headersRow.WPRD_UID = this.TimePeriodID;
headersRow.TS_CREATOR_RES_UID = CreatorId;
headersRow.TS_NAME = Name;
headersRow.TS_COMMENTS = Comments;
headersRow.TS_ENTRY_MODE_ENUM =
(byte)PSLibrary.TimesheetEnum.EntryMode.Daily;
headersRow.TS_STATUS_ENUM =
(byte)PSLibrary.TimesheetEnum.Status.InProgress;
this.m_TimesheetDataSet.Headers.AddHeadersRow(headersRow);

// Create the timesheet with the default line types
specified by the admin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top