コード例 #1
0
 private static void CleanUp(ExecutionDto dto)
 {
     dto.DataObject = null;
     dto.ErrorResultTO.ClearErrors();
     GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce;
     GC.Collect(3, GCCollectionMode.Forced, false);
 }
コード例 #2
0
ファイル: ExecutionDto.cs プロジェクト: tuga1975/Warewolf
        public static IResponseWriter CreateResponseWriter(this ExecutionDto dto)
        {
            var dataObject        = dto.DataObject;
            var esbExecuteRequest = dto.Request;
            var executionDlid     = dto.DataListIdGuid;
            var workspaceGuid     = dto.WorkspaceID;
            var serviceName       = dto.ServiceName;
            var resource          = dto.Resource;
            var formatter         = dto.DataListFormat;
            var executePayload    = "";
            var webRequest        = dto.WebRequestTO;
            var serializer        = dto.Serializer;
            var allErrors         = dto.ErrorResultTO;

            if (!dataObject.Environment.HasErrors())
            {
                if (!esbExecuteRequest.WasInternalService)
                {
                    dataObject.DataListID  = executionDlid;
                    dataObject.WorkspaceID = workspaceGuid;
                    dataObject.ServiceName = serviceName;
                    executePayload         = GetExecutePayload(dataObject, resource, webRequest, ref formatter);
                }
                else
                {
                    // internal service request we need to return data for it from the request object ;)

                    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
            {
                executePayload = SetupErrors(dataObject, allErrors);
            }

            if (dataObject.Environment.HasErrors())
            {
                Dev2Logger.Error(GlobalConstants.ExecutionLoggingResultStartTag + (executePayload ?? "").Replace(Environment.NewLine, string.Empty) + GlobalConstants.ExecutionLoggingResultEndTag, dataObject.ExecutionID.ToString());
            }
            else
            {
                Dev2Logger.Debug(GlobalConstants.ExecutionLoggingResultStartTag + (executePayload ?? "").Replace(Environment.NewLine, string.Empty) + GlobalConstants.ExecutionLoggingResultEndTag, dataObject.ExecutionID.ToString());
            }
            if (!dataObject.Environment.HasErrors() && esbExecuteRequest.WasInternalService)
            {
                if (executePayload.IsJSON())
                {
                    formatter = DataListFormat.CreateFormat("JSON", EmitionTypes.JSON, "application/json");
                }
                else
                {
                    if (executePayload.IsXml())
                    {
                        formatter = DataListFormat.CreateFormat("XML", EmitionTypes.XML, "text/xml");
                    }
                }
            }
            Dev2DataListDecisionHandler.Instance.RemoveEnvironment(dataObject.DataListID);
            dataObject.Environment = null;
            dto.ErrorResultTO.ClearErrors();
            return(new StringResponseWriter(executePayload, formatter.ContentType));
        }
コード例 #3
0
        public static IResponseWriter CreateResponseWriter(this ExecutionDto dto)
        {
            var dataObject        = dto.DataObject;
            var esbExecuteRequest = dto.Request;
            var executionDlid     = dto.DataListIdGuid;
            var workspaceGuid     = dto.WorkspaceID;
            var serviceName       = dto.ServiceName;
            var resource          = dto.Resource;
            var formatter         = dto.DataListFormat;
            var executePayload    = dto.PayLoad;
            var webRequest        = dto.WebRequestTO;
            var serializer        = dto.Serializer;
            var allErrors         = dto.ErrorResultTO;

            if (!dataObject.Environment.HasErrors())
            {
                if (!esbExecuteRequest.WasInternalService)
                {
                    dataObject.DataListID  = executionDlid;
                    dataObject.WorkspaceID = workspaceGuid;
                    dataObject.ServiceName = serviceName;

                    if (!dataObject.IsDebug || dataObject.RemoteInvoke || dataObject.RemoteNonDebugInvoke)
                    {
                        if (resource?.DataList != null)
                        {
                            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,
                                                                                                       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(), webRequest.WebServerUrl);
                            }
                        }
                    }
                    else
                    {
                        executePayload = string.Empty;
                    }
                }
                else
                {
                    // internal service request we need to return data for it from the request object ;)

                    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
            {
                executePayload = SetupErrors(dataObject, allErrors);
            }

            Dev2Logger.Debug("Execution Result [ " + executePayload + " ]");
            if (!dataObject.Environment.HasErrors() && esbExecuteRequest.WasInternalService)
            {
                if (executePayload.IsJSON())
                {
                    formatter = DataListFormat.CreateFormat("JSON", EmitionTypes.JSON, "application/json");
                }
                else if (executePayload.IsXml())
                {
                    formatter = DataListFormat.CreateFormat("XML", EmitionTypes.XML, "text/xml");
                }
            }
            Dev2DataListDecisionHandler.Instance.RemoveEnvironment(dataObject.DataListID);
            dataObject.Environment = null;
            return(new StringResponseWriter(executePayload, formatter.ContentType));
        }