Ejemplo n.º 1
0
        public JsonResult SyncPipe(PipelineRequestPack pack)
        {
            if (pack.id == 0)
            {
                return(null);
            }
            else
            {
                var result = new PipelineResultPack()
                {
                    id = pack.id
                };
                var pipeline = ServiceLocator.GetInstance <IPipelineManager>();
                var msgSeq   = pack.lastMsgSeq;

                var valid = false;
                AddMessages(result, pipeline.GetMessages(ClientSession.Current, ref msgSeq, out valid));

                //processar o pack
                foreach (var dataItem in pack.data)
                {
                    if (dataItem.type == "opcall")
                    {
                        var resultItem = new PipelineResultPackItem()
                        {
                            type   = "opresult",
                            opid   = dataItem.opid,
                            opname = dataItem.opname
                        };
                        result.data.Add(resultItem);

                        try
                        {
                            resultItem.data = pipeline.ExecuteOperationJSON(ClientSession.Current, dataItem.opname, dataItem.data);
                        }
                        catch (Exception ex)
                        {
                            resultItem.error   = true;
                            resultItem.message = ex.ToString();
                        }
                    }
                }

                AddMessages(result, pipeline.GetMessages(ClientSession.Current, ref msgSeq, out valid));
                return(Json(result));
            }
        }
Ejemplo n.º 2
0
        public JsonResult SyncPipe(PipelineRequestPack pack)
        {
            if (pack.id == 0)
                return null;
            else
            {
                var result = new PipelineResultPack() { id = pack.id };
                var pipeline = ServiceLocator.GetInstance<IPipelineManager>();
                var msgSeq = pack.lastMsgSeq;

                var valid = false;
                AddMessages(result, pipeline.GetMessages(ClientSession.Current, ref msgSeq, out valid));

                //processar o pack
                foreach (var dataItem in pack.data)
                {
                    if (dataItem.type == "opcall")
                    {
                        var resultItem = new PipelineResultPackItem()
                        {
                            type = "opresult",
                            opid = dataItem.opid,
                            opname = dataItem.opname
                        };
                        result.data.Add(resultItem);

                        try
                        {
                            resultItem.data = pipeline.ExecuteOperationJSON(ClientSession.Current, dataItem.opname, dataItem.data);
                        }
                        catch (Exception ex)
                        {
                            resultItem.error = true;
                            resultItem.message = ex.ToString();
                        }
                    }
                }

                AddMessages(result, pipeline.GetMessages(ClientSession.Current, ref msgSeq, out valid));
                return Json(result);
            }
        }