当前位置: 首页>>代码示例>>C#>>正文


C# ErrorResultTO.MakeDataListReady方法代码示例

本文整理汇总了C#中Dev2.DataList.Contract.ErrorResultTO.MakeDataListReady方法的典型用法代码示例。如果您正苦于以下问题:C# ErrorResultTO.MakeDataListReady方法的具体用法?C# ErrorResultTO.MakeDataListReady怎么用?C# ErrorResultTO.MakeDataListReady使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Dev2.DataList.Contract.ErrorResultTO的用法示例。


在下文中一共展示了ErrorResultTO.MakeDataListReady方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateForm


//.........这里部分代码省略.........
                }
                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 =
开发者ID:NatashaSchutte,项目名称:Warewolf-ESB,代码行数:67,代码来源:AbstractWebRequestHandler.cs

示例2: ErrorResultTO_MakeDatalistReady_CannotSetUnknownMemberError_MessageConvertedToOutdatedServerError

        public void ErrorResultTO_MakeDatalistReady_CannotSetUnknownMemberError_MessageConvertedToOutdatedServerError()
        {
            var errorResultTO = new ErrorResultTO();
            errorResultTO.AddError("Cannot set unknown member");
            //------------Execute Test---------------------------

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

            // Assert Message Converted To Outdated Server Error
            Assert.AreEqual(expected, result, "Error message not relevent");
        }
开发者ID:NatashaSchutte,项目名称:Warewolf-ESB,代码行数:12,代码来源:DataListConverterTest.cs

示例3: Invoke

        /// <summary>
        /// Invokes the specified service as per the dataObject against theHost
        /// </summary>
        /// <param name="dataObject">The data object.</param>
        /// <param name="errors">The errors.</param>
        /// <returns></returns>
        /// <exception cref="System.Exception">Can only execute workflows from web browser</exception>
        public Guid Invoke(IDSFDataObject dataObject, out ErrorResultTO errors)
        {
            var result = GlobalConstants.NullDataListID;
            var time = new Stopwatch();
            time.Start();
            errors = new ErrorResultTO();
            int update = 0;
            // BUG 9706 - 2013.06.22 - TWR : added pre debug dispatch
            if(dataObject.Environment.HasErrors())
            {
                errors.AddError(dataObject.Environment.FetchErrors());
                DispatchDebugErrors(errors, dataObject, StateType.Before);
            }
            errors.ClearErrors();
            try
            {
                var serviceId = dataObject.ResourceID;

                // we need to get better at getting this ;)

                var serviceName = dataObject.ServiceName;
                if(serviceId == Guid.Empty && string.IsNullOrEmpty(serviceName))
                {
                    errors.AddError(Resources.DynamicServiceError_ServiceNotSpecified);
                }
                else
                {

                    try
                    {
                        var sl = new ServiceLocator();
                        Dev2Logger.Log.Debug("Finding service");
                        var theService = serviceId == Guid.Empty ? sl.FindService(serviceName, _workspace.ID) : sl.FindService(serviceId, _workspace.ID);

                        if(theService == null)
                        {
                            errors.AddError("Service [ " + serviceName + " ] not found.");
                        }
                        else if(theService.Actions.Count <= 1)
                        {
                            #region Execute ESB container

                            var theStart = theService.Actions.FirstOrDefault();
                            if(theStart != null && theStart.ActionType != Common.Interfaces.Core.DynamicServices.enActionType.InvokeManagementDynamicService && theStart.ActionType != Common.Interfaces.Core.DynamicServices.enActionType.Workflow && dataObject.IsFromWebServer)
                            {
                                throw new Exception("Can only execute workflows from web browser");
                            }
                            Dev2Logger.Log.Debug("Mapping Action Dependencies");
                            MapServiceActionDependencies(theStart, sl);

                            // Invoke based upon type ;)
                            if(theStart != null)
                            {
                                theStart.DataListSpecification = theService.DataListSpecification;
                                Dev2Logger.Log.Debug("Getting container");
                                var container = GenerateContainer(theStart, dataObject, _workspace);
                                ErrorResultTO invokeErrors;
                                result = container.Execute(out invokeErrors, update);
                                errors.MergeErrors(invokeErrors);
                            }
                            #endregion
                        }
                        else
                        {
                            errors.AddError("Malformed Service [ " + serviceId + " ] it contains multiple actions");
                        }
                    }
                    catch(Exception e)
                    {
                        errors.AddError(e.Message);
                    }
                    finally
                    {
                        if (dataObject.Environment.HasErrors())
                        {
                            var errorString = dataObject.Environment.FetchErrors();
                            var executionErrors = ErrorResultTO.MakeErrorResultFromDataListString(errorString);
                            errors.MergeErrors(executionErrors);
                        }

                        dataObject.Environment.AddError(errors.MakeDataListReady());

                        if(errors.HasErrors())
                        {
                            Dev2Logger.Log.Error(errors.MakeDisplayReady());
                        }
                    }
                }
            }
            finally
            {
                time.Stop();
                ServerStats.IncrementTotalRequests();
//.........这里部分代码省略.........
开发者ID:Robin--,项目名称:Warewolf,代码行数:101,代码来源:EsbServiceInvoker.cs

示例4: CanConvertErrorResultTojson

        public void CanConvertErrorResultTojson()
        {
            ErrorResultTO errors = new ErrorResultTO();
            errors.AddError("Error 1");
            errors.AddError("Error 2");

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


            Assert.AreEqual(expected, result, "Expected [ " + expected + " but got [ " + result + " ]");
        }
开发者ID:NatashaSchutte,项目名称:Warewolf-ESB,代码行数:12,代码来源:DataListConverterTest.cs

示例5: CreateForm


//.........这里部分代码省略.........
                // 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);
            }
        }
开发者ID:david-x-chen,项目名称:Warewolf-ESB,代码行数:101,代码来源:AbstractWebRequestHandler.cs

示例6: Plugin

        /// <summary>
        /// Invokes a plugin assembly
        /// </summary>
        /// <param name="plugin">The action of type Plugin</param>
        /// <param name="req">The req.</param>
        /// <param name="formatOutput">Indicates if the output of the plugin should be run through the formatter</param>
        /// <returns>
        /// Unlimited object
        /// </returns>
        public Guid Plugin(ServiceAction plugin, IDSFDataObject req, bool formatOutput)
        {
            Guid result = GlobalConstants.NullDataListID;
            Guid tmpID = GlobalConstants.NullDataListID;

            var errors = new ErrorResultTO();
            var allErrors = new ErrorResultTO();

            try
            {
                AppDomain tmpDomain = plugin.PluginDomain;

                //Instantiate the Remote Oject handler which will allow cross application domain access
                var remoteHandler =
                    (RemoteObjectHandler)
                    tmpDomain.CreateInstanceFromAndUnwrap(typeof(IFrameworkDataChannel).Module.Name,
                                                          typeof(RemoteObjectHandler).ToString());

                var dataBuilder = new StringBuilder("<Args><Args>");
                foreach(ServiceActionInput sai in plugin.ServiceActionInputs)
                {
                    dataBuilder.Append("<Arg>");
                    dataBuilder.Append("<TypeOf>");
                    dataBuilder.Append(sai.NativeType);
                    dataBuilder.Append("</TypeOf>");
                    dataBuilder.Append("<Value>");
                    dataBuilder.Append(sai.Value); // Fetch value and assign
                    dataBuilder.Append("</Value>");
                    dataBuilder.Append("</Arg>");
                }

                dataBuilder.Append("</Args></Args>");

                //xele.Value = (remoteHandler.RunPlugin(plugin.Source.AssemblyLocation, plugin.Source.AssemblyName, plugin.SourceMethod, data));
                string exeValue =
                    (remoteHandler.RunPlugin(plugin.Source.AssemblyLocation, plugin.Source.AssemblyName,
                                             plugin.SourceMethod, dataBuilder.ToString(), plugin.OutputDescription,
                                             formatOutput));

                // TODO : Now create a new dataList and merge the result into the current dataList ;)
                string dlShape = ClientCompiler.ShapeDev2DefinitionsToDataList(plugin.ServiceActionOutputs,
                                                                                enDev2ArgumentType.Output, false,
                                                                                out errors);
                allErrors.MergeErrors(errors);
                tmpID = ClientCompiler.ConvertTo(DataListFormat.CreateFormat(GlobalConstants._XML), exeValue, dlShape,
                                                  out errors);
                ClientCompiler.SetParentID(tmpID, req.DataListID); // set parent for merge op in finally...

                allErrors.MergeErrors(errors);

                //Unload the temporary application domain
                //AppDomain.Unload(tmpDomain); -- throws exception when attempting to access after first unload?! -- A strange world C# / Winblows dev is
            }
            catch(Exception ex)
            {
                allErrors.AddError(ex.Message);
            }
            finally
            {
                // handle any errors that might have occured
                IBinaryDataListEntry be = Dev2BinaryDataListFactory.CreateEntry(enSystemTag.Error.ToString(),
                                                                                string.Empty);
                string error;
                be.TryPutScalar(
                    Dev2BinaryDataListFactory.CreateBinaryItem(allErrors.MakeDataListReady(),
                                                               enSystemTag.Error.ToString()), out error);
                errors.AddError(error);
                SvrCompiler.Upsert(null, req.DataListID,
                                    DataListUtil.BuildSystemTagForDataList(enSystemTag.Error, true), be, out errors);

                // now merge and delete tmp
                if(tmpID != GlobalConstants.NullDataListID)
                {
                    // Travis.Frisinger - 29.01.2013 - Bug 8352
                    // We merge here since we never have the shape generated here in the request DL ;)
                    Guid mergeID = ClientCompiler.Merge(req.DataListID, tmpID, enDataListMergeTypes.Union, enTranslationDepth.Data_With_Blank_OverWrite, false, out errors);

                    if(mergeID == GlobalConstants.NullDataListID)
                    {
                        allErrors.AddError("Failed to merge data from Plugin Invoke");
                        allErrors.MergeErrors(errors);
                    }

                    //ClientCompiler.Shape(tmpID, enDev2ArgumentType.Output, plugin.ServiceActionOutputs, out errors);
                    ClientCompiler.DeleteDataListByID(tmpID);
                    result = req.DataListID;
                }
            }

            return result;
        }
开发者ID:Robin--,项目名称:Warewolf,代码行数:100,代码来源:DynamicServicesInvoker.cs

示例7: AddErrorsToDataList

        private void AddErrorsToDataList(ErrorResultTO errors, Guid dataListID)
        {
            // Upsert any errors that might have occured into the datalist
            IBinaryDataListEntry be = Dev2BinaryDataListFactory.CreateEntry(enSystemTag.Error.ToString(), string.Empty);
            string error;
            be.TryPutScalar(Dev2BinaryDataListFactory.CreateBinaryItem(errors.MakeDataListReady(), enSystemTag.Error.ToString()), out error);
            if (!string.IsNullOrWhiteSpace(error))
            {
                //At this point there was an error while trying to handle errors so we throw an exception
                throw new Exception(string.Format("The error '{0}' occured while creating the error entry for the following errors: {1}", error, errors.MakeDisplayReady()));
            }

            var upsertErrors = new ErrorResultTO();
            SvrCompiler.Upsert(null, dataListID, DataListUtil.BuildSystemTagForDataList(enSystemTag.Error, true), be, out upsertErrors);
            if (upsertErrors.HasErrors())
            {
                //At this point there was an error while trying to handle errors so we throw an exception
                throw new Exception(string.Format("The error '{0}' occured while upserting the following errors to the datalist: {1}", errors.MakeDisplayReady(), errors.MakeDisplayReady()));
            }
        }
开发者ID:Robin--,项目名称:Warewolf,代码行数:20,代码来源:DynamicServicesInvoker.cs

示例8: ManagementDynamicService

        /// <summary>
        /// Invoke a management method which is a statically coded method in the service implementation for service engine administrators
        /// </summary>
        /// <param name="serviceAction">Action of type InvokeManagementDynamicService</param>
        /// <param name="xmlRequest">The XML request.</param>
        /// <returns>
        /// UnlimitedObject
        /// </returns>
        public Guid  ManagementDynamicService(ServiceAction serviceAction, IDSFDataObject xmlRequest)
        {
            var errors = new ErrorResultTO();
            var allErrors = new ErrorResultTO();
            Guid result = GlobalConstants.NullDataListID;

            try
            {
                object[] parameterValues = null;
                //Instantiate a Endpoint object that contains all static management methods
                object o = this;
                //Activator.CreateInstance(typeof(Unlimited.Framework.DynamicServices.DynamicServicesEndpoint), new object[] {string.Empty});

                //Get the management method
                MethodInfo m = o.GetType().GetMethod(serviceAction.SourceMethod);
                //Infer the parameters of the management method
                ParameterInfo[] parameters = m.GetParameters();
                //If there are parameters then retrieve them from the service action input values
                if(parameters.Count() > 0)
                {
                    IEnumerable<object> parameterData = from c in serviceAction.ServiceActionInputs
                                                        select c.Value;

                    parameterValues = parameterData.ToArray();
                }
                //Invoke the management method and store the return value
                string val = m.Invoke(o, parameterValues).ToString();

                result = ClientCompiler.UpsertSystemTag(xmlRequest.DataListID, enSystemTag.ManagmentServicePayload, val,
                                                         out errors);

                //_clientCompiler.Upsert(xmlRequest.DataListID, DataListUtil.BuildSystemTagForDataList(enSystemTag.ManagmentServicePayload, true), val, out errors);
                allErrors.MergeErrors(errors);

                //returnval = new UnlimitedObject(GetXElement(val));
            }
            catch(Exception ex)
            {
                allErrors.AddError(ex.Message);
            }
            finally
            {
                // handle any errors that might have occured

                if(allErrors.HasErrors())
                {
                    IBinaryDataListEntry be = Dev2BinaryDataListFactory.CreateEntry(enSystemTag.Error.ToString(),
                                                                                    string.Empty);
                    string error;
                    be.TryPutScalar(
                        Dev2BinaryDataListFactory.CreateBinaryItem(allErrors.MakeDataListReady(),
                                                                   enSystemTag.Error.ToString()), out error);
                    if(error != string.Empty)
                    {
                        errors.AddError(error);
                    }
                }

                // No cleanup to happen ;)
            }

            return result;
        }
开发者ID:Robin--,项目名称:Warewolf,代码行数:71,代码来源:DynamicServicesInvoker.cs


注:本文中的Dev2.DataList.Contract.ErrorResultTO.MakeDataListReady方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。