zoukankan      html  css  js  c++  java
  • H3BPM中前端发送JS对象请求后端C#

    BPM流程中用到异步请求, 工作记录

           //前端定义对象,最后转成字符串, 发送到C#的接口
    var num=$.MvcSheetUI.GetElement("OTC09_01").SheetGridView().RowCount; //子表行数 var jsonobj = {}; //定义JSON jsonobj.rows=[]; //定义成员数组 for(var i=1;i<=num;i++) { var obj={}; //定义数组成员 obj.qty=$.MvcSheetUI.GetControlValue("OTC09_01.BGSL",i); obj.predate=$.MvcSheetUI.GetControlValue("OTC09_01.BGRQ",i); obj.socode=$.MvcSheetUI.GetControlValue("OTC09_01.DDH",i); obj.rowno=$.MvcSheetUI.GetControlValue("OTC09_01.RowNo",i); jsonobj.rows.push(obj); //把成员加入数组 } $.MvcSheetUI.SetControlValue("jsonobj",JSON.stringify(jsonobj)); //以JSON格式转成字符串

    C#接收到解析

            public WSResult OTC09ToERP(string jsonStr)
            {
                //提取JSON行数组
                JObject jsonObj = (JObject)JsonConvert.DeserializeObject(jsonStr);
                JArray jsonArr = (JArray)JsonConvert.DeserializeObject(jsonObj["rows"].ToString());
                int num = jsonArr.Count;
                //构建ERP SQL字符串
                string sqlTests = string.Empty;
                for (var i = 0; i < num; i++)
                {
                    JObject jsonRow = (JObject)JsonConvert.DeserializeObject(jsonArr[i].ToString());
                    //变更数量,件数,发货日期,完工日期
                    string sqlTest = @"update SO_SODetails set iQuantity={0},iNum={0}/(ISNULL(b.cInvDefine13,1)),dPreDate={1},dPreMoDate={1},cScloser={4} from SO_SODetails a
                                    inner join inventory b on a.cInvCode=b.cInvCode
                                    where a.cSOCode='{2}' and a.iRowNo={3} ";
                    //处理空值
                    string val1, val2,val3 = val1 = val2 = val3 = string.Empty;
                    val1 = jsonRow["qty"].ToString() == "" ? "iQuantity" : jsonRow["qty"].ToString();
                    val2 = jsonRow["predate"].ToString() == "" ? "dPreDate" : "'" + jsonRow["predate"].ToString() + "'";
                    val3 = jsonRow["qty"].ToString() == "0" ? "'EAI'" : "cScloser";
                    //格式化占位符
                    sqlTests += string.Format(sqlTest, val1, val2, jsonRow["socode"].ToString(), jsonRow["rowno"].ToString(),val3);
                }
                //执行ERP变更
                SqlCon con = new SqlCon("ERP");
                try
                {
                    con.open();
                    if (con.ENQuery(sqlTests) > 0)
                    {
                        r._message = "订单变更成功";
                        r._result = "1";
                        r._state = "successful";
                    }
    
                }
                catch (Exception)
                {
    
                    throw;
                }
                finally
                {
                    con.close();
                }
                return r;
            }
  • 相关阅读:
    51 nod 1181 质数中的质数(质数筛法)
    Just oj 2018 C语言程序设计竞赛(高级组)F:Star(结构体排序+最小生成树)
    欧拉函数+费马小定理拓展
    ZOJ 3785 What day is that day?(数论:费马小定理)
    Just oj 2018 C语言程序设计竞赛(高级组)H: CBT?
    树链剖分(入门学习)
    bitset用法
    链式前向星
    Nearest Common Ancestors(LCA板子)
    LCA(最近公共祖先)
  • 原文地址:https://www.cnblogs.com/snowguest/p/12094771.html
Copyright © 2011-2022 走看看