Asked by:
Can not read the Resource Calendar Exceptions using PSI

Question
-
Hello,
I'm trying to read the CalendarExceptions for a Resource, but I'm getting a Fault Exception every time (System.ServiceModel.FaultException`1 was unhandled
Message=ProjectServerError(s) LastError=GeneralUnhandledException Instructions: Pass this into PSClientError constructor to access all error information).
I attach here the code I'm using - what am I doing wrong? - Thanks!
// Get the ID of the user.
Guid currentUserGuid = resourceClient.GetCurrentUserUid();
//Prepare filter
SvcResource.ResourceDataSet resourceDS = new SvcResource.ResourceDataSet();
PSLibrary.Filter filter = new PSLibrary.Filter();
filter.FilterTableName = resourceDS.Resources.TableName;
//filter.FilterTableName = resourceDS.CalendarExceptions.TableName;
filter.Fields.Add(new PSLibrary.Filter.Field(resourceDS.CalendarExceptions.TableName,
resourceDS.CalendarExceptions.RES_UIDColumn.ColumnName,
PSLibrary.Filter.SortOrderTypeEnum.None));
filter.Fields.Add(new PSLibrary.Filter.Field(resourceDS.CalendarExceptions.TableName,
resourceDS.CalendarExceptions.StartColumn.ColumnName,
PSLibrary.Filter.SortOrderTypeEnum.None));
filter.Fields.Add(new PSLibrary.Filter.Field(resourceDS.CalendarExceptions.TableName,
resourceDS.CalendarExceptions.FinishColumn.ColumnName,
PSLibrary.Filter.SortOrderTypeEnum.None));
//Add a filter to restrict the return results to the current user
PSLibrary.Filter.FieldOperator criteriaCurrentResource = new PSLibrary.Filter.FieldOperator(
PSLibrary.Filter.FieldOperationType.Equal,
resourceDS.Resources.RES_UIDColumn.ColumnName,
currentUserGuid.ToString()
);
filter.Criteria = criteriaCurrentResource;
resourceDS = resourceClient.ReadResources(filter.GetXml(), false);
Joao- Moved by Alexander.Burton Wednesday, January 26, 2011 6:55 PM Moving to programming forum (From:Project Server General Questions and Answers)
Wednesday, January 26, 2011 4:00 PM
All replies
-
Hi Joao,
For starters, catch the ServiceModel.FaultException in a try - catch block, and extract information about the error stack. For an example of how to do that, see the WCF example in the QueueCreateProject method. Also take a look at the ULS log.
Jim Corbin [MSFT]Thursday, January 27, 2011 3:37 PM -
Thanks a lot, Jim.
By the way, I'm using Project Server 2010 / Visual Studio 2010 / .Net 4.
In the ULS there's nothing special.
If I try the exact same code above to read any other Resource data, such as ResourceAvailabilities, ResourceRates or ResourceCustomFields it works fine.
I only get an exception while trying to read the Resource CalendarExceptions:
System.ServiceModel.FaultException`1 was unhandled
Message=ProjectServerError(s) LastError=ResourceFilterInvalid Instructions: Pass this into PSClientError constructor to access all error information
Source=mscorlib
StackTrace:
Server stack trace:
at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at SvcResource.Resource.ReadResources(String xmlFilter, Boolean autoCheckOut)
at SvcResource.ResourceClient.ReadResources(String xmlFilter, Boolean autoCheckOut)
at WindowsFormsApplication1.Form1.alfa() in D:\CODE\ProjectServerVacations\WindowsFormsApplication1\Form1.cs:line 435
at WindowsFormsApplication1.Form1.button1_Click(Object sender, EventArgs e) in D:\CODE\ProjectServerVacations\WindowsFormsApplication1\Form1.cs:line 440
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at WindowsFormsApplication1.Program.Main() in D:\CODE\ProjectServerVacations\WindowsFormsApplication1\Program.cs:line 18
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
JoaoThursday, January 27, 2011 4:26 PM -
Oops... use .NET 3.5, not 4. That may have nothing to do with the problem, but Project Server is built with 3.5.
Jim Corbin [MSFT]Thursday, January 27, 2011 4:34 PM -
Thanks again, Jim!
I've changed the project to .Net 3.5 and the behavior is exactly the same.
JoaoThursday, January 27, 2011 5:57 PM -
-
Thanks Andrew.
Because I'm integrating the system where our employees book their vacations with Project Server, I need to programmatically access, iterate and manipulate the Resource CalendarExceptions.
JoaoFriday, January 28, 2011 10:00 AM -
That's what I figured, but had to mention it. Good luck!
Andrew Lavinsky [MVP] Twitter: @alavinskyFriday, January 28, 2011 4:48 PM -
This is expected and documented Joao - but I assume you can still get to the data you want - but may need to pulll more back.
From the SDK
The xmlFilter parameter works with the Criteria operators to filter rows only in the primary ResourcesDataTable. For example, you cannot use xmlFilter with the ReadResources method to filter rows in the CalendarExceptionsDataTable. If you try to filter rows in a secondary DataTable, the PSI returns a FilterInvalid exception.
Best regards,
Brian.
Blog | Facebook | Twitter | Posting is provided "AS IS" with no warranties, and confers no rights.
Project Server TechCenter | Project Developer Center | Project Server Help | Project Product PageThursday, February 3, 2011 11:54 PM -
Thanks, Brian!
Yes - I've read the documentation. However, I'm not using any Criteria related to the CalendarExceptionsDataTable - I'm only selecting columns from it. It works fine for the other Resource tables such as: ResourceAvailabilities, ResourceRates or ResourceCustomFields, so I'm wondering why it doesn't work for this particular table.
Do you know other method to get access to this data?
Best regards,
João
JoaoFriday, February 4, 2011 9:09 AM -
From your example it looks like you are trying to read calendar exceptions for a specific resource. I have been able to do that as follows:
resourceDs = resourceClient.ReadResource(new Guid("b62b0cd3-4736-4504-a648-9d9c9403f556")); Console.WriteLine("Resource calendar exceptions:"); foreach (ResourceDataSet.CalendarExceptionsRow calendarException in resourceDs.CalendarExceptions) { Console.WriteLine(calendarException.Name + ", " + calendarException.Start.ToShortDateString() + ", " + calendarException.Finish.ToShortDateString()); }
Monday, December 3, 2012 8:55 PM -
same here, I have to access project web service to read and manipulate data starting from vacations (inserted into a sql server)
any suggestions on how to proceed?
I'm waiting for the access to the MS project server, I still haven't written a single line of code
Tuesday, December 18, 2012 11:56 AM