Example #1
0
        public void CalcLeaveTime()
        {
            string message = "{}";

            try
            {
                string    record = this.Request["record"];
                Hashtable ht     = JavaScriptConvert.DeserializeObject <Hashtable>(record);

                tlvleaapp obj = new tlvleaapp();
                obj.emno = ht["emno"].ToString();
                obj.frtm = Convert.ToDateTime(ht["fromdate"].ToString());
                obj.totm = Convert.ToDateTime(ht["todate"].ToString());

                lvleaappBll bll  = new lvleaappBll();
                string      json = bll.CalcLeaveTime(obj);

                message = "{status:'success'," + json + "}";
            }
            catch (Exception ex)
            {
                message = "{status:'failure',msg:'" + ExceptionPaser.Parse(HRMSRes.Public_Message_EditBad, ex, true) + "'}";
            }
            Response.Write(message);
        }
Example #2
0
        public void getEmpLeaveSettings()
        {
            string message;

            try
            {
                string record = this.Request["record"];

                Hashtable ht = JavaScriptConvert.DeserializeObject <Hashtable>(record);

                lvleaappBll bll = new lvleaappBll();

                LvSettingInfo lstSettings = bll.GetEmpLeaveSettings(ht["emno"].ToString(), ht["ltcd"].ToString(), Convert.ToDateTime(ht["fromdate"].ToString()));

                string json = JavaScriptConvert.SerializeObject(lstSettings);

                message = "{status:'success',msg:'" + json + "'}";

                Response.Write(message);
            }
            catch (Exception ex)
            {
                message = "{status:'failure',msg:'" + ExceptionPaser.Parse(HRMSRes.Public_Message_QueryFail, ex, true) + "'}";
                Response.Output.Write(message);
            }
        }
Example #3
0
        /// <summary>
        /// 从URL获取参数赋值
        /// </summary>
        private void GetUrlParamenter()
        {
            var param = Request["params"]; //RequestHelper.Get<string>("params");

            if (!string.IsNullOrEmpty(param))
            {
                param           = Base64Helper.Decode(param);
                WidgetParameter = JavaScriptConvert.DeserializeObject <Dictionary <string, object> >(param);
            }
            var tempFile = WidgetParameter["filename"];

            /*
             * update by glg 2011-6-22
             * update:
             *       orginal: if (WidgetParameter.ContainsKey("CssClass"))
             *       now:     if (WidgetParameter.ContainsKey("CssClass") || WidgetParameter.ContainsKey("cssclass"))
             * reason: 调用PasteNode()时 传入的参数为小写
             */
            if (WidgetParameter.ContainsKey("CssClass") || WidgetParameter.ContainsKey("cssclass"))
            {
                if (WidgetParameter.ContainsKey("CssClass"))
                {
                    WidgetParameter["CssClass"] = WidgetParameter["CssClass"].ToString().Replace(".", "_");
                }
                else
                {
                    WidgetParameter["cssclass"] = WidgetParameter["cssclass"].ToString().Replace(".", "_");
                }
            }
            else
            {
                WidgetParameter.Add("CssClass", Path.GetFileNameWithoutExtension(tempFile.ToString()).Replace(".", "_"));
            }

            if (tempFile != null)
            {
                var file = tempFile.ToString();

                if (file.StartsWith("/"))
                {
                    file = "~" + file;
                }
                VirtualWidgetPath = file;
            }
            Action        = RequestHelper.Get <string>("action");
            Target        = RequestHelper.Get <string>("target");
            NextId        = RequestHelper.Get <string>("nextid");
            TemplateGroup = RequestHelper.Get <string>("folder");
            FileName      = RequestHelper.Get <string>("file");

            /*
             * add by glg 2011-6-22
             * reson:粘贴样式时只传过来可复制的属性
             */
            if (string.Compare(Action, "paste", true) == 0 && !WidgetParameter.ContainsKey("id"))
            {
                WidgetParameter.Add("id", NextId);
            }
        }
Example #4
0
        /// <summary>
        /// 获取某个城市某个时间区间的成功率
        /// </summary>
        /// <param name="startDate">开始时间</param>
        /// <param name="EndDate">结束时间</param>
        /// <param name="citycode">成功率</param>
        private static Dictionary <string, string> GetSucessedPercent(string startDate, String EndDate, string citycode = "-1")
        {
            Dictionary <string, string> retDic = new Dictionary <string, string>();

            retDic.Add("Amount", "");
            retDic.Add("SuccessPercent", "");

            /**
             * 1.先登录cqa。
             * 2.查询成功率。
             * 3.低于设置百分比后,发送邮件警示。
             */
            double sucedPercent = 0;

            try
            {
                string param1        = HttpUtility.UrlEncode(startDate, Encoding.GetEncoding("utf-8"));
                string param2        = HttpUtility.UrlEncode(EndDate, Encoding.GetEncoding("utf-8"));
                string param3        = HttpUtility.UrlEncode("2016-10-01 00:00:00", Encoding.GetEncoding("utf-8"));
                string getUrl1       = string.Format("http://cqa.91bihu.com/chart/Getcount?cityid={3}&sourec={4}&topagentid=&ensure=1&c**t=0&fasttips=0&firststa={0}&firstend={1}&secondsta={2}&secondend={2}&thirdsta={2}&thirdend={2}", param1, param2, param3, citycode, Config.companyId);
                string getUrl1Result = HttpHelper.SimpleGetOrPostUrlData(getUrl1, "", "GET");
                Root   rootobj       = JavaScriptConvert.DeserializeObject <Root>(getUrl1Result);
                if (rootobj == null)
                {
                    return(retDic);
                }
                double Amount;
                foreach (var item in rootobj.quantity)
                {
                    double successQty, failQty;
                    double.TryParse(item.succeedQuantity.ToString(), out successQty);
                    double.TryParse(item.failureQuantity.ToString(), out failQty);
                    Amount = successQty + failQty;
                    double percent = 0;
                    if (successQty != 0 && failQty != 0)
                    {
                        percent = Math.Round((successQty * 1.0 / (successQty + failQty) * 1.0) * 100, 2);
                    }
                    else if (successQty != 0 && failQty == 0)
                    {
                        percent = 100.00;
                    }
                    else
                    {
                        percent = 0.0;
                    }
                    sucedPercent = percent;

                    retDic["Amount"]         = Amount.ToString();
                    retDic["SuccessPercent"] = sucedPercent.ToString();
                    break;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(retDic);
        }
Example #5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(string strJson, out string strOut)
 {
     strOut  = "更改账户信息失败";
     strJson = strJson.Replace("\"on\"", "\"1\"");
     strJson = strJson.Replace("\"off\"", "\"0\"");
     SmsServer.Model.SmsUser model = (SmsServer.Model.SmsUser)JavaScriptConvert.DeserializeObject(strJson, typeof(SmsServer.Model.SmsUser));
     return(dal.Update(model));
 }
Example #6
0
        public string Remove()
        {
            RemoveApplicationParams actionParams = JavaScriptConvert.DeserializeObject <RemoveApplicationParams>(JsonParams);

            int result = ManyouApplications.RemoveApplication(actionParams.AppIdList);

            return(GetResult(result > 0 ? result : 1));
        }
Example #7
0
        public void HashtableDeserialization()
        {
            string value = @"{""Name"":""Orange"", ""Price"":3.99, ""Expiry"":""01/24/2010 12:00:00""}";

            Hashtable p = JavaScriptConvert.DeserializeObject(value, typeof(Hashtable)) as Hashtable;

            Assert.AreEqual("Orange", p["Name"].ToString());
        }
Example #8
0
        public void SerializeDeserializeSetOnlyProperty()
        {
            string value = JavaScriptConvert.SerializeObject(new SetOnlyPropertyClass());

            SetOnlyPropertyClass c = JavaScriptConvert.DeserializeObject <SetOnlyPropertyClass>(value);

            Assert.AreEqual(c.Field, "Field");
        }
Example #9
0
        public void TypedHashtableDeserialization()
        {
            string value = @"{""Name"":""Orange"", ""Hash"":{""Expiry"":""01/24/2010 12:00:00""}}";

            TypedSubHashtable p = JavaScriptConvert.DeserializeObject(value, typeof(TypedSubHashtable)) as TypedSubHashtable;

            Assert.AreEqual("01/24/2010 12:00:00", p.Hash["Expiry"].ToString());
        }
Example #10
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!base.IsPostBack)
     {
         string code = "";
         if (base.Request.QueryString["code"] != null)
         {
             code = base.Request.QueryString["code"].ToString();
         }
         else
         {
             string RechargeUrl = string.Format("https://open.weixin.qq.com/connect/oauth2/authorize?appid={0}&redirect_uri=http://{1}/mobile/member/rechargeOnline.aspx&response_type=code&scope=snsapi_base&state=0#wechat_redirect", PubFunction.curParameter.strWeiXinAppID, PubFunction.curParameter.strDoMain);
             base.Response.Redirect(RechargeUrl);
         }
         if (code != "")
         {
             string getAuthorize = this.GetAuthorize(code);
             getAuthorize = "[" + getAuthorize + "]";
             JavaScriptArray  javascript = (JavaScriptArray)JavaScriptConvert.DeserializeObject(getAuthorize);
             JavaScriptObject obj        = (JavaScriptObject)javascript[0];
             if (obj["openid"] != null && obj["openid"].ToString() != "")
             {
                 string openid = obj["openid"].ToString();
                 this.txtOpenID.Value = openid;
             }
         }
         if (this.Session["MemID"] != null)
         {
             int MemID = int.Parse(this.Session["MemID"].ToString());
             this.txtMemID.Value = MemID.ToString();
             this.BindMemInfo(MemID);
         }
         else
         {
             base.Response.Redirect("login.aspx");
         }
         Chain.Model.SysParameter parameter = new Chain.BLL.SysParameter().GetModel(1);
         this.txtMaxMoney.Value = parameter.Xiane.ToString();
         DateTime now = DateTime.Now;
         this.txtNow.Value = now.ToString();
         DateTime utcnow    = DateTime.UtcNow;
         string   timestamp = Convert.ToInt64((utcnow - new DateTime(1970, 1, 1, 0, 0, 0, 0)).TotalSeconds).ToString();
         this.timestamps.Value = timestamp;
         string systemDomain = parameter.SystemDomain;
         this.appid.Value = parameter.WeiXinAppID;
         string nonceStr = Guid.NewGuid().ToString().Replace("-", "");
         this.nonceStrs.Value = nonceStr;
         this.signTypes.Value = "MD5";
         string url         = base.Request.Url.ToString();
         Sign   sign        = new Sign();
         string jsapiTicket = sign.JsapiTicket(parameter.WeiXinAppID, parameter.WeiXinAppSecret);
         if (!(jsapiTicket == ""))
         {
             string signature = sign.ConfigSign(jsapiTicket, nonceStr, timestamp, url);
             this.signatures.Value = signature;
         }
     }
 }
        public void DeSerialize()
        {
            DateTimeTestClass c =
                JavaScriptConvert.DeserializeObject <DateTimeTestClass>(@"{""PreField"":""Pre"",""DateTimeField"":""@1229083932012@"",""PostField"":""Post""}", new AspNetAjaxDateTimeConverter());

            Assert.AreEqual(new DateTime(2008, 12, 12, 12, 12, 12, 12), c.DateTimeField);
            Assert.AreEqual("Pre", c.PreField);
            Assert.AreEqual("Post", c.PostField);
        }
Example #12
0
        private void webwxgetcontact()
        {
            ShowMsg("webwxgetcontact");
            if (true)
            {
                var url = "https://wx[number].qq.com/cgi-bin/mmwebwx-bin/webwxgetcontact?pass_ticket={pass_ticket}&r={time}&skey={SKEY}";

                HttpWebRequest h = (HttpWebRequest)HttpWebRequest.Create(ReplaceKey(url));
                h.AllowAutoRedirect = false;
                h.CookieContainer   = cookieContainer;
                //提取全部的cookie

                h.Accept = "application/json, text/plain, */*";
                HttpWebResponse  r       = (HttpWebResponse)h.GetResponse();
                CookieCollection cookies = r.Cookies;

                using (System.IO.StreamReader read = new System.IO.StreamReader(r.GetResponseStream()))
                {
                    string value = read.ReadToEnd();
                    USER_LIST = JavaScriptConvert.DeserializeObject(value) as JavaScriptObject;

                    //显示到list中
                    var arr = USER_LIST["MemberList"] as JavaScriptArray;
                    DataContractJsonSerializer jss = new DataContractJsonSerializer(typeof(FriendDataResponse));

                    data       = value.ConvertJson <FriendDataResponse>();
                    friendList = data;


                    foreach (JavaScriptObject o in arr)
                    {
                        USER_DI[o["UserName"] + ""] = o["NickName"] + "";
                        //NickName
                    }
                }
                r.Close();
                bool                 onlyFriend = ckOnlyFriend.Checked;
                List <Friend>        friends    = new List <Friend>();
                IEnumerable <Friend> ef;
                if (onlyFriend)
                {
                    ef = data.MemberList.Where(m =>
                    {
                        m.AliasDesc = m.UserName.Replace("@", "").Convert16ToString();
                        return(m.SelfDefineType == FriendDataCategory.Friend);
                    });
                }
                else
                {
                    ef = data.MemberList;
                }
                friends = ef.OrderBy(s => s.OrderByName).ToList();
                // data.MemberList.Sort(data.MemberList)
                ListBindDataSource(friends);
            }
        }
        public SubscriberDetail Get(string emailAddress)
        {
            NameValueCollection queryArguments = new NameValueCollection();

            queryArguments.Add("email", emailAddress);

            string json = HttpHelper.Get(string.Format("/subscribers/{0}.json", _listID), queryArguments);

            return(JavaScriptConvert.DeserializeObject <SubscriberDetail>(json));
        }
Example #14
0
        public void PersonTypedObjectDeserialization()
        {
            var store = new Store();

            var jsonText = JavaScriptConvert.SerializeObject(store);

            var deserializedStore = (Store)JavaScriptConvert.DeserializeObject(jsonText, typeof(Store));

            Console.WriteLine(jsonText);
        }
Example #15
0
        public void ReadOnlyCollectionSerialize()
        {
            var r1 = new ReadOnlyCollection <int>(new int[] { 0, 1, 2, 3, 4 });

            var jsonText = JavaScriptConvert.SerializeObject(r1);

            var r2 = JavaScriptConvert.DeserializeObject <ReadOnlyCollection <int> >(jsonText);

            CollectionAssert.AreEqual(r1, r2);
        }
Example #16
0
        public static List <ProxyInfo> GetProxyList_FromConfig(string configFilePath)
        {
            string json = File.ReadAllText(configFilePath, new UTF8Encoding(true, true));

            if (json.Trim() != string.Empty)
            {
                return((List <ProxyInfo>)JavaScriptConvert.DeserializeObject(json, typeof(List <ProxyInfo>)));
            }
            return(null);
        }
Example #17
0
        public void JavaScriptConvertSerializer()
        {
            string value = @"{""Name"":""Orange"", ""Price"":3.99, ""Expiry"":""01/24/2010 12:00:00""}";

            Product p = JavaScriptConvert.DeserializeObject(value, typeof(Product)) as Product;

            Assert.AreEqual("Orange", p.Name);
            Assert.AreEqual(new DateTime(2010, 1, 24, 12, 0, 0), p.Expiry);
            Assert.AreEqual(3.99, p.Price);
        }
Example #18
0
        public Order Query(Order order)
        {
            PayAndQueryFulu pay1 = new PayAndQueryFulu();

            string result = pay1.QueryOrder(order);

            // 直充商品:
            //{
            //    "code": 0,
            //    "message": "接口调用成功",
            //    "result": "{\"area\":\"电信一区\",\"buy_num\":1,\"cards\":null,\"charge_account\":\"888888\",\"create_time\":\"2019-07-01 17:53:32\",\"customer_order_no\":\"201906281030191013526\",\"finish_time\":\"2019-07-01 17:53:41\",\"operator_serial_number\":\"--\",\"order_id\":\"19070134869845421753\",\"order_price\":40.0,\"order_state\":\"success\",\"order_type\":4,\"product_id\":10000373,\"product_name\":\"qb5测试代充账号功能\",\"server\":\"逐鹿中原\",\"type\":\"Q币\"}",
            //    "sign": "06f351b34d9b02bc13bc62e66bdab2c8"
            //}
            //卡密商品:
            //{
            //    "code": 0,
            //    "message": "接口调用成功",
            //    "result": "{\"area\":null,\"buy_num\":2,\"cards\":[{\"CardNumber\":\"12nCp6X/nALmrvr1erxK+D4L8n/kqz/RItKWUfvZrCU=\",\"CardPwd\":\"9HeOgdv+NpLihh2+5Gm0Mj4L8n/kqz/RItKWUfvZrCU=\",\"CardDeadline\":\"2019-06-30 11:15:32\"},{\"CardNumber\":\"12nCp6X/nALmrvr1erxK+BzfvN8D1qbXOYunJrydEWA\",\"CardPwd\":\"9HeOgdv+NpLihh2+5Gm0MhzfvN8D1qbXOYunJrydEWA=\",\"CardDeadline\":\"2019-06-30 11:15:32\"}],\"charge_account\":null,\"create_time\":\"2019-07-01 17:55:38\",\"customer_order_no\":\"201906281230191013521\",\"finish_time\":\"2019-07-01 17:55:41\",\"operator_serial_number\":\"\",\"order_id\":\"19070116656844081755\",\"order_price\":8.9999,\"order_state\":\"success\",\"order_type\":3,\"product_id\":10000481,\"product_name\":\"入库出库专用卡密库存不要随便使用-jfs\",\"server\":null,\"type\":null}",
            //    "sign": "d440344a46479d3fa61883bcc2f1d983"
            //}
            JavaScriptObject jsonObj = (JavaScriptObject)JavaScriptConvert.DeserializeObject(result);

            string code    = jsonObj["code"].ToString();
            string message = jsonObj["message"].ToString();

            string resultJson = jsonObj["result"].ToString();

            JavaScriptObject jsonObj2    = (JavaScriptObject)JavaScriptConvert.DeserializeObject(resultJson);
            string           order_id    = jsonObj2["order_id"].ToString();
            string           order_state = jsonObj2["order_state"].ToString();

            //订单状态: (success:成功,processing:处理中,failed:失败,untreated:未处理)

            switch (order_state)
            {
            case "success":
                order.RechargeStatus = (int)OrderRechargeStatus.successful;
                order.RechargeMsg    = EnumService.GetDescription(OrderRechargeStatus.successful) + "-" + order_state;
                return(order);

            case "failed":

                order.RechargeStatus = (int)OrderRechargeStatus.failure;

                order.RechargeMsg = EnumService.GetDescription(OrderRechargeStatus.failure) + "-" + order_state;
                return(order);

            case "processing":
            case "untreated":
            default:
                break;
            }

            return(order);
        }
Example #19
0
        //https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxgetvoice?msgid=8332473900244757099&skey=@crypt_39864b32_3b5756470b541ab03f03f519c0f1d2a9
        //private Image DownLoadvoice(string MsgID)
        //{
        //    var url = "https://wx[number].qq.com/cgi-bin/mmwebwx-bin/webwxgetvoice?&msgid={0}&skey={1}";


        //    HttpWebRequest h = (HttpWebRequest)HttpWebRequest.Create(ReplaceHeaderKey(string.Format(url, MsgID, step4xml.skey)));
        //    h.AllowAutoRedirect = false;
        //    h.CookieContainer = cookieContainer;
        //    //h.Accept = "image/png,image/*;q=0.8,*/*;q=0.5";
        //    HttpWebResponse r = (HttpWebResponse)h.GetResponse();
        //    MemoryStream ms = new MemoryStream(r.GetResponseStream());
        //    r.Close();
        //    return ms;
        //}



        void doStep7()
        {
            if (__7)
            {
                //https://webpush.weixin.qq.com/cgi-bin/mmwebwx-bin/synccheck?r=1444004057053&skey=%40crypt_39864b32_c5aaad7d38892d44fde5da7e97b32e69&sid=iM3uR2da1I2t0Upy&uin=840648442&deviceid=e013657496826621&synckey=1_634979925%7C2_634981902%7C3_634981851%7C11_634981845%7C201_1444003994%7C1000_1443952994&_=1444003858911
                //var url = "https://webpush.weixin.qq.com/cgi-bin/mmwebwx-bin/synccheck?r={time}&skey={SKEY}&sid={SID}&uin={UIN}&deviceid={DeviceID}&synckey=1_634979925%7C2_634981902%7C3_634981851%7C11_634981845%7C201_1444003994%7C1000_1443952994&_=1444003858911

                //var url = "https://wx2.qq.com/cgi-bin/mmwebwx-bin/webwxsync?sid={SID}&r={time}&skey={SKEY}";
                var url = "https://wx[number].qq.com/cgi-bin/mmwebwx-bin/webwxsync?sid={SID}&skey={SKEY}&lang=zh_CN&pass_ticket={pass_ticket}";

                HttpWebRequest h = (HttpWebRequest)HttpWebRequest.Create(ReplaceKey(url));
                h.AllowAutoRedirect = false;
                h.CookieContainer   = cookieContainer;
                h.Method            = "POST";
                h.Accept            = "application/json, text/plain, */*";
                h.ContentType       = "application/json;charset=utf-8";

                byte[] bs = Encoding.ASCII.GetBytes(ReplaceHeaderKey(@"{""BaseRequest"":{""Uin"":{UIN},""Sid"":""{SID}"",""Skey"":""{SKEY}"",""DeviceID"":""{DeviceID}""},""SyncKey"":{SyncKey},""rr"":{time}}"));
                using (Stream reqStream = h.GetRequestStream())
                {
                    reqStream.Write(bs, 0, bs.Length);
                    reqStream.Close();
                }

                HttpWebResponse r = (HttpWebResponse)h.GetResponse();

                //var list = GetAllCookies(cookieContainer);

                using (System.IO.StreamReader read = new System.IO.StreamReader(r.GetResponseStream()))
                {
                    string value = read.ReadToEnd();

                    if (value.IndexOf("\"SyncKey\": ") == -1)
                    {
                        throw new Exception("SyncKey 没有捕获到");
                    }

                    SyncKey  = SubString(value.Replace("\r", "").Replace("\n", ""), "\"SyncKey\": ", "}]}");
                    SyncKey += "}]}";

                    //得到用户的消息
                    JavaScriptObject ret = JavaScriptConvert.DeserializeObject(value) as JavaScriptObject;
                    JavaScriptArray  arr = ret["AddMsgList"] as JavaScriptArray;
                    foreach (JavaScriptObject obj in arr)
                    {
                        var content = obj["Content"].ToString().Replace("&gt;", ">").Replace("&lt;", "<").Replace("<br/>", "");
                        ShowMsg(content, obj);

                        //处理消息
                        DoMsg(content, obj, obj["MsgId"] + "");
                    }
                }
                r.Close();
            }
        }
Example #20
0
        public void JsonIgnoreAttributeTest()
        {
            string json = JavaScriptConvert.SerializeObject(new JsonIgnoreAttributeTestClass());

            Assert.AreEqual(@"{""Field"":0,""Property"":21}", json);

            var c = JavaScriptConvert.DeserializeObject <JsonIgnoreAttributeTestClass>(@"{""Field"":99,""Property"":-1,""IgnoredField"":-1}");

            Assert.AreEqual(0, c.IgnoredField);
            Assert.AreEqual(99, c.Field);
        }
Example #21
0
        public static string Create(string clientID, string title, string unsubscribePage, bool confirmedOptIn, string confirmationSuccessPage)
        {
            string json = HttpHelper.Post(string.Format("/lists/{0}.json", clientID), null, JavaScriptConvert.SerializeObject(
                                              new ListDetail()
            {
                Title = title, UnsubscribePage = unsubscribePage, ConfirmedOptIn = confirmedOptIn, ConfirmationSuccessPage = confirmationSuccessPage
            })
                                          );

            return(JavaScriptConvert.DeserializeObject <string>(json));
        }
Example #22
0
        /// <summary>
        /// 分片上传
        /// </summary>
        /// <param name="bucketName">bucket名称</param>
        /// <param name="remotePath">远程文件路径</param>
        /// <param name="localPath">本地文件路径</param>
        /// <param name="bizAttribute">biz属性</param>
        /// <param name="sliceSize">切片大小(字节),默认为1M,目前只支持1M</param>
        /// <param name="insertOnly">是否覆盖同名文件</param>
        /// <param name="paras"></param>
        /// <returns></returns>
        public string SliceUploadFile2(string bucketName, string remotePath, string fileName, byte[] fileContent,
                                       string bizAttribute = "", int sliceSize = SLICE_SIZE.SLIZE_SIZE_1M, int insertOnly = 1)
        {
            var fileSha  = SHA1.GetFileSHA1_new(fileContent);
            var fileSize = fileContent.Length;
            var result   = SliceUploadInit2(bucketName, remotePath, fileName, fileContent, fileSha, bizAttribute, sliceSize, insertOnly);

            ResultJson resultJson = (ResultJson)JavaScriptConvert.DeserializeObject(result, typeof(ResultJson));

            if (resultJson.code != 0)
            {
                return(result);
            }

            var data = resultJson.data;

            if (data.access_url != null)
            {
                var accessUrl = data.access_url;
                //Console.WriteLine("命中秒传" + accessUrl);
                return(result);
            }

            int retryCount = 0;
            var session    = data.session;

            sliceSize = data.slice_size;

            var sign = this.isSign ? this.signature : Sign.Signature(appId, secretId, secretKey, getExpiredTime(), bucketName);

            //总共重试三次
            for (long offset = 0; offset < fileSize; offset += sliceSize)
            {
                result     = SliceUploadData2(bucketName, remotePath, fileName, fileContent, fileSha, session, offset, sliceSize, sign);
                resultJson = (ResultJson)JavaScriptConvert.DeserializeObject(result, typeof(ResultJson));
                if (resultJson.code != 0)
                {
                    if (retryCount < 10)
                    {
                        ++retryCount;
                        offset -= sliceSize;
                        //Console.WriteLine("重试...");
                        continue;
                    }
                    else
                    {
                        //Console.WriteLine("upload fail");
                        return(result);
                    }
                }
            }

            return(SliceUploadFinish2(bucketName, remotePath, fileName, fileContent, fileSha, session));
        }
        public static void NewtonsoftConversionToObject()
        {
            for (int i = 0; i < Common.Iterations; i++)
            {
                Person art = (Person)
                             JavaScriptConvert.DeserializeObject(
                    Common.PersonJson, typeof(Person));

                TextWriter.Null.Write(art.ToString());
            }
        }
Example #24
0
        public string CreateCustomField(string fieldName, CustomFieldDataType dataType, List <string> options)
        {
            string json = HttpHelper.Post(string.Format("/lists/{0}/customfields.json", _listID), null, JavaScriptConvert.SerializeObject(
                                              new Dictionary <string, object>()
            {
                { "FieldName", fieldName }, { "DataType", dataType.ToString() }, { "Options", options }
            })
                                          );

            return(JavaScriptConvert.DeserializeObject <string>(json));
        }
Example #25
0
 internal static Object jsonToObj(String jsonStr, Type type)
 {
     try
     {
         return(JavaScriptConvert.DeserializeObject(jsonStr, type));
     }
     catch (Exception e) {
         Console.WriteLine("json数据异常:" + e.Message);
         return(null);
     }
 }
Example #26
0
        public static string Create(string clientID, string subject, string name, string fromName, string fromEmail, string replyTo, string htmlUrl, string textUrl, List <string> listIDs, List <string> segmentIDs)
        {
            string json = HttpHelper.Post(string.Format("/campaigns/{0}.json", clientID), null, JavaScriptConvert.SerializeObject(
                                              new Dictionary <string, object>()
            {
                { "Subject", subject }, { "Name", name }, { "FromName", fromName }, { "FromEmail", fromEmail }, { "ReplyTo", replyTo }, { "HtmlUrl", htmlUrl }, { "TextUrl", textUrl }, { "ListIDs", listIDs }, { "SegmentIDs", segmentIDs }
            })
                                          );

            return(JavaScriptConvert.DeserializeObject <string>(json));
        }
        public static void NewtonsoftConversionToGenericObject()
        {
            for (int i = 0; i < Common.Iterations; i++)
            {
                JavaScriptObject art = (JavaScriptObject)
                                       JavaScriptConvert.DeserializeObject(
                    Common.PersonJson, typeof(JavaScriptObject));

                TextWriter.Null.Write(art["Name"]);
            }
        }
Example #28
0
        private static object deserializeInputStream(Stream inputStream)
        {
            string data;

            using (StreamReader reader = new StreamReader(inputStream))
            {
                data = Encoding.UTF8.GetString(Convert.FromBase64String(reader.ReadToEnd()));
            }

            return(JavaScriptConvert.DeserializeObject(data));
        }
Example #29
0
        private string UpdateUserAppFieldsInfo()
        {
            SetUserAppFieldsInfoParams actionParams = JavaScriptConvert.DeserializeObject <SetUserAppFieldsInfoParams>(UnicodeToString(JsonParams));

            UserApplicationInfo userAppInfo = ManyouApplications.GetUserApplicationInfo(actionParams.UId, actionParams.AppId.ToString())[0];

            userAppInfo.MYML        = actionParams.Markup != "" ? actionParams.Markup : userAppInfo.MYML;
            userAppInfo.ProfileLink = actionParams.ActionMarkup != "" ? actionParams.ActionMarkup : userAppInfo.ProfileLink;

            return(GetResult(ManyouApplications.UpdateUserApplication(userAppInfo)));
        }
        public static void NewtonsoftConversionToHashtable()
        {
            for (int i = 0; i < Common.Iterations; i++)
            {
                Hashtable art = (Hashtable)
                                JavaScriptConvert.DeserializeObject(
                    Common.PersonJson, typeof(Hashtable));

                TextWriter.Null.Write(art["Name"]);
            }
        }