private bool DoRealPost(string previews) { string _type = (previews != "") ? "link" : "text"; try { MR_posts_new _np = Main.Current.RT.REST.Posts_New(StringUtility.RichTextBox_ReplaceNewline(MyParent.pureTextBox.Text), "", previews, _type); if (_np == null) { MessageBox.Show(I18n.L.T("PostForm.PostError"), "Waveface", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } Main.Current.ShowStatuMessage(I18n.L.T("PostForm.PostSuccess"), true); Main.Current.GetAllDataAsync(ShowTimelineIndexType.LocalLastRead, true); return(true); } catch (Exception _e) { MessageBox.Show(_e.Message); return(false); } }
private bool DoRealPost(string files) { string _type = (files != "") ? "image" : "text"; try { MR_posts_new _np = Main.Current.RT.REST.Posts_New(StringUtility.RichTextBox_ReplaceNewline(MyParent.pureTextBox.Text), files, "", _type); if (_np == null) { MessageBox.Show(I18n.L.T("PostForm.PostError"), "Waveface", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } MessageBox.Show(I18n.L.T("PostForm.PostSuccess"), "Waveface", MessageBoxButtons.OK, MessageBoxIcon.Information); return(true); } catch (Exception _e) { MessageBox.Show(_e.Message); return(false); } }
public MR_posts_new Posts_New(string text, string files, string previews, string type) { if (!IsNetworkAvailable) { return(null); } MR_posts_new _ret = null; try { _ret = m_service.posts_new(SessionToken, m_rt.CurrentGroupID, text, files, previews, type); } catch (Station401Exception _e) { Main.Current.Station401ExceptionHandler(_e.Message); } if (_ret != null) { if (_ret.status == "200") { return(_ret); } } return(null); }
private void btnSend_Click(object sender, EventArgs e) { if (!Main.Current.CheckNetworkStatus()) { return; } if (pureTextBox.Text.Trim().Equals(string.Empty)) { MessageBox.Show(I18n.L.T("TextEmpty"), "Waveface", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { try { MR_posts_new _np = Main.Current.RT.REST.Posts_New(StringUtility.RichTextBox_ReplaceNewline(pureTextBox.Text), "", "", "text"); if (_np == null) { MessageBox.Show(I18n.L.T("PostForm.PostError"), "Waveface", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } Main.Current.ShowStatuMessage(I18n.L.T("PostForm.PostSuccess"), true); Main.Current.GetAllDataAsync(ShowTimelineIndexType.LocalLastRead, true); SetDialogResult_Yes_AndClose(); } catch (Exception _e) { MessageBox.Show(_e.Message, "Waveface", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public bool PostText(string text) { try { MR_posts_new _np = Post_CreateNewPost(text, "", "", "text"); return(_np != null); } catch { return(false); } }
public MR_posts_new Post_CreateNewPost(string text, string files, string previews, string type) { MR_posts_new _postsNew = m_serviceV2.posts_new(SessionToken, RT.CurrentGroupID, text, files, previews, type); if ((_postsNew != null) && (_postsNew.status == "200")) { return(_postsNew); } else { return(null); } }
public bool PostLink(string text, string previews) { try { MR_posts_new _np = Post_CreateNewPost(text, "", previews, "link"); if (_np == null) { return(false); } return(true); } catch { return(false); } }
public bool PostDocs(string text, List <string> docs) { string _files = doPostDocs(docs); try { MR_posts_new _np = Post_CreateNewPost(text, _files, "", "doc"); if (_np == null) { return(false); } return(true); } catch { return(false); } }
public bool PostPhotos(string text, List <string> images) { string _files = postImages(images); try { MR_posts_new _np = Post_CreateNewPost(text, _files, "", "image"); if (_np == null) { return(false); } return(true); } catch { return(false); } }
private bool DoRealPost(string files) { try { MR_posts_new _np = Main.Current.RT.REST.Posts_New(richTextBox.Text, files, "", "rtf"); if (_np == null) { MessageBox.Show("Post Error!"); return(false); } MessageBox.Show("Post success!"); return(true); } catch (Exception _e) { MessageBox.Show(_e.Message); return(false); } }
private bool DoRealPost(string files) { string _type = (files != "") ? "doc" : "text"; try { MR_posts_new _np = Main.Current.RT.REST.Posts_New(StringUtility.RichTextBox_ReplaceNewline(MyParent.pureTextBox.Text), files, "", _type); if (_np == null) { MessageBox.Show("Post Error!"); return(false); } MessageBox.Show("Post success!"); return(true); } catch (Exception _e) { MessageBox.Show(_e.Message); return(false); } }
private NewPostItem BatchPhotoPost(NewPostItem newPost) { int _count = 0; string _tmpStamp = DateTime.Now.Ticks.ToString(); s_logger.Trace("[" + _tmpStamp + "]" + "BatchPhotoPost:" + newPost.Text + ", Files=" + newPost.Files.Count); string _ids = "["; while (true) { if (StartUpload) { string _file = newPost.Files[_count]; if (newPost.UploadedFiles.Keys.Contains(_file)) { _ids += "\"" + newPost.UploadedFiles[_file] + "\"" + ","; s_logger.Trace("[" + _tmpStamp + "]" + "Batch Sended Photo [" + _count + "]" + _file); } else { try { Downloading = true; if (!File.Exists(_file)) { // 原始檔案不存在. 作錯誤處裡 s_logger.Error("Image File does not exist: [" + _file + "]"); if (ShowFileMissDialog != null) { ShowFileMissDialog(_file); } while (Main.Current.NewPostThreadErrorDialogResult == DialogResult.None) { Thread.Sleep(500); } switch (Main.Current.NewPostThreadErrorDialogResult) { case DialogResult.Cancel: // Delete Post newPost.ErrorAndDeletePost = true; newPost.PostOK = false; return(newPost); case DialogResult.Yes: // Remove Picture s_logger.Error("Remove: [" + _file + "]"); newPost.Files.Remove(_file); newPost.PostOK = false; UpdateUI(int.MinValue, ""); return(newPost); case DialogResult.Retry: // DoNothing s_logger.Error("Ignore & Retry Miss File: [" + _file + "]"); newPost.PostOK = false; return(newPost); } } if (CheckStoragesUsage() <= 0) { if (CheckStoragesUsage() <= 0) //Hack { // 雲端個人儲存空間不足. 作錯誤處裡 s_logger.Error("(CheckStoragesUsage() <= 0)"); if (OverQuotaMissDialog != null) { OverQuotaMissDialog(""); } while (Main.Current.NewPostThreadErrorDialogResult == DialogResult.None) { Thread.Sleep(500); } switch (Main.Current.NewPostThreadErrorDialogResult) { case DialogResult.Cancel: // Delete Post newPost.ErrorAndDeletePost = true; newPost.PostOK = false; return(newPost); case DialogResult.Retry: // DoNothing newPost.PostOK = false; return(newPost); } } } string _text = new FileName(_file).Name; string _resizedImage = ImageUtility.ResizeImage(_file, _text, newPost.ResizeRatio, 100); MR_attachments_upload _uf = Main.Current.RT.REST.File_UploadFile(_text, _resizedImage, "", true); if (_uf == null) { newPost.PostOK = false; return(newPost); } _ids += "\"" + _uf.object_id + "\"" + ","; newPost.UploadedFiles.Add(_file, _uf.object_id); s_logger.Trace("[" + _tmpStamp + "]" + "Batch Upload Photo [" + _count + "]" + _file); string _localFile = Main.GCONST.CachePath + _uf.object_id + "_origin_" + _text; File.Copy(_file, _localFile); Downloading = false; } catch (Exception _e) { Downloading = false; NLogUtility.Exception(s_logger, _e, "BatchPhotoPost:File_UploadFile"); newPost.PostOK = false; return(newPost); } } _count++; int _counts = newPost.Files.Count; if (UpdateUI != null) { string _msg; if (Items.Count == 1) { _msg = string.Format(I18n.L.T("OnePostUpload"), _count, _counts - _count); } else { _msg = string.Format(I18n.L.T("MultiplePostUpload"), _count, _counts - _count, Items.Count - 1); } UpdateUI(_count * 100 / _counts, _msg); } if (_count == _counts) { break; } } else { newPost.PostOK = false; return(newPost); } } _ids = _ids.Substring(0, _ids.Length - 1); // 去掉最後一個"," _ids += "]"; try { MR_posts_new _np = Main.Current.RT.REST.Posts_New(newPost.Text, _ids, "", "image"); if (_np == null) { newPost.PostOK = false; return(newPost); } s_logger.Trace("[" + _tmpStamp + "]" + "Batch Post:" + newPost.Text + ", Files=" + newPost.Files.Count); } catch (Exception _e) { NLogUtility.Exception(s_logger, _e, "BatchPhotoPost:File_UploadFile"); newPost.PostOK = false; return(newPost); } newPost.PostOK = true; return(newPost); }