public async Task <IHttpActionResult> LoginLinkedin(LinkedinUser profile) { try { var user = await db.Users.Where(u => u.Email == profile.Id).FirstOrDefaultAsync(); if (user == null) { user = new User { Email = profile.Id, FirstName = profile.FirstName, LastName = profile.LastName, ImagePath = "no_image", UserTypeId = 4, Telephone = "...", }; db.Users.Add(user); UsersHelper.CreateUserASP(profile.Id, "User", profile.Id); } else { user.FirstName = profile.FirstName; user.LastName = profile.LastName; user.ImagePath = "no_image"; db.Entry(user).State = EntityState.Modified; } await db.SaveChangesAsync(); return(Ok(true)); } catch (DbEntityValidationException e) { var message = string.Empty; foreach (var eve in e.EntityValidationErrors) { message = string.Format("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { message += string.Format("\n- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } return(BadRequest(message)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public void StartCompanyEmployeeScraper(ref LinkedinUser objLinkedinUser) { try { if (objLinkedinUser.isloggedin) { GetEmployeeDataFromCompanyURL(ref objLinkedinUser.globusHttpHelper, GlobalsScraper.lstUrlCompanyEmpScraper); } } catch (Exception ex) { } }
public async Task <IActionResult> Login(LinkedinUserAuthCodeDto linkedinUserAuthCodeDto) { string linkedinAuthToken = await ExchangeLinkedinCodeToUserToken(linkedinUserAuthCodeDto.LinkedinAuthCode); LinkedinUser linkedinUser = await GetLinkedinUser(linkedinAuthToken); User user = await _userManager.FindByEmailAsync(linkedinUser.Email); if (user == null) { user = new User { UserName = linkedinUser.Email.Split("@")[0], NickName = linkedinUser.LocalizedFirstName + " " + linkedinUser.LocalizedLastName, Email = linkedinUser.Email, PhotoUrl = await _photoController.UploadAvatarByUrl(linkedinUser.PhotoUrl), RegisteredVia = "Linkedin", Created = DateTime.Now, LastActive = DateTime.Now }; var result = await _userManager.CreateAsync(user); if (!result.Succeeded) { return(BadRequest("User not created")); } var res = _userManager.AddToRoleAsync(user, "User").Result; if (!res.Succeeded) { return(BadRequest("error on adding role for user")); } } // generate the jwt for the local user... var userForToken = await _userManager.FindByEmailAsync(user.Email); if (userForToken == null) { return(BadRequest("cant create user")); } string token = AppTokens.GenerateJwtToken(userForToken, _config, _userManager).Result; var userForReturnDto = _mapper.Map <UserForReturnDto>(userForToken); return(Ok(new { token = token, user = userForReturnDto })); }
public void StartGroupStatus(ref LinkedinUser objLinkedinUser) { try { Dictionary <string, string> dicGroup = new Dictionary <string, string>(); GlobusLogHelper.log.Info("Finding Groups..."); dicGroup = GetGroups(ref objLinkedinUser); GlobalsGroups.lstGroups.Clear(); foreach (var item in dicGroup) { GlobalsGroups.lstGroups.Add(Regex.Split(item.Key, "<:><:>")[0]); } BindingGroupNames(); } catch (Exception ex) { } }
public void StartSalesNavigator(ref LinkedinUser objLinkedinUser) { try { GlobusHttpHelper objHttpHelper = objLinkedinUser.globusHttpHelper; string mainUrl = string.Empty; mainUrl = FormURL(ref objLinkedinUser); Pagination(ref objHttpHelper, mainUrl); //ScrapeProfileDetails(ref objHttpHelper); try { string[] profileUrls = lstProfileUrls.ToArray(); System.IO.File.WriteAllLines(FilePath.profileUrlsSalesNavigatorScraper, profileUrls); } catch { } } catch (Exception ex) { } }
public void LoadAccountsFromDataBase() { try { LDGlobals.loadedAccountsDictionary.Clear(); LDGlobals.listAccounts.Clear(); DataTable dt = new DataTable(); dt.Columns.Add("UserName"); dt.Columns.Add("Password"); // dt.Columns.Add("ScreenName"); //// dt.Columns.Add("FollowerCount"); // dt.Columns.Add("FollwingCount"); dt.Columns.Add("proxyAddress"); dt.Columns.Add("proxyPort"); dt.Columns.Add("ProxyUserName"); dt.Columns.Add("ProxyPassword"); // dt.Columns.Add("GroupName"); // dt.Columns.Add("AccountStatus"); int counter = 0; DataSet ds = null; try { ds = Qm.SelectAccounts(); } catch (Exception ex) { GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } foreach (DataRow ds_item in ds.Tables[0].Rows) { if (Globals.CheckLicenseManager == "fdfreetrial" && counter == 5) { break; } counter = counter + 1; try { string item = ds_item[0].ToString() + ":" + ds_item[1].ToString() + ":" + ds_item[2].ToString() + ":" + ds_item[3].ToString() + ":" + ds_item[4].ToString() + ":" + ds_item[5].ToString(); string account = item; string[] AccArr = account.Split(':'); if (AccArr.Count() > 1) { string accountUser = account.Split(':')[0]; string accountPass = account.Split(':')[1]; string ScreenName = string.Empty; string FollowerCount = string.Empty; string FollwingCount = string.Empty; string proxyAddress = string.Empty; string proxyPort = string.Empty; string proxyUserName = string.Empty; string proxyPassword = string.Empty; string GroupName = string.Empty; string AccountStatus = string.Empty; string status = string.Empty; DataGridColumn newcolumn = new DataGridHyperlinkColumn(); int DataCount = account.Split(':').Length; if (DataCount == 2) { //Globals.accountMode = AccountMode.NoProxy; } else if (DataCount == 4) { proxyAddress = account.Split(':')[2]; proxyPort = account.Split(':')[3]; } else if (DataCount == 6) { proxyAddress = account.Split(':')[2]; proxyPort = account.Split(':')[3]; proxyUserName = account.Split(':')[4]; proxyPassword = account.Split(':')[5]; } dt.Rows.Add(accountUser, accountPass, proxyAddress, proxyPort, proxyUserName, proxyPassword); try { LinkedinUser objLD_Users = new LinkedinUser(); // TWTUsers objTwtUser = new TWTUsers(); objLD_Users.username = accountUser; objLD_Users.password = accountPass; objLD_Users.proxyip = proxyAddress; objLD_Users.proxyport = proxyPort; objLD_Users.proxyusername = proxyUserName; objLD_Users.proxypassword = proxyPassword; LDGlobals.loadedAccountsDictionary.Add(objLD_Users.username, objLD_Users); // TWTGlobals.loadedAccountsDictionary.Add(objTwtUser.username, objTwtUser); #region MyRegion //try //{ // if (cmbGroups_GroupCampaignManager_Accounts.InvokeRequired) // { // cmbScraper__fanscraper_Accounts.Invoke(new MethodInvoker(delegate // { // cmbScraper__fanscraper_Accounts.Items.Add(accountUser); // })); // } //} //catch (Exception ex) //{ // GlobusLogHelper.log.Error("Error : " + ex.StackTrace); //} //try //{ // if (cmbScraper__CustomAudiencesScraper_Accounts.InvokeRequired) // { // cmbScraper__CustomAudiencesScraper_Accounts.Invoke(new MethodInvoker(delegate // { // cmbScraper__CustomAudiencesScraper_Accounts.Items.Add(accountUser); // })); // } //} //catch (Exception ex) //{ // GlobusLogHelper.log.Error("Error : " + ex.StackTrace); //} //try //{ // //cmbCommentsOnPostSelectAccount // if (cmbCommentsOnPostSelectAccount.InvokeRequired) // { // cmbCommentsOnPostSelectAccount.Invoke(new MethodInvoker(delegate // { // cmbCommentsOnPostSelectAccount.Items.Add(accountUser + ":" + accountPass); // })); // } //} //catch (Exception ex) //{ // GlobusLogHelper.log.Error(ex.Message); //} //try //{ // if (cmbGroups_GroupCampaignManager_Accounts.InvokeRequired) // { // cmbGroups_GroupCampaignManager_Accounts.Invoke(new MethodInvoker(delegate // { // cmbGroups_GroupCampaignManager_Accounts.Items.Add(accountUser); // })); // } //} //catch (Exception ex) //{ // GlobusLogHelper.log.Error("Error : " + ex.StackTrace); //} //try //{ // if (cmbScraper__GroupMemberScraper_Accounts.InvokeRequired) // { // cmbScraper__GroupMemberScraper_Accounts.Invoke(new MethodInvoker(delegate // { // cmbScraper__GroupMemberScraper_Accounts.Items.Add(accountUser); // })); // } //} //catch (Exception ex) //{ // GlobusLogHelper.log.Error("Error : " + ex.StackTrace); //} #endregion LDGlobals.listAccounts.Add(objLD_Users.username + ":" + objLD_Users.password + ":" + objLD_Users.proxyip + ":" + objLD_Users.proxyport + ":" + objLD_Users.proxyusername + ":" + objLD_Users.proxypassword); // TWTGlobals.listAccounts.Add(objTwtUser.username + ":" + objTwtUser.password + ":" + objTwtUser.proxyip + ":" + objTwtUser.proxyport + ":" + objTwtUser.proxyusername + ":" + objTwtUser.proxypassword); } catch (Exception ex) { GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } ///Set this to "0" if loading unprofiled accounts /// string profileStatus = "0"; } else { GlobusLogHelper.log.Info("Account has some problem : " + item); GlobusLogHelper.log.Debug("Account has some problem : " + item); } } catch (Exception ex) { GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } } DataView dv = dt.DefaultView; dv.AllowNew = false; this.Dispatcher.Invoke(new Action(delegate { // grvAccounts_AccountCreator_AccountDetails.ItemsSource = dv; })); try { grvAccounts_AccountCreator_AccountDetails.ItemsSource = dt.DefaultView; } catch { } GlobusLogHelper.log.Debug("Accounts Loaded : " + dt.Rows.Count); GlobusLogHelper.log.Info("Accounts Loaded : " + dt.Rows.Count); } catch (Exception ex) { GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } }
private void LoadAccounts() { //Globals.IsFreeVersion = true; try { DataSet ds; DataTable dt = new DataTable(); Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); dlg.DefaultExt = ".txt"; dlg.Filter = "Text documents (.txt)|*.txt"; Nullable <bool> result = dlg.ShowDialog(); if (result == true) { DateTime sTime = DateTime.Now; #region MyRegion //if (lblAccounts_ManageAccounts_LoadsAccountsPath.InvokeRequired) //{ // lblAccounts_ManageAccounts_LoadsAccountsPath.Invoke(new MethodInvoker(delegate // { // lblAccounts_ManageAccounts_LoadsAccountsPath.Text = ofd.FileName; // })); //} //else //{ // lblAccounts_ManageAccounts_LoadsAccountsPath.Text = ofd.FileName; //} #endregion dt.Columns.Add("UserName"); dt.Columns.Add("Password"); dt.Columns.Add("proxyAddress"); dt.Columns.Add("proxyPort"); dt.Columns.Add("ProxyUserName"); dt.Columns.Add("ProxyPassword"); ds = new DataSet(); ds.Tables.Add(dt); #region MyRegion //if (grvAccounts_ManageAccounts_ManageAccountsDetails.InvokeRequired) //{ // grvAccounts_ManageAccounts_ManageAccountsDetails.Invoke(new MethodInvoker(delegate // { // grvAccounts_ManageAccounts_ManageAccountsDetails.DataSource = null; // })); //} //else //{ // grvAccounts_ManageAccounts_ManageAccountsDetails.DataSource = null; //} #endregion List <string> templist = GlobusFileHelper.ReadFile(dlg.FileName); //if (templist.Count > 0) //{ // LDGlobals.loadedAccountsDictionary.Clear(); // LDGlobals.listAccounts.Clear(); //} int counter = 0; foreach (string item in templist) { if (Globals.CheckLicenseManager == "fdfreetrial" && counter == 5) { break; } counter = counter + 1; try { string account = item; string[] AccArr = account.Split(':'); if (AccArr.Count() > 1) { string accountUser = account.Split(':')[0]; string accountPass = account.Split(':')[1]; string proxyAddress = string.Empty; string proxyPort = string.Empty; string proxyUserName = string.Empty; string proxyPassword = string.Empty; int DataCount = account.Split(':').Length; if (DataCount == 2) { //Globals.accountMode = AccountMode.NoProxy; } else if (DataCount == 4) { proxyAddress = account.Split(':')[2]; proxyPort = account.Split(':')[3]; } else if (DataCount > 5 && DataCount < 7) { proxyAddress = account.Split(':')[2]; proxyPort = account.Split(':')[3]; proxyUserName = account.Split(':')[4]; proxyPassword = account.Split(':')[5]; } else if (DataCount == 7) { proxyAddress = account.Split(':')[5]; proxyPort = account.Split(':')[6]; proxyUserName = account.Split(':')[7]; proxyPassword = account.Split(':')[8]; } //dt.Rows.Add(accountUser, accountPass, ScreenName, FollowerCount, FollwingCount, proxyAddress, proxyPort, proxyUserName, proxyPassword, GroupName, AccountStatus); dt.Rows.Add(accountUser, accountPass, proxyAddress, proxyPort, proxyUserName, proxyPassword); // dt.Rows.Add(accountUser, accountPass, proxyAddress, proxyPort, proxyUserName, proxyPassword); Qm.AddAccountInDataBase(accountUser, accountPass, proxyAddress, proxyPort, proxyUserName, proxyPassword); try { // loadedAccountsDictionary.Clear(); LinkedinUser objLinkedinUser = new LinkedinUser(); objLinkedinUser.username = accountUser; objLinkedinUser.password = accountPass; objLinkedinUser.proxyip = proxyAddress; objLinkedinUser.proxyport = proxyPort; objLinkedinUser.proxyusername = proxyUserName; objLinkedinUser.proxypassword = proxyPassword; LDGlobals.loadedAccountsDictionary.Add(objLinkedinUser.username, objLinkedinUser); LDGlobals.listAccounts.Add(objLinkedinUser.username + ":" + objLinkedinUser.password + ":" + objLinkedinUser.proxyip + ":" + objLinkedinUser.proxyport + ":" + objLinkedinUser.proxyusername + ":" + objLinkedinUser.proxypassword); } catch (Exception ex) { GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } ///Set this to "0" if loading unprofiled accounts /// string profileStatus = "0"; } else { GlobusLogHelper.log.Info("Account has some problem : " + item); GlobusLogHelper.log.Debug("Account has some problem : " + item); } } catch (Exception ex) { GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } } DataSet objDataSet = Qm.SelectAccounts(); dt = objDataSet.Tables["tb_LinkedInAccount"]; DataView dv = dt.DefaultView; dv.AllowNew = false; this.Dispatcher.Invoke(new Action(delegate { grvAccounts_AccountCreator_AccountDetails.ItemsSource = dv; })); try { DateTime eTime = DateTime.Now; string timeSpan = (eTime - sTime).TotalSeconds.ToString(); Application.Current.Dispatcher.Invoke(new Action(() => { lblaccounts_ManageAccounts_LoadsAccountsCount.Content = dt.Rows.Count.ToString(); })); GlobusLogHelper.log.Debug("Accounts Loaded : " + dt.Rows.Count.ToString() + " In " + timeSpan + " Seconds"); GlobusLogHelper.log.Info("Accounts Loaded : " + dt.Rows.Count.ToString() + " In " + timeSpan + " Seconds"); } catch (Exception ex) { GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } } } catch (Exception ex) { GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } Application.Current.Dispatcher.Invoke((Action)(() => { LoadAccountProgressBar.IsIndeterminate = false; })); }
public void LoginHttpHelper(ref LinkedinUser linkedUser) { try { GlobusHttpHelper objGlobusHttpHelper = new GlobusHttpHelper(); linkedUser.globusHttpHelper = objGlobusHttpHelper; GlobusHttpHelper HttpHelper = linkedUser.globusHttpHelper; GlobusLogHelper.log.Info("Logging In With Account : " + linkedUser.username); GlobusLogHelper.log.Info("Login Process is Running... "); string Url = LDGlobals.Instance.LDhomeurl; string pageSrcLogin = string.Empty; int ProxyPort = 0; if (!string.IsNullOrEmpty(linkedUser.proxyport) && NumberHelper.ValidateNumber(linkedUser.proxyport)) { ProxyPort = int.Parse(linkedUser.proxyport); } pageSrcLogin = HttpHelper.getHtmlfromUrlProxy(new Uri(Url), "", linkedUser.proxyip, linkedUser.proxyport, linkedUser.proxyusername, linkedUser.proxypassword); if (pageSrcLogin.Contains("Sign Out")) { return; } string postdata = string.Empty; string postUrl = string.Empty; string ResLogin = string.Empty; string csrfToken = string.Empty; string regCsrfParam = string.Empty; string sourceAlias = string.Empty; if (pageSrcLogin.Contains("csrfToken")) { try { int startIndex = pageSrcLogin.IndexOf("name=\"csrfToken\""); string start = pageSrcLogin.Substring(startIndex).Replace("name=\"csrfToken\"", ""); int endIndex = start.IndexOf("\" "); string end = start.Substring(0, endIndex).Replace("value=\"", "").Trim(); csrfToken = end; if (csrfToken.Contains(LDGlobals.Instance.LDhomeurl)) { csrfToken = Utils.getBetween("@@@@@@@" + csrfToken, "@@@@@@@", "\"/></form>"); } //csrfToken = csrfToken; } catch (Exception ex) { GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } } try { if (csrfToken.Contains("&")) { string[] Arr = csrfToken.Split('&'); csrfToken = Arr[0].Replace("\"", string.Empty); } } catch (Exception ex) { GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } if (pageSrcLogin.Contains("sourceAlias")) { sourceAlias = pageSrcLogin.Substring(pageSrcLogin.IndexOf("sourceAlias"), 100); string[] Arr = sourceAlias.Split('"'); sourceAlias = Arr[2].Replace(@"\", string.Empty).Replace("//", string.Empty).Trim(); } try { int SourceAliasStart = pageSrcLogin.IndexOf("regCsrfParam"); if (SourceAliasStart > 0) { try { regCsrfParam = pageSrcLogin.Substring(pageSrcLogin.IndexOf("regCsrfParam"), 100); string[] Arr = regCsrfParam.Split('"'); regCsrfParam = Arr[2].Replace(@"\", string.Empty).Replace("//", string.Empty); } catch (Exception ex) { GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } } if (string.IsNullOrEmpty(regCsrfParam)) { regCsrfParam = Utils.getBetween(pageSrcLogin, "loginCsrfParam", "/>"); regCsrfParam = Utils.getBetween(regCsrfParam, "value=\"", "\""); } } catch (Exception ex) { GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } postUrl = "https://www.linkedin.com/uas/login-submit"; postdata = "isJsEnabled=true&source_app=&tryCount=&session_key=" + Uri.EscapeDataString(linkedUser.username) + "&session_password="******"&signin=Sign%20In&session_redirect=&loginCsrfParam=" + regCsrfParam + "&csrfToken=" + csrfToken + "&sourceAlias=" + sourceAlias; int port = 80; try { port = Convert.ToInt32(linkedUser.proxyport); ResLogin = HttpHelper.postFormDataProxy(new Uri(postUrl), postdata, "", linkedUser.proxyip, port, linkedUser.proxyusername, linkedUser.proxypassword);//HttpHelper.postFormDataRef(new Uri(postUrl), postdata, "https://www.linkedin.com/uas/login?goback=&trk=hb_signin", "", ""); } catch (Exception ex) { GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } if (ResLogin.Contains("Request Error") || ResLogin.Contains("Join Today")) { Url = "https://www.linkedin.com/"; postdata = "isJsEnabled=true&source_app=&tryCount=&clickedSuggestion=false&session_key=" + Uri.EscapeDataString(linkedUser.username) + "&session_password="******"&signin=Sign%20In&session_redirect=&trk=hb_signin&loginCsrfParam=" + regCsrfParam + "&fromEmail=&csrfToken=" + csrfToken + "&sourceAlias=" + sourceAlias + "&client_ts=1434028850511&client_r=rairaaz4%40gmail.com%3A910202384%3A297133466%3A594693585&client_output=-480305440&client_n=910202384%3A297133466%3A594693585&client_v=1.0.1"; ResLogin = HttpHelper.postFormDataProxy(new Uri(postUrl), postdata, "", linkedUser.proxyip, port, linkedUser.proxyusername, linkedUser.proxypassword); } string ImageUrl = string.Empty; string captchaText = string.Empty; string captchachallengeid = string.Empty; string dts = string.Empty; string origActionAlias = string.Empty; string origSourceAlias = string.Empty; string irhf = string.Empty; string submissionID = string.Empty; string CAPTCHAfwdcsrftoken = string.Empty; string CAPTCHAfwdsignin = string.Empty; string CAPTCHAfwdsession_password = string.Empty; string CAPTCHAfwdsession_key = string.Empty; string CAPTCHAfwdisJsEnabled = string.Empty; string CAPTCHAfwdloginCsrfParam = string.Empty; #region coommented seurity verification //if (ResLogin.Contains("Security Verification")) //{ // string dataforcapctha = HttpHelper.getHtmlfromUrl1(new Uri("https://www.google.com/recaptcha/api/noscript?k=6LcnacMSAAAAADoIuYvLUHSNLXdgUcq-jjqjBo5n")); // if (!string.IsNullOrEmpty(dataforcapctha)) // { // int startindex = dataforcapctha.IndexOf("id=\"recaptcha_challenge_field\""); // if (startindex > 0) // { // string start = dataforcapctha.Substring(startindex).Replace("id=\"recaptcha_challenge_field\"", ""); // int endindex = start.IndexOf("\">"); // string end = start.Substring(0, endindex).Replace("value=", string.Empty).Replace("\"", string.Empty).Trim(); // ImageUrl = "https://www.google.com/recaptcha/api/image?c=" + end; // System.Net.WebClient webclient = new System.Net.WebClient(); // byte[] args = webclient.DownloadData(ImageUrl); // string[] arr1 = new string[] { Globals.CapchaLoginID, Globals.CapchaLoginPassword, "" }; // captchaText = DecodeDBC(arr1, args); // } // if (ResLogin.Contains("name=\"security-challenge-id\"")) // { // int startindexnew = ResLogin.IndexOf("name=\"security-challenge-id\""); // if (startindexnew > 0) // { // string start = ResLogin.Substring(startindexnew).Replace("name=\"security-challenge-id\"", "").Replace("value=\"", ""); // int endindex = start.IndexOf("\""); // string end = start.Substring(0, endindex); // captchachallengeid = end.Replace("\"", string.Empty).Trim(); // } // } // if (ResLogin.Contains("name=\"dts\"")) // { // int startindexnew = ResLogin.IndexOf("name=\"dts\""); // if (startindexnew > 0) // { // string start = ResLogin.Substring(startindexnew).Replace("name=\"dts\"", "").Replace("value=\"", ""); // int endindex = start.IndexOf("\""); // string end = start.Substring(0, endindex); // dts = end.Replace("\"", string.Empty).Trim(); // } // } // if (ResLogin.Contains("name=\"origActionAlias\"")) // { // int startindexnew = ResLogin.IndexOf("name=\"origActionAlias\""); // if (startindexnew > 0) // { // string start = ResLogin.Substring(startindexnew).Replace("name=\"origActionAlias\"", "").Replace("value=\"", ""); // int endindex = start.IndexOf("\""); // string end = start.Substring(0, endindex); // origActionAlias = end.Replace("\"", string.Empty).Trim(); // } // } // if (ResLogin.Contains("name=\"submissionId\"")) // { // int startindexnew = ResLogin.IndexOf("name=\"submissionId\""); // if (startindexnew > 0) // { // string start = ResLogin.Substring(startindexnew).Replace("name=\"submissionId\"", string.Empty).Replace("value=\"", string.Empty); // int endindex = start.IndexOf("\""); // string end = start.Substring(0, endindex); // submissionID = end.Replace("\"", string.Empty).Trim(); // } // } // if (ResLogin.Contains("name=\"CAPTCHA-fwd-csrfToken\"")) // { // int startindexnew = ResLogin.IndexOf("name=\"CAPTCHA-fwd-csrfToken\""); // if (startindexnew > 0) // { // string start = ResLogin.Substring(startindexnew).Replace("name=\"CAPTCHA-fwd-csrfToken\"", string.Empty).Replace("value=\"", string.Empty); // int endindex = start.IndexOf("\""); // string end = start.Substring(0, endindex); // CAPTCHAfwdcsrftoken = end.Replace("\"", string.Empty).Trim(); // } // } // if (ResLogin.Contains("name=\"CAPTCHA-fwd-signin\"")) // { // int startindexnew = ResLogin.IndexOf("name=\"CAPTCHA-fwd-signin\""); // if (startindexnew > 0) // { // string start = ResLogin.Substring(startindexnew).Replace("name=\"CAPTCHA-fwd-signin\"", string.Empty).Replace("value=\"", string.Empty); // int endindex = start.IndexOf("\""); // string end = start.Substring(0, endindex); // CAPTCHAfwdsignin = end.Replace("\"", string.Empty).Trim(); // } // } // if (ResLogin.Contains("name=\"CAPTCHA-fwd-session_password\"")) // { // int startindexnew = ResLogin.IndexOf("name=\"CAPTCHA-fwd-session_password\""); // if (startindexnew > 0) // { // string start = ResLogin.Substring(startindexnew).Replace("name=\"CAPTCHA-fwd-session_password\"", string.Empty).Replace("value=\"", string.Empty); // int endindex = start.IndexOf("\""); // string end = start.Substring(0, endindex); // CAPTCHAfwdsession_password = end.Replace("\"", string.Empty).Trim(); // } // } // if (ResLogin.Contains("name=\"CAPTCHA-fwd-session_key\"")) // { // int startindexnew = ResLogin.IndexOf("name=\"CAPTCHA-fwd-session_key\""); // if (startindexnew > 0) // { // string start = ResLogin.Substring(startindexnew).Replace("name=\"CAPTCHA-fwd-session_key\"", string.Empty).Replace("value=\"", string.Empty); // int endindex = start.IndexOf("\""); // string end = start.Substring(0, endindex); // CAPTCHAfwdsession_key = end.Replace("\"", string.Empty).Trim(); // } // } // if (ResLogin.Contains("name=\"CAPTCHA-fwd-isJsEnabled\"")) // { // int startindexnew = ResLogin.IndexOf("name=\"CAPTCHA-fwd-isJsEnabled\""); // if (startindexnew > 0) // { // string start = ResLogin.Substring(startindexnew).Replace("name=\"CAPTCHA-fwd-isJsEnabled\"", string.Empty).Replace("value=\"", string.Empty); // int endindex = start.IndexOf("\""); // string end = start.Substring(0, endindex); // CAPTCHAfwdisJsEnabled = end.Replace("\"", string.Empty).Trim(); // } // } // if (ResLogin.Contains("name=\"CAPTCHA-fwd-loginCsrfParam\"")) // { // int startindexnew = ResLogin.IndexOf("name=\"CAPTCHA-fwd-loginCsrfParam\""); // if (startindexnew > 0) ; // { // string start = ResLogin.Substring(startindexnew).Replace("name=\"CAPTCHA-fwd-loginCsrfParam\"", string.Empty).Replace("value=\"", string.Empty); // int endindex = start.IndexOf("\""); // string end = start.Substring(0, endindex); // CAPTCHAfwdloginCsrfParam = end.Replace("\"", string.Empty).Trim(); // } // } // if (ResLogin.Contains("name=\"origSourceAlias\"")) // { // int startindexnew = ResLogin.IndexOf("name=\"origSourceAlias\""); // if (startindexnew > 0) // { // string start = ResLogin.Substring(startindexnew).Replace("name=\"origSourceAlias\"", "").Replace("value=\"", ""); // int endindex = start.IndexOf("\""); // string end = start.Substring(0, endindex); // origSourceAlias = end.Replace("\"", string.Empty).Trim(); // } // } // if (ResLogin.Contains("name=\"irhf\"")) // { // int startindexnew = ResLogin.IndexOf("name=\"irhf\""); // if (startindexnew > 0) // { // string start = ResLogin.Substring(startindexnew).Replace("name=\"irhf\"", "").Replace("value=\"", ""); // int endindex = start.IndexOf("\""); // string end = start.Substring(0, endindex); // irhf = end.Replace("\"", string.Empty).Trim(); // } // } // if (!string.IsNullOrEmpty(ImageUrl) && !string.IsNullOrEmpty(captchaText)) // { // //postdata = "recaptcha_challenge_field=" + ImageUrl.Replace("https://www.google.com/recaptcha/api/image?c=", string.Empty) + "&recaptcha_response_field=" + captchaText.Replace(" ", "+") + "&dts=" + dts + "&security-challenge-id=" + captchachallengeid + "&hr=&source_app=&csrfToken=" + csrfToken + "&isJsEnabled=true&session_redirect=&session_password="******"&session_key=" + Uri.EscapeDataString(accountUser) + "&origSourceAlias=" + origSourceAlias + "&origActionAlias=" + origActionAlias + "&irhf=" + irhf + "&sourceAlias=" + sourceAlias + "&submissionId=" + submissionID + ; // postdata = "recaptcha_challenge_field=" + ImageUrl.Replace("https://www.google.com/recaptcha/api/image?c=", string.Empty) + "&recaptcha_response_field=" + captchaText.Replace(" ", "+") + "&irhf=" + irhf + "&dts=" + dts + "&security-challenge-id=" + captchachallengeid + "&submissionId=" + submissionID + "&CAPTCHA-fwd-csrfToken=" + CAPTCHAfwdcsrftoken + "&CAPTCHA-fwd-isJsEnabled=" + CAPTCHAfwdisJsEnabled + "&CAPTCHA-fwd-signin=" + CAPTCHAfwdsignin + "&CAPTCHA-fwd-loginCsrfParam=" + CAPTCHAfwdloginCsrfParam + "&CAPTCHA-fwd-session_password="******"&CAPTCHAfwd-session_key=" + CAPTCHAfwdsession_key + "&session_password="******"&session_key=" + Uri.EscapeDataString(accountUser) + "&origSourceAlias=" + origSourceAlias + "&origActionAlias=" + origActionAlias + "&csrfToken=" + csrfToken + "&sourceAlias=" + sourceAlias; // postdata = postdata.Replace(" ", string.Empty); // ResLogin = HttpHelper.postFormDataRef(new Uri("https://www.linkedin.com/uas/captcha-submit"), postdata, "https://www.linkedin.com/uas/login-submit", string.Empty, string.Empty, string.Empty, string.Empty, string.Empty); // } // else // { // ResLogin = string.Empty; // } // if (ResLogin.Contains("The text you entered does not match the characters in the security image. Please try again with this new image") || string.IsNullOrEmpty(ResLogin)) // { // Log("[ " + DateTime.Now + " ] => [ " + accountUser + " Cannot Login because of Captcha ]"); // GlobusFileHelper.WriteStringToTextfile(accountUser + ":" + accountPass + ":" + proxyAddress + ":" + proxyPort + ":" + proxyUserName + ":" + proxyPassword, Globals.pathCapcthaLogin); // SearchCriteria.loginREsponce = string.Empty; // //FrmScrapGroupMember.ChangeToNextAccount = true; // } // } //} #endregion if (ResLogin.Contains("Sign Out") || ResLogin.Contains("class=\"signout\"") || ResLogin.Contains("Cerrar sesión")) { linkedUser.isloggedin = true; GlobusLogHelper.log.Info("Logged In With Account : " + linkedUser.username); try { // string Search = HttpHelper.getHtmlfromUrlProxy(new Uri("https://www.linkedin.com/search?trk=advsrch"),"", linkedUser.proxyip, linkedUser.proxyport, linkedUser.proxyusername, linkedUser.proxypassword); } catch (Exception ex) { GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } } else if (ResLogin.Contains("logout?session_full_logout")) { string Search = HttpHelper.getHtmlfromUrlProxy(new Uri("https://www.linkedin.com/search?trk=advsrch"), "", linkedUser.proxyip, linkedUser.proxyport, linkedUser.proxyusername, linkedUser.proxypassword); } else if (ResLogin.Contains("Sign-In Verification")) { GlobusLogHelper.log.Info(" Verification required : " + linkedUser.username); } else if (ResLogin.Contains("Your LinkedIn account has been temporarily restricted")) { GlobusLogHelper.log.Info("Your LinkedIn account : " + linkedUser.username + " has been temporarily restricted "); } else { GlobusLogHelper.log.Info("NotLogged In With Account : " + linkedUser.username); } } catch (Exception ex) { GlobusLogHelper.log.Info("NotLogged In With Account : " + linkedUser.username); } }
public void StartMultiThreadsCompanyEmployeeScraper(object parameters) { try { if (!GlobalsScraper.isStopCompanyEmployeeScraper) { try { GlobalsScraper.lstThreadsCompanyEmployeeScraper.Add(Thread.CurrentThread); GlobalsScraper.lstThreadsCompanyEmployeeScraper.Distinct(); Thread.CurrentThread.IsBackground = true; } catch (Exception ex) { GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } try { Array paramsArray = new object[1]; paramsArray = (Array)parameters; LinkedinUser objLinkedinUser = (LinkedinUser)paramsArray.GetValue(0); if (!objLinkedinUser.isloggedin) { GlobusHttpHelper objGlobusHttpHelper = objLinkedinUser.globusHttpHelper; //Login Process Accounts.AccountManager objAccountManager = new AccountManager(); objAccountManager.LoginHttpHelper(ref objLinkedinUser); } if (objLinkedinUser.isloggedin) { // Call StartActionMessageReply StartCompanyEmployeeScraper(ref objLinkedinUser); } else { GlobusLogHelper.log.Info("Couldn't Login With Username : "******"Couldn't Login With Username : "******"Error : " + ex.StackTrace); } } } catch (Exception ex) { GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } finally { try { // if (!isStopWallPoster) { lock (lockrThreadControllerCompanyEmployeeScraper) { GlobalsScraper.countThreadControllerCompanyEmployeeScraper = GlobalsScraper.countThreadControllerCompanyEmployeeScraper--; Monitor.Pulse(lockrThreadControllerCompanyEmployeeScraper); } } } catch (Exception ex) { GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } } }
public void ThreadStartCompanyEmployeeScraper() { try { int numberOfAccountPatch = 25; if (GlobalsScraper.NoOfThreadsCompanyEmployeeScraper > 0) { numberOfAccountPatch = GlobalsScraper.NoOfThreadsCompanyEmployeeScraper; } List <List <string> > list_listAccounts = new List <List <string> >(); if (LDGlobals.listAccounts.Count >= 1) { list_listAccounts = Utils.Split(LDGlobals.listAccounts, numberOfAccountPatch); foreach (List <string> listAccounts in list_listAccounts) { foreach (string account in listAccounts) { try { lock (lockrThreadControllerCompanyEmployeeScraper) { try { if (GlobalsScraper.countThreadControllerCompanyEmployeeScraper >= listAccounts.Count) { Monitor.Wait(lockrThreadControllerCompanyEmployeeScraper); } string acc = account.Remove(account.IndexOf(':')); //Run a separate thread for each account LinkedinUser item = null; LDGlobals.loadedAccountsDictionary.TryGetValue(acc, out item); if (item != null) { Thread profilerThread = new Thread(StartMultiThreadsCompanyEmployeeScraper); profilerThread.Name = "workerThread_Profiler_" + acc; profilerThread.IsBackground = true; profilerThread.Start(new object[] { item }); GlobalsScraper.countThreadControllerCompanyEmployeeScraper++; } } catch (Exception ex) { // GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } } } catch (Exception ex) { // GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } } } } } catch (Exception ex) { // GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } }
public string FormURL(ref LinkedinUser objLinkedinUser) { GlobusHttpHelper objHttpHelper = objLinkedinUser.globusHttpHelper; string url = "https://www.linkedin.com/sales/search/?"; try { if (!string.IsNullOrEmpty(currentCompany)) { url = url + "&company=" + currentCompany; // url = url + "&companyScope=" + GlobalsScraper.selectedCurrentPast_Input_SalesNav; } if (!string.IsNullOrEmpty(relationship)) { int i = 0; string[] rawRelationship = Regex.Split(relationship, ","); string addRelationshipValue = "facet=N"; for (i = 0; i < rawRelationship.Count(); i++) { addRelationshipValue = addRelationshipValue + "&facet.N=" + rawRelationship[i]; } url = url + addRelationshipValue; } if (!string.IsNullOrEmpty(location)) { string locationResponse = objHttpHelper.getHtmlfromUrl(new Uri("https://www.linkedin.com/ta/region?query=" + Uri.EscapeDataString(location))); string rawLocationValue = Utils.getBetween(locationResponse, "\"id\":\"", "\",\""); url = url + "&facet=G&facet.G=" + rawLocationValue; } if (!string.IsNullOrEmpty(title)) { url = url + "&jobTitle=" + title; } if (!string.IsNullOrEmpty(titleScope)) { url = url + "&titleScope=" + titleScope; } if (!string.IsNullOrEmpty(industry)) { int i = 0; string[] rawIndustry = Regex.Split(industry, ","); string addIndustryValue = "&facet=I"; for (i = 0; i < rawIndustry.Count(); i++) { addIndustryValue = addIndustryValue + "&facet.I=" + rawIndustry[i]; } url = url + addIndustryValue; } if (!string.IsNullOrEmpty(country)) { // url = url + "&countryCode=" + SalesNavigatorGlobals.country; } if (!string.IsNullOrEmpty(within)) { url = url + "&radiusMiles=" + within; } if (!string.IsNullOrEmpty(postalCode)) { url = url + "&postalCode=" + postalCode; } if (!string.IsNullOrEmpty(firstName)) { url = url + "&firstName=" + firstName; } if (!string.IsNullOrEmpty(lastName)) { url = url + "&lastName=" + lastName; } if (!string.IsNullOrEmpty(seniorityLevel)) { int i = 0; string[] rawSeniorityLevel = Regex.Split(seniorityLevel, ","); string addSeniorityValue = "&facet=SE"; for (i = 0; i < rawSeniorityLevel.Count(); i++) { addSeniorityValue = addSeniorityValue + "&facet.SE=" + rawSeniorityLevel[i]; } url = url + addSeniorityValue; } if (!string.IsNullOrEmpty(function)) { int i = 0; string[] rawFunction = Regex.Split(function, ","); string addFunctionValue = "&facet=FA"; for (i = 0; i < rawFunction.Count(); i++) { addFunctionValue = addFunctionValue + "&facet.FA=" + rawFunction[i]; } url = url + addFunctionValue; } if (!string.IsNullOrEmpty(companySize)) { int i = 0; string[] rawCompanySize = Regex.Split(companySize, ","); string addCompanySizeValue = "&facet=CS"; for (i = 0; i < rawCompanySize.Count(); i++) { addCompanySizeValue = addCompanySizeValue + "&facet.CS=" + rawCompanySize[i]; } url = url + addCompanySizeValue; } if (!string.IsNullOrEmpty(yearOfExperience)) { int i = 0; string[] rawYearsOfExperience = Regex.Split(yearOfExperience, ","); string addYearsOfExperienceValue = "&facet=TE"; for (i = 0; i < rawYearsOfExperience.Count(); i++) { addYearsOfExperienceValue = addYearsOfExperienceValue + "&facet.TE=" + rawYearsOfExperience[i]; } url = url + addYearsOfExperienceValue; } if (!string.IsNullOrEmpty(language)) { int i = 0; string[] rawlanguage = Regex.Split(language, ","); string addLanguageValue = "&facet=L"; for (i = 0; i < rawlanguage.Count(); i++) { addLanguageValue = addLanguageValue + "&facet.L=" + rawlanguage[i]; } url = url + addLanguageValue; } if (!string.IsNullOrEmpty(whenJoined)) { int i = 0; string[] rawWhenJoined = Regex.Split(whenJoined, ","); string addWhenJoinedValue = "&facet=DR"; for (i = 0; i < rawWhenJoined.Count(); i++) { addWhenJoinedValue = addWhenJoinedValue + "&facet.DR=" + rawWhenJoined[i]; } url = url + addWhenJoinedValue; } //url = url + "&defaultSelection=false&start=replaceVariableCounter&count=100"; url = url + "&defaultSelection=false&start=0&count=10&searchHistoryId=1540160093"; if (!string.IsNullOrEmpty(keyword)) { url = url + "&keywords=" + Uri.EscapeDataString(keyword) + "&trk=lss-search-tab"; } else { url = url + "&trk=lss-search-tab"; } } catch (Exception ex) { } return(url); }
public void PostGroupMsgUpdate(ref LinkedinUser objLnkedinUser) { try { if (objLnkedinUser.isloggedin) { GlobusHttpHelper HttpHelper = objLnkedinUser.globusHttpHelper; string postdata = string.Empty; string postUrl = string.Empty; string ResLogin = string.Empty; string csrfToken = string.Empty; string sourceAlias = string.Empty; string referal = string.Empty; string ReturnString = string.Empty; string PostGrpDiscussion = string.Empty; string PostGrpMoreDetails = string.Empty; string PostGrpAttachLink = string.Empty; string PostGrpKey = string.Empty; try { string MessageText = string.Empty; string PostedMessage = string.Empty; string pageSource = string.Empty; pageSource = HttpHelper.getHtmlfromUrl1(new Uri("http://www.linkedin.com/home?trk=hb_tab_home_top")); if (pageSource.Contains("csrfToken")) { string pattern = @"\"; csrfToken = pageSource.Substring(pageSource.IndexOf("csrfToken"), 50); string[] Arr = csrfToken.Split('&'); csrfToken = Arr[0]; csrfToken = csrfToken.Replace("csrfToken", "").Replace("\"", string.Empty).Replace("value", string.Empty).Replace("cs", string.Empty).Replace("id", string.Empty).Replace("=", string.Empty); csrfToken = csrfToken.Replace(pattern, string.Empty.Trim()); } if (pageSource.Contains("sourceAlias")) { string pattern1 = @"\"; sourceAlias = pageSource.Substring(pageSource.IndexOf("sourceAlias"), 100); string[] Arr = sourceAlias.Split('"'); sourceAlias = Arr[2]; sourceAlias = sourceAlias.Replace(pattern1, string.Empty.Trim()); } try { foreach (var Itegid in GlobalsGroups.SelectedGroups) { string[] grpNameWithDetails = Itegid.Split('^'); try { lock (Locked_GrpKey_Post) { if (GlobalsGroups.Que_GrpKey_Post.Count > 0) { try { PostGrpKey = GlobalsGroups.Que_GrpKey_Post.Dequeue(); } catch { } } } lock (Locked_GrpPostTitle_Post) { if (GlobalsGroups.Que_GrpPostTitle_Post.Count > 0) { try { PostGrpDiscussion = GlobalsGroups.Que_GrpPostTitle_Post.Dequeue(); } catch { } } } lock (Locked_GrpMoreDtl_Post) { if (GlobalsGroups.Que_GrpMoreDtl_Post.Count > 0) { try { PostGrpMoreDetails = GlobalsGroups.Que_GrpMoreDtl_Post.Dequeue(); //Que_GrpMoreDtl_Post.Clear(); } catch { } } } lock (Locked_Que_GrpAttachLink_Post) { if (GlobalsGroups.Que_GrpAttachLink_Post.Count > 0) { try { PostGrpAttachLink = GlobalsGroups.Que_GrpAttachLink_Post.Dequeue(); } catch { } } } string[] grpDisplay = Itegid.Split('^'); string GrpName = grpDisplay[0].ToString().Replace("[", string.Empty).Trim(); string[] PostGid = grpDisplay[1].Replace("]", string.Empty).Split(','); string Gid = string.Empty; // HJKHKJH try { if (NumberHelper.ValidateNumber(PostGid[1].Trim())) { Gid = PostGid[1].Trim(); } else if (NumberHelper.ValidateNumber(PostGid[2].Trim())) { Gid = PostGid[2].Trim(); } else if (NumberHelper.ValidateNumber(PostGid[3].Trim())) { Gid = PostGid[3].Trim(); } else if (NumberHelper.ValidateNumber(PostGid[4].Trim())) { Gid = PostGid[4].Trim(); } else if (NumberHelper.ValidateNumber(PostGid[5].Trim())) { Gid = PostGid[5].Trim(); } else if (NumberHelper.ValidateNumber(PostGid[6].Trim())) { Gid = PostGid[6].Trim(); } else if (NumberHelper.ValidateNumber(PostGid[7].Trim())) { Gid = PostGid[7].Trim(); } else if (NumberHelper.ValidateNumber(PostGid[8].Trim())) { Gid = PostGid[8].Trim(); } else if (NumberHelper.ValidateNumber(PostGid[9].Trim())) { Gid = PostGid[9].Trim(); } else if (NumberHelper.ValidateNumber(PostGid[10].Trim())) { Gid = PostGid[10].Trim(); } else if (NumberHelper.ValidateNumber(PostGid[11].Trim())) { Gid = PostGid[11].Trim(); } else if (NumberHelper.ValidateNumber(PostGid[12].Trim())) { Gid = PostGid[12].Trim(); } } catch { } //string ReqUrl = PostGrpAttachLink; string ReqUrl = PostGrpMoreDetails; ReqUrl = ReqUrl.Replace(":", "%3A").Replace("//", "%2F%2F"); referal = "http://www.linkedin.com/groups/" + grpDisplay[2].Replace(" ", "-") + "-" + Gid + "?goback=%2Egmr_" + Gid; string GetStatus = HttpHelper.getHtmlfromUrl(new Uri("http://www.linkedin.com/share?getPreview=&url=" + ReqUrl), referal); string ImgCount = string.Empty; try { int StartinImgCnt = GetStatus.IndexOf("current"); string startImgCnt = GetStatus.Substring(StartinImgCnt); int EndIndexImgCnt = startImgCnt.IndexOf("</span>"); string EndImgCnt = startImgCnt.Substring(0, EndIndexImgCnt).Replace("value\":", "").Replace("\"", ""); ImgCount = EndImgCnt.Replace("current", string.Empty).Replace(">", string.Empty); } catch { ImgCount = "0"; } string LogoUrl = string.Empty; try { int StartinImgUrl = GetStatus.IndexOf("url"); string startImgUrl = GetStatus.Substring(StartinImgUrl); int EndIndexImgUrl = startImgUrl.IndexOf("border="); string EndImgUrl = startImgUrl.Substring(0, EndIndexImgUrl).Replace("value\":", "").Replace("\"", ""); LogoUrl = EndImgUrl.Replace("url=", string.Empty).Trim(); } catch { LogoUrl = "false"; } string EntityId = string.Empty; try { int StartinEntityId = GetStatus.IndexOf("data-entity-id"); string startEntityId = GetStatus.Substring(StartinEntityId); int EndIndexEntityId = startEntityId.IndexOf("data-entity-url"); string EndEntityId = startEntityId.Substring(0, EndIndexEntityId).Replace("value\":", "").Replace("\"", ""); EntityId = EndEntityId.Replace("\"", string.Empty).Replace("data-entity-id", string.Empty).Replace("=", string.Empty).Trim(); } catch { } string contentTitle = string.Empty; try { int StartinContent = GetStatus.IndexOf("share-view-title"); string startContent = GetStatus.Substring(StartinContent); int EndIndexContent = startContent.IndexOf("</h4>"); string EndContent = startContent.Substring(0, EndIndexContent).Replace("value\":", "").Replace("\"", ""); contentTitle = EndContent.Replace("\"", string.Empty).Replace("\n", string.Empty).Replace("share-view-title", string.Empty).Replace("id=", string.Empty).Replace(">", string.Empty).Replace("&", "and").Replace("amp;", string.Empty).Trim(); if (contentTitle.Contains("#")) { contentTitle = contentTitle.Replace("and", "&"); contentTitle = Uri.EscapeDataString(contentTitle); } } catch { } string contentSummary = string.Empty; try { int StartinConSumm = GetStatus.IndexOf("share-view-summary\">"); string startConSumm = GetStatus.Substring(StartinConSumm); int EndIndexConSumm = startConSumm.IndexOf("</span>"); string EndConSumm = startConSumm.Substring(0, EndIndexConSumm).Replace("value\":", "").Replace("\"", ""); contentSummary = EndConSumm.Replace("\"", string.Empty).Replace("\n", string.Empty).Replace("share-view-summary", string.Empty).Replace("id=", string.Empty).Replace(">", string.Empty).Replace("</span<a href=#", string.Empty).Trim(); contentSummary = contentSummary.Replace(",", "%2C").Replace(" ", "%20"); if (contentSummary.Contains("#")) { contentSummary = contentSummary.Replace("and", "&"); contentSummary = Uri.EscapeDataString(contentSummary); } } catch { } string PostGroupstatus = string.Empty; string ResponseStatusMsg = string.Empty; csrfToken = csrfToken.Replace("<meta http-", "").Replace(">", "").Trim(); try { //PostGroupstatus = "csrfToken=" + csrfToken + "&postTitle=" + PostGrpDiscussion + "&postText=" + PostGrpMoreDetails + "&pollChoice1-ANetPostForm=&pollChoice2-ANetPostForm=&pollChoice3-ANetPostForm=&pollChoice4-ANetPostForm=&pollChoice5-ANetPostForm=&pollEndDate-ANetPostForm=0&contentImageCount=0&contentImageIndex=-1&contentImage=&contentEntityID=&contentUrl=&contentTitle=&contentSummary=&contentImageIncluded=true&%23=&gid=" + Gid.Trim() + "&postItem=&ajax=true&tetherAccountID=&facebookTetherID="; PostGroupstatus = "csrfToken=" + csrfToken + "&postTitle=" + PostGrpDiscussion + "&postText=" + PostGrpMoreDetails + "&pollChoice1-ANetPostForm=&pollChoice2-ANetPostForm=&pollChoice3-ANetPostForm=&pollChoice4-ANetPostForm=&pollChoice5-ANetPostForm=&pollEndDate-ANetPostForm=0&contentImageCount=" + ImgCount + "&contentImageIndex=-1&contentImage=" + LogoUrl + "&contentEntityID=" + EntityId + "&contentUrl=" + ReqUrl + "&contentTitle=" + contentTitle + "&contentSummary=" + contentSummary + "&contentImageIncluded=true&%23=&gid=" + Gid + "&postItem=&ajax=true&tetherAccountID=&facebookTetherID="; ResponseStatusMsg = HttpHelper.postFormData(new Uri("http://www.linkedin.com/groups"), PostGroupstatus); } catch { } #region written by sharan try { string PagesourceProfile = HttpHelper.getHtmlfromUrl(new Uri("https://www.linkedin.com/profile/view?id=394473043&trk=nav_responsive_tab_profile")); string GoBackValue = string.Empty; string Url = string.Empty; if (PagesourceProfile.Contains("&goback=")) { GoBackValue = Utils.getBetween(PagesourceProfile, "&goback=", "&").Trim(); Url = "https://www.linkedin.com/grp/home?gid=" + Gid + "&goback=" + GoBackValue; } PostGroupstatus = "csrfToken=" + csrfToken + "&title=" + PostGrpDiscussion + "&details=" + PostGrpMoreDetails + "&groupId=" + Gid + "&displayCategory=DISCUSSION"; ResponseStatusMsg = HttpHelper.postFormDataRef(new Uri("https://www.linkedin.com/grp/postForm/submit"), PostGroupstatus, Url, "", ""); } catch (Exception ex) { } #endregion string CSVHeader = "UserName" + "," + "HeaderPost" + "," + "Details Post" + "," + "ToGroup"; if (ResponseStatusMsg.Contains("SUCCESS") || ResponseStatusMsg.Contains("Accept the description According to you")) { GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Message Header Posted : " + PostGrpDiscussion + " Successfully on Group : " + grpDisplay[2] + " ]"); GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Message More Details Posted : " + PostGrpMoreDetails + " Successfully on Group : " + grpDisplay[2] + " ]"); string CSV_Content = objLnkedinUser.username + "," + PostGrpDiscussion.Replace(",", ";") + "," + PostGrpMoreDetails.Replace(",", ";") + "," + grpDisplay[2].Replace(",", string.Empty); CSVUtilities.ExportDataCSVFile(CSVHeader, CSV_Content, FilePath.path_GroupUpdates); } else if (ResponseStatusMsg.Contains("Your request to join is still pending")) { GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Your membership is pending approval on a Group:" + grpDisplay[2] + " ]"); GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Message Header: " + PostGrpDiscussion + " Not Posted on Group:" + grpDisplay[2] + " Because Your membership is pending for approval. ]"); GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Message More Details: " + PostGrpMoreDetails + " Not Posted on Group:" + grpDisplay[2] + " Because Your membership is pending for approval. ]"); GlobusFileHelper.AppendStringToTextfileNewLine("Your membership is pending approval on a Group:" + grpDisplay[2], FilePath.path_GroupUpdate); GlobusFileHelper.AppendStringToTextfileNewLine("Message Header: " + PostGrpDiscussion + " Not Posted on Group:" + grpDisplay[2] + " Because Your membership is pending for approval. ", FilePath.path_GroupUpdate); GlobusFileHelper.AppendStringToTextfileNewLine("Message More Details: " + PostGrpMoreDetails + " Not Posted on Group:" + grpDisplay[2] + " Because Your membership is pending for approval. ", FilePath.path_GroupUpdate); } else if (ResponseStatusMsg.Contains("Your post has been submitted for review")) { GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Message Header Posted : " + PostGrpDiscussion + " Successfully on Group : " + grpDisplay[2] + " ]"); GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Message More Details Posted : " + PostGrpMoreDetails + " Successfully on Group : " + grpDisplay[2] + " ]"); GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Your post has been submitted for review ]"); string CSV_Content = objLnkedinUser.username + "," + PostGrpDiscussion.Replace(",", ";") + "," + PostGrpMoreDetails.Replace(",", ";") + "," + grpDisplay[2]; } else if (ResponseStatusMsg.Contains("Error")) { //Log("[ " + DateTime.Now + " ] => [ Error in Post ]"); GlobusFileHelper.AppendStringToTextfileNewLine("Error in Post", FilePath.path_GroupUpdate); } else { GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Message Not Posted ]"); GlobusFileHelper.AppendStringToTextfileNewLine("Message Not Posted", FilePath.path_GroupUpdate); } int delay = RandomNumberGenerator.GenerateRandom(GlobalsGroups.minDelay, GlobalsGroups.maxDelay); GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Delay for : " + delay + " Seconds ]"); Thread.Sleep(delay * 1000); } catch (Exception ex) { GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error --> Group Update --> cmbGroupUser_SelectedIndexChanged() ---1--->>>> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace + " Stack Trace >>> " + ex.StackTrace, FilePath.Path_LinkedinGetGroupMemberErrorLogs); //Log("[ " + DateTime.Now + " ] => [ Error:" + ex.Message + "StackTrace --> >>>" + ex.StackTrace + " ]"); } } } catch (Exception ex) { GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error --> Group Update --> cmbGroupUser_SelectedIndexChanged() ---1--->>>> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace, FilePath.Path_LinkedinErrorLogs); GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error --> Group Update --> cmbGroupUser_SelectedIndexChanged() ---1--->>>> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace, FilePath.Path_LinkedinGetGroupMemberErrorLogs); // Log("[ " + DateTime.Now + " ] => [ Error:" + ex.Message + "StackTrace --> >>>" + ex.StackTrace + " ]"); } } catch (Exception ex) { GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error --> Group Update --> cmbGroupUser_SelectedIndexChanged() ---2--->>>> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace, FilePath.Path_LinkedinErrorLogs); GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error --> Group Update --> cmbGroupUser_SelectedIndexChanged() ---2--->>>> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace, FilePath.Path_LinkedinGetGroupMemberErrorLogs); } } } catch (Exception ex) { } }
public void StartSendUpdate(ref LinkedinUser objLinkedinUser) { try { int numberOfThreads = 0; if (GlobalsGroups.ListGrpDiscussion.Count > 0) { foreach (string Message in GlobalsGroups.ListGrpDiscussion) { GlobalsGroups.Que_GrpPostTitle_Post.Enqueue(Message); } } else { GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Please Add Group Title Message Text ]"); return; } if (GlobalsGroups.GroupUrl.Count > 0) { foreach (string grpKey in GlobalsGroups.GroupUrl) { GlobalsGroups.Que_GrpKey_Post.Enqueue(grpKey); } } else { GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Group User Key Invalid ]"); return; } if (GlobalsGroups.ListGrpMoreDetails.Count > 0) { foreach (string grpmoredtl in GlobalsGroups.ListGrpMoreDetails) { GlobalsGroups.Que_GrpMoreDtl_Post.Enqueue(grpmoredtl); } } else { GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Please Add Group MoreDetails Message Text ]"); return; } //if (chkSameMessageForAllGroup.Checked) { GlobalsGroups.Que_GrpPostTitle_Post.Clear(); GlobalsGroups.Que_GrpMoreDtl_Post.Clear(); if (GlobalsGroups.ListGrpDiscussion.Count > 0) { foreach (string Message in GlobalsGroups.ListGrpDiscussion) { GlobalsGroups.Que_GrpPostTitle_Post.Enqueue(Message); break; } } else { GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Please Add Group Title Message Text ]"); return; } if (GlobalsGroups.ListGrpMoreDetails.Count > 0) { foreach (string grpmoredtl in GlobalsGroups.ListGrpMoreDetails) { GlobalsGroups.Que_GrpMoreDtl_Post.Enqueue(grpmoredtl); break; } } else { GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Please Add Group MoreDetails Message Text ]"); return; } } PostGroupMsgUpdate(ref objLinkedinUser); } catch (Exception ex) { GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error --> Group Update --> LinkedInGroupMessage() >>>> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace, FilePath.Path_LinkedinErrorLogs); GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error --> Group Update --> LinkedInGroupMessage() >>>> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace, FilePath.Path_LinkedinGetGroupMemberErrorLogs); } }
public Dictionary <string, string> GetGroups(ref LinkedinUser objLinkedInUser) { string pageSource = string.Empty; GlobusHttpHelper HttpHelper = objLinkedInUser.globusHttpHelper; Dictionary <string, string> GroupName = new Dictionary <string, string>(); try { string url = "https://www.linkedin.com"; pageSource = HttpHelper.getHtmlfromUrl(new Uri(url)); string[] arr = Regex.Split(pageSource, "<h3>"); string profId = Utils.getBetween(arr[2], "<a href=\"", "\""); pageSource = HttpHelper.getHtmlfromUrl(new Uri(profId)); string[] arr1 = Regex.Split(pageSource, "<h3>"); string profileId = Utils.getBetween(arr1[2], "<a href=\"", "\""); pageSource = HttpHelper.getHtmlfromUrl(new Uri(profileId)); string[] arr1_groups = Regex.Split(pageSource, "link_groups_settings"); arr1_groups = arr1_groups.Skip(1).ToArray(); if (arr1_groups.Length > 0) { GlobusLogHelper.log.Info(arr1_groups.Length + " Groups Found"); } foreach (string item in arr1_groups) { string grpName = string.Empty; string grpId = string.Empty; grpName = Utils.getBetween(item, "name\":\"", "\",\""); grpName = grpName.Replace(":", ""); grpId = Utils.getBetween(item, "&gid=", "&"); Thread.Sleep(500); GlobusLogHelper.log.Info(grpName); grpName = grpName + "<:><:>" + objLinkedInUser.username; if (NumberHelper.ValidateNumber(grpId)) { GroupName.Add(grpName, grpId); } } if (GroupName.Count == 0) { try { string url_to_get_Groups = string.Empty; url_to_get_Groups = Utils.getBetween(pageSource, "<div id=\"groups-container", "</div>"); url_to_get_Groups = Utils.getBetween(url_to_get_Groups, "url\":\"", "\"})"); pageSource = HttpHelper.getHtmlfromUrl(new Uri(url_to_get_Groups)); arr1_groups = Regex.Split(pageSource, "link_groups_settings"); arr1_groups = arr1_groups.Skip(1).ToArray(); foreach (string item in arr1_groups) { try { string grpName = string.Empty; string grpId = string.Empty; grpName = Utils.getBetween(item, "name\":\"", "\",\""); grpName = grpName.Replace(":", ""); grpId = Utils.getBetween(item, "&gid=", "&"); grpName = grpName + "<:><:>" + objLinkedInUser.username; if (NumberHelper.ValidateNumber(grpId)) { GroupName.Add(grpName, grpId); } } catch (Exception ex) { } } } catch (Exception ex) { } } } catch (Exception ex) { } return(GroupName); }