//public dynamic WorkflowApplication(ServiceAction action, dynamic xmlRequest, string dataList) public dynamic WorkflowApplication(ServiceAction action, IDSFDataObject dataObj, string dataList) { //var dataObject = new DsfDataObject(xmlRequest.XmlString); ErrorResultTO errors; Guid instanceId = Guid.Empty; Guid parentWorkflowInstanceId; Guid parentInstanceId = Guid.Empty; string bookmark = string.Empty; // PBI : 5376 Refactored IBinaryDataListEntry tmp = SvrCompiler.Evaluate(null, dataObj.DataListID, DataList.Contract.enActionType.System, enSystemTag.Bookmark.ToString(), out errors); if(tmp != null) { bookmark = tmp.FetchScalar().TheValue; } tmp = SvrCompiler.Evaluate(null, dataObj.DataListID, DataList.Contract.enActionType.System, enSystemTag.InstanceId.ToString(), out errors); if(tmp != null) { Guid.TryParse(tmp.FetchScalar().TheValue, out instanceId); } tmp = SvrCompiler.Evaluate(null, dataObj.DataListID, DataList.Contract.enActionType.System, enSystemTag.ParentWorkflowInstanceId.ToString(), out errors); if(tmp != null) { Guid.TryParse(tmp.FetchScalar().TheValue, out parentWorkflowInstanceId); } //tmp = SvrCompiler.Evaluate(null, dataObj.DataListID, DataList.Contract.enActionType.System, // enSystemTag.ParentInstanceID.ToString(), out errors); //if (tmp != null) //{ // Guid.TryParse(tmp.FetchScalar().TheValue, out parentInstanceId); //} //bool isDebug = false; //if (xmlRequest.BDSDebugMode is string) //{ // bool.TryParse(xmlRequest.BDSDebugMode, out isDebug); //} // End PBI Mods dataObj.ServiceName = action.ServiceName; // Travis : Now set Data List dataObj.DataList = dataList; Exception wfException = null; IDSFDataObject data = null; PooledServiceActivity activity = action.PopActivity(); try { data = _wf.InvokeWorkflow(activity.Value, dataObj, new List<object> { _dsfChannel }, instanceId, _workspace, bookmark, dataObj.IsDebug); } catch(Exception ex) { wfException = ex; } finally { action.PushActivity(activity); } if(data != null) { return data.DataListID; //return UnlimitedObject.GetStringXmlDataAsUnlimitedObject(data.XmlData); } // ReSharper disable RedundantIfElseBlock else // ReSharper restore RedundantIfElseBlock { dynamic returnError = new UnlimitedObject("Error"); if(wfException != null) { returnError.ErrorDetail = new UnlimitedObject(wfException); } return GlobalConstants.NullDataListID; } }
/// <summary> /// Executes the specified errors. /// </summary> /// <param name="errors">The errors.</param> /// <returns></returns> public override Guid Execute(out ErrorResultTO errors) { errors = new ErrorResultTO(); WorkflowApplicationFactory wfFactor = new WorkflowApplicationFactory(); Guid result = GlobalConstants.NullDataListID; // set current bookmark as per DataObject ;) string bookmark = DataObject.CurrentBookmarkName; Guid instanceId = DataObject.WorkflowInstanceId; // Set Service Name DataObject.ServiceName = ServiceAction.ServiceName; // Set server ID, only if not set yet - original server; if (DataObject.ServerID == Guid.Empty) { DataObject.ServerID = HostSecurityProvider.Instance.ServerID; } // Set resource ID, only if not set yet - original resource; if (DataObject.ResourceID == Guid.Empty && ServiceAction != null && ServiceAction.Service != null) { DataObject.ResourceID = ServiceAction.Service.ID; } // Travis : Now set Data List DataObject.DataList = ServiceAction.DataListSpecification; // Set original instance ID, only if not set yet - original resource; if (DataObject.OriginalInstanceID == Guid.Empty) { DataObject.OriginalInstanceID = DataObject.DataListID; } Dev2Logger.Log.Info(String.Format("Started Execution for Service Name:{0} Resource Id:{1} Mode:{2}", DataObject.ServiceName, DataObject.ResourceID, DataObject.IsDebug?"Debug":"Execute")); //Set execution origin if (!string.IsNullOrWhiteSpace(DataObject.ParentServiceName)) { DataObject.ExecutionOrigin = ExecutionOrigin.Workflow; DataObject.ExecutionOriginDescription = DataObject.ParentServiceName; } else if (DataObject.IsDebug) { DataObject.ExecutionOrigin = ExecutionOrigin.Debug; } else { DataObject.ExecutionOrigin = ExecutionOrigin.External; } PooledServiceActivity activity = ServiceAction.PopActivity(); try { var theActivity = activity.Value as DynamicActivity; // BUG 9304 - 2013.05.08 - TWR - Added CompileExpressions _workflowHelper.CompileExpressions(theActivity); IDSFDataObject exeResult = wfFactor.InvokeWorkflow(activity.Value, DataObject, new List <object> { EsbChannel, }, instanceId, TheWorkspace, bookmark, out errors); result = exeResult.DataListID; } catch (InvalidWorkflowException iwe) { Dev2Logger.Log.Error(iwe); var msg = iwe.Message; int start = msg.IndexOf("Flowchart ", StringComparison.Ordinal); // trap the no start node error so we can replace it with something nicer ;) errors.AddError(start > 0 ? GlobalConstants.NoStartNodeError : iwe.Message); } catch (Exception ex) { Dev2Logger.Log.Error(ex); errors.AddError(ex.Message); } finally { ServiceAction.PushActivity(activity); } Dev2Logger.Log.Info(String.Format("Completed Execution for Service Name:{0} Resource Id: {1} Mode:{2}", DataObject.ServiceName, DataObject.ResourceID, DataObject.IsDebug?"Debug":"Execute")); return(result); }