Issue reading requestparameter operation/Mode type from workflow
-
16 พฤษภาคม 2555 18:01
Hi,
I have written a Action workflow and it is getting executed upon a change in value(s) of an MVA called "Profiles". In this action workflow I am trying to ReadRequestparameters. My goal is to read what gets added and what gets deleted and update database based on that.
This is my workflow:
Below is the private function I am calling from the WriteToDatabase coded activity, just to check I am getting appropriate request parameters & values.
private void DumpRequest(Activity callingActivity) { ReadOnlyCollection<CreateRequestParameter> _requestParameters = FIMCurrentRequestActivity_CurrentRequest.ParseParameters<CreateRequestParameter>(); SequentialWorkflow containingWorkflow = null; if (!SequentialWorkflow.TryGetContainingWorkflow(callingActivity, out containingWorkflow)) throw new ApplicationException("Internal error - unable to get Containing Workflow"); foreach (CreateRequestParameter requestParameter in _requestParameters) WriteToLogFile("RequestParameter (\"" + requestParameter.PropertyName + "\")= \"" + requestParameter.Value.ToString() + requestParameter.Operation + "\""); WriteToLogFile("Workflow Dictionary"); foreach (KeyValuePair<string, object> dItem in containingWorkflow.WorkflowDictionary) WriteToLogFile("Dictionary Entry (\"" + dItem.Key + "\") = \"" + dItem.Value.ToString() + "\""); }Here is the request xml, copied from the FIM2010 Portal.
<RequestParameter xmlns:q1="http://microsoft.com/wsdl/types/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="UpdateRequestParameter"> <Target>1e38d694-ae63-4b3c-b9df-ad06aa8d8b47</Target> <Calculated>false</Calculated> <PropertyName>Profiles</PropertyName> <Value xsi:type="xsd:string">1123</Value> <Operation>Create</Operation> <Mode>Add</Mode> </RequestParameter> ------------------------------------------------------------ <RequestParameter xmlns:q1="http://microsoft.com/wsdl/types/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="UpdateRequestParameter"> <Target>1e38d694-ae63-4b3c-b9df-ad06aa8d8b47</Target> <Calculated>false</Calculated> <PropertyName>Profiles</PropertyName> <Value xsi:type="xsd:string">1123</Value> <Operation>Create</Operation> <Mode>Remove</Mode> </RequestParameter>
This is the request UI where it shows "Add" and "Remove" as Operations:
Now my question here is why the request xml shows "Create" opertions only? How I can read the deleted value here. RequestParameter doesn't offer any property to read the Mode of the operation. Is there any better way to read what gets deleted from the MVA and what gets added in MVA?
Thanks for your help.
Bhavesh
ตอบทั้งหมด
-
16 พฤษภาคม 2555 20:59
I'm actually doing the same thing, but only working with added multivalue items
I'm a little confused on the XML snips - since both are showing the 1123 value and I don't see the 123 value. typo maybe?
In my code I am checking the mode - like this (CurrentRequestActivity is named 'ReadRequest')
if (ReadRequest.CurrentRequest.Operation == OperationType.Put)
{
foreach (UpdateRequestParameter updateRequestParameter in ReadRequest.CurrentRequest.ParseParameters<UpdateRequestParameter>())
{
if ( updateRequestParameter.PropertyName == "GoupsToAdd";
&& updateRequestParameter.Mode == UpdateMode.Insert )
{
groups.Add(new Guid(updateRequestParameter.Value.ToString() ) );
}
}
}Frank C. Drewes III - Senior Consultant: Oxford Computer Group
- ทำเครื่องหมายเป็นคำตอบโดย bhavesh001 17 พฤษภาคม 2555 13:33
-
17 พฤษภาคม 2555 13:42
Thank you very much Frank. Sorry for the typo in the post.
We end up using UpdateRequestPrameter same as you showed in your code. UpdateRequestParameter has MODE property to know programatically what is being added/inserted and what is getting deleted.
ReadOnlyCollection<UpdateRequestParameter> newParams =
FIMCurrentRequestActivity_CurrentRequest.ParseParameters<UpdateRequestParameter>();foreach (UpdateRequestParameter updrequestParameter in newParams) WriteToLogFile(string.Format("Update RequestParameter (PropertyName: '{0}', Value: '{1}', Operation: '{2}',
Mode: '{3}'", updrequestParameter.PropertyName ,
updrequestParameter.Value.ToString(), updrequestParameter.Operation, updrequestParameter.Mode));Bhavesh
- แก้ไขโดย bhavesh001 17 พฤษภาคม 2555 13:43 typo