Example #1
0
 public void WriteOldTest()
 {
     CookieContainer ck = new CookieContainer();
     Writer writer = new Writer("http://sweet.2ch.sc/test/read.cgi/kawaii/1438245456/");
     WriteResponse wr =  writer.Write("", "sage", "てすとてすと");
     wr.GetResult();
     Debug.WriteLine(wr.Result);
     WriteResponse wr2 = writer.Write("", "sage", "てすとてすと");
     wr2.GetResult();
     Debug.WriteLine(wr2.Result);
 }
 void WriteThread()
 {
     try
     {
         Writer writer = new Writer(URL);
         writer.CookieContainer = cc;
         //writer.CookieContainer.Add(new Cookie("READJS", "off") { Domain = new Uri(writer.PostURL).Host});
         //writer.CookieContainer.Add(new Cookie("MAIL", "") { Domain = new Uri(writer.PostURL).Host });
         //writer.CookieContainer.Add(new Cookie("NAME", "") { Domain = new Uri(writer.PostURL).Host });
         String Name = "", Mail = "", Message = "", Subject = "";
         Dispatcher.Invoke(new Action(() =>
         {
             Name = NameTextBox.Text;
             Mail = MailTextBox.Text;
             Message = MessageTextBox.Text;
             Subject = SubjectTextBox.Text;
         }));
         WriteResponse wr = writer.CreateThread(Name,Mail,Message,Subject);
         wr.GetResult();
         if (wr.Result == WriteResponse.WriteResult.True || wr.Result == WriteResponse.WriteResult.False)
         {
             //成功時
             Dispatcher.Invoke(new Action(() =>
             {
                 this.Close();
             }));
         }
         else
         {
             //たぶん何かのエラーだ
             Dispatcher.Invoke(new Action(() =>
             {
                 StatusLabel.Content = wr.Result;
             }));
         }
     }
     catch (Exception ex)
     {
         Dispatcher.Invoke(new Action(() =>
         {
             StatusLabel.Content = ex.ToString();
         }));
     }
 }