#pragma warning disable S1541 // Methods and properties should not be too complex protected override void ExecuteTool(IDSFDataObject dataObject, int update) #pragma warning restore S1541 // Methods and properties should not be too complex { var allErrors = new ErrorResultTO(); dataObject.EnvironmentID = EnvironmentID?.Expression == null ? Guid.Empty : Guid.Parse(EnvironmentID.Expression.ToString()); dataObject.RemoteServiceType = Type?.Expression?.ToString() ?? ""; ParentServiceName = dataObject.ServiceName; var parentServiceName = string.Empty; var serviceName = string.Empty; var isRemote = dataObject.IsRemoteWorkflow(); if ((isRemote || dataObject.IsRemoteInvokeOverridden) && dataObject.EnvironmentID == Guid.Empty) { dataObject.IsRemoteInvokeOverridden = true; } var oldResourceId = dataObject.ResourceID; InitializeDebug(dataObject); try { if (ServiceServer != Guid.Empty) { dataObject.RemoteInvokerID = ServiceServer.ToString(); } dataObject.RunWorkflowAsync = RunWorkflowAsync; parentServiceName = dataObject.ParentServiceName; serviceName = dataObject.ServiceName; dataObject.ParentServiceName = serviceName; _previousInstanceId = dataObject.ParentInstanceID; dataObject.ParentID = oldResourceId; dataObject.ParentInstanceID = UniqueID; dataObject.ParentWorkflowInstanceId = ParentWorkflowInstanceId; if (!DeferExecution) { var tmpErrors = new ErrorResultTO(); var esbChannel = dataObject.EsbChannel; if (esbChannel == null) { throw new Exception(ErrorResource.NullESBChannel); } dataObject.ServiceName = ServiceName; // set up for sub-exection ;) dataObject.ResourceID = ResourceID.Expression == null ? Guid.Empty : Guid.Parse(ResourceID.Expression.ToString()); BeforeExecutionStart(dataObject, allErrors); if (dataObject.IsDebugMode() || dataObject.RunWorkflowAsync && !dataObject.IsFromWebServer) { DispatchDebugStateAndUpdateRemoteServer(dataObject, StateType.Before, update); } allErrors.MergeErrors(tmpErrors); ExecutionImpl(esbChannel, dataObject, InputMapping, OutputMapping, out tmpErrors, update); allErrors.MergeErrors(tmpErrors); AfterExecutionCompleted(tmpErrors); allErrors.MergeErrors(tmpErrors); dataObject.ServiceName = ServiceName; } } catch (Exception err) { dataObject.Environment.AddError(err.Message); } finally { DebugOutput(dataObject, update, allErrors, parentServiceName, serviceName, oldResourceId); } }
protected override void ExecuteTool(IDSFDataObject dataObject) { ErrorResultTO allErrors = new ErrorResultTO(); dataObject.EnvironmentID = (EnvironmentID == null || EnvironmentID.Expression == null) ? Guid.Empty : Guid.Parse(EnvironmentID.Expression.ToString()); dataObject.RemoteServiceType = Type.Expression == null ? "" : Type.Expression.ToString(); ParentServiceName = dataObject.ServiceName; string parentServiceName = string.Empty; string serviceName = string.Empty; // BUG 9634 - 2013.07.17 - TWR - changed isRemoteExecution to check EnvironmentID instead // This is now the wrong behavior - We need to keep the original EnvironmentID when not a remote workflow // This is because we put and empty GUID in when designing against a remote server that uses it's resources // The first time through this value is set correctly when executing those designed resource from our localhost // If we change it as per what was here, we always get a localhost tag instead of the remote host we are design against var isRemote = dataObject.IsRemoteWorkflow(); if ((isRemote || dataObject.IsRemoteInvokeOverridden) && dataObject.EnvironmentID == Guid.Empty) { dataObject.IsRemoteInvokeOverridden = true; } var oldResourceId = dataObject.ResourceID; InitializeDebug(dataObject); try { //compiler.ClearErrors(dataObject.DataListID); if (ServiceServer != Guid.Empty) { // we need to adjust the originating server id so debug reflect remote server instead of localhost ;) dataObject.RemoteInvokerID = ServiceServer.ToString(); } dataObject.RunWorkflowAsync = RunWorkflowAsync; if (dataObject.IsDebugMode() || (dataObject.RunWorkflowAsync && !dataObject.IsFromWebServer)) { DispatchDebugState(dataObject, StateType.Before); } Guid resourceId = dataObject.ResourceID; if (resourceId != Guid.Empty) { dataObject.ResourceID = resourceId; } // scrub it clean ;) // set the parent service parentServiceName = dataObject.ParentServiceName; serviceName = dataObject.ServiceName; dataObject.ParentServiceName = serviceName; _previousInstanceId = dataObject.ParentInstanceID; dataObject.ParentID = oldResourceId; dataObject.ParentInstanceID = UniqueID; dataObject.ParentWorkflowInstanceId = ParentWorkflowInstanceId; if (!DeferExecution) { // In all cases the ShapeOutput will have merged the execution data up into the current ErrorResultTO tmpErrors = new ErrorResultTO(); IEsbChannel esbChannel = dataObject.EsbChannel; if (esbChannel == null) { throw new Exception("FATAL ERROR : Null ESB channel!!"); } else { // NEW EXECUTION MODEL ;) // PBI 7913 dataObject.ServiceName = ServiceName; // set up for sub-exection ;) dataObject.ResourceID = ResourceID.Expression == null ? Guid.Empty : Guid.Parse(ResourceID.Expression.ToString()); BeforeExecutionStart(dataObject, allErrors); allErrors.MergeErrors(tmpErrors); // Execute Request ExecutionImpl(esbChannel, dataObject, InputMapping, OutputMapping, out tmpErrors); allErrors.MergeErrors(tmpErrors); AfterExecutionCompleted(tmpErrors); allErrors.MergeErrors(tmpErrors); dataObject.ServiceName = ServiceName; } } } catch (Exception err) { dataObject.Environment.Errors.Add(err.Message); } finally { if (!dataObject.WorkflowResumeable || !dataObject.IsDataListScoped) { // Handle Errors if (allErrors.HasErrors()) { DisplayAndWriteError("DsfActivity", allErrors); dataObject.Environment.AddError(allErrors.MakeDataListReady()); // add to datalist in variable specified if (!String.IsNullOrEmpty(OnErrorVariable)) { var upsertVariable = DataListUtil.AddBracketsToValueIfNotExist(OnErrorVariable); dataObject.Environment.Assign(upsertVariable, allErrors.MakeDataListReady()); } } } if (dataObject.IsDebugMode() || (dataObject.RunWorkflowAsync && !dataObject.IsFromWebServer)) { DispatchDebugState(dataObject, StateType.After); } dataObject.ParentInstanceID = _previousInstanceId; dataObject.ParentServiceName = parentServiceName; dataObject.ServiceName = serviceName; dataObject.RemoteInvokeResultShape = new StringBuilder(); // reset targnet shape ;) dataObject.RunWorkflowAsync = false; dataObject.RemoteInvokerID = Guid.Empty.ToString(); dataObject.EnvironmentID = Guid.Empty; dataObject.ResourceID = oldResourceId; } }
public override IEnumerable <StateVariable> GetState() { var serializer = new Dev2JsonSerializer(); var inputs = serializer.Serialize(Inputs); var outputs = serializer.Serialize(Outputs); return(new[] { new StateVariable { Name = "Inputs", Type = StateVariable.StateType.Input, Value = inputs }, new StateVariable { Name = "Outputs", Type = StateVariable.StateType.Output, Value = outputs }, new StateVariable { Name = "ServiceServer", Type = StateVariable.StateType.Input, Value = ServiceServer.ToString() }, new StateVariable { Name = "EnvironmentID", Type = StateVariable.StateType.Input, Value = EnvironmentID.Expression.ToString() }, new StateVariable { Name = "IsWorkflow", Type = StateVariable.StateType.Input, Value = IsWorkflow.ToString() }, new StateVariable { Name = "ServiceUri", Type = StateVariable.StateType.Input, Value = ServiceUri }, new StateVariable { Name = "ResourceID", Type = StateVariable.StateType.Input, Value = ResourceID.Expression.ToString() }, new StateVariable { Name = "ServiceName", Type = StateVariable.StateType.Input, Value = ServiceName }, new StateVariable { Name = "ParentServiceName", Type = StateVariable.StateType.Input, Value = ParentServiceName } }); }
protected override void ExecuteTool(IDSFDataObject dataObject, int update) { ErrorResultTO allErrors = new ErrorResultTO(); dataObject.EnvironmentID = EnvironmentID?.Expression == null ? Guid.Empty : Guid.Parse(EnvironmentID.Expression.ToString()); dataObject.RemoteServiceType = Type?.Expression?.ToString() ?? ""; ParentServiceName = dataObject.ServiceName; string parentServiceName = string.Empty; string serviceName = string.Empty; var isRemote = dataObject.IsRemoteWorkflow(); if ((isRemote || dataObject.IsRemoteInvokeOverridden) && dataObject.EnvironmentID == Guid.Empty) { dataObject.IsRemoteInvokeOverridden = true; } var oldResourceId = dataObject.ResourceID; var wasTestExecution = dataObject.IsServiceTestExecution; InitializeDebug(dataObject); try { if (ServiceServer != Guid.Empty) { dataObject.RemoteInvokerID = ServiceServer.ToString(); } dataObject.RunWorkflowAsync = RunWorkflowAsync; Guid resourceId = dataObject.ResourceID; if (resourceId != Guid.Empty) { dataObject.ResourceID = resourceId; } parentServiceName = dataObject.ParentServiceName; serviceName = dataObject.ServiceName; dataObject.ParentServiceName = serviceName; _previousInstanceId = dataObject.ParentInstanceID; dataObject.ParentID = oldResourceId; dataObject.ParentInstanceID = UniqueID; dataObject.ParentWorkflowInstanceId = ParentWorkflowInstanceId; if (!DeferExecution) { ErrorResultTO tmpErrors = new ErrorResultTO(); IEsbChannel esbChannel = dataObject.EsbChannel; if (esbChannel == null) { throw new Exception(ErrorResource.NullESBChannel); } dataObject.ServiceName = ServiceName; // set up for sub-exection ;) dataObject.ResourceID = ResourceID.Expression == null ? Guid.Empty : Guid.Parse(ResourceID.Expression.ToString()); BeforeExecutionStart(dataObject, allErrors); if (dataObject.IsDebugMode() || dataObject.RunWorkflowAsync && !dataObject.IsFromWebServer) { DispatchDebugStateAndUpdateRemoteServer(dataObject, StateType.Before, update); } allErrors.MergeErrors(tmpErrors); ExecutionImpl(esbChannel, dataObject, InputMapping, OutputMapping, out tmpErrors, update); allErrors.MergeErrors(tmpErrors); AfterExecutionCompleted(tmpErrors); allErrors.MergeErrors(tmpErrors); dataObject.ServiceName = ServiceName; } } catch (Exception err) { dataObject.Environment.Errors.Add(err.Message); } finally { if (!dataObject.WorkflowResumeable || !dataObject.IsDataListScoped) { // Handle Errors if (allErrors.HasErrors()) { DisplayAndWriteError("DsfActivity", allErrors); foreach (var allError in allErrors.FetchErrors()) { dataObject.Environment.Errors.Add(allError); } // add to datalist in variable specified if (!String.IsNullOrEmpty(OnErrorVariable)) { var upsertVariable = DataListUtil.AddBracketsToValueIfNotExist(OnErrorVariable); dataObject.Environment.Assign(upsertVariable, allErrors.MakeDataListReady(), update); } } } if (dataObject.IsDebugMode() || dataObject.RunWorkflowAsync && !dataObject.IsFromWebServer) { var dt = DateTime.Now; DispatchDebugState(dataObject, StateType.After, update, dt); ChildDebugStateDispatch(dataObject); _debugOutputs = new List <DebugItem>(); DispatchDebugState(dataObject, StateType.Duration, update, dt); } dataObject.ParentInstanceID = _previousInstanceId; dataObject.ParentServiceName = parentServiceName; dataObject.ServiceName = serviceName; dataObject.RemoteInvokeResultShape = new StringBuilder(); // reset targnet shape ;) dataObject.RunWorkflowAsync = false; dataObject.RemoteInvokerID = Guid.Empty.ToString(); dataObject.EnvironmentID = Guid.Empty; dataObject.ResourceID = oldResourceId; } }
[ExcludeFromCodeCoverage] //This execution is no longer used protected override void OnExecute(NativeActivityContext context) { // ???? Why is this here.... context.Properties.ToObservableCollection(); IEsbChannel esbChannel = DataObject.EsbChannel; IDSFDataObject dataObject = context.GetExtension <IDSFDataObject>(); dataObject.EnvironmentID = context.GetValue(EnvironmentID); Guid datalistId = DataListExecutionID.Get(context); ParentWorkflowInstanceId = context.WorkflowInstanceId.ToString(); dataObject.RemoteServiceType = context.GetValue(Type); var resourceId = context.GetValue(ResourceID); ErrorResultTO allErrors = new ErrorResultTO(); ParentServiceName = dataObject.ServiceName; string parentServiceName = string.Empty; string serviceName = string.Empty; var isRemote = dataObject.IsRemoteWorkflow(); if ((isRemote || dataObject.IsRemoteInvokeOverridden) && dataObject.EnvironmentID == Guid.Empty) { dataObject.IsRemoteInvokeOverridden = true; } var oldResourceId = dataObject.ResourceID; InitializeDebug(dataObject); try { if (ServiceServer != Guid.Empty) { dataObject.RemoteInvokerID = ServiceServer.ToString(); } dataObject.RunWorkflowAsync = RunWorkflowAsync; if (resourceId != Guid.Empty) { dataObject.ResourceID = resourceId; } if (dataObject.IsDebugMode() || dataObject.RunWorkflowAsync && !dataObject.IsFromWebServer) { DispatchDebugState(dataObject, StateType.Before, 0); } // scrub it clean ;) // set the parent service parentServiceName = dataObject.ParentServiceName; serviceName = dataObject.ServiceName; dataObject.ParentServiceName = serviceName; _previousInstanceId = dataObject.ParentInstanceID; dataObject.ParentID = oldResourceId; dataObject.ParentInstanceID = UniqueID; dataObject.ParentWorkflowInstanceId = ParentWorkflowInstanceId; if (!DeferExecution) { // In all cases the ShapeOutput will have merged the execution data up into the current ErrorResultTO tmpErrors = new ErrorResultTO(); if (esbChannel == null) { throw new Exception(ErrorResource.NullESBChannel); } else { // NEW EXECUTION MODEL ;) // PBI 7913 if (datalistId != GlobalConstants.NullDataListID) { BeforeExecutionStart(dataObject, allErrors); allErrors.MergeErrors(tmpErrors); dataObject.ServiceName = ServiceName; // set up for sub-exection ;) dataObject.ResourceID = ResourceID.Expression == null ? Guid.Empty : Guid.Parse(ResourceID.Expression.ToString()); // Execute Request ExecutionImpl(esbChannel, dataObject, InputMapping, OutputMapping, out tmpErrors, 0); // careful of zero if wf comes back allErrors.MergeErrors(tmpErrors); AfterExecutionCompleted(tmpErrors); allErrors.MergeErrors(tmpErrors); dataObject.DataListID = datalistId; // re-set DL ID dataObject.ServiceName = ServiceName; } } } } finally { // Handle Errors if (allErrors.HasErrors()) { DisplayAndWriteError("DsfActivity", allErrors); dataObject.Environment.AddError(allErrors.MakeDataListReady()); // add to datalist in variable specified if (!String.IsNullOrEmpty(OnErrorVariable)) { var upsertVariable = DataListUtil.AddBracketsToValueIfNotExist(OnErrorVariable); dataObject.Environment.Assign(upsertVariable, allErrors.MakeDataListReady(), 0); } } if (dataObject.IsDebugMode() || dataObject.RunWorkflowAsync && !dataObject.IsFromWebServer) { DispatchDebugState(dataObject, StateType.After, 0); } dataObject.ParentInstanceID = _previousInstanceId; dataObject.ParentServiceName = parentServiceName; dataObject.ServiceName = serviceName; dataObject.RemoteInvokeResultShape = new StringBuilder(); // reset targnet shape ;) dataObject.RunWorkflowAsync = false; dataObject.RemoteInvokerID = Guid.Empty.ToString(); dataObject.EnvironmentID = Guid.Empty; dataObject.ResourceID = oldResourceId; } }
protected override void OnExecute(NativeActivityContext context) { // ???? Why is this here.... context.Properties.ToObservableCollection(); IEsbChannel esbChannel = context.GetExtension <IEsbChannel>(); IDSFDataObject dataObject = context.GetExtension <IDSFDataObject>(); IDataListCompiler compiler = DataListFactory.CreateDataListCompiler(); ErrorResultTO errors; ErrorResultTO allErrors = new ErrorResultTO(); Guid datalistId = DataListExecutionID.Get(context); ParentServiceName = dataObject.ServiceName; ParentWorkflowInstanceId = context.WorkflowInstanceId.ToString(); string parentServiceName = string.Empty; string serviceName = string.Empty; // BUG 9634 - 2013.07.17 - TWR - changed isRemoteExecution to check EnvironmentID instead // This is now the wrong behavior - We need to keep the original EnvironmentID when not a remote workflow // This is because we put and empty GUID in when designing against a remote server that uses it's resources // The first time through this value is set correctly when executing those designed resource from our localhost // If we change it as per what was here, we always get a localhost tag instead of the remote host we are design against var isRemote = dataObject.IsRemoteWorkflow(); dataObject.EnvironmentID = context.GetValue(EnvironmentID); if ((isRemote || dataObject.IsRemoteInvokeOverridden) && dataObject.EnvironmentID == Guid.Empty) { dataObject.IsRemoteInvokeOverridden = true; } var oldResourceId = dataObject.ResourceID; InitializeDebug(dataObject); try { compiler.ClearErrors(dataObject.DataListID); if (ServiceServer != Guid.Empty) { // we need to adjust the originating server id so debug reflect remote server instead of localhost ;) dataObject.RemoteInvokerID = ServiceServer.ToString(); } dataObject.RemoteServiceType = context.GetValue(Type); dataObject.RunWorkflowAsync = RunWorkflowAsync; if (dataObject.IsDebugMode() || (dataObject.RunWorkflowAsync && !dataObject.IsFromWebServer)) { DispatchDebugState(context, StateType.Before); } var resourceId = context.GetValue(ResourceID); if (resourceId != Guid.Empty) { dataObject.ResourceID = resourceId; } // scrub it clean ;) ScrubDataList(compiler, datalistId, context.WorkflowInstanceId.ToString(), out errors); allErrors.MergeErrors(errors); // set the parent service parentServiceName = dataObject.ParentServiceName; serviceName = dataObject.ServiceName; dataObject.ParentServiceName = serviceName; _previousInstanceId = dataObject.ParentInstanceID; dataObject.ParentID = oldResourceId; dataObject.ParentInstanceID = UniqueID; dataObject.ParentWorkflowInstanceId = ParentWorkflowInstanceId; if (!DeferExecution) { // In all cases the ShapeOutput will have merged the execution data up into the current ErrorResultTO tmpErrors = new ErrorResultTO(); if (esbChannel == null) { throw new Exception("FATAL ERROR : Null ESB channel!!"); } else { // NEW EXECUTION MODEL ;) // PBI 7913 if (datalistId != GlobalConstants.NullDataListID) { BeforeExecutionStart(dataObject, allErrors); allErrors.MergeErrors(tmpErrors); dataObject.ServiceName = ServiceName; // set up for sub-exection ;) dataObject.ResourceID = ResourceID.Expression == null ? Guid.Empty : Guid.Parse(ResourceID.Expression.ToString()); // Execute Request ExecutionImpl(esbChannel, dataObject, InputMapping, OutputMapping, out tmpErrors); allErrors.MergeErrors(tmpErrors); AfterExecutionCompleted(tmpErrors); allErrors.MergeErrors(tmpErrors); dataObject.DataListID = datalistId; // re-set DL ID dataObject.ServiceName = ServiceName; } // ** THIS IS A HACK OF NOTE, WE NEED TO ADDRESS THIS! if (dataObject.IsDebugMode()) { //Dont remove this it is here to fix the data not being returned correctly string testData = compiler.ConvertFrom(dataObject.DataListID, DataListFormat.CreateFormat(GlobalConstants._Studio_Debug_XML), enTranslationDepth.Data, out errors).ToString(); if (string.IsNullOrEmpty(testData)) { } } } bool whereErrors = compiler.HasErrors(datalistId); Result.Set(context, whereErrors); HasError.Set(context, whereErrors); IsValid.Set(context, whereErrors); } } finally { if (!dataObject.WorkflowResumeable || !dataObject.IsDataListScoped) { // Handle Errors if (allErrors.HasErrors()) { DisplayAndWriteError("DsfActivity", allErrors); compiler.UpsertSystemTag(dataObject.DataListID, enSystemTag.Dev2Error, allErrors.MakeDataListReady(), out errors); // add to datalist in variable specified if (!String.IsNullOrEmpty(OnErrorVariable)) { var upsertVariable = DataListUtil.AddBracketsToValueIfNotExist(OnErrorVariable); compiler.Upsert(dataObject.DataListID, upsertVariable, allErrors.MakeDataListReady(), out errors); } } } if (dataObject.IsDebugMode() || (dataObject.RunWorkflowAsync && !dataObject.IsFromWebServer)) { DispatchDebugState(context, StateType.After); } dataObject.ParentInstanceID = _previousInstanceId; dataObject.ParentServiceName = parentServiceName; dataObject.ServiceName = serviceName; dataObject.RemoteInvokeResultShape = new StringBuilder(); // reset targnet shape ;) dataObject.RunWorkflowAsync = false; dataObject.RemoteInvokerID = Guid.Empty.ToString(); dataObject.EnvironmentID = Guid.Empty; dataObject.ResourceID = oldResourceId; } }