예제 #1
0
        //public bool LoginHttpHelper(string username, string password, string proxyaddress, string proxyport, string proxyusername, string proxypassword, ref GlobusHttpHelper HttpHelper, ref string Message)
        //{
        //    LoggerLoginLogout("Logging Block.............");
        //    string Url = string.Empty;
        //    int port = 888;
        //    Regex PortCheck = new Regex("^[0-9]*$");

        //    _AccountUser = username;
        //    _AccountPass = password;
        //    _ProxyAddress = proxyaddress;
        //    _ProxyPort = proxyport;
        //    _ProxyUserName = proxyusername;
        //    _ProxyPassword = proxypassword;

        //    if (PortCheck.IsMatch(_ProxyPort) && !string.IsNullOrEmpty(_ProxyPort))
        //    {
        //        port = int.Parse(_ProxyPort);
        //    }
        //    Url = "https://www.linkedin.com/";
        //    ////string pageSrcLogin = HttpChilkat.GetHtmlProxy(Url, proxyAddress, proxyPort, proxyUserName, proxyPassword);
        //    string pageSrcLogin = HttpHelper.getHtmlfromUrlProxy(new Uri(Url), _ProxyAddress, port, _ProxyUserName, _ProxyPassword);


        //    string postdata = string.Empty;
        //    string postUrl = string.Empty;
        //    string ResLogin = string.Empty;
        //    string csrfToken = string.Empty;
        //    string sourceAlias = string.Empty;

        //    if (pageSrcLogin.Contains("csrfToken"))
        //    {
        //        csrfToken = pageSrcLogin.Substring(pageSrcLogin.IndexOf("csrfToken"), 100);
        //        string[] Arr = csrfToken.Split('"');
        //        csrfToken = Arr[2];
        //    }

        //    if (pageSrcLogin.Contains("sourceAlias"))
        //    {
        //        sourceAlias = pageSrcLogin.Substring(pageSrcLogin.IndexOf("sourceAlias"), 100);
        //        string[] Arr = sourceAlias.Split('"');
        //        sourceAlias = Arr[2];
        //    }
        //    //_AccountUser = "******";
        //    //_AccountPass = "******";

        //    _AccountUser = _AccountUser.Replace("@", "%40");
        //    postUrl = "https://www.linkedin.com/uas/login-submit";
        //    postdata = "session_key=" + _AccountUser + "&session_password="******"&source_app=&trk=guest_home_login&session_redirect=&csrfToken=" + csrfToken + "&sourceAlias=" + sourceAlias;

        //    ResLogin = HttpHelper.postFormData(new Uri(postUrl), postdata);
        //    if (ResLogin.Contains("The email address or password you provided does not match our records"))
        //    {
        //        //Message = "The email address or password does not match our records";
        //        //return false;
        //    }
        //    else if (ResLogin.Contains("Sign Out") && ResLogin.Contains("Profiles"))
        //    {
        //        Message = "Logged in";
        //        return true;
        //    }
        //    else if (ResLogin.Contains("Your LinkedIn account has been temporarily restricted"))
        //    {
        //        Message = "Your LinkedIn account has been temporarily restricted";
        //        return false;
        //    }

        //    Url = "http://www.linkedin.com/home?trk=hb_tab_home_top";
        //    pageSrcLogin = HttpHelper.getHtmlfromUrlProxy(new Uri(Url), _ProxyPassword, port, _ProxyUserName, _ProxyPassword);

        //    //LogoutHttpHelper(ref HttpHelper);

        //    //Url = "http://www.linkedin.com/home?trk=hb_tab_home_top";
        //    //pageSrcLogin = HttpHelper.getHtmlfromUrlProxy(new Uri(Url), _ProxyPassword, 888, _ProxyUserName, _ProxyPassword);
        //    return true;
        //}

        public void LogoutHttpHelper(ref GlobusHttpHelper HttpHelper)
        {
            string Url = string.Empty;

            Url = "http://www.linkedin.com/home?trk=hb_tab_home_top";
            ////string pageSrcLogin = HttpChilkat.GetHtmlProxy(Url, proxyAddress, proxyPort, proxyUserName, proxyPassword);
            string pageSrcHome = HttpHelper.getHtmlfromUrl1(new Uri(Url));

            Url = "https://www.linkedin.com/secure/login?session_full_logout=&trk=hb_signout";
            string pageSrcLogout = HttpHelper.getHtmlfromUrl1(new Uri(Url));
        }
        public void SetProfilePic(ref GlobusHttpHelper httpHelper)
        {
            try
            {
                string homePageSource    = httpHelper.getHtmlfromUrl1(new Uri("http://www.linkedin.com"));
                string ProfileID         = GetProfileId(ref httpHelper, homePageSource);
                string Url               = "http://www.linkedin.com/profile/view?id=" + ProfileID + "&trk=tab_pro";
                string ProfilePageSource = httpHelper.getHtmlfromUrl1(new Uri(Url));

                if (!string.IsNullOrEmpty(homePageSource))
                {
                    try
                    {
                        if (ProfilePageSource.Contains("link__nprofileEdit"))
                        {
                            try
                            {
                                string link__nprofileEdit = httpHelper.GetUniqueKeyBasedValue(ProfilePageSource, "link__nprofileEdit");
                            }
                            catch { }
                        }

                        if (ProfilePageSource.Contains("link__editPictureInfo"))
                        {
                            try
                            {
                                string link__editPictureInfo = httpHelper.GetUniqueKeyBasedValue(ProfilePageSource, "link__editPictureInfo");
                            }
                            catch { }
                        }
                        string refere = string.Empty;
                        try
                        {
                            UploadPic(ref httpHelper, ProfilePageSource, refere);
                        }
                        catch { }
                    }
                    catch { }
                }
            }
            catch { }

            finally
            {
                Log("[ " + DateTime.Now + " ] => [ PROCESS COMPLETED ]");
                Log("--------------------------------------------------------------------------------------------------------------------------------------------");
            }
        }
예제 #3
0
        public void StartCreateGroup(ref GlobusHttpHelper HttpHelper, int mindelay, int maxdelay)
        {
            try
            {
                string UploadInfo            = string.Empty;
                string status                = string.Empty;
                string TempID                = string.Empty;
                string image                 = string.Empty;
                string PostCreateGroup       = string.Empty;
                string ResponseStatusMsg     = string.Empty;
                string urlForNewGroupCreated = string.Empty;
                Log("[ " + DateTime.Now + " ] => [ Group Creation In Account :" + accountUser + " ]");
                try
                {
                    string PageSource1 = string.Empty;
                    for (int i = 0; i <= 5; i++)
                    {
                        PageSource1 = HttpHelper.getHtmlfromUrl1(new Uri("http://www.linkedin.com/createGroup?displayCreate=&trk=anet_creategrp"));
                        if (!string.IsNullOrEmpty(PageSource1))
                        {
                            break;
                        }
                        Thread.Sleep(2 * 1000);
                    }

                    if (PageSource1.Contains("Confirm Your Email Address:"))
                    {
                        //
                        GlobusFileHelper.AppendStringToTextfileNewLine(accountUser + ":" + accountPass + ":" + proxyAddress + ":" + proxyPort + ":" + proxyUserName + ":" + proxyPassword, Globals.path_NotCreateGroup);
                        Log("[ " + DateTime.Now + " ] => [ Cannot Create Group , Confirm Your Email Address for Create group you must have at least one confirmed email address: " + accountUser + " ]");
                        return;
                    }

                    csrfToken = GetCsrfToken(PageSource1);
                    try
                    {
                        int    StartIndex = PageSource1.IndexOf("name=\"upload_info\"");
                        string start      = PageSource1.Substring(StartIndex).Replace("name=\"upload_info\"", "").Replace("type=\"hidden\"", "").Replace("value=\"", "");
                        int    EndIndex   = start.IndexOf("\"/>");
                        string end        = start.Substring(0, EndIndex).Replace("value=\"", "").Replace(" ", "");
                        UploadInfo = end;
                    }
                    catch (Exception ex)
                    {
                    }

                    NameValueCollection nvc = new NameValueCollection();
                    nvc.Add("csrfToken", csrfToken);
                    nvc.Add("upload_info", UploadInfo);
                    nvc.Add("callback", "logo.processResponseLargeLogo");
                    nvc.Add("isCSMode", "false");
                    nvc.Add("_method", "PUT");

                    string[] array = Regex.Split(PostIamge, ".");
                    if (!string.IsNullOrEmpty(PostIamge))
                    {
                        Log("[ " + DateTime.Now + " ] => [ Uploading Logo ]");
                    }
                    image = array[array.Length - 1];
                    string result = HttpHelper.HttpUploadFileBackground("http://www.linkedin.com/mupld/upload", PostIamge, "file", "image/" + image, nvc, true, ref status);
                    if (result.Contains("{\"status\":\"ERROR\""))
                    {
                        Log("[ " + DateTime.Now + " ] => [ Error In Uploading Logo ! ]");
                        return;
                    }
                    try
                    {
                        int    Startindex = result.IndexOf("value\":");
                        string start      = result.Substring(Startindex);
                        int    EndIndex   = start.IndexOf("\",");
                        string End        = start.Substring(0, EndIndex).Replace("value\":", "").Replace("\"", "");
                        TempID = End;
                    }
                    catch (Exception ex)
                    {
                    }
                    string CSVHeader  = "UserName" + "," + "GroupName" + "," + "CreatedGroupUrl";
                    string GetRequest = HttpHelper.getHtmlfromUrl1(new Uri("http://media03.linkedin.com/media/" + TempID));
                    TempID = Uri.EscapeDataString(TempID.Replace("\\", ""));

                    if (SearchCriteria.CreateGroupStatus == "Member")
                    {
                        Log("[ " + DateTime.Now + " ] => [ Creating Member Group ]");
                        PostCreateGroup   = "csrfToken=" + Uri.EscapeDataString(csrfToken) + "&acceptLogoTerms=acceptLogoTerms&groupName=" + PostGrpName + "&groupCategory=" + SearchCriteria.GroupType + "&otherGroupCategory=&shortDesc=" + PostGrpSummry + "&longDesc=" + PostGrpDesc + "&homeSite=" + PostGrpWebsite + "&groupEmail=" + Uri.EscapeDataString(accountUser) + "&groupInDirectory-open=groupInDirectory-open&logoInProfiles-open=logoInProfiles-open&membersSendInvites-open=membersSendInvites-open&access=request&groupInDirectory-request=groupInDirectory-request&logoInProfiles-request=logoInProfiles-request&emailDomains=&language=" + SearchCriteria.GroupLang + "&countryCode=&postalCode=&acceptContract=acceptContract&create=Create+a+Members-Only+Group&gid=&largeLogoTempID=" + TempID + "&discVisibility=false&tetherAccountID=&facebookTetherID=&uncroppedHeroImageID=&croppedHeroImageID=&heroImageCropParams=";
                        ResponseStatusMsg = HttpHelper.postFormDataRef(new Uri("http://www.linkedin.com/createGroup"), PostCreateGroup, "http://www.linkedin.com/createGroup", "", "");

                        Thread.Sleep(2000);

                        if (ResponseStatusMsg.Contains("Please choose a different group name.") || ResponseStatusMsg.Contains("Sorry this group name is not available. Please choose a different one."))
                        {
                            PostGrpName = PostGrpName + "New";
                            string CSV_Content = accountUser + "," + PostGrpName;
                            PostCreateGroup   = "csrfToken=" + Uri.EscapeDataString(csrfToken) + "&acceptLogoTerms=acceptLogoTerms&groupName=" + PostGrpName + "&groupCategory=" + SearchCriteria.GroupType + "&otherGroupCategory=&shortDesc=" + PostGrpSummry + "&longDesc=" + PostGrpDesc + "&homeSite=" + PostGrpWebsite + "&groupEmail=" + Uri.EscapeDataString(accountUser) + "&groupInDirectory-open=groupInDirectory-open&logoInProfiles-open=logoInProfiles-open&membersSendInvites-open=membersSendInvites-open&access=request&groupInDirectory-request=groupInDirectory-request&logoInProfiles-request=logoInProfiles-request&emailDomains=&language=" + SearchCriteria.GroupLang + "&countryCode=&postalCode=&acceptContract=acceptContract&create=Create+a+Members-Only+Group&gid=&largeLogoTempID=" + TempID + "&discVisibility=false&tetherAccountID=&facebookTetherID=&uncroppedHeroImageID=&croppedHeroImageID=&heroImageCropParams=";
                            ResponseStatusMsg = HttpHelper.postFormDataRef(new Uri("http://www.linkedin.com/createGroup"), PostCreateGroup, "http://www.linkedin.com/createGroup", "", "");
                            Thread.Sleep(2000);
                            if (ResponseStatusMsg.Contains("Send Invitation"))
                            {
                                Log("[ " + DateTime.Now + " ] => [ New Member-Only-Group Create : " + PostGrpName + " Place of " + PostGrpName + " has Successfully Created on: " + accountUser + " ]");
                                CSV_Content = accountUser + "," + PostGrpName;
                                CSVUtilities.ExportDataCSVFile(CSVHeader, CSV_Content, Globals.path_CreateGroups);
                            }
                        }
                        else if (ResponseStatusMsg.Contains("Send Invitation"))
                        {
                            Log("[ " + DateTime.Now + " ] => [ Member-Only-Group: " + PostGrpName + " has Successfully Created on: " + accountUser + " has Successfully Created on: " + urlForNewGroupCreated + " ]");
                            string CSV_Content = accountUser + "," + PostGrpName + "," + urlForNewGroupCreated;
                            CSVUtilities.ExportDataCSVFile(CSVHeader, CSV_Content, Globals.path_CreateGroups);
                            urlForNewGroupCreated = string.Empty;
                        }
                        else if (ResponseStatusMsg.Contains("You must confirm your primary email address before creating a group."))
                        {
                            Log("[ " + DateTime.Now + " ] => [ User: "******"  must confirm his/her primary email address before creating a group. ]");
                            GlobusFileHelper.AppendStringToTextfileNewLine(accountUser + ":" + accountPass + ":" + proxyAddress + ":" + proxyPort + ":" + proxyUserName + ":" + proxyPassword, Globals.path_NotCreatedGroups);
                            return;
                        }
                        else if (ResponseStatusMsg.Contains("Sorry you cannot create more groups on LinkedIn because you already own too many groups."))
                        {
                            Log("[ " + DateTime.Now + " ] => [ Sorry User: "******" cannot create more groups on LinkedIn because his/her already own too many groups. ]");
                            GlobusFileHelper.AppendStringToTextfileNewLine(accountUser + ":" + accountPass + ":" + proxyAddress + ":" + proxyPort + ":" + proxyUserName + ":" + proxyPassword, Globals.path_NotCreatedGroups);
                            return;
                        }
                        else if (ResponseStatusMsg.Contains("You cannot create new groups because you've exceeded the maximum number of group memberships."))
                        {
                            Log("[ " + DateTime.Now + " ] => [ Sorry User: "******" You cannot create new groups because you've exceeded the maximum number of group memberships. ]");
                            GlobusFileHelper.AppendStringToTextfileNewLine("Sorry User: "******" You cannot create new groups because you've exceeded the maximum number of group memberships.", Globals.path_NotCreatedGroups);
                            return;
                        }
                        else if (ResponseStatusMsg.Contains("Please enter a valid URL."))
                        {
                            Log("[ " + DateTime.Now + " ] => [ Sorry User: "******" You cannot create new groups because your Web Site URL is not Valid. ]");
                            GlobusFileHelper.AppendStringToTextfileNewLine(accountUser + ":" + accountPass + ":" + proxyAddress + ":" + proxyPort + ":" + proxyUserName + ":" + proxyPassword, Globals.path_NotCreatedGroups);
                            return;
                        }
                        else
                        {
                            Log("[ " + DateTime.Now + " ] => [ Group Not Created With Username >>> " + accountUser + " ]");
                            GlobusFileHelper.AppendStringToTextfileNewLine(accountUser + ":" + accountPass + ":" + proxyAddress + ":" + proxyPort + ":" + proxyUserName + ":" + proxyPassword, Globals.path_NotCreatedGroups);
                        }
                    }
                    else if (SearchCriteria.CreateGroupStatus == "Open")
                    {
                        try
                        {
                            Log("[ " + DateTime.Now + " ] => [ Creating Open Group ]");
                            PostCreateGroup   = "csrfToken=" + Uri.EscapeDataString(csrfToken) + "&acceptLogoTerms=acceptLogoTerms&groupName=" + PostGrpName + "&groupCategory=" + SearchCriteria.GroupType + "&otherGroupCategory=&shortDesc=" + PostGrpSummry + "&longDesc=" + PostGrpDesc + "&homeSite=" + PostGrpWebsite + "&groupEmail=" + Uri.EscapeDataString(accountUser) + "&access=open&groupInDirectory-open=groupInDirectory-open&logoInProfiles-open=logoInProfiles-open&membersSendInvites-open=membersSendInvites-open&groupInDirectory-request=groupInDirectory-request&logoInProfiles-request=logoInProfiles-request&emailDomains=&language=" + SearchCriteria.GroupLang + "&countryCode=&postalCode=&acceptContract=acceptContract&create=Create+an+Open+Group&gid=&largeLogoTempID=" + TempID + "&discVisibility=true&tetherAccountID=&facebookTetherID=&uncroppedHeroImageID=&croppedHeroImageID=&heroImageCropParams=";
                            ResponseStatusMsg = HttpHelper.postFormDataRef(new Uri("http://www.linkedin.com/createGroup"), PostCreateGroup, "http://www.linkedin.com/createGroup?displayCreate=&displayCreate=&trk=hb_side_crgrp", "", "");

                            if (ResponseStatusMsg.Contains("Please choose a different group name.") || ResponseStatusMsg.Contains("Sorry this group name is not available. Please choose a different one."))
                            {
                                //Log("[ " + DateTime.Now + " ] => [ No more unique data avaialble for creating groups -- Please insert data ]");
                                Log("[ " + DateTime.Now + " ] => [ No more unique data available for creating groups -- Please insert data ]");
                                return;

                                PostGrpName       = PostGrpName + " New";
                                PostCreateGroup   = "csrfToken=" + Uri.EscapeDataString(csrfToken) + "&acceptLogoTerms=acceptLogoTerms&groupName=" + PostGrpName + "&groupCategory=" + SearchCriteria.GroupType + "&otherGroupCategory=&shortDesc=" + PostGrpSummry + "&longDesc=" + PostGrpDesc + "&homeSite=" + PostGrpWebsite + "&groupEmail=" + Uri.EscapeDataString(accountUser) + "&access=open&groupInDirectory-open=groupInDirectory-open&logoInProfiles-open=logoInProfiles-open&membersSendInvites-open=membersSendInvites-open&groupInDirectory-request=groupInDirectory-request&logoInProfiles-request=logoInProfiles-request&emailDomains=&language=" + SearchCriteria.GroupLang + "&countryCode=&postalCode=&acceptContract=acceptContract&create=Create+an+Open+Group&gid=&largeLogoTempID=" + TempID + "&discVisibility=true&tetherAccountID=&facebookTetherID=&uncroppedHeroImageID=&croppedHeroImageID=&heroImageCropParams=";
                                ResponseStatusMsg = HttpHelper.postFormDataRef(new Uri("http://www.linkedin.com/createGroup"), PostCreateGroup, "http://www.linkedin.com/createGroup?displayCreate=&displayCreate=&trk=hb_side_crgrp", "", "");

                                Thread.Sleep(2000);

                                if (ResponseStatusMsg.Contains("Send Invitation"))
                                {
                                    Log("[ " + DateTime.Now + " ] => [ New Open-Group Create : " + PostGrpName + " Place of " + PostGrpName + " has Successfully Created on: " + accountUser + " ]");
                                    string CSV_Content = accountUser + "," + PostGrpName;
                                    CSVUtilities.ExportDataCSVFile(CSVHeader, CSV_Content, Globals.path_CreateGroups);
                                }
                                else
                                {
                                    Log("[ " + DateTime.Now + " ] => [ New Open-Group Not Created : " + PostGrpName + " Place of " + PostGrpName + " has Successfully Created on: " + accountUser + " ]");
                                }
                            }
                            else if (ResponseStatusMsg.Contains("Send Invitation"))
                            {
                                string   End       = string.Empty;
                                string[] arrForGid = Regex.Split(ResponseStatusMsg, "gid");
                                //arrForGid.Skip(1).ToArray();

                                foreach (string item in arrForGid)
                                {
                                    if (!item.Contains("<!DOCTYPE html"))
                                    {
                                        int    Startindex = item.IndexOf("=");
                                        string start      = item.Substring(Startindex);
                                        int    EndIndex   = start.IndexOf("&");
                                        End = start.Substring(0, EndIndex).Replace("=", "").Replace("\"", "").Replace("&amp", "");
                                        break;
                                    }
                                }
                                urlForNewGroupCreated = "http://www.linkedin.com/groups?home=&gid=" + End;
                                Log("[ " + DateTime.Now + " ] => [ Open-Group: " + PostGrpName + " has  Successfully Created on: " + accountUser + " ]");
                                string CSV_Content = accountUser + "," + PostGrpName + "," + urlForNewGroupCreated;
                                CSVUtilities.ExportDataCSVFile(CSVHeader, CSV_Content, Globals.path_CreateGroups);
                            }
                            else if (ResponseStatusMsg.Contains("You must confirm your primary email address before creating a group."))
                            {
                                Log("[ " + DateTime.Now + " ] => [ User: "******"  must confirm his/her primary email address before creating a group.  ]");
                                GlobusFileHelper.AppendStringToTextfileNewLine(accountUser + ":" + accountPass + ":" + proxyAddress + ":" + proxyPort + ":" + proxyUserName + ":" + proxyPassword, Globals.path_NotCreatedGroups);
                                return;
                            }
                            else if (ResponseStatusMsg.Contains("Sorry you cannot create more groups on LinkedIn because you already own too many groups."))
                            {
                                Log("[ " + DateTime.Now + " ] => [ Sorry User: "******" cannot create more groups on LinkedIn because his/her already own too many groups. ]");
                                GlobusFileHelper.AppendStringToTextfileNewLine(accountUser + ":" + accountPass + ":" + proxyAddress + ":" + proxyPort + ":" + proxyUserName + ":" + proxyPassword, Globals.path_NotCreatedGroups);
                            }
                            else if (ResponseStatusMsg.Contains("You cannot create new groups because you've exceeded the maximum number of group memberships."))
                            {
                                Log("[ " + DateTime.Now + " ] => [ Sorry User: "******" You cannot create new groups because you've exceeded the maximum number of group memberships. ]");
                                GlobusFileHelper.AppendStringToTextfileNewLine(accountUser + ":" + accountPass + ":" + proxyAddress + ":" + proxyPort + ":" + proxyUserName + ":" + proxyPassword, Globals.path_NotCreatedGroups);
                                //return;
                            }
                            else if (ResponseStatusMsg.Contains("Please enter a valid URL."))
                            {
                                Log("[ " + DateTime.Now + " ] => [ Sorry User: "******" You cannot create new groups because your Web Site URL is not Valid. ]");
                                GlobusFileHelper.AppendStringToTextfileNewLine(accountUser + ":" + accountPass + ":" + proxyAddress + ":" + proxyPort + ":" + proxyUserName + ":" + proxyPassword, Globals.path_NotCreatedGroups);
                                //return;
                            }
                            else if (ResponseStatusMsg.Contains("Sorry, but group management is currently unavailable. Please try again later"))
                            {
                                Log("[ " + DateTime.Now + " ] => [ Sorry User: "******" Sorry, but group management is currently unavailable. Please try again later. ]");
                                GlobusFileHelper.AppendStringToTextfileNewLine(accountUser + ":" + accountPass + ":" + proxyAddress + ":" + proxyPort + ":" + proxyUserName + ":" + proxyPassword, Globals.path_NotCreatedGroups);
                                //return;
                            }
                            else
                            {
                                GlobusFileHelper.AppendStringToTextfileNewLine(accountUser + ":" + accountPass + ":" + proxyAddress + ":" + proxyPort + ":" + proxyUserName + ":" + proxyPassword, Globals.path_NotCreatedGroups);
                                Log("[ " + DateTime.Now + " ] => [ Group Not Created With Username >>> " + accountUser + " ]");
                            }
                        }
                        catch (Exception ex)
                        {
                        }
                    }

                    int delay = RandomNumberGenerator.GenerateRandom(mindelay, maxdelay);
                    Log("[ " + DateTime.Now + " ] => [ Delay for : " + delay + " Seconds ]");
                    Thread.Sleep(delay * 1000);
                }
                catch (Exception ex)
                {
                }
                finally
                {
                }
            }
            catch
            {
            }
        }
예제 #4
0
        public void SendInvitation(ref GlobusHttpHelper HttpHelper, string grpURL, string grpId)
        {
            try
            {
                string FString     = string.Empty;
                string Nstring     = string.Empty;
                string connId      = string.Empty;
                string FullName    = string.Empty;
                string ToMsg       = string.Empty;
                string ContactName = string.Empty;

                string URL = "http://www.linkedin.com/manageGroup?dispAddMbrs=&gid=" + grpId + "&invtActn=im-invite&cntactSrc=cs-connections";

                string grpPageSource = HttpHelper.getHtmlfromUrl1(new Uri(URL));

                //string csrfToken = GetCsrfToken(grpPageSource);
                try
                {
                    int    startindex = grpPageSource.IndexOf("csrfToken=");
                    string start      = grpPageSource.Substring(startindex).Replace("csrfToken=", string.Empty);
                    int    endindex   = start.IndexOf("\"");
                    string end        = start.Substring(0, endindex).Replace("\"", string.Empty);
                    csrfToken = end.Trim();
                }
                catch
                { }
                ClsLinkedinMain             clsLinkedinMain = new ClsLinkedinMain();
                Dictionary <string, string> dTotalFriends   = clsLinkedinMain.PostAddMembers(ref HttpHelper, accountUser);

                // To manage the code for friends in which invitation already sent

                // SucessfullySendInvitationToFriend();

                //int counter = 1;

                foreach (KeyValuePair <string, string> itemChecked in dTotalFriends)
                {
                    try
                    {
                        //if (!IsAllAccounts)
                        //{
                        //    if (counter > 50)
                        //    {
                        //        break;
                        //    }
                        //}

                        //counter++;

                        string FName = string.Empty;
                        string Lname = string.Empty;

                        FName = itemChecked.Value.Split(' ')[0];
                        Lname = itemChecked.Value.Split(' ')[1];

                        FullName = FName + " " + Lname;
                        try
                        {
                            ContactName = ContactName + "  :  " + FullName;
                        }
                        catch { }
                        if (ToMsg == string.Empty)
                        {
                            ToMsg += FullName;
                        }
                        else
                        {
                            ToMsg += ";" + FullName;
                        }

                        Log("[ " + DateTime.Now + " ] => [ Adding Contact : " + FullName + " ]");


                        string ToCd = itemChecked.Key;

                        if (ToCd.Contains(":"))
                        {
                            try
                            {
                                ToCd = ToCd.Substring(ToCd.IndexOf(":"), ToCd.Length - ToCd.IndexOf(":")).Replace(":", string.Empty).Trim();
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine("Error >>> " + ex.StackTrace);
                            }
                        }

                        List <string> AddAllString = new List <string>();

                        if (FString == string.Empty)
                        {
                            string CompString = "{" + "\"" + "_" + ToCd.Trim() + "\"" + ":" + "{" + "\"" + "memberId" + "\"" + ":" + "\"" + ToCd.Trim() + "\"" + "," + "\"" + "firstName" + "\"" + ":" + "\"" + FName + "\"" + "," + "\"" + "lastName" + "\"" + ":" + "\"" + Lname + "\"" + "}";
                            FString = CompString;
                        }
                        else
                        {
                            string CompString = "\"" + "_" + ToCd.Trim() + "\"" + ":" + "{" + "\"" + "memberId" + "\"" + ":" + "\"" + ToCd.Trim() + "\"" + "," + "\"" + "firstName" + "\"" + ":" + "\"" + FName + "\"" + "," + "\"" + "lastName" + "\"" + ":" + "\"" + Lname + "\"" + "}";
                            FString = CompString;
                        }

                        if (Nstring == string.Empty)
                        {
                            Nstring = FString;
                            connId  = ToCd;
                        }
                        else
                        {
                            Nstring += "," + FString;
                            connId  += " " + ToCd;
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("ex.Message >>> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace + "  ex.Stack Trace >>> " + ex.StackTrace);
                    }

                    //}
                    Nstring += "}";


                    string postData = "csrfToken=" + csrfToken + "&emailRecipients=&subAddMbrs=Send+Invitations&gid=" + grpId + "&invtActn=im-invite&cntactSrc=cs-connections&remIntives=999&connectionIds=" + connId + "&connectionNames=" + Uri.EscapeUriString(Nstring) + "&contactIDs=&newGroup=false";

                    string response = HttpHelper.postFormData(new Uri("http://www.linkedin.com/manageGroup"), postData);

                    //if (response.Contains("You have successfully sent invitations to this group") || response.Contains("Upgrade Your Account"))
                    if (response.Contains("You have successfully sent invitations to this group"))
                    {
                        Log("[ " + DateTime.Now + " ] => [ You have successfully sent invitations to Group : " + grpURL + " With Username : "******"Invite user : "******" ]");
                        string CSVHeader  = "GroupUrl" + "," + "UserName" + "," + "Invite User";
                        string CSVContent = grpURL + "," + accountUser + "," + FullName;
                        CSVUtilities.ExportDataCSVFile(CSVHeader, CSVContent, Globals.path_SentInvitationGroup);
                        // GlobusFileHelper.AppendStringToTextfileNewLine(content, Globals.path_SentInvitationGroup);
                    }
                    else
                    {
                        Log("[ " + DateTime.Now + " ] => [ Couldn't Send Invitation With Username : "******" ]");
                        string CSVHeader  = "GroupUrl" + "," + "UserName";
                        string CSVContent = grpURL + "," + accountUser;
                        CSVUtilities.ExportDataCSVFile(CSVHeader, CSVContent, Globals.path_NotSentInvitationGroup);
                        //GlobusFileHelper.AppendStringToTextfileNewLine(content, Globals.path_NotSentInvitationGroup);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error >>> " + ex.StackTrace);
            }
        }
예제 #5
0
        public string PostAddGroupUsingUrl(ref GlobusHttpHelper HttpHelper, Dictionary <string, Dictionary <string, string> > LinkdInContacts, string Screen_name, string pass, int mindelay, int maxdelay)
        {
            string postdata    = string.Empty;
            string postUrl     = string.Empty;
            string ResLogin    = string.Empty;
            string csrfToken   = string.Empty;
            string sourceAlias = string.Empty;

            string ReturnString = string.Empty;
            string GroupName    = string.Empty;

            try
            {
                string MessageText   = string.Empty;
                string PostedMessage = string.Empty;

                string pageSource = HttpHelper.getHtmlfromUrl1(new Uri("http://www.linkedin.com/home?trk=hb_tab_home_top"));
                if (pageSource.Contains("csrfToken"))
                {
                    csrfToken = pageSource.Substring(pageSource.IndexOf("csrfToken"), 50);
                    string[] Arr = csrfToken.Split('&');
                    csrfToken = Arr[0];
                    csrfToken = csrfToken.Replace(":", "%3A").Replace("csrfToken", "").Replace("\"", string.Empty).Replace("value", string.Empty).Replace("cs", string.Empty).Replace("id", string.Empty).Replace("=", string.Empty);
                    csrfToken = csrfToken.Trim();
                }

                if (pageSource.Contains("sourceAlias"))
                {
                    sourceAlias = pageSource.Substring(pageSource.IndexOf("sourceAlias"), 100);
                    string[] Arr = sourceAlias.Split('"');
                    sourceAlias = Arr[2];
                }

                postUrl  = "https://www.linkedin.com/uas/login-submit";
                postdata = "session_key=" + Screen_name + "&session_password="******"&source_app=&trk=guest_home_login&session_redirect=&csrfToken=" + csrfToken + "&sourceAlias=" + sourceAlias;
                ResLogin = HttpHelper.postFormData(new Uri(postUrl), postdata);

                try
                {
                    foreach (KeyValuePair <string, Dictionary <string, string> > UserValue in LinkdInContacts)
                    {
                        foreach (KeyValuePair <string, string> GroupValue in UserValue.Value)
                        {
                            post_url = string.Empty;
                            post_url = (GroupValue.Key + ":" + GroupValue.Value);
                            try
                            {
                                string GoBack = "/%2Eanb_" + post_url.Split(':')[1];
                                LogGroupUrl("[ " + DateTime.Now + " ] => [ ID: " + Screen_name + " has Joining the Group: " + post_url.Split(':')[0] + " ]");
                                string pageGetreq = HttpHelper.getHtmlfromUrl1(new Uri("http://www.linkedin.com/groupRegistration?gid=" + post_url.Split(':')[1] + "&csrfToken=" + csrfToken + "&trk=group-join-button"));


                                if (pageGetreq.Contains("Your request to join the"))
                                {
                                    ReturnString = "Your request to join the: " + post_url.Split(':')[0] + " group has been received.";
                                    LogGroupUrl("[ " + DateTime.Now + " ] => [ " + ReturnString + " ]");
                                    GlobusFileHelper.AppendStringToTextfileNewLine(Screen_name + ":" + ReturnString, Globals.path_JoinSearchGroupSuccess);
                                }
                                else if (pageGetreq.Contains("Welcome to the"))
                                {
                                    ReturnString = "Welcome to the: " + post_url.Split(':')[0] + " group on LinkedIn.";
                                    LogGroupUrl("[ " + DateTime.Now + " ] => [ " + ReturnString + " ]");
                                    GlobusFileHelper.AppendStringToTextfileNewLine(Screen_name + ":" + ReturnString, Globals.path_JoinSearchGroupSuccess);
                                }
                                else if (pageGetreq.Contains("You're already a member of the"))
                                {
                                    ReturnString = "You're already a member of the: " + post_url.Split(':')[0] + "";
                                    LogGroupUrl("[ " + DateTime.Now + " ] => [ " + ReturnString + " ]");
                                    GlobusFileHelper.AppendStringToTextfileNewLine(Screen_name + ":" + ReturnString, Globals.path_JoinSearchGroupSuccess);
                                }
                                else if (pageGetreq.Contains("Your settings have been updated"))
                                {
                                    ReturnString = "Your request to join the: " + post_url.Split(':')[0] + " group has been received.";
                                    LogGroupUrl("[ " + DateTime.Now + " ] => [ " + ReturnString + " ]");
                                    GlobusFileHelper.AppendStringToTextfileNewLine(Screen_name + ":" + ReturnString, Globals.path_JoinSearchGroupSuccess);
                                }
                                else if (pageGetreq.Contains("We’re sorry, this group has reached its maximum number of members allowed. If you have any questions, please contact the group manager for more information"))
                                {
                                    LogGroupUrl("[ " + DateTime.Now + " ] => [ We’re sorry, this group has reached its maximum number of members allowed. ]");
                                    GlobusFileHelper.AppendStringToTextfileNewLine(Screen_name + ":" + "We’re sorry, this group has reached its maximum number of members allowed.", Globals.path_JoinSearchGroupFail);
                                }
                                else if (pageGetreq.Contains("reached or exceeded the maximum number of pending group applications."))
                                {
                                    LogGroupUrl("[ " + DateTime.Now + " ] => [ We’re sorry...You’ve reached or exceeded the maximum number of pending group applications. Please wait for your pending requests to be approved by a group manager or withdraw pending requests before joining new groups. ]");
                                    GlobusFileHelper.AppendStringToTextfileNewLine(Screen_name + ":" + "We’re sorry...You’ve reached or exceeded the maximum number of pending group applications. Please wait for your pending requests to be approved by a group manager or withdraw pending requests before joining new groups. ", Globals.path_JoinSearchGroupFail);
                                }
                                else if (pageGetreq.Contains("reached or exceeded the maximum number of confirmed and pending groups."))
                                {
                                    ReturnString = "You’ve reached or exceeded the maximum number of confirmed and pending groups.";
                                    LogGroupUrl("[ " + DateTime.Now + " ] => [ You’ve reached or exceeded the maximum number of confirmed and pending groups.]");
                                    GlobusFileHelper.AppendStringToTextfileNewLine(Screen_name + ":" + ReturnString, Globals.path_JoinSearchGroupFail);
                                }
                                else if (pageGetreq.Contains("Error"))
                                {
                                    LogGroupUrl("[ " + DateTime.Now + " ] => [ Error In Joining Group ]");
                                    GlobusFileHelper.AppendStringToTextfileNewLine(Screen_name + ":" + "Error In Joining Group", Globals.path_JoinSearchGroupFail);
                                }
                                else
                                {
                                    LogGroupUrl("[ " + DateTime.Now + " ] => [ Group Could Not Be Joined ]");
                                    GlobusFileHelper.AppendStringToTextfileNewLine(Screen_name + ":" + "Group Could Not Be Joined", Globals.path_JoinSearchGroupFail);
                                }
                            }
                            catch { }

                            int delay = RandomNumberGenerator.GenerateRandom(mindelay, maxdelay);
                            LogGroupUrl("[ " + DateTime.Now + " ] => [ Delay for : " + delay + " Seconds ]");
                            Thread.Sleep(delay * 1000);
                        }
                    }
                }
                catch (Exception ex)
                {
                    LogGroupUrl(DateTime.Now + " [ Error:" + ex.Message + "StackTrace --> >>>" + ex.StackTrace + " ]");
                }
            }
            catch (Exception ex)
            {
                GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error --> Add Search Groups --> PostSearchGroupAddFinal() >>>> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace, Globals.Path_LinkedinErrorLogs);
                GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error --> Add Search Groups --> PostSearchGroupAddFinal() >>>> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace, Globals.Path_LinkedinAddSearchGroupErrorLogs);
                ReturnString = "Error";
            }
            return(ReturnString);
        }
예제 #6
0
        public string PostFollowCompanyUsingUrl(ref GlobusHttpHelper HttpHelper, Dictionary <string, Dictionary <string, string> > LinkdInContacts, int mindelay, int maxdelay)
        {
            string postdata     = string.Empty;
            string postUrl      = string.Empty;
            string ResLogin     = string.Empty;
            string csrfToken    = string.Empty;
            string sourceAlias  = string.Empty;
            string ReturnString = string.Empty;

            try
            {
                string MessageText   = string.Empty;
                string PostedMessage = string.Empty;
                string pageSource    = HttpHelper.getHtmlfromUrl1(new Uri("http://www.linkedin.com/home?trk=hb_tab_home_top"));

                if (pageSource.Contains("csrfToken"))
                {
                    csrfToken = pageSource.Substring(pageSource.IndexOf("csrfToken"), 50);
                    string[] Arr = csrfToken.Split('&');
                    csrfToken = Arr[0];
                    csrfToken = csrfToken.Replace(":", "%3A").Replace("csrfToken", "").Replace("\"", string.Empty).Replace("value", string.Empty).Replace("cs", string.Empty).Replace("id", string.Empty).Replace("=", string.Empty);
                    csrfToken = csrfToken.Trim();
                }

                if (pageSource.Contains("sourceAlias"))
                {
                    sourceAlias = pageSource.Substring(pageSource.IndexOf("sourceAlias"), 100);
                    string[] Arr = sourceAlias.Split('"');
                    sourceAlias = Arr[2];
                }

                try
                {
                    int counter = 0;
                    foreach (KeyValuePair <string, Dictionary <string, string> > UserValue in LinkdInContacts)
                    {
                        counter = counter + 1;
                        foreach (KeyValuePair <string, string> GroupValue in UserValue.Value)
                        {
                            post_url = string.Empty;
                            post_url = (GroupValue.Key + ":" + GroupValue.Value);

                            string Screen_name = UserValue.Key.Split(':')[0];
                            string pass        = UserValue.Key.Split(':')[1];

                            postUrl  = "https://www.linkedin.com/uas/login-submit";
                            postdata = "session_key=" + Screen_name + "&session_password="******"&source_app=&trk=guest_home_login&session_redirect=&csrfToken=" + csrfToken + "&sourceAlias=" + sourceAlias;
                            ResLogin = HttpHelper.postFormData(new Uri(postUrl), postdata);

                            try
                            {
                                string GoBack = "%2Ebzo_*1_*1_*1_*1_*1_*1_*1_" + post_url.Split(':')[1];
                                Log("[ " + DateTime.Now + " ] => [ ID: " + Screen_name + " has Follow the Company: " + post_url.Split(':')[0] + " ]");
                                string pageGetreq = HttpHelper.getHtmlfromUrl1(new Uri("http://www.linkedin.com/company/follow/submit?id=" + post_url.Split(':')[1] + "&fl=start&version=2&ft=pageKey%3Dbiz-overview-internal%3Bmodule%3Dbutton&sp=biz-overview&csrfToken=" + csrfToken + "&goback=" + GoBack));

                                if (pageGetreq.Contains("Following"))
                                {
                                    ReturnString = "Your request to Follow the: " + post_url.Split(':')[0] + " company has been Successfully Followed.";
                                    Log("[ " + DateTime.Now + " ] => [ " + ReturnString + " ]");
                                    //GlobusFileHelper.AppendStringToTextfileNewLine(Screen_name + ":" + ReturnString, Globals.path_FollowCompany);
                                }
                                else if (pageGetreq.Contains("Error"))
                                {
                                    Log("[ " + DateTime.Now + " ] => [ Error In Follow Company ]");
                                    GlobusFileHelper.AppendStringToTextfileNewLine(Screen_name + ":" + "Error In Follow Company", Globals.path_Not_FollowCompany);
                                }
                                else
                                {
                                    Log("[ " + DateTime.Now + " ] => [ Company Could Not Be Followed ]");
                                    GlobusFileHelper.AppendStringToTextfileNewLine(Screen_name + ":" + "Company Could Not Be Followed", Globals.path_Not_FollowCompany);
                                }
                            }
                            catch { }

                            if (counter < LinkdInContacts.Count())
                            {
                                int delay = RandomNumberGenerator.GenerateRandom(mindelay, maxdelay);
                                Log("[ " + DateTime.Now + " ] => [ Delay for : " + delay + " Seconds ]");
                                Thread.Sleep(delay * 1000);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error --> Follow Company--1 --> PostFollowCompanyUsingUrl() >>>> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace, Globals.Path_LinkedinErrorLogs);
                    GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error --> Follow Company--1 --> PostFollowCompanyUsingUrl() >>>> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace, Globals.Path_LinkedinFollowCompanyErrorLogs);
                }
            }
            catch (Exception ex)
            {
                GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error --> Follow Company--2--> PostFollowCompanyUsingUrl() >>>> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace, Globals.Path_LinkedinErrorLogs);
                GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error --> Follow Company--2--> PostFollowCompanyUsingUrl() >>>> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace, Globals.Path_LinkedinFollowCompanyErrorLogs);
                ReturnString = "Error";
            }
            return(ReturnString);
        }
        private void Connect(ref GlobusHttpHelper httpHelper, string profileURL)
        {
            try
            {
                Log("[ " + DateTime.Now + " ] => [ Start Sending Connect With Username >>> " + _UserName + " ]");

                string key = string.Empty;
                string firstName_Guest = string.Empty;
                string lastName_Guest = string.Empty;
                string authToken = string.Empty;
                string goback = string.Empty;
                string fullName = string.Empty;

                string pageSource = httpHelper.getHtmlfromUrl1(new Uri(profileURL));

                //if (!pageSource.Contains("\"i18n__Connect\":\"Connect\",\"deferImg\":true"))
                //{
                //    Log("[ " + DateTime.Now + " ] => [ You can not send invitation to profile url >>> " + profileURL + " with username >>> " + _UserName + " ]");
                //    return;

                //}

                if (string.IsNullOrEmpty(pageSource))
                {
                    Thread.Sleep(1 * 1000);

                    pageSource = httpHelper.getHtmlfromUrl1(new Uri(profileURL));
                }

                if (string.IsNullOrEmpty(pageSource))
                {
                    Log("[ " + DateTime.Now + " ] => [ Page Source Is Null ! ]");

                    Log("[ " + DateTime.Now + " ] => [ Process Completed With Username >>> " + _UserName + " ]");

                    return;
                }

                if (pageSource.Contains("memberId:"))
                {
                    key = pageSource.Substring(pageSource.IndexOf("memberId:"), pageSource.IndexOf("</script>", pageSource.IndexOf("memberId:")) - pageSource.IndexOf("memberId:")).Replace("memberId:", string.Empty).Replace("\"", string.Empty).Replace("};", string.Empty).Trim();
                }

                if (pageSource.Contains("snapshotID=&authToken="))
                {
                    authToken = pageSource.Substring(pageSource.IndexOf("snapshotID=&authToken=") + 22, pageSource.IndexOf("&", (pageSource.IndexOf("snapshotID=&authToken=") + 22)) - (pageSource.IndexOf("snapshotID=&authToken=") + 22)).Replace("snapshotID=&authToken=", string.Empty).Replace("\"", string.Empty).Trim();
                }

                if (String.IsNullOrEmpty(authToken) && pageSource.Contains("authToken="))
                {
                    authToken = pageSource.Substring(pageSource.IndexOf("authToken="), pageSource.IndexOf(",", (pageSource.IndexOf("authToken="))) - (pageSource.IndexOf("authToken="))).Replace("authToken=", string.Empty).Replace("\"", string.Empty).Trim();

                    if (authToken.Contains("authType"))
                    {
                        try
                        {
                            authToken = authToken.Split('&')[0];
                        }
                        catch { }

                    }
                    if (authToken.Contains("&"))
                    {
                        try
                        {
                            authToken = authToken.Split('&')[0];
                        }
                        catch { }
                    }
                }

                if (pageSource.Contains("goback="))
                {
                    goback = pageSource.Substring(pageSource.IndexOf("goback="), pageSource.IndexOf("\"", pageSource.IndexOf("goback=")) - pageSource.IndexOf("goback=")).Replace("goback=", string.Empty).Replace("\"", string.Empty).Trim();
                }
                if (string.IsNullOrEmpty(goback))
                {
                    string[] gobck = Regex.Split(pageSource, "&goback=");
                    int startindex = gobck[2].IndexOf("");
                    string start = gobck[2].Substring(startindex);
                    int endindex = start.IndexOf(",");
                    string end = start.Substring(0, endindex).Replace("\"",string.Empty);
                    goback = end.Trim();
                }

                if (pageSource.Contains("class=\"full-name\""))
                {
                    fullName = pageSource.Substring(pageSource.IndexOf("class=\"full-name\""), pageSource.IndexOf("<", pageSource.IndexOf("class=\"full-name\"")) - pageSource.IndexOf("class=\"full-name\"")).Replace("class=\"full-name\"", string.Empty).Replace("\"", string.Empty).Replace("dir=auto>", string.Empty).Trim();
                }

                if (string.IsNullOrEmpty(fullName))
                {
                    try
                    {
                        int startindex = pageSource.IndexOf("<span class=\"full-name\">");
                        string start = pageSource.Substring(startindex).Replace("<span class=\"full-name\">", string.Empty);
                        int endindex = start.IndexOf("</span>");
                        string end = start.Substring(0, endindex).Replace("</span>", string.Empty);
                        fullName = end.Trim();
                    }
                    catch
                    { }
                }
                if (fullName.Contains(" "))
                {
                    firstName_Guest = fullName.Substring(0, fullName.LastIndexOf(" ")).Replace("&quot;", "\"").Trim();

                    lastName_Guest = fullName.Substring(fullName.LastIndexOf(" "), fullName.Length - fullName.LastIndexOf(" ")).Replace("&quot;", "\"").Trim();

                }

                string pageSource1 = httpHelper.getHtmlfromUrl1(new Uri("http://www.linkedin.com/people/invite?from=profile&key=" + key + "&firstName=" + firstName_Guest + "&lastName=" + lastName_Guest + "&authToken=" + authToken + "&authType=name&goback=" + goback + "&trk=prof-0-sb-connect-button"));

                if (string.IsNullOrEmpty(pageSource1))
                {
                    Thread.Sleep(1 * 1000);

                    pageSource1 = httpHelper.getHtmlfromUrl1(new Uri("http://www.linkedin.com/people/invite?from=profile&key=" + key + "&firstName=" + firstName_Guest + "&lastName=" + lastName_Guest + "&authToken=" + authToken + "&authType=name&goback=" + goback + "&trk=prof-0-sb-connect-button"));
                }

                if (string.IsNullOrEmpty(pageSource1))
                {
                    Log("[ " + DateTime.Now + " ] => [ Page Source Is Null ! ]");

                    Log("[ " + DateTime.Now + " ] => [ Process Completed With Username >>> " + _UserName + " ]");

                    return;
                }
                if (!pageSource1.Contains("emailAddress-invitee-invitation"))
                {
                    SendInvitation(ref httpHelper, pageSource1, key, authToken, goback, firstName_Guest, lastName_Guest);
                }

                if (pageSource1.Contains("emailAddress-invitee-invitation"))
                {
                    Log("[ " + DateTime.Now + " ] => [ Invitation already sent to " + firstName_Guest + lastName_Guest + " from >>> " + _UserName + " ]");
                    Log("[ " + DateTime.Now + " ] => [ -----------------------------------------------------------------------------------------------]");
                }
            }
            catch (Exception ex)
            {
                //Log("[ " + DateTime.Now + " ] => [ Error >>> ex.Message >>> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace + " ex.StackTrace >>> " + ex.StackTrace + " ]");
            }
        }
예제 #8
0
        private void Connect(ref GlobusHttpHelper httpHelper, string profileURL)
        {
            try
            {
                Log("[ " + DateTime.Now + " ] => [ Start Sending Connect With Username >>> " + _UserName + " ]");


                string key             = string.Empty;
                string firstName_Guest = string.Empty;
                string lastName_Guest  = string.Empty;
                string authToken       = string.Empty;
                string goback          = string.Empty;
                string fullName        = string.Empty;

                string pageSource = httpHelper.getHtmlfromUrl1(new Uri(profileURL));

                //if (!pageSource.Contains("\"i18n__Connect\":\"Connect\",\"deferImg\":true"))
                //{
                //    Log("[ " + DateTime.Now + " ] => [ You can not send invitation to profile url >>> " + profileURL + " with username >>> " + _UserName + " ]");
                //    return;

                //}

                if (string.IsNullOrEmpty(pageSource))
                {
                    Thread.Sleep(1 * 1000);

                    pageSource = httpHelper.getHtmlfromUrl1(new Uri(profileURL));
                }

                if (string.IsNullOrEmpty(pageSource))
                {
                    Log("[ " + DateTime.Now + " ] => [ Page Source Is Null ! ]");

                    Log("[ " + DateTime.Now + " ] => [ Process Completed With Username >>> " + _UserName + " ]");

                    return;
                }

                if (pageSource.Contains("memberId:"))
                {
                    key = pageSource.Substring(pageSource.IndexOf("memberId:"), pageSource.IndexOf("</script>", pageSource.IndexOf("memberId:")) - pageSource.IndexOf("memberId:")).Replace("memberId:", string.Empty).Replace("\"", string.Empty).Replace("};", string.Empty).Trim();
                }

                if (pageSource.Contains("snapshotID=&authToken="))
                {
                    authToken = pageSource.Substring(pageSource.IndexOf("snapshotID=&authToken=") + 22, pageSource.IndexOf("&", (pageSource.IndexOf("snapshotID=&authToken=") + 22)) - (pageSource.IndexOf("snapshotID=&authToken=") + 22)).Replace("snapshotID=&authToken=", string.Empty).Replace("\"", string.Empty).Trim();
                }

                if (String.IsNullOrEmpty(authToken) && pageSource.Contains("authToken="))
                {
                    authToken = pageSource.Substring(pageSource.IndexOf("authToken="), pageSource.IndexOf(",", (pageSource.IndexOf("authToken="))) - (pageSource.IndexOf("authToken="))).Replace("authToken=", string.Empty).Replace("\"", string.Empty).Trim();

                    if (authToken.Contains("authType"))
                    {
                        try
                        {
                            authToken = authToken.Split('&')[0];
                        }
                        catch { }
                    }
                    if (authToken.Contains("&"))
                    {
                        try
                        {
                            authToken = authToken.Split('&')[0];
                        }
                        catch { }
                    }
                }

                if (pageSource.Contains("goback="))
                {
                    goback = pageSource.Substring(pageSource.IndexOf("goback="), pageSource.IndexOf("\"", pageSource.IndexOf("goback=")) - pageSource.IndexOf("goback=")).Replace("goback=", string.Empty).Replace("\"", string.Empty).Trim();
                }
                if (string.IsNullOrEmpty(goback))
                {
                    string[] gobck      = Regex.Split(pageSource, "&goback=");
                    int      startindex = gobck[2].IndexOf("");
                    string   start      = gobck[2].Substring(startindex);
                    int      endindex   = start.IndexOf(",");
                    string   end        = start.Substring(0, endindex).Replace("\"", string.Empty);
                    goback = end.Trim();
                }


                if (pageSource.Contains("class=\"full-name\""))
                {
                    fullName = pageSource.Substring(pageSource.IndexOf("class=\"full-name\""), pageSource.IndexOf("<", pageSource.IndexOf("class=\"full-name\"")) - pageSource.IndexOf("class=\"full-name\"")).Replace("class=\"full-name\"", string.Empty).Replace("\"", string.Empty).Replace("dir=auto>", string.Empty).Trim();
                }

                if (string.IsNullOrEmpty(fullName))
                {
                    try
                    {
                        int    startindex = pageSource.IndexOf("<span class=\"full-name\">");
                        string start      = pageSource.Substring(startindex).Replace("<span class=\"full-name\">", string.Empty);
                        int    endindex   = start.IndexOf("</span>");
                        string end        = start.Substring(0, endindex).Replace("</span>", string.Empty);
                        fullName = end.Trim();
                    }
                    catch
                    { }
                }
                if (fullName.Contains(" "))
                {
                    firstName_Guest = fullName.Substring(0, fullName.LastIndexOf(" ")).Replace("&quot;", "\"").Trim();

                    lastName_Guest = fullName.Substring(fullName.LastIndexOf(" "), fullName.Length - fullName.LastIndexOf(" ")).Replace("&quot;", "\"").Trim();
                }

                string pageSource1 = httpHelper.getHtmlfromUrl1(new Uri("http://www.linkedin.com/people/invite?from=profile&key=" + key + "&firstName=" + firstName_Guest + "&lastName=" + lastName_Guest + "&authToken=" + authToken + "&authType=name&goback=" + goback + "&trk=prof-0-sb-connect-button"));

                if (string.IsNullOrEmpty(pageSource1))
                {
                    Thread.Sleep(1 * 1000);

                    pageSource1 = httpHelper.getHtmlfromUrl1(new Uri("http://www.linkedin.com/people/invite?from=profile&key=" + key + "&firstName=" + firstName_Guest + "&lastName=" + lastName_Guest + "&authToken=" + authToken + "&authType=name&goback=" + goback + "&trk=prof-0-sb-connect-button"));
                }

                if (string.IsNullOrEmpty(pageSource1))
                {
                    Log("[ " + DateTime.Now + " ] => [ Page Source Is Null ! ]");

                    Log("[ " + DateTime.Now + " ] => [ Process Completed With Username >>> " + _UserName + " ]");

                    return;
                }
                if (!pageSource1.Contains("emailAddress-invitee-invitation"))
                {
                    SendInvitation(ref httpHelper, pageSource1, key, authToken, goback, firstName_Guest, lastName_Guest);
                }

                if (pageSource1.Contains("emailAddress-invitee-invitation"))
                {
                    Log("[ " + DateTime.Now + " ] => [ Invitation already sent to " + firstName_Guest + lastName_Guest + " from >>> " + _UserName + " ]");
                    Log("[ " + DateTime.Now + " ] => [ -----------------------------------------------------------------------------------------------]");
                }
            }
            catch (Exception ex)
            {
                //Log("[ " + DateTime.Now + " ] => [ Error >>> ex.Message >>> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace + " ex.StackTrace >>> " + ex.StackTrace + " ]");
            }
        }
        private void GetEmployeeDataFromCompanyURL(ref GlobusHttpHelper HttpHelper, List <string> lstCompanyUrls)
        {
            try
            {
                if (!GlobalsScraper.isSearchByCompanyNamesToGetEmailId)
                {
                    foreach (string item in lstCompanyUrls)
                    {
                        try
                        {
                            GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Starting Parsing With UserName : "******" ]");
                            //Log("Url >>> " + item);
                            string compCode = Regex.Split(item, "company/")[1];
                            compCode = compCode.Split('?')[0];
                            string EmployeeUrl = "https://www.linkedin.com/vsearch/p?keywords=" + SearchCriteria.Keyword + "&openAdvancedForm=true&locationType=" + SearchCriteria.Country + "&countryCode=" + SearchCriteria.Country + "&f_CC=" + compCode + "&rsid=&orig=ADVS";

                            string LinkPagesourceCompEmp = HttpHelper.getHtmlfromUrl1(new Uri(EmployeeUrl));

                            try
                            {
                                int      pagenumber    = 0;
                                string   strPageNumber = string.Empty;
                                string[] Arr12         = Regex.Split(LinkPagesourceCompEmp, "<p class=\"summary\">");

                                if (Arr12.Count() == 1)
                                {
                                    Arr12 = Regex.Split(LinkPagesourceCompEmp, "formattedResultCount");
                                }

                                foreach (string item1 in Arr12)
                                {
                                    try
                                    {
                                        if (!item1.Contains("<!DOCTYPE"))
                                        {
                                            if (item1.Contains("<strong>"))
                                            {
                                                try
                                                {
                                                    //":"15,439","i18n_survey_feedback_thanks":
                                                    string pageNO = Regex.Split(item1, "i18n_survey")[0].Replace(":", string.Empty).Replace(",", string.Empty).Replace("\"", string.Empty);

                                                    string[] arrPageNO = Regex.Split(pageNO, "[^0-9]");

                                                    foreach (string item2 in arrPageNO)
                                                    {
                                                        try
                                                        {
                                                            if (!string.IsNullOrEmpty(item2))
                                                            {
                                                                strPageNumber = item2;
                                                            }
                                                        }
                                                        catch
                                                        {
                                                        }
                                                    }
                                                }
                                                catch
                                                {
                                                }
                                            }
                                        }
                                    }
                                    catch
                                    {
                                    }
                                }



                                try
                                {
                                    strPageNumber = strPageNumber.Replace(".", string.Empty);
                                    if (strPageNumber != string.Empty || strPageNumber == "0")
                                    {
                                        GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Total Results found: " + strPageNumber + " ]");
                                    }
                                    pagenumber = int.Parse(strPageNumber);
                                }
                                catch (Exception)
                                {
                                }

                                pagenumber = (pagenumber / 10) + 1;

                                LinkedInScraper obj_LinkedInScraper = new LinkedInScraper();

                                EmployeeUrl = EmployeeUrl + "##CompanyEmployeeScraper";

                                obj_LinkedInScraper.StartCompanyEmployeeScraperWithPagination(ref HttpHelper, EmployeeUrl, pagenumber);
                            }
                            catch
                            { }
                        }
                        catch
                        { }
                    }
                }

                #region for kishore's requirement
                if (GlobalsScraper.isSearchByCompanyNamesToGetEmailId)
                {
                    foreach (string item in lstCompanyUrls)
                    {
                        try
                        {
                            string compCode = "";
                            GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Starting Parsing With UserName : "******" ]");
                            // string compCode = Regex.Split(item, "company/")[1];
                            // compCode = compCode.Split('?')[0];

                            string   compName = item.Replace(" ", "+");
                            string   CompUrl  = "https://www.linkedin.com/vsearch/c?type=companies&keywords=" + compName;
                            string   source   = HttpHelper.getHtmlfromUrl1(new Uri(CompUrl));
                            string[] arr      = Regex.Split(source, "fmt_industry");
                            string   url      = "";
                            if (arr.Length > 1)
                            {
                                url      = Utils.getBetween(arr[1], "link_biz_overview_", "\",\"");
                                url      = Utils.getBetween(url + "###", "\":\"/", "###");
                                compCode = Utils.getBetween(url, "company/", "?");
                            }
                            url    = "https://www.linkedin.com/" + url;
                            source = HttpHelper.getHtmlfromUrl1(new Uri(url));

                            string EmployeeUrl           = "https://www.linkedin.com/vsearch/p?keywords=" + SearchCriteria.Keyword + "&openAdvancedForm=true&locationType=" + SearchCriteria.Country + "&countryCode=" + SearchCriteria.Country + "&f_CC=" + compCode + "&rsid=&orig=ADVS";
                            string LinkPagesourceCompEmp = HttpHelper.getHtmlfromUrl1(new Uri(EmployeeUrl));

                            try
                            {
                                int      pagenumber    = 0;
                                string   strPageNumber = string.Empty;
                                string[] Arr12         = Regex.Split(LinkPagesourceCompEmp, "<p class=\"summary\">");

                                if (Arr12.Count() == 1)
                                {
                                    Arr12 = Regex.Split(LinkPagesourceCompEmp, "formattedResultCount");
                                }

                                foreach (string item1 in Arr12)
                                {
                                    try
                                    {
                                        if (!item1.Contains("<!DOCTYPE"))
                                        {
                                            if (item1.Contains("<strong>"))
                                            {
                                                try
                                                {
                                                    //":"15,439","i18n_survey_feedback_thanks":
                                                    string pageNO = Regex.Split(item1, "i18n_survey")[0].Replace(":", string.Empty).Replace(",", string.Empty).Replace("\"", string.Empty);

                                                    string[] arrPageNO = Regex.Split(pageNO, "[^0-9]");

                                                    foreach (string item2 in arrPageNO)
                                                    {
                                                        try
                                                        {
                                                            if (!string.IsNullOrEmpty(item2))
                                                            {
                                                                strPageNumber = item2;
                                                            }
                                                        }
                                                        catch
                                                        {
                                                        }
                                                    }
                                                }
                                                catch
                                                {
                                                }
                                            }
                                        }
                                    }
                                    catch
                                    {
                                    }
                                }



                                try
                                {
                                    strPageNumber = strPageNumber.Replace(".", string.Empty);
                                    if (strPageNumber != string.Empty || strPageNumber == "0")
                                    {
                                        GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Total Results found: " + strPageNumber + " ]");
                                    }
                                    pagenumber = int.Parse(strPageNumber);
                                }
                                catch (Exception)
                                {
                                }

                                pagenumber = (pagenumber / 10) + 1;

                                LinkedInScraper obj_LinkedInScraper = new LinkedInScraper();

                                EmployeeUrl = EmployeeUrl + "##CompanyEmployeeScraper";

                                obj_LinkedInScraper.StartCompanyEmployeeScraperWithPagination(ref HttpHelper, EmployeeUrl, pagenumber);
                            }
                            catch
                            { }
                        }
                        catch
                        { }
                    }
                }

                #endregion
            }
            catch { }
        }
        public void Pagination(ref GlobusHttpHelper objHttpHelper, string mainUrl)
        {
            int PageCunt = 1;

            try
            {
                string totalResults      = string.Empty;
                bool   dispTotalResults  = true;
                string mainPageResponse  = string.Empty;
                int    paginationCounter = 0;
                do
                {
                    //mainUrl = mainUrl.Replace("replaceVariableCounter", paginationCounter.ToString());

                    //if (SalesNavigatorGlobals.isStop)
                    //{
                    //    return;
                    //}

                    ///string hoMEuRL = "https://www.linkedin.com/sales/search/?facet=N&facet.N=O&facet=G&facet.G=in:7350&facet=I&facet.I=96&facet=FA&facet.FA=12&defaultSelection=false&start=0&count=10&searchHistoryId=1540160093&keywords=ITIL&trk=lss-search-tab";
                    // string Url = mainUrl.Replace("replaceVariableCounter", paginationCounter.ToString());
                    mainPageResponse = objHttpHelper.getHtmlfromUrl(new Uri(mainUrl));
                    if (string.IsNullOrEmpty(mainPageResponse))
                    {
                        mainPageResponse = objHttpHelper.getHtmlfromUrl1(new Uri("https://www.linkedin.com/sales/?trk=nav_responsive_sub_nav_upgrade"));
                        mainPageResponse = objHttpHelper.getHtmlfromUrl(new Uri(mainUrl));
                    }

                    //if (mainPageResponse.Contains("We'll be back soon.")&&(mainPageResponse.Contains("We're getting things cleaned up.")))
                    //{
                    //    string unwatedStr = "https://www.linkedin.com/sales/search/?facet=N&facet.N=O&facet=G&facet.G=in:7350&facet=I&facet.I=96&facet=FA&facet.FA=12&defaultSelection=false&start=0&count=10&searchHistoryId=1540160093&keywords="+""+"&trk=lss-search-tab";// "&countryCode=" + Utils.getBetween(mainUrl, "&countryCode=", "&");
                    //    mainPageResponse = objHttpHelper.getHtmlfromUrl(new Uri(mainUrl.Replace(unwatedStr, paginationCounter.ToString())));
                    //}


                    if (string.IsNullOrEmpty(mainPageResponse))
                    {
                        if (string.IsNullOrEmpty(mainPageResponse))
                        {
                            //MessageBox.Show("Null response from internet. Please check your internet connection and restart the software.");
                            GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ No response from internet. Please check your internet connection. ] ");
                        }
                        Thread.Sleep(2000);
                        mainPageResponse = objHttpHelper.getHtmlfromUrl(new Uri(mainUrl.Replace("replaceVariableCounter", paginationCounter.ToString())));
                    }
                    try
                    {
                        if (dispTotalResults)
                        {
                            totalResults = Utils.getBetween(mainPageResponse, "\"total\":", ",\"").Trim();
                            GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Total results found : " + totalResults + " ]");
                            GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Scraping profile Url ]");
                            dispTotalResults = false;
                        }
                    }
                    catch
                    { }
                    int           checkCountUrls   = 0;
                    string[]      profileUrl_Split = Regex.Split(mainPageResponse, "\"profileUrl\"");
                    List <string> ProfileList      = new List <string>();
                    foreach (string profileUrlItem in profileUrl_Split)
                    {
                        if (!profileUrlItem.Contains("<!DOCTYPE"))
                        {
                            checkCountUrls++;
                            string profileUrl = Utils.getBetween(profileUrlItem, ":\"", "\",\"");
                            lstProfileUrls.Add(profileUrl);
                            GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Scraped Url : " + profileUrl + " ] ");
                            ProfileList.Add(profileUrl);
                        }
                    }
                    Thread.Sleep(1000);
                    ScrapeProfileDetails(ref objHttpHelper, ProfileList);
                    int startindex = paginationCounter;
                    paginationCounter = paginationCounter + 100;
                    mainUrl           = CreatePaginationUrl(mainUrl, startindex, paginationCounter);
                } while (mainPageResponse.Contains("\"profileUrl\":\""));
            }
            catch (Exception ex)
            {
            }
        }
        private void GetEmployeeDataFromCompanyURL(ref GlobusHttpHelper HttpHelper, List<string> lstCompanyUrls)
        {
            try
            {
                if (!GlobalsScraper.isSearchByCompanyNamesToGetEmailId)
                {
                    foreach (string item in lstCompanyUrls)
                    {
                        try
                        {
                            GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Starting Parsing With UserName : "******" ]");
                            //Log("Url >>> " + item);
                            string compCode = Regex.Split(item, "company/")[1];
                            compCode = compCode.Split('?')[0];
                            string EmployeeUrl = "https://www.linkedin.com/vsearch/p?keywords=" + SearchCriteria.Keyword + "&openAdvancedForm=true&locationType=" + SearchCriteria.Country + "&countryCode=" + SearchCriteria.Country + "&f_CC=" + compCode + "&rsid=&orig=ADVS";

                            string LinkPagesourceCompEmp = HttpHelper.getHtmlfromUrl1(new Uri(EmployeeUrl));

                            try
                            {
                                int pagenumber = 0;
                                string strPageNumber = string.Empty;
                                string[] Arr12 = Regex.Split(LinkPagesourceCompEmp, "<p class=\"summary\">");

                                if (Arr12.Count() == 1)
                                {
                                    Arr12 = Regex.Split(LinkPagesourceCompEmp, "formattedResultCount");
                                }

                                foreach (string item1 in Arr12)
                                {
                                    try
                                    {
                                        if (!item1.Contains("<!DOCTYPE"))
                                        {
                                            if (item1.Contains("<strong>"))
                                            {
                                                try
                                                {
                                                    //":"15,439","i18n_survey_feedback_thanks":
                                                    string pageNO = Regex.Split(item1, "i18n_survey")[0].Replace(":", string.Empty).Replace(",", string.Empty).Replace("\"", string.Empty);

                                                    string[] arrPageNO = Regex.Split(pageNO, "[^0-9]");

                                                    foreach (string item2 in arrPageNO)
                                                    {
                                                        try
                                                        {
                                                            if (!string.IsNullOrEmpty(item2))
                                                            {
                                                                strPageNumber = item2;
                                                            }
                                                        }
                                                        catch
                                                        {
                                                        }
                                                    }
                                                }
                                                catch
                                                {
                                                }
                                            }
                                        }
                                    }
                                    catch
                                    {
                                    }
                                }



                                try
                                {
                                    strPageNumber = strPageNumber.Replace(".", string.Empty);
                                    if (strPageNumber != string.Empty || strPageNumber == "0")
                                    {
                                        GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Total Results found: " + strPageNumber + " ]");
                                    }
                                    pagenumber = int.Parse(strPageNumber);
                                }
                                catch (Exception)
                                {

                                }

                                pagenumber = (pagenumber / 10) + 1;

                                LinkedInScraper obj_LinkedInScraper = new LinkedInScraper();

                                EmployeeUrl = EmployeeUrl + "##CompanyEmployeeScraper";

                                obj_LinkedInScraper.StartCompanyEmployeeScraperWithPagination(ref HttpHelper, EmployeeUrl, pagenumber);

                            }
                            catch
                            { }
                        }
                        catch
                        { }
                    }
                }

                #region for kishore's requirement
                if (GlobalsScraper.isSearchByCompanyNamesToGetEmailId)
                {
                    foreach (string item in lstCompanyUrls)
                    {
                        try
                        {
                            string compCode = "";
                            GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Starting Parsing With UserName : "******" ]");
                            // string compCode = Regex.Split(item, "company/")[1];
                            // compCode = compCode.Split('?')[0];

                            string compName = item.Replace(" ", "+");
                            string CompUrl = "https://www.linkedin.com/vsearch/c?type=companies&keywords=" + compName;
                            string source = HttpHelper.getHtmlfromUrl1(new Uri(CompUrl));
                            string[] arr = Regex.Split(source, "fmt_industry");
                            string url = "";
                            if (arr.Length > 1)
                            {
                                url = Utils.getBetween(arr[1], "link_biz_overview_", "\",\"");
                                url = Utils.getBetween(url + "###", "\":\"/", "###");
                                compCode = Utils.getBetween(url, "company/", "?");


                            }
                            url = "https://www.linkedin.com/" + url;
                            source = HttpHelper.getHtmlfromUrl1(new Uri(url));

                            string EmployeeUrl = "https://www.linkedin.com/vsearch/p?keywords=" + SearchCriteria.Keyword + "&openAdvancedForm=true&locationType=" + SearchCriteria.Country + "&countryCode=" + SearchCriteria.Country + "&f_CC=" + compCode + "&rsid=&orig=ADVS";
                            string LinkPagesourceCompEmp = HttpHelper.getHtmlfromUrl1(new Uri(EmployeeUrl));

                            try
                            {
                                int pagenumber = 0;
                                string strPageNumber = string.Empty;
                                string[] Arr12 = Regex.Split(LinkPagesourceCompEmp, "<p class=\"summary\">");

                                if (Arr12.Count() == 1)
                                {
                                    Arr12 = Regex.Split(LinkPagesourceCompEmp, "formattedResultCount");
                                }

                                foreach (string item1 in Arr12)
                                {
                                    try
                                    {
                                        if (!item1.Contains("<!DOCTYPE"))
                                        {
                                            if (item1.Contains("<strong>"))
                                            {
                                                try
                                                {
                                                    //":"15,439","i18n_survey_feedback_thanks":
                                                    string pageNO = Regex.Split(item1, "i18n_survey")[0].Replace(":", string.Empty).Replace(",", string.Empty).Replace("\"", string.Empty);

                                                    string[] arrPageNO = Regex.Split(pageNO, "[^0-9]");

                                                    foreach (string item2 in arrPageNO)
                                                    {
                                                        try
                                                        {
                                                            if (!string.IsNullOrEmpty(item2))
                                                            {
                                                                strPageNumber = item2;
                                                            }
                                                        }
                                                        catch
                                                        {
                                                        }
                                                    }
                                                }
                                                catch
                                                {
                                                }
                                            }
                                        }
                                    }
                                    catch
                                    {
                                    }
                                }



                                try
                                {
                                    strPageNumber = strPageNumber.Replace(".", string.Empty);
                                    if (strPageNumber != string.Empty || strPageNumber == "0")
                                    {
                                        GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Total Results found: " + strPageNumber + " ]");
                                    }
                                    pagenumber = int.Parse(strPageNumber);
                                }
                                catch (Exception)
                                {

                                }

                                pagenumber = (pagenumber / 10) + 1;

                                LinkedInScraper obj_LinkedInScraper = new LinkedInScraper();

                                EmployeeUrl = EmployeeUrl + "##CompanyEmployeeScraper";

                                obj_LinkedInScraper.StartCompanyEmployeeScraperWithPagination(ref HttpHelper, EmployeeUrl, pagenumber);

                            }
                            catch
                            { }
                        }
                        catch
                        { }
                    }
                }

                #endregion
            }
            catch { }
        }
예제 #12
0
        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)
            {
            }
        }
예제 #13
0
        public Dictionary <string, string> PostAddOpenGroups(ref GlobusHttpHelper HttpHelper, string SearchKeyword, string username)
        {
            try
            {
                int           count         = 5;
                string        IncodePost    = string.Empty;
                string        PostMessage   = string.Empty;
                string        PostMessage1  = string.Empty;
                string        MemFullName   = string.Empty;
                string        SearchId      = string.Empty;
                string        TotResult     = string.Empty;
                string        Grpurl        = string.Empty;
                string        GrpName       = string.Empty;
                string        IsOpenGrp     = string.Empty;
                string        GrpType       = string.Empty;
                string        GrpId         = string.Empty;
                string        GroupMember   = string.Empty;
                List <string> checkDupGrpId = new List <string>();

                OpenGroupDtl.Clear();

                {
                    count = BoxGroupCount;
                }

                PostMessage = "http://www.linkedin.com/vsearch/g?orig=TRNV&keywords=" + SearchKeyword;

                //PostMessage = "http://www.linkedin.com/vsearch/g?type=groups&keywords=" + SearchKeyword + "&orig=GLHD&rsid=&pageKey=member-home";

                IncodePost = Uri.EscapeUriString(PostMessage);
                string pageSource = HttpHelper.getHtmlfromUrl1(new Uri(IncodePost));

                string[] RgxGroupDataResult = System.Text.RegularExpressions.Regex.Split(pageSource, "results_count_with_keywords");

                foreach (var itemResult in RgxGroupDataResult)
                {
                    try
                    {
                        if (!itemResult.Contains("<!DOCTYPE html>"))
                        {
                            int    startindexRes = itemResult.IndexOf("strong");
                            string startRes      = itemResult.Substring(startindexRes);
                            int    endIndexRes   = startRes.IndexOf("/strong");
                            TotResult = startRes.Substring(0, endIndexRes).Replace("&quot;", string.Empty).Replace(",", string.Empty).Replace("&", string.Empty).Replace(":", string.Empty).Replace("strong", string.Empty).Replace("\\u003e", "").Replace("\\u003c", "");
                        }
                    }
                    catch { }
                }
                if (TotResult.Contains("."))
                {
                    TotResult = TotResult.Replace(".", "").Trim();
                }
                int pageNo = Convert.ToInt32(TotResult);
                pageNo = (pageNo / 10) + 2;
                bool BreakingLoop = false;

                for (int i = 1; i < pageNo; i++)
                {
                    string PageWiseUrl = "vsearch/g?orig=TRNV&keywords=" + SearchKeyword + "&openFacets=N,G,L&page_num=" + i + "&pt=groups";
                    PostMessage1 = "http://www.linkedin.com/" + PageWiseUrl + "";

                    string   pageSource1   = HttpHelper.getHtmlfromUrl1(new Uri(PostMessage1));
                    string[] RgxGroupData1 = System.Text.RegularExpressions.Regex.Split(pageSource1, "fmt_name");

                    foreach (var OpenGrps in RgxGroupData1)
                    {
                        try
                        {
                            if (!OpenGrps.Contains("<!DOCTYPE html>"))
                            {
                                try
                                {
                                    int    startindex = OpenGrps.IndexOf("\":\"");
                                    string start      = OpenGrps.Substring(startindex);
                                    int    endIndex   = start.IndexOf(",");
                                    GrpName = start.Substring(0, endIndex).Replace("\"", string.Empty).Replace("id", string.Empty).Replace(",", string.Empty).Replace(":", string.Empty).Replace("<B>", string.Empty).Replace("/B", string.Empty).Replace("\\u002d", "-").Replace("\\u003e", "").Replace("\\u003cB", "").Replace("\\u003c", "").Replace("&amp;", "");
                                }
                                catch { }

                                try
                                {
                                    int    startinGrTyp  = OpenGrps.IndexOf("isOpen");
                                    string startGrTyp    = OpenGrps.Substring(startinGrTyp);
                                    int    endIndexGrTyp = startGrTyp.IndexOf(",");
                                    IsOpenGrp = startGrTyp.Substring(0, endIndexGrTyp).Replace("isOpen", string.Empty).Replace("\"", string.Empty).Replace(":", string.Empty).Replace(",", string.Empty).Trim();

                                    if (IsOpenGrp == "true")
                                    {
                                        GrpType = "Open Group";
                                    }
                                    else
                                    {
                                        GrpType = "Member Only Group";
                                    }
                                }
                                catch { }

                                if (GrpName == "group" || GrpName == "_postGroupLink" || GrpName == "_viewGroupLink" || GrpName == "_similarGroupLink" || GrpName == "_searchWithinLink" || GrpName == "_joinGroupLink" || GrpName == "N" || GrpName == "Remove All")
                                {
                                    continue;
                                }

                                try
                                {
                                    int    startindex1 = OpenGrps.IndexOf("&gid=");
                                    string start1      = OpenGrps.Substring(startindex1);
                                    int    endIndex1   = start1.IndexOf("trk=");
                                    GrpId = start1.Substring(0, endIndex1).Replace("&gid=", string.Empty).Replace("&", string.Empty).Trim();
                                }
                                catch { }

                                try
                                {
                                    int    startindex2 = OpenGrps.IndexOf("membersCount");
                                    string start2      = OpenGrps.Substring(startindex2);
                                    int    endIndex2   = start2.IndexOf(",");
                                    GroupMember = start2.Substring(0, endIndex2).Replace("membersCount\":", string.Empty).Trim();
                                }
                                catch { }

                                try
                                {
                                    int    startindex  = OpenGrps.IndexOf("gid=");
                                    string start       = OpenGrps.Substring(startindex);
                                    int    endIndex    = start.IndexOf(",");
                                    string Grpfinalurl = start.Substring(0, endIndex).Replace("\"", string.Empty).Replace("gid=", string.Empty).Replace(",", string.Empty).Replace(":", string.Empty).Replace("<B>", string.Empty).Replace("</B>", string.Empty).Replace("\\u002d", "-");
                                    Grpurl = "http://www.linkedin.com/groups?gid=" + Grpfinalurl;
                                }
                                catch { }


                                if (checkDupGrpId.Count != 0)
                                {
                                    if (checkDupGrpId.Contains(GrpId))
                                    {
                                    }
                                    else
                                    {
                                        checkDupGrpId.Add(GrpId);
                                        if (OpenGroupDtl.Count < count)
                                        {
                                            #region Data Saved In CSV File

                                            if (!string.IsNullOrEmpty(Grpurl) || !string.IsNullOrEmpty(GrpName))
                                            {
                                                try
                                                {
                                                    string CSVHeader   = "Grpurl" + "," + "GrpName" + "," + "ID" + "," + "GroupMember";
                                                    string CSV_Content = Grpurl + "," + GrpName + "," + username + "," + GroupMember;
                                                    CSVUtilities.ExportDataCSVFile(CSVHeader, CSV_Content, Globals.path_LinkedinJoinSearchGroup);
                                                    Log("[ " + DateTime.Now + " ] => [ Data Saved In CSV File ! ]");
                                                }
                                                catch { }
                                            }
                                            #endregion

                                            OpenGroupDtl.Add(GrpName + " (" + GrpType + ")", GrpId);
                                        }
                                        else
                                        {
                                            BreakingLoop = true;
                                            break;
                                        }
                                        Log("[ " + DateTime.Now + " ] => [ Founded Group Name : " + GrpName + " ]");
                                    }

                                    int delay = RandomNumberGenerator.GenerateRandom(JoinSearchGroup.minDelay, JoinSearchGroup.maxDelay);
                                    Log("[ " + DateTime.Now + " ] => [ Delay for : " + delay + " Seconds ]");
                                    Thread.Sleep(delay * 1000);
                                }
                                else
                                {
                                    checkDupGrpId.Add(GrpId);
                                    if (OpenGroupDtl.Count < count)
                                    {
                                        #region Data Saved In CSV File

                                        if (!string.IsNullOrEmpty(Grpurl) || !string.IsNullOrEmpty(GrpName))
                                        {
                                            try
                                            {
                                                string CSVHeader   = "Grpurl" + "," + "GrpName" + "," + "ID" + "," + "GrpMembr";
                                                string CSV_Content = Grpurl + "," + GrpName + "," + username + "," + GroupMember;
                                                CSVUtilities.ExportDataCSVFile(CSVHeader, CSV_Content, Globals.path_LinkedinJoinSearchGroup);
                                                Log("[ " + DateTime.Now + " ] => [ Data Saved In CSV File ! ]");
                                            }
                                            catch { }
                                        }
                                        #endregion

                                        OpenGroupDtl.Add(GrpName + " (" + GrpType + ")", GrpId);
                                    }
                                    else
                                    {
                                        BreakingLoop = true;
                                        break;
                                    }

                                    int delay = RandomNumberGenerator.GenerateRandom(JoinSearchGroup.minDelay, JoinSearchGroup.maxDelay);
                                    Log("[ " + DateTime.Now + " ] => [ Delay for : " + delay + " Seconds ]");
                                    Thread.Sleep(delay * 1000);
                                }
                            }
                        }
                        catch { }
                    }
                    if (BreakingLoop)
                    {
                        break;
                    }
                }

                return(OpenGroupDtl);
            }
            catch (Exception ex)
            {
                GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error --> Add Search Groups --> PostAddOpenGroups() >>>> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace, Globals.Path_LinkedinErrorLogs);
                GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error --> Add Search Groups --> PostAddOpenGroups() >>>> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace, Globals.Path_LinkedinAddSearchGroupErrorLogs);
                return(OpenGroupDtl);
            }
        }
예제 #14
0
        public void PostFinalMsgGroupMember_1By1(ref GlobusHttpHelper HttpHelper, Dictionary <string, string> SlectedContacts, List <string> GrpMemSubjectlist, List <string> GrpMemMessagelist, string msg, string body, string UserName, string FromemailId, string FromEmailNam, string SelectedGrpName, string grpId, bool mesg_with_tag, bool msg_spintaxt, int mindelay, int maxdelay, bool preventMsgSameGroup, bool preventMsgWithoutGroup, bool preventMsgGlobal)
        {
            try
            {
                MsgGroupMemDbManager objMsgGroupMemDbMgr = new MsgGroupMemDbManager();

                string postdata       = string.Empty;
                string postUrl        = string.Empty;
                string ResLogin       = string.Empty;
                string csrfToken      = string.Empty;
                string sourceAlias    = string.Empty;
                string ReturnString   = string.Empty;
                string PostMsgSubject = string.Empty;
                string PostMsgBody    = string.Empty;
                string FString        = string.Empty;

                try
                {
                    string MessageText    = string.Empty;
                    string PostedMessage  = string.Empty;
                    string senderEmail    = string.Empty;
                    string getComposeData = HttpHelper.getHtmlfromUrl(new Uri("https://www.linkedin.com/inbox/compose"));
                    try
                    {
                        int startindex = getComposeData.IndexOf("\"senderEmail\" value=\"");
                        if (startindex < 0)
                        {
                            startindex = getComposeData.IndexOf("\"senderEmail\",\"value\":\"");
                        }
                        string start    = getComposeData.Substring(startindex).Replace("\"senderEmail\" value=\"", string.Empty).Replace("\"senderEmail\",\"value\":\"", string.Empty);
                        int    endindex = start.IndexOf("\"/>");
                        if (endindex < 0)
                        {
                            endindex = start.IndexOf("\",\"");
                        }
                        string end = start.Substring(0, endindex).Replace("\"/>", string.Empty).Replace("\",\"", string.Empty);
                        senderEmail = end.Trim();
                    }
                    catch
                    { }
                    string pageSource = HttpHelper.getHtmlfromUrl1(new Uri("http://www.linkedin.com/home?trk=hb_tab_home_top"));
                    if (pageSource.Contains("csrfToken"))
                    {
                        try
                        {
                            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).Replace("\n", string.Empty).Replace(">", string.Empty).Replace("<script typ", string.Empty);
                            csrfToken = csrfToken.Trim();
                        }
                        catch (Exception ex)
                        {
                        }
                    }

                    if (pageSource.Contains("sourceAlias"))
                    {
                        try
                        {
                            sourceAlias = pageSource.Substring(pageSource.IndexOf("sourceAlias"), 100);
                            string[] Arr = sourceAlias.Split('"');
                            sourceAlias = Arr[2];
                        }
                        catch (Exception ex)
                        {
                        }
                    }

                    if (pageSource.Contains("goback="))
                    {
                        try
                        {
                        }
                        catch (Exception ex)
                        {
                        }
                    }

                    foreach (KeyValuePair <string, string> itemChecked in SlectedContacts)
                    {
                        try
                        {
                            DataSet ds          = new DataSet();
                            DataSet ds_bList    = new DataSet();
                            string  ContactName = string.Empty;
                            string  Nstring     = string.Empty;
                            string  connId      = string.Empty;
                            string  FName       = string.Empty;
                            string  Lname       = string.Empty;
                            string  tempBody    = string.Empty;
                            string  tempsubject = string.Empty;
                            string  n_ame1      = string.Empty;

                            //grpId = itemChecked.Key.ToString();

                            try
                            {
                                // FName = itemChecked.Value.Split(' ')[0];
                                // Lname = itemChecked.Value.Split(' ')[1];
                                try
                                {
                                    n_ame1 = itemChecked.Value.Split(']')[1].Trim();;
                                }
                                catch
                                { }
                                if (string.IsNullOrEmpty(n_ame1))
                                {
                                    try
                                    {
                                        n_ame1 = itemChecked.Value;
                                    }
                                    catch
                                    { }
                                }
                                string[] n_ame = Regex.Split(n_ame1, " ");
                                FName = " " + n_ame[0];
                                Lname = n_ame[1];

                                if (!string.IsNullOrEmpty(n_ame[2]))
                                {
                                    Lname = Lname + n_ame[2];
                                }
                                if (!string.IsNullOrEmpty(n_ame[3]))
                                {
                                    Lname = Lname + n_ame[3];
                                }
                                if (!string.IsNullOrEmpty(n_ame[4]))
                                {
                                    Lname = Lname + n_ame[4];
                                }
                                if (!string.IsNullOrEmpty(n_ame[5]))
                                {
                                    Lname = Lname + n_ame[5];
                                }
                            }
                            catch (Exception ex)
                            {
                            }

                            try
                            {
                                ContactName = FName + " " + Lname;
                                ContactName = ContactName.Replace("%20", " ");
                            }
                            catch { }

                            Log("[ " + DateTime.Now + " ] => [ Adding Contact : " + ContactName + " ]");

                            string        ToCd         = itemChecked.Key;
                            List <string> AddAllString = new List <string>();

                            if (FString == string.Empty)
                            {
                                string CompString = "{" + "\"" + "_" + ToCd.Trim() + "\"" + ":" + "{" + "\"" + "memberId" + "\"" + ":" + "\"" + ToCd.Trim() + "\"" + "," + "\"" + "firstName" + "\"" + ":" + "\"" + FName + "\"" + "," + "\"" + "lastName" + "\"" + ":" + "\"" + Lname + "\"" + "}";
                                FString = CompString;
                            }
                            else
                            {
                                string CompString = "\"" + "_" + ToCd.Trim() + "\"" + ":" + "{" + "\"" + "memberId" + "\"" + ":" + "\"" + ToCd.Trim() + "\"" + "," + "\"" + "firstName" + "\"" + ":" + "\"" + FName + "\"" + "," + "\"" + "lastName" + "\"" + ":" + "\"" + Lname + "\"" + "}";
                                FString = CompString;
                            }

                            if (Nstring == string.Empty)
                            {
                                Nstring = FString;
                                connId  = ToCd;
                            }
                            else
                            {
                                Nstring += "," + FString;
                                connId  += " " + ToCd;
                            }

                            Nstring += "}";

                            try
                            {
                                string PostMessage       = string.Empty;
                                string ResponseStatusMsg = string.Empty;

                                Log("[ " + DateTime.Now + " ] => [ Message Sending Process Running.. ]");


                                if (msg_spintaxt == true)
                                {
                                    try
                                    {
                                        msg  = GrpMemSubjectlist[RandomNumberGenerator.GenerateRandom(0, GrpMemSubjectlist.Count - 1)];
                                        body = GrpMemMessagelist[RandomNumberGenerator.GenerateRandom(0, GrpMemMessagelist.Count - 1)];
                                    }
                                    catch
                                    {
                                    }
                                }
                                try
                                {
                                    tempsubject = msg;
                                    tempBody    = body;
                                }
                                catch
                                { }
                                if (mesg_with_tag == true)
                                {
                                    if (string.IsNullOrEmpty(FName))
                                    {
                                        tempBody = body.Replace("<Insert Name>", ContactName);
                                    }
                                    else
                                    {
                                        tempBody = GlobusSpinHelper.spinLargeText(new Random(), body);

                                        if (lstSubjectReuse.Count == GrpMemSubjectlist.Count)
                                        {
                                            lstSubjectReuse.Clear();
                                        }
                                        foreach (var itemSubject in GrpMemSubjectlist)
                                        {
                                            if (string.IsNullOrEmpty(TemporarySubject))
                                            {
                                                TemporarySubject = itemSubject;
                                                tempsubject      = itemSubject;
                                                lstSubjectReuse.Add(itemSubject);
                                                break;
                                            }
                                            else if (!lstSubjectReuse.Contains(itemSubject))
                                            {
                                                TemporarySubject = itemSubject;
                                                tempsubject      = itemSubject;
                                                lstSubjectReuse.Add(itemSubject);
                                                break;
                                            }
                                            else
                                            {
                                                continue;
                                            }
                                        }

                                        tempBody    = tempBody.Replace("<Insert Name>", FName);
                                        tempsubject = tempsubject.Replace("<Insert Name>", FName);
                                    }
                                }
                                else
                                {
                                    if (string.IsNullOrEmpty(FName))
                                    {
                                        tempBody = body.Replace("<Insert Name>", ContactName);
                                    }
                                    else
                                    {
                                        tempBody = body.Replace("<Insert Name>", FName);
                                    }
                                }

                                if (SelectedGrpName.Contains(":"))
                                {
                                    try
                                    {
                                        string[] arrSelectedGrpName = Regex.Split(SelectedGrpName, ":");
                                        if (arrSelectedGrpName.Length > 1)
                                        {
                                            SelectedGrpName = arrSelectedGrpName[1];
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                    }
                                }



                                if (mesg_with_tag == true)
                                {
                                    tempBody = tempBody.Replace("<Insert Group>", SelectedGrpName);
                                    tempBody = tempBody.Replace("<Insert From Email>", FromEmailNam);
                                    tempBody = tempBody.Replace("<Insert Name>", string.Empty).Replace("<Insert Group>", string.Empty).Replace("<Insert From Email>", string.Empty);
                                }
                                else
                                {
                                    tempBody = tempBody.Replace("<Insert Group>", SelectedGrpName);
                                    tempBody = tempBody.Replace("<Insert From Email>", FromEmailNam);
                                    tempBody = tempBody.Replace("<Insert Name>", string.Empty).Replace("<Insert Group>", string.Empty).Replace("<Insert From Email>", string.Empty);
                                }

                                //Check BlackListed Accounts
                                try
                                {
                                    string Querystring = "Select ProfileID From tb_BlackListAccount Where ProfileID ='" + itemChecked.Key + "'";
                                    ds_bList = DataBaseHandler.SelectQuery(Querystring, "tb_BlackListAccount");
                                }
                                catch { }


                                if (preventMsgSameGroup)
                                {
                                    try
                                    {
                                        string Querystring = "Select MsgFrom,MsgToId,MsgTo,MsgGroupId,MsgGroupName,MsgSubject,MsgBody From tb_ManageMsgGroupMem Where MsgFrom ='" + UserName + "' and MsgGroupId = " + grpId + " and MsgToId = " + connId + "";
                                        ds = DataBaseHandler.SelectQuery(Querystring, "tb_ManageMsgGroupMem");
                                    }
                                    catch { }
                                }

                                if (preventMsgWithoutGroup)
                                {
                                    try
                                    {
                                        string Querystring = "Select MsgFrom,MsgToId,MsgTo,MsgGroupId,MsgGroupName,MsgSubject,MsgBody From tb_ManageMsgGroupMem Where MsgFrom ='" + UserName + "' and MsgToId = " + connId + "";
                                        ds = DataBaseHandler.SelectQuery(Querystring, "tb_ManageMsgGroupMem");
                                    }
                                    catch { }
                                }
                                if (preventMsgGlobal)
                                {
                                    try
                                    {
                                        string Querystring = "Select MsgFrom,MsgToId,MsgTo,MsgGroupId,MsgGroupName,MsgSubject,MsgBody From tb_ManageMsgGroupMem Where MsgToId = " + connId + "";
                                        ds = DataBaseHandler.SelectQuery(Querystring, "tb_ManageMsgGroupMem");
                                    }
                                    catch { }
                                }

                                try
                                {
                                    if (ds.Tables.Count > 0)
                                    {
                                        if (ds.Tables[0].Rows.Count > 0)
                                        {
                                            PostMessage       = "";
                                            ResponseStatusMsg = "Already Sent";
                                        }
                                        else
                                        {
                                            if (ds_bList.Tables.Count > 0 && ds_bList.Tables[0].Rows.Count > 0)
                                            {
                                                Log("[ " + DateTime.Now + " ] => [ User: "******" is Added BlackListed List For Send Messages Pls Check ]");
                                                ResponseStatusMsg = "BlackListed";
                                            }
                                            else
                                            {
                                                PostMessage       = "csrfToken=" + csrfToken + "&subject=" + Uri.EscapeDataString(msg.ToString()) + "&body=" + Uri.EscapeDataString(tempBody.ToString()) + "&submit=Send+Message&fromName=" + Uri.EscapeDataString(FromEmailNam) + "&showRecipeints=showRecipeints&fromEmail=" + FromemailId + "&connectionIds=" + connId + "&connectionNames=&allowEditRcpts=true&addMoreRcpts=false&openSocialAppBodySuffix=&st=&viewerDestinationUrl=&contentType=MEBC&groupID=" + grpId + "";
                                                ResponseStatusMsg = HttpHelper.postFormData(new Uri("http://www.linkedin.com/groupMsg"), PostMessage);
                                            }
                                        }
                                    }
                                    else
                                    {
                                        if (ds_bList.Tables.Count > 0)
                                        {
                                            if (ds_bList.Tables[0].Rows.Count > 0)
                                            {
                                                Log("[ " + DateTime.Now + " ] => [ User: "******" is Added BlackListed List For Send Messages Pls Check ]");
                                                ResponseStatusMsg = "BlackListed";
                                            }
                                            else
                                            {
                                                PostMessage       = "csrfToken=" + csrfToken + "&subject=" + Uri.EscapeDataString(tempsubject.ToString()) + "&body=" + Uri.EscapeDataString(tempBody.ToString()) + "&submit=Send+Message&fromName=" + Uri.EscapeDataString(FromEmailNam) + "&showRecipeints=showRecipeints&fromEmail=" + FromemailId + "&connectionIds=" + connId + "&connectionNames=&allowEditRcpts=true&addMoreRcpts=false&openSocialAppBodySuffix=&st=&viewerDestinationUrl=&contentType=MEBC&groupID=" + grpId + "";
                                                ResponseStatusMsg = HttpHelper.postFormData(new Uri("http://www.linkedin.com/groupMsg"), PostMessage);
                                            }
                                        }
                                    }
                                }
                                catch (Exception)
                                {
                                    //PostMessage = "csrfToken=" + csrfToken + "&subject=" + Uri.EscapeDataString(msg.ToString()) + "&body=" + Uri.EscapeDataString(tempBody.ToString()) + "&submit=Send+Message&showRecipeints=showRecipeintsfromName=" + Uri.EscapeDataString(FromEmailNam) + "&fromEmail=" + FromemailId + "&connectionIds=" + connId + "&connectionNames=&allowEditRcpts=true&addMoreRcpts=false&openSocialAppBodySuffix=&st=&viewerDestinationUrl=&contentType=MEBC&groupID=" + grpId + "";
                                    //ResponseStatusMsg = HttpHelper.postFormData(new Uri("http://www.linkedin.com/groupMsg"), PostMessage);
                                }

                                if ((!ResponseStatusMsg.Contains("Your message was successfully sent.") && !ResponseStatusMsg.Contains("Already Sent")) && (!ResponseStatusMsg.Contains("Se ha enviado tu mensaje satisfactoriamente") && !ResponseStatusMsg.Contains("Ya ha sido enviada") && !ResponseStatusMsg.Contains("Uw bericht is verzonden")))
                                {
                                    if (ResponseStatusMsg.Contains("Already Sent") || (ResponseStatusMsg.Contains("Ya ha sido enviada") || (ResponseStatusMsg.Contains("BlackListed"))))
                                    {
                                        continue;
                                    }

                                    try
                                    {
                                        pageSource = HttpHelper.getHtmlfromUrl1(new Uri("https://www.linkedin.com/groups?viewMembers=&gid=" + grpId));

                                        if (pageSource.Contains("contentType="))
                                        {
                                            try
                                            {
                                                string contentType = pageSource.Substring(pageSource.IndexOf("contentType="), pageSource.IndexOf("&", pageSource.IndexOf("contentType=")) - pageSource.IndexOf("contentType=")).Replace("contentType=", string.Empty).Replace("contentType=", string.Empty).Trim();

                                                string pageSource2 = HttpHelper.getHtmlfromUrl1(new Uri("https://www.linkedin.com/groupMsg?displayCreate=&contentType=" + contentType + "&connId=" + connId + "&groupID=" + grpId + ""));

                                                PostMessage = "csrfToken=" + csrfToken + "&subject=" + Uri.EscapeDataString(msg.ToString()) + "&body=" + Uri.EscapeDataString(tempBody.ToString()) + "&submit=Send+Message&showRecipeints=showRecipeints&fromName=" + FromEmailNam + "&fromEmail=" + FromemailId + "&connectionIds=" + connId + "&connectionNames=" + Uri.EscapeUriString(Nstring) + "&allowEditRcpts=true&addMoreRcpts=false&openSocialAppBodySuffix=&st=&viewerDestinationUrl=&contentType=" + contentType + "&groupID=" + grpId + "";
                                            }
                                            catch (Exception ex)
                                            {
                                            }
                                        }


                                        ResponseStatusMsg = HttpHelper.postFormData(new Uri("https://www.linkedin.com/groupMsg"), PostMessage);
                                    }
                                    catch (Exception ex)
                                    {
                                    }
                                }

                                if ((ResponseStatusMsg.Contains("Your message was successfully sent.")) || (ResponseStatusMsg.Contains("Se ha enviado tu mensaje satisfactoriamente") || (ResponseStatusMsg.Contains("Uw bericht is verzonden"))))
                                {
                                    Log("[ " + DateTime.Now + " ] => [ Subject Posted : " + tempsubject + " ]");
                                    Log("[ " + DateTime.Now + " ] => [ Body Text Posted : " + tempBody.ToString() + " ]");
                                    Log("[ " + DateTime.Now + " ] => [ Message Posted To Account: " + ContactName + " ]");
                                    ReturnString = "Your message was successfully sent.";

                                    #region CSV
                                    string bdy = string.Empty;
                                    try
                                    {
                                        bdy = body.ToString().Replace("\r", string.Empty).Replace("\n", " ").Replace(",", " ");
                                    }
                                    catch { }
                                    if (string.IsNullOrEmpty(bdy))
                                    {
                                        bdy = tempBody.ToString().Replace(",", ":");
                                    }
                                    string CSVHeader   = "UserName" + "," + "Subject" + "," + "Body Text" + "," + "ContactName";
                                    string CSV_Content = UserName + "," + tempsubject + "," + bdy.ToString() + "," + ContactName;
                                    CSVUtilities.ExportDataCSVFile(CSVHeader, CSV_Content, Globals.path_MessageSentGroupMember);

                                    try
                                    {
                                        objMsgGroupMemDbMgr.InsertMsgGroupMemData(UserName, Convert.ToInt32(connId), ContactName, Convert.ToInt32(grpId), SelectedGrpName, msg, tempBody);
                                    }
                                    catch { }

                                    #endregion
                                }
                                else if (ResponseStatusMsg.Contains("There was an unexpected problem that prevented us from completing your request"))
                                {
                                    Log("[ " + DateTime.Now + " ] => [ There was an unexpected problem that prevented us from completing your request ! ]");
                                    GlobusFileHelper.AppendStringToTextfileNewLine("Error In Message Posting", Globals.path_MessageGroupMember);
                                }
                                else if (ResponseStatusMsg.Contains("You are no longer authorized to message this"))
                                {
                                    Log("[ " + DateTime.Now + " ] => [ You are no longer authorized to message this ! ]");
                                    GlobusFileHelper.AppendStringToTextfileNewLine("Error In Message Posting", Globals.path_MessageGroupMember);
                                }
                                else if ((ResponseStatusMsg.Contains("Already Sent")) || (ResponseStatusMsg.Contains("Ya ha sido enviada")))
                                {
                                    string bdy = string.Empty;
                                    try
                                    {
                                        bdy = body.ToString().Replace("\r", string.Empty).Replace("\n", " ").Replace(",", " ");
                                    }
                                    catch { }
                                    if (string.IsNullOrEmpty(bdy))
                                    {
                                        bdy = tempBody.ToString().Replace(",", ":");
                                    }
                                    string CSVHeader   = "UserName" + "," + "Subject" + "," + "Body Text" + "," + "ContactName";
                                    string CSV_Content = UserName + "," + msg + "," + bdy.ToString() + "," + ContactName;
                                    CSVUtilities.ExportDataCSVFile(CSVHeader, CSV_Content, Globals.path_MessageAlreadySentGroupMember);

                                    Log("[ " + DateTime.Now + " ] => [ Message Not Posted To Account: " + ContactName + " because it has sent the same message]");
                                }
                                else
                                {
                                    Log("[ " + DateTime.Now + " ] => [ Error In Message Posting ]");
                                    GlobusFileHelper.AppendStringToTextfileNewLine("Error In Message Posting", Globals.path_MessageGroupMember);
                                }

                                int delay = RandomNumberGenerator.GenerateRandom(mindelay, maxdelay);
                                Log("[ " + DateTime.Now + " ] => [ Delay for : " + delay + " Seconds ]");
                                Thread.Sleep(delay * 1000);
                            }
                            catch (Exception ex)
                            {
                                //Log("[ " + DateTime.Now + " ] => [ Error:" + ex.Message + "StackTrace --> >>>" + ex.StackTrace + " ]");
                                GlobusFileHelper.AppendStringToTextfileNewLine(" Error:" + ex.Message + "StackTrace --> >>>" + ex.StackTrace, Globals.path_MessageGroupMember);
                            }
                        }
                        catch (Exception ex)
                        {
                            //Log("[ " + DateTime.Now + " ] => [ Error:" + ex.Message + "StackTrace --> >>>" + ex.StackTrace);
                            GlobusFileHelper.AppendStringToTextfileNewLine(" Error:" + ex.Message + "StackTrace --> >>>" + ex.StackTrace, Globals.path_MessageGroupMember);
                        }
                    }
                }
                catch (Exception ex)
                {
                    GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error -->  PostFinalMsgGroupMember() --> 1 --> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace, Globals.Path_LinkedinErrorLogs);
                    GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error --> PostFinalMsgGroupMember() --> 1 --> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace, Globals.path_MessageGroupMember);
                }
            }
            catch (Exception ex)
            {
                GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error -->  PostFinalMsgGroupMember() --> 2 --> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace, Globals.Path_LinkedinErrorLogs);
                GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error --> PostFinalMsgGroupMember() --> 2 --> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace, Globals.Path_LinkedinComposeMessageErrorLogs);
            }
        }
예제 #15
0
        public void AddExperience(ref GlobusHttpHelper HttpHelper)
        {
            string FirstGetResponse   = HttpHelper.getHtmlfromUrl1(new Uri("http://www.linkedin.com/profile/edit?trk=tab_pro"));
            string postData           = string.Empty;
            string postUrl            = string.Empty;
            string expertise_comments = string.Empty;
            string specialties        = string.Empty;
            string csrfToken          = string.Empty;
            string sourceAlias        = string.Empty;
            string goback             = string.Empty;
            string Companyname        = string.Empty;
            string Title          = string.Empty;
            string Description    = string.Empty;
            string Location       = string.Empty;
            string startDateMonth = string.Empty;
            string startDateYear  = string.Empty;
            string endDateMonth   = string.Empty;
            string endDateYear    = string.Empty;

            // birthday_day = RandomNumberGenerator.GenerateRandom(1, 28).ToString();
            if (!SameExperienceTime && EndMonthFromcmb != string.Empty)
            {
                try
                {
                    startDateMonth = RandomNumberGenerator.GenerateRandom(1, 12).ToString();
                    startDateYear  = RandomNumberGenerator.GenerateRandom(1980, 2013).ToString();
                    endDateMonth   = RandomNumberGenerator.GenerateRandom(1, 12).ToString();
                    endDateYear    = RandomNumberGenerator.GenerateRandom(1980, 2013).ToString();
                }
                catch { }

                if (Convert.ToInt32(startDateYear) < Convert.ToInt32(endDateYear))
                {
                }
                else
                {
                    startDateYear = "2008";
                    endDateYear   = "2011";
                }
            }
            else
            {
                startDateMonth = StartMonthFromcmb;
                startDateYear  = StartYearFromcmb;
                endDateMonth   = EndMonthFromcmb;
                endDateYear    = EndYearFromcmb;
            }

            try
            {
                Companyname = lstCmpNames[RandomNumberGenerator.GenerateRandom(0, lstCmpNames.Count)];
                Loger("[ " + DateTime.Now + " ] => [ Company Name : " + Companyname + " ]");
            }
            catch { }
            try
            {
                Title = lstTitelNames[RandomNumberGenerator.GenerateRandom(0, lstTitelNames.Count)];
                Loger("[ " + DateTime.Now + " ] => [ Company Title : " + Title + " ]");
            }
            catch { }
            try
            {
                Location = lstLocationNames[RandomNumberGenerator.GenerateRandom(0, lstLocationNames.Count)];
                Loger("[ " + DateTime.Now + " ] => [ Location : " + Location + " ]");
            }
            catch { }
            try
            {
                Description = lstDescriptionNames[RandomNumberGenerator.GenerateRandom(0, lstDescriptionNames.Count)];
                Loger("[ " + DateTime.Now + " ] => [ Description : " + Description + " ]");
            }
            catch { }


            string[] ArrCsrfToken = Regex.Split(FirstGetResponse, "input");

            if (FirstGetResponse.Contains("csrfToken"))
            {
                try
                {
                    csrfToken = FirstGetResponse.Substring(FirstGetResponse.IndexOf("csrfToken"), 100);
                    string[] Arr = csrfToken.Split('>');
                    csrfToken = Arr[0].Replace("csrfToken=", "").Replace("\"", "").Trim();
                }
                catch (Exception ex)
                {
                }
            }

            try
            {
                string[] ArrForValue = Regex.Split(FirstGetResponse, "name\":\"sourceAlias");
                string   strValue    = (ArrForValue[1].Substring(ArrForValue[1].IndexOf("value\":"), ArrForValue[1].IndexOf("type\":", ArrForValue[1].IndexOf("value\":")) - ArrForValue[1].IndexOf("value\":")).Replace("value\":", string.Empty).Replace("\\\"", string.Empty).Replace("\"", string.Empty).Replace(",", "").Trim());
                sourceAlias = (strValue);
            }
            catch { }
            if (FirstGetResponse.Contains("goback"))
            {
                try
                {
                    goback = FirstGetResponse.Substring(FirstGetResponse.IndexOf("goback"), 300);
                    string[] Arr = goback.Split(',');
                    goback = Arr[0].Replace("goback=", "").Replace("\n", string.Empty).Replace("\"", string.Empty);
                }
                catch (Exception ex)
                {
                }
            }

            try
            {
                string postdataa = "csrfToken=" + csrfToken + "&goback=" + goback + "&trk=view-topcard&startTask=&futureOffset=";
                //string CheckRes = HttpHelper.postFormDataRef(new Uri("http://www.linkedin.com/profile/guided-edit-entry-point"), postdataa, "http://www.linkedin.com/profile/edit?trk=tab_pro", "", "XMLHttpRequest", "", "", "1");
                string CheckRes = HttpHelper.postFormDataRef(new Uri("http://www.linkedin.com/profile/guided-edit-entry-point"), postdataa, "http://www.linkedin.com/profile/edit?trk=nav_responsive_sub_nav_edit_profile", "", "XMLHttpRequest", "", "", "1");
                string FirstPostUrlForAddExperience      = "http://www.linkedin.com/lite/web-action-track?csrfToken=" + csrfToken;
                string FirstPostDataForAddExperience     = "pkey=nprofile_v2_edit_fs&tcode=nprofile-edit-position-submit&plist=activityType%3Aadd";
                string FirstPostResponseForAddExperience = HttpHelper.postFormDataRef(new Uri(FirstPostUrlForAddExperience), FirstPostDataForAddExperience, "http://www.linkedin.com/profile/edit?trk=nav_responsive_sub_nav_edit_profile", "", "XMLHttpRequest", "", "", "1");
            }
            catch { }

            try
            {
                string SecondPostUrlForAddExperience  = "http://www.linkedin.com/lite/web-action-track?csrfToken=" + csrfToken;
                string SecondPostDataForAddExperience = "pkey=nprofile_v2_edit_fs&tcode=nprofile-edit-position-submit&plist=activityType%3Aadd";
                SecondPostDataForAddExperience = "pkey=nprofile_v2_edit_fs&tcode=profile-edit-position-form&plist=source%3Aprof-edit-background-add_position-link";
                string SecondPostResponseForAddExperience = HttpHelper.postFormDataRef(new Uri(SecondPostUrlForAddExperience), SecondPostDataForAddExperience, "http://www.linkedin.com/profile/edit?trk=nav_responsive_sub_nav_edit_profile", "", "XMLHttpRequest", "", "", "1");
            }
            catch { }
            string ThirdPostResponseForAddExperience = string.Empty;

            try
            {
                if (!string.IsNullOrEmpty(endDateYear) && !string.IsNullOrEmpty(endDateMonth))
                {
                    string ThirdPostUrlForAddExperience  = "http://www.linkedin.com/profile/edit-position-submit?goback=" + goback;
                    string ThirdPostDataForAddExperience = "companyName=" + Companyname + "&companyDisplayName=" + Companyname + "&title=" + Title + "&positionLocationName=" + Location + "&startDateMonth=" + startDateMonth + "&startDateYear=" + startDateYear + "&endDateMonth=" + endDateMonth + "&endDateYear=" + endDateYear + "&updateHeadline=true&updatedHeadline=&summary=" + Description + "&trk-infoParams=&submit=Save&locale=en_US&timestamp=0&useJsonResponse=true&positionID=&experienceId=&defaultLocaleParam=en_US&companyID=0&positionLocation=0&checkboxValue=&sendMailCheckboxValue=&csrfToken=" + csrfToken + "&sourceAlias=" + sourceAlias;
                    ThirdPostResponseForAddExperience = HttpHelper.postFormDataRef(new Uri(ThirdPostUrlForAddExperience), ThirdPostDataForAddExperience, "http://www.linkedin.com/profile/edit?trk=tab_pro", "", "XMLHttpRequest", "", "", "1");

                    Loger("[ " + DateTime.Now + " ] => [ Experience Add to UserName : "******" ]");
                    Loger("[ " + DateTime.Now + " ] => [ Company Name : " + Companyname + " Title : " + Title + " Set Using UserName : "******" ]");

                    try
                    {
                        string CSVHeader   = "User Name" + "," + "Company Name" + "," + "Title" + "," + "Location" + "," + "Description";
                        string CSV_Content = _UserName + "," + Companyname + "," + Title + "," + Location + "," + Description.Replace(",", string.Empty);
                        CSVUtilities.ExportDataCSVFile(CSVHeader, CSV_Content, Globals.path_LinkedinAddExperience);
                        Loger("[ " + DateTime.Now + " ] => [ Data Saved In CSV File ! ]");
                    }
                    catch { }
                }
                else
                {
                    string ThirdPostUrlForAddExperience  = "http://www.linkedin.com/profile/edit-position-submit?goback=" + goback;
                    string ThirdPostDataForAddExperience = "companyName=" + Companyname + "&companyDisplayName=" + Companyname + "&title=" + Title + "&positionLocationName=" + Location + "&startDateMonth=" + startDateMonth + "&startDateYear=" + startDateYear + "&endDateMonth=&endDateYear=&isCurrent=isCurrent&updateHeadline=true&updatedHeadline=" + Title + "&summary=" + Description + "&trk-infoParams=&submit=Save&locale=en_US&timestamp=1360644826453&useJsonResponse=true&positionID=&experienceId=&defaultLocaleParam=en_US&companyID=0&positionLocation=0&checkboxValue=&sendMailCheckboxValue=&csrfToken=" + csrfToken + "&sourceAlias=" + sourceAlias;
                    ThirdPostResponseForAddExperience = HttpHelper.postFormDataRef(new Uri(ThirdPostUrlForAddExperience), ThirdPostDataForAddExperience, "http://www.linkedin.com/profile/edit?trk=tab_pro", "", "XMLHttpRequest", "", "", "1");
                    Loger("[ " + DateTime.Now + " ] => [ Experience Add to UserName : "******" ]");
                    Loger("[ " + DateTime.Now + " ] => [ Company Name : " + Companyname + " Title : " + Title + " Set Using UserName : "******" ]");

                    try
                    {
                        string CSVHeader   = "User Name" + "," + "Company Name" + "," + "Title" + "," + "Location" + "," + "Description";
                        string CSV_Content = _UserName + "," + Companyname + "," + Title + "," + Location + "," + Description.Replace(",", "");
                        CSVUtilities.ExportDataCSVFile(CSVHeader, CSV_Content, Globals.path_LinkedinAddExperience);
                        Loger("[ " + DateTime.Now + " ] => [ Data Saved In CSV File ! ]");
                    }
                    catch { }
                }
            }
            catch { }
        }
예제 #16
0
        public void PostFinalMsgGroupMember(ref GlobusHttpHelper HttpHelper, Dictionary <string, string> SlectedContacts, string msg, string body, string UserName, string FromemailId, string FromEmailNam, int mindelay, int maxdelay)
        {
            try
            {
                string postdata       = string.Empty;
                string postUrl        = string.Empty;
                string ResLogin       = string.Empty;
                string csrfToken      = string.Empty;
                string sourceAlias    = string.Empty;
                string ReturnString   = string.Empty;
                string PostMsgSubject = string.Empty;
                string PostMsgBody    = string.Empty;

                try
                {
                    string MessageText   = string.Empty;
                    string PostedMessage = string.Empty;

                    int totalSelectedItems = SlectedContacts.Count;
                    Log("[ " + DateTime.Now + " ] => [ Total Selected Members : " + totalSelectedItems + " ]");

                    IEnumerable <IEnumerable <KeyValuePair <string, string> > > partitioned = SlectedContacts.Partition(50);


                    foreach (var item in partitioned)
                    {
                        string FString     = string.Empty;
                        string Nstring     = string.Empty;
                        string connId      = string.Empty;
                        string FullName    = string.Empty;
                        string ContactName = string.Empty;

                        string pageSource = HttpHelper.getHtmlfromUrl1(new Uri("http://www.linkedin.com/home?trk=hb_tab_home_top"));
                        if (pageSource.Contains("csrfToken"))
                        {
                            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.Trim();
                        }

                        if (pageSource.Contains("sourceAlias"))
                        {
                            sourceAlias = pageSource.Substring(pageSource.IndexOf("sourceAlias"), 100);
                            string[] Arr = sourceAlias.Split('"');
                            sourceAlias = Arr[2];
                        }


                        try
                        {
                            foreach (KeyValuePair <string, string> itemChecked in item)
                            {
                                try
                                {
                                    string FName = string.Empty;
                                    string Lname = string.Empty;
                                    FullName = string.Empty;

                                    FName = itemChecked.Value.Split(' ')[0];
                                    Lname = itemChecked.Value.Split(' ')[1];

                                    FullName = FName + " " + Lname;
                                    try
                                    {
                                        ContactName = ContactName + "  :  " + FullName;

                                        if (ContactName.Contains("class="))
                                        {
                                            try
                                            {
                                                ContactName = ContactName.Substring(0, ContactName.IndexOf("class=")).Trim();
                                            }
                                            catch (Exception ex)
                                            {
                                            }
                                        }
                                    }
                                    catch { }
                                    Log("[ " + DateTime.Now + " ] => [ Adding Contact : " + FullName + " ]");

                                    string        ToCd         = itemChecked.Key;
                                    List <string> AddAllString = new List <string>();

                                    if (FString == string.Empty)
                                    {
                                        string CompString = "{" + "\"" + "_" + ToCd.Trim() + "\"" + ":" + "{" + "\"" + "memberId" + "\"" + ":" + "\"" + ToCd.Trim() + "\"" + "," + "\"" + "firstName" + "\"" + ":" + "\"" + FName + "\"" + "," + "\"" + "lastName" + "\"" + ":" + "\"" + Lname + "\"" + "}";
                                        FString = CompString;
                                    }
                                    else
                                    {
                                        string CompString = "\"" + "_" + ToCd.Trim() + "\"" + ":" + "{" + "\"" + "memberId" + "\"" + ":" + "\"" + ToCd.Trim() + "\"" + "," + "\"" + "firstName" + "\"" + ":" + "\"" + FName + "\"" + "," + "\"" + "lastName" + "\"" + ":" + "\"" + Lname + "\"" + "}";
                                        FString = CompString;
                                    }

                                    if (Nstring == string.Empty)
                                    {
                                        Nstring = FString;
                                        connId  = ToCd;
                                    }
                                    else
                                    {
                                        Nstring += "," + FString;
                                        connId  += " " + ToCd;
                                    }
                                }
                                catch { }
                            }
                            Nstring += "}";

                            try
                            {
                                string PostMessage;
                                string ResponseStatusMsg;
                                Log("[ " + DateTime.Now + " ] => [ Message Sending Process Running.. ]");
                                PostMessage       = "csrfToken=" + csrfToken + "&subject=" + Uri.EscapeDataString(msg.ToString()) + "&body=" + Uri.EscapeDataString(body.ToString()) + "&submit=Send+Message&showRecipeints=showRecipeints&fromName=" + FromEmailNam + "&fromEmail=" + FromemailId + "&connectionIds=" + connId + "&connectionNames=" + Uri.EscapeUriString(Nstring) + "&allowEditRcpts=true&addMoreRcpts=false&openSocialAppBodySuffix=&st=&viewerDestinationUrl=&goback=.smg_*1_*1_*1_*1_*1_*1_*1_*1_*1";
                                ResponseStatusMsg = HttpHelper.postFormData(new Uri("http://www.linkedin.com/msgToConns"), PostMessage);


                                if (ResponseStatusMsg.Contains("Your message was successfully sent."))
                                {
                                    Log("[ " + DateTime.Now + " ] => [ Subject Posted : " + msg + " ]");
                                    Log("[ " + DateTime.Now + " ] => [ Body Text Posted : " + body.ToString() + " ]");
                                    Log("[ " + DateTime.Now + " ] => [ Message Posted To  Accounts : " + item.Count() + " ] ");
                                    ReturnString = "Your message was successfully.";

                                    #region CSV
                                    string bdy = string.Empty;
                                    try
                                    {
                                        bdy = body.ToString().Replace("\r", string.Empty).Replace("\n", " ").Replace(",", " ");
                                    }
                                    catch { }
                                    if (string.IsNullOrEmpty(bdy))
                                    {
                                        bdy = body.ToString().Replace(",", ":");
                                    }
                                    string CSVHeader   = "UserName" + "," + "Subject" + "," + "Body Text" + "," + "ContactName";
                                    string CSV_Content = UserName + "," + msg + "," + bdy.ToString() + "," + ContactName;
                                    CSVUtilities.ExportDataCSVFile(CSVHeader, CSV_Content, Globals.path_MessageSentGroupMember);

                                    #endregion

                                    //GlobusFileHelper.AppendStringToTextfileNewLine("Subject Posted : " + textMsg.Text.ToString(), Globals.path_MessageGroupMember);
                                    //GlobusFileHelper.AppendStringToTextfileNewLine("Body Text Posted : " + txtBody.Text.ToString(), Globals.path_MessageGroupMember);
                                    //GlobusFileHelper.AppendStringToTextfileNewLine("Message Posted To All Selected Accounts", Globals.path_MessageGroupMember);
                                }
                                else if (ResponseStatusMsg.Contains("There was an unexpected problem that prevented us from completing your request.") || ResponseStatusMsg.Contains("You are no longer authorized to message this"))
                                {
                                    //Log("Error In Message Posting");
                                    Log("[ " + DateTime.Now + " ] => [ There was an unexpected problem that prevented us from completing your request ]");
                                    //string CSVHeader = "UserName" + "," + "Subject" + "," + "Body Text" + "," + "ContactName";
                                    //string CSV_Content = UserName + "," + msg + "," + body.ToString() + "," + ContactName;
                                    //CSVUtilities.ExportDataCSVFile(CSVHeader, CSV_Content, Globals.path_MessageSentGroupMember);

                                    GlobusFileHelper.AppendStringToTextfileNewLine("Error In Message Posting", Globals.path_MessageGroupMember);
                                }
                            }
                            catch (Exception ex)
                            {
                                //Log("[ " + DateTime.Now + " ] => [ Error:" + ex.Message + "StackTrace --> >>>" + ex.StackTrace + " ]");

                                GlobusFileHelper.AppendStringToTextfileNewLine(" Error:" + ex.Message + "StackTrace --> >>>" + ex.StackTrace, Globals.path_MessageGroupMember);
                            }

                            int delay = RandomNumberGenerator.GenerateRandom(mindelay, maxdelay);
                            Log("[ " + DateTime.Now + " ] => [ Delay for : " + delay + " Seconds ]");
                            Thread.Sleep(delay * 1000);
                        }
                        catch (Exception ex)
                        {
                            GlobusFileHelper.AppendStringToTextfileNewLine(" Error:" + ex.Message + "StackTrace --> >>>" + ex.StackTrace, Globals.path_MessageGroupMember);
                        }
                    }
                }
                catch (Exception ex)
                {
                    GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error -->  PostFinalMsgGroupMember() --> 1 --> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace, Globals.Path_LinkedinErrorLogs);
                    GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error --> PostFinalMsgGroupMember() --> 1 --> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace, Globals.path_MessageGroupMember);
                }
            }
            catch (Exception ex)
            {
                GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error -->  PostFinalMsgGroupMember() --> 2 --> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace, Globals.Path_LinkedinErrorLogs);
                GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error --> PostFinalMsgGroupMember() --> 2 --> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace, Globals.path_MessageGroupMember);
            }
        }
        public void GetMultipleRecords(ref GlobusHttpHelper HttpHelper)
        {
            try
            {
                string csrfToken      = string.Empty;
                string LastName       = string.Empty;
                string FirstName      = string.Empty;
                string Industry       = string.Empty;
                string Postalcode     = string.Empty;
                string Distance       = string.Empty;
                string contentSummary = string.Empty;
                string Title          = string.Empty;
                string Company        = string.Empty;
                string school         = string.Empty;
                string Country        = string.Empty;
                string countrycode    = string.Empty;
                string industrycode   = string.Empty;
                string rsid           = string.Empty;

                string pageSource = HttpHelper.getHtmlfromUrl1(new Uri("http://www.linkedin.com/home?trk=hb_tab_home_top"));

                try
                {
                    try
                    {
                        string[] Arr_Pst = Regex.Split(postalCode, "(");
                    }
                    catch { }
                    try
                    {
                        Postalcode = postalCode.Substring(0, postalCode.IndexOf(" "));
                        Country    = postalCode.Replace(Postalcode, string.Empty).Replace(")", string.Empty).Replace("(", string.Empty).Trim();
                    }
                    catch
                    {
                        if (Postalcode == string.Empty)
                        {
                            Postalcode = postalCode;
                        }
                    }
                }
                catch { }
                if (pageSource.Contains("csrfToken"))
                {
                    csrfToken = pageSource.Substring(pageSource.IndexOf("csrfToken"), 100);
                    string[] Arr = csrfToken.Split('&');
                    csrfToken = Arr[0];
                    csrfToken = csrfToken.Replace("csrfToken=", "");
                    csrfToken = csrfToken.Replace("%3A", ":");
                }
                InBoardPro.GetIndustryCode  objIndustry       = new GetIndustryCode();
                Dictionary <string, string> Dict_IndustryCode = new Dictionary <string, string>();

                Dict_IndustryCode = objIndustry.getIndustry();
                foreach (KeyValuePair <string, string> item in Dict_IndustryCode)
                {
                    try
                    {
                        string toloweritem         = item.Value.ToLower();
                        string tolowerindustrytype = industryType.ToLower();
                        if (toloweritem == tolowerindustrytype)
                        {
                            //SearchCriteria.Country = item.Key;
                            industrycode = item.Key;
                            break;
                        }
                    }
                    catch
                    {
                    }
                }

                Dictionary <string, string> Dict_CountryCode = new Dictionary <string, string>();
                Dict_CountryCode = objIndustry.getCountry();
                foreach (KeyValuePair <string, string> item in Dict_CountryCode)
                {
                    try
                    {
                        string toloweritem        = item.Value.ToLower();
                        string tolowercountrytype = Country.ToLower();
                        if (toloweritem == tolowercountrytype)
                        {
                            countrycode = item.Key;
                            break;
                        }
                    }
                    catch
                    {
                    }
                }
                string Firstresponse = string.Empty;
                if (string.IsNullOrEmpty(countrycode))
                {
                    countrycode = "us";
                }

                string FirstGetRequestUrl = string.Empty;
                string FirstGetResponse   = string.Empty;
                {
                    try
                    {
                        FirstGetRequestUrl = "http://www.linkedin.com/search/fpsearch?lname=" + lastName + "&searchLocationType=I&countryCode=" + countrycode + "&postalCode=" + Postalcode + "&distance=" + distance + "&keepFacets=keepFacets&page_num=1&facet_I=" + industrycode + "&pplSearchOrigin=ADVS&viewCriteria=2&sortCriteria=R&redir=redir";
                        FirstGetResponse   = HttpHelper.getHtmlfromUrl1(new Uri(FirstGetRequestUrl));
                    }
                    catch { }
                }

                int RecordCount = 0;
                try
                {
                    RecordCount = objIndustry.GetPageNo(FirstGetResponse);

                    if (RecordCount == 0)
                    {
                        string getAdvPagedata = HttpHelper.getHtmlfromUrl(new Uri("http://www.linkedin.com/vsearch/f?adv=true&trk=advsrch"), "http://www.linkedin.com/");

                        try
                        {
                            int    startindex = getAdvPagedata.IndexOf("rsid=");
                            string start      = getAdvPagedata.Substring(startindex).Replace("rsid=", "");
                            int    endindex   = start.IndexOf("&amp;");
                            string end        = start.Substring(0, endindex);
                            rsid = end;
                        }
                        catch (Exception ex)
                        {
                        }

                        try
                        {
                            FirstGetRequestUrl = "http://www.linkedin.com/vsearch/p?lastName=" + lastName + "&postalCode=" + postalCode + "&openAdvancedForm=true&locationType=I&countryCode=" + countrycode + "&distance=" + distance + "&f_I=" + industrycode.Replace(" ", "") + "&rsid=" + rsid + "&orig=ADVS";
                            FirstGetResponse   = HttpHelper.getHtmlfromUrl1(new Uri(FirstGetRequestUrl));
                        }
                        catch { }
                    }

                    RecordCount = objIndustry.GetPageNo(FirstGetResponse);

                    if (lastName != string.Empty && industryType == string.Empty)
                    {
                        Loger("[ " + DateTime.Now + " ] => [ Get RecordCount : " + RecordCount + " Using UserName : "******" Zip Code : " + postalCode.ToString() + " Distance : " + distance + " LastName : " + lastName + " ]");
                    }

                    if (industryType != string.Empty && lastName == string.Empty)
                    {
                        Loger("[ " + DateTime.Now + " ] => [ Get RecordCount : " + RecordCount + " Using UserName : "******" Zip Code : " + postalCode.ToString() + " Distance : " + distance + " Industry : " + industryType + " ]");
                    }

                    if (lastName == string.Empty && industryType == string.Empty)
                    {
                        Loger("[ " + DateTime.Now + " ] => [ Get RecordCount : " + RecordCount + " Using UserName : "******" Zip Code : " + postalCode.ToString() + " Distance : " + distance + " ]");
                    }
                }
                catch { }
                try
                {
                    LinkedinScrappDbManager objLsManager = new LinkedinScrappDbManager();
                    objLsManager.InsertScarppRecordData(Postalcode, distance, industryType, lastName, RecordCount);
                }
                catch { }
                try
                {
                    string prxyadress = string.Empty;
                    try
                    {
                        if (!string.IsNullOrEmpty(proxyAddress) && !string.IsNullOrEmpty(proxyPort))
                        {
                            prxyadress = proxyAddress + ":" + proxyPort;
                        }
                    }
                    catch { }

                    if (lastName != string.Empty && industryType == string.Empty)
                    {
                        string CSVHeader   = "LastName" + "," + "CentralZipCode" + "," + "DistanceFromZipCode" + "," + "Number Of Result" + "," + "UserName" + "," + "Password" + "," + "Proxy" + "," + "ProxyPwd ";
                        string CSV_Content = lastName.ToString().Replace(",", ";") + "," + postalCode.ToString().Replace(",", ";") + "," + distance.ToString().Replace(",", ";") + "," + RecordCount.ToString().Replace(",", ";") + "," + accountUser.Replace(",", ";") + "," + accountPass.Replace(",", ";") + "," + prxyadress.Replace(",", ";") + "," + proxyPassword.Replace(",", ";");
                        CSVUtilities.ExportDataCSVFile(CSVHeader, CSV_Content, Globals.path_InBoardProGetDataResultCountLastNameWise);
                    }

                    if (industryType != string.Empty && lastName == string.Empty)
                    {
                        string CSVHeader   = "IndustryZone" + "," + "CentralZipCode" + "," + "DistanceFromZipCode" + "," + "Number Of Result" + "," + "UserName" + "," + "Password" + "," + "Proxy" + "," + "ProxyPwd ";
                        string CSV_Content = industryType.ToString().Replace(",", ";") + "," + postalCode.ToString().Replace(",", ";") + "," + distance.ToString().Replace(",", ";") + "," + RecordCount.ToString().Replace(",", ";") + "," + accountUser.Replace(",", ";") + "," + accountPass.Replace(",", ";") + "," + prxyadress.Replace(",", ";") + "," + proxyPassword.Replace(",", ";");
                        CSVUtilities.ExportDataCSVFile(CSVHeader, CSV_Content, Globals.path_InBoardProGetDataResultCountIndustryZoneWise);
                    }

                    if (lastName == string.Empty && industryType == string.Empty)
                    {
                        string CSVHeader   = "CentralZipCode" + "," + "DistanceFromZipCode" + "," + "Number Of Result" + "," + "UserName" + "," + "Password" + "," + "Proxy" + "," + "ProxyPwd ";
                        string CSV_Content = postalCode.ToString().Replace(",", ";") + "," + distance.ToString().Replace(",", ";") + "," + RecordCount.ToString().Replace(",", ";") + "," + accountUser.Replace(",", ";") + "," + accountPass.Replace(",", ";") + "," + prxyadress.Replace(",", ";") + "," + proxyPassword.Replace(",", ";");
                        CSVUtilities.ExportDataCSVFile(CSVHeader, CSV_Content, Globals.path_InBoardProGetDataResultCountZipCodeWise);
                    }
                }
                catch { }
            }
            catch { }
        }
예제 #18
0
        public void GetRecords(ref GlobusHttpHelper HttpHelper)
        {
            try
            {
                string csrfToken      = string.Empty;
                string LastName       = string.Empty;
                string FirstName      = string.Empty;
                string Industry       = string.Empty;
                string Postalcode     = string.Empty;
                string Distance       = string.Empty;
                string contentSummary = string.Empty;
                string Title          = string.Empty;
                string Company        = string.Empty;
                string school         = string.Empty;
                string Country        = string.Empty;
                string countrycode    = string.Empty;
                string industrycode   = string.Empty;
                string rsid           = string.Empty;

                string pageSource = HttpHelper.getHtmlfromUrl1(new Uri("http://www.linkedin.com/home?trk=hb_tab_home_top"));

                try
                {
                    try
                    {
                        string[] Arr_Pst = Regex.Split(postalCode, "(");
                    }
                    catch { }
                    try
                    {
                        Postalcode = postalCode.Substring(0, postalCode.IndexOf(" "));
                        Country    = postalCode.Replace(Postalcode, string.Empty).Replace(")", string.Empty).Replace("(", string.Empty).Trim();
                        //Postalcode = Arr_Pst[0].Replace(" ", string.Empty).Trim();
                        //Country = Arr_Pst[1].Replace("{", string.Empty).Replace("}", string.Empty).Trim();
                    }
                    catch
                    {
                        if (Postalcode == string.Empty)
                        {
                            Postalcode = postalCode;
                        }
                    }
                }
                catch { }
                if (pageSource.Contains("csrfToken"))
                {
                    csrfToken = pageSource.Substring(pageSource.IndexOf("csrfToken"), 100);
                    string[] Arr = csrfToken.Split('&');
                    csrfToken = Arr[0];
                    csrfToken = csrfToken.Replace("csrfToken=", "");
                    csrfToken = csrfToken.Replace("%3A", ":");
                }
                InBoardPro.GetIndustryCode  objIndustry       = new GetIndustryCode();
                Dictionary <string, string> Dict_IndustryCode = new Dictionary <string, string>();


                Dict_IndustryCode = objIndustry.getIndustry();
                foreach (KeyValuePair <string, string> item in Dict_IndustryCode)
                {
                    try
                    {
                        string toloweritem         = item.Value.ToLower();
                        string tolowerindustrytype = industryType.ToLower();
                        if (toloweritem == tolowerindustrytype)
                        {
                            //SearchCriteria.Country = item.Key;
                            industrycode = item.Key;
                            break;
                        }
                    }
                    catch
                    {
                    }
                }

                Dictionary <string, string> Dict_CountryCode = new Dictionary <string, string>();
                Dict_CountryCode = objIndustry.getCountry();
                foreach (KeyValuePair <string, string> item in Dict_CountryCode)
                {
                    try
                    {
                        string toloweritem        = item.Value.ToLower();
                        string tolowercountrytype = Country.ToLower();
                        if (toloweritem == tolowercountrytype)
                        {
                            countrycode = item.Key;
                            break;
                        }
                    }
                    catch
                    {
                    }
                }
                string Firstresponse = string.Empty;
                if (string.IsNullOrEmpty(countrycode))
                {
                    countrycode = "us";
                }

                string FirstGetRequestUrl = string.Empty;
                string FirstGetResponse   = string.Empty;
                {
                    try
                    {
                        FirstGetRequestUrl = "http://www.linkedin.com/search/fpsearch?lname=" + lastName + "&searchLocationType=I&countryCode=" + countrycode + "&postalCode=" + Postalcode + "&distance=" + distance + "&keepFacets=keepFacets&page_num=1&facet_I=" + industrycode + "&pplSearchOrigin=ADVS&viewCriteria=2&sortCriteria=R&redir=redir";
                        FirstGetResponse   = HttpHelper.getHtmlfromUrl1(new Uri(FirstGetRequestUrl));
                    }
                    catch { }
                }

                int RecordCount = 0;
                try
                {
                    RecordCount = objIndustry.GetPageNo(FirstGetResponse);

                    if (RecordCount == 0)
                    {
                        string getAdvPagedata = HttpHelper.getHtmlfromUrl(new Uri("http://www.linkedin.com/vsearch/f?adv=true&trk=advsrch"), "http://www.linkedin.com/");

                        try
                        {
                            int    startindex = getAdvPagedata.IndexOf("rsid=");
                            string start      = getAdvPagedata.Substring(startindex).Replace("rsid=", "");
                            int    endindex   = start.IndexOf("&amp;");
                            string end        = start.Substring(0, endindex);
                            rsid = end;
                        }
                        catch (Exception ex)
                        {
                        }

                        //FirstGetRequestUrl = "http://www.linkedin.com/vsearch/p?lastName=" + lastName + "&postalCode=" + postalCode + "&openAdvancedForm=true&locationType=I&countryCode=" + countrycode + "&distance=" + distance + "&facet_I=" + industrycode + "&sortBy=R&rsid=" + rsid + "&orig=MDYS";
                        // http://www.linkedin.com/vsearch/p?lastName=James&postalCode=44101&openAdvancedForm=true&locationType=I&countryCode=us&distance=50&f_N=F,S,A&rsid=2247217581372762829704&orig=MDYS";
                        //http://www.linkedin.com/vsearch/p?lastName=" + lastName + "&postalCode=" + postalCode + "&openAdvancedForm=true&locationType=I&countryCode=" + countrycode + "&distance=" + distance + "&facet_I=" + industrycode + "&sortBy=R&rsid=" + rsid + "&orig=MDYS";

                        try
                        {
                            FirstGetRequestUrl = "http://www.linkedin.com/vsearch/p?lastName=" + lastName + "&postalCode=" + postalCode + "&openAdvancedForm=true&locationType=I&countryCode=" + countrycode + "&distance=" + distance + "&f_I=" + industrycode.Replace(" ", "") + "&rsid=" + rsid + "&orig=ADVS";
                            FirstGetResponse   = HttpHelper.getHtmlfromUrl1(new Uri(FirstGetRequestUrl));
                        }
                        catch { }
                    }


                    RecordCount = objIndustry.GetPageNo(FirstGetResponse);

                    Loger("[ " + DateTime.Now + " ] => [ Get RecordCount : " + RecordCount + " Using UserName : "******" Postal Code : " + postalCode.ToString() + " Distance : " + distance + " Industry : " + industrycode + " ]");
                }
                catch { }
                try
                {
                    LinkedinScrappDbManager objLsManager = new LinkedinScrappDbManager();
                    objLsManager.InsertScarppRecordData(Postalcode, distance, industryType, lastName, RecordCount);
                }
                catch { }
                try
                {
                    string prxyadress = string.Empty;
                    try
                    {
                        if (!string.IsNullOrEmpty(proxyAddress) && !string.IsNullOrEmpty(proxyPort))
                        {
                            prxyadress = proxyAddress + ":" + proxyPort;
                        }
                    }
                    catch { }

                    string CSVHeader   = "PostalCode" + "," + "Distance" + "," + "IndustryType" + "," + "LastName" + "," + "UserName" + "," + "Password" + "," + "Proxy" + "," + "ProxyPwd " + "," + "Number Of Result";                                                                                                                                                                      // + "," + "Connection" + "," + "Recommendations " + "," + "SkillAndExpertise " + "," + "Experience " + "," + " Education" + "," + "Groups" + "," + "UserEmail" + "," + "UserContactNumber" + "," + "PastTitles" + "," + "PastCompany" + "," + "Location" + "," + "Country" + "," + "Industry" + "," + "WebSites" + "," + "LinkedinLogInID" + ",";
                    string CSV_Content = postalCode.Replace(",", ";") + "," + distance.Replace(",", ";") + "," + industryType.Replace(",", ";") + "," + lastName.Replace(",", ";") + "," + accountUser.Replace(",", ";") + "," + accountPass.Replace(",", ";") + "," + prxyadress.Replace(",", ";") + "," + proxyPassword.Replace(",", ";") + "," + RecordCount.ToString().Replace(",", ";"); //+ "," + Connection.Replace(",", ";") + "," + recomandation.Replace(",", string.Empty) + "," + Skill.Replace(",", ";") + "," + LDS_Experience.Replace(",", string.Empty) + "," + EducationCollection.Replace(",", ";") + "," + groupscollectin.Replace(",", ";") + "," + USERemail.Replace(",", ";") + "," + LDS_UserContact.Replace(",", ";") + "," + LDS_PastTitles + "," + AllComapny.Replace(",", ";") + "," + country.Replace(",", ";") + "," + location.Replace(",", ";") + "," + Industry.Replace(",", ";") + "," + Website.Replace(",", ";") + "," + accountUser + ",";// +TypeOfProfile + ",";
                    CSVUtilities.ExportDataCSVFile(CSVHeader, CSV_Content, Globals.path_InBoardProGetDataResultCount);
                }
                catch { }
            }
            catch { }
        }
        public string FromEmailCodeComposeMsg(ref GlobusHttpHelper HttpHelper, string email)
        {
            string FromId = string.Empty;
            //string FromNm = string.Empty;
            string namewithid = string.Empty;
            string pageSource = string.Empty;
            string[] RgxGroupData = new string[] { };

            if (string.IsNullOrEmpty(namewithid))
            {
                try
                {
                    pageSource = HttpHelper.getHtmlfromUrl1(new Uri("http://www.linkedin.com/inbox/compose?trk=inbox_messages-comm-left_nav-compose"));
                    RgxGroupData = Regex.Split(pageSource, "\"name\":\"senderEmail\"");

                    try
                    {
                        if (RgxGroupData[1].Contains("\"value\":"))
                        {
                            try
                            {
                                int StartIndex = RgxGroupData[1].IndexOf("\"value\":");
                                string start = RgxGroupData[1].Substring(StartIndex);
                                int endIndex = start.IndexOf(",");
                                FromId = start.Substring(0, endIndex).Replace("\"", string.Empty).Replace("value:", string.Empty).Replace("}", string.Empty).Trim();
                            }
                            catch
                            {
                            }
                        }
                        //namewithid = FromId + ":" + FromNm;
                        namewithid = FromId;
                    }
                    catch { }
                }
                catch (Exception ex)
                {
                    return namewithid;
                }
            }
            return namewithid;
        }
        public void Pagination(ref GlobusHttpHelper objHttpHelper, string mainUrl)
        {
            int PageCunt = 1;
            try
            {
                string totalResults = string.Empty;
                bool dispTotalResults = true;
                string mainPageResponse = string.Empty;
                int paginationCounter = 0;
                do
                {
                    //mainUrl = mainUrl.Replace("replaceVariableCounter", paginationCounter.ToString());

                    //if (SalesNavigatorGlobals.isStop)
                    //{
                    //    return;
                    //}

                    ///string hoMEuRL = "https://www.linkedin.com/sales/search/?facet=N&facet.N=O&facet=G&facet.G=in:7350&facet=I&facet.I=96&facet=FA&facet.FA=12&defaultSelection=false&start=0&count=10&searchHistoryId=1540160093&keywords=ITIL&trk=lss-search-tab";
                    // string Url = mainUrl.Replace("replaceVariableCounter", paginationCounter.ToString());
                    mainPageResponse = objHttpHelper.getHtmlfromUrl(new Uri(mainUrl));
                    if (string.IsNullOrEmpty(mainPageResponse))
                    {
                        mainPageResponse = objHttpHelper.getHtmlfromUrl1(new Uri("https://www.linkedin.com/sales/?trk=nav_responsive_sub_nav_upgrade"));
                        mainPageResponse = objHttpHelper.getHtmlfromUrl(new Uri(mainUrl));
                    }

                    //if (mainPageResponse.Contains("We'll be back soon.")&&(mainPageResponse.Contains("We're getting things cleaned up.")))
                    //{
                    //    string unwatedStr = "https://www.linkedin.com/sales/search/?facet=N&facet.N=O&facet=G&facet.G=in:7350&facet=I&facet.I=96&facet=FA&facet.FA=12&defaultSelection=false&start=0&count=10&searchHistoryId=1540160093&keywords="+""+"&trk=lss-search-tab";// "&countryCode=" + Utils.getBetween(mainUrl, "&countryCode=", "&");
                    //    mainPageResponse = objHttpHelper.getHtmlfromUrl(new Uri(mainUrl.Replace(unwatedStr, paginationCounter.ToString())));
                    //}


                    if (string.IsNullOrEmpty(mainPageResponse))
                    {
                        if (string.IsNullOrEmpty(mainPageResponse))
                        {
                            //MessageBox.Show("Null response from internet. Please check your internet connection and restart the software.");
                            GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ No response from internet. Please check your internet connection. ] ");
                        }
                        Thread.Sleep(2000);
                        mainPageResponse = objHttpHelper.getHtmlfromUrl(new Uri(mainUrl.Replace("replaceVariableCounter", paginationCounter.ToString())));

                    }
                    try
                    {
                        if (dispTotalResults)
                        {
                            totalResults = Utils.getBetween(mainPageResponse, "\"total\":", ",\"").Trim();
                            GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Total results found : " + totalResults + " ]");
                            GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Scraping profile Url ]");
                            dispTotalResults = false;
                        }
                    }
                    catch
                    { }
                    int checkCountUrls = 0;
                    string[] profileUrl_Split = Regex.Split(mainPageResponse, "\"profileUrl\"");
                    List<string> ProfileList = new List<string>();
                    foreach (string profileUrlItem in profileUrl_Split)
                    {
                        if (!profileUrlItem.Contains("<!DOCTYPE"))
                        {
                            checkCountUrls++;
                            string profileUrl = Utils.getBetween(profileUrlItem, ":\"", "\",\"");
                            lstProfileUrls.Add(profileUrl);
                            GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Scraped Url : " + profileUrl + " ] ");
                            ProfileList.Add(profileUrl);

                        }
                    }
                    Thread.Sleep(1000);
                    ScrapeProfileDetails(ref objHttpHelper, ProfileList);
                    int startindex = paginationCounter;
                    paginationCounter = paginationCounter + 100;
                    mainUrl = CreatePaginationUrl(mainUrl, startindex, paginationCounter);
                } while (mainPageResponse.Contains("\"profileUrl\":\""));
            }
            catch (Exception ex)
            {
            }
        }
        public string FromName(ref GlobusHttpHelper HttpHelper)
        {
            string FromNm = string.Empty;
            try
            {
                string pageSource = HttpHelper.getHtmlfromUrl1(new Uri("http://www.linkedin.com/profile/edit?trk=nav_responsive_sub_nav_edit_profile"));

                string[] RgxGroupData = System.Text.RegularExpressions.Regex.Split(pageSource, "fmt_full_display_name");

                foreach (var fromname in RgxGroupData)
                {
                    if (fromname.Contains("\":\""))
                    {
                        try
                        {
                            if (!(fromname.Contains("<!DOCTYPE html>")))
                            {
                                try
                                {
                                    int StartIndex = fromname.IndexOf("\":\"");
                                    string start = fromname.Substring(StartIndex);
                                    int endIndex = start.IndexOf("i18n_optional_not_pinyin");
                                    FromNm = start.Substring(0, endIndex).Replace("\"", string.Empty).Replace("\":\"", string.Empty);
                                    FromNm = FromNm.Split(',')[0].Replace(":", string.Empty).Replace("\\u002d", "-");
                                }
                                catch
                                { }
                                try
                                {
                                    if (string.IsNullOrEmpty(FromNm) || FromNm.Contains("LastName"))
                                    {
                                        int StartIndex = fromname.IndexOf("\":\"");
                                        string start = fromname.Substring(StartIndex);
                                        int endIndex = start.IndexOf(",");
                                        FromNm = start.Substring(0, endIndex).Replace("\"", string.Empty).Replace("\":\"", string.Empty);
                                        FromNm = FromNm.Split(',')[0].Replace(":", string.Empty);
                                    }
                                }
                                catch
                                { }
                            }
                        }
                        catch { }
                    }
                }
                return FromNm;
            }
            catch (Exception ex)
            {
                //return FromNm;
            }
            return FromNm;
        }
        public void StartAcceptInvitations(ref GlobusHttpHelper httpHelper)
        {
            try
            {
                string csrfToken     = string.Empty;
                string userFirstName = string.Empty;
                string UserLastName  = string.Empty;
                string SenderName    = string.Empty;
                string newPagesource = string.Empty;
                bool   isTrue        = false;
                int    startRow      = 1;

                string pageSource = httpHelper.getHtmlfromUrl1(new Uri("http://www.linkedin.com/inbox/invitations/pending"));


                var 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);
                    UserLastName         = resultForUserDetails.Split(' ')[1].Replace("\"", string.Empty);
                }
                catch { }

                if (pageSource.Contains("csrfToken"))
                {
                    csrfToken = pageSource.Substring(pageSource.IndexOf("csrfToken"), 100);
                    string[] Arr = csrfToken.Split('"');
                    try
                    {
                        foreach (string item in Arr)
                        {
                            try
                            {
                                if (item.Contains("csrfToken="))
                                {
                                    csrfToken = item.Substring(item.IndexOf("csrfToken="), item.IndexOf("&", item.IndexOf("csrfToken=")) - item.IndexOf("csrfToken=")).Replace("csrfToken=", string.Empty).Replace("\"", string.Empty).Replace("\\", string.Empty).Trim();//Arr[2].Replace(@"\", string.Empty).Replace("//", string.Empty);

                                    break;
                                }
                            }
                            catch (Exception ex)
                            {
                            }

                            if (item.Contains("csrfToken="))
                            {
                                csrfToken = item.Replace("csrfToken=", string.Empty).Trim();

                                break;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        //csrfToken = Arr[0].Replace("csrfToken=", "").Replace("\\", "");
                    }
                }

                // For Show More

                //string postData1 = "pkey=inbox-invitations-pending&tcode=%5Bobject%20Arguments%5D&plist=";
                //string response1 = httpHelper.postFormData(new Uri("http://www.linkedin.com/lite/web-action-track?csrfToken="+csrfToken+""),postData1);
                //string pageSource2=httpHelper.getHtmlfromUrl(new Uri("http://www.linkedin.com/inbox/invitations/pending/more?sinceDate=1366351490125&startRow=6&count=20&showBlocked=false&ctx=inbox&rnd=1366353236172"));
                //*** Conver HTML to XML *******************************//
                #region Convert HTML to XML
                ChilkatHttpHelpr objhelper = new ChilkatHttpHelpr();
                //xHtml contain xml data
                string xHtml = objhelper.ConvertHtmlToXml(pageSource);

                Chilkat.Xml xml = new Chilkat.Xml();
                xml.LoadXml(xHtml);
                //xHtml.

                ////  Iterate over all h1 tags:
                Chilkat.Xml xNode             = default(Chilkat.Xml);
                Chilkat.Xml xBeginSearchAfter = default(Chilkat.Xml);
                #endregion

                #region Invitatin count
                xBeginSearchAfter = null;
                xNode             = xml.SearchForAttribute(xBeginSearchAfter, "span", "class", "invitation-count count ");

                try
                {
                    while ((xNode != null))
                    {
                        string strvalue       = xNode.AccumulateTagContent("text", "script|style");
                        string Invitatincount = strvalue;
                        Log("[ " + DateTime.Now + " ] => [ Invitation Count = " + Invitatincount + " UserName = "******" ]");
                        Log("-----------------------------------------------------------------------------------------------------------------------------------");
                        break;
                    }
                }
                catch (Exception ex)
                {
                }

                #endregion


                do
                {
                    newPagesource = httpHelper.getHtmlfromUrl1(new Uri("https://www.linkedin.com/inbox/invitations?keywords=&sortBy=&startRow=" + startRow + "&subFilter=&trk=&showBlocked=false"));
                    if (newPagesource.Contains("inbox-list"))
                    {
                        string inbox_list = httpHelper.GetDataWithTagValueByTagAndAttributeNameWithClass(newPagesource, "ol", "inbox-list ");

                        if (inbox_list.Contains("<li"))
                        {
                            isTrue = true;
                            string[] srrLi = Regex.Split(inbox_list, "<li");

                            foreach (string item in srrLi)
                            {
                                try
                                {
                                    if (item.Contains("data-gid=\""))
                                    {
                                        string data_gid    = item.Substring(item.IndexOf("data-gid=\"") + 10, item.IndexOf("\"", item.IndexOf("data-gid=\"") + 10) - (item.IndexOf("data-gid=\"") + 10)).Replace("\"", string.Empty).Replace("data-gid=\"", string.Empty).Trim();
                                        int    startindex1 = item.IndexOf("alt=");
                                        string start1      = item.Substring(startindex1).Replace("alt=", string.Empty);
                                        int    endindex1   = start1.IndexOf("height");
                                        string end1        = start1.Substring(0, endindex1).Replace("\"", string.Empty).Trim();
                                        SenderName = end1;

                                        string response2 = httpHelper.getHtmlfromUrl1(new Uri("http://www.linkedin.com/inbox/action?mboxItemGID=" + data_gid + "&actionType=invitationAccept&csrfToken=" + csrfToken + "&goback=%2Epiv_*1_*1_*1_*1_*1&trk=inbox-invitations-inv-accept&ctx=inbox&rnd=1366352095313"));

                                        if (response2.Contains(" are now connected"))
                                        {
                                            string SuccessMsg = string.Empty;
                                            int    startindex = response2.IndexOf("<div class=\"confirmation\">");

                                            if (startindex > 0)
                                            {
                                                try
                                                {
                                                    string start    = response2.Substring(startindex).Replace("<div class=\"confirmation\">", string.Empty);
                                                    int    endindex = start.IndexOf("<ul>");
                                                    string end      = start.Substring(0, endindex);
                                                    //SuccessMsg = end.Replace("<h4>", string.Empty).Replace("\"", string.Empty).Replace("</h4>", string.Empty).Replace("\n", string.Empty).Replace("\t", string.Empty).Replace("\"u002", "-").Replace("You", "User: "******"<h4>", string.Empty).Replace("\"", string.Empty).Replace("</h4>", string.Empty).Replace("\n", string.Empty).Replace("\t", string.Empty).Replace("\"u002", "-").Replace("You", "User: "******"( Name:" + userFirstName + "  " + UserLastName + ") ").Trim();
                                                }
                                                catch { }
                                            }

                                            GlobusFileHelper.AppendStringToTextfileNewLine(SuccessMsg, Globals.path_AcceptInvitationEmail);
                                            Log("[ " + DateTime.Now + " ] => [ " + SuccessMsg + " ]");
                                        }
                                        if (!(response2.Contains(SenderName)))
                                        {
                                            Log("[ " + DateTime.Now + " ] => [ Invitation accepted from " + SenderName + " ]");
                                        }
                                        else
                                        {
                                            //Log("There is some error !");
                                        }
                                    }
                                }
                                catch (Exception ex)
                                {
                                }
                            }
                        }
                        else
                        {
                            //Log("[ " + DateTime.Now + " ] => [ There is no invitation ! ]");
                            Log("[ " + DateTime.Now + " ] => [ No more invitations left to accept ! ]");
                        }
                    }
                    startRow = startRow + 10;
                } while (newPagesource.Contains("is now a connection."));
                //else
                //{
                //    Log("[ " + DateTime.Now + " ] => [ There is no invitation ! ]");
                //}

                //if (isTrue)
                //{
                //    StartAcceptInvitations(ref httpHelper);
                //}
            }
            catch (Exception ex)
            {
            }
        }
예제 #23
0
        public void StartAcceptInvitations(ref GlobusHttpHelper httpHelper)
        {
            try
            {
                string csrfToken = string.Empty;
                string userFirstName = string.Empty;
                string UserLastName = string.Empty;
                string SenderName = string.Empty;
                string newPagesource = string.Empty;
                bool isTrue = false;
                int startRow = 1;

                string pageSource = httpHelper.getHtmlfromUrl1(new Uri("http://www.linkedin.com/inbox/invitations/pending"));

                var 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);
                    UserLastName = resultForUserDetails.Split(' ')[1].Replace("\"", string.Empty);
                }
                catch { }

                if (pageSource.Contains("csrfToken"))
                {
                    csrfToken = pageSource.Substring(pageSource.IndexOf("csrfToken"), 100);
                    string[] Arr = csrfToken.Split('"');
                    try
                    {
                        foreach (string item in Arr)
                        {
                            try
                            {
                                if (item.Contains("csrfToken="))
                                {
                                    csrfToken = item.Substring(item.IndexOf("csrfToken="), item.IndexOf("&", item.IndexOf("csrfToken=")) - item.IndexOf("csrfToken=")).Replace("csrfToken=", string.Empty).Replace("\"", string.Empty).Replace("\\", string.Empty).Trim();//Arr[2].Replace(@"\", string.Empty).Replace("//", string.Empty);

                                    break;
                                }
                            }
                            catch (Exception ex)
                            {
                            }

                            if (item.Contains("csrfToken="))
                            {
                                csrfToken = item.Replace("csrfToken=", string.Empty).Trim();

                                break;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        //csrfToken = Arr[0].Replace("csrfToken=", "").Replace("\\", "");
                    }
                }

                // For Show More

                //string postData1 = "pkey=inbox-invitations-pending&tcode=%5Bobject%20Arguments%5D&plist=";
                //string response1 = httpHelper.postFormData(new Uri("http://www.linkedin.com/lite/web-action-track?csrfToken="+csrfToken+""),postData1);
                //string pageSource2=httpHelper.getHtmlfromUrl(new Uri("http://www.linkedin.com/inbox/invitations/pending/more?sinceDate=1366351490125&startRow=6&count=20&showBlocked=false&ctx=inbox&rnd=1366353236172"));
                //*** Conver HTML to XML *******************************//
                #region Convert HTML to XML
                ChilkatHttpHelpr objhelper = new ChilkatHttpHelpr();
                //xHtml contain xml data
                string xHtml = objhelper.ConvertHtmlToXml(pageSource);

                Chilkat.Xml xml = new Chilkat.Xml();
                xml.LoadXml(xHtml);
                //xHtml.

                ////  Iterate over all h1 tags:
                Chilkat.Xml xNode = default(Chilkat.Xml);
                Chilkat.Xml xBeginSearchAfter = default(Chilkat.Xml);
                #endregion

                #region Invitatin count
                xBeginSearchAfter = null;
                xNode = xml.SearchForAttribute(xBeginSearchAfter, "span", "class", "invitation-count count ");

                try
                {
                    while ((xNode != null))
                    {
                        string strvalue = xNode.AccumulateTagContent("text", "script|style");
                        string Invitatincount = strvalue;
                        Log("[ " + DateTime.Now + " ] => [ Invitation Count = " + Invitatincount + " UserName = "******" ]");
                        Log("-----------------------------------------------------------------------------------------------------------------------------------");
                        break;
                    }
                }
                catch (Exception ex)
                {

                }

                #endregion

                do
                {
                    newPagesource = httpHelper.getHtmlfromUrl1(new Uri("https://www.linkedin.com/inbox/invitations?keywords=&sortBy=&startRow=" + startRow + "&subFilter=&trk=&showBlocked=false"));
                if (newPagesource.Contains("inbox-list"))
                {
                    string inbox_list = httpHelper.GetDataWithTagValueByTagAndAttributeNameWithClass(newPagesource, "ol", "inbox-list ");

                    if (inbox_list.Contains("<li"))
                    {
                        isTrue = true;
                        string[] srrLi = Regex.Split(inbox_list, "<li");

                        foreach (string item in srrLi)
                        {
                            try
                            {
                                if (item.Contains("data-gid=\""))
                                {
                                    string data_gid = item.Substring(item.IndexOf("data-gid=\"") + 10, item.IndexOf("\"", item.IndexOf("data-gid=\"") + 10) - (item.IndexOf("data-gid=\"") + 10)).Replace("\"", string.Empty).Replace("data-gid=\"", string.Empty).Trim();
                                    int startindex1 = item.IndexOf("alt=");
                                    string start1 = item.Substring(startindex1).Replace("alt=",string.Empty);
                                    int endindex1 = start1.IndexOf("height");
                                    string end1 = start1.Substring(0, endindex1).Replace("\"", string.Empty).Trim();
                                    SenderName = end1;

                                    string response2 = httpHelper.getHtmlfromUrl1(new Uri("http://www.linkedin.com/inbox/action?mboxItemGID=" + data_gid + "&actionType=invitationAccept&csrfToken=" + csrfToken + "&goback=%2Epiv_*1_*1_*1_*1_*1&trk=inbox-invitations-inv-accept&ctx=inbox&rnd=1366352095313"));

                                    if (response2.Contains(" are now connected"))
                                    {
                                        string SuccessMsg = string.Empty;
                                        int startindex = response2.IndexOf("<div class=\"confirmation\">");

                                        if (startindex > 0)
                                        {
                                            try
                                            {
                                                string start = response2.Substring(startindex).Replace("<div class=\"confirmation\">", string.Empty);
                                                int endindex = start.IndexOf("<ul>");
                                                string end = start.Substring(0, endindex);
                                                //SuccessMsg = end.Replace("<h4>", string.Empty).Replace("\"", string.Empty).Replace("</h4>", string.Empty).Replace("\n", string.Empty).Replace("\t", string.Empty).Replace("\"u002", "-").Replace("You", "User: "******"<h4>", string.Empty).Replace("\"", string.Empty).Replace("</h4>", string.Empty).Replace("\n", string.Empty).Replace("\t", string.Empty).Replace("\"u002", "-").Replace("You", "User: "******"( Name:" + userFirstName + "  " + UserLastName + ") ").Trim();

                                            }
                                            catch { }
                                        }

                                        GlobusFileHelper.AppendStringToTextfileNewLine(SuccessMsg, Globals.path_AcceptInvitationEmail);
                                        Log("[ " + DateTime.Now + " ] => [ " + SuccessMsg + " ]");

                                    }
                                    if (!(response2.Contains(SenderName)))
                                    {
                                        Log("[ " + DateTime.Now + " ] => [ Invitation accepted from " + SenderName + " ]");
                                    }
                                    else
                                    {
                                        //Log("There is some error !");
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                            }
                        }

                    }
                    else
                    {
                        //Log("[ " + DateTime.Now + " ] => [ There is no invitation ! ]");
                        Log("[ " + DateTime.Now + " ] => [ No more invitations left to accept ! ]");

                    }
                }
                startRow = startRow + 10;
                } while (newPagesource.Contains("is now a connection."));
                //else
                //{
                //    Log("[ " + DateTime.Now + " ] => [ There is no invitation ! ]");
                //}

                //if (isTrue)
                //{
                //    StartAcceptInvitations(ref httpHelper);
                //}
            }
            catch (Exception ex)
            {
            }
        }
예제 #24
0
        public string PostAddCompanyUsingUrl(ref GlobusHttpHelper HttpHelper, string username, int mindelay, int maxdelay)
        {
            string ReturnString = string.Empty;

            try
            {
                string        IncodePost        = string.Empty;
                string        PostMessage       = string.Empty;
                string        MemFullName       = string.Empty;
                string        SearchId          = string.Empty;
                string        CompanyName       = string.Empty;
                string        IsOpenGrp         = string.Empty;
                string        CompanyType       = string.Empty;
                string        CompanyId         = string.Empty;
                string        goback            = string.Empty;
                List <string> checkDupcompanyId = new List <string>();
                List <string> tempcompanyUrl    = new List <string>();
                CompanyDtl.Clear();

                //----------------------------------------------------------------------------------------------------------------------
                string postdata      = string.Empty;
                string postUrl       = string.Empty;
                string ResLogin      = string.Empty;
                string csrfToken     = string.Empty;
                string sourceAlias   = string.Empty;
                string MessageText   = string.Empty;
                string PostedMessage = string.Empty;

                string pageSource = HttpHelper.getHtmlfromUrl1(new Uri("http://www.linkedin.com/home?trk=hb_tab_home_top"));

                if (pageSource.Contains("csrfToken"))
                {
                    csrfToken = pageSource.Substring(pageSource.IndexOf("csrfToken"), 50);
                    string[] Arr = csrfToken.Split('<');
                    csrfToken = Arr[0];
                    csrfToken = csrfToken.Replace(":", "%3A").Replace("csrfToken", "").Replace("\"", string.Empty).Replace("value", string.Empty).Replace("cs", string.Empty).Replace("id", string.Empty).Replace("=", string.Empty).Replace(">", string.Empty);
                    csrfToken = csrfToken.Replace("\n<script src", "").Trim();
                }

                if (pageSource.Contains("sourceAlias"))
                {
                    sourceAlias = pageSource.Substring(pageSource.IndexOf("sourceAlias"), 100);
                    string[] Arr = sourceAlias.Split('"');
                    sourceAlias = Arr[2];
                }

                //-------------------------------------------------------------------------------------------------------------------------------

                foreach (var CompanywithUrl in lstLinkedinCompanyURL)
                {
                    try
                    {
                        string finalurl = string.Empty;

                        if (!CompanywithUrl.Contains("http"))
                        {
                            finalurl = "http://" + CompanywithUrl;
                        }
                        else
                        {
                            finalurl = CompanywithUrl;;
                        }

                        string pageSource1 = HttpHelper.getHtmlfromUrl1(new Uri(finalurl));

                        string[] RgxCompanyData1 = System.Text.RegularExpressions.Regex.Split(pageSource1, "<h1 class=\"name\"");

                        try
                        {
                            int    startindex = RgxCompanyData1[1].IndexOf("<span itemprop=\"name\">");
                            string start      = RgxCompanyData1[1].Substring(startindex);
                            int    endIndex   = start.IndexOf("</span>");
                            CompanyName = start.Substring(0, endIndex).Replace("<span itemprop=\"name\">", string.Empty).Replace("\n", string.Empty).Replace("\\u002d", "-").Trim();

                            if (CompanyName.Contains("<img src="))
                            {
                                CompanyName = CompanyName.Split('>')[0];
                            }
                        }
                        catch
                        {
                            CompanyName = getBetween(pageSource1, "company_name", "</a>").Replace("\n", "").Replace(">", "").Replace("\"", "").Trim();
                        }

                        try
                        {
                            int    startindex1 = RgxCompanyData1[1].IndexOf("/company/follow/submit?id=");
                            string start1      = RgxCompanyData1[1].Substring(startindex1);
                            int    endIndex1   = start1.IndexOf("&amp");
                            CompanyId = start1.Substring(0, endIndex1).Replace("/company/follow/submit?id=", string.Empty).Replace("&amp;", string.Empty).Trim();

                            //int startindex1 = pageSource1.IndexOf("X-FS-Origin-Request");
                            //string start1 = pageSource1.Substring(startindex1);
                            //int endIndex1 = start1.IndexOf("?");
                            //CompanyId = start1.Substring(0, endIndex1).Replace("X-FS-Origin-Request", string.Empty).Replace("?", string.Empty).Replace("\"", "").Replace("company", "").Replace("/", "").Replace(":", "").Trim();
                        }
                        catch
                        {
                            CompanyId = getBetween(pageSource1, "submit?id=", "&amp;").Replace("\n", "").Replace(">", "").Replace("\"", "").Trim();
                        }

                        try
                        { int    startindex1 = pageSource1.IndexOf("goback=");
                          string start1      = pageSource1.Substring(startindex1);
                          int    endIndex1   = start1.IndexOf("&");
                          goback = start1.Substring(0, endIndex1).Replace("goback=", string.Empty); }
                        catch { }


                        string txid = (UnixTimestampFromDateTime(System.DateTime.Now) * 1000).ToString();

                        //postUrl = "https://www.linkedin.com/uas/login-submit";
                        //postdata = "session_key=" + username + "&session_password="******"&source_app=&trk=guest_home_login&session_redirect=&csrfToken=" + csrfToken + "&sourceAlias=" + sourceAlias;
                        //ResLogin = HttpHelper.postFormData(new Uri(postUrl), postdata);

                        try
                        {
                            //string GoBack = "%2Ebzo_*1_*1_*1_*1_*1_*1_*1_" + CompanyId;
                            Log("[ " + DateTime.Now + " ] => [ ID: " + username + " has Follow the Company: " + CompanyName.ToString() + " ]");
                            //string pageGetreq = HttpHelper.getHtmlfromUrl1(new Uri("http://www.linkedin.com/company/follow/submit?id=" + CompanyId + "&fl=start&version=2&ft=pageKey%3Dbiz-overview-internal%3Bmodule%3Dbutton&sp=biz-overview&csrfToken=" + csrfToken + "&goback=" + GoBack));
                            string pageGetreq = HttpHelper.getHtmlfromUrl1(new Uri("http://www.linkedin.com/company/follow/submit?id=" + CompanyId + "&fl=start&version=2&ft=pageKey%3Dbiz-overview%3Bmodule%3Dbutton&sp=biz-overview&csrfToken=" + csrfToken + "&goback=" + goback + "&ajax=&rnd=" + txid));

                            if (pageGetreq.Contains("Following"))
                            {
                                ReturnString = "Your request to Follow the: " + CompanyName.ToString() + " company has been Successfully Followed.";
                                Log("[ " + DateTime.Now + " ] => [ " + ReturnString + " ]");

                                #region Data Saved In CSV File

                                if (!string.IsNullOrEmpty(CompanywithUrl) || !string.IsNullOrEmpty(CompanyName))
                                {
                                    try
                                    {
                                        string CSVHeader   = "Companyurl" + "," + "CompanyName" + "," + "LoginID";
                                        string CSV_Content = CompanywithUrl.Replace(",", ";") + "," + CompanyName.Replace(",", ";") + "," + username;
                                        CSVUtilities.ExportDataCSVFile(CSVHeader, CSV_Content, Globals.path_LinkedinFollowCompanyUsingUrl);
                                        Log("[ " + DateTime.Now + " ] => [ Company Name: " + CompanyName.Replace(",", ";") + " in Account : " + username.Replace(",", ";") + " ]");
                                        Log("[ " + DateTime.Now + " ] => [ Data Saved In CSV File ! ]");

                                        tempcompanyUrl.Add(CompanywithUrl);
                                    }
                                    catch { }
                                }
                                #endregion
                            }
                            else if (pageGetreq.Contains("Error"))
                            {
                                Log("[ " + DateTime.Now + " ] => [ Error In Follow Company ]");
                                GlobusFileHelper.AppendStringToTextfileNewLine(username + ":" + "Error In Follow Company", Globals.path_Not_FollowCompany);
                            }
                            else
                            {
                                Log("[ " + DateTime.Now + " ] => [ Company Could Not Be Followed ]");
                                GlobusFileHelper.AppendStringToTextfileNewLine(username + ":" + "Company Could Not Be Followed", Globals.path_Not_FollowCompany);
                            }
                        }
                        catch { }


                        if (checkDupcompanyId.Count != 0)
                        {
                            if (checkDupcompanyId.Contains(CompanyId))
                            {
                            }
                            else
                            {
                                checkDupcompanyId.Add(CompanyId);
                                CompanyDtl.Add(CompanyName, CompanyId);
                                Log("[ " + DateTime.Now + " ] => [ Founded Company Name : " + CompanyName + " ]");
                            }
                        }
                        else
                        {
                            CompanyDtl.Add(CompanyName, CompanyId);
                        }
                    }
                    catch { }

                    if (tempcompanyUrl.Count() == CountPerAccount)
                    {
                        break;
                    }

                    int delay = RandomNumberGenerator.GenerateRandom(mindelay, maxdelay);
                    Log("[ " + DateTime.Now + " ] => [ Delay for : " + delay + " Seconds ]");
                    Thread.Sleep(delay * 1000);
                }
            }
            catch (Exception ex)
            {
                GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error --> Search Company for follow --> PostAddCompanyUsingUrl() >>>> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace, Globals.Path_LinkedinErrorLogs);
                GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error --> Search Company for follow --> PostAddCompanyUsingUrl() >>>> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace, Globals.Path_LinkedinFollowCompanyErrorLogs);
                return(ReturnString);
            }
            return(ReturnString);
        }
예제 #25
0
        public Dictionary <string, string> PostAddOpenGroupsUsingUrl(ref GlobusHttpHelper HttpHelper, string username, int mindelay, int maxdelay, List <string> lstLinkedinGroupURL, bool IsDevideData)
        {
            try
            {
                string postdata    = string.Empty;
                string postUrl     = string.Empty;
                string ResLogin    = string.Empty;
                string csrfToken   = string.Empty;
                string sourceAlias = string.Empty;

                string        ReturnString  = string.Empty;
                string        GroupName     = string.Empty;
                string        IncodePost    = string.Empty;
                string        PostMessage   = string.Empty;
                string        MemFullName   = string.Empty;
                string        SearchId      = string.Empty;
                string        GrpName       = string.Empty;
                string        IsOpenGrp     = string.Empty;
                string        GrpType       = string.Empty;
                string        GrpId         = string.Empty;
                List <string> checkDupGrpId = new List <string>();
                OpenGroupDtl.Clear();
                List <string> tempGrpUrl = new List <string>();

                //-----------------------------------------------------------------------------------------------------------------------------------------
                string MessageText   = string.Empty;
                string PostedMessage = string.Empty;

                string pageSource = HttpHelper.getHtmlfromUrl1(new Uri("http://www.linkedin.com/home?trk=hb_tab_home_top"));
                if (pageSource.Contains("csrfToken"))
                {
                    csrfToken = pageSource.Substring(pageSource.IndexOf("csrfToken"), 50);
                    //string[] Arr = csrfToken.Split('&');
                    string[] Arr = csrfToken.Split('>');
                    csrfToken = Arr[0];
                    csrfToken = csrfToken.Replace(":", "%3A").Replace("csrfToken", "").Replace("\"", string.Empty).Replace("value", string.Empty).Replace("cs", string.Empty).Replace("id", string.Empty).Replace("=", string.Empty).Replace(">", string.Empty);
                    csrfToken = csrfToken.Trim();
                }

                if (pageSource.Contains("sourceAlias"))
                {
                    sourceAlias = pageSource.Substring(pageSource.IndexOf("sourceAlias"), 100);
                    string[] Arr = sourceAlias.Split('"');
                    sourceAlias = Arr[2];
                }
                //-----------------------------------------------------------------------------------------------------------------------------------------

                foreach (var GrpswithUrl in lstLinkedinGroupURL)
                {
                    try
                    {
                        string   pageSource1   = HttpHelper.getHtmlfromUrl1(new Uri(GrpswithUrl));
                        string[] RgxGroupData1 = System.Text.RegularExpressions.Regex.Split(pageSource1, "<h1 class=\"group-name public\">");

                        if (RgxGroupData1.Count() == 1)
                        {
                            RgxGroupData1 = System.Text.RegularExpressions.Regex.Split(pageSource1, "<h1 class=\"group-name private\">");
                        }

                        try
                        {
                            int    startindex = RgxGroupData1[1].IndexOf("title=");
                            string start      = RgxGroupData1[1].Substring(startindex);
                            int    endIndex   = start.IndexOf("</a>");
                            GrpName = start.Substring(0, endIndex).Replace("\"", string.Empty).Replace("title=", string.Empty).Replace("This group is members only", string.Empty).Replace("This is an open group", string.Empty).Replace(">", string.Empty).Replace(",", string.Empty).Replace(":", string.Empty).Replace("<B>", string.Empty).Replace("</B>", string.Empty).Replace("\\u002d", "-").Trim();

                            if (GrpName.Contains("<img src="))
                            {
                                GrpName = GrpName.Split('>')[0];
                            }
                        }
                        catch { }

                        try
                        {
                            if (RgxGroupData1[1].Contains("This group is members only"))
                            {
                                GrpType = "Member Only Group";
                            }
                            else
                            {
                                GrpType = "Open Group";
                            }
                        }
                        catch { }

                        if (GrpName == "group" || GrpName == "_postGroupLink" || GrpName == "_viewGroupLink" || GrpName == "_similarGroupLink" || GrpName == "_searchWithinLink" || GrpName == "_joinGroupLink" || GrpName == "N" || GrpName == "Remove All")
                        {
                            continue;
                        }

                        try
                        {
                            int    startindex1 = RgxGroupData1[1].IndexOf("gid=");
                            string start1      = RgxGroupData1[1].Substring(startindex1);
                            int    endIndex1   = start1.IndexOf("trk=");
                            GrpId = start1.Substring(0, endIndex1).Replace("gid=", string.Empty).Replace("&amp;", string.Empty).Trim();
                        }
                        catch { }

                        //post_url = string.Empty;
                        //post_url = (GroupValue.Key + ":" + GroupValue.Value);

                        try
                        {
                            string GoBack = "/%2Eanb_" + GrpId;
                            LogGroupUrl("[ " + DateTime.Now + " ] => [ ID: " + username + " has Joining the Group: " + GrpName + " ]");
                            string pageGetreq = HttpHelper.getHtmlfromUrl1(new Uri("http://www.linkedin.com/groupRegistration?gid=" + GrpId + "&csrfToken=" + csrfToken + "&trk=group-join-button"));


                            if (pageGetreq.Contains("Your request to join the"))
                            {
                                ReturnString = "Your request to join the: " + GrpName + " group has been received.";
                                LogGroupUrl("[ " + DateTime.Now + " ] => [ " + ReturnString + " ]");
                                GlobusFileHelper.AppendStringToTextfileNewLine(username + ":" + ReturnString, Globals.path_JoinSearchGroupSuccess);

                                #region Data Saved In CSV File

                                if (!string.IsNullOrEmpty(GrpswithUrl) || !string.IsNullOrEmpty(GrpName))
                                {
                                    try
                                    {
                                        string CSVHeader   = "Grpurl" + "," + "GrpName" + "," + "ID";
                                        string CSV_Content = GrpswithUrl + "," + GrpName + "," + username;
                                        CSVUtilities.ExportDataCSVFile(CSVHeader, CSV_Content, Globals.path_LinkedinJoinGroupUsingUrl);
                                        Log("[ " + DateTime.Now + " ] => [ GroupName: " + GrpName + " ]");
                                        Log("[ " + DateTime.Now + " ] => [ Data Saved In CSV File ! ]");
                                        LogGroupUrl("[ " + DateTime.Now + " ] => [ GroupName: " + GrpName + " ]");
                                        LogGroupUrl("[ " + DateTime.Now + " ] => [ Data Saved In CSV File ! ]");
                                        Log(GrpswithUrl + " " + username);
                                        tempGrpUrl.Add(GrpswithUrl);
                                    }
                                    catch { }
                                }
                                #endregion
                            }
                            else if (pageGetreq.Contains("Welcome to the"))
                            {
                                ReturnString = "Welcome to the: " + GrpName + " group on LinkedIn.";
                                LogGroupUrl("[ " + DateTime.Now + " ] => [ " + ReturnString + " ]");
                                GlobusFileHelper.AppendStringToTextfileNewLine(username + ":" + ReturnString, Globals.path_JoinSearchGroupSuccess);

                                #region Data Saved In CSV File

                                if (!string.IsNullOrEmpty(GrpswithUrl) || !string.IsNullOrEmpty(GrpName))
                                {
                                    try
                                    {
                                        string CSVHeader   = "Grpurl" + "," + "GrpName" + "," + "ID";
                                        string CSV_Content = GrpswithUrl + "," + GrpName + "," + username;
                                        CSVUtilities.ExportDataCSVFile(CSVHeader, CSV_Content, Globals.path_LinkedinJoinGroupUsingUrl);
                                        Log("[ " + DateTime.Now + " ] => [ GroupName: " + GrpName + " ]");
                                        Log("[ " + DateTime.Now + " ] => [ Data Saved In CSV File ! ]");
                                        LogGroupUrl("[ " + DateTime.Now + " ] => [ GroupName: " + GrpName + " ]");
                                        LogGroupUrl("[ " + DateTime.Now + " ] => [ Data Saved In CSV File ! ]");

                                        tempGrpUrl.Add(GrpswithUrl);
                                    }
                                    catch { }
                                }
                                #endregion
                            }
                            else if (pageGetreq.Contains("You're already a member of the"))
                            {
                                ReturnString = "You're already a member of the: " + GrpName + "";
                                LogGroupUrl("[ " + DateTime.Now + " ] => [ " + ReturnString + " ]");
                                GlobusFileHelper.AppendStringToTextfileNewLine(username + ":" + ReturnString, Globals.path_JoinSearchGroupSuccess);
                            }
                            else if (pageGetreq.Contains("Your settings have been updated"))
                            {
                                ReturnString = "Your request to join the: " + GrpName + " group has been received.";
                                LogGroupUrl("[ " + DateTime.Now + " ] => [ " + ReturnString + " ]");
                                GlobusFileHelper.AppendStringToTextfileNewLine(username + ":" + ReturnString, Globals.path_JoinSearchGroupSuccess);
                            }
                            else if (pageGetreq.Contains("We’re sorry, this group has reached its maximum number of members allowed. If you have any questions, please contact the group manager for more information"))
                            {
                                LogGroupUrl("[ " + DateTime.Now + " ] => [ We’re sorry, this group has reached its maximum number of members allowed. ]");
                                GlobusFileHelper.AppendStringToTextfileNewLine(username + ":" + "We’re sorry, this group has reached its maximum number of members allowed.", Globals.path_JoinSearchGroupSuccess);
                            }
                            else if (pageGetreq.Contains("reached or exceeded the maximum number of pending group applications."))
                            {
                                LogGroupUrl("[ " + DateTime.Now + " ] => [ We’re sorry...You’ve reached or exceeded the maximum number of pending group applications. Please wait for your pending requests to be approved by a group manager or withdraw pending requests before joining new groups. ]");
                                GlobusFileHelper.AppendStringToTextfileNewLine(username + ":" + "We’re sorry...You’ve reached or exceeded the maximum number of pending group applications. Please wait for your pending requests to be approved by a group manager or withdraw pending requests before joining new groups. ", Globals.path_JoinSearchGroupSuccess);
                                //break;
                            }
                            else if (pageGetreq.Contains("reached or exceeded the maximum number of confirmed and pending groups."))
                            {
                                ReturnString = "You’ve reached or exceeded the maximum number of confirmed and pending groups.";
                                LogGroupUrl("[ " + DateTime.Now + " ] => [ You’ve reached or exceeded the maximum number of confirmed and pending groups.]");
                                GlobusFileHelper.AppendStringToTextfileNewLine(username + ":" + ReturnString, Globals.path_JoinSearchGroupSuccess);
                                //break;
                            }
                            else if (pageGetreq.Contains("Error"))
                            {
                                LogGroupUrl("[ " + DateTime.Now + " ] => [ Error In Joining Group ]");
                                GlobusFileHelper.AppendStringToTextfileNewLine(username + ":" + "Error In Joining Group", Globals.path_JoinSearchGroupSuccess);
                            }
                            else
                            {
                                LogGroupUrl("[ " + DateTime.Now + " ] => [ Group Could Not Be Joined ]");
                                GlobusFileHelper.AppendStringToTextfileNewLine(username + ":" + "Group Could Not Be Joined", Globals.path_JoinSearchGroupSuccess);
                                //LogGroupUrl(username + "   " + GrpswithUrl);
                            }
                        }
                        catch { }

                        if (checkDupGrpId.Count != 0)
                        {
                            if (checkDupGrpId.Contains(GrpId))
                            {
                            }
                            else
                            {
                                checkDupGrpId.Add(GrpId);
                                OpenGroupDtl.Add(GrpName + " (" + GrpType + ")", GrpId);
                                Log("[ " + DateTime.Now + " ] => [ Founded Group Name : " + GrpName + " ]");
                                LogGroupUrl("[ " + DateTime.Now + " ] => [ Founded Group Name : " + GrpName + " ]");
                            }
                        }
                        else
                        {
                            OpenGroupDtl.Add(GrpName + " (" + GrpType + ")", GrpId);
                        }
                    }
                    catch { }
                    if (!IsDevideData)
                    {
                        if (tempGrpUrl.Count() == CountPerAccount)
                        {
                            break;
                        }
                    }

                    int delay = RandomNumberGenerator.GenerateRandom(mindelay, maxdelay);
                    LogGroupUrl("[ " + DateTime.Now + " ] => [ Delay for : " + delay + " Seconds ]");
                    Thread.Sleep(delay * 1000);
                }

                //foreach (var Removable in tempGrpUrl)
                //{
                //    lstLinkedinGroupURL.Remove(Removable);
                //}

                return(OpenGroupDtl);
            }
            catch (Exception ex)
            {
                GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error --> Add Search Groups --> PostAddOpenGroups() >>>> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace, Globals.Path_LinkedinErrorLogs);
                GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error --> Add Search Groups --> PostAddOpenGroups() >>>> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace, Globals.Path_LinkedinAddSearchGroupErrorLogs);
                return(OpenGroupDtl);
            }
        }