示例#1
0
        public static void Test()
        {
            var log_path    = @"E:\Debug-20180628.txt;E:\Debug-20180629.txt;E:\Debug-20180630.txt;E:\Debug-20180701.txt;E:\Debug-20180702.txt;E:\Debug-20180703.txt;";
            var list_source = new List <string>();

            foreach (var path in log_path.Split(';', StringSplitOptions.RemoveEmptyEntries))
            {
                if (File.Exists(path))
                {
                    foreach (var s in File.ReadAllLines(path))
                    {
                        var index = s.IndexOf("request content:orders=");
                        if (index > 0)
                        {
                            list_source.Add(s.Substring(index).Replace("request content:orders=", ""));
                        }
                    }
                }
            }

            var sb = new StringBuilder();

            foreach (var s in list_source)
            {
                sb.AppendLine(formatXml(ComFunc.Base64DeCode(ComFunc.UrlDecode(s))));
            }

            File.WriteAllText("e:/hongxun.txt", sb.ToString());
        }
示例#2
0
        /// <summary>
        /// 将json中的特殊数据做转化
        /// </summary>
        /// <param name="v"></param>
        /// <returns></returns>
        ConvertData ConvertObject(object v)
        {
            var rtn = new ConvertData();

            if (v is string)
            {
                if (ComFunc.nvl(v).StartsWith("#2:"))
                {
                    var          bstr  = ComFunc.Base64DeCode(ComFunc.nvl(v));
                    var          bytes = Encoding.UTF8.GetBytes(bstr);
                    MemoryStream ms    = new MemoryStream(bytes);
                    rtn.Content = ms;
                }
                else if (ComFunc.nvl(v).StartsWith("#sql:"))
                {
                    rtn.DataType = DataType.Express;
                    rtn.Content  = ComFunc.nvl(v).Replace("#sql:", "");
                }
                else
                {
                    rtn.Content = v;
                }
            }
            else
            {
                rtn.Content = v;
            }
            return(rtn);
        }
        public static void Test()
        {
            HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://10.15.1.245:5001/dms/jiangsu/orders_hongxun");

            //HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://119.97.137.9:8080/dms/jiangsu/orders_hongxun");
            //HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://localhost:5002/dms/jiangsu/orders_hongxun");
            try
            {
                var    orders       = WebUtility.UrlEncode("PD94bWwgdmVyc2lvbj0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JfZGVsaXZfdGltZT4KCiAgICAgICAgICAgICAgICA8YnVpbGRfbmFtZT7okovlubPlubM8L2J1aWxkX25hbWU+CgogICAgICAgICAgICAgICAgPGJ1aWxkX3RlbD4xODkwMDAwMDAwMDwvYnVpbGRfdGVsPgoKICAgICAgICAgICAgICAgIDxkZXB0X2NvZGU+MTIxNjQ4Mjg8L2RlcHRfY29kZT4KCiAgICAgICAgICAgICAgICA8ZGVwdF9uYW1lPua2n+awtOWVhuS4muW5v+WcuuaMh+WumuS4k+iQpeW6lzwvZGVwdF9uYW1lPgoKICAgICAgICAgICAgICAgIDxkaXN0X2NvZGU+MTIxMDQyMzA8L2Rpc3RfY29kZT4KCiAgICAgICAgICAgICAgICA8ZGlzdF9uYW1lPuabvuWNju+8iOe7j+mUgOWVhu+8iXRlc3Q8L2Rpc3RfbmFtZT4KCiAgICAgICAgICAgICAgICA8b3JkZXJfbW9uZXk+MjA8L29yZGVyX21vbmV5PgoKICAgICAgICAgICAgICAgIDxkZWxpdl9uYW1lPua3ruWuieWQiOS9nOWOhTE8L2RlbGl2X25hbWU+CgogICAgICAgICAgICAgICAgPGRlbGl2X21vYmlsZT4xMzkwNTE5NDU4MTwvZGVsaXZfbW9iaWxlPgoKICAgICAgICAgICAgICAgIDxkZWxpdl9hZGRyZXNzPuS4reWkrui3rzQw5Y+3MTA25Y2V5YWDPC9kZWxpdl9hZGRyZXNzPgoKICAgICAgICAgICAgICAgIDxpc19tZWV0aW5nPjA8L2lzX21lZXRpbmc+CgogICAgICAgICAgICAgICAgPG1lZXRpbmdfbmFtZT48L21lZXRpbmdfbmFtZT4KCiAgICAgICAgICAgICAgICA8cGF5X21vZGU+MTwvcGF5X21vZGU+CgogICAgICAgICAgICAgICAgPGFsbF9wYXlfbW9uZXk+MjA8L2FsbF9wYXlfbW9uZXk+CgogICAgICAgICAgICAgICAgPG11bHRpcGx5X3BheT4KCiAgICAgICAgICAgICAgICAgICAgPHBheT4KCiAgICAgICAgICAgICAgICAgICAgICAgIDxwYXlfdGltZT4yMDE4MDMxMjE1MjMwNDwvcGF5X3RpbWU+CgogICAgICAgICAgICAgICAgICAgICAgICA8cGF5X21vbmV5PjIwPC9wYXlfbW9uZXk+CgogICAgICAgICAgICAgICAgICAgICAgICA8cGF5X3R5cGU+RkxLPC9wYXlfdHlwZT4KCiAgICAgICAgICAgICAgICAgICAgPC9wYXk+CgogICAgICAgICAgICAgICAgPC9tdWx0aXBseV9wYXk+CgogICAgICAgICAgICAgICAgPGl0ZW1fbGlzdD4KCiAgICAgICAgICAgICAgICAgICAgPGl0ZW0+CgogICAgICAgICAgICAgICAgICAgICAgICA8ZGV0YWlsX251bT5TMjAxODAzMTIxNTIyNDk3MjA2MDg8L2RldGFpbF9udW0+CgogICAgICAgICAgICAgICAgICAgICAgICA8Z29vZHNfdHlwZT5TUExYX1NKWkQ8L2dvb2RzX3R5cGU+CgogICAgICAgICAgICAgICAgICAgICAgICA8Z29vZHNfbnVtPkpTWUQtRERTQ1NQUC1ERFNDU1hINi0wMjwvZ29vZHNfbnVtPgoKICAgICAgICAgICAgICAgICAgICAgICAgPGdvb2RzX3ByaWNlPjEwPC9nb29kc19wcmljZT4KCiAgICAgICAgICAgICAgICAgICAgICAgIDxnb29kc19jb3VudD4yPC9nb29kc19jb3VudD4KCiAgICAgICAgICAgICAgICAgICAgPC9pdGVtPgoKICAgICAgICAgICAgICAgIDwvaXRlbV9saXN0PgoKICAgICAgICAgICAgICAgIDxnaWZ0X2xpc3QvPgoKICAgICAgICAgICAgPC9vcmRlcj4KCiAgICAgICAgICAgIDxvcmRlcj4KCiAgICAgICAgICAgICAgICA8aG9uZ3h1bl9vcmRlcl9ubz7puL/ov4XorqLljZXlj7c8L2hvbmd4dW5fb3JkZXJfbm8+CgogICAgICAgICAgICAgICAgPG9yZGVyX25vPkIyMDE4MDMxMjE1MjQ0MDcyMDYxNTwvb3JkZXJfbm8+CgogICAgICAgICAgICAgICAgPG9yZGVyX3N0YXR1cz48L29yZGVyX3N0YXR1cz4KCiAgICAgICAgICAgICAgICA8b3JkZXJfcmVnaW9uPjEyPC9vcmRlcl9yZWdpb24+CgogICAgICAgICAgICAgICAgPHJlZ2lvbl9uYW1lPua3ruWuiTwvcmVnaW9uX25hbWU+CgogICAgICAgICAgICAgICAgPGFyZWFfbnVtPjEyMTI8L2FyZWFfbnVtPgoKICAgICAgICAgICAgICAgIDxhcmVhX25hbWU+5raf5rC0PC9hcmVhX25hbWU+CgogICAgICAgICAgICAgICAgPGJ1aWxkX3RpbWU+MjAxODAzMTIxNTI0NDAxOTg8L2J1aWxkX3RpbWU+CgogICAgICAgICAgICAgICAgPG9yZGVyX2RlbGl2X3RpbWU+MjAxODAzMTIxNTI0NTc8L29yZGVyX2RlbGl2X3RpbWU+CgogICAgICAgICAgICAgICAgPGJ1aWxkX25hbWU+6JKL5bmz5bmzPC9idWlsZF9uYW1lPgoKICAgICAgICAgICAgICAgIDxidWlsZF90ZWw+MTg5MDAwMDAwMDA8L2J1aWxkX3RlbD4KCiAgICAgICAgICAgICAgICA8ZGVwdF9jb2RlPjEyMTY0ODI4PC9kZXB0X2NvZGU+CgogICAgICAgICAgICAgICAgPGRlcHRfbmFtZT7mtp/msLTllYbkuJrlub/lnLrmjIflrprkuJPokKXlupc8L2RlcHRfbmFtZT4KCiAgICAgICAgICAgICAgICA8ZGlzdF9jb2RlPjEyMTA0MjMwPC9kaXN0X2NvZGU+CgogICAgICAgICAgICAgICAgPGRpc3RfbmFtZT7mm77ljY7vvIjnu4/plIDllYbvvIl0ZXN0PC9kaXN0X25hbWU+CgogICAgICAgICAgICAgICAgPG9yZGVyX21vbmV5PjMwPC9vcmRlcl9tb25leT4KCiAgICAgICAgICAgICAgICA8ZGVsaXZfbmFtZT7mt67lronlkIjkvZzljoUxPC9kZWxpdl9uYW1lPgoKICAgICAgICAgICAgICAgIDxkZWxpdl9tb2JpbGU+MTM5MDUxOTQ1ODE8L2RlbGl2X21vYmlsZT4KCiAgICAgICAgICAgICAgICA8ZGVsaXZfYWRkcmVzcz7kuK3lpK7ot680MOWPtzEwNuWNleWFgzwvZGVsaXZfYWRkcmVzcz4KCiAgICAgICAgICAgICAgICA8aXNfbWVldGluZz4wPC9pc19tZWV0aW5nPgoKICAgICAgICAgICAgICAgIDxtZWV0aW5nX25hbWU+PC9tZWV0aW5nX25hbWU+CgogICAgICAgICAgICAgICAgPHBheV9tb2RlPjE8L3BheV9tb2RlPgoKICAgICAgICAgICAgICAgIDxhbGxfcGF5X21vbmV5PjMwPC9hbGxfcGF5X21vbmV5PgoKICAgICAgICAgICAgICAgIDxtdWx0aXBseV9wYXk+CgogICAgICAgICAgICAgICAgICAgIDxwYXk+CgogICAgICAgICAgICAgICAgICAgICAgICA8cGF5X3RpbWU+MjAxODAzMTIxNTI0NTc8L3BheV90aW1lPgoKICAgICAgICAgICAgICAgICAgICAgICAgPHBheV9tb25leT4zMDwvcGF5X21vbmV5PgoKICAgICAgICAgICAgICAgICAgICAgICAgPHBheV90eXBlPkZMSzwvcGF5X3R5cGU+CgogICAgICAgICAgICAgICAgICAgIDwvcGF5PgoKICAgICAgICAgICAgICAgIDwvbXVsdGlwbHlfcGF5PgoKICAgICAgICAgICAgICAgIDxpdGVtX2xpc3Q+CgogICAgICAgICAgICAgICAgICAgIDxpdGVtPgoKICAgICAgICAgICAgICAgICAgICAgICAgPGRldGFpbF9udW0+UzIwMTgwMzEyMTUyNDQwNzIwNjE2PC9kZXRhaWxfbnVtPgoKICAgICAgICAgICAgICAgICAgICAgICAgPGdvb2RzX3R5cGU+U1BMWF9TSlpEPC9nb29kc190eXBlPgoKICAgICAgICAgICAgICAgICAgICAgICAgPGdvb2RzX251bT5KU1lELUREU0NTUFAtRERTQ1NYSDYtMDI8L2dvb2RzX251bT4KCiAgICAgICAgICAgICAgICAgICAgICAgIDxnb29kc19wcmljZT4xMDwvZ29vZHNfcHJpY2U+CgogICAgICAgICAgICAgICAgICAgICAgICA8Z29vZHNfY291bnQ+MzwvZ29vZHNfY291bnQ+CgogICAgICAgICAgICAgICAgICAgIDwvaXRlbT4KCiAgICAgICAgICAgICAgICA8L2l0ZW1fbGlzdD4KCiAgICAgICAgICAgICAgICA8Z2lmdF9saXN0Lz4KCiAgICAgICAgICAgIDwvb3JkZXI+CgogICAgICAgIDwvb3JkZXJfbGlzdHM+CgogICAgPC9ib2R5PgoKPC9yZXF1ZXN0Pg==");
                var    b            = ComFunc.Base64DeCode(ComFunc.UrlDecode(orders));
                var    d            = FrameDLRObject.CreateInstance(b);
                byte[] requestBytes = System.Text.Encoding.UTF8.GetBytes($"orders={orders}");
                req.Method           = "POST";
                req.ContentType      = "application/x-www-form-urlencoded";
                req.ContentLength    = requestBytes.Length;
                req.Timeout          = 60000;
                req.ReadWriteTimeout = 60000;
                Stream requestStream = req.GetRequestStream();
                requestStream.Write(requestBytes, 0, requestBytes.Length);
                requestStream.Close();
                HttpWebResponse res     = (HttpWebResponse)req.GetResponse();
                StreamReader    sr      = new StreamReader(res.GetResponseStream(), System.Text.Encoding.UTF8);
                string          backstr = sr.ReadToEnd();
                requestStream = null;
                sr.Close();
                res.Close();
            }
            finally
            {
                req = null;
            }
        }
示例#4
0
 public string Base64Decode(string str)
 {
     return(ComFunc.Base64DeCode(str));
 }
示例#5
0
        public object InsertOrdersFromHongxun()
        {
            var content = ComFunc.UrlDecode(ComFunc.nvl(PostDataD.orders));

            var up = DB.NewDBUnitParameter();

            var xml = FrameDLRObject.CreateInstance(ComFunc.Base64DeCode(content));

            if (xml != null)
            {
                if (xml.error == null)
                {
                    List <object> listorder = new List <object>();
                    List <object> listpay   = new List <object>();
                    List <object> listgoods = new List <object>();
                    List <object> listgift  = new List <object>();
                    //查看是否只有一笔资料
                    if (xml.request.body.order_lists.order is FrameDLRObject)
                    {
                        var orderitem = xml.request.body.order_lists.order;
                        listorder.Add(copyOrderItem(orderitem));
                        var order_no = orderitem.order_no;
                        //pay
                        if (orderitem.multiply_pay != null && orderitem.multiply_pay != "")
                        {
                            var payitem = orderitem.multiply_pay.pay;
                            if (payitem is FrameDLRObject)
                            {
                                listpay.Add(copyPayItem(payitem, order_no));
                            }
                            else
                            {
                                List <object> payarray = payitem;
                                foreach (var obj in payarray)
                                {
                                    listpay.Add(copyPayItem(obj, order_no));
                                }
                            }
                        }
                        //goods
                        if (orderitem.item_list != null && orderitem.item_list != "")
                        {
                            var goodsobj = orderitem.item_list.item;
                            if (goodsobj is FrameDLRObject)
                            {
                                listgoods.Add(copyGoodsItem(goodsobj, order_no));
                            }
                            else
                            {
                                List <object> goodsarray = goodsobj;
                                foreach (var obj in goodsarray)
                                {
                                    listgoods.Add(copyGoodsItem(obj, order_no));
                                }
                            }
                        }
                        //gift
                        if (orderitem.gift_list != null && orderitem.gift_list != "")
                        {
                            var giftsobj = orderitem.gift_list.gift;
                            if (giftsobj is FrameDLRObject)
                            {
                                listgift.Add(copyGiftItem(giftsobj, order_no));
                            }
                            else
                            {
                                List <object> giftsarray = giftsobj;
                                foreach (var obj in giftsarray)
                                {
                                    listgift.Add(copyGiftItem(obj, order_no));
                                }
                            }
                        }
                    }
                    else
                    {
                        List <object> list = xml.request.body.order_lists.order;
                        foreach (dynamic orderitem in list)
                        {
                            listorder.Add(copyOrderItem(orderitem));
                            var order_no = orderitem.order_no;
                            //pay
                            if (orderitem.multiply_pay != null && orderitem.multiply_pay != "")
                            {
                                var payitem = orderitem.multiply_pay.pay;
                                if (payitem is FrameDLRObject)
                                {
                                    listpay.Add(copyPayItem(payitem, order_no));
                                }
                                else
                                {
                                    List <object> payarray = payitem;
                                    foreach (var obj in payarray)
                                    {
                                        listpay.Add(copyPayItem(obj, order_no));
                                    }
                                }
                            }
                            //goods
                            if (orderitem.item_list != null && orderitem.item_list != "")
                            {
                                var goodsobj = orderitem.item_list.item;
                                if (goodsobj is FrameDLRObject)
                                {
                                    listgoods.Add(copyGoodsItem(goodsobj, order_no));
                                }
                                else
                                {
                                    List <object> goodsarray = goodsobj;
                                    foreach (var obj in goodsarray)
                                    {
                                        listgoods.Add(copyGoodsItem(obj, order_no));
                                    }
                                }
                            }
                            //gift
                            if (orderitem.gift_list != null && orderitem.gift_list != "")
                            {
                                var giftsobj = orderitem.gift_list.gift;
                                if (giftsobj is FrameDLRObject)
                                {
                                    listgift.Add(copyGiftItem(giftsobj, order_no));
                                }
                                else
                                {
                                    List <object> giftsarray = giftsobj;
                                    foreach (var obj in giftsarray)
                                    {
                                        listgift.Add(copyGiftItem(obj, order_no));
                                    }
                                }
                            }
                        }
                    }

                    foreach (var item in listorder)
                    {
                        //DB.QuickInsert(up, "orders", item);
                        var dobj = (FrameDLRObject)item;
                        foreach (var k in dobj.Keys)
                        {
                            up.SetValue(k, dobj.GetValue(k));
                        }
                        DB.NonQuery <JiangSuUnit>(up, "addorderinfo");
                    }
                    foreach (var item in listpay)
                    {
                        //DB.QuickInsert(up, "orders_paymode", item);
                        var dobj = (FrameDLRObject)item;
                        foreach (var k in dobj.Keys)
                        {
                            up.SetValue(k, dobj.GetValue(k));
                        }
                        DB.NonQuery <JiangSuUnit>(up, "addorderpay");
                    }
                    foreach (var item in listgoods)
                    {
                        //DB.QuickInsert(up, "orders_goods", item);
                        var dobj = (FrameDLRObject)item;
                        foreach (var k in dobj.Keys)
                        {
                            up.SetValue(k, dobj.GetValue(k));
                        }
                        DB.NonQuery <JiangSuUnit>(up, "addordergoods");
                    }
                    foreach (var item in listgift)
                    {
                        //DB.QuickInsert(up, "orders_gifts", item);
                        var dobj = (FrameDLRObject)item;
                        foreach (var k in dobj.Keys)
                        {
                            up.SetValue(k, dobj.GetValue(k));
                        }
                        DB.NonQuery <JiangSuUnit>(up, "addordergift");
                    }
                }

                return("ok");
            }
            else
            {
                return("格式不正确或内容有问题");
            }
        }
        /// <summary>
        /// 从session中获取对象
        /// </summary>
        /// <param name="session"></param>
        /// <param name="key"></param>
        /// <returns></returns>
        public static object GetObject(this ISession session, string key)
        {
            var str = session.GetString(key);

            if (string.IsNullOrEmpty(str))
            {
                return(null);
            }
            var arr = str.Split(';');

            if (arr.Length != 2)
            {
                return(null);
            }
            var assemblefullname = arr[0];
            var base64           = arr[1];

            var value        = ComFunc.Base64DeCode(base64.Replace(" ", "+"));
            var typefullname = assemblefullname.Substring(0, assemblefullname.IndexOf(","));
            var t            = Type.GetType(assemblefullname);

            if (typefullname == typeof(string).FullName)
            {
                return(value);
            }
            if (typefullname == typeof(FrameDLRObject).FullName)
            {
                return((FrameDLRObject)FrameDLRObject.CreateInstance(value, FrameDLRFlags.SensitiveCase));
            }
            if (t.GetTypeInfo().GetInterface(typeof(IJSONParsable).Name, true) != null)
            {
                var obj = (IJSONParsable)Activator.CreateInstance(t);
                obj.TryParseJSON(value);
                return(obj);
            }
            if (typefullname == typeof(int).FullName)
            {
                return(int.Parse(value));
            }
            if (typefullname == typeof(long).FullName)
            {
                return(long.Parse(value));
            }
            if (typefullname == typeof(float).FullName)
            {
                return(float.Parse(value));
            }
            if (typefullname == typeof(double).FullName)
            {
                return(double.Parse(value));
            }
            if (typefullname == typeof(decimal).FullName)
            {
                return(decimal.Parse(value));
            }
            if (typefullname == typeof(DateTime).FullName)
            {
                return(DateTimeStd.ParseStd(value, "yyyy/MM/dd HH:mm:ss fff").Value);
            }
            if (typefullname == typeof(bool).FullName)
            {
                return(bool.Parse(value));
            }


            FrameDLRObject dobj = FrameDLRObject.CreateInstance(value, FrameDLRFlags.SensitiveCase);

            return(dobj.ToModel(t));
        }