public MR_posts_new posts_new(string session_token, string group_id, string content, string attachment_id_array, string preview, string type, string coverAttach, string share_email_list, string event_type, string favorite) { log.Info("start Post_new"); MR_posts_new _re = null; string post_id = genGuid(); post_id = System.Web.HttpUtility.UrlEncode(post_id); session_token = System.Web.HttpUtility.UrlEncode(session_token); group_id = System.Web.HttpUtility.UrlEncode(group_id); content = System.Web.HttpUtility.UrlEncode(content); attachment_id_array = System.Web.HttpUtility.UrlEncode(attachment_id_array); preview = System.Web.HttpUtility.UrlEncode(preview); share_email_list = System.Web.HttpUtility.UrlEncode(share_email_list); event_type = System.Web.HttpUtility.UrlEncode(event_type); favorite = System.Web.HttpUtility.UrlEncode(favorite); try { string _url = "https://develop.waveface.com:443/v3" + "/pio_posts/new"; string _parms = "post_id" + "=" + post_id + "&" + "apikey" + "=" + APIKEY + "&" + "session_token" + "=" + session_token + "&" + "content" + "=" + content + "&" + "type" + "=" + type + "&" + "favorite" + "=" + favorite + "&" + "event_type" + "=" + event_type + "&"; if (share_email_list != string.Empty) { _parms += "shared_email_list" + "=" + share_email_list + "&"; } if (attachment_id_array != string.Empty) { _parms += "attachment_id_array" + "=" + attachment_id_array + "&"; } if (preview != string.Empty) { _parms += "preview" + "=" + preview + "&"; } if (type == "image") { if (coverAttach != string.Empty) { _parms += "cover_attach" + "=" + coverAttach + "&"; } } _parms += "group_id" + "=" + group_id; WebPostHelper _webPos = new WebPostHelper(); bool _isOK = _webPos.doPost(_url, _parms, null); if (!_isOK) { return(null); } string _r = _webPos.getContent(); _responseMessage = _r; MR_posts_new _ret = JsonConvert.DeserializeObject <MR_posts_new>(_r); return(_ret); } catch (WebException _e) { if (_e.Status == WebExceptionStatus.ProtocolError) { HttpWebResponse _res = (HttpWebResponse)_e.Response; log.Error("Create POst_new, failed: " + _e.Data); log.Error("HttpWebResponse, return: " + _res); } } catch (Exception _e) { log.Error("Create POst_new, failed: " + _e.Data); } return(_re); }
// share private void Button_Click(object sender, RoutedEventArgs e) { char[] delimiterChars0 = { ';' }; // 0 get email setup setup_emailList(); string _emailStr = setup_emailList(); if (email_list.Items.Count <= 0) { bool result = checkAvailable(_emailStr); if (result == false) { // MessageBox.Show("email address ERROR!"); label_invalid.Visibility = Visibility.Visible; return; } } else if (AutoCompleteBox.Text != "") { //MessageBox.Show("email address ERROR!"); label_invalid.Visibility = Visibility.Visible; return; } if (_emailStr == "") { // MessageBox.Show("Plaese input shared email address!"); label_invalid.Visibility = Visibility.Visible; return; } arr = _emailStr.Split(delimiterChars0); foreach (string _mail in arr) { email_arr.Add(_mail); } SetBusyState(); int i = 0; // handle user press share button before upload finished do { System.Threading.Thread.Sleep(100); i++; } while (uploadFinished == false && i <= 1000); log.Info("3. create New Post "); // #region step 1& 2 (do by background worker) ////// 1. login //if (already_login == false) //{ // string data = callLogin(user, password); // textBox_return.Text = data; // already_login = true; //} //// 2. upload attachments ////Configure the ProgressBar //char[] delimiterChars = { '~' }; //arr = filename.Split(delimiterChars); //no_of_attachments = arr.Length; //foreach (string _mail in arr) //{ // string _data = callUploadAttachment(_mail); // textBox_return.Text += "object id= " + _data + "\r\n"; //} #endregion //// 3. new POST _ws.group_id = group_id; _ws.session_token = session_token; _ws.APIKEY = APIKEY; string object_id = _ws._object_id; string content = ""; string attachment_id_array = count_attachments(); // "[" + '"' + object_id.ToString() + '"' + "]"; string preview = ""; string type = "event"; string share_email_list = count_emails(); // "[" + '"' + email + '"' + "]"; string coverAttach = ""; string event_type = "favorite_shared"; string favorite = "0"; try { MR_posts_new ret_post = _ws.posts_new(session_token, group_id, content, attachment_id_array, preview, type, coverAttach, share_email_list, event_type, favorite); textBox_return.Text = "Upload 完畢! \r\n Create post_id= " + ret_post.post.post_id + ", " + ret_post.api_ret_message + " !"; textBox_return.Text += "\r\n\r\n" + _ws._responseMessage; email_list.Items.Clear(); AutoCompleteBox.Text = ""; } catch (Exception err) { // to log error textBox_return.Text = "return NULL, get image error!"; log.Error("Create New Post, return NULL: " + err.Message); // } //busy_flag.Visibility = Visibility.Visible; label_favorite.Visibility = Visibility.Visible; label_pass.Visibility = Visibility.Visible; log.Info("end of create new Post "); }