示例#1
0
        public DirectResponse DeleteData(string key, string CurCompany)
        {
            DirectResponse dr = new DirectResponse();

            GLXNAVWebApp.ReqWorksheet.ReqWorksheet_Service svc = new GLXNAVWebApp.ReqWorksheet.ReqWorksheet_Service();
            svc.Url         = Clsc.ReBuildUrl(svc.Url, CurCompany);
            svc.Credentials = Clsc.CheckCredentials();

            if (!string.IsNullOrEmpty(key))
            {
                try
                {
                    svc.Delete("DEFAULT", key);
                }
                catch (Exception e)
                {
                    dr.Success      = false;
                    dr.Result       = "Completed with error";
                    dr.ErrorMessage = e.Message;
                    return(dr);
                }
            }
            dr.Result = "Completed with success";
            return(dr);
        }
示例#2
0
        public override void ExecuteResult(ControllerContext context)
        {
            DirectResponse response = new DirectResponse();

            response.Result = this.Result;
            response.IsUpload = this.IsUpload;

            if (!string.IsNullOrEmpty(this.ErrorMessage))
            {
                response.Success = false;
                response.ErrorMessage = this.ErrorMessage;
            }
            else
            {
                if (!string.IsNullOrEmpty(this.Script))
                {
                    response.Script = string.Concat("<string>", this.Script);
                }

                if (this.ExtraParamsResponse.Count > 0)
                {
                    response.ExtraParamsResponse = this.ExtraParamsResponse.ToJson();
                }
            }

            response.Return();
        }
        public void ProcessRequest(HttpContext context)
        {
            System.Threading.Thread.Sleep(8000);
            DirectResponse r = new DirectResponse();

            r.Return();
        }
        public DirectResponse PostReceive(string docNo, string CurCompany)
        {
            DirectResponse dr = new DirectResponse();

            GLXNAVWebApp.PurchaseOrder.PurchaseOrder_Service svc = new GLXNAVWebApp.PurchaseOrder.PurchaseOrder_Service();
            svc.Url         = common.ReBuildUrl(svc.Url, CurCompany);
            svc.Credentials = common.CheckCredentials();

            GLXNAVWebApp.PurchaseOrder.PurchaseOrder g;
            g = svc.Read(docNo);
            try
            {
                svc.PostReceive(g.Key);
                g = svc.Read(docNo);
            }
            catch (Exception e)
            {
                dr.Success      = false;
                dr.Result       = "{control: 'grid'}";
                dr.ErrorMessage = e.Message;
                return(dr);
            }
            string json = JSON.Serialize(g);

            json = json.Replace(@"'", @" ");

            dr.Result = String.Format("{{documentNo:'{0}',record:'{1}'}}", g.No, json);
            return(dr);
        }
示例#5
0
        public DirectResponse DoAddUser(string userName, string fullName, string company, string location, string batch, string role, string companies)
        {
            var dataUser = new data_UserCreateRequest();

            dataUser.Username  = userName;
            dataUser.FullName  = fullName;
            dataUser.Company   = company;
            dataUser.Location  = location;
            dataUser.Batch     = batch;
            dataUser.Role      = role;
            dataUser.Companies = companies;

            BSL_GLXAccountClient client = new BSL_GLXAccountClient();
            string mess = client.createUser(dataUser);

            DirectResponse dr = new DirectResponse();

            if (mess == "")
            {
                dr.Success = true;
                dr.Result  = String.Format("{{Message:'{0}'}}", "");
            }
            else
            {
                dr.Success      = false;
                dr.ErrorMessage = mess;
            }
            return(dr);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="context"></param>
        public override void ExecuteResult(ControllerContext context)
        {
            DirectResponse response = new DirectResponse();

            response.Result   = this.Result;
            response.IsUpload = this.IsUpload;

            response.Success      = ResourceManager.AjaxSuccess;
            response.ErrorMessage = ResourceManager.AjaxErrorMessage;

            if (!string.IsNullOrEmpty(this.ErrorMessage))
            {
                response.Success      = false;
                response.ErrorMessage = this.ErrorMessage;
            }
            else
            {
                if (!string.IsNullOrEmpty(this.Script))
                {
                    response.Script = this.Script;
                }

                if (this.ExtraParamsResponse.Count > 0)
                {
                    response.ExtraParamsResponse = this.ExtraParamsResponse.ToJson();
                }
            }

            response.Return();
        }
        public void ProcessRequest(HttpContext context)
        {
            DirectResponse r = new DirectResponse();

            X.Js.Call("Ext.toast", "The Server Time is: " + DateTime.Now.ToLongTimeString(), 2000);

            r.Return();
        }
示例#8
0
        public DirectResponse SayHello1(string name)
        {
            DirectResponse response = new DirectResponse();

            // Return a script to be executed on the client
            response.Script = string.Concat("alert('Hello, ", name, "');");

            return(response);
        }
示例#9
0
        private void CheckOnException(DirectResponse directResponse)
        {
            if (!directResponse.Error.HasValues)
            {
                return;
            }

            var errorDesc = directResponse.Error.ToObject <ErrorDescriptor>();

            throw new ServerException(errorDesc);
        }
示例#10
0
        public async Task CreateWithCreditCardToken()
        {
            var token = new TokenResponse();

            using (var tokenApi = new EbanxTokenOperationApi())
            {
                var request = new TokenRequest
                {
                    Country         = "BR",
                    CreditCard      = CreaditCardRequestExtention.GetACard(),
                    PaymentTypeCode = "mastercard",
                };

                token = await tokenApi.Create(request);
            }


            var response = new DirectResponse();

            using (var directApi = new EbanxDirectOperationApi())
            {
                var request = new DirectRequest
                {
                    Operation = "request",
                    Mode      = "full",
                    Payment   = new PaymentRequest
                    {
                        Name         = "Customer Name",
                        Email        = "*****@*****.**",
                        AmountTotal  = 500,
                        Zipcode      = "000000",
                        Address      = "Rua X",
                        StreetNumber = "5",
                        City         = "City",
                        State        = "SP",
                        Country      = "BR",
                        PhoneNumber  = "999999999",
                        CreditCard   = new CreditCardRequest
                        {
                            Token = token.Token
                        },
                        CurrencyCode        = "BRL",
                        MerchantPaymentCode = Guid.NewGuid().ToString(),
                        Document            = "29479146002",
                        Instalments         = 1
                    }
                };

                response = await directApi.Create(request);
            }

            Assert.IsTrue(response.Success);
            Assert.IsTrue(response.Payment.TransactionStatus.Success);
        }
        private void doRequest(HttpContext ctx)
        {
            Encoding encoding = ctx.Request.ContentEncoding;
            ctx.Response.BufferOutput = true;
            DirectResponse responseMsg = new DirectResponse();
            try
            {
                Logger.LoggerInstance.RuntimeLogger.Info("开始解析请求");
                DirectRequest dr = GetDirectRequest(ctx.Request);
                Logger.LoggerInstance.RuntimeLogger.Info("开始调用服务");

                System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
                sw.Start();
                responseMsg.Data = invokeProxy(dr, ctx);
                sw.Stop();
                //计算前端调用事件
                NHExt.Runtime.Logger.LoggerHelper.Info("前端调用" + dr.Action + "服务,耗费时间:" + sw.ElapsedMilliseconds, NHExt.Runtime.Logger.LoggerInstance.BizLogger);
            }
            catch (NHExt.Runtime.Exceptions.BizException ex)
            {
                NHExt.Runtime.Logger.LoggerHelper.Error(ex, NHExt.Runtime.Logger.LoggerInstance.BizLogger);

                responseMsg.Success = false;
                responseMsg.ResultMsg = ex.Message;
                responseMsg.ResultDetailMsg = ex.StackTrace;
            }
            catch (NHExt.Runtime.Exceptions.RuntimeException ex)
            {
                NHExt.Runtime.Logger.LoggerHelper.Error(ex, NHExt.Runtime.Logger.LoggerInstance.RuntimeLogger);

                responseMsg.Success = false;
                responseMsg.ResultMsg = ex.Message;
                responseMsg.ResultDetailMsg = ex.StackTrace;
            }

            catch (Exception ex)
            {
                NHExt.Runtime.Logger.LoggerHelper.Error(ex, NHExt.Runtime.Logger.LoggerInstance.RuntimeLogger);
                if (ex.InnerException != null)
                {
                    NHExt.Runtime.Logger.LoggerHelper.Error(ex, NHExt.Runtime.Logger.LoggerInstance.RuntimeLogger);
                    ex = ex.InnerException;
                }
                responseMsg.Success = false;
                responseMsg.ResultMsg = ex.Message;
                responseMsg.ResultDetailMsg = ex.StackTrace;
            }
            finally
            {
                this.RenderClient(ctx.Response, responseMsg);
            }

        }
        public DirectResponse SayHello2(string name)
        {
            DirectResponse response = new DirectResponse();

            ParameterCollection parameters = new ParameterCollection();

            parameters["Greeting"] = "Hello, " + name;

            response.ExtraParamsResponse = parameters.ToJson();

            return(response);
        }
示例#13
0
        public async Task Create()
        {
            var responseDirect = new DirectResponse();

            using (var directApi = new EbanxDirectOperationApi())
            {
                var r = new DirectRequest
                {
                    Operation = "request",
                    Mode      = "full",
                    Payment   = new PaymentRequest
                    {
                        Name                = "Customer Name",
                        Email               = "*****@*****.**",
                        AmountTotal         = 500,
                        Zipcode             = "000000",
                        Address             = "Rua X",
                        StreetNumber        = "5",
                        City                = "City",
                        State               = "SP",
                        Country             = "BR",
                        PhoneNumber         = "999999999",
                        CurrencyCode        = "BRL",
                        MerchantPaymentCode = Guid.NewGuid().ToString(),
                        Document            = "29479146002",
                        Instalments         = 1,
                        PaymentTypeCode     = "boleto",
                        DueDate             = DateTime.Now.AddDays(3).ToString("dd/MM/yyyy"),
                    }
                };

                responseDirect = await directApi.Create(r);

                var response = new CancelResponse();

                var request = new CancelRequest
                {
                    Hash = responseDirect.Payment.Hash
                };

                using (var api = new EbanxCancelOperationApi(request))
                {
                    response = await api.Create();
                }

                Assert.IsFalse(response.Success);
                //Assert.IsTrue(!string.IsNullOrEmpty(token?.Token));
            }
        }
        public void Should_return_null_result_if_interceptor_does_not_invoke_handler()
        {
            var       parametersParser = MockRepository.GenerateStub <ParametersParser>();
            IMetadata metadata         = BuildMockMetadata();
            var       target           = new DirectHandler(metadata, parametersParser, delegate { });

            DirectResponse actual = target.Handle(new DirectRequest {
                Action   = "Action",
                Method   = "methodThatThrowException",
                JsonData = new JArray(),
                Tid      = 123,
                Type     = "rpc"
            });

            actual.Type.Should().Be.EqualTo("rpc");
            actual.Result.Should().Be.Null();
        }
        public void Should_return_error_when_fail_to_get_methodinfo()
        {
            var       parametersParser = MockRepository.GenerateStub <ParametersParser>();
            IMetadata metadata         = BuildMockMetadata();
            var       target           = new DirectHandler(metadata, parametersParser, (type, info, invoker) => invoker.Invoke());

            metadata.Stub(x => x.GetMethodInfo("Action", "nonExistentMethod")).Throw(new Exception("Method not found"));

            DirectResponse response = target.Handle(new DirectRequest {
                Action   = "Action",
                Method   = "nonExistentMethod",
                JsonData = new JArray()
            });

            response.Result.Should().Be.Null();
            response.Type.Should().Be.EqualTo("exception");
            response.Message.Should().Be.EqualTo("Method not found");
            response.Where.Should().Contain("Method not found");
        }
示例#16
0
        public DirectResponse DelUser(string uname)
        {
            BSL_GLXAccountClient client = new BSL_GLXAccountClient();
            string mess = client.DelUser(uname);

            DirectResponse dr = new DirectResponse();

            if (mess == "")
            {
                dr.Success = true;
                dr.Result  = String.Format("{{Message:'{0}'}}", "");
            }
            else
            {
                dr.Success      = false;
                dr.ErrorMessage = mess;
            }
            return(dr);
        }
示例#17
0
        public async Task CreateWithInsufficientFundsCard()
        {
            var response = new DirectResponse();

            using (var directApi = new EbanxDirectOperationApi())
            {
                var request = new DirectRequest
                {
                    Operation = "request",
                    Mode      = "full",
                    Payment   = new PaymentRequest
                    {
                        Name         = "Customer Name",
                        Email        = "*****@*****.**",
                        AmountTotal  = 500,
                        Zipcode      = "000000",
                        Address      = "Rua X",
                        StreetNumber = "5",
                        City         = "City",
                        State        = "SP",
                        Country      = "BR",
                        PhoneNumber  = "999999999",
                        CreditCard   = CreaditCardRequestExtention.GetACard(CreaditCardRequestExtention.CreditCardTestRequestOperation.InsufficientFunds),

                        //PaymentTypeCode = "boleto",
                        SubAccount = new SubAccountRequest
                        {
                            Name     = "SubAccount Name",
                            ImageUrl = "Image Uri"
                        },
                        CurrencyCode        = "BRL",
                        MerchantPaymentCode = Guid.NewGuid().ToString(),
                        Document            = "29479146002",
                        Instalments         = 1
                    }
                };

                response = await directApi.Create(request);
            }

            Assert.IsTrue(response.Success);
            Assert.IsFalse(response.Payment.TransactionStatus.Success);
        }
        public void Should_invoke_expected_method_passing_parameters_and_returning_result()
        {
            var       parametersParser = MockRepository.GenerateStub <ParametersParser>();
            IMetadata metadata         = BuildMockMetadata();
            var       actionInstance   = MockRepository.GenerateMock <Action>();
            var       target           = new DirectHandler(metadata, parametersParser, (type, method, invoker) => invoker.Invoke(actionInstance));

            parametersParser.Stub(x => x.Parse(Arg <ParameterInfo[]> .Is.Anything, Arg <JToken> .Is.Anything, Arg <IDictionary <string, object> > .Is.Anything, Arg <JsonSerializer> .Is.Anything)).Return(new object[] { 123, "str", true });
            actionInstance.Expect(x => x.MethodWithParams(123, "str", true)).Return("ret");

            DirectResponse response = target.Handle(new DirectRequest {
                Action   = "Action",
                Method   = "methodWithParams",
                JsonData = new JArray(new JValue(123), new JValue("str"), new JValue(true))
            });

            response.Result.ToString().Should().Be.EqualTo("ret");

            actionInstance.VerifyAllExpectations();
        }
        public void Should_return_error_if_interceptor_throws_exceptions()
        {
            var       parametersParser = MockRepository.GenerateStub <ParametersParser>();
            IMetadata metadata         = BuildMockMetadata();
            var       target           = new DirectHandler(metadata, parametersParser, delegate {
                throw new Exception("error from interceptor");
            });

            DirectResponse actual = target.Handle(new DirectRequest {
                Action   = "Action",
                Method   = "method",
                JsonData = new JArray(),
                Tid      = 123,
                Type     = "rpc"
            });

            actual.Type.Should().Be.EqualTo("exception");
            actual.Message.Should().Be.EqualTo("error from interceptor");
            actual.Where.Should().Contain("error from interceptor");
        }
        public void Should_return_error_when_fail_to_parse_parameters()
        {
            var       parametersParser = MockRepository.GenerateStub <ParametersParser>();
            IMetadata metadata         = BuildMockMetadata();
            var       target           = new DirectHandler(metadata, parametersParser, (type, info, invoker) => invoker.Invoke());

            var actionInstance = MockRepository.GenerateMock <Action>();

            actionInstance.Expect(x => x.MethodWithRawParameters(Arg <JToken> .Matches(y => y.ToString() == "value"))).Return(new JValue("ret"));
            parametersParser.Stub(x => x.Parse(Arg <ParameterInfo[]> .Is.Anything, Arg <JToken> .Is.Anything, Arg <IDictionary <string, object> > .Is.Anything, Arg <JsonSerializer> .Is.Anything)).Throw(new Exception("stubexc"));

            DirectResponse response = target.Handle(new DirectRequest {
                Action   = "Action",
                Method   = "method",
                JsonData = new JArray()
            });

            response.Result.Should().Be.Null();
            response.Type.Should().Be.EqualTo("exception");
            response.Message.Should().Be.EqualTo("stubexc");
            response.Where.Should().Contain("stubexc");
        }
示例#21
0
        public DirectResponse Carry_out_action_message()
        {
            DirectResponse dr = new DirectResponse();

            try
            {
                GLXNAVWebApp.PurchaseOrder_CU.PurchaseOrder purchaseOrder_cu = new GLXNAVWebApp.PurchaseOrder_CU.PurchaseOrder();
                purchaseOrder_cu.Url         = common.ReBuildUrl(purchaseOrder_cu.Url, GlobalVariable.CompanyName);
                purchaseOrder_cu.Credentials = common.CheckCredentials();
                purchaseOrder_cu.UseOneJnl();

                dr.Success = true;
                //dr.Result = String.Format("{{Message:'{0}'}}", result);
            }
            catch (Exception ex)
            {
                dr.Success      = false;
                dr.ErrorMessage = ex.Message;
            }

            return(dr);
        }
        public void Should_build_expected_response_when_target_method_throws_exception()
        {
            var       parametersParser = MockRepository.GenerateStub <ParametersParser>();
            IMetadata metadata         = BuildMockMetadata();
            var       target           = new DirectHandler(metadata, parametersParser, (type, method, invoker) => invoker.Invoke());

            DirectResponse actual = target.Handle(new DirectRequest {
                Action   = "Action",
                Method   = "methodThatThrowException",
                JsonData = new JArray(),
                Tid      = 123,
                Type     = "rpc"
            });

            actual.Action.Should().Be.EqualTo("Action");
            actual.Method.Should().Be.EqualTo("methodThatThrowException");
            actual.Tid.Should().Be.EqualTo(123);
            actual.Type.Should().Be.EqualTo("exception");
            actual.Message.Should().Be.EqualTo("something wrong happened");
            actual.Where.Should().Contain("something wrong happened");
            actual.Result.Should().Be.Null();
        }
        public void Should_build_response_based_on_request_data()
        {
            var       parametersParser = MockRepository.GenerateStub <ParametersParser>();
            IMetadata metadata         = BuildMockMetadata();
            var       target           = new DirectHandler(metadata, parametersParser, (type, info, invoker) => invoker.Invoke());

            DirectResponse actual = target.Handle(new DirectRequest {
                Action   = "Action",
                Method   = "method",
                JsonData = new JArray(),
                Tid      = 123,
                Type     = "rpc"
            });

            actual.Action.Should().Be.EqualTo("Action");
            actual.Method.Should().Be.EqualTo("method");
            actual.Tid.Should().Be.EqualTo(123);
            actual.Type.Should().Be.EqualTo("rpc");
            actual.Message.Should().Be.Null();
            actual.Where.Should().Be.Null();
            actual.Result.Should().Be.Null();
        }
示例#24
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="context"></param>
        public override void ExecuteResult(ControllerContext context)
        {
            DirectResponse response = new DirectResponse();

            response.Result   = this.Result;
            response.IsUpload = this.IsUpload;

            if (!string.IsNullOrEmpty(this.ErrorMessage))
            {
                response.Success      = false;
                response.ErrorMessage = this.ErrorMessage;
            }
            else
            {
                if (HttpContext.Current != null)
                {
                    var instanceScript = HttpContext.Current.Items[ResourceManager.INSTANCESCRIPT];
                    if (instanceScript != null)
                    {
                        this.Script = instanceScript.ToString() + (this.Script ?? "");
                    }
                }

                if (!string.IsNullOrEmpty(this.Script))
                {
                    response.Script = string.Concat("<string>", this.Script);
                }

                if (this.ExtraParamsResponse.Count > 0)
                {
                    response.ExtraParamsResponse = this.ExtraParamsResponse.ToJson();
                }
            }

            response.Return();
        }
        public DirectResponse UpdateData(string HdrChangedData, string dData, string LineChangedData, string CurCompany)
        {
            DirectResponse dr = new DirectResponse();
            Dictionary <string, object> jsonData = JSON.Deserialize <Dictionary <string, object> >(HdrChangedData);

            #region Parse data to class hdr
            GLXNAVWebApp.PurchaseOrder.PurchaseOrder g = (GLXNAVWebApp.PurchaseOrder.PurchaseOrder)
                                                         JsonConvert.DeserializeObject(HdrChangedData, typeof(GLXNAVWebApp.PurchaseOrder.PurchaseOrder),
                                                                                       new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Include
            });

            //workaround
            g.Posting_Date = g.Posting_Date.AddDays(1);

            #endregion Parse data to class

            #region Data of Request Line
            //Get modified data
            List <GLXNAVWebApp.PurchaseOrder.Purchase_Order_Line> line = new List <GLXNAVWebApp.PurchaseOrder.Purchase_Order_Line>();
            if (!string.IsNullOrEmpty(dData))
            {
                line = JSON.Deserialize <List <GLXNAVWebApp.PurchaseOrder.Purchase_Order_Line> >(dData);
            }
            if (line != null)
            {
                g.PurchLines = line.ToArray();

                //Set key null for new line
                foreach (GLXNAVWebApp.PurchaseOrder.Purchase_Order_Line item in g.PurchLines)
                {
                    if (string.IsNullOrEmpty(item.Key))
                    {
                        item.Key = null;
                    }
                }
            }
            #endregion Data of Request Line

            #region Update data
            GLXNAVWebApp.PurchaseOrder.PurchaseOrder_Service svc = new GLXNAVWebApp.PurchaseOrder.PurchaseOrder_Service();
            svc.Url         = common.ReBuildUrl(svc.Url, CurCompany);
            svc.Credentials = common.CheckCredentials();

            try
            {
                if (string.IsNullOrEmpty(g.Key))
                {
                    svc.Create(ref g);
                }
                else
                {
                    svc.Update(ref g);
                }
            }
            catch (Exception e)
            {
                dr.Success      = false;
                dr.Result       = "{control: 'grid'}";
                dr.ErrorMessage = e.Message;
                return(dr);
            }
            #endregion Update data

            string json = JSON.Serialize(g);
            json = json.Replace(@"'", @" ");

            dr.Result = String.Format("{{documentNo:'{0}',record:'{1}'}}", g.No, json);
            return(dr);
        }
 protected virtual void RenderClient(HttpResponse response, DirectResponse responseMsg)
 {
     response.Write(NHExt.Runtime.Serialize.JsonSerialize.Serialize(responseMsg));
 }
示例#27
0
        public DirectResponse UpdateData(string Batch, string HdrChangedData, string CurCompany)
        {
            DirectResponse dr = new DirectResponse();
            Dictionary <string, object> jsonData = JSON.Deserialize <Dictionary <string, object> >(HdrChangedData);

            #region Parse data to class hdr
            //Nếu Action_Message có giá trị bằng null => Action_Message = ""
            HdrChangedData = HdrChangedData.Replace(String.Format(@"""{0}"":{1}", "Action_Message", "null"), String.Format(@"""{0}"":""{1}""", "Action_Message", ""));

            //Nếu Replenishment_System có giá trị bằng null => Replenishment_System = ""
            HdrChangedData = HdrChangedData.Replace(String.Format(@"""{0}"":{1}", "Replenishment_System", "null"), String.Format(@"""{0}"":""{1}""", "Replenishment_System", ""));

            //Set value of Option string to integer
            //int i = 0;
            //foreach (string item in GLXNAVWebApp.ReqWorksheet.Action_Message.GetNames(typeof(GLXNAVWebApp.ReqWorksheet.Action_Message)))
            //{
            //    string t = item.ToString().Replace("_", " ");
            //    HdrChangedData = HdrChangedData.Replace(String.Format(@"""{0}"":""{1}""", "Action_Message", t), String.Format(@"""{0}"":""{1}""", "Action_Message", i.ToString()));
            //    i += 1;
            //}

            //i = 0;
            //foreach (string item in GLXNAVWebApp.ReqWorksheet.Replenishment_System.GetNames(typeof(GLXNAVWebApp.ReqWorksheet.Replenishment_System)))
            //{
            //    string t = item.ToString().Replace("_", " ");
            //    HdrChangedData = HdrChangedData.Replace(String.Format(@"""{0}"":""{1}""", "Replenishment_System", t), String.Format(@"""{0}"":""{1}""", "Replenishment_System", i.ToString()));
            //    i += 1;
            //}

            GLXNAVWebApp.ReqWorksheet.ReqWorksheet g = (GLXNAVWebApp.ReqWorksheet.ReqWorksheet)
                                                       JsonConvert.DeserializeObject(HdrChangedData, typeof(GLXNAVWebApp.ReqWorksheet.ReqWorksheet),
                                                                                     new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Include
            });
            #endregion Parse data to class

            #region
            //GLXNAVWebApp.ReqWorksheet_CodeUnit.ReqWorksheet_CodeUnit. = new GLXNAVWebApp.ReqWorksheet.ReqWorksheet_Service();
            GLXNAVWebApp.GLXWebService.GLXWebService_Service svc1 = new GLXWebService.GLXWebService_Service();
            #endregion

            #region Update data
            GLXNAVWebApp.ReqWorksheet.ReqWorksheet_Service svc = new GLXNAVWebApp.ReqWorksheet.ReqWorksheet_Service();
            svc.Url         = Clsc.ReBuildUrl(svc.Url, CurCompany);
            svc.Credentials = Clsc.CheckCredentials();

            try
            {
                if (string.IsNullOrEmpty(g.Key))
                {
                    svc.Create(Batch, ref g);
                }
                else
                {
                    svc.Update(Batch, ref g);
                }
            }
            catch (Exception e)
            {
                dr.Success      = false;
                dr.Result       = "{control: 'grid'}";
                dr.ErrorMessage = e.Message;
            }
            #endregion Update data

            string json = JSON.Serialize(g);
            json = json.Replace(@"'", @" ");

            dr.Result = String.Format("{{Key:'{0}',No:'{1}',record:'{2}'}}", g.Key, g.No, json);

            return(dr);
        }
示例#28
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="context"></param>
        public override void ExecuteResult(ControllerContext context)
        {
            DirectResponse response = new DirectResponse();

            response.Result = this.Result;
			response.IsUpload = this.IsUpload;

            if (!string.IsNullOrEmpty(this.ErrorMessage))
            {
                response.Success = false;
                response.ErrorMessage = this.ErrorMessage;
            }
            else
            {
                if (HttpContext.Current != null)
                {
                    var instanceScript = HttpContext.Current.Items[ResourceManager.INSTANCESCRIPT];
                    if (instanceScript != null)
                    {
                        this.Script = instanceScript.ToString()  + (this.Script ?? "");
                    }
                }
                
                if (!string.IsNullOrEmpty(this.Script))
                {
                    response.Script = string.Concat("<string>", this.Script);
                }

                if (this.ExtraParamsResponse.Count > 0)
                {
                    response.ExtraParamsResponse = this.ExtraParamsResponse.ToJson();
                }
            }
            
            response.Return();
        }