예제 #1
0
        public void EndorsingPeople(ref GlobusHttpHelper HttpHelper, string UserId)
        {
            try
            {
                int count     = 0;
                int ProxyPort = 0;
                if (!string.IsNullOrEmpty(proxyPort) && NumberHelper.ValidateNumber(proxyPort))
                {
                    ProxyPort = Convert.ToInt32(proxyPort);
                }

                string EndorseLink       = string.Empty;
                string modelNo           = string.Empty;
                string csrfToken         = string.Empty;
                string postdata          = string.Empty;
                string _ed               = string.Empty;
                string endorseUrl        = string.Empty;
                string Link              = string.Empty;
                string LinkSource        = string.Empty;
                string PageSourceProfile = string.Empty;

                try
                {
                    Globals.tempDict.Add(UserId, "");
                    Log("[ " + DateTime.Now + " ] => [ Starting Getting Member Details For User Id Link - :" + UserId + " With : " + Username + " ]");
                }
                catch
                {
                }


                if (!UserId.Contains("http"))
                {
                    Link = "http://www.linkedin.com/people/conn-details?i=&contactMemberID=" + UserId;

                    PageSourceProfile = HttpHelper.getHtmlfromUrlProxy(new Uri(Link), proxyAddress, 0, proxyUsername, proxyPassword);

                    try
                    {
                        int startindex = PageSourceProfile.IndexOf("/profile/view?id=");
                        if (startindex > 0)
                        {
                            string start    = PageSourceProfile.Substring(startindex);
                            int    endIndex = start.IndexOf("\">");
                            string end      = start.Substring(0, endIndex).Replace("\\", "").Replace("&", "&");

                            if (end.Contains("&trk"))
                            {
                                end = end.Split('&')[0].ToString();
                            }

                            LinkSource = "http://www.linkedin.com" + end;
                        }
                    }
                    catch (Exception ex)
                    {
                        GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error -->EndorsingPeople() --> LinkSource >>>> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace, Globals.Path_LinkedinErrorLogs);
                        GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error --> EndorsingPeople() --> LinkSource >>>> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace, Globals.path_EndorsePeople);
                    }

                    if (string.IsNullOrEmpty(UserId))
                    {
                        try
                        {
                            Globals.tempDict.Add(UserId, "");
                            Log("[ " + DateTime.Now + " ] => [ Cannot Find Data For Userid : " + UserId + " From " + Username + " ]");
                            return;
                        }
                        catch
                        { }
                    }

                    PageSourceProfile = HttpHelper.getHtmlfromUrlProxy(new Uri(LinkSource), proxyAddress, 0, proxyUsername, proxyPassword);
                }
                else
                {
                    Link = UserId;

                    PageSourceProfile = HttpHelper.getHtmlfromUrlProxy(new Uri(Link), proxyAddress, 0, proxyUsername, proxyPassword);
                }



                if (PageSourceProfile.Contains("csrfToken"))
                {
                    csrfToken = PageSourceProfile.Substring(PageSourceProfile.IndexOf("csrfToken"), 100);
                    string[] Arr = csrfToken.Split('&');

                    try
                    {
                        csrfToken = Arr[0].Replace("csrfToken=", "").Replace("\\", "");
                        csrfToken = csrfToken.Split('>')[0].Replace(">", string.Empty).Replace("\"", string.Empty);
                    }
                    catch (Exception ex)
                    {
                        csrfToken = Arr[0].Replace("csrfToken=", "").Replace("\\", "");
                    }
                    //csrfToken
                    if (csrfToken.Contains("updateTagsUrl"))
                    {
                        csrfToken = csrfToken.Split(',')[0].ToString();
                    }
                }


                Dictionary <string, string> lstskilldata = new Dictionary <string, string>();
                if (PageSourceProfile.Contains("/profile/unendorse?_ed="))
                {
                    _ed = Utils.getBetween(PageSourceProfile, "/profile/unendorse?_ed=", "&");
                }
                if (PageSourceProfile.Contains("endorseURL:"))
                {
                    endorseUrl = Utils.getBetween(PageSourceProfile, "endorseURL:", ",").Replace("\\", "").Replace("'", "").Trim();
                    endorseUrl = "https://www.linkedin.com" + endorseUrl;
                }

                try
                {
                    string[] arr = Regex.Split(PageSourceProfile, "fmt__skill_name\":");
                    arr = arr.Skip(1).ToArray();
                    foreach (string item in arr)
                    {
                        string SkillName = string.Empty;
                        string SkillId   = string.Empty;
                        if (!item.Contains("viewerEndorsementId\":"))
                        {
                            if (item.Contains("id\":"))
                            {
                                SkillName = Utils.getBetween(item, "", ",").Replace("\\u002d", "-").Replace("\"", "").Replace(",", "").Replace("&amp;", "&").Replace("}", "").Trim();
                                //SkillId = Utils.getBetween(item, "id\":", ",").Replace("\"", "").Replace(",", "").Replace("&amp;", "&").Replace("}", "").Replace("\u002d", "-").Trim();
                                lstskilldata.Add(SkillName, SkillName);
                            }
                        }
                    }
                    if (lstskilldata.Count == 0)
                    {
                        arr = Regex.Split(PageSourceProfile, "data-endorsed-item-name=\"");
                        arr = arr.Skip(1).ToArray();

                        foreach (string item in arr)
                        {
                            if (EndorsePeople.no_of_Skils == lstskilldata.Count)
                            {
                                if (EndorsePeople.no_of_Skils == 0 && lstskilldata.Count == 0)
                                {
                                }
                                else
                                {
                                    break;
                                }
                            }
                            string SkillName = string.Empty;
                            string SkillId   = string.Empty;
                            if (!item.Contains("endorse-item has-endorsements endorsed-by-viewer"))
                            {
                                //if (item.Contains("id\":"))
                                {
                                    SkillName = Utils.getBetween(item, "", "\"").Replace("\\u002d", "-").Replace("\"", "").Replace(",", "").Replace("&amp;", "&").Replace("}", "").Trim();
                                    //SkillId = Utils.getBetween(item, "id\":", ",").Replace("\"", "").Replace(",", "").Replace("&amp;", "&").Replace("}", "").Replace("\u002d", "-").Trim();
                                    lstskilldata.Add(SkillName, SkillName);
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error -->EndorsingPeople() --> lstskilldata Data  >>>> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace, Globals.Path_LinkedinErrorLogs);
                    GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error --> EndorsingPeople() --> lstskilldata Data >>>> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace, Globals.path_EndorsePeople);
                }

                try
                {
                    string _UserId = string.Empty;

                    if (lstskilldata.Count > 0)
                    {
                        foreach (KeyValuePair <string, string> item in lstskilldata)
                        {
                            if (count > 4)
                            {
                                return;
                            }
                            if (!UserId.Contains("http"))
                            {
                                _UserId = UserId;
                            }
                            else
                            {
                                _UserId = Utils.getBetween(UserId + "@", "&id=", "@");
                                if (string.IsNullOrEmpty(_UserId))
                                {
                                    _UserId = Utils.getBetween(UserId + "@", "?id=", "@");
                                }
                                //_UserId = UserId.Substring(UserId.IndexOf("&id=")).Replace("&id=", string.Empty);
                            }

                            postdata = "endorsementCount=1&recipientId-0=" + _UserId + "&recipientType-0=member&endorsedItemName-0=" + Uri.EscapeDataString(item.Key) + "&endorsementId-0=&endorserIds-0=";
                            string PostUrl = "http://www.linkedin.com/profile/endorse?csrfToken=" + csrfToken + "&_ed=" + _ed + "&goback=%2Enpv_" + UserId + "_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_contacts*5contacts*5list*5contact*4name*50_*1";

                            string PostPageSource = HttpHelper.postFormDataRef(new Uri(endorseUrl), postdata, LinkSource, "", "", "", "", "1");

                            if (!PostPageSource.Contains("fail") || !PostPageSource.Contains("failure"))
                            {
                                string[] ArrayPostedData = System.Text.RegularExpressions.Regex.Split(PostPageSource, "}");
                                //ArrayPostedData = ArrayPostedData.Skip(1).ToArray();
                                foreach (string itemdata in ArrayPostedData)
                                {
                                    foreach (KeyValuePair <string, string> item1 in lstskilldata)
                                    {
                                        if (itemdata.Contains(item1.Key))
                                        {
                                            string status = string.Empty;
                                            try
                                            {
                                                //int startindex = itemdata.IndexOf("endorsementStatus\":\"");
                                                int startindex = PostPageSource.IndexOf("status");
                                                if (startindex >= 0)
                                                {
                                                    //string start = itemdata.Substring(startindex).Replace("endorsementStatus\":\"", "");
                                                    //int endIndex = start.IndexOf("\",\"");
                                                    //string end = start.Substring(0, endIndex).Replace("&amp;", "&");
                                                    //status = end;

                                                    string start    = PostPageSource.Substring(startindex).Replace("status", "");
                                                    int    endIndex = start.IndexOf("}");
                                                    string end      = start.Substring(0, endIndex).Replace("\"", string.Empty).Replace(":", string.Empty);
                                                    status = end;

                                                    string CSVHeader   = "UserID" + "," + "Skill" + "," + "Status" + "," + "EndorseID"; //New Addedd
                                                    string CSV_Content = Username + "," + item1.Key + "," + status + "," + UserId;      //new adde
                                                    CSVUtilities.ExportDataCSVFile(CSVHeader, CSV_Content, Globals.path_EndorsedPeopleText);
                                                    Log("[ " + DateTime.Now + " ] => [ Status For Skill : " + item1.Key + " ==> " + status + " ]");
                                                }
                                            }
                                            catch (Exception ex)
                                            {
                                                GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error -->EndorsingPeople() --> PostPageSource posted correct >>>> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace, Globals.Path_LinkedinErrorLogs);
                                                GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error --> EndorsingPeople() --> PostPageSource posted correct >>>> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace, Globals.path_EndorsePeople);
                                            }
                                        }
                                    }
                                }
                            }
                            else
                            {
                                string CSVHeader   = "UserID" + "," + "Status" + "," + "EndorseID";
                                string CSV_Content = Username + "," + "Failure" + "," + UserId;
                                CSVUtilities.ExportDataCSVFile(CSVHeader, CSV_Content, Globals.path_NotEndorsedPeopleText);
                                GlobusFileHelper.AppendStringToTextfileNewLine(Username + ",Failure", Globals.path_NotEndorsedPeopleText);
                                Log("[ " + DateTime.Now + " ] => [ Failure for User id : " + item.Key + " -> " + _UserId + " ]");
                            }
                            count++;
                        }
                    }
                    else
                    {
                        Log("[ " + DateTime.Now + " ] => [ No skills found for User id " + _UserId + " ]");
                    }
                }
                catch (Exception ex)
                {
                    GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error -->EndorsingPeople() --> postdata  >>>> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace, Globals.Path_LinkedinErrorLogs);
                    GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error --> EndorsingPeople() --> postdata >>>> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace, Globals.path_EndorsePeople);
                }
            }
            catch (Exception ex)
            {
                GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error --> EndorsingPeople() --> Full Data >>>> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace, Globals.Path_LinkedinErrorLogs);
                GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error --> EndorsingPeople() --> Full Data >>>> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace, Globals.path_EndorsePeople);
            }
        }
예제 #2
0
        public void InviteFriendThroughEmail(int NoofemailRequest, int MaxDelay, int MinDelay)
        {
            try
            {
                int   proxyport = 888;
                Regex PortCheck = new Regex("^[0-9]*$");

                if (PortCheck.IsMatch(_ProxyPort) && !string.IsNullOrEmpty(_ProxyPort))
                {
                    proxyport = int.Parse(_ProxyPort);
                }

                string xMESSAGE = string.Empty;
                LoggerManageConnection("[ " + DateTime.Now + " ] => [ Logging In With Account : " + _UserName + " ]");

                if (linkedinLoginAndLogout.LoginHttpHelper(_UserName, _Password, _ProxyAddress, _ProxyPort, _ProxyUserName, _ProxyPassword, ref HttpHelper, ref xMESSAGE))
                {
                    LoggerManageConnection("[ " + DateTime.Now + " ] => [ Logged in with " + _UserName + " ]");
                    //int CounterInvite = 1;

                    if (UniqueEmailStatus == "False")
                    {
                        DataSet ds_bList = new DataSet();
                        foreach (string Email in _lstInviteEmails)
                        {
                            string emailtosend = string.Empty;

                            try
                            {
                                string Querystring = "Select UserID From tb_BlackListAccount Where UserID ='" + Email + "'";
                                ds_bList = DataBaseHandler.SelectQuery(Querystring, "tb_BlackListAccount");
                            }
                            catch { }

                            if (ds_bList.Tables.Count > 0)
                            {
                                if (ds_bList.Tables[0].Rows.Count > 0)
                                {
                                    LoggerManageConnection("[ " + DateTime.Now + " ] => [ User: "******" is Added BalckListed List For Send Connection Pls Check ]");
                                    return;
                                }
                            }
                            else
                            {
                                if (Email.Contains(":"))
                                {
                                    emailtosend = Email.Split(':')[0];
                                }
                                else
                                {
                                    emailtosend = Email;
                                }

                                try
                                {
                                    LoggerManageConnection("[ " + DateTime.Now + " ] => [ Sending Invitation To :" + emailtosend + " ]");

                                    string emailAddresses     = string.Empty;
                                    string csrfToken          = string.Empty;
                                    string sourceAlias        = string.Empty;
                                    string PostData           = string.Empty;
                                    string PgSrcInviteMessgae = string.Empty;
                                    string postUrl            = string.Empty;

                                    // https://www.linkedin.com/fetch/manual-invite-create

                                    PgSrcInviteMessgae = HttpHelper.getHtmlfromUrlProxy(new Uri("https://www.linkedin.com/fetch/importAndInviteEntry"), _ProxyAddress, proxyport, _ProxyUserName, _ProxyPassword);
                                    emailAddresses     = emailtosend;

                                    // For csrfToken
                                    string[] ArrCsrfToken = Regex.Split(PgSrcInviteMessgae, "input");
                                    foreach (string item in ArrCsrfToken)
                                    {
                                        try
                                        {
                                            if (!item.Contains("<!DOCTYPE"))
                                            {
                                                if (item.Contains("csrfToken") && item.Contains("value="))
                                                {
                                                    csrfToken = item;
                                                    break;
                                                }
                                            }
                                        }
                                        catch (Exception ex)
                                        {
                                        }
                                    }
                                    if (csrfToken.Contains("csrfToken"))
                                    {
                                        try
                                        {
                                            csrfToken = csrfToken.Substring(csrfToken.IndexOf("csrfToken"), 44);
                                            string[] Arr = csrfToken.Split('&');
                                            csrfToken = Arr[0].Replace("csrfToken=", string.Empty);
                                            csrfToken = csrfToken.Replace(":", "%3A").Replace("\\", string.Empty).Replace("csrfToken", "").Replace("=", "").Replace("value", "").Replace("\"", "").Trim();
                                        }
                                        catch (Exception ex)
                                        {
                                        }
                                    }

                                    // For sourceAlias
                                    if (PgSrcInviteMessgae.Contains("sourceAlias"))
                                    {
                                        try
                                        {
                                            sourceAlias = PgSrcInviteMessgae.Substring(PgSrcInviteMessgae.IndexOf("sourceAlias"), 100);
                                            string[] Arr = sourceAlias.Split('"');
                                            sourceAlias = Arr[2].Replace("\\", string.Empty).Trim();
                                        }
                                        catch (Exception ex)
                                        {
                                        }
                                    }

                                    //Post Data for Invite Message
                                    PostData = "emailAddresses=" + Uri.EscapeDataString(emailAddresses) + "&subject=Invitation+to+connect+on+LinkedIn&csrfToken=" + csrfToken + "&sourceAlias=" + sourceAlias;
                                    //Post Url for Invite Message

                                    postUrl = "https://www.linkedin.com/fetch/manual-invite-create";

                                    string postResponse = HttpHelper.postFormDataRef(new Uri(postUrl), PostData, "https://www.linkedin.com/fetch/manual-invite-create", "", "", "", "", "");

                                    if (postResponse.Contains("Your invitation has been sent.") && postResponse.Contains("alert success"))
                                    {
                                        LoggerManageConnection("[ " + DateTime.Now + " ] => [ Invitation sent to :" + emailtosend + " from ID : " + _UserName + " ]");
                                        GlobusFileHelper.AppendStringToTextfileNewLine(_UserName + "-->" + emailtosend, Globals.path_AddConnectionEmail);
                                    }
                                    else if (!postResponse.Contains("Your invitation has been sent.") && !postResponse.Contains("alert success"))
                                    {
                                        int Delay = RandomNumberGenerator.GenerateRandom(MinimumDelay, MaximumDelay);
                                        Thread.Sleep(Delay * 1000);
                                        postResponse = HttpHelper.postFormDataRef(new Uri(postUrl), PostData, "https://www.linkedin.com/fetch/manual-invite-create", "", "", "", "", "");
                                        if (postResponse.Contains("Your invitation has been sent.") && postResponse.Contains("alert success"))
                                        {
                                            LoggerManageConnection("[ " + DateTime.Now + " ] => [ Invitation sent to :" + emailtosend + " from ID : " + _UserName + " ]");
                                            GlobusFileHelper.AppendStringToTextfileNewLine(_UserName + "-->" + emailtosend, Globals.path_AddConnectionEmail);
                                        }
                                        else
                                        {
                                            LoggerManageConnection("[ " + DateTime.Now + " ] => [ Invitation sent to :" + emailtosend + " from ID : " + _UserName + " ]");
                                            GlobusFileHelper.AppendStringToTextfileNewLine(_UserName + "-->" + emailtosend, Globals.path_AddConnectionEmail);
                                            //LoggerManageConnection("[ " + DateTime.Now + " ] => [ Some Problem for sending Invitation :" + emailtosend + " from ID : " + _UserName + " ]");
                                            //GlobusFileHelper.AppendStringToTextfileNewLine(_UserName + "-->" + emailtosend, Globals.path_NonAddConnectionEmail);
                                        }
                                    }
                                    else
                                    {
                                        LoggerManageConnection("[ " + DateTime.Now + " ] => [ Invitation sent to :" + emailtosend + " from ID : " + _UserName + " ]");
                                        GlobusFileHelper.AppendStringToTextfileNewLine(_UserName + "-->" + emailtosend, Globals.path_AddConnectionEmail);
                                        //LoggerManageConnection("[ " + DateTime.Now + " ] => [ Some Problem for sending Invitation :" + emailtosend + " from ID : " + _UserName + " ]");
                                        //GlobusFileHelper.AppendStringToTextfileNewLine(_UserName + "-->" + emailtosend, Globals.path_NonAddConnectionEmail);
                                    }

                                    MinimumDelay = MinDelay;
                                    MaximumDelay = MaxDelay;

                                    int Delay1 = RandomNumberGenerator.GenerateRandom(MinimumDelay, MaximumDelay);
                                    LoggerManageConnection("[ " + DateTime.Now + " ] => [ Delay For : " + Delay1 + " Seconds ]");
                                    Thread.Sleep(Delay1 * 1000);
                                }
                                catch (Exception ex)
                                {
                                }
                            }
                        }
                    }
                    else
                    {
                        int counter = 0;

                        while (UsingEmailQueue.Count > 0)
                        {
                            string emailtosend = string.Empty;

                            lock (locker_InvitataionEmail)
                            {
                                if (UsingEmailQueue.Count > 0)
                                {
                                    emailtosend = UsingEmailQueue.Dequeue();
                                    if (listItemTempForInvitation.Contains(emailtosend))
                                    {
                                        continue;
                                    }
                                }

                                else
                                {
                                    LoggerManageConnection("[ " + DateTime.Now + " ] => [ All Loaded Email are used ]");
                                }

                                try
                                {
                                    LoggerManageConnection("[ " + DateTime.Now + " ] => [ Sending Invitation To :" + emailtosend + " from ID : " + _UserName + " ]");

                                    string emailAddresses     = string.Empty;
                                    string csrfToken          = string.Empty;
                                    string sourceAlias        = string.Empty;
                                    string PostData           = string.Empty;
                                    string PgSrcInviteMessgae = string.Empty;
                                    string postUrl            = string.Empty;

                                    // https://www.linkedin.com/fetch/manual-invite-create

                                    PgSrcInviteMessgae = HttpHelper.getHtmlfromUrlProxy(new Uri("https://www.linkedin.com/fetch/importAndInviteEntry"), _ProxyAddress, proxyport, _ProxyUserName, _ProxyPassword);
                                    emailAddresses     = emailtosend.Replace("@", "%40");

                                    // For csrfToken
                                    string[] ArrCsrfToken = Regex.Split(PgSrcInviteMessgae, "input");
                                    foreach (string item in ArrCsrfToken)
                                    {
                                        try
                                        {
                                            if (!item.Contains("<!DOCTYPE"))
                                            {
                                                if (item.Contains("csrfToken") && item.Contains("value="))
                                                {
                                                    csrfToken = item;
                                                    break;
                                                }
                                            }
                                        }
                                        catch (Exception ex)
                                        {
                                        }
                                    }
                                    if (csrfToken.Contains("csrfToken"))
                                    {
                                        try
                                        {
                                            csrfToken = csrfToken.Substring(csrfToken.IndexOf("csrfToken"), 40);
                                            string[] Arr = csrfToken.Split('&');
                                            csrfToken = Arr[0].Replace("csrfToken=", string.Empty);
                                            csrfToken = csrfToken.Replace(":", "%3A").Replace("\\", string.Empty).Trim();;
                                        }
                                        catch (Exception ex)
                                        {
                                        }
                                    }

                                    // For sourceAlias
                                    if (PgSrcInviteMessgae.Contains("sourceAlias"))
                                    {
                                        try
                                        {
                                            sourceAlias = PgSrcInviteMessgae.Substring(PgSrcInviteMessgae.IndexOf("sourceAlias"), 100);
                                            string[] Arr = sourceAlias.Split('"');
                                            sourceAlias = Arr[2].Replace("\\", string.Empty).Trim();
                                        }
                                        catch (Exception ex)
                                        {
                                        }
                                    }

                                    //Post Data for Invite Message
                                    // emailAddresses=adanu%40femail.com%2Cagantuk%40gmail.com%2C&subject=Invitation+to+connect+on+LinkedIn&csrfToken=ajax%3A3731156693650115835&sourceAlias=0_7MU6tu3FMvMnMAXccRg8dcLvCi6FWQRq-jJrq2WCIlH
                                    PostData = "emailAddresses=" + emailAddresses + "&csrfToken=" + csrfToken + "&sourceAlias=" + sourceAlias;

                                    //Post Url for Invite Message
                                    postUrl = "https://www.linkedin.com/fetch/manual-invite-create";

                                    //Post Response
                                    string postResponse = HttpHelper.postFormDataRef(new Uri(postUrl), PostData, "https://www.linkedin.com/fetch/manual-invite-create", "", "", "", "", "");

                                    if (postResponse.Contains("One invitation has been sent.") && postResponse.Contains("alert success"))
                                    {
                                        LoggerManageConnection("[ " + DateTime.Now + " ] => [ Invitation sent to :" + emailtosend + " from ID : " + _UserName);
                                        GlobusFileHelper.AppendStringToTextfileNewLine(_UserName + "-->" + emailtosend, Globals.path_AddConnectionEmail);
                                    }
                                    else
                                    {
                                        LoggerManageConnection("[ " + DateTime.Now + " ] => [ Invitation sent to :" + emailtosend + " from ID : " + _UserName);
                                        GlobusFileHelper.AppendStringToTextfileNewLine(_UserName + "-->" + emailtosend, Globals.path_AddConnectionEmail);
                                        //LoggerManageConnection("[ " + DateTime.Now + " ] => [ Some Problem for sending Invitation :" + emailtosend + " from ID : " + _UserName + " ]");
                                        //GlobusFileHelper.AppendStringToTextfileNewLine(_UserName + "-->" + emailtosend, Globals.path_NonAddConnectionEmail);
                                    }
                                    counter = counter + 1;

                                    MinimumDelay = MinDelay;
                                    MaximumDelay = MaxDelay;

                                    int Delay = RandomNumberGenerator.GenerateRandom(MinimumDelay, MaximumDelay);
                                    LoggerManageConnection("[ " + DateTime.Now + " ] => [ Delay For : " + Delay + " Seconds ]");
                                    Thread.Sleep(Delay * 1000);
                                    listItemTempForInvitation.Add(emailtosend);
                                }
                                catch (Exception ex)
                                {
                                }
                            }
                        }
                    }
                }
                else
                {
                    LoggerManageConnection("[ " + DateTime.Now + " ] => [ " + xMESSAGE + " With Username >>> " + _UserName + " ]");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
        public Dictionary<string, string> AddSpecificGroupUser(ref GlobusHttpHelper HttpHelper, LinkedinUser objLinkedinUser, string gid)
        {
            string endName = string.Empty;
            string DeegreeConn = string.Empty;
            string endKey = string.Empty;
            string Locality = string.Empty;
            string Val_sourceAlias = string.Empty;
            string Val_key = string.Empty;
            string Val_defaultText = string.Empty;
            string Name = string.Empty;
            string Val_CsrToken = string.Empty;
            string Val_Subject = string.Empty;
            string Val_greeting = string.Empty;
            string Val_AuthToken = string.Empty;
            string Val_AuthType = string.Empty;
            string val_trk = string.Empty;
            string Val_lastName = string.Empty;
            string html = string.Empty;
            string Title = string.Empty;

            #region Data Initialization
            string GroupMemId = string.Empty;
            string GroupName = string.Empty;
            string Industry = string.Empty;
            string URLprofile = string.Empty;
            string firstname = string.Empty;
            string lastname = string.Empty;
            string location = string.Empty;
            string country = string.Empty;
            string postal = string.Empty;
            string phone = string.Empty;
            string USERemail = string.Empty;
            string code = string.Empty;
            string education1 = string.Empty;
            string education2 = string.Empty;
            string titlecurrent = string.Empty;
            string companycurrent = string.Empty;
            string titlepast1 = string.Empty;
            string companypast1 = string.Empty;
            string titlepast2 = string.Empty;
            string companypast2 = string.Empty;
            string titlepast3 = string.Empty;
            string companypast3 = string.Empty;
            string titlepast4 = string.Empty;
            string companypast4 = string.Empty;
            string Recommendations = string.Empty;
            string Connection = string.Empty;
            string Designation = string.Empty;
            string Website = string.Empty;
            string Contactsettings = string.Empty;
            string recomandation = string.Empty;

            string titleCurrenttitle = string.Empty;
            string titleCurrenttitle2 = string.Empty;
            string titleCurrenttitle3 = string.Empty;
            string titleCurrenttitle4 = string.Empty;
            string Skill = string.Empty;
            string TypeOfProfile = "Public";
            List<string> EducationList = new List<string>();
            string Finaldata = string.Empty;
            string EducationCollection = string.Empty;
            List<string> checkerlst = new List<string>();
            List<string> checkgrplist = new List<string>();
            string groupscollectin = string.Empty;
            string strFamilyName = string.Empty;
            string LDS_LoginID = string.Empty;
            string LDS_Websites = string.Empty;
            string LDS_UserProfileLink = string.Empty;
            string LDS_CurrentTitle = string.Empty;
            string LDS_Experience = string.Empty;
            string LDS_UserContact = string.Empty;
            string LDS_PastTitles = string.Empty;
            string LDS_BackGround_Summary = string.Empty;
            string LDS_Desc_AllComp = string.Empty;
            string Company = string.Empty;
            List<string> lstpasttitle = new List<string>();
            List<string> checkpasttitle = new List<string>();
            string csrfToken = string.Empty;
            string pageSource = string.Empty;
            string[] RgxSikValue = new string[] { };
            string[] RgxPageNo = new string[] { };
            string sikvalue = string.Empty;
            int pageno = 25;
            int counter = 0;

            string group_Url = string.Empty;
            string pagination_url = string.Empty;

            string groupId = string.Empty;
            string UserID = string.Empty;

            #endregion


            try
            {
                HttpHelper = objLinkedinUser.globusHttpHelper;
                UserID = objLinkedinUser.username;
                GroupSpecMem.Clear();
                GroupName = gid.Split('^')[0];
                groupId = gid.Split(':')[1];
                string pageSource1 = HttpHelper.getHtmlfromUrl(new Uri("https://www.linkedin.com/home?trk=hb_tab_home_top"));

                if (pageSource1.Contains("csrfToken"))
                {
                    csrfToken = pageSource1.Substring(pageSource1.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("\n", string.Empty).Replace(">", string.Empty).Replace("<script src", string.Empty);
                    csrfToken = csrfToken.Trim();
                }



                for (int i = 1; i <= pageno; i++)
                {
                    counter++;

                    string[] RgxGroupData = new string[] { };

                    #region with group search
                    if (WithGroupSearch == true)
                    {

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

                        if (counter == 1)
                        {

                            //  pageSource = HttpHelper.getHtmlfromUrl(new Uri("http://www.linkedin.com/groups?viewMembers=&gid=" + gid.Split(':')[2]));

                            pageSource = HttpHelper.getHtmlfromUrl(new Uri("https://www.linkedin.com/groups?viewMembers=&gid=" + gid.Split(':')[1]));

                            string Gid = string.Empty;
                            try
                            {
                                Gid = gid.Split(':')[1];
                            }
                            catch (Exception ex)
                            {
                            }
                            string URL = "https://www.linkedin.com/groups?viewMembers=&gid=" + Gid;
                            pageSource = HttpHelper.getHtmlfromUrl(new Uri(URL));

                            RgxSikValue = System.Text.RegularExpressions.Regex.Split(pageSource, "sik");
                            try
                            {
                                sikvalue = RgxSikValue[1].Split('&')[0].Replace("=", string.Empty);
                            }
                            catch { }

                            try
                            {
                                if (NumberHelper.ValidateNumber(sikvalue))
                                {
                                    sikvalue = sikvalue.Split('\"')[0];
                                }
                                else
                                {
                                    sikvalue = sikvalue.Split('\"')[0];
                                }
                            }
                            catch
                            {
                                sikvalue = sikvalue.Split('\"')[0];
                            }

                            //if (pageSource.Contains("<p class=\"paginate\">"))
                            //{
                            //    pagination_url = Utils.getBetween(pageSource, "<p class=\"paginate\">", "</a>");
                            //    pagination_url = Utils.getBetween(pagination_url, "href=\"", "\">").Replace("amp;", "");
                            //    pagination_url = "https://www.linkedin.com" + pagination_url;
                            //}

                            if (!string.IsNullOrEmpty(sikvalue))
                            {

                                //string postdata = "csrfToken=" + csrfToken + "&searchField=" + SearchKeyword + "&searchMembers=submit&searchMembers=Search&gid=" + gid.Split(':')[2] + "&goback=.gna_" + gid.Split(':')[2] + "";
                                //pageSource = HttpHelper.postFormDataRef(new Uri("https://www.linkedin.com/groups"), postdata, "http://www.linkedin.com/groups?viewMembers=&gid=" + gid.Split(':')[2] + "&sik=" + txid + "&split_page=" + i + "&goback=%2Egna_" + gid.Split(':')[2] + "", "", "");
                                #region Commented by sharan
                                string postdata = "csrfToken=" + csrfToken + "&searchField=" + SearchKeyword + "&searchMembers=submit&searchMembers=Search&gid=" + gid.Split(':')[1] + "&goback=.gna_" + gid.Split(':')[1] + "";
                                pageSource = HttpHelper.postFormDataRef(new Uri("https://www.linkedin.com/groups"), postdata, "http://www.linkedin.com/groups?viewMembers=&gid=" + gid.Split(':')[1] + "&sik=" + txid + "&split_page=" + i + "&goback=%2Egna_" + gid.Split(':')[1] + "", "", "");
                                #endregion

                                #region written by sharan
                                pageSource = HttpHelper.getHtmlfromUrl(new Uri("https://www.linkedin.com/grp/members?csrfToken=" + csrfToken + "&search=" + SearchKeyword.Replace(" ", "+") + "&gid=" + gid.Split(':')[1]));
                                #endregion
                                //string postdata = "csrfToken=" + csrfToken + "&searchField=" + SearchKeyword + "&searchMembers=submit&searchMembers=Search&gid=" + gid.Split(':')[1] + "&goback=.gna_" + gid.Split(':')[1] + "";
                                //pageSource = HttpHelper.postFormDataRef(new Uri("http://www.linkedin.com/groups"), postdata, "http://www.linkedin.com/groups?viewMembers=&gid=" + gid.Split(':')[1] + "&sik=" + txid + "&split_page=" + i + "&goback=%2Egna_" + gid.Split(':')[1] + "", "", "");

                            }
                            else
                            {

                                pageSource = HttpHelper.getHtmlfromUrl(new Uri("https://www.linkedin.com/grp/members?csrfToken=" + csrfToken + "&search=" + SearchKeyword.Replace(" ", "+") + "&gid=" + gid.Split(':')[1]));

                                // pageSource = HttpHelper.getHtmlfromUrl(new Uri("https://www.linkedin.com/grp/members?csrfToken=" + csrfToken + "&search=" + SearchKeyword.Replace(" ", "+") + "&gid=" + gid.Split(':')[1]));

                            }
                        }

                        if (!string.IsNullOrEmpty(sikvalue))
                        {
                            if (counter > 1)
                            {


                                // string getdata = "http://www.linkedin.com/groups?viewMembers=&gid=" + gid.Split(':')[2] + "&sik=" + txid + "&split_page=" + i + "&goback=%2Egna_" + gid.Split(':')[2] + "";
                                string getdata = "http://www.linkedin.com/groups?viewMembers=&gid=" + gid.Split(':')[1] + "&sik=" + txid + "&split_page=" + i + "&goback=%2Egna_" + gid.Split(':')[1] + "";
                                string new_pagination_url = pagination_url;
                                new_pagination_url = Utils.getBetween("###" + new_pagination_url, "###", "page=");
                                new_pagination_url = new_pagination_url + "page=" + counter;
                                pageSource = HttpHelper.getHtmlfromUrl(new Uri(new_pagination_url));
                                //   pageSource = HttpHelper.getHtmlfromUrl(new Uri(getdata));


                                // string getdata = "http://www.linkedin.com/groups?viewMembers=&gid=" + gid.Split(':')[1] + "&sik=" + txid + "&split_page=" + i + "&goback=%2Egna_" + gid.Split(':')[1] + "";
                                //  pageSource = HttpHelper.getHtmlfromUrl(new Uri(getdata));

                            }



                            RgxGroupData = System.Text.RegularExpressions.Regex.Split(pageSource, "<li class=\"member\">");


                            if (counter == 1)
                            {
                                try
                                {
                                    RgxPageNo = System.Text.RegularExpressions.Regex.Split(pageSource, "<h3 class=\"page-title\">Search Results: <span>");
                                    pageno = Convert.ToInt32(RgxPageNo[1].Split('<')[0].Replace("(", string.Empty).Replace(")", string.Empty).Replace("+", string.Empty).Trim());
                                    pageno = pageno / 20 + 1;
                                }
                                catch { }

                                if (pageno > 25)
                                {
                                    pageno = 25;
                                }

                                try
                                {
                                    if (pageSource.Contains("<p class=\"paginate\">"))
                                    {
                                        pagination_url = Utils.getBetween(pageSource, "<p class=\"paginate\">", "</a>");
                                        pagination_url = Utils.getBetween(pagination_url, "href=\"", "\">").Replace("amp;", "");
                                        pagination_url = "https://www.linkedin.com" + pagination_url;
                                        pagination_url = pagination_url.Replace("amp;", "");
                                    }
                                }
                                catch
                                { }
                            }
                        }
                        else
                        {
                            // RgxGroupData = System.Text.RegularExpressions.Regex.Split(pageSource, "<li class=\"member\">");
                            if (counter > 1)
                            {


                                //string getdata = "https://www.linkedin.com/grp/members?csrfToken=" + csrfToken + "&search=" + SearchKeyword.Replace(" ", "+") + "&gid=" + gid.Split(':')[2] + "&page="+i;

                                //string getdata = "https://www.linkedin.com/grp/members?csrfToken=" + csrfToken + "&search=" + SearchKeyword.Replace(" ", "+") + "&gid=" + gid.Split(':')[2] + "&page=" + i;

                                string new_pagination_url = pagination_url;
                                new_pagination_url = Utils.getBetween("###" + new_pagination_url, "###", "page=");
                                new_pagination_url = new_pagination_url + "page=" + counter;
                                pageSource = HttpHelper.getHtmlfromUrl(new Uri(new_pagination_url));

                                // pageSource = HttpHelper.getHtmlfromUrl(new Uri(getdata));
                            }


                            if (string.IsNullOrEmpty(sikvalue) && counter == 1)
                            {
                                try
                                {
                                    if (pageSource.Contains("<p class=\"paginate\">"))
                                    {
                                        pagination_url = Utils.getBetween(pageSource, "<p class=\"paginate\">", "</a>");
                                        pagination_url = Utils.getBetween(pagination_url, "href=\"", "\">").Replace("amp;", "");
                                        pagination_url = "https://www.linkedin.com" + pagination_url;
                                        pagination_url = pagination_url.Replace("amp;", "");
                                    }
                                }
                                catch
                                { }
                            }



                            RgxGroupData = System.Text.RegularExpressions.Regex.Split(pageSource, "<li class=\"member\">");

                            if (counter == 1)
                            {
                                try
                                {
                                    RgxPageNo = System.Text.RegularExpressions.Regex.Split(pageSource, "<h3 class=\"page-title\">Search Results <span>");
                                    pageno = Convert.ToInt32(RgxPageNo[1].Split('<')[0].Replace("(", string.Empty).Replace(")", string.Empty).Replace("+", string.Empty).Trim());
                                    pageno = pageno / 20 + 1;
                                }
                                catch { }

                                if (pageno > 25)
                                {
                                    pageno = 25;
                                }
                            }
                        }
                    }

                    #endregion

                    else
                    {
                        //pageSource = HttpHelper.getHtmlfromUrl(new Uri("http://www.linkedin.com/groups?viewMembers=&gid=" + gid.Split(':')[2] + "&split_page=" + i + ""));
                        pageSource = HttpHelper.getHtmlfromUrl(new Uri("https://www.linkedin.com/grp/members?gid=" + gid.Split(':')[1] + "&page=" + i));

                        group_Url = "https://www.linkedin.com/grp/members?gid=" + gid.Split(':')[1];


                        RgxGroupData = System.Text.RegularExpressions.Regex.Split(pageSource, "<li class=\"member\" id=\"");
                        if (RgxGroupData.Length == 1)
                        {
                            RgxGroupData = Regex.Split(pageSource, "<span class=\"new-miniprofile-container\"");
                            if (RgxGroupData.Length == 1)
                            {
                                break;
                            }
                        }
                    }

                    #region for csv
                    if (WithCsvinAddFriend == true)
                    {
                        List<string> PageSerchUrl = ChilkatBasedRegex.GettingAllUrls(pageSource, "profile/view?id");
                        string FrnAcceptUrL = string.Empty;
                        foreach (string item in PageSerchUrl)
                        {
                            try
                            {
                                if (item.Contains("/profile/view?id"))
                                {
                                    FrnAcceptUrL = "http://www.linkedin.com" + item;
                                    string[] urll = Regex.Split(FrnAcceptUrL, "&authType");
                                    GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ " + FrnAcceptUrL + " ]");

                                    string stringSource = HttpHelper.getHtmlfromUrl(new Uri(FrnAcceptUrL));

                                    #region GroupMemId
                                    try
                                    {
                                        string[] gid1 = FrnAcceptUrL.Split('&');
                                        GroupMemId = gid1[0].Replace("http://www.linkedin.com/profile/view?id=", string.Empty);
                                    }
                                    catch { }
                                    #endregion

                                    #region Name
                                    try
                                    {
                                        try
                                        {
                                            strFamilyName = stringSource.Substring(stringSource.IndexOf("\"See Full Name\",\"i18n_Edit\":\"Edit\",\"fmt__full_name\":\""), (stringSource.IndexOf("i18n__expand_your_network_to_see_more", stringSource.IndexOf("\"See Full Name\",\"i18n_Edit\":\"Edit\",\"fmt__full_name\":\"")) - stringSource.IndexOf("\"See Full Name\",\"i18n_Edit\":\"Edit\",\"fmt__full_name\":\""))).Replace("\"See Full Name\",\"i18n_Edit\":\"Edit\",\"fmt__full_name\":\"", string.Empty).Replace("\\", string.Empty).Replace("\"", string.Empty).Replace(",", string.Empty).Trim();
                                        }
                                        catch
                                        {
                                            try
                                            {
                                                strFamilyName = stringSource.Substring(stringSource.IndexOf("i18n__Overview_for_X"), (stringSource.IndexOf(",", stringSource.IndexOf("i18n__Overview_for_X")) - stringSource.IndexOf("i18n__Overview_for_X"))).Replace("i18n__Overview_for_X", string.Empty).Replace("\\", string.Empty).Replace("\"", string.Empty).Replace(",", string.Empty).Replace(":Overview for", "").Trim();

                                            }
                                            catch { }
                                        }
                                    }
                                    catch { }

                                    #endregion

                                    #region Namesplitation
                                    string[] NameArr = new string[5];
                                    if (strFamilyName.Contains(" "))
                                    {
                                        try
                                        {
                                            NameArr = Regex.Split(strFamilyName, " ");
                                        }
                                        catch { }
                                    }
                                    #endregion

                                    #region FirstName
                                    try
                                    {
                                        firstname = NameArr[0];
                                    }
                                    catch { }
                                    #endregion

                                    #region LastName



                                    try
                                    {
                                        lastname = NameArr[1];

                                        if (NameArr.Count() == 3)
                                        {
                                            lastname = NameArr[1] + " " + NameArr[2];
                                        }

                                        if (lastname.Contains("}]"))
                                        {

                                            #region Name
                                            try
                                            {
                                                try
                                                {
                                                    strFamilyName = stringSource.Substring(stringSource.IndexOf("<span class=\"n fn\">")).Replace("\\", string.Empty).Replace("\"", string.Empty).Replace(",", string.Empty).Trim();
                                                }
                                                catch
                                                {
                                                    try
                                                    {
                                                        strFamilyName = stringSource.Substring(stringSource.IndexOf("fmt__full_name\":"), (stringSource.IndexOf(",", stringSource.IndexOf("fmt__full_name\":")) - stringSource.IndexOf("fmt__full_name\":"))).Replace("fmt__full_name\":", string.Empty).Replace("\\", string.Empty).Replace("\"", string.Empty).Replace(",", string.Empty).Trim();

                                                    }
                                                    catch { }
                                                }
                                            }
                                            catch { }
                                            #endregion
                                        }
                                    }
                                    catch { }
                                    #endregion

                                    #region Company
                                    Company = string.Empty;
                                    try
                                    {
                                        try
                                        {
                                            try
                                            {
                                                //Company = stringSource.Substring(stringSource.IndexOf("visible\":true,\"memberHeadline"), (stringSource.IndexOf("memberID", stringSource.IndexOf("visible\":true,\"memberHeadline")) - stringSource.IndexOf("visible\":true,\"memberHeadline"))).Replace("visible\":true,\"memberHeadline", string.Empty).Replace("\\", string.Empty).Replace("\"", string.Empty).Replace(",", string.Empty).Replace(":", string.Empty).Replace("   ", string.Empty).Trim();
                                                Company = stringSource.Substring(stringSource.IndexOf("\"memberHeadline"), (stringSource.IndexOf("memberID", stringSource.IndexOf("\"memberHeadline")) - stringSource.IndexOf("\"memberHeadline"))).Replace("\"memberHeadline", string.Empty).Replace("\\", string.Empty).Replace("\"", string.Empty).Replace(",", string.Empty).Replace(":", string.Empty).Replace("i18n__LocationLocationcompletenessLevel4", string.Empty).Replace("visibletrue", "").Replace("isPortfoliofalse", string.Empty).Replace("isLNLedtrue", string.Empty).Trim();
                                            }
                                            catch
                                            {
                                            }

                                            if (string.IsNullOrEmpty(Company))
                                            {
                                                try
                                                {
                                                    //memberHeadline
                                                    Company = stringSource.Substring(stringSource.IndexOf("memberHeadline\":"), (stringSource.IndexOf(",", stringSource.IndexOf("memberHeadline\":")) - stringSource.IndexOf("memberHeadline\":"))).Replace("memberHeadline\":", string.Empty).Replace("\\", string.Empty).Replace("\"", string.Empty).Replace(",", string.Empty).Replace(":", string.Empty).Replace("   ", string.Empty).Replace(":", "").Replace("&dsh;", "").Replace("&amp", "").Replace(";", "").Replace("isPortfoliofalse", string.Empty).Replace("isLNLedtrue", string.Empty).Trim();
                                                }
                                                catch
                                                {
                                                }

                                            }

                                            titlecurrent = string.Empty;
                                            companycurrent = string.Empty;
                                            string[] strdesigandcompany = new string[4];
                                            if (Company.Contains(" at ") || Company.Contains(" of "))
                                            {
                                                try
                                                {
                                                    strdesigandcompany = Regex.Split(Company, " at ");

                                                    if (strdesigandcompany.Count() == 1)
                                                    {
                                                        strdesigandcompany = Regex.Split(Company, " of ");
                                                    }
                                                }
                                                catch { }

                                                #region Title
                                                try
                                                {
                                                    titlecurrent = strdesigandcompany[0];
                                                }
                                                catch { }
                                                #endregion

                                                #region Current Company
                                                try
                                                {
                                                    companycurrent = strdesigandcompany[1];
                                                }
                                                catch { }
                                                #endregion
                                            }

                                            if (titlecurrent == string.Empty)
                                            {
                                                titlecurrent = Company;
                                            }
                                        }
                                        catch { }

                                        #region PastCompany
                                        string[] companylist = Regex.Split(stringSource, "companyName\"");
                                        string AllComapny = string.Empty;

                                        string Companyname = string.Empty;
                                        checkerlst.Clear();
                                        foreach (string item1 in companylist)
                                        {
                                            try
                                            {
                                                if (!item1.Contains("<!DOCTYPE html>"))
                                                {
                                                    Companyname = item1.Substring(item1.IndexOf(":"), (item1.IndexOf(",", item1.IndexOf(":")) - item1.IndexOf(":"))).Replace(":", string.Empty).Replace("\\", string.Empty).Replace("\"", string.Empty).Replace(",", string.Empty).Replace(":", string.Empty).Replace("]", string.Empty).Replace("}", string.Empty).Trim();
                                                    //Checklist.Add(item);
                                                    string items = item1;
                                                    checkerlst.Add(Companyname);
                                                    checkerlst = checkerlst.Distinct().ToList();
                                                }
                                            }
                                            catch { }
                                        }
                                        AllComapny = string.Empty;
                                        foreach (string item1 in checkerlst)
                                        {
                                            if (string.IsNullOrEmpty(AllComapny))
                                            {
                                                AllComapny = item1.Replace("}", "").Replace("]", "").Replace("&amp;", "&");
                                            }
                                            else
                                            {
                                                AllComapny = AllComapny + " : " + item1.Replace("}", "").Replace("]", "").Replace("&amp;", "&");
                                            }
                                        }

                                        if (companycurrent == string.Empty)
                                        {
                                            companycurrent = checkerlst[0].ToString();
                                        }
                                        #endregion

                                    #endregion Company

                                        #region Company Descripription

                                        try
                                        {
                                            string[] str_CompanyDesc = Regex.Split(stringSource, "showSummarySection");

                                            foreach (string item2 in str_CompanyDesc)
                                            {
                                                try
                                                {
                                                    string Current_Company = string.Empty;
                                                    if (!item2.Contains("<!DOCTYPE html>"))
                                                    {
                                                        int startindex = item2.IndexOf("specialties\":\"");

                                                        if (startindex > 0)
                                                        {
                                                            try
                                                            {
                                                                string start = item2.Substring(startindex).Replace("specialties\":", "");
                                                                int endindex = start.IndexOf("\",\"associatedWith\"");
                                                                string end = start.Substring(0, endindex);
                                                                Current_Company = end.Replace(",\"specialties_lb\":", string.Empty).Replace("\"", string.Empty).Replace("summary_lb", "Summary").Replace(",", ";").Replace("\"u002", "-");
                                                                LDS_BackGround_Summary = Current_Company;
                                                            }
                                                            catch { }
                                                        }

                                                    }

                                                    if (!item2.Contains("<!DOCTYPE html>"))
                                                    {
                                                        int startindex = item2.IndexOf("\"summary_lb\"");

                                                        if (startindex > 0)
                                                        {
                                                            try
                                                            {
                                                                string start = item2.Substring(startindex).Replace("\"summary_lb\"", "");
                                                                int endindex = start.IndexOf("\",\"associatedWith\"");
                                                                string end = start.Substring(0, endindex);
                                                                Current_Company = end.Replace(",\"specialties_lb\":", string.Empty).Replace("<br>", string.Empty).Replace("\n\"", string.Empty).Replace("\"", string.Empty).Replace("summary_lb", "Summary").Replace(",", ";").Replace("u002", "-").Replace(":", string.Empty);
                                                                LDS_BackGround_Summary = Current_Company;
                                                            }
                                                            catch { }
                                                        }

                                                    }

                                                }
                                                catch { }
                                            }
                                        }
                                        catch { }

                                        #endregion

                                        #region Education
                                        EducationCollection = string.Empty;
                                        try
                                        {
                                            try
                                            {
                                                EducationCollection = stringSource.Substring(stringSource.IndexOf("\"schoolName\":"), (stringSource.IndexOf(",", stringSource.IndexOf("\"schoolName\":")) - stringSource.IndexOf("\"schoolName\":"))).Replace("\"schoolName\":", string.Empty).Replace("\\", string.Empty).Replace("\"", string.Empty).Replace(",", string.Empty).Trim();
                                            }
                                            catch
                                            {
                                                try
                                                {
                                                    //  education1 = stringSource.Substring(stringSource.IndexOf("i18n__Overview_for_X"), (stringSource.IndexOf(",", stringSource.IndexOf("i18n__Overview_for_X")) - stringSource.IndexOf("i18n__Overview_for_X"))).Replace("i18n__Overview_for_X", string.Empty).Replace("\\", string.Empty).Replace("\"", string.Empty).Replace(",", string.Empty).Replace(":Overview for", "").Trim();

                                                }
                                                catch { }
                                            }
                                        }
                                        catch { }

                                        #endregion

                                        #region Email
                                        try
                                        {
                                            string[] str_Email = Regex.Split(stringSource, "email\"");
                                            USERemail = stringSource.Substring(stringSource.IndexOf("[{\"email\":"), (stringSource.IndexOf("}]", stringSource.IndexOf("[{\"email\":")) - stringSource.IndexOf("[{\"email\":"))).Replace("[{\"email\":", string.Empty).Replace("\\", string.Empty).Replace("\"", string.Empty).Replace(",", string.Empty).Replace(":", string.Empty).Trim();
                                        }
                                        catch (Exception ex)
                                        {

                                        }
                                        #endregion Email

                                        #region Website
                                        Website = string.Empty;
                                        try
                                        {
                                            Website = stringSource.Substring(stringSource.IndexOf("[{\"URL\":"), (stringSource.IndexOf(",", stringSource.IndexOf("[{\"URL\":")) - stringSource.IndexOf("[{\"URL\":"))).Replace("[{\"URL\":", string.Empty).Replace("\\", string.Empty).Replace("\"", string.Empty).Replace(",", string.Empty).Replace("}]", string.Empty).Trim();
                                        }
                                        catch { }
                                        #endregion Website

                                        #region location
                                        location = string.Empty;
                                        try
                                        {
                                            location = stringSource.Substring(stringSource.IndexOf("Country\",\"fmt__location\":"), (stringSource.IndexOf("i18n_no_location_matches", stringSource.IndexOf("Country\",\"fmt__location\":")) - stringSource.IndexOf("Country\",\"fmt__location\":"))).Replace("Country\",\"fmt__location\":", string.Empty).Replace("\\", string.Empty).Replace("\"", string.Empty).Replace(":", string.Empty).Replace(",", string.Empty).Trim();
                                        }
                                        catch (Exception ex)
                                        {
                                            try
                                            {
                                                if (string.IsNullOrEmpty(location))
                                                {
                                                    int startindex = stringSource.IndexOf("\"fmt_location\":\"");
                                                    if (startindex > 0)
                                                    {
                                                        string start = stringSource.Substring(startindex).Replace("\"fmt_location\":\"", "");
                                                        int endindex = start.IndexOf("\",");
                                                        string end = start.Substring(0, endindex);
                                                        country = end;
                                                    }
                                                }
                                            }
                                            catch (Exception ex1)
                                            {

                                            }
                                        }

                                        #endregion location

                                        #region Country
                                        try
                                        {
                                            int startindex = stringSource.IndexOf("\"locationName\":\"");
                                            if (startindex > 0)
                                            {
                                                string start = stringSource.Substring(startindex).Replace("\"locationName\":\"", "");
                                                int endindex = start.IndexOf("\",");
                                                string end = start.Substring(0, endindex);
                                                location = end;
                                            }
                                        }
                                        catch (Exception ex)
                                        {

                                        }
                                        #endregion

                                        #region Industry
                                        Industry = string.Empty;
                                        try
                                        {
                                            //Industry = stringSource.Substring(stringSource.IndexOf("fmt__industry_highlight\":"), (stringSource.IndexOf(",", stringSource.IndexOf("fmt__industry_highlight\":")) - stringSource.IndexOf("fmt__industry_highlight\":"))).Replace("fmt__industry_highlight\":", string.Empty).Replace("\\", string.Empty).Replace("\"", string.Empty).Replace(",", string.Empty).Replace(":", string.Empty).Trim();
                                            int startindex = stringSource.IndexOf("\"industry_highlight\":\"");
                                            if (startindex > 0)
                                            {
                                                string start = stringSource.Substring(startindex).Replace("\"industry_highlight\":\"", "");
                                                int endindex = start.IndexOf("\",");
                                                string end = start.Substring(0, endindex).Replace("&amp;", "&");
                                                Industry = end;
                                            }
                                        }
                                        catch (Exception ex)
                                        {
                                        }
                                        #endregion Industry

                                        #region Connection
                                        Connection = string.Empty;
                                        try
                                        {
                                            //Connection = stringSource.Substring(stringSource.IndexOf("_count_string\":"), (stringSource.IndexOf(",", stringSource.IndexOf("_count_string\":")) - stringSource.IndexOf("_count_string\":"))).Replace("_count_string\":", string.Empty).Replace("\\", string.Empty).Replace("\"", string.Empty).Replace(",", string.Empty).Replace(":", string.Empty).Trim();
                                            int startindex = stringSource.IndexOf("\"numberOfConnections\":");
                                            if (startindex > 0)
                                            {
                                                string start = stringSource.Substring(startindex).Replace("\"numberOfConnections\":", "");
                                                int endindex = start.IndexOf(",");
                                                string end = start.Substring(0, endindex).Replace("&amp;", "&").Replace("}", string.Empty);
                                                Connection = end;
                                            }
                                        }
                                        catch (Exception ex)
                                        {
                                        }
                                        #endregion Connection

                                        #region Recommendation
                                        try
                                        {
                                            //recomandation = stringSource.Substring(stringSource.IndexOf("i18n__Recommend_Query\":"), (stringSource.IndexOf(",", stringSource.IndexOf("i18n__Recommend_Query\":")) - stringSource.IndexOf("i18n__Recommend_Query\":"))).Replace("i18n__Recommend_Query\":", string.Empty).Replace("\\", string.Empty).Replace("\"", string.Empty).Replace(",", string.Empty).Replace(":", string.Empty).Trim();         
                                            string PageSource = HttpHelper.getHtmlfromUrl(new Uri("http://www.linkedin.com/profile/profile-v2-endorsements?id=" + GroupMemId + "&authType=OUT_OF_NETWORK&authToken=rXRG&goback=%2Efps_PBCK_*1_*1_*1_*1_*1_*1_tcs_*2_CP_I_us_*1_*1_false_1_R_*1_*51_*1_*51_true_*1_*2_*2_*2_*2_*2_*2_*2_*2_*2_*2_*2_*2_*2_*2_*2_*2_*2_*2_*2_*2"));
                                            string[] arrayRecommendedName = Regex.Split(PageSource, "headline");
                                            List<string> ListRecommendationName = new List<string>();
                                            recomandation = string.Empty;
                                            foreach (var itemRecomName in arrayRecommendedName)
                                            {
                                                try
                                                {
                                                    if (!itemRecomName.Contains("Endorsements"))
                                                    {
                                                        try
                                                        {

                                                            int startindex = itemRecomName.IndexOf(":");
                                                            string start = itemRecomName.Substring(startindex);
                                                            int endIndex = start.IndexOf("\",");
                                                            string Heading = (start.Substring(0, endIndex).Replace("\"", string.Empty).Replace(":", string.Empty));

                                                            int startindex1 = itemRecomName.IndexOf("fmt__referrerfullName");
                                                            string start1 = itemRecomName.Substring(startindex1);
                                                            int endIndex1 = start1.IndexOf("\",");
                                                            Name = (start1.Substring(0, endIndex1).Replace("\"", string.Empty).Replace("fmt__referrerfullName", string.Empty).Replace(":", string.Empty));

                                                            ListRecommendationName.Add(Name + " : " + Heading);
                                                        }
                                                        catch { }
                                                    }
                                                }
                                                catch { }

                                            }

                                            foreach (var item5 in ListRecommendationName)
                                            {
                                                if (recomandation == string.Empty)
                                                {
                                                    recomandation = item5;
                                                }
                                                else
                                                {
                                                    recomandation += "  -  " + item5;
                                                }
                                            }

                                        }
                                        catch { }
                                        #endregion

                                        #region Experience
                                        LDS_Experience = string.Empty;
                                        if (LDS_Experience == string.Empty)
                                        {
                                            try
                                            {
                                                string[] array = Regex.Split(stringSource, "title_highlight");
                                                string exp = string.Empty;
                                                string comp = string.Empty;
                                                List<string> ListExperince = new List<string>();
                                                string SelItem = string.Empty;

                                                foreach (var itemGrps in array)
                                                {
                                                    try
                                                    {
                                                        if (itemGrps.Contains("title_pivot") && !itemGrps.Contains("<!DOCTYPE html")) //">Join
                                                        {
                                                            try
                                                            {

                                                                int startindex = itemGrps.IndexOf("\":\"");
                                                                string start = itemGrps.Substring(startindex);
                                                                int endIndex = start.IndexOf(",");
                                                                exp = (start.Substring(0, endIndex).Replace("\"", string.Empty).Replace(":", string.Empty).Replace("&amp", "&").Replace(";", string.Empty).Replace("\\u002d", "-").Replace("name:", string.Empty));

                                                            }
                                                            catch { }

                                                            try
                                                            {

                                                                int startindex1 = itemGrps.IndexOf("companyName");
                                                                string start1 = itemGrps.Substring(startindex1);
                                                                int endIndex1 = start1.IndexOf(",");
                                                                comp = (start1.Substring(0, endIndex1).Replace("\"", string.Empty).Replace("companyName", string.Empty).Replace(":", string.Empty).Replace(";", string.Empty).Replace("\\u002d", "-").Replace("name:", string.Empty));

                                                            }
                                                            catch { }

                                                            if (titlecurrent == string.Empty)
                                                            {
                                                                titlecurrent = exp;
                                                            }

                                                            if (companycurrent == string.Empty)
                                                            {
                                                                companycurrent = comp;
                                                            }

                                                            ListExperince.Add(exp + ":" + comp);

                                                        }
                                                    }
                                                    catch { }
                                                }

                                                foreach (var itemExp in ListExperince)
                                                {
                                                    if (LDS_Experience == string.Empty)
                                                    {
                                                        LDS_Experience = itemExp;
                                                    }
                                                    else
                                                    {
                                                        LDS_Experience += "  -  " + itemExp;
                                                    }
                                                }

                                            }
                                            catch { }
                                        }

                                        #endregion

                                        #region Group
                                        try
                                        {
                                            string PageSource = HttpHelper.getHtmlfromUrl(new Uri("http://www.linkedin.com/profile/mappers?x-a=profile_v2_groups%2Cprofile_v2_follow%2Cprofile_v2_connections&x-p=profile_v2_discovery%2Erecords%3A4%2Ctop_card%2EprofileContactsIntegrationStatus%3A0%2Cprofile_v2_comparison_insight%2Edistance%3A1%2Cprofile_v2_right_fixed_discovery%2Eoffset%3A0%2Cprofile_v2_connections%2Edistance%3A1%2Cprofile_v2_right_fixed_discovery%2Erecords%3A4%2Cprofile_v2_network_overview_insight%2Edistance%3A1%2Cprofile_v2_right_top_discovery_teamlinkv2%2Eoffset%3A0%2Cprofile_v2_right_top_discovery_teamlinkv2%2Erecords%3A4%2Cprofile_v2_discovery%2Eoffset%3A0%2Cprofile_v2_summary_upsell%2EsummaryUpsell%3Atrue%2Cprofile_v2_network_overview_insight%2EnumConn%3A1668%2Ctop_card%2Etc%3Atrue&x-oa=bottomAliases&id=" + GroupMemId + "&locale=&snapshotID=&authToken=&authType=name&invAcpt=&notContactable=&primaryAction=&isPublic=false&sfd=true&_=1366115853014"));

                                            string[] array = Regex.Split(PageSource, "href=\"/groupRegistration?");
                                            string[] array1 = Regex.Split(PageSource, "groupRegistration?");
                                            List<string> ListGroupName = new List<string>();
                                            string SelItem = string.Empty;

                                            foreach (var itemGrps in array1)
                                            {
                                                try
                                                {
                                                    if (itemGrps.Contains("?gid=") && !itemGrps.Contains("<!DOCTYPE html")) //">Join
                                                    {
                                                        if (itemGrps.IndexOf("?gid=") == 0)
                                                        {
                                                            try
                                                            {
                                                                int startindex = itemGrps.IndexOf("\"name\":");
                                                                string start = itemGrps.Substring(startindex);
                                                                int endIndex = start.IndexOf(",");
                                                                ListGroupName.Add(start.Substring(0, endIndex).Replace("\"", string.Empty).Replace("amp", string.Empty).Replace("&", string.Empty).Replace(";", string.Empty).Replace("csrfToken", string.Empty).Replace("name:", string.Empty));
                                                            }
                                                            catch { }
                                                        }
                                                    }
                                                }
                                                catch { }
                                            }

                                            foreach (var item6 in ListGroupName)
                                            {
                                                if (groupscollectin == string.Empty)
                                                {
                                                    groupscollectin = item6;
                                                }
                                                else
                                                {
                                                    groupscollectin += "  -  " + item6;

                                                }
                                            }

                                        }
                                        catch { }

                                        #endregion

                                        #region skill and Expertise
                                        try
                                        {
                                            string[] strarr_skill = Regex.Split(stringSource, "endorse-item-name-text\"");
                                            string[] strarr_skill1 = Regex.Split(stringSource, "fmt__skill_name\"");
                                            if (strarr_skill.Count() >= 2)
                                            {
                                                foreach (string item7 in strarr_skill)
                                                {
                                                    try
                                                    {
                                                        if (!item7.Contains("!DOCTYPE html"))
                                                        {
                                                            try
                                                            {
                                                                string Grp = item7.Substring(item7.IndexOf("<"), (item7.IndexOf(">", item7.IndexOf("<")) - item7.IndexOf("<"))).Replace("<", string.Empty).Replace("\\", string.Empty).Replace("\"", string.Empty).Replace(",", string.Empty).Replace(":", string.Empty).Trim();
                                                                checkgrplist.Add(Grp);
                                                                checkgrplist.Distinct().ToList();
                                                            }
                                                            catch { }
                                                        }

                                                    }
                                                    catch { }
                                                }

                                                foreach (string item8 in checkgrplist)
                                                {
                                                    if (string.IsNullOrEmpty(Skill))
                                                    {
                                                        Skill = item8;
                                                    }
                                                    else
                                                    {
                                                        Skill = Skill + "  -  " + item8;
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                if (strarr_skill1.Count() >= 2)
                                                {
                                                    try
                                                    {
                                                        foreach (string skillitem in strarr_skill1)
                                                        {
                                                            if (!skillitem.Contains("!DOCTYPE html"))
                                                            {
                                                                try
                                                                {
                                                                    string Grp = skillitem.Substring(skillitem.IndexOf(":"), (skillitem.IndexOf("}", skillitem.IndexOf(":")) - skillitem.IndexOf(":"))).Replace(":", string.Empty).Replace("\\", string.Empty).Replace("\"", string.Empty).Replace(",", string.Empty).Replace(":", string.Empty).Trim();
                                                                    checkgrplist.Add(Grp);
                                                                    checkgrplist.Distinct().ToList();
                                                                }
                                                                catch { }
                                                            }
                                                        }

                                                        foreach (string item9 in checkgrplist)
                                                        {
                                                            if (string.IsNullOrEmpty(Skill))
                                                            {
                                                                Skill = item9;
                                                            }
                                                            else
                                                            {
                                                                Skill = Skill + "  -  " + item9;
                                                            }
                                                        }
                                                    }
                                                    catch (Exception ex)
                                                    {

                                                    }
                                                }
                                            }
                                        }
                                        catch (Exception ex)
                                        {

                                        }

                                        #endregion

                                        #region Pasttitle and All Company Summary
                                        string[] pasttitles = Regex.Split(stringSource, "company_name");
                                        string pstTitlesitem = string.Empty;
                                        string pstDescCompitem = string.Empty;
                                        LDS_PastTitles = string.Empty;
                                        pasttitles = pasttitles.Skip(1).ToArray();
                                        foreach (string item10 in pasttitles)
                                        {
                                            if (item10.Contains("positionId"))
                                            {
                                                try
                                                {
                                                    int startindex = item10.IndexOf(":");
                                                    if (startindex > 0)
                                                    {
                                                        string start = item10.Substring(startindex).Replace(":\"", "");
                                                        int endindex = start.IndexOf("\",");
                                                        string end = start.Substring(0, endindex);
                                                        pstTitlesitem = end.Replace(",", ";");
                                                    }

                                                    if (string.IsNullOrEmpty(LDS_PastTitles))
                                                    {
                                                        LDS_PastTitles = pstTitlesitem;
                                                    }
                                                    else
                                                    {
                                                        LDS_PastTitles = LDS_PastTitles + "  :  " + pstTitlesitem;
                                                    }


                                                    int startindex1 = item10.IndexOf("summary_lb\":\"");
                                                    if (startindex > 0)
                                                    {
                                                        string start1 = item10.Substring(startindex1).Replace("summary_lb\":\"", "");
                                                        int endindex1 = 0;

                                                        if (start1.Contains("associatedWith"))
                                                        {
                                                            endindex1 = start1.IndexOf("\",\"associatedWith\"");

                                                            if (start1.Contains("\"}"))
                                                            {
                                                                endindex1 = start1.IndexOf("\"}");
                                                            }

                                                        }
                                                        else if (start1.Contains("\"}"))
                                                        {
                                                            endindex1 = start1.IndexOf("\"}");
                                                        }


                                                        string end1 = start1.Substring(0, endindex1);
                                                        pstDescCompitem = end1.Replace(",", ";").Replace("u002d", "-").Replace("<br>", string.Empty).Replace("\n\"", string.Empty);

                                                        if (pstDescCompitem.Contains("\";\"associatedWith"))
                                                        {
                                                            pstDescCompitem = Regex.Split(pstDescCompitem, "\";\"associatedWith")[0];
                                                        }
                                                    }

                                                    if (string.IsNullOrEmpty(LDS_Desc_AllComp))
                                                    {
                                                        LDS_Desc_AllComp = pstTitlesitem + "-" + pstDescCompitem + " ++ ";
                                                    }
                                                    else
                                                    {
                                                        LDS_Desc_AllComp = LDS_Desc_AllComp + pstTitlesitem + "-" + pstDescCompitem + " ++ ";
                                                    }
                                                }
                                                catch
                                                {
                                                }
                                            }

                                        }
                                        #endregion

                                        #region FullUrl
                                        try
                                        {
                                            string[] UrlFull = System.Text.RegularExpressions.Regex.Split(FrnAcceptUrL, "&authType");
                                            LDS_UserProfileLink = UrlFull[0];

                                            LDS_UserProfileLink = UrlFull[0];
                                            //  LDS_UserProfileLink = stringSource.Substring(stringSource.IndexOf("canonicalUrl\":"), (stringSource.IndexOf(",", stringSource.IndexOf("canonicalUrl\":")) - stringSource.IndexOf("canonicalUrl\":"))).Replace("canonicalUrl\":", string.Empty).Replace("\\", string.Empty).Replace("\"", string.Empty).Replace(",", string.Empty).Replace(":", string.Empty).Trim();
                                        }
                                        catch { }
                                        #endregion

                                        LDS_LoginID = objLinkedinUser.username;

                                        if (string.IsNullOrEmpty(firstname))
                                        {
                                            firstname = "Linkedin Member";
                                        }

                                        LDS_BackGround_Summary = LDS_BackGround_Summary.Replace("\n", "").Replace("-", "").Replace("d", "").Replace("&#x2022", "").Replace(";", "").Replace("\n", "").Replace(",", "").Replace("&#x201", "").Trim();

                                        LDS_Desc_AllComp = "NA";
                                        Skill = "NA";

                                        string LDS_FinalData = TypeOfProfile + "," + LDS_UserProfileLink + "," + firstname + "," + lastname + "," + Company.Replace(",", ";") + "," + titlecurrent.Replace(",", ";") + "," + companycurrent.Replace(",", ";") + "," + LDS_Desc_AllComp + "," + LDS_BackGround_Summary.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(",", ";") + "," + LDS_LoginID.Replace(",", ";") + ",";
                                      //  AppFileHelper.AddingLinkedInGroupMemberDataToCSVFile(LDS_FinalData, SearchCriteria.FileName);

                                    }
                                    catch { }
                                }

                            }
                            catch { }
                        }
                    }
                    #endregion

                    foreach (var GrpUser in RgxGroupData)
                    {
                        try
                        {
                            if (GrpUser.Contains("member"))
                            {
                                if (GrpUser.Contains("title=\"YOU") || GrpUser.Contains("<!DOCTYPE html>"))
                                {
                                    if (GrpUser.Contains("title=\"YOU"))
                                    {

                                    }
                                    continue;
                                }
                                string profileUrl = string.Empty;
                                try
                                {
                                    profileUrl = Utils.getBetween(GrpUser, "<a href=\"", "\">");
                                }
                                catch
                                {
                                }
                                try
                                {
                                    //data-li-fullName="Kashish Arora">Send message</a>

                                    int startindex = GrpUser.IndexOf("fullName=");
                                    if (startindex > 0)
                                    {
                                        endName = string.Empty;
                                        string start = GrpUser.Substring(startindex);
                                        int endIndex = start.IndexOf(">Send message<");
                                        if (endIndex == -1)
                                        {
                                            endIndex = start.IndexOf(">");
                                        }
                                        endName = start.Substring(0, endIndex).Replace("fullName=", string.Empty).Replace("'", string.Empty).Replace(",", string.Empty).Replace("/", string.Empty).Replace("\"", string.Empty).Replace("&amp;", "&").Replace("&quot;", "'").Replace("tracking=anetppl_sendmsg", string.Empty).Replace("tracking=anetppl_invite", string.Empty).Replace("\\u00e9", "é").Trim();
                                    }
                                    else
                                    {
                                        endName = string.Empty;
                                        int startindex1 = GrpUser.IndexOf("alt=");
                                        string start = GrpUser.Substring(startindex1).Replace("alt=\"", "");
                                        int endIndex = start.IndexOf("\"");
                                        try
                                        {
                                            endName = start.Substring(0, endIndex).Replace("alt=", string.Empty).Replace("'", string.Empty).Replace(",", string.Empty).Replace(">", string.Empty).Replace("\"", string.Empty).Replace("&amp;", "&").Replace("&quot;", "'").Replace("tracking=anetppl_sendmsg", string.Empty).Replace("tracking=anetppl_invite", string.Empty).Replace("\\u00e9", "é").Trim();
                                        }
                                        catch { }
                                        try
                                        {
                                            if (string.IsNullOrEmpty(endName))
                                            {
                                                endName = start.Substring(start.IndexOf("alt="), start.IndexOf("class=", start.IndexOf("alt=")) - start.IndexOf("alt=")).Replace("alt=", string.Empty).Replace("alt=", string.Empty).Replace("\"", string.Empty).Replace("&quot;", "'").Replace("tracking=anetppl_sendmsg", string.Empty).Replace("tracking=anetppl_invite", string.Empty).Replace("\\u00e9", "é").Trim();
                                            }

                                        }
                                        catch { }
                                    }
                                }
                                catch
                                {

                                }

                                //Deegree connection
                                try
                                {
                                    int startindex = GrpUser.IndexOf("<span class=\"degree-icon\">");
                                    if (startindex > 0)
                                    {
                                        DeegreeConn = string.Empty;
                                        string start = GrpUser.Substring(startindex);
                                        int endIndex = start.IndexOf("<sup>");
                                        DeegreeConn = start.Substring(0, endIndex).Replace("<span class=\"degree-icon\">", string.Empty);

                                        if (DeegreeConn == "1")
                                        {
                                            DeegreeConn = DeegreeConn + "st";
                                        }
                                        else if (DeegreeConn == "2")
                                        {
                                            DeegreeConn = DeegreeConn + "nd";
                                        }
                                        else if (DeegreeConn == "3")
                                        {
                                            DeegreeConn = DeegreeConn + "rd";
                                        }
                                    }
                                    else
                                    {
                                        startindex = GrpUser.IndexOf("span class=\"degree-icon group\">");
                                        DeegreeConn = string.Empty;

                                        if (startindex > 0)
                                        {
                                            DeegreeConn = string.Empty;
                                            string start = GrpUser.Substring(startindex);
                                            int endIndex = start.IndexOf("</span>");
                                            DeegreeConn = start.Substring(0, endIndex).Replace("span class=\"degree-icon group\">", string.Empty);

                                        }

                                        if (DeegreeConn == string.Empty)
                                        {

                                            DeegreeConn = "3rd";
                                        }
                                    }

                                }

                                catch { }

                                try
                                {
                                    int startindex2 = GrpUser.IndexOf("memberId=");
                                    if (startindex2 > 0)
                                    {
                                        endKey = string.Empty;
                                        string start1 = GrpUser.Substring(startindex2);
                                        int endIndex1 = start1.IndexOf("data-li-fullName=");
                                        endKey = start1.Substring(0, endIndex1).Replace("memberId=", string.Empty).Replace("'", string.Empty).Replace(",", string.Empty).Replace("/", string.Empty).Replace("\"", string.Empty).Trim();
                                    }
                                    else
                                    {
                                        endKey = string.Empty;
                                        int startindex3 = GrpUser.IndexOf("member-");
                                        string start1 = GrpUser.Substring(startindex3);
                                        int endIndex1 = start1.IndexOf(">");
                                        endKey = start1.Substring(0, endIndex1).Replace("member-", string.Empty).Replace("'", string.Empty).Replace(",", string.Empty).Replace(">", string.Empty).Replace("\"", string.Empty).Trim();
                                    }
                                }
                                catch
                                {

                                }

                                try
                                {
                                    GroupSpecMem.Add(endKey, " [" + GroupName.Replace(",", string.Empty) + " ] " + endName + " (" + DeegreeConn.Replace(",", string.Empty) + ")");
                                    string item = UserID + "," + GroupName.Replace(",", string.Empty) + "," + group_Url.Replace("'", "").Replace("\r", "").Replace(" ", "").Replace("\n", " ") + "," + endName + "," + profileUrl.Replace("'", "").Replace("\r", "").Replace(" ", "").Replace("\n", " ") + "," + DeegreeConn.Replace(",", string.Empty);
                                   // AddingLinkedInDataToCSVFile1(item);
                                    if (WithGroupSearch == true)
                                    {
                                        GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Added Group Member : " + endName + " (" + DeegreeConn + ") with Search keyword : " + SearchKeyword + " ]");
                                        //  objfrmMain.AddLoggerLoggerForGroupScraper("[ " + DateTime.Now + " ] => [ Added Group Member : " + endName + " (" + DeegreeConn + ") with Search keyword : " + SearchKeyword + " ]");
                                    }
                                    else
                                    {
                                        GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Added Group Member : " + endName + " ]");
                                    }
                                }
                                catch { }
                            }
                            else
                            {

                            }
                        }
                        catch { }
                    }



                    return GroupSpecMem;
                }

                #region new code_11_26

                if (GroupSpecMem.Count <= 0)
                {
                    List<string> lstNewMembers = new List<string>();
                    bool gotScrapeUrl = false;
                    int startPage = 10;

                  string  url = "https://www.linkedin.com/communities-api/v1/memberships/community/" + groupId + "?projection=MINI&count=20&start=0";
                GetItemToScrapeUrls:
                    List<string> lstitemForScrap = new List<string>();
             //   pageSource = HttpHelper.getHtmlfromUrl(new Uri(url), "https://www.linkedin.com/groups/" + groupId + "", "", "");


                #region Cookie settings
              //  string CookieDaata = "bcookie=\"v=2&e456608f-798a-4a30-8111-4abf66a2a2d2\"; bscookie=\"v=1&201504281150112c2cb966-888b-44d4-8fe3-2bed850fc88eAQH5LeTYIub6nyWgnwTdMWl9XSSvnwsJ\"; visit=\"v=1&M\"; _chartbeat2=vnNg6xd-hkBwUPD5.1439389439450.1439994463832.10000001; VID=V_2015_08_19_07_4913; ELOQUA=GUID=28AF04F863BF45A78F3AA16B2C88EFBC; BKUT=1439994600; sessionid=\"eyJkamFuZ29fdGltZXpvbmUiOiJBc2lhL0tvbGthdGEifQ:1a1DwL:Z1TtuNNPyqGqvT1Pix66crqU9RA\"; csrftoken=fGdgb242nAkaqdDI0T72TptnHK9Fq9MM; _ga=GA1.2.1307723840.1448360766; L1c=5eba1285; oz_props_fetch_size1_125011638=9; wutan=YjukjFsDQIHEoN/VG0Nwwa8w7dzs308V6oAfSeVHCY8=; L1e=4a2dae59; oz_props_fetch_size1_394473043=5; oz_props_fetch_size1_394482147=1; sl=\"v=1&y7Ik2\"; li_at=AQEDAReDUeMB8eJnAAABUXFNV2wAAAFRcbs0bEsAw1uzWq20X7lGOtdsUgxs31vuFr1q74cnHL82GBdRUIVjbPbKccr0gJVqHj9mqczMKjWVA417H7gRrQeFQARUNssZqNTx0aZZR1hyEmdxvf4iYbF1; liap=true; JSESSIONID=\"ajax:7383772031323678847\"; share_setting=PUBLIC; sdsc=1%3A1SZM1shxDNbLt36wZwCgPgvN58iw%3D; _lipt=0_0MPCZKVCxoBpoHR17D_hDUfM2NiX0FG-oN1B8U9sDtgK_Ydwh1Gw2TGDG8LSwwC-BWGgocnwaixcQM_gvLFHZRCDaMOR9vUNoFFU7Pv4sekUOXFI9ys8jl6QfmKapvABKOlY89bVv5mqx58JvuF7NyP6lyWIckctWO6k6UG0iu1y6ABeq4BLdi4Hx_r4fhtEsbUgeBtzZHE00OAoBcpWzyBorypcrsvu10vjpfQ4JrlkZcgesHUL0zqxRmg6dwbDlfWnQT0C4hwhjEdaTEVNTp; lidc=\"b=LB47:g=319:u=13:i=1449305064:t=1449390866:s=AQG1xLWNXv_mwQpQa_XpXXydwVB0xggq\"; lang=\"v=2&lang=en-us\"; RT=s=1449305300845&r=https%3A%2F%2Fwww.linkedin.com%2Fgroups%2F47307%2Fmembers";


              //  string[] CookieDaatalst = Regex.Split(CookieDaata, ";");
              //  HttpHelper.gCookies = new System.Net.CookieCollection();
              //  System.Net.CookieCollection CookieCollection =   new System.Net.CookieCollection();
                
              //  foreach (string itemlst in CookieDaatalst)
              //  {

              //      try
              //      {
                        
              //          string[] namevalue = Regex.Split(itemlst, "=");

              //          string name = namevalue[0].Replace(" ","");
              //          string value = namevalue[1].Replace(" ", "");

              //          string Domain = "linkedin.com";

              //          System.Net.Cookie cookie = new System.Net.Cookie();
              //          cookie.Name = name;
              //          cookie.Value = value;
              //          cookie.Domain = Domain;
              //          bool IsFound = false;
              //          try
              //          {
                         
              //              foreach (System.Net.Cookie cokieitem in HttpHelper.gCookies)
              //              {

              //                  if (cookie == cokieitem)
              //                  {
              //                      IsFound = true;
              //                      break;
              //                  }
              //              }
              //              if (!IsFound)
              //              {
              //                  HttpHelper.gCookies.Add(cookie);
              //              }
              //          }
              //          catch { };
              //      }
              //      catch { };
              //  }

                #endregion


                pageSource = HttpHelper.getHtmlfromUrl(new Uri(url), "https://www.linkedin.com/groups/" + groupId + "", "", "");
                    string[] arr = Regex.Split(pageSource, ".jpg\",\"name\":");
                    foreach (var itemArr in arr)
                    {
                        if (itemArr.Contains("{\"data\":[{\"profileUrl\""))
                        {
                            continue;
                        }

                        string memberName = string.Empty;
                        string memberId = string.Empty;

                        memberName = Utils.getBetween(itemArr, "\"", "\",\"");
                        memberId = Utils.getBetween(itemArr, "id\":\"", "\",\"");
                        GroupName = GroupName.Replace(",", string.Empty);
                        try
                        {
                            if (!memberName.Contains("data\":[{\""))
                            {
                                GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Added Group Member : " + memberName + " ]");
                                GroupSpecMem.Add(memberId, " [" + GroupName + " ] " + memberName);
                            }

                        }
                        catch (Exception ex)
                        {
                            Console.Write(ex);
                        }


                        //string name = Utils.getBetween(itemArr, "\"", ",").Replace("\"", "");
                        //string memberId = Utils.getBetween(itemArr, "nonIterableMemberId\":", ",").Replace("\"", "");
                        string itemToScrapUrl = "https://www.linkedin.com/profile/view?id=" + memberId + "&authType=name&authToken=2ZLd";
                        if (!lstitemForScrap.Contains(itemToScrapUrl))
                        {
                            gotScrapeUrl = true;
                            lstitemForScrap.Add(itemToScrapUrl);
                        }
                    }
                    if (gotScrapeUrl)
                    {
                        //foreach (var itemForScrap in lstitemForScrap)
                        //{
                        //    if (!lstNewMembers.Contains(itemForScrap))
                        //    {
                        //        if (!obj_ClsScrapGroupMember.CrawlingLinkedInPage(itemForScrap, ref HttpHelper))
                        //        {
                        //            obj_ClsScrapGroupMember.CrawlingPageDataSource(itemForScrap, ref HttpHelper);
                        //        }
                        //        lstNewMembers.Add(itemForScrap);
                        //    }
                        //}

                        startPage = startPage + 10;
                        url = "https://www.linkedin.com/communities-api/v1/memberships/community/" + groupId + "?membershipStatus=MEMBER&start=" + startPage + "&projection=FULL";
                        gotScrapeUrl = false;
                        if (startPage <= 500)
                        {
                            goto GetItemToScrapeUrls;
                        }

                    }



                }
                #endregion
            }
            catch (Exception ex)
            {
            }
            return GroupSpecMem;
        }
예제 #4
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
            {
            }
        }
        public void PostFinalMsg(ref GlobusHttpHelper HttpHelper, Dictionary<string, string> SlectedContacts, string userText, List<string> GrpMemSubjectlist, string msg, string body, string UserEmail, string FromemailId, string FromEmailNam, bool msg_spintaxt, int mindelay, int maxdelay, bool preventMsgSameUser, bool preventMsgGlobalUser)
        {
           // ComposeMsgDbManager objComposeMsgDbMgr = new ComposeMsgDbManager();

            try
            {
                string companyName = string.Empty;
                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;
                string Nstring = string.Empty;
                string connId = string.Empty;
                string FullName = string.Empty;
                string ToMsg = string.Empty;
                string ToCd = string.Empty;


                try
                {
                    DataSet ds_bList = new DataSet();
                    DataSet ds = new DataSet();
                    string MessageText = string.Empty;
                    string PostedMessage = string.Empty;

                    string pageSource = HttpHelper.getHtmlfromUrl(new Uri("https://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).Replace("\n", string.Empty).Replace(">", string.Empty).Replace("<script typ", string.Empty);
                        csrfToken = csrfToken.Trim();
                    }

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

                    //if (IsAllAccounts)
                    //{
                    //    try
                    //    {
                    //        ClsLinkedinMain obj_ClsLinkedinMain = new ClsLinkedinMain();

                    //        Dictionary<string, string> dTotalFriends = obj_ClsLinkedinMain.PostAddMembers(ref HttpHelper, UserEmail);

                    //        Log("[ " + DateTime.Now + " ] => [ No. Of Friends = " + dTotalFriends.Count + " With Username >>> " + UserEmail + " ]");

                    //        if (dTotalFriends.Count > 0)
                    //        {


                    //            PostMessageToAllAccounts(ref HttpHelper, SlectedContacts, dTotalFriends, msg, body, UserEmail, FromemailId, FromEmailNam, mindelay, mindelay);

                    //            int count = SlectedContacts2.Count();

                    //            if (count > 0)
                    //            {
                    //                do
                    //                {

                    //                    PostMessageToAllAccounts(ref HttpHelper, SlectedContacts2, dTotalFriends, msg, body, UserEmail, FromemailId, FromEmailNam, mindelay, mindelay);
                    //                    count = SlectedContacts2.Count();

                    //                } while (count > 0);
                    //            }
                    //        }
                    //        Log("[ " + DateTime.Now + " ] => [ PROCESS COMPLETED With Username >>> " + UserEmail + " ]");
                    //        Log("-----------------------------------------------------------------------------------------------------------------------------------");

                    //        return;
                    //    }
                    //    catch (Exception ex)
                    //    {
                    //    }
                    //}


                    string ContactName = string.Empty;
                    int counter = 1;
                    Dictionary<string, string> SlectedSentContacts = new Dictionary<string, string>();
                    Nstring = string.Empty;
                    ContactName = string.Empty;
                    string ProfileUrl = string.Empty;
                    string ProfileID = string.Empty;
                    foreach (KeyValuePair<string, string> itemChecked in SlectedContacts)
                    {
                        if (Globals.groupStatusString == "API")
                        {
                            ProfileUrl = "https://www.linkedin.com/contacts/view?id=" + itemChecked.Key + "";
                            string profilePageSource = HttpHelper.getHtmlfromUrl(new Uri(ProfileUrl));
                            ProfileID = Utils.getBetween(profilePageSource, "id=", ",").Replace("\"", "");
                        }
                        else
                        {
                            //ProfileUrl = "https://www.linkedin.com/profile/view?id=" + itemChecked.Key + ""; // commented for rodney account
                            //ProfileID = itemChecked.Key;

                            ProfileUrl = "https://www.linkedin.com/contacts/view?id=" + itemChecked.Key + "";
                            string profilePageSource = HttpHelper.getHtmlfromUrl(new Uri(ProfileUrl));
                            ProfileID = Utils.getBetween(profilePageSource, "id=", ",").Replace("\"", "");

                        }

                        if (counter < 50)
                        {
                            SlectedSentContacts.Add(itemChecked.Key, itemChecked.Value);

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

                            if (ds_bList.Tables.Count > 0 && ds_bList.Tables[0].Rows.Count > 0)
                            {
                               // Log("[ " + DateTime.Now + " ] => [ User: "******":", string.Empty).Trim() + " is Added BlackListed List For Send Messages Pls Check ]");

                            }
                            else
                            {

                                try
                                {

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

                                    try
                                    {
                                        FName = itemChecked.Value.Split(' ')[0];
                                        Lname = itemChecked.Value.Split(' ')[1];
                                    }
                                    catch { }

                                    //FullName = FName + " " + Lname;
                                    FullName = itemChecked.Value.Split(':')[0];
                                    try
                                    {
                                        //ContactName = ContactName + "  :  " + FullName;
                                        ContactName = "  :  " + FullName;
                                    }
                                    catch { }

                                    if (ToMsg == string.Empty)
                                    {
                                        //ToMsg += FullName;
                                        ToMsg = FullName;
                                    }
                                    else
                                    {
                                        //ToMsg += ";" + FullName;
                                        ToMsg = ";" + FullName;
                                    }

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

                                    //ToCd = itemChecked.Key;  //for client sudi
                                    ToCd = ProfileID;
                                    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;
                                        Nstring = FString;
                                        connId = ToCd;
                                        //connId += " " + ToCd;
                                    }


                                }
                                catch (Exception ex)
                                {
                                    Console.Write("error : " + ex.StackTrace);
                                }
                                //Nstring += "}";
                            }

                        }
                        else
                        {
                            try
                            {
                                SlectedContacts1.Add(itemChecked.Key, itemChecked.Value);
                            }
                            catch (Exception ex)
                            {
                                Console.Write("error : " + ex.StackTrace);
                            }
                        }
                        counter++;


                        //}

                        if (SlectedContacts1.Count != 0)
                        {
                            foreach (KeyValuePair<string, string> itemremove in SlectedSentContacts)
                            {
                                SlectedContacts1.Remove(itemremove.Key);
                            }
                        }

                        if (msg_spintaxt == true)
                        {
                            try
                            {
                               // body = GlobusSpinHelper.spinLargeText(new Random(), userText);
                                msg = GrpMemSubjectlist[RandomNumberGenerator.GenerateRandom(0, GrpMemSubjectlist.Count - 1)];
                            }
                            catch (Exception ex)
                            {
                                Console.Write("error : " + ex.StackTrace);
                            }
                            try
                            {
                                body = body.Replace("<Insert Name>", FullName);
                                body = body.Replace("<Insert From Email>", FromEmailNam);
                                body = body.Replace("<Company Name>", "");
                                PostMsgSubject = PostMsgSubject.Replace("<Company Name>", "");
                            }
                            catch
                            { }
                        }


                        if (preventMsgSameUser)
                        {
                            try
                            {
                                string Querystring = "Select MsgFrom,MsgToId,MsgTo,MsgSubject,MsgBody From tb_ManageComposeMsg Where MsgFrom ='" + UserEmail + "' and MsgBody = '" + body + "' and MsgToId = " + connId + "";
                                ds = DataBaseHandler.SelectQuery(Querystring, "tb_ManageComposeMsg");
                            }
                            catch (Exception ex)
                            {
                                Console.Write("error : " + ex.StackTrace);
                            }
                        }


                        if (preventMsgGlobalUser)
                        {
                            try
                            {
                                string Querystring = "Select MsgFrom,MsgToId,MsgTo,MsgSubject,MsgBody From tb_ManageComposeMsg Where MsgToId = " + connId + "";
                                ds = DataBaseHandler.SelectQuery(Querystring, "tb_ManageComposeMsg");
                            }
                            catch (Exception ex)
                            {
                                Console.Write("error : " + ex.StackTrace);
                            }
                        }

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

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

                            if (ds.Tables.Count > 0)
                            {
                                if (ds.Tables[0].Rows.Count > 0)
                                {

                                    PostMessage = "";
                                    ResponseStatusMsg = "Already Sent";

                                }
                                else
                                {

                                    PostMessage = "senderEmail=" + FromemailId.Trim() + "&ccInput=&subject=" + Uri.EscapeDataString(msg.ToString()) + "&body=" + Uri.EscapeDataString(body.ToString()) + "&isReply=&isForward=&itemId=&recipients=" + Uri.EscapeUriString(connId) + "&recipientNames=" + Uri.EscapeUriString(Nstring) + "&groupId=&csrfToken=" + csrfToken + "&sourceAlias=" + sourceAlias + "&submit=Send+Message";
                                    ResponseStatusMsg = HttpHelper.postFormDataRef(new Uri("https://www.linkedin.com/inbox/mailbox/message/send"), PostMessage, "https://www.linkedin.com/inbox/", "", "", "XMLHttpRequest", "https://www.linkedin.com", "1");   //ahmed sudi client changes
                                }
                            }
                            else
                            {
                                PostMessage = "senderEmail=" + FromemailId.Trim() + "&ccInput=&subject=" + Uri.EscapeDataString(msg.ToString()) + "&body=" + Uri.EscapeDataString(body.ToString()) + "&isReply=&isForward=&itemId=&recipients=" + Uri.EscapeUriString(connId) + "&recipientNames=" + Uri.EscapeUriString(Nstring) + "&groupId=&csrfToken=" + csrfToken + "&sourceAlias=" + sourceAlias + "&submit=Send+Message";
                                ResponseStatusMsg = HttpHelper.postFormDataRef(new Uri("https://www.linkedin.com/inbox/mailbox/message/send"), PostMessage, "https://www.linkedin.com/inbox/", "", "", "XMLHttpRequest", "https://www.linkedin.com", "1");   //ahmed sudi client changes
                            }

                            if (ResponseStatusMsg.Contains("Your message was successfully sent.") || ResponseStatusMsg.Contains("Tu mensaje ha sido enviado con éxito."))
                            {
                                #region for newConnections only

                                try
                                {
                                    if (Globals.isnew_Connections_only)
                                    {
                                        string query_update = "update tb_New_Connections set status=1 where UserId=" + connId;
                                        DataBaseHandler.UpdateQuery(query_update, "tb_ComposeMessageExcelData");
                                    }
                                }
                                catch (Exception ex)
                                {
                                   // Log("[ " + DateTime.Now + " ] => [ Exception : " + ex + " ]");
                                }




                                #endregion


                                try
                                {
                                    string query_update = "update tb_ComposeMessageExcelData set status=1 where RecipientProfileId=" + connId;
                                    DataBaseHandler.UpdateQuery(query_update, "tb_ComposeMessageExcelData");
                                }
                                catch (Exception ex)
                                {
                                    Console.Write("error : " + ex.StackTrace);
                                }

                                // foreach (var item in SlectedSentContacts)
                                // {
                                try
                                {
                                    string Querystring = "Select ProfileID From tb_BlackListAccount Where ProfileID ='" + itemChecked.Key + "'";
                                    ds_bList = DataBaseHandler.SelectQuery(Querystring, "tb_BlackListAccount");
                                }
                                catch (Exception ex)
                                {
                                    Console.Write("error : " + ex.StackTrace);
                                }

                                if (ds_bList.Tables.Count > 0 && ds_bList.Tables[0].Rows.Count > 0)
                                {
                                   // Log("[ " + DateTime.Now + " ] => [ User: "******":", string.Empty).Trim() + " is Added BlackListed List For Send Messages Pls Check ]");
                                }
                                else
                                {
                                   // Log("[ " + DateTime.Now + " ] => [ Subject Posted : " + msg + " ]");
                                   // Log("[ " + DateTime.Now + " ] => [ Body Text Posted : " + body.ToString() + " ]");
                                   // Log("[ " + DateTime.Now + " ] => [ Message Posted To Account: " + itemChecked.Value.Split(':')[0] + " With Username >>> " + UserEmail + " ]");

                                    ReturnString = "Your message was successfully sent.";
                                    string bdy = string.Empty;

                                    try
                                    {
                                    }
                                    catch { }
                                    if (string.IsNullOrEmpty(bdy))
                                    {
                                        bdy = body.ToString().Replace(",", ":");
                                    }


                                    string CSVHeader = "UserName" + "," + "Subject" + "," + "Body Text" + "," + "ContactName" + "," + "ProfileUrl";
                                    string CSV_Content = UserEmail + "," + msg + "," + bdy + "," + ContactName.Replace(":", string.Empty).Trim() + "," + ProfileUrl;
                                   // CSVUtilities.ExportDataCSVFile(CSVHeader, CSV_Content, Globals.path_ComposeMessageSent);

                                    try
                                    {
                                       // objComposeMsgDbMgr.InsertComposeMsgData(UserEmail, Convert.ToInt32(connId), ContactName, msg, bdy);
                                    }
                                    catch (Exception ex)
                                    {
                                        Console.Write("error : " + ex.StackTrace);
                                    }
                                }
                                //}

                            }

                            else if (ResponseStatusMsg.Contains("There was an unexpected problem that prevented us from completing your request."))
                            {
                                //Log("[ " + DateTime.Now + " ] => [ Error In Message Posting ]");
                               // GlobusFileHelper.AppendStringToTextfileNewLine("Error In Message Posting", Globals.path_ComposeMessage);
                            }
                            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 (Exception ex)
                                {
                                    Console.Write("error : " + ex.StackTrace);
                                }

                                if (string.IsNullOrEmpty(bdy))
                                {
                                    bdy = bdy.ToString().Replace(",", ":");
                                }
                                string CSVHeader = "UserName" + "," + "Subject" + "," + "Body Text" + "," + "ContactName";
                                string CSV_Content = UserEmail + "," + msg + "," + bdy.ToString() + "," + ContactName;
                               // CSVUtilities.ExportDataCSVFile(CSVHeader, CSV_Content, Globals.path_MessageAlreadySentComposeMgs);

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

                            {
                                int delay = RandomNumberGenerator.GenerateRandom(mindelay, maxdelay);
                               GlobusLogHelper.log.Info( "Delay for : " + delay + " Seconds ]");
                                Thread.Sleep(delay * 1000);
                            }

                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                }

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }

        }
        public void PostFinalMsg_WithTag(ref GlobusHttpHelper HttpHelper, Dictionary<string, string> SlectedContacts, List<string> messagesubject, string userText, string msg, string body, string UserEmail, string FromemailId, string FromEmailNam, bool msg_spintaxt, int mindelay, int maxdelay, bool preventMsgSameUser, bool preventMsgGlobalUser)
        {
            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;
                string FString = string.Empty;
                string FullName = string.Empty;
                string ToMsg = string.Empty;

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

                    string pageSource = HttpHelper.getHtmlfromUrl(new Uri("https://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];
                    }
                    #region For all
                    //if (IsAllAccounts)
                    //{
                    //    try
                    //    {
                    //        ClsLinkedinMain obj_ClsLinkedinMain = new ClsLinkedinMain();

                    //        Dictionary<string, string> dTotalFriends = obj_ClsLinkedinMain.PostAddMembers(ref HttpHelper, UserEmail);

                    //        Log("[ " + DateTime.Now + " ] => [ No. Of Friends = " + dTotalFriends.Count + " With Username >>> " + UserEmail + " ]");

                    //        if (dTotalFriends.Count > 0)
                    //        {
                    //            // PostMessageToAllAccounts_1By1(ref HttpHelper, dTotalFriends, msg, body, UserEmail, FromemailId, FromEmailNam, mindelay, maxdelay);
                    //            PostMessageToAllAccounts_1By1(ref HttpHelper, dTotalFriends, messagesubject, userText, UserEmail, FromemailId, FromEmailNam, mindelay, maxdelay);
                    //        }
                    //        Log("[ " + DateTime.Now + " ] => [ PROCESS COMPLETED With Username >>> " + UserEmail + " ]");
                    //        Log("-----------------------------------------------------------------------------------------------------------------------------------");

                    //        return;
                    //    }
                    //    catch (Exception ex)
                    //    {
                    //        GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error -->  PostFinalMsg_1By1() --> 1 --> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace, Globals.Path_LinkedinErrorLogs);
                    //        GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error --> PostFinalMsg_1By1() --> 1 --> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace, Globals.Path_LinkedinComposeMessageErrorLogs);
                    //    }
                    //}
                    #endregion

                    string ProfileUrl = string.Empty;
                    foreach (KeyValuePair<string, string> itemChecked in SlectedContacts)
                    {
                        //ComposeMsgDbManager objComposeMsgDbMgr = new ComposeMsgDbManager();

                        //ProfileUrl = "https://www.linkedin.com/profile/view?id=" + itemChecked.Key + ""; for client ahmad

                        //ProfileUrl = "https://www.linkedin.com/contacts/view?id=" + itemChecked.Key + "";
                        //string profilePageSource = HttpHelper.getHtmlfromUrl1(new Uri(ProfileUrl));
                        //string  ProfileID = Utils.getBetween(profilePageSource, "id=", ",").Replace("\"", "");

                        string ProfileID = string.Empty;
                        if (Globals.groupStatusString == "API")
                        {
                            ProfileUrl = "https://www.linkedin.com/contacts/view?id=" + itemChecked.Key + "";
                            string profilePageSource = HttpHelper.getHtmlfromUrl(new Uri(ProfileUrl));
                            ProfileID = Utils.getBetween(profilePageSource, "id=", ",").Replace("\"", "");
                        }
                        else
                        {
                            ProfileUrl = "https://www.linkedin.com/profile/view?id=" + itemChecked.Key + "";

                            ProfileID = itemChecked.Key;
                        }
                        try
                        {
                            DataSet ds = new DataSet();
                            DataSet ds_bList = new DataSet();
                            string companyName = string.Empty;
                            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;

                            try
                            {
                                FName = itemChecked.Value.Split(' ')[0];
                                FullName = itemChecked.Value.Split(':')[0];
                                companyName = itemChecked.Value.Split(':')[2];
                                ContactName = ContactName + "  :  " + FullName;
                            }
                            catch
                            {
                            }
                           
                            if (ToMsg == string.Empty)
                            {
                                ToMsg += FullName;
                            }
                            else
                            {
                                ToMsg += ";" + FullName;
                            }

                            GlobusLogHelper.log.Info (" Adding Contact " + FullName );
                            string ToCd = ProfileID;//itemChecked.Key; for client ahmed sudi
                            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;

                                if (msg_spintaxt)
                                {

                                    //if (lstSubjectReuse.Count == messagesubject.Count)
                                    //{
                                    //    lstSubjectReuse.Clear();
                                    //}
                                    //foreach (var itemSubject in messagesubject)
                                    //{
                                    //    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;
                                    //    }
                                    //}
                                }
                                else
                                {
                                    tempBody = body;
                                    tempsubject = msg;
                                }


                                GlobusLogHelper.log.Info("Sending Message ");
                                if (!FName.Contains("."))
                                {
                                    //tempBody = tempBody.Replace("<Insert Name>", FullName);
                                    tempBody = tempBody.Replace("Insert Name", FName);
                                    tempBody = tempBody.Replace("<Insert From Email>", FromEmailNam);
                                    tempsubject = tempsubject.Replace("Insert Name", FName);
                                    tempBody = tempBody.Replace("Company Name", companyName);
                                    tempsubject = tempsubject.Replace("Company Name", companyName);
                                }
                                else
                                {
                                    tempBody = tempBody.Replace("Insert Name", FullName);
                                    tempBody = tempBody.Replace("<Insert From Email>", FromEmailNam);
                                    tempBody = tempBody.Replace("<Company Name>", companyName);
                                    tempsubject = tempsubject.Replace("<Company Name>", companyName);
                                }

                                try
                                {
                                    string Querystring = "Select ProfileID From tb_BlackListAccount Where ProfileID ='" + ProfileID + "'";
                                    ds_bList = DataBaseHandler.SelectQuery(Querystring, "tb_BlackListAccount");
                                }
                                catch { }

                                if (preventMsgSameUser)
                                {
                                    try
                                    {
                                        string Querystring = "Select MsgFrom,MsgToId,MsgTo,MsgSubject,MsgBody From tb_ManageComposeMsg Where MsgFrom ='" + UserEmail + "' and MsgBody = '" + tempBody + "' and MsgToId = " + connId + "";
                                        ds = DataBaseHandler.SelectQuery(Querystring, "tb_ManageComposeMsg");
                                    }
                                    catch (Exception ex)
                                    {
                                        Console.Write("error : " + ex.StackTrace);
                                    }
                                }


                                if (preventMsgGlobalUser)
                                {
                                    try
                                    {
                                        string Querystring = "Select MsgFrom,MsgToId,MsgTo,MsgSubject,MsgBody From tb_ManageComposeMsg Where MsgToId = " + connId + "";
                                        ds = DataBaseHandler.SelectQuery(Querystring, "tb_ManageComposeMsg");
                                    }
                                    catch (Exception ex)
                                    {
                                        Console.Write("error : " + ex.StackTrace);
                                    }
                                }

                                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)
                                        {

                                            GlobusLogHelper.log.Info(" User: "******":", string.Empty).Trim() + " is Added BlackListed List For Send Messages Pls Check ");
                                            ResponseStatusMsg = "BlackListed";
                                        }
                                        else
                                        {
                                            tempBody = tempBody.Replace("<Insert Name>", string.Empty).Replace("<Insert Group>", string.Empty).Replace("<Insert From Email>", string.Empty);

                                            PostMessage = "senderEmail=" + FromemailId.Trim() + "&ccInput=&subject=" + Uri.EscapeDataString(tempsubject.ToString()) + "&body=" + Uri.EscapeDataString(tempBody.ToString()) + "&isReply=&isForward=&itemId=&recipients=" + Uri.EscapeUriString(connId) + "&recipientNames=" + Uri.EscapeUriString(Nstring) + "&groupId=&csrfToken=" + csrfToken + "&sourceAlias=" + sourceAlias + "&submit=Send+Message";
                                            ResponseStatusMsg = HttpHelper.postFormDataRef(new Uri("https://www.linkedin.com/inbox/mailbox/message/send"), PostMessage, "https://www.linkedin.com/inbox/", "", "", "XMLHttpRequest", "https://www.linkedin.com", "1");   //ahmed sudi client changes
                                            //PostMessage = "csrfToken=" + csrfToken + "&subject=" + Uri.EscapeDataString(tempsubject.ToString()) + "&body=" + Uri.EscapeDataString(tempBody.ToString()) + "&submit=Send+Message&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";   //commented for client ahmad sudi
                                            //ResponseStatusMsg = HttpHelper.postFormData(new Uri("http://www.linkedin.com/msgToConns"), PostMessage);
                                        }
                                    }
                                }
                                else
                                {
                                    if (ds_bList.Tables.Count > 0 && ds_bList.Tables[0].Rows.Count > 0)
                                    {

                                        GlobusLogHelper.log.Info(" User: "******":", string.Empty).Trim() + " is Added BlackListed List For Send Messages Pls Check ]");
                                        ResponseStatusMsg = "BlackListed";
                                    }
                                    else
                                    {
                                        tempBody = tempBody.Replace("<Insert Name>", string.Empty).Replace("<Insert Group>", string.Empty).Replace("<Insert From Email>", string.Empty);
                                        PostMessage = "senderEmail=" + FromemailId.Trim() + "&ccInput=&subject=" + Uri.EscapeDataString(tempsubject.ToString()) + "&body=" + Uri.EscapeDataString(tempBody.ToString()) + "&isReply=&isForward=&itemId=&recipients=" + Uri.EscapeUriString(connId) + "&recipientNames=" + Uri.EscapeUriString(Nstring) + "&groupId=&csrfToken=" + csrfToken + "&sourceAlias=" + sourceAlias + "&submit=Send+Message";
                                        ResponseStatusMsg = HttpHelper.postFormDataRef(new Uri("https://www.linkedin.com/inbox/mailbox/message/send"), PostMessage, "https://www.linkedin.com/inbox/", "", "", "XMLHttpRequest", "https://www.linkedin.com", "1");   //ahmed sudi client changes


                                        //PostMessage = "csrfToken=" + csrfToken + "&subject=" + Uri.EscapeDataString(tempsubject.ToString()) + "&body=" + Uri.EscapeDataString(tempBody.ToString()) + "&submit=Send+Message&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.")) || (ResponseStatusMsg.Contains("Se ha enviado tu mensaje satisfactoriamente")) || (ResponseStatusMsg.Contains("Sua mensagem foi enviada")))
                                {
                                    GlobusLogHelper.log.Info(" Subject Posted : " + tempsubject.ToString());
                                    GlobusLogHelper.log.Info(" Body Text Posted : " + tempBody.ToString());
                                    GlobusLogHelper.log.Info(" Message posted to " + FullName );

                                    ReturnString = "Your message was successfully sent.";
                                    string bdy = string.Empty;
                                    try
                                    {
                                        bdy = tempBody.ToString().Replace("\r", string.Empty).Replace("\n", " ").Replace(",", " ");
                                    }
                                    catch { }
                                    if (string.IsNullOrEmpty(bdy))
                                    {
                                        bdy = tempBody.ToString().Replace(",", ":");
                                    }

                                    string CSVHeader = "UserName" + "," + "Subject" + "," + "Body Text" + "," + "ContactName" + "," + "ProfileUrl";
                                    string CSV_Content = UserEmail + "," + tempsubject + "," + bdy + "," + ContactName.Replace(":", string.Empty).Trim() + "," + ProfileUrl;
                                   // CSVUtilities.ExportDataCSVFile(CSVHeader, CSV_Content, Globals.path_ComposeMessageSent);

                                    try
                                    {
                                     //   objComposeMsgDbMgr.InsertComposeMsgData(UserEmail, Convert.ToInt32(connId), ContactName, msg, tempBody);
                                    }
                                    catch (Exception ex)
                                    {
                                        Console.Write("error : " + ex.StackTrace);
                                    }
                                    try
                                    {
                                        string query_update = "update tb_ComposeMessageExcelData set status=1 where RecipientProfileId=" + connId;
                                        DataBaseHandler.UpdateQuery(query_update, "tb_ComposeMessageExcelData");
                                    }
                                    catch (Exception ex)
                                    {
                                        Console.Write("error : " + ex.StackTrace);
                                    }

                                }

                                else if (ResponseStatusMsg.Contains("There was an unexpected problem that prevented us from completing your request."))
                                {
                                     GlobusLogHelper.log.Info("Error In Message Posting ");
                                   // GlobusFileHelper.AppendStringToTextfileNewLine("Error In Message Posting", Globals.path_ComposeMessage);
                                }
                                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 (Exception ex)
                                    {
                                        Console.Write("error : " + ex.StackTrace);
                                    }
                                    if (string.IsNullOrEmpty(bdy))
                                    {
                                        bdy = tempBody.ToString().Replace(",", ":");
                                    }
                                    string CSVHeader = "UserName" + "," + "Subject" + "," + "Body Text" + "," + "ContactName";
                                    string CSV_Content = UserEmail + "," + tempsubject + "," + bdy.ToString() + "," + ContactName.Replace(":", string.Empty);
                                    //CSVUtilities.ExportDataCSVFile(CSVHeader, CSV_Content, Globals.path_MessageAlreadySentComposeMgs);

                                    GlobusLogHelper.log.Info("Message Not Posted To Account: " + ContactName.Replace(":", string.Empty) + " because it has sent the same message already");
                                }
                                else if (ResponseStatusMsg.Contains("BlackListed"))
                                {

                                }
                                else
                                {
                                    GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Failed In Message Posting ]");
                                    //GlobusFileHelper.AppendStringToTextfileNewLine("Failed In Message Posting", Globals.path_ComposeMessage);
                                }
                            }
                            catch (Exception ex)
                            {
                                GlobusLogHelper.log.Info("Exception : " + ex);
                            }

                            int delay = RandomNumberGenerator.GenerateRandom(mindelay, maxdelay);
                            GlobusLogHelper.log.Info("Delay for : " + delay + " Seconds ");
                            Thread.Sleep(delay * 1000);
                        }
                        catch (Exception ex)
                        {
                            GlobusLogHelper.log.Info("Exception : " + ex);
                        }
                    }
                }
                catch (Exception ex)
                {
                    GlobusLogHelper.log.Info("Exception : " + ex);
                }

            }
            catch (Exception ex)
            {
                GlobusLogHelper.log.Info("Exception : " + ex);
            }

        }
예제 #7
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 { }
        }
예제 #8
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)
            {
            }
        }