/// <summary>
        /// Executes the sub request.
        /// </summary>
        /// <param name="dataObject">The data object.</param>
        /// <param name="workspaceId">The workspace unique identifier.</param>
        /// <param name="inputDefs">The input defs.</param>
        /// <param name="outputDefs">The output defs.</param>
        /// <param name="errors">The errors.</param>
        /// <returns></returns>
        public IExecutionEnvironment ExecuteSubRequest(IDSFDataObject dataObject, Guid workspaceId, string inputDefs, string outputDefs, out ErrorResultTO errors)
        {
            var           theWorkspace = WorkspaceRepository.Instance.Get(workspaceId);
            var           invoker      = CreateEsbServicesInvoker(theWorkspace);
            ErrorResultTO invokeErrors;
            var           oldID = dataObject.DataListID;

            errors = new ErrorResultTO();

            // local non-scoped execution ;)
            var isLocal = !dataObject.IsRemoteWorkflow();

            var principle = Thread.CurrentPrincipal;

            Dev2Logger.Log.Info("SUB-EXECUTION USER CONTEXT IS [ " + principle.Identity.Name + " ] FOR SERVICE  [ " + dataObject.ServiceName + " ]");

            _doNotWipeDataList = false;
            if (dataObject.RunWorkflowAsync)
            {
                _doNotWipeDataList = true;
                ExecuteRequestAsync(dataObject, inputDefs, invoker, isLocal, oldID, out invokeErrors);
                errors.MergeErrors(invokeErrors);
            }
            else
            {
                if (isLocal)
                {
                    if (GetResource(workspaceId, dataObject.ResourceID) == null && GetResource(workspaceId, dataObject.ServiceName) == null)
                    {
                        errors.AddError(string.Format("Resource {0} not found.", dataObject.ServiceName));
                        return(null);
                    }
                }

                var executionContainer = invoker.GenerateInvokeContainer(dataObject, dataObject.ServiceName, isLocal, oldID);
                if (executionContainer != null)
                {
                    CreateNewEnvironmentFromInputMappings(dataObject, inputDefs);
                    if (!isLocal)
                    {
                        _doNotWipeDataList = true;
                        SetRemoteExecutionDataList(dataObject, executionContainer, errors);
                    }
                    if (!errors.HasErrors())
                    {
                        executionContainer.InstanceInputDefinition  = inputDefs;
                        executionContainer.InstanceOutputDefinition = outputDefs;
                        executionContainer.Execute(out invokeErrors);
                        var env = UpdatePreviousEnvironmentWithSubExecutionResultUsingOutputMappings(dataObject, outputDefs);
                        errors.MergeErrors(invokeErrors);
                        string errorString = dataObject.Environment.FetchErrors();
                        invokeErrors = ErrorResultTO.MakeErrorResultFromDataListString(errorString);
                        errors.MergeErrors(invokeErrors);
                        return(env);
                    }
                    errors.AddError(string.Format("Resource {0} not found.", dataObject.ServiceName));
                }
            }
            return(new ExecutionEnvironment());
        }
Ejemplo n.º 2
0
 public AuditLog(IDSFDataObject dsfDataObject, string auditType, string detail, IDev2Activity previousActivity, IDev2Activity nextActivity)
 {
     WorkflowID                 = dsfDataObject.ResourceID.ToString();
     ExecutionID                = dsfDataObject.ExecutionID.ToString();
     ExecutionOrigin            = Convert.ToInt64(dsfDataObject.ExecutionOrigin);
     IsSubExecution             = Convert.ToInt64(dsfDataObject.IsSubExecution);
     IsRemoteWorkflow           = Convert.ToInt64(dsfDataObject.IsRemoteWorkflow());
     WorkflowName               = dsfDataObject.ServiceName;
     ServerID                   = dsfDataObject.ServerID.ToString();
     ParentID                   = dsfDataObject.ParentID.ToString();
     ExecutingUser              = dsfDataObject.ExecutingUser?.ToString();
     ExecutionOriginDescription = dsfDataObject.ExecutionOriginDescription;
     ExecutionToken             = dsfDataObject.ExecutionToken.ToJson();
     Environment                = dsfDataObject.Environment.ToJson();
     AuditDate                  = DateTime.Now.ToString();
     AuditType                  = auditType;
     AdditionalDetail           = detail;
     if (previousActivity != null)
     {
         PreviousActivity     = previousActivity.GetDisplayName();
         PreviousActivityType = previousActivity.GetType().ToString();
         PreviousActivityId   = previousActivity.ActivityId.ToString();
     }
     if (nextActivity != null)
     {
         NextActivity     = nextActivity.GetDisplayName();
         NextActivityType = nextActivity.GetType().ToString();
         NextActivityId   = nextActivity.ActivityId.ToString();
     }
 }
Ejemplo n.º 3
0
            protected SubExecutionHelperBase(IEnvironmentOutputMappingManager environmentOutputMappingManager, Guid workspaceId, EsbServiceInvoker invoker, IDSFDataObject dataObject, string inputDefs, string outputDefs)
            {
                _environmentOutputMappingManager = environmentOutputMappingManager;
                _workspaceId = workspaceId;
                _invoker     = invoker;
                _dataObject  = dataObject;
                _inputDefs   = inputDefs;
                _outputDefs  = outputDefs;

                _oldId        = _dataObject.DataListID;
                _oldStartTime = _dataObject.StartTime;
                _isLocal      = !_dataObject.IsRemoteWorkflow();
            }
Ejemplo n.º 4
0
        public static void LogState(this IDSFDataObject dsfDataObject, JsonTextWriter jsonTextWriter)
        {
            jsonTextWriter.WriteRaw("{\"DsfDataObject\":");
            jsonTextWriter.WriteStartObject();

            jsonTextWriter.WritePropertyName("ServerID");
            jsonTextWriter.WriteValue(dsfDataObject.ServerID);

            jsonTextWriter.WritePropertyName("ParentID");
            jsonTextWriter.WriteValue(dsfDataObject.ParentID);

            jsonTextWriter.WritePropertyName("ClientID");
            jsonTextWriter.WriteValue(dsfDataObject.ClientID);

            jsonTextWriter.WritePropertyName("ExecutingUser");
            jsonTextWriter.WriteValue(dsfDataObject?.ExecutingUser?.Identity?.ToJson());

            jsonTextWriter.WritePropertyName("ExecutionID");
            jsonTextWriter.WriteValue(dsfDataObject.ExecutionID);

            jsonTextWriter.WritePropertyName("ExecutionOrigin");
            jsonTextWriter.WriteValue(dsfDataObject.ExecutionOrigin);

            jsonTextWriter.WritePropertyName("ExecutionOriginDescription");
            jsonTextWriter.WriteValue(dsfDataObject.ExecutionOriginDescription);

            jsonTextWriter.WritePropertyName("ExecutionToken");
            jsonTextWriter.WriteValue(dsfDataObject.ExecutionToken.ToJson());

            jsonTextWriter.WritePropertyName("IsSubExecution");
            jsonTextWriter.WriteValue(dsfDataObject.IsSubExecution);

            jsonTextWriter.WritePropertyName("IsRemoteWorkflow");
            jsonTextWriter.WriteValue(dsfDataObject.IsRemoteWorkflow());

            jsonTextWriter.WritePropertyName("Environment");
            jsonTextWriter.WriteRawValue(dsfDataObject.Environment.ToJson());

            jsonTextWriter.WriteEndObject();
            jsonTextWriter.WriteRaw("}");
        }
Ejemplo n.º 5
0
        public Audit(IDSFDataObject dsfDataObject, string auditType, string detail, IDev2Activity previousActivity, IDev2Activity nextActivity, Exception exception)
        {
            var dev2Serializer = new Dev2JsonSerializer();

            WorkflowID                 = dsfDataObject.ResourceID.ToString();
            ExecutionID                = dsfDataObject.ExecutionID.ToString();
            ExecutionOrigin            = Convert.ToInt64(dsfDataObject.ExecutionOrigin);
            IsSubExecution             = Convert.ToBoolean(dsfDataObject.IsSubExecution);
            IsRemoteWorkflow           = Convert.ToBoolean(dsfDataObject.IsRemoteWorkflow());
            WorkflowName               = dsfDataObject.ServiceName;
            ServerID                   = dsfDataObject.ServerID.ToString();
            ParentID                   = dsfDataObject.ParentID.ToString();
            ExecutingUser              = dsfDataObject.ExecutingUser?.ToString();
            User                       = dsfDataObject.ExecutingUser?.ToString();
            ExecutionOriginDescription = dsfDataObject.ExecutionOriginDescription;
            ExecutionToken             = dev2Serializer.Serialize(ExecutionToken);
            Environment                = dsfDataObject.Environment.ToJson();
            VersionNumber              = dsfDataObject.VersionNumber.ToString();
            AuditDate                  = DateTime.Now;
            StartDateTime              = DateTime.Now;
            CompletedDateTime          = DateTime.Now;
            Url              = dsfDataObject.WebUrl;
            AuditType        = auditType;
            AdditionalDetail = detail;
            Exception        = exception;

            if (previousActivity != null)
            {
                PreviousActivity     = previousActivity.GetDisplayName();
                PreviousActivityType = previousActivity.GetType().ToString();
                PreviousActivityId   = previousActivity.UniqueID;
            }
            if (nextActivity != null)
            {
                NextActivity     = nextActivity.GetDisplayName();
                NextActivityType = nextActivity.GetType().ToString();
                NextActivityId   = nextActivity.UniqueID;
            }
        }
Ejemplo n.º 6
0
#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);
            }
        }
Ejemplo n.º 7
0
        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;
            }
        }
Ejemplo n.º 8
0
        public IExecutionEnvironment ExecuteSubRequest(IDSFDataObject dataObject, Guid workspaceId, string inputDefs, string outputDefs, out ErrorResultTO errors, int update, bool handleErrors)
        {
            var wasTestExecution = dataObject.IsServiceTestExecution;

            dataObject.IsSubExecution = true;
            try
            {
                dataObject.IsServiceTestExecution = false;
                var           theWorkspace = wRepository.Get(workspaceId);
                var           invoker      = CreateEsbServicesInvoker(theWorkspace);
                ErrorResultTO invokeErrors;
                var           oldID = dataObject.DataListID;
                errors = new ErrorResultTO();

                // local non-scoped execution ;)
                var isLocal = !dataObject.IsRemoteWorkflow();

                var principle = Thread.CurrentPrincipal;
                Dev2Logger.Info("SUB-EXECUTION USER CONTEXT IS [ " + principle.Identity.Name + " ] FOR SERVICE  [ " + dataObject.ServiceName + " ]", dataObject.ExecutionID.ToString());
                var oldStartTime = dataObject.StartTime;
                dataObject.StartTime = DateTime.Now;
                if (dataObject.RunWorkflowAsync)
                {
                    ExecuteRequestAsync(dataObject, inputDefs, invoker, isLocal, oldID, out invokeErrors, update);
                    dataObject.StartTime = oldStartTime;
                    errors.MergeErrors(invokeErrors);
                }
                else
                {
                    if (isLocal && GetResource(workspaceId, dataObject.ResourceID) == null && GetResource(workspaceId, dataObject.ServiceName) == null)
                    {
                        errors.AddError(string.Format(ErrorResource.ResourceNotFound, dataObject.ServiceName));
                        dataObject.StartTime = oldStartTime;
                        return(null);
                    }


                    var executionContainer = invoker.GenerateInvokeContainer(dataObject, dataObject.ServiceName, isLocal, oldID);
                    dataObject.IsServiceTestExecution = wasTestExecution;
                    if (executionContainer != null)
                    {
                        CreateNewEnvironmentFromInputMappings(dataObject, inputDefs, update);
                    }
                    if (executionContainer != null && !isLocal)
                    {
                        SetRemoteExecutionDataList(dataObject, executionContainer, errors);
                    }
                    if (executionContainer != null && !errors.HasErrors())
                    {
                        executionContainer.InstanceInputDefinition  = inputDefs;
                        executionContainer.InstanceOutputDefinition = outputDefs;
                        executionContainer.Execute(out invokeErrors, update);
                        var env = UpdatePreviousEnvironmentWithSubExecutionResultUsingOutputMappings(dataObject, outputDefs, update, handleErrors, errors);

                        errors.MergeErrors(invokeErrors);
                        var errorString = dataObject.Environment.FetchErrors();
                        invokeErrors = ErrorResultTO.MakeErrorResultFromDataListString(errorString);
                        errors.MergeErrors(invokeErrors);
                        dataObject.StartTime = oldStartTime;
                        return(env);
                    }
                    if (executionContainer != null)
                    {
                        errors.AddError(string.Format(ErrorResource.ResourceNotFound, dataObject.ServiceName));
                    }
                }
                dataObject.StartTime = oldStartTime;
                return(new ExecutionEnvironment());
            }
            finally
            {
                dataObject.IsServiceTestExecution = wasTestExecution;
                dataObject.IsSubExecution         = false;
            }
        }
Ejemplo n.º 9
0
        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;
            }
        }
Ejemplo n.º 10
0
        [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;
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Executes the sub request.
        /// </summary>
        /// <param name="dataObject">The data object.</param>
        /// <param name="workspaceId">The workspace unique identifier.</param>
        /// <param name="inputDefs">The input defs.</param>
        /// <param name="outputDefs">The output defs.</param>
        /// <param name="errors">The errors.</param>
        /// <returns></returns>
        public Guid ExecuteSubRequest(IDSFDataObject dataObject, Guid workspaceId, string inputDefs, string outputDefs, out ErrorResultTO errors)
        {
            var           theWorkspace = WorkspaceRepository.Instance.Get(workspaceId);
            var           invoker      = CreateEsbServicesInvoker(theWorkspace);
            ErrorResultTO invokeErrors;
            var           oldID    = dataObject.DataListID;
            var           compiler = DataListFactory.CreateDataListCompiler();

            var remainingMappings = ShapeForSubRequest(dataObject, inputDefs, outputDefs, out errors);

            // local non-scoped execution ;)
            var isLocal = !dataObject.IsRemoteWorkflow();

            var principle = Thread.CurrentPrincipal;

            Dev2Logger.Log.Info("SUB-EXECUTION USER CONTEXT IS [ " + principle.Identity.Name + " ] FOR SERVICE  [ " + dataObject.ServiceName + " ]");

            var result = dataObject.DataListID;

            _doNotWipeDataList = false;
            if (dataObject.RunWorkflowAsync)
            {
                _doNotWipeDataList = true;
                ExecuteRequestAsync(dataObject, compiler, invoker, isLocal, oldID, out invokeErrors);
                errors.MergeErrors(invokeErrors);
            }
            else
            {
                var executionContainer = invoker.GenerateInvokeContainer(dataObject, dataObject.ServiceName, isLocal, oldID);
                if (executionContainer != null)
                {
                    if (!isLocal)
                    {
                        _doNotWipeDataList = true;
                        SetRemoteExecutionDataList(dataObject, executionContainer);
                    }

                    executionContainer.InstanceOutputDefinition = outputDefs;
                    result = executionContainer.Execute(out invokeErrors);
                    errors.MergeErrors(invokeErrors);
                    string errorString = compiler.FetchErrors(dataObject.DataListID, true);
                    invokeErrors = ErrorResultTO.MakeErrorResultFromDataListString(errorString);
                    errors.MergeErrors(invokeErrors);
                    // If Web-service or Plugin, skip the final shaping junk ;)
                    if (SubExecutionRequiresShape(workspaceId, dataObject.ServiceName))
                    {
                        if (!dataObject.IsDataListScoped && remainingMappings != null)
                        {
                            // Adjust the remaining output mappings ;)
                            compiler.SetParentID(dataObject.DataListID, oldID);
                            var outputMappings = remainingMappings.FirstOrDefault(c => c.Key == enDev2ArgumentType.Output);
                            compiler.Shape(dataObject.DataListID, enDev2ArgumentType.Output, outputMappings.Value,
                                           out invokeErrors);
                            errors.MergeErrors(invokeErrors);
                        }
                        else
                        {
                            compiler.Shape(dataObject.DataListID, enDev2ArgumentType.Output, outputDefs, out invokeErrors);
                            errors.MergeErrors(invokeErrors);
                        }
                    }

                    // The act of doing this moves the index data correctly ;)
                    // We need to remove this in the future.
#pragma warning disable 168
                    // ReSharper disable UnusedVariable
                    var dl1 = compiler.ConvertFrom(dataObject.DataListID, DataListFormat.CreateFormat(GlobalConstants._XML_Without_SystemTags), enTranslationDepth.Data, out invokeErrors);
                    var dl2 = compiler.ConvertFrom(oldID, DataListFormat.CreateFormat(GlobalConstants._XML_Without_SystemTags), enTranslationDepth.Data, out invokeErrors);
                    // ReSharper restore UnusedVariable
#pragma warning restore 168

                    return(result);
                }
                errors.AddError("Null container returned");
            }
            return(result);
        }
Ejemplo n.º 12
0
        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;
            }
        }