The core TO used in the execution engine ;)
Inheritance: System.Activities.Persistence.PersistenceParticipant, IDSFDataObject
示例#1
0
        public void DsfDataOBject_IsRemoteWorkflow_WhenOverrideNotSet_ExpectTrue()
        {
            //------------Setup for test--------------------------
            IDSFDataObject dataObject = new DsfDataObject(string.Empty, Guid.NewGuid());
            dataObject.EnvironmentID = Guid.NewGuid();

            //------------Execute Test---------------------------
            var result = dataObject.IsRemoteWorkflow();

            //------------Assert Results-------------------------
            Assert.IsTrue(result);
        }
示例#2
0
        public void DsfDataOBject_IsRemoteWorkflow_WhenOverrideSetAndEmptyGuid_ExpectFalse()
        {
            //------------Setup for test--------------------------
            IDSFDataObject dataObject = new DsfDataObject(string.Empty, Guid.NewGuid());
            dataObject.EnvironmentID = Guid.Empty;
            dataObject.IsRemoteInvokeOverridden = true;

            //------------Execute Test---------------------------
            var result = dataObject.IsRemoteWorkflow();

            //------------Assert Results-------------------------
            Assert.IsFalse(result);
        }
        // ReSharper disable InconsistentNaming
        public void DsfPluginActivity_DsfPluginActivityUnitTest_GetNewPluginServiceExecution_ServiceConstructed()
        // ReSharper restore InconsistentNaming
        {
            //init
            var expected = Guid.NewGuid();
            var pluginActivity = new MockDsfPluginActivity();
            var mockContext = new DsfDataObject("<DataList></DataList>", expected);

            //exe
            var actual = pluginActivity.MockGetNewPluginServiceExecution(mockContext);

            //assert
            Assert.AreEqual(typeof(PluginServiceExecution), actual.GetType(), "DsfPluginActivity did not construct a correct PluginServiceExecution");
            Assert.AreEqual(expected, actual.DataObj.DataListID, "The Plugin Service Execution constructed by DsfPluginActivity is using the incorrect datalist");
        }
        public void JsonMappingCompoundTo_Constructor_SetsProperties_NotIsCompound()
        {
            //------------Setup for test--------------------------
            // ReSharper disable RedundantArgumentName
            var dataObject = new DsfDataObject(xmldata: string.Empty, dataListId: Guid.NewGuid());

            dataObject.Environment.Assign("[[a]]", "10", 0);
            dataObject.Environment.Assign("[[b]]", "20", 0);
            dataObject.Environment.Assign("[[rec(1).a]]", "50", 0);
            dataObject.Environment.Assign("[[rec(1).b]]", "500", 0);
            //------------Execute Test---------------------------

            var jsonMappingCompound = new JsonMappingCompoundTo(
                env: dataObject.Environment,
                compound: new JsonMappingTo { SourceName = "[[a]]", DestinationName = "a" }
            );
            //------------Assert Results-------------------------
            Assert.IsNotNull(jsonMappingCompound);
            Assert.IsFalse(jsonMappingCompound.IsCompound);
        }
        public void JsonMappingCompoundTo_MaxCount_NotIsCompound()
        {
            //------------Setup for test--------------------------
            var dataObject = new DsfDataObject(xmldata: string.Empty, dataListId: Guid.NewGuid());
            dataObject.Environment.Assign("[[a]]", "10", 0);
            dataObject.Environment.Assign("[[b]]", "20", 0);
            dataObject.Environment.Assign("[[rec(1).a]]", "50", 0);
            dataObject.Environment.Assign("[[rec(1).b]]", "500", 0);
            dataObject.Environment.Assign("[[rec(2).a]]", "60", 0);
            dataObject.Environment.Assign("[[rec(2).b]]", "600", 0);
            //------------Execute Test---------------------------

            var jsonMappingCompound = new JsonMappingCompoundTo(
                env: dataObject.Environment,
                compound: new JsonMappingTo
                {
                    SourceName = "[[rec().a]]",
                    DestinationName = "myName"
                }
            );
            //------------Assert Results-------------------------
            Assert.IsNotNull(jsonMappingCompound);
            Assert.IsFalse(jsonMappingCompound.IsCompound);
            Assert.AreEqual(jsonMappingCompound.MaxCount, 1);

            // check for list
            jsonMappingCompound = new JsonMappingCompoundTo(
                env: dataObject.Environment,
                compound: new JsonMappingTo
                {
                    SourceName = "[[rec(*).a]]",
                    DestinationName = "myName"
                }
            );
            Assert.IsFalse(jsonMappingCompound.IsCompound);
            Assert.AreEqual(jsonMappingCompound.MaxCount, 2);
        }
示例#6
0
        public void DsfDataObject_Clone_NormalClone_FullDuplicationForProperties()
        {
            //------------Setup for test--------------------------
            IDSFDataObject dataObject = new DsfDataObject(string.Empty, Guid.NewGuid(), "<x>1</x>");
            Guid wfInstanceID = Guid.NewGuid();

            dataObject.BookmarkExecutionCallbackID = Guid.NewGuid();
            dataObject.CurrentBookmarkName = "def";
            dataObject.DataList = new StringBuilder("<x/>");
            dataObject.DataListID = Guid.NewGuid();
            dataObject.DatalistInMergeDepth = enTranslationDepth.Data;
            dataObject.DatalistInMergeID = Guid.NewGuid();
            dataObject.DatalistInMergeType = enDataListMergeTypes.Union;
            dataObject.DatalistOutMergeDepth = enTranslationDepth.Data;
            dataObject.DatalistOutMergeFrequency = DataListMergeFrequency.Always;
            dataObject.DatalistOutMergeID = Guid.NewGuid();
            dataObject.DatalistOutMergeType = enDataListMergeTypes.Union;
            dataObject.DebugSessionID = Guid.NewGuid();
            dataObject.EnvironmentID = Guid.NewGuid();
         //   dataObject.Errors = new ErrorResultTO();
         //   dataObject.Errors.AddError("my error");
            dataObject.ExecutionCallbackID = Guid.NewGuid();
            dataObject.ExecutionOrigin = ExecutionOrigin.Debug;
            dataObject.ExecutionOriginDescription = "xxx";
            dataObject.ForceDeleteAtNextNativeActivityCleanup = true;
            dataObject.IsDataListScoped = false;
            dataObject.IsDebug = true;
            dataObject.IsFromWebServer = true;
            dataObject.IsOnDemandSimulation = true;
            dataObject.NumberOfSteps = 2;
            dataObject.OriginalInstanceID = Guid.NewGuid();
            dataObject.ParentInstanceID = "1211";
            dataObject.ParentServiceName = "xxx";
            dataObject.ParentThreadID = 2;
            dataObject.ParentWorkflowInstanceId = "1233";
            dataObject.RawPayload = new StringBuilder("<raw>a</raw>");
            dataObject.RemoteDebugItems = new List<IDebugState>();
            dataObject.RemoteInvoke = false;
            dataObject.RemoteInvokeResultShape = new StringBuilder("<x/>");
            dataObject.RemoteInvokerID = "999";
            dataObject.RemoteServiceType = "NA";
            dataObject.ResourceID = Guid.NewGuid();
            dataObject.ReturnType = EmitionTypes.XML;
            dataObject.ServerID = Guid.NewGuid();
            dataObject.ServiceName = "xxx";
            dataObject.WorkflowInstanceId = wfInstanceID;
            dataObject.WorkflowResumeable = false;
            dataObject.ParentID = Guid.NewGuid();
            dataObject.WorkspaceID = Guid.NewGuid();
            dataObject.ClientID = Guid.NewGuid();
            dataObject.RunWorkflowAsync = true;
            dataObject.IsDebugNested = true;
            dataObject.ForEachNestingLevel = 3;
            dataObject.StopExecution = false;
            var threadsToDispose = new Dictionary<int, List<Guid>>();
            List<Guid> guidList = new List<Guid> { Guid.NewGuid() };
            threadsToDispose.Add(3, guidList);
            dataObject.ThreadsToDispose = threadsToDispose;

            //------------Execute Test---------------------------
            IDSFDataObject clonedObject = dataObject.Clone();

            //------------Assert Results-------------------------

            // check counts, then check values
            var properties = typeof(IDSFDataObject).GetProperties();
            Assert.AreEqual(57, properties.Length);

            // now check each value to ensure it transfered
            Assert.AreEqual(dataObject.BookmarkExecutionCallbackID, clonedObject.BookmarkExecutionCallbackID);
            Assert.AreEqual(dataObject.CurrentBookmarkName, clonedObject.CurrentBookmarkName);
            Assert.AreEqual(dataObject.DataList, clonedObject.DataList);
            Assert.AreEqual(dataObject.DataListID, clonedObject.DataListID);
            Assert.AreEqual(dataObject.DatalistInMergeDepth, clonedObject.DatalistInMergeDepth);
            Assert.AreEqual(dataObject.DatalistInMergeID, clonedObject.DatalistInMergeID);
            Assert.AreEqual(dataObject.DatalistInMergeType, clonedObject.DatalistInMergeType);
            Assert.AreEqual(dataObject.DatalistOutMergeDepth, clonedObject.DatalistOutMergeDepth);
            Assert.AreEqual(dataObject.DatalistOutMergeFrequency, clonedObject.DatalistOutMergeFrequency);
            Assert.AreEqual(dataObject.DatalistOutMergeID, clonedObject.DatalistOutMergeID);
            Assert.AreEqual(dataObject.DatalistOutMergeType, clonedObject.DatalistOutMergeType);
            Assert.AreEqual(dataObject.DebugSessionID, clonedObject.DebugSessionID);
            Assert.AreEqual(dataObject.EnvironmentID, clonedObject.EnvironmentID);
    //        Assert.AreEqual(dataObject.Errors, clonedObject.Errors);
            Assert.AreEqual(dataObject.ExecutingUser, clonedObject.ExecutingUser);
            Assert.AreEqual(dataObject.ExecutionCallbackID, clonedObject.ExecutionCallbackID);
            Assert.AreEqual(dataObject.ExecutionOrigin, clonedObject.ExecutionOrigin);
            Assert.AreEqual(dataObject.ExecutionOriginDescription, clonedObject.ExecutionOriginDescription);
            Assert.AreEqual(dataObject.ForceDeleteAtNextNativeActivityCleanup, clonedObject.ForceDeleteAtNextNativeActivityCleanup);
            Assert.AreEqual(dataObject.IsDataListScoped, clonedObject.IsDataListScoped);
            Assert.AreEqual(dataObject.IsDebug, clonedObject.IsDebug);
            Assert.AreEqual(dataObject.IsFromWebServer, clonedObject.IsFromWebServer);
            Assert.AreEqual(dataObject.IsOnDemandSimulation, clonedObject.IsOnDemandSimulation);
            Assert.AreEqual(dataObject.IsRemoteInvoke, clonedObject.IsRemoteInvoke);
            Assert.AreEqual(dataObject.IsRemoteInvokeOverridden, clonedObject.IsRemoteInvokeOverridden);
            Assert.AreEqual(dataObject.NumberOfSteps, clonedObject.NumberOfSteps);
            Assert.AreEqual(dataObject.OriginalInstanceID, clonedObject.OriginalInstanceID);
            Assert.AreEqual(dataObject.ParentInstanceID, clonedObject.ParentInstanceID);
            Assert.AreEqual(dataObject.ParentServiceName, clonedObject.ParentServiceName);
            Assert.AreEqual(dataObject.ParentThreadID, clonedObject.ParentThreadID);
            Assert.AreEqual(dataObject.ParentWorkflowInstanceId, clonedObject.ParentWorkflowInstanceId);
            Assert.AreEqual(dataObject.RawPayload, clonedObject.RawPayload);
            Assert.AreEqual(dataObject.RemoteDebugItems, clonedObject.RemoteDebugItems);
            Assert.AreEqual(dataObject.RemoteInvoke, clonedObject.RemoteInvoke);
            Assert.AreEqual(dataObject.RemoteNonDebugInvoke, clonedObject.RemoteNonDebugInvoke);
            Assert.AreEqual(dataObject.RemoteInvokeResultShape, clonedObject.RemoteInvokeResultShape);
            Assert.AreEqual(dataObject.RemoteInvokerID, clonedObject.RemoteInvokerID);
            Assert.AreEqual(dataObject.RemoteServiceType, clonedObject.RemoteServiceType);
            Assert.AreEqual(dataObject.ResourceID, clonedObject.ResourceID);
            Assert.AreEqual(dataObject.ReturnType, clonedObject.ReturnType);
            Assert.AreEqual(dataObject.ServerID, clonedObject.ServerID);
            Assert.AreEqual(dataObject.ClientID, clonedObject.ClientID);
            Assert.AreEqual(dataObject.ServiceName, clonedObject.ServiceName);
            Assert.AreEqual(dataObject.WorkflowInstanceId, clonedObject.WorkflowInstanceId);
            Assert.AreEqual(dataObject.WorkflowResumeable, clonedObject.WorkflowResumeable);
            Assert.AreEqual(dataObject.WorkspaceID, clonedObject.WorkspaceID);
            Assert.AreEqual(dataObject.ThreadsToDispose, clonedObject.ThreadsToDispose);
            Assert.AreEqual(dataObject.ParentID, clonedObject.ParentID);
            Assert.AreEqual(dataObject.RunWorkflowAsync, clonedObject.RunWorkflowAsync);
            Assert.AreEqual(dataObject.IsDebugNested, clonedObject.IsDebugNested);
            Assert.AreEqual(dataObject.ForEachNestingLevel, clonedObject.ForEachNestingLevel);
            Assert.AreEqual(dataObject.StopExecution, clonedObject.StopExecution);
        }
示例#7
0
        public void DsfDataObject_NestingLevel_Get_Set_ExpectCorrectGetSet()
        {
            //------------Setup for test--------------------------
            IDSFDataObject dataObject = new DsfDataObject(string.Empty, Guid.NewGuid());
            dataObject.ForEachNestingLevel = 3;
            Assert.AreEqual(dataObject.ForEachNestingLevel, 3);

        }
示例#8
0
        public void DsfDataObjectz_RawPayload_WhenNotNull_ExpectRawPayload()
        {
            //------------Setup for test--------------------------
            IDSFDataObject dataObject = new DsfDataObject(string.Empty, Guid.NewGuid(), "foo");

            //------------Execute Test---------------------------
            var result = dataObject.RawPayload.ToString();

            //------------Assert Results-------------------------
            StringAssert.Contains(result, "foo");
        }
        protected static IResponseWriter CreateForm(WebRequestTO webRequest, string serviceName, string workspaceId, NameValueCollection headers, List<DataListFormat> publicFormats, IPrincipal user = null)
        {
            //lock(ExecutionObject)
            {
                string executePayload = "";
                IDataListCompiler compiler = DataListFactory.CreateDataListCompiler();
                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;
                        }

                        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;
                        }

                    }
                }
                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 && hasExecute) || (resource != null && resource.ResourceType == ResourceType.ReservedService);
                }
                // Build EsbExecutionRequest - Internal Services Require This ;)
                EsbExecuteRequest esbExecuteRequest = new EsbExecuteRequest { ServiceName = serviceName };

                Dev2Logger.Log.Debug("About to execute web request [ " + serviceName + " ] DataObject Payload [ " + dataObject.RawPayload + " ]");
                var executionDlid = GlobalConstants.NullDataListID;
                if(canExecute)
                {
                    ErrorResultTO errors;
                    executionDlid = esbEndpoint.ExecuteRequest(dataObject, esbExecuteRequest, workspaceGuid, out errors);
                    allErrors.MergeErrors(errors);
                }
                else
                {
                    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 = publicFormats.FirstOrDefault(c => c.PublicFormatName == dataObject.ReturnType)
                                ?? publicFormats.FirstOrDefault(c => c.PublicFormatName == EmitionTypes.XML);

                // force it to XML if need be ;)

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


                        // some silly chicken thinks web request where a good idea for debug ;(
                        if(!dataObject.IsDebug || dataObject.RemoteInvoke)
                        {
                            if (dataObject.ReturnType == EmitionTypes.JSON)
                            {
                                executePayload = ExecutionEnvironmentUtils.GetJsonOutputFromEnvironment(dataObject, workspaceGuid,resource.DataList.ToString());
                            }
                            else if (dataObject.ReturnType == EmitionTypes.XML)
                            {
                                executePayload = ExecutionEnvironmentUtils.GetXmlOutputFromEnvironment(dataObject, workspaceGuid,resource.DataList.ToString());
                            }
                            dataObject.Environment.AddError(allErrors.MakeDataListReady());
                        }
                        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 + " ]");

                // Clean up the datalist from the server
                if(!dataObject.WorkflowResumeable && executionDlid != GlobalConstants.NullDataListID)
                {
                    compiler.ForceDeleteDataListByID(executionDlid);
                    if(dataObject.IsDebug && !dataObject.IsRemoteInvoke && !dataObject.RunWorkflowAsync)
                    {
                        DataListRegistar.ClearDataList();
                    }
                    else
                    {
                        foreach(var thread in dataObject.ThreadsToDispose)
                        {
                            DataListRegistar.DisposeScope(thread.Key, executionDlid);
                        }

                        DataListRegistar.DisposeScope(Thread.CurrentThread.ManagedThreadId, executionDlid);
                    }
                }

                // old HTML throw back ;)
                if(dataObject.ReturnType == EmitionTypes.WIZ)
                {
                    int start = (executePayload.IndexOf("<Dev2System.FormView>", StringComparison.Ordinal) + 21);
                    int end = (executePayload.IndexOf("</Dev2System.FormView>", StringComparison.Ordinal));
                    int len = (end - start);
                    if(len > 0)
                    {
                        if(dataObject.ReturnType == EmitionTypes.WIZ)
                        {
                            string tmp = executePayload.Substring(start, (end - start));
                            string result = CleanupHtml(tmp);
                            const string DocType = @"<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Strict//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"">";
                            return new StringResponseWriter(String.Format("{0}\r\n{1}", DocType, result), ContentTypes.Html);
                        }
                    }
                }

                // 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;
                // else handle the format requested ;)
                return new StringResponseWriter(executePayload, formatter.ContentType);
            }
        }
示例#10
0
        public void DsfDataObject_RawPayload_WhenNull_ExpectEmptyString()
        {
            //------------Setup for test--------------------------
            IDSFDataObject dataObject = new DsfDataObject(string.Empty, Guid.NewGuid());

            //------------Execute Test---------------------------
            var result = dataObject.RawPayload;

            //------------Assert Results-------------------------
            Assert.AreEqual(string.Empty, result.ToString(), "RawPayload did not return and empty string");
        }
        public void JsonMappingCompoundTo_EvalResultIndexed_IsCompound()
        {
            //------------Setup for test--------------------------
            var dataObject = new DsfDataObject(xmldata: string.Empty, dataListId: Guid.NewGuid());
            dataObject.Environment.Assign("[[a]]", "10", 0);
            dataObject.Environment.Assign("[[b]]", "20", 0);
            dataObject.Environment.Assign("[[rec(1).a]]", "50", 0);
            dataObject.Environment.Assign("[[rec(1).b]]", "500", 0);
            //------------Execute Test---------------------------

            var jsonMappingCompound = new JsonMappingCompoundTo(
                env: dataObject.Environment,
                compound: new JsonMappingTo
                {
                    SourceName = "[[a]],[[b]]",
                    DestinationName = "myName"
                }
            );
            //------------Assert Results-------------------------
            Assert.IsNotNull(jsonMappingCompound);
            Assert.IsTrue(jsonMappingCompound.IsCompound);
        }
        protected static void BindRequestVariablesToDataObject(WebRequestTO request, ref DsfDataObject dataObject)
        {
            if(dataObject != null && request != null)
            {
                if(!string.IsNullOrEmpty(request.Bookmark))
                {
                    dataObject.CurrentBookmarkName = request.Bookmark;
                }

                if(!string.IsNullOrEmpty(request.InstanceID))
                {
                    Guid tmpId;
                    if(Guid.TryParse(request.InstanceID, out tmpId))
                    {
                        dataObject.WorkflowInstanceId = tmpId;
                    }
                }

                if(!string.IsNullOrEmpty(request.ServiceName) && string.IsNullOrEmpty(dataObject.ServiceName))
                {
                    dataObject.ServiceName = request.ServiceName;
                }
            }
        }
示例#13
0
        public Guid Invoke(DynamicService service, dynamic xmlRequest, Guid dataListId, out ErrorResultTO errors)
        {
            //dynamic result = new UnlimitedObject();
            //dynamic forwardResult = new UnlimitedObject();
            var allErrors = new ErrorResultTO();
            errors = new ErrorResultTO();

            if(service == null)
            {
                allErrors.AddError("Dynamic Service not found exception");
                return GlobalConstants.NullDataListID;
            }

            string dataList = service.DataListSpecification;


            // PBI : 5376 Amendedment for DataList Server
            Guid result = GlobalConstants.NullDataListID;
            string data = xmlRequest.XmlString.Trim();
            byte[] incomingData = Encoding.UTF8.GetBytes(data);
            Guid serviceDataId;


            var performDataListInMerge = false;

            if(dataList != string.Empty)
            {
                serviceDataId = SvrCompiler.ConvertTo(null, DataListFormat.CreateFormat(GlobalConstants._XML),
                                                       incomingData, dataList, out errors);
                errors = new ErrorResultTO(); // re-set to avoid carring

                // PBI : 5376
                // If dataListID == NullID, create a new list and set it as the current ID
                // Else, create a new list, union the old data into the new and continue on ;)
                if(dataListId != GlobalConstants.NullDataListID)
                {
                    serviceDataId = SvrCompiler.Merge(null, serviceDataId, dataListId, enDataListMergeTypes.Union,
                                                       enTranslationDepth.Data, false, out errors);
                }
                else
                {
                    performDataListInMerge = true;
                }
            }
            else
            {
                serviceDataId = SvrCompiler.CloneDataList(dataListId, out errors);
                performDataListInMerge = true;
            }

            if (errors.HasErrors())
            {
                allErrors.MergeErrors(errors);
            }
            IDSFDataObject dataObject = new DsfDataObject(xmlRequest.XmlString, serviceDataId);
            dataObject.DataList = dataList;

            if(performDataListInMerge)
            {
                SvrCompiler.ConditionalMerge(null, DataListMergeFrequency.Always, serviceDataId,
                                              dataObject.DatalistInMergeID,
                                              DataListMergeFrequency.Always, dataObject.DatalistInMergeType,
                                              dataObject.DatalistInMergeDepth);
            }

            // TODO  : Reset the AmbientDataList to this ID?

            // Fetch data for Input binding...
            DataListTranslatedPayloadTO tmpData = null;
            dynamic inputBinding = null;

            // End PBI Amendments

            foreach(ServiceAction serviceAction in service.Actions)
            {
                //TraceWriter.WriteTrace(_managementChannel, string.Format("Validating the inputs of Service '{0}'", service.Name), Resources.TraceMessageType_Message);
                foreach(ServiceActionInput sai in serviceAction.ServiceActionInputs)
                {
                    //Assigning the input the value from the callers request data
                    //TraceWriter.WriteTrace(_managementChannel, string.Format("Discovered input '{0}'", sai.Name), Resources.TraceMessageType_Message);
                    if(sai.CascadeSource)
                    {
                        TraceWriter.WriteTrace(_managementChannel, string.Format("Input '{0}' is cascaded", sai.Name),
                                               Resources.TraceMessageType_Message);
                        //This is a cascaded input so retrieve the value from the
                        //previous actions response
                        //sai.Value = forwardResult.GetValue(sai.Name);
                    }
                    else
                    {
                        if(tmpData == null)
                        {
                            tmpData = SvrCompiler.ConvertFrom(null, serviceDataId, enTranslationDepth.Data,
                                                               DataListFormat.CreateFormat(GlobalConstants._XML),
                                                               out errors);

                            if(!DataListUtil.isNullADL(tmpData.FetchAsString()))
                            {
                                inputBinding = new UnlimitedObject(tmpData.FetchAsString());
                            }
                            else
                            {
                                // Empty data, try the incoming stream?!
                                inputBinding = new UnlimitedObject(xmlRequest.XmlString);
                            }
                        }

                        // 16.10.2012 : Travis.Frisinger - EmptyToNull amendments
                        string tmpVal = inputBinding.GetValue(sai.Name);
                        if(sai.EmptyToNull && tmpVal == string.Empty)
                        {
                            tmpVal = AppServerStrings.NullConstant;
                        }

                        sai.Value = tmpVal;
                    }

                    //TraceWriter.WriteTrace(string.Format("Assigning value {0} to input '{1}'", sai.Value.ToString(), sai.Name));

                    //Validating inputs if there is validation set up in the service definition
                    if(sai.IsRequired && string.IsNullOrEmpty(sai.DefaultValue))
                    {
                        if(!sai.Validate())
                        {
                            allErrors.AddError(string.Format("Validation Failure. Argument '{0}' failed validation.",
                                                             sai.Name));

                            //TraceWriter.WriteTrace(_managementChannel, string.Format("Argument '{0}' failed validation", sai.Name), Resources.TraceMessageType_Message);
                            //xmlRequest.Error = string.Format("Validation Failure. Argument '{0}' failed validation.", sai.Name);
                            //return xmlRequest;
                        }
                    }
                    //This input does not have any value in the callers request
                    //so we are setting the input value to the full request
                    if(string.IsNullOrEmpty(sai.Value.ToString()))
                    {
                        sai.Value = !string.IsNullOrEmpty(sai.DefaultValue) ? sai.DefaultValue : string.Empty;
                    }
                }

                //if (service.Mode == enDynamicServiceMode.ValidationOnly)
                //{
                //    xmlRequest.ValidationOnly.Result = true;

                //    return xmlRequest;
                //}

                if(serviceAction.ActionType == enActionType.Switch)
                {
                    if(!string.IsNullOrEmpty(serviceAction.Cases.DataElementName))
                    {
                        ////Assigning the input the value from the callers request data
                        //if (serviceAction.Cases.CascadeSource)
                        //{
                        //This is a cascaded input so retrieve the value from the
                        //previous actions response
                        //sai.Value = actionResponse.GetValue(sai.Name);
                        //serviceAction.Cases.DataElementValue = forwardResult.GetValue(serviceAction.Cases.DataElementName);
                        //}
                        //else
                        //{
                        serviceAction.Cases.DataElementValue = xmlRequest.GetValue(serviceAction.Cases.DataElementName);
                        //}
                    }
                }


                //
                //Juries - This is a dirty hack, naughty naughty.
                //Hijacked current functionality to enable erros to be added to an item after its already been added to the tree
                //
                if(allErrors.HasErrors())
                {
                    DebugDispatcher.Instance.Write(new DebugState()
                    {
                        ParentID = dataObject.ParentInstanceID,
                        WorkspaceID = dataObject.WorkspaceID,
                        StartTime = DateTime.Now,
                        EndTime = DateTime.Now,
                        IsSimulation = false,
                        ServerID = dataObject.ServerID,
                        Server = string.Empty,
                        Version = string.Empty,
                        Name = GetType().Name,
                        HasError = true,
                        ErrorMessage = allErrors.MakeDisplayReady(),
                        ActivityType = ActivityType.Workflow,
                        StateType = StateType.Append
                    });
                }
                
                // TODO : properly build up DataList prior to this....
                result = Invoke(serviceAction, dataObject, dataList);

                // Remember to clean up ;)
                if(dataListId != GlobalConstants.NullDataListID)
                {
                    // Merge the execution DL into the mainDL ;)

                    Guid mergeId = SvrCompiler.Merge(null, dataListId, serviceDataId, enDataListMergeTypes.Union,
                                                      enTranslationDepth.Data, false, out errors);
                    SvrCompiler.DeleteDataListByID(serviceDataId, true);

                    // Now reset the DataListID on DataObject ;)
                    if(result != serviceDataId)
                    {
                        throw new Exception("FATAL ERROR : DataList Execution Mis-Match!");
                    }

                    dataObject.DataListID = mergeId;
                    result = mergeId;
                }
                else
                {
                    SvrCompiler.ConditionalMerge(null,
                                                  DataListMergeFrequency.Always | DataListMergeFrequency.OnCompletion,
                                                  dataObject.DatalistOutMergeID, dataObject.DataListID,
                                                  dataObject.DatalistOutMergeFrequency, dataObject.DatalistOutMergeType,
                                                  dataObject.DatalistOutMergeDepth);
                } // else we want to keep the DL around until we end execution

                #region Terminate the service if this Service Action is marked to terminate on fault

                //If this action should immediately terminate the execution of this service 
                //then stop here and return the results thus far
                if(serviceAction.TerminateServiceOnFault && errors.HasErrors())
                {
                    result = GlobalConstants.NullDataListID;
                }

                #endregion
            }

            return result;
        }
        public void JsonMappingEvaluated_Constructor_SetsProperties()
        {
            //------------Setup for test--------------------------
            var dataObject = new DsfDataObject(xmldata: string.Empty, dataListId: Guid.NewGuid());
            dataObject.Environment.Assign("[[a]]", "10",0);
            dataObject.Environment.Assign("[[as]]", "hellow world", 0);
            dataObject.Environment.Assign("[[af]]", "9.9", 0);
            dataObject.Environment.Assign("[[b]]", "20", 0);
            dataObject.Environment.Assign("[[rec(1).a]]", "50", 0);
            dataObject.Environment.Assign("[[rec(1).b]]", "500", 0);
            dataObject.Environment.Assign("[[rec(2).a]]", "60", 0);
            dataObject.Environment.Assign("[[rec(2).b]]", "600", 0);
            //------------Execute Test---------------------------

            // scalar evaluating to atom
            string sn = "[[a]]";
            const string sns = "[[as]]";
            const string snf = "[[af]]";
            string dn = "a";
            const string dns = "as";
            const string dnf = "af";
            var scalarsSn = new[] { "[[x().z]]", "[[x]]", sn, sns, snf };
            var scalarsDn = new[] { "z", "x", dn, dns, dnf };
            var scalarsV = new[] { new object[] { null }, (object)null, 10, "hellow world", 9.9 };
            for (int i = 0; i < scalarsSn.Length; i++)
            {
                var jsonMappingEvaluatedLocal = new JsonMappingEvaluated(
                    dataObject.Environment,
                    scalarsSn[i]);
                //------------Assert Results-------------------------
                jsonMappingEvaluatedLocal.Should().NotBeNull();
                jsonMappingEvaluatedLocal.Simple.Should().NotBeNull();
                jsonMappingEvaluatedLocal.Simple.SourceName.Should().Be(scalarsSn[i]);
                jsonMappingEvaluatedLocal.Simple.DestinationName.Should().Be(scalarsDn[i]);
                if (i != 0)
                {
                    //((object[])((WarewolfDataEvaluationCommon.WarewolfEvalResult.WarewolfAtomListresult)jsonMappingEvaluatedLocal.EvalResult).Item.GetValue(0))[0].Should().Be(((object[])((WarewolfDataEvaluationCommon.WarewolfEvalResult.WarewolfAtomListresult)dataObject.Environment.EvalForJson(scalarsSn[i])).Item.GetValue(0))[0]);
                    jsonMappingEvaluatedLocal.EvalResult.Should().Be(dataObject.Environment.EvalForJson(scalarsSn[i]));
                    jsonMappingEvaluatedLocal.EvalResultAsObject.Should().Be(scalarsV[i]);
                }

                jsonMappingEvaluatedLocal.Count.Should().Be(1);
            }


            // recordset
            sn = "[[rec().a]]"; dn = "a";
            var jsonMappingEvaluated = new JsonMappingEvaluated(dataObject.Environment, sn);
            //------------Assert Results-------------------------
            jsonMappingEvaluated.Should().NotBeNull();
            jsonMappingEvaluated.Simple.Should().NotBeNull();
            jsonMappingEvaluated.Simple.SourceName.Should().Be(sn);
            jsonMappingEvaluated.Simple.DestinationName.Should().Be(dn);
            ((WarewolfDataEvaluationCommon.WarewolfEvalResult.WarewolfAtomListresult)jsonMappingEvaluated.EvalResult).Item.GetValue(0).Should().Be(
                ((WarewolfDataEvaluationCommon.WarewolfEvalResult.WarewolfAtomListresult)dataObject.Environment.Eval(sn,0)).Item.GetValue(0));
            jsonMappingEvaluated.Count.Should().Be(1);

            // recordset name
            sn = "[[rec()]]"; dn = "rec";
            jsonMappingEvaluated = new JsonMappingEvaluated(dataObject.Environment, sn);
            //------------Assert Results-------------------------
            jsonMappingEvaluated.Should().NotBeNull();
            jsonMappingEvaluated.Simple.Should().NotBeNull();
            jsonMappingEvaluated.Simple.SourceName.Should().Be(sn);
            jsonMappingEvaluated.Simple.DestinationName.Should().Be(dn);
            //jsonMappingEvaluated.EvalResult.Should().Be(dataObject.Environment.Eval(sn));
            //((WarewolfDataEvaluationCommon.WarewolfEvalResult.WarewolfRecordSetResult)jsonMappingEvaluated.EvalResult).Item.Data["a"][0].Should().Be(
            //  ((WarewolfDataEvaluationCommon.WarewolfEvalResult.WarewolfRecordSetResult)dataObject.Environment.Eval(sn)).Item.Data["a"][0]);
            jsonMappingEvaluated.Count.Should().Be(1);
        }
        private void CheckComplexEvaluatedResultIndexed(string expression, string name, int index, string expected, DsfDataObject dataObject)
        {
            var jsonMappingCompound = new JsonMappingCompoundTo(
                env: dataObject.Environment,
            compound: new JsonMappingTo
                {
                    SourceName = expression,
                    DestinationName = name
                }
            );
            var a = jsonMappingCompound.ComplexEvaluatedResultIndexed(index);
            if (a is JProperty)
            {
                var jp = new JObject { a };
                Assert.AreEqual(expected, jp
                .ToString(Formatting.None));
            }
            else
            {
                var jp = new JProperty(name, jsonMappingCompound.ComplexEvaluatedResultIndexed(index));
                var j = new JObject(jp);
                var s = j.ToString(Formatting.None);
                Assert.AreEqual(expected,
                s);
            }

        }
示例#16
0
        public void DataObject_Ctor_WhenXmlStringDoesNotHaveBookmarkExecutionCallbackIDSet_ExpectParseAndSet()
        {
            //------------Setup for test--------------------------
            var debugID = Guid.NewGuid();
            var envID = Guid.NewGuid();
            var exeID = Guid.NewGuid();
            var parentID = Guid.NewGuid();
            var instID = Guid.NewGuid();

            var xmlStr = "<Payload>" +
                         "<IsDebug>true</IsDebug>" +
                         "<DebugSessionID>" + debugID + "</DebugSessionID>" +
                         "<EnvironmentID>" + envID + "</EnvironmentID>" +
                         "<IsOnDemandSimulation>true</IsOnDemandSimulation>" +
                         "<ParentServiceName>TestParentService</ParentServiceName>" +
                         "<ExecutionCallbackID>" + exeID + "</ExecutionCallbackID>" +
                         "<ParentInstanceID>" + parentID + "</ParentInstanceID>" +
                         "<NumberOfSteps>5</NumberOfSteps>" +
                         "<CurrentBookmarkName>MyBookmark</CurrentBookmarkName>" +
                         "<WorkflowInstanceId>" + instID + "</WorkflowInstanceId>" +
                         "<IsDataListScoped>true</IsDataListScoped>" +
                         "<Service>MyTestService</Service>" +
                         "</Payload>";


            //------------Execute Test---------------------------
            var dataObjct = new DsfDataObject(xmlStr, Guid.NewGuid(), "<x>1</x>");

            //------------Assert Results-------------------------
            Assert.IsTrue(dataObjct.IsDebug);
            StringAssert.Contains(dataObjct.DebugSessionID.ToString(), debugID.ToString());
            StringAssert.Contains(dataObjct.EnvironmentID.ToString(), envID.ToString());
            Assert.IsTrue(dataObjct.IsOnDemandSimulation);
            StringAssert.Contains(dataObjct.ParentServiceName, "TestParentService");
            StringAssert.Contains(dataObjct.ExecutionCallbackID.ToString(), exeID.ToString());
            StringAssert.Contains(dataObjct.BookmarkExecutionCallbackID.ToString(), exeID.ToString());
            StringAssert.Contains(dataObjct.ParentInstanceID, parentID.ToString());
            Assert.AreEqual(5, dataObjct.NumberOfSteps, "Wrong number of steps");
            StringAssert.Contains(dataObjct.CurrentBookmarkName, "MyBookmark");
            StringAssert.Contains(dataObjct.WorkflowInstanceId.ToString(), instID.ToString());
            Assert.IsTrue(dataObjct.IsDataListScoped);
            StringAssert.Contains(dataObjct.ServiceName, "MyTestService");
            StringAssert.Contains(dataObjct.RawPayload.ToString(), xmlStr);

            // Default Data Merge Checks
            StringAssert.Contains(dataObjct.DatalistOutMergeID.ToString(), Guid.Empty.ToString());
            StringAssert.Contains(dataObjct.DatalistOutMergeType.ToString(), enDataListMergeTypes.Intersection.ToString());
            StringAssert.Contains(dataObjct.DatalistOutMergeDepth.ToString(), enTranslationDepth.Data_With_Blank_OverWrite.ToString());
            StringAssert.Contains(dataObjct.DatalistOutMergeFrequency.ToString(), DataListMergeFrequency.OnCompletion.ToString());

            StringAssert.Contains(dataObjct.DatalistInMergeID.ToString(), Guid.Empty.ToString());
            StringAssert.Contains(dataObjct.DatalistInMergeType.ToString(), enDataListMergeTypes.Intersection.ToString());
            StringAssert.Contains(dataObjct.DatalistInMergeDepth.ToString(), enTranslationDepth.Data_With_Blank_OverWrite.ToString());

        }
 public void JsonMappingCompoundTo_ComplexEvaluatedResultIndexedRecsetColumnMixed()
 {
     //------------Setup for test--------------------------
     var dataObject = new DsfDataObject(xmldata: string.Empty, dataListId: Guid.NewGuid());
     dataObject.Environment.Assign("[[a]]", "10", 0);
     dataObject.Environment.Assign("[[b]]", "20", 0);
     dataObject.Environment.Assign("[[rec(1).a]]", "50", 0);
     dataObject.Environment.Assign("[[rec(1).b]]", "500", 0);
     dataObject.Environment.Assign("[[rec(2).a]]", "60", 0);
     dataObject.Environment.Assign("[[rec(2).b]]", "600", 0);
     CheckComplexEvaluatedResultIndexed("[[rec(*).a]],[[rec(*).b]]", "myName", 0, @"{""myName"":[{""a"":50,""b"":500},{""a"":60,""b"":600}]}", dataObject);
 }
        protected static void BindRequestVariablesToDataObject(WebRequestTO request, ref DsfDataObject dataObject)
        {
            if(dataObject != null && request != null)
            {
                if(!string.IsNullOrEmpty(request.Bookmark))
                {
                    dataObject.CurrentBookmarkName = request.Bookmark;
                }

                if(!string.IsNullOrEmpty(request.InstanceID))
                {
                    Guid tmpId;
                    if(Guid.TryParse(request.InstanceID, out tmpId))
                    {
                        dataObject.WorkflowInstanceId = tmpId;
                    }
                }

                if(!string.IsNullOrEmpty(request.ServiceName) && string.IsNullOrEmpty(dataObject.ServiceName))
                {
                    dataObject.ServiceName = request.ServiceName;
                }
                foreach(string key in request.Variables)
                {
                    dataObject.Environment.Assign(DataListUtil.AddBracketsToValueIfNotExist(key),request.Variables[key],0);   
            }
                
        }
        }
        public void JsonMappingCompoundTo_EvalResultIndexed_NotIsCompound()
        {
            //------------Setup for test--------------------------
            var dataObject = new DsfDataObject(xmldata: string.Empty, dataListId: Guid.NewGuid());
            dataObject.Environment.Assign("[[a]]", "10", 0);
            dataObject.Environment.Assign("[[b]]", "20", 0);
            dataObject.Environment.Assign("[[rec(1).a]]", "50", 0);
            dataObject.Environment.Assign("[[rec(1).b]]", "500", 0);
            dataObject.Environment.Assign("[[rec(2).a]]", "60", 0);
            dataObject.Environment.Assign("[[rec(2).b]]", "600", 0);
            //------------Execute Test---------------------------

            // for scalars
            var jsonMappingCompound = new JsonMappingCompoundTo(
                env: dataObject.Environment,
                compound: new JsonMappingTo
                {
                    SourceName = "[[a]]",
                    DestinationName = "myName"
                }
            );
            //------------Assert Results-------------------------
            Assert.IsNotNull(jsonMappingCompound);
            Assert.IsFalse(jsonMappingCompound.IsCompound);
            Assert.AreEqual(jsonMappingCompound.EvaluatedResultIndexed(0), 10);
            Assert.AreEqual(jsonMappingCompound.EvaluatedResultIndexed(1), null);

            // for lists
            jsonMappingCompound = new JsonMappingCompoundTo(
                env: dataObject.Environment,
                compound: new JsonMappingTo
                {
                    SourceName = "[[rec(*).a]]",
                    DestinationName = "myName"
                }
            );
            Assert.IsFalse(jsonMappingCompound.IsCompound);
            Assert.AreEqual(new JObject(new JProperty("a", jsonMappingCompound.EvaluatedResultIndexed(0))).ToString(Formatting.None), "{\"a\":[50,60]}");
            jsonMappingCompound = new JsonMappingCompoundTo(
                env: dataObject.Environment,
            compound: new JsonMappingTo
                {
                    SourceName = "[[rec(*).b]]",
                    DestinationName = "myName"
                }
            );
            Assert.AreEqual(new JObject(new JProperty("b", jsonMappingCompound.EvaluatedResultIndexed(1))).ToString(Formatting.None), "{\"b\":[500,600]}");
        }
        public StringBuilder ProcessRequest(EsbExecuteRequest request, Guid workspaceID, Guid dataListID, string connectionId)
        {
            var channel = new EsbServicesEndpoint();
            var xmlData = string.Empty;
            if(request.Args != null && request.Args.ContainsKey("DebugPayload"))
            {
                xmlData = request.Args["DebugPayload"].ToString();
                xmlData = xmlData.Replace("<DataList>", "<XmlData>").Replace("</DataList>", "</XmlData>");
            }

            // we need to adjust for the silly xml structure this system was init built on ;(
            if(string.IsNullOrEmpty(xmlData))
            {
                xmlData = "<DataList></DataList>";
            }

            IDSFDataObject dataObject = new DsfDataObject(xmlData, dataListID);
            dataObject.EsbChannel = channel;
            dataObject.ServiceName = request.ServiceName;
            var resource = ResourceCatalog.Instance.GetResource(workspaceID, request.ServiceName);
            if(resource != null)
            {
                dataObject.ResourceID = resource.ResourceID;
            }
            dataObject.ClientID = Guid.Parse(connectionId);
            dataObject.ExecutingUser = ExecutingUser;
            // we need to assign new ThreadID to request coming from here, because it is a fixed connection and will not change ID on its own ;)
            if(!dataObject.Errors.HasErrors())
            {
                var dlID = Guid.Empty;
                ErrorResultTO errors;

                if(ExecutingUser == null)
                {
                    throw new Exception("Null Executing User");
                }

                try
                {
                    // Execute in its own thread to give proper context ;)
                    var t = new Thread(() =>
                    {
                        Thread.CurrentPrincipal = ExecutingUser;
                        dlID = channel.ExecuteRequest(dataObject, request, workspaceID, out errors);
                    });

                    t.Start();

                    t.Join();
                }
                catch(Exception e)
                {
                    Dev2Logger.Log.Error(e.Message,e);
                }


                var compiler = DataListFactory.CreateDataListCompiler();

                if(request.ExecuteResult.Length > 0)
                {
                    return request.ExecuteResult;
                }

                // return the datalist ;)
                if(dataObject.IsDebugMode())
                {
                    compiler.ForceDeleteDataListByID(dlID);
                    return new StringBuilder("Completed Debug");
                }

                var result = compiler.ConvertFrom(dlID, DataListFormat.CreateFormat(GlobalConstants._XML_Without_SystemTags), enTranslationDepth.Data, out errors);
                compiler.ForceDeleteDataListByID(dlID);
                return result;
            }

            ExecuteMessage msg = new ExecuteMessage { HasError = true };
            msg.SetMessage(dataObject.Errors.MakeDisplayReady());

            Dev2JsonSerializer serializer = new Dev2JsonSerializer();
            return serializer.SerializeToBuilder(msg);
        }
        public void CheckOutputFormatOfDataListForViewInBrowserForAllInputRegions()
        {
            IDataListCompiler comp = DataListFactory.CreateDataListCompiler();
            ErrorResultTO errors;
            Guid dlId = comp.ConvertTo(DataListFormat.CreateFormat(GlobalConstants._XML), string.Empty, ServiceShape.ToStringBuilder(), out errors);

            IDSFDataObject dataObj = new DsfDataObject(string.Empty, dlId) { WorkspaceID = _workspaceId, DataListID = dlId, ServiceName = ServiceName };
            EsbServicesEndpoint endPoint = new EsbServicesEndpoint();
            string result = endPoint.FetchExecutionPayload(dataObj, DataListFormat.CreateFormat(GlobalConstants._XML_Without_SystemTags), out errors);

            DeleteDataList(dlId);

            Assert.IsTrue(result.IndexOf("<inputScalar", StringComparison.Ordinal) < 0, "Output format contains additional tag, <inputScalar>");
            Assert.IsTrue(result.IndexOf("<noneScalar", StringComparison.Ordinal) < 0, "Output format contains additional tag, <noneScalar>");
            Assert.IsTrue(result.IndexOf("<f1", StringComparison.Ordinal) < 0, "Output format contains additional tag, <recset><f1/></recset>");
            Assert.IsTrue(result.IndexOf("<f4", StringComparison.Ordinal) < 0, "Output format contains additional tag, <recset><f4/></recset>");
            Assert.IsTrue(result.IndexOf("<newrecset", StringComparison.Ordinal) < 0, "Output format contains additional tag, <newrecset></newrecset>");
            Assert.IsTrue(result.IndexOf("<field1", StringComparison.Ordinal) < 0, "Output format contains additional tag, <newrecset><f1/></newrecset>");
            Assert.IsTrue(result.IndexOf("<field2", StringComparison.Ordinal) < 0, "Output format contains additional tag, <newrecset><f1/></newrecset>");

        }
示例#22
0
 public void DataObject_IsDebugMode_RemoteInvokeIsTrueAndRunWorkflowAsyncIsFalse_IsDebugModeIsTrue()
 {
     //------------Setup for test--------------------------
     IDSFDataObject dataObject = new DsfDataObject(string.Empty, Guid.NewGuid(), "<x>1</x>");
     dataObject.RunWorkflowAsync = false;
     dataObject.RemoteInvoke = true;
     //------------Execute Test---------------------------
     var isDebug = dataObject.IsDebugMode();
     //------------Assert Results-------------------------
     Assert.IsTrue(isDebug);
 }
        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 = null;
                    // set correct principle ;)
                    Thread.CurrentPrincipal = user;
                    var userPrinciple = user;                   
                    Common.Utilities.PerformActionInsideImpersonatedContext(userPrinciple, () => { 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);
            }
        }
示例#24
0
        public void DataObject_Ctor_WhenXmlStringContainsAllIncludingDataMergePropertiesSet_ExpectParseAndSet()
        {
            //------------Setup for test--------------------------
            var debugID = Guid.NewGuid();
            var envID = Guid.NewGuid();
            var exeID = Guid.NewGuid();
            var bookmarkID = Guid.NewGuid();
            var parentID = Guid.NewGuid();
            var instID = Guid.NewGuid();
            var mergeIDOut = Guid.NewGuid();
            var mergeIDIn = Guid.NewGuid();

            var xmlStr = "<Payload>" +
                         "<IsDebug>true</IsDebug>" +
                         "<DebugSessionID>" + debugID + "</DebugSessionID>" +
                         "<EnvironmentID>" + envID + "</EnvironmentID>" +
                         "<IsOnDemandSimulation>true</IsOnDemandSimulation>" +
                         "<ParentServiceName>TestParentService</ParentServiceName>" +
                         "<ExecutionCallbackID>" + exeID + "</ExecutionCallbackID>" +
                         "<BookmarkExecutionCallbackID>" + bookmarkID + "</BookmarkExecutionCallbackID>" +
                         "<ParentInstanceID>" + parentID + "</ParentInstanceID>" +
                         "<NumberOfSteps>5</NumberOfSteps>" +
                         "<CurrentBookmarkName>MyBookmark</CurrentBookmarkName>" +
                         "<WorkflowInstanceId>" + instID + "</WorkflowInstanceId>" +
                         "<IsDataListScoped>true</IsDataListScoped>" +
                         "<Service>MyTestService</Service>" +
                         "<DatalistOutMergeID>" + mergeIDOut + "</DatalistOutMergeID>" +
                         "<DatalistOutMergeType>Union</DatalistOutMergeType>" +
                         "<DatalistOutMergeDepth>Data</DatalistOutMergeDepth>" +
                         "<DatalistOutMergeFrequency>Never</DatalistOutMergeFrequency>" +
                         "<DatalistInMergeID>" + mergeIDIn + "</DatalistInMergeID>" +
                         "<DatalistInMergeType>Union</DatalistInMergeType>" +
                         "<DatalistInMergeDepth>Data</DatalistInMergeDepth>" +
                         "</Payload>";


            //------------Execute Test---------------------------
            var dataObjct = new DsfDataObject(xmlStr, Guid.NewGuid(), "<x>1</x>");

            //------------Assert Results-------------------------
            Assert.IsTrue(dataObjct.IsDebug);
            StringAssert.Contains(dataObjct.DebugSessionID.ToString(), debugID.ToString());
            StringAssert.Contains(dataObjct.EnvironmentID.ToString(), envID.ToString());
            Assert.IsTrue(dataObjct.IsOnDemandSimulation);
            StringAssert.Contains(dataObjct.ParentServiceName, "TestParentService");
            StringAssert.Contains(dataObjct.ExecutionCallbackID.ToString(), exeID.ToString());
            StringAssert.Contains(dataObjct.BookmarkExecutionCallbackID.ToString(), bookmarkID.ToString());
            StringAssert.Contains(dataObjct.ParentInstanceID, parentID.ToString());
            Assert.AreEqual(5, dataObjct.NumberOfSteps, "Wrong number of steps");
            StringAssert.Contains(dataObjct.CurrentBookmarkName, "MyBookmark");
            StringAssert.Contains(dataObjct.WorkflowInstanceId.ToString(), instID.ToString());
            Assert.IsTrue(dataObjct.IsDataListScoped);
            StringAssert.Contains(dataObjct.ServiceName, "MyTestService");
            StringAssert.Contains(dataObjct.RawPayload.ToString(), xmlStr);

            // Data Merge Checks
            StringAssert.Contains(dataObjct.DatalistOutMergeID.ToString(), mergeIDOut.ToString());
            StringAssert.Contains(dataObjct.DatalistOutMergeType.ToString(), enDataListMergeTypes.Union.ToString());
            StringAssert.Contains(dataObjct.DatalistOutMergeDepth.ToString(), enTranslationDepth.Data.ToString());
            StringAssert.Contains(dataObjct.DatalistOutMergeFrequency.ToString(), DataListMergeFrequency.Never.ToString());

            StringAssert.Contains(dataObjct.DatalistInMergeID.ToString(), mergeIDIn.ToString());
            StringAssert.Contains(dataObjct.DatalistInMergeType.ToString(), enDataListMergeTypes.Union.ToString());
            StringAssert.Contains(dataObjct.DatalistInMergeDepth.ToString(), enTranslationDepth.Data.ToString());

        }
        /// <summary>
        ///     Clones this instance.
        /// </summary>
        /// <returns></returns>
        public IDSFDataObject Clone()
        {
            IDSFDataObject result = new DsfDataObject();

            result.BookmarkExecutionCallbackID = BookmarkExecutionCallbackID;
            result.CurrentBookmarkName = CurrentBookmarkName;
            result.DebugSessionID = DebugSessionID;
            result.DataList = DataList;
            result.DataListID = DataListID;
            result.DatalistOutMergeDepth = DatalistOutMergeDepth;
            result.DatalistOutMergeFrequency = DatalistOutMergeFrequency;
            result.DatalistOutMergeID = DatalistOutMergeID;
            result.DatalistOutMergeType = DatalistOutMergeType;
            result.DatalistInMergeDepth = DatalistInMergeDepth;
            result.DatalistInMergeID = DatalistInMergeID;
            result.DatalistInMergeType = DatalistInMergeType;
            result.EnvironmentID = EnvironmentID;
            result.Errors = Errors;
            result.ExecutionCallbackID = ExecutionCallbackID;
            result.ExecutionOrigin = ExecutionOrigin;
            result.ExecutionOriginDescription = ExecutionOriginDescription;
            result.ForceDeleteAtNextNativeActivityCleanup = ForceDeleteAtNextNativeActivityCleanup;
            result.IsDataListScoped = IsDataListScoped;
            result.IsDebug = IsDebug;
            result.IsOnDemandSimulation = IsOnDemandSimulation;
            result.IsFromWebServer = IsFromWebServer;
            result.NumberOfSteps = NumberOfSteps;
            result.OriginalInstanceID = OriginalInstanceID;
            result.ParentInstanceID = ParentInstanceID;
            result.ParentServiceName = ParentServiceName;
            result.ParentThreadID = ParentThreadID;
            result.ParentWorkflowInstanceId = ParentWorkflowInstanceId;
            result.RawPayload = RawPayload;
            result.RemoteDebugItems = RemoteDebugItems;
            result.RemoteInvoke = RemoteInvoke;
            result.IsRemoteInvokeOverridden = result.IsRemoteInvokeOverridden;
            result.RemoteInvokeResultShape = RemoteInvokeResultShape;
            result.RemoteInvokerID = RemoteInvokerID;
            result.RemoteServiceType = RemoteServiceType;
            result.ResourceID = ResourceID;
            result.ReturnType = ReturnType;
            result.ServerID = ServerID;
            result.ClientID = ClientID;
            result.ServiceName = ServiceName;
            result.WorkflowInstanceId = WorkflowInstanceId;
            result.WorkflowResumeable = WorkflowResumeable;
            result.WorkspaceID = WorkspaceID;
            result.ThreadsToDispose = ThreadsToDispose;
            result.ParentID = ParentID;
            result.RunWorkflowAsync = RunWorkflowAsync;
            result.IsDebugNested = IsDebugNested;
            result.ForEachNestingLevel = ForEachNestingLevel;
            result.Environment = Environment;
            result.EsbChannel = EsbChannel;
            result.ExecutionToken = ExecutionToken;
            return result;
        }
        public StringBuilder ProcessRequest(EsbExecuteRequest request, Guid workspaceID, Guid dataListID, string connectionId)
        {
            var channel = new EsbServicesEndpoint();
            var xmlData = string.Empty;
            if(request.Args != null && request.Args.ContainsKey("DebugPayload"))
            {
                xmlData = request.Args["DebugPayload"].ToString();
                xmlData = xmlData.Replace("<DataList>", "<XmlData>").Replace("</DataList>", "</XmlData>");
            }

            // we need to adjust for the silly xml structure this system was init built on ;(
            if(string.IsNullOrEmpty(xmlData))
            {
                xmlData = "<DataList></DataList>";
            }

            IDSFDataObject dataObject = new DsfDataObject(xmlData, dataListID);
            dataObject.StartTime = DateTime.Now;
            dataObject.EsbChannel = channel;
            dataObject.ServiceName = request.ServiceName;
           
            var resource = ResourceCatalog.Instance.GetResource(workspaceID, request.ServiceName);
            if(resource != null)
            {
                dataObject.ResourceID = resource.ResourceID;
            }
            dataObject.ClientID = Guid.Parse(connectionId);
            dataObject.ExecutingUser = ExecutingUser;
            // we need to assign new ThreadID to request coming from here, because it is a fixed connection and will not change ID on its own ;)
            if(!dataObject.Environment.HasErrors())
            {
                ErrorResultTO errors;

                if(ExecutingUser == null)
                {
                    throw new Exception("Null Executing User");
                }

                try
                {
                    // Execute in its own thread to give proper context ;)
                    var t = new Thread(() =>
                    {
                        Thread.CurrentPrincipal = ExecutingUser;
                        channel.ExecuteRequest(dataObject, request, workspaceID, out errors);
                    });

                    t.Start();

                    t.Join();
                }
                catch(Exception e)
                {
                    Dev2Logger.Log.Error(e.Message,e);
                }



                if(request.ExecuteResult.Length > 0)
                {
                    return request.ExecuteResult;
                }

                return new StringBuilder();
            }

            ExecuteMessage msg = new ExecuteMessage { HasError = true };
            msg.SetMessage(String.Join(Environment.NewLine, dataObject.Environment.Errors));

            Dev2JsonSerializer serializer = new Dev2JsonSerializer();
            return serializer.SerializeToBuilder(msg);
        }
示例#27
0
        /// <summary>
        ///     Clones this instance.
        /// </summary>
        /// <returns></returns>
        public IDSFDataObject Clone()
        {
            IDSFDataObject result = new DsfDataObject();

            result.BookmarkExecutionCallbackID = BookmarkExecutionCallbackID;
            result.CurrentBookmarkName         = CurrentBookmarkName;
            result.DebugSessionID                         = DebugSessionID;
            result.DataList                               = DataList;
            result.DataListID                             = DataListID;
            result.DatalistOutMergeDepth                  = DatalistOutMergeDepth;
            result.DatalistOutMergeFrequency              = DatalistOutMergeFrequency;
            result.DatalistOutMergeID                     = DatalistOutMergeID;
            result.DatalistOutMergeType                   = DatalistOutMergeType;
            result.DatalistInMergeDepth                   = DatalistInMergeDepth;
            result.DatalistInMergeID                      = DatalistInMergeID;
            result.DatalistInMergeType                    = DatalistInMergeType;
            result.EnvironmentID                          = EnvironmentID;
            result.DebugEnvironmentId                     = DebugEnvironmentId;
            result.ExecutionCallbackID                    = ExecutionCallbackID;
            result.ExecutionOrigin                        = ExecutionOrigin;
            result.ExecutionOriginDescription             = ExecutionOriginDescription;
            result.ForceDeleteAtNextNativeActivityCleanup = ForceDeleteAtNextNativeActivityCleanup;
            result.IsDataListScoped                       = IsDataListScoped;
            result.IsDebug = IsDebug;
            result.IsOnDemandSimulation     = IsOnDemandSimulation;
            result.IsFromWebServer          = IsFromWebServer;
            result.NumberOfSteps            = NumberOfSteps;
            result.OriginalInstanceID       = OriginalInstanceID;
            result.ParentInstanceID         = ParentInstanceID;
            result.ParentServiceName        = ParentServiceName;
            result.ParentThreadID           = ParentThreadID;
            result.ParentWorkflowInstanceId = ParentWorkflowInstanceId;
            result.RawPayload               = RawPayload;
            result.RemoteDebugItems         = RemoteDebugItems;
            result.RemoteInvoke             = RemoteInvoke;
            result.RemoteNonDebugInvoke     = RemoteNonDebugInvoke;
            result.IsRemoteInvokeOverridden = IsRemoteInvokeOverridden;
            result.RemoteInvokeResultShape  = RemoteInvokeResultShape;
            result.RemoteInvokerID          = RemoteInvokerID;
            result.RemoteServiceType        = RemoteServiceType;
            result.ResourceID               = ResourceID;
            result.ReturnType               = ReturnType;
            result.ServerID               = ServerID;
            result.ClientID               = ClientID;
            result.ServiceName            = ServiceName;
            result.WorkflowInstanceId     = WorkflowInstanceId;
            result.WorkflowResumeable     = WorkflowResumeable;
            result.WorkspaceID            = WorkspaceID;
            result.ThreadsToDispose       = ThreadsToDispose;
            result.ParentID               = ParentID;
            result.RunWorkflowAsync       = RunWorkflowAsync;
            result.IsDebugNested          = IsDebugNested;
            result.ForEachNestingLevel    = ForEachNestingLevel;
            result.Environment            = Environment;
            result.EsbChannel             = EsbChannel;
            result.ExecutionToken         = ExecutionToken;
            result.ForEachUpdateValue     = ForEachUpdateValue;
            result.TestName               = TestName;
            result.SourceResourceID       = SourceResourceID;
            result.IsServiceTestExecution = IsServiceTestExecution;
            result.IsDebugFromWeb         = IsDebugFromWeb;
            result.ExecutionID            = ExecutionID;
            result.WebUrl         = WebUrl;
            result.IsSubExecution = IsSubExecution;
            result.QueryString    = QueryString;
            result.ExecutingUser  = ExecutingUser;
            if (ServiceTest != null)
            {
                var serializer = new Dev2JsonSerializer();
                var testString = serializer.Serialize(ServiceTest);
                result.ServiceTest = serializer.Deserialize <IServiceTestModelTO>(testString);
            }
            return(result);
        }
示例#28
0
// ReSharper disable InconsistentNaming
        public void DsfForEach_UpdateDebugParentID_UniqueIdNotSameIfNestingLevelIncreased()
// ReSharper restore InconsistentNaming
        {
            var dataObject = new DsfDataObject(CurrentDl, Guid.NewGuid())
            {
                // NOTE: WorkflowApplicationFactory.InvokeWorkflowImpl() will use HostSecurityProvider.Instance.ServerID 
                //       if this is NOT provided which will cause the tests to fail!
                ServerID = Guid.NewGuid(),
                IsDebug = true,
                ForEachNestingLevel = 1
            };

            DsfForEachActivity act = new DsfForEachActivity();
            var originalGuid = Guid.NewGuid();
            act.UniqueID = originalGuid.ToString();
            act.UpdateDebugParentID(dataObject);
            Assert.AreNotEqual(originalGuid.ToString(), act.UniqueID);
            Assert.AreEqual(act.GetWorkSurfaceMappingId(), originalGuid);


        }
        public void CheckOutputFormatOfDataListForViewInBrowserForOneRecordsetOutputRegion()
        {
            IDataListCompiler comp = DataListFactory.CreateDataListCompiler();
            ErrorResultTO errors;
            Guid dlId = comp.ConvertTo(DataListFormat.CreateFormat(GlobalConstants._XML), string.Empty.ToStringBuilder(), ServiceShape.ToStringBuilder(), out errors);
            var resource = ResourceCatalog.Instance.GetResource(_workspaceId, ServiceName);
            IDSFDataObject dataObj = new DsfDataObject(string.Empty, dlId) { WorkspaceID = _workspaceId, DataListID = dlId, ServiceName = ServiceName, ResourceID = resource.ResourceID };
            EsbServicesEndpoint endPoint = new EsbServicesEndpoint();
            string result = endPoint.FetchExecutionPayload(dataObj, DataListFormat.CreateFormat(GlobalConstants._XML_Without_SystemTags), out errors);

            DeleteDataList(dlId);

            Assert.IsTrue(result.IndexOf("<outputScalar", StringComparison.Ordinal) > 0, "Output format missing required tag of <outputScalar>");
            Assert.IsTrue(result.IndexOf("<bothScalar", StringComparison.Ordinal) > 0, "Output format missing required tag of <bothScalar");
            Assert.IsTrue(result.IndexOf("<recset", StringComparison.Ordinal) > 0, "Output format missing required tag of <recset></recset>");
            Assert.IsTrue(result.IndexOf("<f2", StringComparison.Ordinal) > 0, "Output format missing required tag of <recset><f2/></recset>");
            Assert.IsTrue(result.IndexOf("<f3", StringComparison.Ordinal) > 0, "Output format missing required tag of <recset><f3/></recset>");

        }