void IWriteContext.Append(string key, string[] subkeys, string[] subvalues)
        {
            IWriteContext ins = new WriteContextByJson();

            ins.Append(subkeys, subvalues);
            if (sb.Length != 0)
            {
                sb.Append(",");
            }
            sb.Append("\"" + key + "\":" + ins.ToString());
        }
Esempio n. 2
0
 public string request(string par_url)
 {
     while (1 == 1)
     {
         System.Threading.Thread.Sleep(100);
         if (doing == false)
         {
             try
             {
                 doing = true;
                 string         url = this.url + par_url;
                 HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
                 req.KeepAlive        = false;
                 req.Timeout          = 60 * 1000;
                 req.ReadWriteTimeout = 60 * 1000;
                 req.CookieContainer  = cookie;
                 //
                 ReadWriteContext.IWriteContext wc = new ReadWriteContext.WriteContextByJson();
                 wc.Append("none", "");
                 byte[] requestBytes = System.Text.Encoding.UTF8.GetBytes(wc.ToString());
                 req.Method = "POST";
                 Stream requestStream = req.GetRequestStream();
                 requestStream.Write(requestBytes, 0, requestBytes.Length);
                 requestStream.Close();
                 //
                 HttpWebResponse res = (HttpWebResponse)req.GetResponse();
                 res.Cookies = req.CookieContainer.GetCookies(req.RequestUri);
                 cookie      = new CookieContainer();
                 cookie.Add(res.Cookies);
                 Stream       stream = res.GetResponseStream();
                 StreamReader reader = new StreamReader(stream);
                 string       str    = reader.ReadToEnd();
                 stream.Close();
                 reader.Close();
                 //
                 doing = false;
                 //
                 returnJson = str;
                 rc         = new ReadWriteContext.ReadContextByJson(returnJson);
                 return(returnJson);
             }
             catch (Exception)
             {
                 throw;
             }
             finally
             {
                 doing = false;
             }
         }
     }
 }