private void btnSendEmailInvite_Click(object sender, EventArgs e) { CheckNetConn = System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable(); if (CheckNetConn) { try { lstSearchconnectionThread.Clear(); if (IsStop) { IsStop = false; } if (_lstConnectionSearchKeyword.Count == 0) { MessageBox.Show("Please Add Keywords!"); AddLoggerManageConnection("[ " + DateTime.Now + " ] => [ Please Add Keywords! ]"); return; } else if (txtInviteMsg.Text.Contains("|")) { if (!(chkUseSpintax_InviteMessage.Checked)) { AddLoggerManageConnection("[ " + DateTime.Now + " ] => [ Please Check SpinTax CheckBox.. ]"); MessageBox.Show("Please Check SpinTax CheckBox.."); return; } if (txtInviteMsg.Text.Contains("{") || txtInviteMsg.Text.Contains("}")) { AddLoggerManageConnection("[ " + DateTime.Now + " ] => [ Its a wrong SpinTax Format.. ]"); MessageBox.Show("Its a wrong SpinTax Format.."); return; } } if (chkUseSpintax_InviteMessage.Checked) { ConnectUsingSearchKeywod.isSpinTaxSearchWithInvite = true; ConnectUsingSearchKeywod.UpdatelistGreetMessatge = SpinnedListGenerator.GetSpinnedList(new List <string> { txtInviteMsg.Text }); } if (!string.IsNullOrEmpty(txt_campNoOfRetweetsParAc.Text) && NumberHelper.ValidateNumber(txt_campNoOfRetweetsParAc.Text)) { SearchCriteria.NumberOfRequestPerKeyword = Convert.ToInt32(txt_campNoOfRetweetsParAc.Text); } if ((LinkedInManager.linkedInDictionary.Count > 0 && !string.IsNullOrEmpty(txtInviteKeyword.Text.ToString()))) { counter_GroupMemberSearch = LinkedInManager.linkedInDictionary.Count; btnSearchKeyword.Cursor = Cursors.AppStarting; new Thread(() => SearchConnectionKeywordThread()).Start(); } else if (string.IsNullOrEmpty(txtInviteKeyword.Text.ToString())) { MessageBox.Show("Please Enter Keywords for search !"); AddLoggerManageConnection("[ " + DateTime.Now + " ] => [ Please Enter Keywords for search ! ]"); return; } else if ((LinkedInManager.linkedInDictionary.Count == 0)) { MessageBox.Show("Please Load LinkedIn Accounts From MyAccounts Menu"); AddLoggerManageConnection("[ " + DateTime.Now + " ] => [ Please Load LinkedIn Accounts From MyAccounts Menu ]"); frmAccounts FrmAccount = new frmAccounts(); FrmAccount.Show(); return; } } catch (Exception ex) { GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error --> Add Connection --> btnSearchConnection_Click() >>>> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace, Globals.Path_LinkedinErrorLogs); GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error --> Add Connection --> btnSearchConnection_Click() >>>> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace, Globals.Path_LinkedinAddConnectionErrorLogs); } } else { MessageBox.Show("Your Internet Connection is disabled ! or not working, Please Check Your Internet Connection..."); AddLoggerManageConnection("[ " + DateTime.Now + " ] => [ Your Internet Connection is disabled ! or not working, Please Check Your Internet Connection... ]"); } }
private void SendInvitation(ref GlobusHttpHelper httpHelper, string pageSource, string key1, string authToken1, string goback1, string firstName_Guest1, string lastName_Guest1) { try { Log("[ " + DateTime.Now + " ] => [ Start Sending Invitation With Username >>> " + _UserName + " ]"); string reason = string.Empty; string existingPositionIC = string.Empty; string greeting = string.Empty; string key = string.Empty; string firstName_Guest = string.Empty; string lastName_Guest = string.Empty; string authToken = string.Empty; string subject = string.Empty; string defaultText = string.Empty; string csrfToken = string.Empty; string sourceAlias = string.Empty; string goback = string.Empty; string userName = string.Empty; string userFirstName = string.Empty; string userLastName = string.Empty; string resultForUserDetails = FindTheUserName(pageSource); try { resultForUserDetails = resultForUserDetails.Substring(resultForUserDetails.IndexOf("alt="), resultForUserDetails.IndexOf("height") - resultForUserDetails.IndexOf("alt=")).Replace("alt=", string.Empty).Replace("/", string.Empty).Trim(); userFirstName = resultForUserDetails.Split(' ')[0].Replace("\"", string.Empty).Replace(",", string.Empty); userLastName = resultForUserDetails.Split(' ')[1].Replace("\"", string.Empty).Replace(",", string.Empty); } catch { } firstName_Guest = GetValue(pageSource, "firstName"); if (string.IsNullOrEmpty(firstName_Guest)) { firstName_Guest = firstName_Guest1; } lastName_Guest = GetValue(pageSource, "lastName"); if (string.IsNullOrEmpty(lastName_Guest)) { lastName_Guest = lastName_Guest1; } reason = GetValue(pageSource, "reason"); existingPositionIC = GetValue(pageSource, "existingPositionIC"); firstName_Guest = firstName_Guest.Replace(""", "\""); greeting = PersonalNote.Replace("<FIRSTNAME>", firstName_Guest).Replace("<PROFILEFIRSTNAME>", userFirstName).Trim(); ClsInviteMemberThroughProfileURL.Listgreetmsg = SpinnedListGenerator.GetSpinnedList(new List <string> { greeting }); string messagebody = string.Empty; messagebody = greeting; if (spintaxsearch) { try { messagebody = Listgreetmsg[RandomNumberGenerator.GenerateRandom(0, Listgreetmsg.Count - 1)]; } catch { } } key = GetValue(pageSource, "key"); if (string.IsNullOrEmpty(key)) { key = key1; } authToken = GetValue(pageSource, "authToken"); if (string.IsNullOrEmpty(authToken)) { authToken = authToken1; } subject = GetValue(pageSource, "subject"); defaultText = GetValue(pageSource, "defaultText"); csrfToken = GetValue(pageSource, "csrfToken"); sourceAlias = GetValue(pageSource, "sourceAlias"); goback = GetValue(pageSource, "goback").Replace("/", "%2F"); if (string.IsNullOrEmpty(goback)) { goback = goback1; } string postData = "existingPositionIC=&companyName.0=&titleIC.0=&startYearIC.0=&endYearIC.0=&schoolText=&schoolID=&existingPositionIB=&companyName.1=&titleIB.0=&startYearIB.0=&endYearIB.0=&reason=IF&otherEmail=&greeting=" + Uri.EscapeDataString(messagebody) + "&iweReconnectSubmit=Send+Invitation&key=" + key + "&firstName=" + firstName_Guest + "&lastName=" + lastName_Guest + "&authToken=" + authToken + "&authType=name&trk=prof-0-sb-connect-button&iweLimitReached=false&companyID.0=&companyID.1=&schoolID=&schoolcountryCode=&schoolprovinceCode=&javascriptEnabled=false&existingAssociation=Job+Openings%2C+Job+Leads+and+Job+Connections%21&subject=" + subject + "&defaultText=" + defaultText + "&csrfToken=" + csrfToken + "&sourceAlias=" + sourceAlias + "&goback=" + goback + ""; string postResponse = httpHelper.postFormData(new Uri("http://www.linkedin.com/people/iweReconnectAction"), postData); if (postResponse.Contains("Invitation to") || postResponse.Contains("invitación a")) { Log("[ " + DateTime.Now + " ] => [ Invitation Sent successfully To >>> " + firstName_Guest + " With Username >>> " + _UserName + " ]"); #region Data Saved In CSV File if (!string.IsNullOrEmpty(firstName_Guest) || !string.IsNullOrEmpty(_UserName)) { try { string CSVHeader = "_UserName" + "," + "firstName_Guest" + "," + "lastName_Guest" + "," + "userFirstName" + "," + "userLastName" + ","; string CSV_Content = _UserName + "," + firstName_Guest + "," + lastName_Guest + "," + userFirstName + "," + userLastName + ","; // +TypeOfProfile + ","; CSVUtilities.ExportDataCSVFile(CSVHeader, CSV_Content, Globals.path_LinkedininvitememberResultUrlData); //path_LinkedinSearchSearchByProfileURL); Log("[ " + DateTime.Now + " ] => [ Data Saved In CSV File ! ]"); } catch { } } #endregion int delay = new Random().Next(MinDelay, MaxDelay); Log("[ " + DateTime.Now + " ] => [ Delay >>> " + delay + " Seconds With Username >>> " + _UserName + " ]"); Log("[ " + DateTime.Now + " ] => [---------------------------------------------------------------------]"); Thread.Sleep(delay * 1000); } else if (postResponse.Contains("Request Error") || postResponse.Contains("Solicitud de error")) { Log("[ " + DateTime.Now + " ] => [ Request Error With Username >>> " + _UserName + " ]"); if (pageSource.Contains("Sorry, there was a problem processing your request. Please try again")) { Log("[ " + DateTime.Now + " ] => [ Sorry, there was a problem processing your request. Please try again With Username >>> " + _UserName + " ]"); } if (pageSource.Contains("You have no confirmed email addresses")) { Log("[ " + DateTime.Now + " ] => [ You have no confirmed email addresses With Username >>> " + _UserName + " ]"); } } else { if (pageSource.Contains("Sorry, there was a problem processing your request. Please try again")) { Log("[ " + DateTime.Now + " ] => [ Sorry, there was a problem processing your request. Please try again With Username >>> " + _UserName + " ]"); } else if (pageSource.Contains("You have no confirmed email addresses")) { Log("[ " + DateTime.Now + " ] => [ You have no confirmed email addresses With Username >>> " + _UserName + " ]"); } else { Log("[ " + DateTime.Now + " ] => [ Error in request With Username >>> " + _UserName + " ]"); } int delay = new Random().Next(MinDelay, MaxDelay); Log("[ " + DateTime.Now + " ] => [ Delay >>> " + delay + " Seconds With Username >>> " + _UserName + " ]"); Log("[ " + DateTime.Now + " ] => [---------------------------------------------------------------------]"); Thread.Sleep(delay * 1000); } } catch (Exception ex) { Console.WriteLine("Error >>> " + ex.StackTrace); } }