Esempio n. 1
0
 public void showMsg(Status status)
 {
     txtMsg.Text = status.Msg;
     //txtMsg.Text += "\nStatus Code: " + status.Code.ToString();
     if ((status.Code == 201) || (status.Code == 200))
     {
         SystemSounds.Beep.Play();
     }
     else
     {
         SystemSounds.Asterisk.Play();
     }
 }
Esempio n. 2
0
 void Posted(Status status)
 {
     //this.Enabled = true;
     foreach (Control et in this.Controls)
     {
         et.Enabled = true;
     }
     this.Cursor = Cursors.Default;
     if ((status.Code != 201) || (!cbClose.Checked))
     {
         notice = new notify();
         notice.showMsg(status);
         notice.ShowDialog(this);
     }
     if ((status.Code == 201) && (cbClose.Checked))
     {
         this.Close();
     }
     //MessageBox.Show(this, Msg, "tumblr Communications - WinTumblr", MessageBoxButtons.OK, MessageBoxIcon.Information);
 }
Esempio n. 3
0
 void Posted(Status status)
 {
     btnValidate.Enabled = true;
     this.Cursor = Cursors.Default;
     notice = new notify();
     notice.showMsg(status); //notice.showAuthenticate(status.Msg);
     notice.ShowDialog(this);
 }
Esempio n. 4
0
 public void ActivateTumblrEvent(Status status)
 {
     TumblrEventArgs TumblrArgs = new TumblrEventArgs(status);
     if (TumblrEvent != null)
     {
         TumblrEvent(this, TumblrArgs);
     }
 }
Esempio n. 5
0
 private Status PostIt(byte[] data)
 {
     // Generic Post to Tumblr method
     HttpWebRequest myRequest;
     HttpWebResponse response = null;
     Stream newStream = null;
     Status status = new Status();
     // Prepare web request...
     myRequest = (HttpWebRequest)WebRequest.Create("http://www.tumblr.com/api/write");
     //myRequest.Proxy
     WebProxy myProxy;
     Uri newUri;
     if ((Proxy.UseProxy != null) && ((bool)Proxy.UseProxy))
     {
         try
         {
             myProxy = new WebProxy();
             newUri = new Uri(Proxy.ServerURL + ":" + Proxy.ServerPort);
             myProxy.Address = newUri;
             if ((Proxy.Domain != null) && (Proxy.Domain.Length > 0))
             {
                 myProxy.Credentials = new NetworkCredential(Proxy.UserName, Proxy.Password, Proxy.Domain);
             }
             else
             {
                 myProxy.Credentials = new NetworkCredential(Proxy.UserName, Proxy.Password);
             }
             myRequest.Proxy = myProxy;
         }
         catch (Exception ex)
         {
             status.Msg = Convert.ToString(ex.Message);
         }
     }
     myRequest.Credentials = CredentialCache.DefaultCredentials;
     myRequest.Method = "POST";
     myRequest.ContentType = "application/x-www-form-urlencoded; charset=utf-8";
     myRequest.ReadWriteTimeout = 600000; // Ten minutes - default should be 5 minutes. Change made due to timeout on larger uploads
     myRequest.Timeout = 600000;
     //header("Content-Type: text/html; charset=iso-8859-1");
     myRequest.ContentLength = data.Length;
     try
     {
         newStream = myRequest.GetRequestStream();
         // Send the data.
         newStream.WriteTimeout = 600000; // Ten minutes - Change made due to timeout on larger uploads. I wonder which is enforced? myRequest or the newStream.
         newStream.Write(data, 0, data.Length);
         // Get the response
         response = (HttpWebResponse)myRequest.GetResponse();
         status.Code = Convert.ToInt32(response.StatusCode);
         status.Msg = response.StatusDescription;
     }
     catch (ProtocolViolationException ex)
     {
         status.Msg = Convert.ToString(ex.Message);
     }
     catch (NotSupportedException ex)
     {
         status.Msg = Convert.ToString(ex.Message);
     }
     catch (WebException ex)
     {
         status.Msg = Convert.ToString(ex.Message);
     }
     catch (Exception e)
     {
         status.Msg = Convert.ToString(e.Message);
     }
     finally
     {
         if (response != null)
         {
             response.Close();
         }
         if (newStream != null)
         {
             newStream.Close();
         }
         ActivateTumblrEvent(status);
     }
     return status;
 }
Esempio n. 6
0
 public TumblrEventArgs(Status status)
 {
     this.message = status.Msg;
 }