public void InterviewResponse_GetAnswers() { form.Clear(); Assert.AreEqual("", HotDocs.Sdk.Server.InterviewResponse.GetAnswers(form)); form.Add("HDInfo", "one"); form.Add("HDInfo", "two"); Assert.AreEqual("onetwo", HotDocs.Sdk.Server.InterviewResponse.GetAnswers(form)); }
/// <summary> /// 发布微博 /// </summary> public void Add() { nv.Clear(); nv = HttpContext.Current.Request.Form; string detail = nv["weibo"]; if (string.IsNullOrEmpty(detail)) { HttpContext.Current.Response.Write("参数错误"); return; } E_Weibo data = new E_Weibo(); data.EnterpriseID = ep.EnterpriceID; data.UserID = ep.UserID; data.Detail = MLMGC.COMP.Weibo.WeiboContent(detail); data.AddDate = DateTime.Now; bool flag = new T_Weibo().Add(data); if (flag) { //添加操作日志 new MLMGC.BLL.Enterprise.T_Log().Add(new MLMGC.DataEntity.Enterprise.E_Log() { EnterpriseID = ep.EnterpriceID, UserID = ep.UserID, LogTitle = "发布微博", IP = MLMGC.COMP.Requests.GetRealIP() }); //HttpContext.Current.Response.Write("{\"type\":\"succ\",\"data\":{\"weiboid\":" + data.WeiboID.ToString() + ",\"username\": \"" + data.TrueName + "\",\"date\": \"" + data.AddDate.ToString("HH:mm") + "\",\"showdate\":\"" + WEIBOHelper.ShowTime(data.AddDate) + "\",\"weibo\": \"" + data.Detail.Replace("\"", "'") + "\",\"img\":\"" + MLMGC.COMP.Config.GetEnterpriseAvatarUrl(data.Avatar) + "\"}}"); HttpContext.Current.Response.Write("succ"); } else { HttpContext.Current.Response.Write("error"); //HttpContext.Current.Response.Write("{\"type\":\"error\",\"data\":{\"weiboid\":0}}"); } }
/// <summary> /// 发布微博 /// </summary> public void Add() { nv.Clear(); nv = HttpContext.Current.Request.Form; string detail = nv["weibo"]; if (string.IsNullOrEmpty(detail)) { HttpContext.Current.Response.Write("参数错误"); return; } E_Weibo data = new E_Weibo(); data.PersonalID = pp.PersonalID; data.UserID = pp.UserID; data.Detail = MLMGC.COMP.Weibo.WeiboContent(detail); data.AddDate = DateTime.Now; bool flag = new T_Weibo().Add(data); if (flag) { HttpContext.Current.Response.Write("succ"); //HttpContext.Current.Response.Write("{\"type\":\"succ\",\"data\":{\"weiboid\":" + data.WeiboID.ToString() + ",\"username\": \"" + data.RealName + "\",\"date\": \"" + data.AddDate.ToString("HH:mm") + "\",\"showdate\":\"" + WEIBOHelper.ShowTime(data.AddDate) + "\",\"weibo\": \"" + data.Detail.Replace("\"", "'") + "\",\"img\":\"" + MLMGC.COMP.Config.GetPersonalAvatarUrl(data.Avatar) + "\"}}"); } else { //HttpContext.Current.Response.Write("{\"type\":\"error\",\"data\":{\"weiboid\":0}}"); HttpContext.Current.Response.Write("error"); } }
private string GenericReloadUrl(System.Collections.Specialized.NameValueCollection queryStrings) { string result; if (queryStrings == null || queryStrings.Count == 0) { result = base.Request.Url.AbsolutePath; } else { System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder(); stringBuilder.Append(base.Request.Url.AbsolutePath).Append("?"); foreach (string text in queryStrings.Keys) { string text2 = queryStrings[text].Trim().Replace("'", ""); if (!string.IsNullOrEmpty(text2) && text2.Length > 0) { stringBuilder.Append(text).Append("=").Append(base.Server.UrlEncode(text2)).Append("&"); } } queryStrings.Clear(); stringBuilder.Remove(stringBuilder.Length - 1, 1); result = stringBuilder.ToString(); } return(result); }
static void Main(string[] args) { Console.WriteLine("Connecting..."); try { Client = new PHP_C.Client(new Uri("http://localhost/php-c/PHP-C/"), true, "root", "admin"); Console.WriteLine("Connected!"); } catch (Exception ex) { Console.WriteLine(string.Format("Error: {0}", ex.Message)); } string INPUT = null; do { Console.Write("> "); INPUT = Console.ReadLine().ToLower(); switch (INPUT) { case "add": Console.Write("Key: "); string Key = Console.ReadLine(); Console.Write("Value: "); string Value = Console.ReadLine(); PostData.Add(Key, Value); break; case "print": Console.WriteLine(" ------ "); foreach (string key_loopVariable in PostData.Keys) { key = key_loopVariable; foreach (string value in PostData.GetValues(key)) { Console.WriteLine(key + " - " + value); } } Console.WriteLine(" ------ "); break; case "clear": PostData.Clear(); break; case "send": Response = Client.sendRequest(PostData); Console.WriteLine(Response.ToString()); Console.WriteLine(Response.Data.ToString()); break; } } while (true); }
/// <summary> /// 读取指定节下的所有键值对 /// </summary> /// <param name="path"></param> /// <param name="section"></param> /// <param name="values"></param> public static void ReadSections(string path, string section, System.Collections.Specialized.NameValueCollection values) { System.Collections.Specialized.StringCollection keys = new System.Collections.Specialized.StringCollection(); ReadSections(path, section, keys); values.Clear(); foreach (string key in keys) { values.Add(key, ReadIniValue(path, section, key)); } }
public string checkJobStatus() { string results = null; System.Collections.Specialized.NameValueCollection y = new System.Collections.Specialized.NameValueCollection(); y.Clear(); results = createJobPost(getRestURL() + "/molpro/jobs/" + jobId, y, "GET"); if (jobStatusCheck != null) { jobStatusCheck(parseReturnxml(results, "id"), parseReturnxml(results, "status"), parseReturnxml(results, "description")); } return(results); }
private void button1_Click(object sender, EventArgs e) { System.Net.WebClient WebClientObj = new System.Net.WebClient(); System.Collections.Specialized.NameValueCollection PostVars = new System.Collections.Specialized.NameValueCollection(); PostVars.Add("userPass", textBox2.Text.Trim()); PostVars.Add("userName", textBox1.Text.Trim()); PostVars.Add("platform", "android"); try { WebClientObj.Encoding = Encoding.UTF8; byte[] byRemoteInfo = WebClientObj.UploadValues("http://xxzy.xinkaoyun.com:8081/holidaywork/login", "POST", PostVars); //下面都没用啦,就上面一句话就可以了 string sRemoteInfo = System.Text.Encoding.UTF8.GetString(byRemoteInfo); LoginObj = JsonConvert.DeserializeObject <Root_1>(sRemoteInfo); PostVars.Clear(); PostVars.Add("token", LoginObj.data.andToken); byRemoteInfo = WebClientObj.UploadValues("http://xxzy.xinkaoyun.com:8081/holidaywork/student/getStudent", "POST", PostVars); sRemoteInfo = System.Text.Encoding.UTF8.GetString(byRemoteInfo); MessageBox.Show(LoginObj.msg); LoginObj_2 = JsonConvert.DeserializeObject <Root_2>(sRemoteInfo); if (LoginObj.msg == "登录成功") { this.Hide(); main.Show(); } //这是获取返回信息 } catch { } }
public ActionResult Check() { var code = Request.Form["code"]; var text = Request.Form["text"]; var wc = new xWebClient(); if (Session["cookies"] != null) { wc.CookieContainer = Session["cookies"] as CookieContainer; } var values = new System.Collections.Specialized.NameValueCollection(); values.Add("code", code); values.Add("textfield", text); var str = wc.UploadValues("http://gsxt.gdgs.gov.cn/aiccips/CheckEntContext/checkCode.html", values); var json = JObject.Parse(str); if ((int)json["flag"] != 1) { return(Content("验证码错误")); } values.Clear(); values.Add("code", code); values.Add("textfield", (string)json["textfield"]); var htmlStr = wc.UploadValues("http://gsxt.gdgs.gov.cn/aiccips/CheckEntContext/showInfo.html", values); var doc = new HtmlAgilityPack.HtmlDocument(); doc.LoadHtml(htmlStr); var nodes = doc.DocumentNode.SelectNodes("//div[@class='list']/ul"); var list = new List <object>(); foreach (var node in nodes) { var li1 = node.SelectSingleNode("li[1]/a"); var li2 = node.SelectSingleNode("li[2]"); var o = new { name = li1.InnerText, brief = li2.InnerText, data = li1.Attributes["href"].Value }; list.Add(o); } return(Content(JsonConvert.SerializeObject(list))); }
/// <summary> /// 模版数据添加完成后需调用此方法 /// </summary> /// <param name="className">列表项(li或者dd)的css类名</param> public void EndTemplateData(string className) { var itemName = "dd"; if (Type != "dl") { itemName = "li"; } if (className != string.Empty) { className = " class='" + className + "'"; } Sb.Append("<" + itemName + className + ">"); Sb.Append(GenerateString()); Sb.Append("</" + itemName + ">"); Nvc.Clear(); }
/// <summary> /// 模版数据添加完成后需调用此方法 /// </summary> /// <param name="className">列表项(li或者dd)的css类名</param> public static void EndTemplateData(string className) { string itemName = "dd"; if (type != "dl") { itemName = "li"; } if (className != string.Empty) { className = " class='" + className + "'"; } sb.Append("<" + itemName + className + ">"); sb.Append(GenerateString()); sb.Append("</" + itemName + ">"); nvc.Clear(); }
public ActionResult Check() { var code = Request.Form["code"]; var text = Request.Form["text"]; var wc = new xWebClient(); if (Session["cookies"] != null) wc.CookieContainer = Session["cookies"] as CookieContainer; var values = new System.Collections.Specialized.NameValueCollection(); values.Add("code", code); values.Add("textfield", text); var str = wc.UploadValues("http://gsxt.gdgs.gov.cn/aiccips/CheckEntContext/checkCode.html", values); var json = JObject.Parse(str); if ((int)json["flag"] != 1) return Content("验证码错误"); values.Clear(); values.Add("code", code); values.Add("textfield", (string)json["textfield"]); var htmlStr = wc.UploadValues("http://gsxt.gdgs.gov.cn/aiccips/CheckEntContext/showInfo.html", values); var doc = new HtmlAgilityPack.HtmlDocument(); doc.LoadHtml(htmlStr); var nodes = doc.DocumentNode.SelectNodes("//div[@class='list']/ul"); var list = new List<object>(); foreach (var node in nodes) { var li1 = node.SelectSingleNode("li[1]/a"); var li2 = node.SelectSingleNode("li[2]"); var o = new { name = li1.InnerText, brief = li2.InnerText, data = li1.Attributes["href"].Value }; list.Add(o); } return Content(JsonConvert.SerializeObject(list)); }
void b_Click(object sender, EventArgs e) { nvc.Clear(); nvc.Add("sysadmin", t1.Text); nvc.Add("admin", t2.Text); nvc.Add("kassa", t3.Text); nvc.Add("tech", t4.Text); try { SaveSettings(); System.Windows.Forms.MessageBox.Show("Данные успешно сохранены!", "Сохранение.", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); if (SettingsChanged != null) { SettingsChanged(this); } } catch (Exception ex) { System.Windows.Forms.MessageBox.Show("При сохранении параметров произошла ошибка.\r\n" + ex.Message, "Сохранение.", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } p.Dispose(); }
public void UpdateIssue(IssueUpdate update, NetworkCredential credential, Action<string> stdout, Action<string> stderr) { var client = new Gurtle.WebClient(); System.Collections.Specialized.NameValueCollection data = new System.Collections.Specialized.NameValueCollection(1); if (update.Comment.Length > 0) { data.Add("comment", update.Comment); } client.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(Encoding.UTF8.GetBytes(credential.UserName + ":" + credential.Password))); client.UploadValues(CommentIssueUrl(update.Issue.Id), data); data.Clear(); client.UploadValues(CloseIssueUrl(update.Status, update.Issue.Id), data); }
/// <summary> /// 执行与释放或重置非托管资源相关的应用程序定义的任务。 /// </summary> public void Dispose() { if (_disposed) { return; } if (_headers != null) { _headers.Clear(); _headers = null; } if (_cookies != null) { _cookies.Clear(); _cookies = null; } if (_queryString != null) { _queryString.Clear(); _queryString = null; } if (_form != null) { _form.Clear(); _form = null; } if (_serverVariables != null) { _serverVariables.Clear(); _serverVariables = null; } if (_params != null) { _params.Clear(); _params = null; } if (_files != null) { _files.Dispose(); _files = null; } if (_inputStream != null) { try { _inputStream.Dispose(); } catch { } _inputStream = null; } _acceptTypes = null; _userAgent = null; _userLanguages = null; _contentEncoding = null; _contentType = null; _rawUrl = null; _url = null; _urlReferrer = null; _httpMethod = null; _protocolVersion = null; _localEndPoint = null; _remoteEndPoint = null; _userHostAddress = null; _userHostName = null; _binaryReadHandler = null; _disposed = true; }
//Added By abhishek public System.Collections.Specialized.NameValueCollection SignupManual(object parameters, GlobusHttpHelper globusHelper) { Array paramsArray = new object[4]; paramsArray = (Array)parameters; System.Collections.Specialized.NameValueCollection nvc = new System.Collections.Specialized.NameValueCollection(); string DBCUsername = BaseLib.Globals.DBCUsername; string DBCPAssword = BaseLib.Globals.DBCPassword; //GlobusHttpHelper globusHelper = new GlobusHttpHelper(); string ImageURL = string.Empty; string authenticitytoken = string.Empty; string capcthavalue = string.Empty; string Email = string.Empty;//"*****@*****.**"; string Password = string.Empty;//"1JESUS11"; string IPAddress = string.Empty; string IPPort = string.Empty; string IPUsername = string.Empty; string IPpassword = string.Empty; string emailData = (string)paramsArray.GetValue(0); string username = (string)paramsArray.GetValue(1); string name = (string)paramsArray.GetValue(2); string IP = (string)paramsArray.GetValue(3); bool Created = true; try { int Count = emailData.Split(':').Length; if (Count == 1) { Log("[ " + DateTime.Now + " ] => [ Uploaded Emails Not In correct Format ]"); Log("[ " + DateTime.Now + " ] => [ " + emailData + " ]"); } if (Count == 2) { Email = emailData.Split(':')[0].Replace("\0", ""); Password = emailData.Split(':')[1].Replace("\0", ""); } else if (Count == 4) { Email = emailData.Split(':')[0].Replace("\0", ""); Password = emailData.Split(':')[1].Replace("\0", ""); IPAddress = emailData.Split(':')[2]; IPPort = emailData.Split(':')[3]; } else if (Count == 6) { Email = emailData.Split(':')[0].Replace("\0", ""); Password = emailData.Split(':')[1].Replace("\0", ""); IPAddress = emailData.Split(':')[2]; IPPort = emailData.Split(':')[3]; IPUsername = emailData.Split(':')[4]; IPpassword = emailData.Split(':')[5]; } else { Log("[ " + DateTime.Now + " ] => [ Uploaded Emails Not In correct Format ]"); Log("[ " + DateTime.Now + " ] => [ " + emailData + " ]"); } } catch (Exception ex) { Log(ex.Message); Console.WriteLine("8 :" + ex.StackTrace); GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> TwitterSignup - SignupMultiThreaded() -- Email Pass --> " + ex.Message, Globals.Path_AccountCreatorErrorLog); GlobusFileHelper.AppendStringToTextfileNewLine("Error --> TwitterSignup - SignupMultiThreaded() -- Email Pass >>>> " + ex.Message + " || DateTime :- " + DateTime.Now, Globals.Path_TwtErrorLogs); } try { RaiseEvent_AddToDictionary(Email); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { if (IP.Split(':').Length == 4) { IPAddress = IP.Split(':')[0]; IPPort = IP.Split(':')[1]; IPUsername = IP.Split(':')[2]; IPpassword = IP.Split(':')[3]; } } catch (Exception ex) { Console.WriteLine("7 :" + ex.StackTrace); GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> TwitterSignup - SignupMultiThreaded() -- IP Split --> " + ex.Message, Globals.Path_AccountCreatorErrorLog); GlobusFileHelper.AppendStringToTextfileNewLine("Error --> TwitterSignup - SignupMultiThreaded() -- IP Split >>>> " + ex.Message + " || DateTime :- " + DateTime.Now, Globals.Path_TwtErrorLogs); } string url = "https://twitter.com/users/email_available?suggest=1&username=&full_name=&email=" + Email.Replace("@", "%40").Replace(" ", "") + "&suggest_on_username=true&context=signup"; string EmailCheck = globusHelper.getHtmlfromUrlIP(new Uri(url), IPAddress, IPPort, IPUsername, IPpassword, "https://twitter.com/signup", ""); if (EmailCheck.Contains("\"taken\":true")) { Log("[ " + DateTime.Now + " ] => [ Email : " + Email + " has already been taken. An email can only be used on one Twitter account at a time ]"); Created = false; GlobusFileHelper.AppendStringToTextfileNewLine(emailData.Replace("\0", ""), Globals.path_EmailAlreadyTaken); nvc.Clear(); return nvc; } //Get User name ..... try { username = username.Replace("\0", ""); Password = Password.Replace("\0", ""); if (!(username.Count() < 15 || Password.Count() > 6)) { if (username.Count() > 15) { Log("[ " + DateTime.Now + " ] => [ Username Must Not be greater than 15 character ]"); username = username.Remove(13); //Removes the extra characters } else if (Password.Count() < 6) { Log("[ " + DateTime.Now + " ] => [ Password Must Not be less than 6 char ]"); } } } catch (Exception ex) { Console.WriteLine("6 :" + ex.StackTrace); GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> TwitterSignup - SignupMultiThreaded() -- Check Username --> " + ex.Message, Globals.Path_AccountCreatorErrorLog); GlobusFileHelper.AppendStringToTextfileNewLine("Error --> TwitterSignup - SignupMultiThreaded() -- Check Username >>>> " + ex.Message + " || DateTime :- " + DateTime.Now, Globals.Path_TwtErrorLogs); } Random randm = new Random(); double cachestop = randm.NextDouble(); string pagesource2 = string.Empty; string textUrl = string.Empty; try { textUrl = globusHelper.getHtmlfromUrlIP(new Uri("https://twitter.com/signup"), IPAddress, IPPort, IPUsername, IPpassword, "", ""); string pagesource1 = globusHelper.getHtmlfromUrlIP(new Uri("https://www.google.com/recaptcha/api/js/recaptcha_ajax.js"), IPAddress, IPPort, IPUsername, IPpassword, "", ""); pagesource2 = globusHelper.getHtmlfromUrlIP(new Uri("https://www.google.com/recaptcha/api/challenge?k=6LfbTAAAAAAAAE0hk8Vnfd1THHnn9lJuow6fgulO&ajax=1&cachestop=" + cachestop + "&lang=en"), IPAddress, IPPort, IPUsername, IPpassword, "", ""); } catch (Exception ex) { Console.WriteLine("5 :" + ex.StackTrace); GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> TwitterSignup - SignupMultiThreaded() -- Getting Signup PageSource --> " + ex.Message, Globals.Path_AccountCreatorErrorLog); GlobusFileHelper.AppendStringToTextfileNewLine("Error --> TwitterSignup - SignupMultiThreaded() -- Getting Signup PageSource >>>> " + ex.Message + " || DateTime :- " + DateTime.Now, Globals.Path_TwtErrorLogs); } try { int IndexStart = pagesource2.IndexOf("challenge :"); if (IndexStart > 0) { string Start = pagesource2.Substring(IndexStart); int IndexEnd = Start.IndexOf("',"); string End = Start.Substring(0, IndexEnd).Replace("challenge :", "").Replace("'", "").Replace(" ", ""); capcthavalue = End; ImageURL = "https://www.google.com/recaptcha/api/image?c=" + End; } else { Log("[ " + DateTime.Now + " ] => [ Cannot Find challenge Captcha on Page. Email : Password --> " + Email + ":" + Password + ":" + IPAddress + ":" + IPPort + ":" + IPUsername + ":" + IPpassword + " ]"); GlobusFileHelper.AppendStringToTextfileNewLine(Email + ":" + Password + ":" + IPAddress + ":" + IPPort + ":" + IPUsername + ":" + IPpassword, Globals.Path_CaptchaRequired); nvc.Clear(); return nvc; } } catch (Exception ex) { Console.WriteLine("1 :" + ex.StackTrace); GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> TwitterSignup - SignupMultiThreaded() -- Getting Image Url --> " + ex.Message, Globals.Path_AccountCreatorErrorLog); GlobusFileHelper.AppendStringToTextfileNewLine("Error --> TwitterSignup - SignupMultiThreaded() -- Getting Image Url >>>> " + ex.Message + " || DateTime :- " + DateTime.Now, Globals.Path_TwtErrorLogs); } WebClient webclient = new WebClient(); try { int intIPPort = 80; if (!string.IsNullOrEmpty(IPPort) && GlobusRegex.ValidateNumber(IPPort)) { intIPPort = int.Parse(IPPort); } ChangeIP_WebClient(IPAddress, intIPPort, IPUsername, IPpassword, ref webclient); } catch (Exception ex) { GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> TwitterSignup - SignupMultiThreaded() -- ChangeIP_WebClient() --> " + ex.Message, Globals.Path_AccountCreatorErrorLog); GlobusFileHelper.AppendStringToTextfileNewLine("Error --> TwitterSignup - SignupMultiThreaded() -- ChangeIP_WebClient() >>>> " + ex.Message + " || DateTime :- " + DateTime.Now, Globals.Path_TwtErrorLogs); } try { int StartIndex = textUrl.IndexOf("phx-signup-form"); if (StartIndex > 0) { string Start = textUrl.Substring(StartIndex); int EndIndex = Start.IndexOf("name=\"authenticity_token"); string End = Start.Substring(0, EndIndex).Replace("phx-signup-form", "").Replace("method=\"POST\"", "").Replace("action=\"https://twitter.com/account/create\"", ""); authenticitytoken = End.Replace("class=\"\">", "").Replace("<input type=\"hidden\"", "").Replace("class=\"\">", "").Replace("value=\"", "").Replace("\n", "").Replace("\"", "").Replace(" ", ""); } else { Log("[ " + DateTime.Now + " ] => [ Cannot find Authenticity Token On Page ]"); nvc.Clear(); return nvc; } } catch (Exception ex) { Console.WriteLine("2 :" + ex.StackTrace); GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> TwitterSignup - SignupMultiThreaded() -- Getting Authenticity --> " + ex.Message, Globals.Path_AccountCreatorErrorLog); GlobusFileHelper.AppendStringToTextfileNewLine("Error --> TwitterSignup - SignupMultiThreaded() -- Getting Authenticity >>>> " + ex.Message + " || DateTime :- " + DateTime.Now, Globals.Path_TwtErrorLogs); } string postData_SignUp = "user%5Bname%5D=" + username + "&user%5Bemail%5D=" + Email + "&user%5Buser_password%5D=" + Password + "&context=front&authenticity_token=" + authenticitytoken + ""; string res_PostSignUp = globusHelper.postFormData(new Uri("https://twitter.com/signup"), postData_SignUp, "", "", "", "", ""); int tempCount_usernameCheckLoop = 0; usernameCheckLoop: int tempCount_passwordCheckLoop = 0; if (username.Contains(" ")) { username = username.Replace(" ", "_"); } string headr = globusHelper.gResponse.Headers.ToString(); string Usernamecheck = globusHelper.getHtmlfromUrlIP(new Uri("https://twitter.com/users/username_available?suggest=1&username="******"&full_name=" + name + "&email=&suggest_on_username=true&context=signup"), IPAddress, IPPort, IPUsername, IPpassword, "https://twitter.com/signup", ""); //if (EmailCheck.Contains("\"taken\":true") // || res_PostSignUp.Contains("You already have an account with this username and password")) //{ // Log("Email : " + Email + " has already been taken. An email can only be used on one Twitter account at a time"); // Created = false; // GlobusFileHelper.AppendStringToTextfileNewLine(emailData.Replace("\0", ""), Globals.path_EmailAlreadyTaken); //} //else if (Usernamecheck.Contains("Username has already been taken")) { //Created = false; Log("[ " + DateTime.Now + " ] => [ Username : "******" has already been taken ]"); if (username.Count() > 12) { username = username.Remove(8); //Removes the extra characters } if (UsernameType == "String") { Log("[ " + DateTime.Now + " ] => [ Adding String To Username ]"); username = username + RandomStringGenerator.RandomString(5); } else if (UsernameType == "Numbers") { Log("[ " + DateTime.Now + " ] => [ Adding Numbers To Username ]"); username = username + RandomStringGenerator.RandomNumber(5); } else { Log("[ " + DateTime.Now + " ] => [ Adding Strings & Numbers To Username ]"); username = username + RandomStringGenerator.RandomStringAndNumber(5); Log("[ " + DateTime.Now + " ] => [ New user name :- " + username + " ]"); } if (username.Count() > 15) { username = username.Remove(13); //Removes the extra characters } tempCount_usernameCheckLoop++; if (tempCount_usernameCheckLoop < 5) { goto usernameCheckLoop; } } else if (EmailCheck.Contains("You cannot have a blank email address")) { Log("[ " + DateTime.Now + " ] => [ Email Address is Blank ]"); Created = false; } if (Created) { nvc.Add("Email", Email); nvc.Add("username", username); nvc.Add("name", name); nvc.Add("Password", Password); nvc.Add("authenticitytoken", authenticitytoken); nvc.Add("IPAddress", IPAddress); nvc.Add("IPpassword", IPpassword); nvc.Add("IPPort", IPPort); nvc.Add("IPUsername", IPUsername); nvc.Add("IPpassword", IPpassword); nvc.Add("capcthavalue", capcthavalue); nvc.Add("ImageURL", ImageURL); //nvc.Add("globusHelper", globusHelper); } return nvc; }
/// <summary> /// Exports all products from a Counter Intelligence DB into a CSV file for further upload. /// </summary> /// <returns></returns> public static void exportAllProducts(string sCsvFile) { Console.WriteLine("Extracting product data from the DB. " + DateTime.Now.ToString("s")); //Get data from the DB. The query is quite elaborate and had to be placed in an external file. SqlConnection connectionKudos = new SqlConnection(ConfigurationManager.ConnectionStrings["Kudos"].ConnectionString); connectionKudos.Open(); SqlCommand commandGetAllProducts = new SqlCommand(getSqlQuery("GetAllProducts"), connectionKudos); commandGetAllProducts.CommandTimeout = 0; SqlDataReader kudosReader = commandGetAllProducts.ExecuteReader(); //prepare a reusable connection for retrieving images SqlConnection connectionImages = new SqlConnection(ConfigurationManager.ConnectionStrings["Kudos"].ConnectionString); connectionImages.Open(); //pepare some constants string sUrlPathFormat = ConfigurationManager.AppSettings.Get("UrlPath"); //load IDs of data processed before. The IDs are stored in files as a list in plain text Hashtable arSavedImageIDs = GetExportedIDs("ImgIdx"); //Load the list of image files exported before Console.WriteLine("Loaded ImgIdx. " + DateTime.Now.ToString("s")); Hashtable arSavedRowIDs = GetExportedIDs("DataIdx"); //Load the list of rows exported before Console.WriteLine("Loaded DataIdx. " + DateTime.Now.ToString("s")); var arExtractedRowIDs = new Hashtable(arSavedRowIDs.Count); //This collection will contain IDs extracted this time to keep the list current ///Prepare the output CSV file var oCSV = new System.Collections.Specialized.NameValueCollection(); StringBuilder CSV = new StringBuilder(); string sRecord = ConfigurationManager.AppSettings.Get("TemplateAllProductsHeader"); //add the header row CSV.AppendLine(sRecord); //Loop through the recordset and read the data Console.WriteLine("Going through extracted data. " + DateTime.Now.ToString("s")); while (kudosReader.Read()) { oCSV.Add("style", kudosReader["code"].ToString()); string sSKU = kudosReader["id"].ToString(); oCSV.Add("sku", sSKU); oCSV.Add("description", kudosReader["idescrfull"].ToString()); oCSV.Add("short_description", kudosReader["idescrshort"].ToString()); oCSV.Add("price", kudosReader["price"].ToString()); oCSV.Add("special", kudosReader["special"].ToString()); oCSV.Add("color", kudosReader["color"].ToString()); oCSV.Add("colorid", kudosReader["colorid"].ToString()); oCSV.Add("product_barcode_", kudosReader["lookupnum"].ToString()); oCSV.Add("name", kudosReader["descr"].ToString()); oCSV.Add("sizetm", kudosReader["sizetm"].ToString()); oCSV.Add("brand", kudosReader["brand"].ToString()); oCSV.Add("qty", kudosReader["quantity"].ToString()); oCSV.Add("stockgroup", kudosReader["stockgroup"].ToString()); //Categories are separated by ; and may have a leading/trailing ; string sValue = kudosReader["category"].ToString(); if (sValue != null) { sValue = sValue.Trim(new char[] { ';' }); } oCSV.Add("_category", sValue); //branch stock data is separated by ; and may have a leading/trailing ; sValue = kudosReader["branches"].ToString(); if (sValue != null) { sValue = sValue.Trim(new char[] { ';' }); } oCSV.Add("branches", sValue); //Sizes get a weird . at the beginning in some products. We don't know what it means, if anything. sValue = kudosReader["size"].ToString(); if (sValue != null) { sValue = sValue.Trim(new char[] { '.' }); } oCSV.Add("size", sValue); // Get image details for the product string sImgIDs = kudosReader["imgids"].ToString(); if (sImgIDs != null) { sImgIDs = sImgIDs.Trim(new char[] { ';' }); } oCSV.Add("image", sImgIDs); //The row for the item is ready to be saved. It contains full item details. Additional rows will contain only some of the details. sRecord = buildCSVRow(oCSV); //use a hash of the row to check if the data changed string sHash = CalculateHash(sRecord, sSKU).ToString(); if (!arSavedRowIDs.Contains(sHash)) { //get any missing images RetrieveImages(connectionImages, arSavedImageIDs, sImgIDs); //add the record to the output CSV.AppendLine(sRecord); } //save the id in a new array to update the list if (!arExtractedRowIDs.Contains(sHash)) { arExtractedRowIDs.Add(sHash, null); } else { System.Diagnostics.EventLog.WriteEntry(Program.EventSourceName, "Duplicate hash " + sHash + " for: " + sRecord, System.Diagnostics.EventLogEntryType.Warning); } oCSV.Clear(); } connectionKudos.Close(); //Don't need the DB any more. //report progress Console.WriteLine("Saving data. " + DateTime.Now.ToString("s")); //Save the data in a temp file with a unique name System.IO.File.WriteAllText(sCsvFile, CSV.ToString()); //Save Image IDs in a file to avoid exporting them again if they were deleted SaveExportedIDs(arSavedImageIDs, "ImgIdx"); SaveExportedIDs(arExtractedRowIDs, "DataIdx"); }
public bool PostPictureOnFriendWall(ref FacebookUser fbUser,string Message,string FriendID, string Username, string Password, string localImagePath, string proxyAddress, string proxyPort, string proxyUsername, string proxyPassword, ref string status) { bool isSentPicMessage = false; string fb_dtsg = string.Empty; string photo_id = string.Empty; string UserId = string.Empty; string xhpc_composerid = string.Empty; string xhpc_targetid = string.Empty; string message_text = string.Empty; string picfilepath = string.Empty; string Response = string.Empty; try { GlobusHttpHelper HttpHelper = fbUser.globusHttpHelper; picfilepath = localImagePath; // string pageSource_Home = HttpHelper.getHtmlfromUrl(new Uri(FBGlobals.Instance.fbhomeurl)); string pageSource_Home = HttpHelper.getHtmlfromUrl(new Uri("https://www.facebook.com/profile.php?id=" + FriendID) ,"",""); UserId = GlobusHttpHelper.GetParamValue(pageSource_Home, "user"); if (string.IsNullOrEmpty(UserId)) { UserId = GlobusHttpHelper.ParseJson(pageSource_Home, "user"); } fb_dtsg = GlobusHttpHelper.GetParamValue(pageSource_Home, "fb_dtsg"); if (string.IsNullOrEmpty(fb_dtsg)) { fb_dtsg = GlobusHttpHelper.ParseJson(pageSource_Home, "fb_dtsg"); } string pageSource_HomeData = pageSource_Home; try { xhpc_composerid = GlobusHttpHelper.GetParamValue(pageSource_HomeData, "composerid"); } catch (Exception ex) { //GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } try { xhpc_targetid = GlobusHttpHelper.GetParamValue(pageSource_HomeData, "xhpc_targetid"); } catch (Exception ex) { // GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } string gridid = string.Empty; string qn = string.Empty; string source = string.Empty; string tagger_session_id = string.Empty; string hide_object_attachment = string.Empty; string is_file_form = string.Empty; string album_type = string.Empty; string composer_unpublished_photo= string.Empty; string clp = string.Empty; string xhpc_publish_type = string.Empty; string xhpc_context = string.Empty; string application = string.Empty; string xhpc_ismeta= string.Empty; string xhpc_timeline= string.Empty; string disable_location_sharing = string.Empty; try { Response = HttpHelper.postFormData(new Uri("https://www.facebook.com/ajax/composerx/attachment/media/upload/?__av=" + UserId + "&composerurihash=1"), "fb_dtsg=" + fb_dtsg + "&composerid=" + xhpc_composerid + "&targetid=" + FriendID + "&istimeline=1&composercontext=composer&onecolumn=1&loaded_components[0]=maininput&loaded_components[1]=prompt&loaded_components[2]=withtaggericon&loaded_components[3]=backdateicon&loaded_components[4]=placetaggericon&loaded_components[5]=ogtaggericon&loaded_components[6]=mainprivacywidget&loaded_components[7]=prompt&loaded_components[8]=backdateicon&loaded_components[9]=mainprivacywidget&loaded_components[10]=ogtaggericon&loaded_components[11]=withtaggericon&loaded_components[12]=placetaggericon&loaded_components[13]=maininput&nctr[_mod]=pagelet_timeline_recent&__user="******"&__a=1&__dyn=7n8ajEAMCBynzpQ9UoHFaeFDzECiq78hACF29aGEVFLFwxBxCbzESu49UJ6K4bBw&__req=w&ttstamp=26581728812272951201044890108&__rev=1391091"); } catch (Exception ex) { //GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } try { gridid = GlobusHttpHelper.getBetween(Response, "gridID\":\"", "\""); } catch (Exception ex) { // GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } try { qn = GlobusHttpHelper.getBetween(Response, "qn\\\" value=\\\"", "\\\""); } catch (Exception ex) { //GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } try { source = GlobusHttpHelper.getBetween(Response, "source\":", ","); } catch (Exception ex) { //GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } try { fb_dtsg = GlobusHttpHelper.getBetween(Response, "fb_dtsg\\\" value=\\\"", "\\\""); } catch (Exception ex) { //GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } try { tagger_session_id = GlobusHttpHelper.getBetween(Response, "tagger_session_id\\\" value=\\\"", "\\\""); } catch (Exception ex) { //GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } try { hide_object_attachment = GlobusHttpHelper.getBetween(Response, "hide_object_attachment\\\" value=\\\"", "\\\""); } catch (Exception ex) { //GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } try { is_file_form = GlobusHttpHelper.getBetween(Response, "is_file_form\\\" value=\\\"", "\\\""); } catch (Exception ex) { //GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } try { album_type = GlobusHttpHelper.getBetween(Response, "album_type\\\" value=\\\"", "\\\""); } catch (Exception ex) { //GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } try { composer_unpublished_photo = GlobusHttpHelper.getBetween(Response, "composer_unpublished_photo[]\\\" value=\\\"", "\\\""); } catch (Exception ex) { //GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } try { clp = "{\"cl_impid\":\"62172361\",\"clearcounter\":0,\"elementid\":\"u_0_1h\",\"version\":\"x\",\"parent_fbid\":" + FriendID + "}"; } catch (Exception ex) { //GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } try { xhpc_publish_type = GlobusHttpHelper.getBetween(Response, "xhpc_publish_type\\\" value=\\\"", "\\\""); } catch (Exception ex) { //GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } try { xhpc_context = GlobusHttpHelper.getBetween(Response, "xhpc_context\\\" value=\\\"", "\\\""); } catch (Exception ex) { //GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } try { application = GlobusHttpHelper.getBetween(Response, "application\":\"", "\""); } catch (Exception ex) { //GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } try { xhpc_ismeta = GlobusHttpHelper.getBetween(Response, "xhpc_ismeta\\\" value=\\\"", "\\\""); } catch (Exception ex) { //GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } try { xhpc_timeline = GlobusHttpHelper.getBetween(Response, "xhpc_timeline\\\" value=\\\"", "\\\""); } catch (Exception ex) { //GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } try { disable_location_sharing = GlobusHttpHelper.getBetween(Response, "disable_location_sharing\\\" value=\\\"", "\\\""); } catch (Exception ex) { //GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } System.Collections.Specialized.NameValueCollection nvc = new System.Collections.Specialized.NameValueCollection(); nvc.Add("fb_dtsg", fb_dtsg); nvc.Add("source", source); nvc.Add("profile_id", UserId); nvc.Add("grid_id", gridid); nvc.Add("qn", qn); nvc.Add("0", localImagePath); nvc.Add("upload_id","1025"); string response = string.Empty; try { response = HttpHelper.HttpUploadPictureForWallNew(ref HttpHelper, UserId, "https://upload.facebook.com/ajax/composerx/attachment/media/saveunpublished?target_id=" + FriendID + "&__av=" + UserId + "&__user="******"&__a=1&__dyn=7n8ajEAMBlynzpQ9UoHaEWCueyp9Esx6iWF29aGEVFLFwxBxCbzESu49UJ6K4bBw&__req=13&fb_dtsg=" + fb_dtsg + "&ttstamp=26581728812272951201044890108&__rev=1391091" + UserId + "&__a=1&fb_dtsg=" + fb_dtsg, "file1", "image/jpeg", localImagePath, nvc, proxyAddress, Convert.ToInt32(0), proxyUsername, proxyPassword, picfilepath); composer_unpublished_photo = GlobusHttpHelper.getBetween(response, "fbid\":\"", "\""); //fb_dtsg = Utils.getBetween(response, "fb_dtsg\\\" value=\\\"", "\\\""); } catch (Exception ex) { //GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } if (string.IsNullOrEmpty(response)) { try { response = HttpHelper.HttpUploadPictureForWall(ref HttpHelper, UserId, FBGlobals.Instance.PostPicOnWallPostUploadPhotosUrl + UserId + "&__a=1&fb_dtsg=" + fb_dtsg, "file1", "image/jpeg", localImagePath, nvc, proxyAddress, Convert.ToInt32(0), proxyUsername, proxyPassword, picfilepath); } catch (Exception ex) { //GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } } else { nvc.Clear(); nvc.Add("composer_session_id",""); nvc.Add("fb_dtsg", fb_dtsg); nvc.Add("xhpc_context", xhpc_context); nvc.Add("xhpc_ismeta", xhpc_ismeta); nvc.Add("xhpc_timeline", xhpc_timeline); nvc.Add("xhpc_composerid", xhpc_composerid); nvc.Add("xhpc_targetid", FriendID); nvc.Add("xhpc_publish_type", xhpc_publish_type); nvc.Add("clp", ""); nvc.Add("xhpc_message_text", Message); nvc.Add("xhpc_message", Message); nvc.Add("composer_unpublished_photo[]", composer_unpublished_photo); nvc.Add("album_type", album_type); nvc.Add("is_file_form", is_file_form); nvc.Add("oid",""); nvc.Add("qn", qn); nvc.Add("application", application); nvc.Add("backdated_date[year]","" ); nvc.Add("backdated_date[month]", ""); nvc.Add("backdated_date[day]", ""); nvc.Add("backdated_date[hour]", ""); nvc.Add("backdated_date[minute]", ""); nvc.Add("is_explicit_place", ""); nvc.Add("composertags_place", ""); nvc.Add("composertags_place_name", ""); nvc.Add("tagger_session_id", tagger_session_id); nvc.Add("action_type_id[]",""); nvc.Add("object_str[]", ""); nvc.Add("object_id[]", ""); nvc.Add("og_location_id[]", ""); nvc.Add("hide_object_attachment", hide_object_attachment); nvc.Add("og_suggestion_mechanism", ""); nvc.Add("og_suggestion_logging_data", ""); nvc.Add("icon_id", ""); nvc.Add("composertags_city", ""); nvc.Add("disable_location_sharing", disable_location_sharing); nvc.Add("composer_predicted_city",""); } string responsestring = HttpHelper.HttpUploadPictureForWallNewFinal(ref HttpHelper, UserId, "https://upload.facebook.com/media/upload/photos/composer/?__av="+UserId+"&__user="******"&__a=1&__dyn=7n8ajEAMBlynzpQ9UoHaEWCueyp9Esx6iWF29aGEVFLFwxBxCbzESu49UJ6K4bBw&__req=o&fb_dtsg="+fb_dtsg+"&ttstamp=26581691188750571181101086979&__rev=1391091", "file1", "image/jpeg", localImagePath, nvc, proxyAddress, Convert.ToInt32(0), proxyUsername, proxyPassword, picfilepath); if (responsestring.Contains("error") && !string.IsNullOrEmpty(responsestring)) { //string resp = HttpHelper.postFormData(new Uri("https://www.facebook.com/ajax/places/city_sharer_reset.php"), "target_id=0&__user="******"&__a=1&__dyn=7n8ajEAMBlynzpQ9UoHaEWCueyp9Esx6iWF29aGEVFLFwxBxCbzESu49UJ6K4bBw&__req=r&fb_dtsg=AQEvW29vnlEO&ttstamp=26581691188750571181101086979&__rev=1391091"); isSentPicMessage = true; } } catch (Exception ex) { //GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } return isSentPicMessage; }