private bool PostTheUpdate() { LocationFinder.StopGPS(); if (!string.IsNullOrEmpty(StatusText)) { Cursor.Current = Cursors.WaitCursor; string UpdateText = TrimTo140(StatusText); if (string.IsNullOrEmpty(UpdateText)) { MessageBox.Show("There was an error shortening the text. Please shorten the message or try again later."); return false; } if (!string.IsNullOrEmpty(picturePath) && pictureService.CanUploadMessage && ClientSettings.SendMessageToMediaService ) { PicturePostObject ppo = new PicturePostObject(); ppo.Filename = picturePath; ppo.Username = AccountToSet.UserName; ppo.Password = AccountToSet.Password; ppo.Message = StatusText; if (pictureService.CanUploadGPS && this.GPSLocation != null) { try { ppo.Lat = GPSLocation.Split(',')[0]; ppo.Lon = GPSLocation.Split(',')[1]; } catch { } } return pictureService.PostPictureMessage(ppo); } else { Yedda.Twitter TwitterConn = new Yedda.Twitter(); TwitterConn.AccountInfo = this.AccountToSet; try { if (this.GPSLocation != null) { TwitterConn.SetLocation(this.GPSLocation); } } catch { } string retValue = TwitterConn.Update(UpdateText, in_reply_to_status_id, Yedda.Twitter.OutputFormatType.XML); uploadedPictureURL = string.Empty; uploadingPicture = false; if (string.IsNullOrEmpty(retValue)) { MessageBox.Show("Error posting status -- empty response. You may want to try again later."); return false; } try { Library.status.DeserializeSingle(retValue, AccountToSet); } catch { MessageBox.Show("Error posting status -- bad response. You may want to try again later."); return false; } return true; } } return true; }
private bool PostTheUpdate() { LocationFinder.StopPosition(); if (!string.IsNullOrEmpty(StatusText) || (!string.IsNullOrEmpty(picturePath) && pictureService.CanUploadMessage && ClientSettings.SendMessageToMediaService)) { Cursor.Current = Cursors.WaitCursor; var updateText = TrimTo140(StatusText); if(updateText.Length>140) { if (PockeTwit.Localization.LocalizedMessageBox.Show("The text is still too long. If you post it twitter will cut off the end. Post anyway?", "Long Text", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == System.Windows.Forms.DialogResult.No) { return false; } } if (!string.IsNullOrEmpty(picturePath) && pictureService.CanUploadMessage && ClientSettings.SendMessageToMediaService ) { PicturePostObject ppo = new PicturePostObject(); ppo.Filename = picturePath; ppo.Username = AccountToSet.UserName; ppo.Password = AccountToSet.Password; ppo.Message = StatusText; if (pictureService.CanUploadGPS && GPSLocation != null) { try { ppo.Lat = GPSLocation.Split(',')[0]; ppo.Lon = GPSLocation.Split(',')[1]; } catch { } } return pictureService.PostPictureMessage(ppo); } else { Yedda.Twitter TwitterConn = new Yedda.Twitter(); TwitterConn.AccountInfo = AccountToSet; try { if (GPSLocation != null) { TwitterConn.SetLocation(GPSLocation); } } catch { } string retValue = string.Empty; string userID = IsDirectMessage(updateText); if (string.IsNullOrEmpty(userID)) retValue = TwitterConn.Update(updateText, in_reply_to_status_id, Yedda.Twitter.OutputFormatType.XML); else { retValue = TwitterConn.SendDirectMessage(userID, updateText.Substring(updateText.IndexOf(userID) + userID.Length + 1), in_reply_to_status_id, Yedda.Twitter.OutputFormatType.XML); } uploadedPictureURL = string.Empty; uploadingPicture = false; if (string.IsNullOrEmpty(retValue)) { PockeTwit.Localization.LocalizedMessageBox.Show("Error posting status -- empty response. You may want to try again later."); return false; } try { Library.status.DeserializeSingle(retValue, AccountToSet); } catch { PockeTwit.Localization.LocalizedMessageBox.Show("Error posting status -- bad response. You may want to try again later."); return false; } return true; } } return true; }