コード例 #1
0
        ErrorResultTO TryInvokeService(IDSFDataObject dataObject, ErrorResultTO errors)
        {
            var serviceId = dataObject.ResourceID;

            var serviceName = dataObject.ServiceName;

            if (serviceId == Guid.Empty && string.IsNullOrEmpty(serviceName))
            {
                errors.AddError(Resources.DynamicServiceError_ServiceNotSpecified);
            }
            else
            {
                try
                {
                    errors = InvokeService(dataObject, errors, serviceId, serviceName);
                }
                catch (Exception e)
                {
                    errors.AddError(e.Message, true);
                }
                finally
                {
                    var environment = dataObject.Environment;
                    if (environment.HasErrors())
                    {
                        var errorString     = environment.FetchErrors();
                        var executionErrors = ErrorResultTO.MakeErrorResultFromDataListString(errorString, true);
                        errors.MergeErrors(executionErrors);
                    }

                    if (dataObject.ReturnType == Web.EmitionTypes.XML || dataObject.ReturnType == Web.EmitionTypes.TRX)
                    {
                        environment.AddError(errors.MakeDataListReady(), true);
                    }
                    else
                    {
                        environment.AddError(errors.MakeDataListReady(false), true);
                    }

                    if (errors.HasErrors())
                    {
                        Dev2Logger.Error(errors.MakeDisplayReady(), dataObject.ExecutionID.ToString());
                    }
                }
            }

            return(errors);
        }
コード例 #2
0
        /// <summary>
        /// When overridden runs the activity's simulation logic
        /// </summary>
        /// <param name="context">The context to be used.</param>
        // ReSharper disable VirtualMemberNeverOverriden.Global
        protected virtual void OnExecuteSimulation(NativeActivityContext context)
        // ReSharper restore VirtualMemberNeverOverriden.Global
        {
            var rootInfo = context.GetExtension <WorkflowInstanceInfo>();

            var key = new SimulationKey
            {
                WorkflowID = rootInfo.ProxyName,
                ActivityID = UniqueID,
                ScenarioID = ScenarioID
            };
            var result = SimulationRepository.Instance.Get(key);

            if (result != null && result.Value != null)
            {
                var dataObject = context.GetExtension <IDSFDataObject>();

                if (dataObject != null)
                {
                    var allErrors = new ErrorResultTO();
                    allErrors.MergeErrors(errorsTo);

                    allErrors.MergeErrors(errorsTo);

                    allErrors.MergeErrors(errorsTo);

                    if (allErrors.HasErrors())
                    {
                        DisplayAndWriteError(rootInfo.ProxyName, allErrors);
                        dataObject.Environment.AddError(allErrors.MakeDataListReady());
                    }
                }
            }
        }
コード例 #3
0
        void ProcessErrors(IDSFDataObject dataObject, int update, bool hasErrors, ErrorResultTO allErrors, int actualIndex)
        {
            if (hasErrors)
            {
                var errorString = allErrors.MakeDataListReady();
                dataObject.Environment.AddError(errorString);
                if (actualIndex > -1)
                {
                    dataObject.Environment.Assign(ResultsCollection[actualIndex].OutputVariable, null, update);
                }
                DisplayAndWriteError(dataObject, DisplayName, allErrors);
                if (_isDebugMode)
                {
                    var itemToAdd = new DebugItem();
                    if (actualIndex < 0)
                    {
                        actualIndex = 0;
                    }
                    AddDebugItem(new DebugItemStaticDataParams("", (actualIndex + 1).ToString(CultureInfo.InvariantCulture)), itemToAdd);

                    var outputVariable = "";
                    if (actualIndex >= 0)
                    {
                        outputVariable = ResultsCollection[actualIndex].OutputVariable;
                    }
                    AddDebugItem(new DebugEvalResult(outputVariable, "", dataObject.Environment, update), itemToAdd);
                    _debugOutputs.Add(itemToAdd);
                }
            }
        }
コード例 #4
0
        /// <summary>
        /// Resumed the specified context.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="bookmark">The bookmark.</param>
        /// <param name="value">The value.</param>
        /// <exception cref="System.Exception">
        /// Parent and Child DataList IDs are the same, aborting resumption!
        /// or
        /// Fatal Error : Cannot merge resumed data
        /// or
        /// Fatal Error : Cannot locate Root DataList for resumption!
        /// </exception>
        public virtual void Resumed(NativeActivityContext context, Bookmark bookmark, object value)
        {
            IDSFDataObject    myDO          = context.GetExtension <IDSFDataObject>();
            IDataListCompiler compiler      = DataListFactory.CreateDataListCompiler();
            ErrorResultTO     errorResultTO = new ErrorResultTO();
            Guid executionID = myDO.DataListID;

            if (value != null)
            {
                Guid rootID;
                Guid.TryParse(value.ToString(), out rootID);

                if (executionID == rootID)
                {
                    throw new Exception("Parent and Child DataList IDs are the same, aborting resumption!");
                }

                try
                {
                    /* Now perform the shape.... */

                    // First set the parentID on executionID to rootID.. so the shape happens correctly ;)
                    compiler.SetParentID(rootID, executionID);
                    // Next shape the execution result into the root datalist ;)
                    ErrorResultTO tmpErrors;
                    Guid          shapeID = compiler.Shape(rootID, enDev2ArgumentType.Output, OutputMapping, out tmpErrors);
                    errorResultTO.MergeErrors(tmpErrors);

                    // set parent instanceID
                    myDO.DataListID = executionID; // reset the DataListID accordingly

                    if (shapeID != executionID)
                    {
                        throw new Exception("Fatal Error : Cannot merge resumed data");
                    }


                    compiler.ConditionalMerge(DataListMergeFrequency.Always | DataListMergeFrequency.OnResumption,
                                              myDO.DatalistOutMergeID, myDO.DataListID, myDO.DatalistOutMergeFrequency, myDO.DatalistOutMergeType, myDO.DatalistOutMergeDepth);
                    ExecutionStatusCallbackDispatcher.Instance.Post(myDO.BookmarkExecutionCallbackID, ExecutionStatusCallbackMessageType.ResumedCallback);
                }
                finally
                {
                    // At resumption this is the root dl entry ;)

                    // Handle Errors
                    if (errorResultTO.HasErrors())
                    {
                        DisplayAndWriteError("Resumption", errorResultTO);
                        var errorString = errorResultTO.MakeDataListReady();
                        myDO.Environment.AddError(errorString);
                    }
                }
            }
            else
            {
                throw new Exception("Fatal Error : Cannot locate Root DataList for resumption!");
            }
        }
コード例 #5
0
        protected override void ExecuteTool(IDSFDataObject dataObject, int update)
        {
            ErrorResultTO allErrors     = new ErrorResultTO();
            ErrorResultTO errorResultTo = new ErrorResultTO();

            allErrors.MergeErrors(errorResultTo);

            try
            {
                if (!errorResultTo.HasErrors())
                {
                    if (allErrors.HasErrors())
                    {
                        return;
                    }
                    allErrors.MergeErrors(errorResultTo);
                    if (allErrors.HasErrors())
                    {
                        return;
                    }

                    if (dataObject.IsDebugMode())
                    {
                        AddDebugInputItem(Script, dataObject.Environment, update);
                    }



                    allErrors.MergeErrors(errorResultTo);
                }
            }
            catch (Exception e)
            {
                allErrors.AddError(e.GetType() == typeof(NullReferenceException) ? "There was an error when returning a value from the javascript, remember to use the 'Return' keyword when returning the result" : e.Message);
            }
            finally
            {
                // Handle Errors
                var hasErrors = allErrors.HasErrors();
                if (hasErrors)
                {
                    DisplayAndWriteError("DsfScriptingJavaScriptActivity", allErrors);
                    dataObject.Environment.AddError(allErrors.MakeDataListReady());
                    dataObject.Environment.Assign(Result, null, update);
                }

                if (dataObject.IsDebugMode())
                {
                    if (hasErrors)
                    {
                        AddDebugOutputItem(new DebugItemStaticDataParams("", Result, ""));
                    }

                    DispatchDebugState(dataObject, StateType.Before, update);
                    DispatchDebugState(dataObject, StateType.After, update);
                }
            }
        }
コード例 #6
0
        public void ErrorResultTO_AddError_NullMessage()
        {
            var resultTo = new ErrorResultTO();

            resultTo.AddError(null, true);

            Assert.IsFalse(resultTo.HasErrors());
            // Shouldn't this be passing?
            Assert.AreEqual(0, resultTo.FetchErrors().Count);
            Assert.AreEqual("", resultTo.MakeDataListReady());
        }
コード例 #7
0
ファイル: ExecutionDto.cs プロジェクト: tuga1975/Warewolf
        static string SetupErrors(IDSFDataObject dataObject, ErrorResultTO allErrors)
        {
            string executePayload;

            if (dataObject.ReturnType == EmitionTypes.XML)
            {
                executePayload =
                    "<FatalError> <Message> An internal error occurred while executing the service request </Message>";
                executePayload += allErrors.MakeDataListReady();
                executePayload += "</FatalError>";
            }
            else
            {
                executePayload =
                    "{ \"FatalError\": \"An internal error occurred while executing the service request\",";
                executePayload += allErrors.MakeDataListReady(false);
                executePayload += "}";
            }
            return(executePayload);
        }
コード例 #8
0
        public void ErrorResultTO_AddError_CheckForDuplicates_True_AddSameError_ExpectLstToBeSame()
        {
            var resultTo = new ErrorResultTO();

            resultTo.AddError("some message", true);
            resultTo.AddError("some message", true);

            Assert.IsTrue(resultTo.HasErrors());
            Assert.AreEqual(1, resultTo.FetchErrors().Count);
            Assert.AreEqual("some message", resultTo.FetchErrors()[0]);
            Assert.AreEqual("<InnerError>some message</InnerError>", resultTo.MakeDataListReady());
        }
コード例 #9
0
        public void CanConvertErrorResultTojson()
        {
            ErrorResultTO errors = new ErrorResultTO();

            errors.AddError("Error 1");
            errors.AddError("Error 2");

            var          result   = errors.MakeDataListReady(false);
            const string expected = "\"errors\": [ \"Error 1\",\"Error 2\"]";


            Assert.AreEqual(expected, result, "Expected [ " + expected + " but got [ " + result + " ]");
        }
コード例 #10
0
        public void ErrorResultTO_MakeDatalistReady_CannotSetUnknownMemberError_MessageConvertedToOutdatedServerError()
        {
            var errorResultTO = new ErrorResultTO();

            errorResultTO.AddError("Cannot set unknown member");
            //------------Execute Test---------------------------

            var          result   = errorResultTO.MakeDataListReady(false);
            const string expected = "\"errors\": [ \"Resource has unrecognized formatting, this Warewolf Server may be to outdated to read this resource.\"]";

            // Assert Message Converted To Outdated Server Error
            Assert.AreEqual(expected, result, "Error message not relevent");
        }
コード例 #11
0
ファイル: ErrorResultTOTests.cs プロジェクト: kapiya/Warewolf
        public void ErrorResultTO_MakeDataListReady_ExpectJson_ShouldEscapeQuotesInErrorMessages()
        {
            var errorResultTo = new ErrorResultTO();

            Assert.AreEqual(0, errorResultTo.FetchErrors().Count);
            errorResultTo.AddError("this is some exception's \"message\" string");
            errorResultTo.AddError("Another \"Error\"");
            errorResultTo.AddError("\"Error\" message");

            var makeDisplayReady = errorResultTo.MakeDataListReady(false);
            var result           = "\"errors\": [ \"this is some exception's \\\"message\\\" string\",\"Another \\\"Error\\\"\",\"\\\"Error\\\" message\"]";

            Assert.AreEqual(result, makeDisplayReady);
        }
コード例 #12
0
        public void ErrorResultTO_MakeDataListReady_ExpectJson_ShouldEscapeQuotesInErrorMessages()
        {
            var errorResultTo = new ErrorResultTO();

            Assert.AreEqual(0, errorResultTo.FetchErrors().Count);
            errorResultTo.AddError("this is some exception's \"message\" string");
            errorResultTo.AddError("Another \"Error\"");
            errorResultTo.AddError("\"Error\" message");

            var makeDisplayReady = errorResultTo.MakeDataListReady(false);
            var result           = "[ \"this is some exception's \\\"message\\\" string\",\"Another \\\"Error\\\"\",\"\\\"Error\\\" message\"]";

            Assert.AreEqual(result, makeDisplayReady, "\"errors\": prefix have been removed to keep with the xml add error of this method as it seems to be the most used");
        }
コード例 #13
0
        public void ErrorResultTO_MakeDataListReady_ShouldReturnAllErrorsAsOne()
        {
            var result        = "<InnerError>SomeError</InnerError><InnerError>AnotherError</InnerError>";
            var errorResultTo = new ErrorResultTO();

            Assert.AreEqual(0, errorResultTo.FetchErrors().Count);
            errorResultTo.AddError("SomeError");
            errorResultTo.AddError("AnotherError");

            Assert.AreEqual(2, errorResultTo.FetchErrors().Count);

            var makeDisplayReady = errorResultTo.MakeDataListReady();

            Assert.AreEqual(result, makeDisplayReady);
        }
コード例 #14
0
        public void ErrorResultTO_MakeDataListReady_AsXmlFalseShouldReturnAllErrorsAsOne()
        {
            var result        = "[ \"SomeError\",\"AnotherError\"]";
            var errorResultTo = new ErrorResultTO();

            Assert.AreEqual(0, errorResultTo.FetchErrors().Count);
            errorResultTo.AddError("SomeError");
            errorResultTo.AddError("AnotherError");

            Assert.AreEqual(2, errorResultTo.FetchErrors().Count);

            var makeDisplayReady = errorResultTo.MakeDataListReady(false);

            Assert.AreEqual(result, makeDisplayReady, "\"errors\": prefix have been removed to keep with the xml add error of this method as it seems to be the most used");
        }
コード例 #15
0
ファイル: ErrorResultTOTests.cs プロジェクト: kapiya/Warewolf
        public void ErrorResultTO_MakeDataListReady_AsXmlFalseShouldReturnAllErrorsAsOne()
        {
            var result        = "\"errors\": [ \"SomeError\",\"AnotherError\"]";
            var errorResultTo = new ErrorResultTO();

            Assert.AreEqual(0, errorResultTo.FetchErrors().Count);
            errorResultTo.AddError("SomeError");
            errorResultTo.AddError("AnotherError");

            Assert.AreEqual(2, errorResultTo.FetchErrors().Count);

            var makeDisplayReady = errorResultTo.MakeDataListReady(false);

            Assert.AreEqual(result, makeDisplayReady);
        }
コード例 #16
0
ファイル: ErrorResultTOTests.cs プロジェクト: kapiya/Warewolf
        public void ErrorResultTO_MakeDataListReady_CannotSetUnknownMember_RemapsErrorMessage()
        {
            var result        = "\"errors\": [ \"SomeError\",\"Resource has unrecognized formatting, this Warewolf Server may be to outdated to read this resource.\",\"Another Error\"]";
            var errorResultTo = new ErrorResultTO();

            Assert.AreEqual(0, errorResultTo.FetchErrors().Count);
            errorResultTo.AddError("SomeError");
            errorResultTo.AddError("Cannot set unknown member");
            errorResultTo.AddError("Another Error");

            Assert.AreEqual(3, errorResultTo.FetchErrors().Count);

            var makeDisplayReady = errorResultTo.MakeDataListReady(false);

            Assert.AreEqual(result, makeDisplayReady);
        }
コード例 #17
0
        public void ErrorResultTO_MakeDataListReady_CannotSetUnknownMember_RemapsErrorMessage()
        {
            var result        = "[ \"SomeError\",\"Resource has unrecognized formatting, this Warewolf Server may be to outdated to read this resource.\",\"Another Error\"]";
            var errorResultTo = new ErrorResultTO();

            Assert.AreEqual(0, errorResultTo.FetchErrors().Count);
            errorResultTo.AddError("SomeError");
            errorResultTo.AddError("Cannot set unknown member");
            errorResultTo.AddError("Another Error");

            Assert.AreEqual(3, errorResultTo.FetchErrors().Count);

            var makeDisplayReady = errorResultTo.MakeDataListReady(false);

            Assert.AreEqual(result, makeDisplayReady, "\"errors\": prefix have been removed to keep with the xml add error of this method as it seems to be the most used");
        }
コード例 #18
0
        protected override void ExecuteTool(IDSFDataObject dataObject, int update)
        {
            var allErrors = new ErrorResultTO();
            var errors    = new ErrorResultTO();

            allErrors.MergeErrors(errors);
            InitializeDebug(dataObject);
            // Process if no errors
            try
            {
                ValidateRecordsetName(RecordsetName, errors);
                allErrors.MergeErrors(errors);
                if (!allErrors.HasErrors())
                {
                    try
                    {
                        TryExecuteTool(dataObject, update, allErrors);
                    }
                    catch (Exception e)
                    {
                        AddDebugInputItem(new DebugItemStaticDataParams("", RecordsetName, "Recordset", "="));
                        allErrors.AddError(e.Message);
                        dataObject.Environment.Assign(CountNumber, "0", update);
                        AddDebugOutputItem(new DebugItemStaticDataParams("0", CountNumber, "", "="));
                    }
                }
            }
            finally
            {
                // Handle Errors
                var hasErrors = allErrors.HasErrors();
                if (hasErrors)
                {
                    var errorString = allErrors.MakeDataListReady();
                    dataObject.Environment.AddError(errorString);
                    DisplayAndWriteError(dataObject, DisplayName, allErrors);
                }
                if (dataObject.IsDebugMode())
                {
                    DispatchDebugState(dataObject, StateType.Before, update);
                    DispatchDebugState(dataObject, StateType.After, update);
                }
            }
        }
コード例 #19
0
ファイル: EsbServiceInvoker.cs プロジェクト: kapiya/Warewolf
        ErrorResultTO TryInvokeService(IDSFDataObject dataObject, ErrorResultTO errors)
        {
            var serviceId = dataObject.ResourceID;

            var serviceName = dataObject.ServiceName;

            if (serviceId == Guid.Empty && string.IsNullOrEmpty(serviceName))
            {
                errors.AddError(Resources.DynamicServiceError_ServiceNotSpecified);
            }
            else
            {
                try
                {
                    errors = InvokeService(dataObject, errors, serviceId, serviceName);
                }
                catch (Exception e)
                {
                    errors.AddError(e.Message);
                }
                finally
                {
                    var environment = dataObject.Environment;
                    if (environment.HasErrors())
                    {
                        var errorString     = environment.FetchErrors();
                        var executionErrors = ErrorResultTO.MakeErrorResultFromDataListString(errorString);
                        errors.MergeErrors(executionErrors);
                    }

                    environment.AddError(errors.MakeDataListReady());

                    if (errors.HasErrors())
                    {
                        Dev2Logger.Error(errors.MakeDisplayReady(), GlobalConstants.WarewolfError);
                    }
                }
            }

            return(errors);
        }
コード例 #20
0
        void HandleErrors(IDSFDataObject dataObject, int update, ErrorResultTO allErrors)
        {
            var hasErrors = allErrors.HasErrors();

            if (!hasErrors && dataObject.Environment.Errors.Any())
            {
                DisplayAndWriteError(dataObject, DisplayName, allErrors);
            }

            if (hasErrors)
            {
                var errorString = allErrors.MakeDataListReady();
                dataObject.Environment.AddError(errorString);
                DisplayAndWriteError(dataObject, DisplayName, allErrors);
            }

            if (dataObject.IsDebugMode())
            {
                DispatchDebugState(dataObject, StateType.Before, update);
                DispatchDebugState(dataObject, StateType.After, update);
            }
        }
コード例 #21
0
        /// <summary>
        /// When overridden runs the activity's simulation logic
        /// </summary>
        /// <param name="context">The context to be used.</param>
        protected virtual void OnExecuteSimulation(NativeActivityContext context)
        {
            var rootInfo = context.GetExtension <WorkflowInstanceInfo>();

            var key = new SimulationKey
            {
                WorkflowID = rootInfo.ProxyName,
                ActivityID = UniqueID,
                ScenarioID = ScenarioID
            };
            var result = SimulationRepository.Instance.Get(key);

            if (result != null && result.Value != null)
            {
                var dataListExecutionID    = context.GetValue(DataListExecutionID);
                IDataListCompiler compiler = DataListFactory.CreateDataListCompiler();

                var dataObject = context.GetExtension <IDSFDataObject>();

                if (compiler != null && dataObject != null)
                {
                    var allErrors = new ErrorResultTO();
                    var dataList  = compiler.FetchBinaryDataList(dataObject.DataListID, out errorsTo);
                    allErrors.MergeErrors(errorsTo);

                    compiler.Merge(dataList, result.Value, enDataListMergeTypes.Union, enTranslationDepth.Data, false, out errorsTo);
                    allErrors.MergeErrors(errorsTo);

                    compiler.Shape(dataListExecutionID, enDev2ArgumentType.Output, OutputMapping, out errorsTo);
                    allErrors.MergeErrors(errorsTo);

                    if (allErrors.HasErrors())
                    {
                        DisplayAndWriteError(rootInfo.ProxyName, allErrors);
                        dataObject.Environment.AddError(allErrors.MakeDataListReady());
                    }
                }
            }
        }
コード例 #22
0
        private void DebugOutput(IDSFDataObject dataObject, int update, ErrorResultTO allErrors, string parentServiceName, string serviceName, Guid oldResourceId)
        {
            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;
        }
コード例 #23
0
        public void ErrorResultTO_MakeDataListReady_ShouldReturnAllErrorsAsOne()
        {
            var result        = "<InnerError>SomeError</InnerError><InnerError>AnotherError</InnerError>";
            var errorResultTo = new ErrorResultTO();

            Assert.IsNotNull(errorResultTo);
            var prObj  = new PrivateObject(errorResultTo);
            var errors = prObj.GetField("_errorList") as IList <string>;

            Assert.IsNotNull(errors);
            Assert.AreEqual(0, errors.Count);
            errorResultTo.AddError("SomeError");
            errorResultTo.AddError("AnotherError");
            errors = prObj.GetField("_errorList") as IList <string>;
            if (errors != null)
            {
                Assert.AreEqual(2, errors.Count);
            }
            var makeDisplayReady = errorResultTo.MakeDataListReady();

            Assert.AreEqual(result, makeDisplayReady);
        }
コード例 #24
0
        /// <summary>
        /// Resumed the specified context.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="bookmark">The bookmark.</param>
        /// <param name="value">The value.</param>
        /// <exception cref="System.Exception">
        /// Parent and Child DataList IDs are the same, aborting resumption!
        /// or
        /// Fatal Error : Cannot merge resumed data
        /// or
        /// Fatal Error : Cannot locate Root DataList for resumption!
        /// </exception>
        public virtual void Resumed(NativeActivityContext context, Bookmark bookmark, object value)
        {
            IDSFDataObject myDO          = context.GetExtension <IDSFDataObject>();
            ErrorResultTO  errorResultTO = new ErrorResultTO();
            Guid           executionID   = myDO.DataListID;

            if (value != null)
            {
                Guid rootID;
                Guid.TryParse(value.ToString(), out rootID);

                if (executionID == rootID)
                {
                    throw new Exception("Parent and Child DataList IDs are the same, aborting resumption!");
                }

                try
                {
                }
                finally
                {
                    // At resumption this is the root dl entry ;)

                    // Handle Errors
                    if (errorResultTO.HasErrors())
                    {
                        DisplayAndWriteError("Resumption", errorResultTO);
                        var errorString = errorResultTO.MakeDataListReady();
                        myDO.Environment.AddError(errorString);
                    }
                }
            }
            else
            {
                throw new Exception("Fatal Error : Cannot locate Root DataList for resumption!");
            }
        }
コード例 #25
0
        protected override void ExecuteTool(IDSFDataObject dataObject, int update)
        {
            var allErrors = new ErrorResultTO();
            var errors    = new ErrorResultTO();

            _executionResult = new List <string>();
            allErrors.MergeErrors(errors);
            InitializeDebug(dataObject);
            // Process if no errors
            try
            {
                TryExecute(dataObject, update, allErrors, errors);
            }
            catch (Exception ex)
            {
                Dev2Logger.Error(string.Format("{0} Exception", DisplayName), ex, GlobalConstants.WarewolfError);
                allErrors.AddError(ex.Message);
            }
            finally
            {
                // Handle Errors
                var hasErrors = allErrors.HasErrors();
                if (hasErrors)
                {
                    DisplayAndWriteError(DisplayName, allErrors);
                    var errorList = allErrors.MakeDataListReady();
                    dataObject.Environment.AddError(errorList);
                    dataObject.Environment.Assign(Result, DisplayName.ToUpper().Contains("Dropbox".ToUpper()) ? GlobalConstants.DropBoxFailure : null, update);
                }
                if (dataObject.IsDebugMode())
                {
                    DispatchDebugState(dataObject, StateType.Before, update);
                    DispatchDebugState(dataObject, StateType.After, update);
                }
            }
        }
コード例 #26
0
        protected override void ExecuteTool(IDSFDataObject dataObject, int update)
        {
            var allErrors = new ErrorResultTO();
            var errors    = new ErrorResultTO();

            allErrors.MergeErrors(errors);
            InitializeDebug(dataObject);
            JsonMappings = JsonMappings.Where(validMapping).ToList();
            // Process if no errors
            try
            {
                if (JsonMappings == null)
                {
                    dataObject.Environment.AddError("Json Mappings supplied to activity is null.");
                }

                // ReSharper disable AssignNullToNotNullAttribute
                if (!dataObject.Environment.Errors.Any() && !JsonMappings.Any())
                // ReSharper restore AssignNullToNotNullAttribute
                {
                    dataObject.Environment.AddError("No Json Mappings supplied to activity.");
                }

                // ReSharper disable AssignNullToNotNullAttribute
                if (!dataObject.Environment.Errors.Any())
                // ReSharper restore AssignNullToNotNullAttribute
                {
                    JsonMappings.ToList().ForEach(m =>
                    {
                        var validationResult = new IsValidJsonCreateMappingInputRule(() => m).Check();
                        if (validationResult != null)
                        {
                            dataObject.Environment.AddError(validationResult.Message);
                        }
                    });
                }

                if (dataObject.IsDebugMode())
                {
                    int j = 0;
                    // ReSharper disable PossibleNullReferenceException
                    foreach (JsonMappingTo a in JsonMappings.Where(to => !String.IsNullOrEmpty(to.SourceName)))
                    // ReSharper restore PossibleNullReferenceException
                    {
                        var debugItem = new DebugItem();
                        AddDebugItem(new DebugItemStaticDataParams(string.Empty, (++j).ToString(CultureInfo.InvariantCulture)), debugItem);
                        AddDebugItem(new DebugEvalResult(a.SourceName, string.Empty, dataObject.Environment, update), debugItem);
                        _debugInputs.Add(debugItem);
                    }
                }
                // TODO: More validation through IRule, IRuleSet to throw out anything not in spec
                if (!dataObject.Environment.Errors.Any())
                {
                    // JsonMappings.Count() is larger than zero
                    var json = new JObject(); // outermost JSON would always be a single JObject, i.e. {'name': value}
                    // ReSharper disable AssignNullToNotNullAttribute
                    List <JsonMappingTo> jsonMappingList = JsonMappings.ToList();
                    // ReSharper restore AssignNullToNotNullAttribute

                    // build the list of JsonMappingCompoundTo - a compound is either a single expression or a comma seperated list of expressions
                    // ReSharper disable MaximumChainedReferences
                    List <JsonMappingCompoundTo> results = jsonMappingList.Where(to => !String.IsNullOrEmpty(to.SourceName)).Select(jsonMapping =>
                                                                                                                                    new JsonMappingCompoundTo(dataObject.Environment, jsonMapping
                                                                                                                                                              )).ToList();
                    // ReSharper restore MaximumChainedReferences



                    // main loop for producing largest list of zipped values

                    results.ForEach(x =>
                    {
                        // if it is not a compound,
                        if (!x.IsCompound)
                        {
                            // add JProperty, with name x.DestinationName, and value eval(x.SourceName)
                            json.Add(new JProperty(
                                         x.DestinationName,
                                         x.EvaluatedResultIndexed(0))
                                     );
                        }
                        else
                        {
                            // if it is a compound,
                            if (!x.EvalResult.IsWarewolfRecordSetResult)
                            {
                                json.Add(new JProperty(
                                             x.DestinationName,
                                             x.ComplexEvaluatedResultIndexed(0))
                                         );
                            }
                            else if (x.EvalResult.IsWarewolfRecordSetResult)
                            {
                                json.Add(
                                    x.ComplexEvaluatedResultIndexed(0));
                            }
                        }
                    }
                                    );


                    dataObject.Environment.Assign(JsonString, json.ToString(Formatting.None), update);

                    if (dataObject.IsDebugMode())
                    {
                        AddDebugOutputItem(new DebugEvalResult(JsonString, string.Empty, dataObject.Environment, update));
                    }

                    /*
                     * var rule = new IsSingleValueRule(() => CountNumber);
                     * var single = rule.Check();
                     * if (single != null)
                     * {
                     *  allErrors.AddError(single.Message);
                     * }
                     * else
                     * {
                     *  var count = 0;
                     *  if (dataObject.Environment.HasRecordSet(RecordsetName))
                     *  {
                     *      count = dataObject.Environment.GetCount(rs);
                     *  }
                     *  var value = count.ToString();
                     *  dataObject.Environment.Assign(CountNumber, value);
                     *  AddDebugOutputItem(new DebugEvalResult(CountNumber, "", dataObject.Environment));
                     * }
                     * */
                }
            }
            catch (Exception e)
            {
                // ReSharper disable AssignNullToNotNullAttribute
                JsonMappings.ToList().ForEach(x =>
                                              // ReSharper restore AssignNullToNotNullAttribute
                {
                    AddDebugInputItem(new DebugItemStaticDataParams("", x.SourceName, "SourceName", "="));
                    AddDebugInputItem(new DebugItemStaticDataParams("", x.DestinationName, "DestinationName"));
                });

                allErrors.AddError(e.Message);
                dataObject.Environment.Assign(JsonString, string.Empty, update);
                AddDebugOutputItem(new DebugItemStaticDataParams(string.Empty, JsonString, "", "="));
            }
            finally
            {
                // Handle Errors
                bool hasErrors = allErrors.HasErrors();
                if (hasErrors)
                {
                    DisplayAndWriteError("DsfCreateJsonActivity", allErrors);
                    string errorString = allErrors.MakeDataListReady();
                    dataObject.Environment.AddError(errorString);
                }
                if (dataObject.IsDebugMode())
                {
                    DispatchDebugState(dataObject, StateType.Before, update);
                    DispatchDebugState(dataObject, StateType.After, update);
                }
            }
        }
コード例 #27
0
        protected static IResponseWriter CreateForm(WebRequestTO webRequest, string serviceName, string workspaceId, NameValueCollection headers, IPrincipal user = null)
        {
            //lock(ExecutionObject)
            {
                string executePayload = "";
                Guid   workspaceGuid;

                if (workspaceId != null)
                {
                    if (!Guid.TryParse(workspaceId, out workspaceGuid))
                    {
                        workspaceGuid = WorkspaceRepository.Instance.ServerWorkspace.ID;
                    }
                }
                else
                {
                    workspaceGuid = WorkspaceRepository.Instance.ServerWorkspace.ID;
                }

                var allErrors  = new ErrorResultTO();
                var dataObject = new DsfDataObject(webRequest.RawRequestPayload, GlobalConstants.NullDataListID, webRequest.RawRequestPayload)
                {
                    IsFromWebServer = true, ExecutingUser = user, ServiceName = serviceName, WorkspaceID = workspaceGuid
                };

                // now bind any variables that are part of the path arguments ;)
                BindRequestVariablesToDataObject(webRequest, ref dataObject);

                // now process headers ;)
                if (headers != null)
                {
                    Dev2Logger.Log.Debug("Remote Invoke");

                    var isRemote = headers.Get(HttpRequestHeader.Cookie.ToString());
                    var remoteId = headers.Get(HttpRequestHeader.From.ToString());

                    if (isRemote != null && remoteId != null)
                    {
                        if (isRemote.Equals(GlobalConstants.RemoteServerInvoke))
                        {
                            // we have a remote invoke ;)
                            dataObject.RemoteInvoke = true;
                        }
                        if (isRemote.Equals(GlobalConstants.RemoteDebugServerInvoke))
                        {
                            // we have a remote invoke ;)
                            dataObject.RemoteNonDebugInvoke = true;
                        }

                        dataObject.RemoteInvokerID = remoteId;
                    }
                }

                // now set the emition type ;)
                int loc;
                if (!String.IsNullOrEmpty(serviceName) && (loc = serviceName.LastIndexOf(".", StringComparison.Ordinal)) > 0)
                {
                    // default it to xml
                    dataObject.ReturnType = EmitionTypes.XML;

                    if (loc > 0)
                    {
                        var          typeOf = serviceName.Substring((loc + 1)).ToUpper();
                        EmitionTypes myType;
                        if (Enum.TryParse(typeOf, out myType))
                        {
                            dataObject.ReturnType = myType;
                        }

                        // adjust the service name to drop the type ;)

                        // avoid .wiz amendments ;)
                        if (!typeOf.ToLower().Equals(GlobalConstants.WizardExt))
                        {
                            serviceName            = serviceName.Substring(0, loc);
                            dataObject.ServiceName = serviceName;
                        }

                        if (typeOf.Equals("api", StringComparison.OrdinalIgnoreCase))
                        {
                            dataObject.ReturnType = EmitionTypes.SWAGGER;
                        }
                    }
                }
                else
                {
                    // default it to xml
                    dataObject.ReturnType = EmitionTypes.XML;
                }

                // ensure service gets set ;)
                if (dataObject.ServiceName == null)
                {
                    dataObject.ServiceName = serviceName;
                }
                IResource resource = null;
                if (!String.IsNullOrEmpty(dataObject.ServiceName))
                {
                    resource = ResourceCatalog.Instance.GetResource(dataObject.WorkspaceID, dataObject.ServiceName);
                    if (resource != null)
                    {
                        dataObject.ResourceID = resource.ResourceID;
                    }
                }
                var esbEndpoint = new EsbServicesEndpoint();
                dataObject.EsbChannel = esbEndpoint;
                var canExecute = true;
                if (ServerAuthorizationService.Instance != null)
                {
                    var authorizationService = ServerAuthorizationService.Instance;
                    var hasView    = authorizationService.IsAuthorized(AuthorizationContext.View, dataObject.ResourceID.ToString());
                    var hasExecute = authorizationService.IsAuthorized(AuthorizationContext.Execute, dataObject.ResourceID.ToString());
                    canExecute = (hasExecute && hasView) || ((dataObject.RemoteInvoke || dataObject.RemoteNonDebugInvoke) && hasExecute) || (resource != null && resource.ResourceType == ResourceType.ReservedService);
                }
                // Build EsbExecutionRequest - Internal Services Require This ;)
                EsbExecuteRequest esbExecuteRequest = new EsbExecuteRequest {
                    ServiceName = serviceName
                };
                foreach (string key in webRequest.Variables)
                {
                    esbExecuteRequest.AddArgument(key, new StringBuilder(webRequest.Variables[key]));
                }
                Dev2Logger.Log.Debug("About to execute web request [ " + serviceName + " ] DataObject Payload [ " + dataObject.RawPayload + " ]");
                var executionDlid = GlobalConstants.NullDataListID;
                if (canExecute && dataObject.ReturnType != EmitionTypes.SWAGGER)
                {
                    ErrorResultTO errors;
                    executionDlid = esbEndpoint.ExecuteRequest(dataObject, esbExecuteRequest, workspaceGuid, out errors);
                    allErrors.MergeErrors(errors);
                }
                else if (!canExecute)
                {
                    allErrors.AddError("Executing a service externally requires View and Execute permissions");
                }
                foreach (var error in dataObject.Environment.Errors)
                {
                    allErrors.AddError(error, true);
                }
                // Fetch return type ;)
                var formatter = DataListFormat.CreateFormat("XML", EmitionTypes.XML, "text/xml");

                // force it to XML if need be ;)

                // Fetch and convert DL ;)
                if (!dataObject.Environment.HasErrors())
                {
                    // a normal service request
                    if (!esbExecuteRequest.WasInternalService)
                    {
                        dataObject.DataListID  = executionDlid;
                        dataObject.WorkspaceID = workspaceGuid;
                        dataObject.ServiceName = serviceName;

                        if (!dataObject.IsDebug || dataObject.RemoteInvoke || dataObject.RemoteNonDebugInvoke)
                        {
                            if (dataObject.ReturnType == EmitionTypes.JSON)
                            {
                                formatter      = DataListFormat.CreateFormat("JSON", EmitionTypes.JSON, "application/json");
                                executePayload = ExecutionEnvironmentUtils.GetJsonOutputFromEnvironment(dataObject, resource.DataList.ToString(), 0);
                            }
                            else if (dataObject.ReturnType == EmitionTypes.XML)
                            {
                                executePayload = ExecutionEnvironmentUtils.GetXmlOutputFromEnvironment(dataObject, Guid.Empty, resource.DataList.ToString(), 0);
                            }
                            else if (dataObject.ReturnType == EmitionTypes.SWAGGER)
                            {
                                formatter      = DataListFormat.CreateFormat("SWAGGER", EmitionTypes.SWAGGER, "application/json");
                                executePayload = ExecutionEnvironmentUtils.GetSwaggerOutputForService(resource, resource.DataList.ToString());
                            }
                        }
                        else
                        {
                            executePayload = string.Empty;
                        }
                    }
                    else
                    {
                        // internal service request we need to return data for it from the request object ;)
                        var serializer = new Dev2JsonSerializer();
                        executePayload = string.Empty;
                        var msg = serializer.Deserialize <ExecuteMessage>(esbExecuteRequest.ExecuteResult);

                        if (msg != null)
                        {
                            executePayload = msg.Message.ToString();
                        }

                        // out fail safe to return different types of data from services ;)
                        if (string.IsNullOrEmpty(executePayload))
                        {
                            executePayload = esbExecuteRequest.ExecuteResult.ToString();
                        }
                    }
                }
                else
                {
                    if (dataObject.ReturnType == EmitionTypes.XML)
                    {
                        executePayload =
                            "<FatalError> <Message> An internal error occurred while executing the service request </Message>";
                        executePayload += allErrors.MakeDataListReady();
                        executePayload += "</FatalError>";
                    }
                    else
                    {
                        // convert output to JSON ;)
                        executePayload =
                            "{ \"FatalError\": \"An internal error occurred while executing the service request\",";
                        executePayload += allErrors.MakeDataListReady(false);
                        executePayload += "}";
                    }
                }


                Dev2Logger.Log.Debug("Execution Result [ " + executePayload + " ]");


                // JSON Data ;)
                if (executePayload.IndexOf("</JSON>", StringComparison.Ordinal) >= 0)
                {
                    int start = executePayload.IndexOf(GlobalConstants.OpenJSON, StringComparison.Ordinal);
                    if (start >= 0)
                    {
                        int end = executePayload.IndexOf(GlobalConstants.CloseJSON, StringComparison.Ordinal);
                        start += GlobalConstants.OpenJSON.Length;

                        executePayload = CleanupHtml(executePayload.Substring(start, (end - start)));
                        if (!String.IsNullOrEmpty(executePayload))
                        {
                            return(new StringResponseWriter(executePayload, ContentTypes.Json));
                        }
                    }
                }
                Dev2DataListDecisionHandler.Instance.RemoveEnvironment(dataObject.DataListID);
                dataObject.Environment = null;
                return(new StringResponseWriter(executePayload, formatter.ContentType));
            }
        }
コード例 #28
0
        public void ErrorResultTO_AddError_CheckForDuplicates_False_AddSameError_ExpectAdd()
        {
            var resultTo = new ErrorResultTO();

            resultTo.AddError("some message", false);
            resultTo.AddError("some message", false);
            resultTo.AddError("some message", true);
            resultTo.AddError("deferent message", false);

            Assert.IsTrue(resultTo.HasErrors());
            Assert.AreEqual(2, resultTo.FetchErrors().Count);
            Assert.AreEqual("some message", resultTo.FetchErrors()[0]);
            Assert.AreEqual("deferent message", resultTo.FetchErrors()[1]);
            Assert.AreEqual("<InnerError>some message</InnerError><InnerError>deferent message</InnerError>", resultTo.MakeDataListReady());
        }
コード例 #29
0
        // ReSharper restore RedundantOverridenMember

        protected override void OnExecute(NativeActivityContext context)
        {
            _debugInputs  = new List <DebugItem>();
            _debugOutputs = new List <DebugItem>();
            IDSFDataObject       dataObject      = context.GetExtension <IDSFDataObject>();
            IDataListCompiler    compiler        = DataListFactory.CreateDataListCompiler();
            IDev2MergeOperations mergeOperations = new Dev2MergeOperations();
            ErrorResultTO        allErrors       = new ErrorResultTO();
            ErrorResultTO        errorResultTo   = new ErrorResultTO();
            Guid executionId = DataListExecutionID.Get(context);
            IDev2DataListUpsertPayloadBuilder <string> toUpsert = Dev2DataListBuilderFactory.CreateStringDataListUpsertBuilder(true);

            toUpsert.IsDebug    = dataObject.IsDebugMode();
            toUpsert.ResourceID = dataObject.ResourceID;

            InitializeDebug(dataObject);
            try
            {
                CleanArguments(MergeCollection);

                if (MergeCollection.Count <= 0)
                {
                    return;
                }

                IDev2IteratorCollection iteratorCollection = Dev2ValueObjectFactory.CreateIteratorCollection();


                allErrors.MergeErrors(errorResultTo);
                Dictionary <int, List <IDev2DataListEvaluateIterator> > listOfIterators = new Dictionary <int, List <IDev2DataListEvaluateIterator> >();

                #region Create a iterator for each row in the data grid in the designer so that the right iteration happen on the data

                int dictionaryKey = 0;
                foreach (DataMergeDTO row in MergeCollection)
                {
                    IBinaryDataListEntry inputVariableExpressionEntry = compiler.Evaluate(executionId, enActionType.User, row.InputVariable, false, out errorResultTo);
                    allErrors.MergeErrors(errorResultTo);

                    IBinaryDataListEntry atExpressionEntry = compiler.Evaluate(executionId, enActionType.User, row.At, false, out errorResultTo);
                    allErrors.MergeErrors(errorResultTo);

                    IBinaryDataListEntry paddingExpressionEntry = compiler.Evaluate(executionId, enActionType.User, row.Padding, false, out errorResultTo);
                    allErrors.MergeErrors(errorResultTo);

                    var fieldName        = row.InputVariable;
                    var splitIntoRegions = DataListCleaningUtils.FindAllLanguagePieces(fieldName);
                    var datalist         = compiler.ConvertFrom(dataObject.DataListID, DataListFormat.CreateFormat(GlobalConstants._Studio_XML), enTranslationDepth.Shape, out errorResultTo).ToString();
                    if (!string.IsNullOrEmpty(datalist))
                    {
                        foreach (var region in splitIntoRegions)
                        {
                            var r           = DataListUtil.IsValueRecordset(region) ? DataListUtil.ReplaceRecordsetIndexWithBlank(region) : region;
                            var isValidExpr = new IsValidExpressionRule(() => r, datalist)
                            {
                                LabelText = fieldName
                            };

                            var errorInfo = isValidExpr.Check();
                            if (errorInfo != null)
                            {
                                row.InputVariable = "";
                                errorResultTo.AddError(errorInfo.Message);
                            }
                            allErrors.MergeErrors(errorResultTo);
                        }
                    }

                    allErrors.MergeErrors(errorResultTo);

                    if (dataObject.IsDebugMode())
                    {
                        DebugItem debugItem = new DebugItem();
                        AddDebugItem(new DebugItemStaticDataParams("", (MergeCollection.IndexOf(row) + 1).ToString(CultureInfo.InvariantCulture)), debugItem);
                        AddDebugItem(new DebugItemVariableParams(row.InputVariable, "", inputVariableExpressionEntry, executionId), debugItem);
                        AddDebugItem(new DebugItemStaticDataParams(row.MergeType, "With"), debugItem);
                        AddDebugItem(new DebugItemVariableParams(row.At, "Using", atExpressionEntry, executionId), debugItem);
                        AddDebugItem(new DebugItemVariableParams(row.Padding, "Pad", paddingExpressionEntry, executionId), debugItem);

                        //Old workflows don't have this set.
                        if (row.Alignment == null)
                        {
                            row.Alignment = string.Empty;
                        }

                        AddDebugItem(DataListUtil.IsEvaluated(row.Alignment) ? new DebugItemStaticDataParams("", row.Alignment, "Align") : new DebugItemStaticDataParams(row.Alignment, "Align"), debugItem);

                        _debugInputs.Add(debugItem);
                    }

                    IDev2DataListEvaluateIterator itr    = Dev2ValueObjectFactory.CreateEvaluateIterator(inputVariableExpressionEntry);
                    IDev2DataListEvaluateIterator atItr  = Dev2ValueObjectFactory.CreateEvaluateIterator(atExpressionEntry);
                    IDev2DataListEvaluateIterator padItr = Dev2ValueObjectFactory.CreateEvaluateIterator(paddingExpressionEntry);

                    iteratorCollection.AddIterator(itr);
                    iteratorCollection.AddIterator(atItr);
                    iteratorCollection.AddIterator(padItr);

                    listOfIterators.Add(dictionaryKey, new List <IDev2DataListEvaluateIterator> {
                        itr, atItr, padItr
                    });
                    dictionaryKey++;
                }

                #endregion

                #region Iterate and Merge Data
                if (!allErrors.HasErrors())
                {
                    while (iteratorCollection.HasMoreData())
                    {
                        int pos = 0;
                        foreach (var iterator in listOfIterators)
                        {
                            var val = iteratorCollection.FetchNextRow(iterator.Value[0]);
                            var at  = iteratorCollection.FetchNextRow(iterator.Value[1]);
                            var pad = iteratorCollection.FetchNextRow(iterator.Value[2]);

                            if (val != null)
                            {
                                if (at != null)
                                {
                                    if (pad != null)
                                    {
                                        if (MergeCollection[pos].MergeType == "Index")
                                        {
                                            if (string.IsNullOrEmpty(at.TheValue))
                                            {
                                                allErrors.AddError("The 'Using' value cannot be blank.");
                                            }

                                            int atValue;
                                            if (!Int32.TryParse(at.TheValue, out atValue) || atValue < 0)
                                            {
                                                allErrors.AddError("The 'Using' value must be a real number.");
                                            }
                                            if (pad.TheValue.Length > 1)
                                            {
                                                allErrors.AddError("'Padding' must be a single character");
                                            }
                                        }
                                        else
                                        {
                                            if (MergeCollection[pos].MergeType == "Chars" && string.IsNullOrEmpty(at.TheValue))
                                            {
                                                allErrors.AddError("The 'Using' value cannot be blank.");
                                            }
                                        }
                                        mergeOperations.Merge(val.TheValue, MergeCollection[pos].MergeType, at.TheValue, pad.TheValue, MergeCollection[pos].Alignment);
                                        pos++;
                                    }
                                }
                            }
                        }
                    }
                    if (!allErrors.HasErrors())
                    {
                        if (string.IsNullOrEmpty(Result))
                        {
                            AddDebugOutputItem(new DebugItemStaticDataParams("", ""));
                        }
                        else
                        {
                            var rule   = new IsSingleValueRule(() => Result);
                            var single = rule.Check();
                            if (single != null)
                            {
                                allErrors.AddError(single.Message);
                            }
                            else
                            {
                                toUpsert.Add(Result, mergeOperations.MergeData.ToString());
                                toUpsert.FlushIterationFrame();
                                compiler.Upsert(executionId, toUpsert, out errorResultTo);
                                allErrors.MergeErrors(errorResultTo);

                                if (dataObject.IsDebugMode() && !allErrors.HasErrors())
                                {
                                    foreach (var debugOutputTo in toUpsert.DebugOutputs)
                                    {
                                        if (debugOutputTo.LeftEntry != null && debugOutputTo.TargetEntry != null)
                                        {
                                            AddDebugOutputItem(new DebugItemVariableParams(debugOutputTo));
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                #endregion Iterate and Merge Data
            }
            catch (Exception e)
            {
                Dev2Logger.Log.Error("DSFDataMerge", e);
                allErrors.AddError(e.Message);
            }
            finally
            {
                #region Handle Errors

                if (allErrors.HasErrors())
                {
                    if (dataObject.IsDebugMode())
                    {
                        AddDebugOutputItem(new DebugItemStaticDataParams("", Result, ""));
                    }
                    DisplayAndWriteError("DsfDataMergeActivity", allErrors);
                    compiler.UpsertSystemTag(dataObject.DataListID, enSystemTag.Dev2Error, allErrors.MakeDataListReady(), out errorResultTo);
                    compiler.Upsert(executionId, Result, (string)null, out errorResultTo);
                }

                if (dataObject.IsDebugMode())
                {
                    DispatchDebugState(context, StateType.Before);
                    DispatchDebugState(context, StateType.After);
                }

                #endregion
            }
        }
コード例 #30
0
        /// <summary>
        /// The execute method that is called when the activity is executed at run time and will hold all the logic of the activity
        /// </summary>
        protected override void OnExecute(NativeActivityContext context)
        {
            _debugInputs  = new List <DebugItem>();
            _debugOutputs = new List <DebugItem>();
            IDSFDataObject    dataObject = context.GetExtension <IDSFDataObject>();
            IDataListCompiler compiler   = DataListFactory.CreateDataListCompiler();

            ErrorResultTO allErrors   = new ErrorResultTO();
            ErrorResultTO errors      = new ErrorResultTO();
            Guid          executionId = DataListExecutionID.Get(context);

            allErrors.MergeErrors(errors);
            InitializeDebug(dataObject);
            // Process if no errors
            try
            {
                IsSingleValueRule.ApplyIsSingleValueRule(Result, allErrors);

                if (dataObject.IsDebugMode())
                {
                    AddDebugInputItem(executionId);
                }
                IFunctionEvaluator functionEvaluator = MathOpsFactory.CreateFunctionEvaluator();

                string input = string.IsNullOrEmpty(Expression) ? Expression : Expression.Replace("\\r", string.Empty).Replace("\\n", string.Empty).Replace(Environment.NewLine, "");

                IEvaluationFunction evaluationFunctionTo = MathOpsFactory.CreateEvaluationExpressionTO(input);

                string result = functionEvaluator.EvaluateFunction(evaluationFunctionTo, executionId, out errors);
                allErrors.MergeErrors(errors);

                compiler.Upsert(executionId, Result, result, out errors);

                if (dataObject.IsDebugMode() && !allErrors.HasErrors())
                {
                    AddDebugOutputItem(Result, executionId);
                }
                allErrors.MergeErrors(errors);
            }
            catch (Exception ex)
            {
                Dev2Logger.Log.Error("Calculate Exception", ex);
                allErrors.AddError(ex.Message);
            }
            finally
            {
                // Handle Errors
                var hasErrors = allErrors.HasErrors();
                if (hasErrors)
                {
                    DisplayAndWriteError("DsfCalculateActivity", allErrors);
                    compiler.UpsertSystemTag(dataObject.DataListID, enSystemTag.Dev2Error, allErrors.MakeDataListReady(), out errors);
                    compiler.Upsert(executionId, Result, (string)null, out errors);
                }
                if (dataObject.IsDebugMode())
                {
                    if (hasErrors)
                    {
                        AddDebugOutputItem(Result, executionId);
                    }
                    DispatchDebugState(context, StateType.Before);
                    DispatchDebugState(context, StateType.After);
                }
            }
        }