Пример #1
0
        public void Build(string requestLogFile, string responseLogFile, string contentFolder, string outputFolder)
        {
            // Load requests file
            DataTable requestDataTable = CSVUtilities.LoadCSVInToDataTable(requestLogFile, (Char)9, -1, -1);

            // Get request match list
            List <RequestMatch> requestMatchList = GetRequestMatchList();

            // Process requests
            for (int requestRowIndex = 0; requestRowIndex < requestDataTable.Rows.Count; requestRowIndex++)
            {
                // Get request details
                RequestDetails requestDetails = GetRequestDetails(requestDataTable, requestRowIndex);

                // Identify request type
                RequestMatch requestMatch = GetRequestMatch(requestDetails, requestMatchList);

                if (requestMatch != null)    // Request type that we handle
                {
                    switch (requestMatch.ActionType)
                    {
                    case RequestMatch.ActionTypes.PostBatch:
                        ProcessPostBatch(requestDetails, requestMatch, contentFolder, outputFolder);
                        break;

                    case RequestMatch.ActionTypes.DeleteAll:
                        ProcessDeleteAll(requestDetails, requestMatch, contentFolder, outputFolder);
                        break;

                    case RequestMatch.ActionTypes.PostRun:
                        break;
                    }
                }
            }
        }
        private void ParseFile(string fileContents)
        {
            m_parseResults = CSVUtilities.ParseCSV(fileContents);

            var columnsOutput = m_parseResults.Item2.Aggregate(String.Empty,
                                                               (current, column) => current + String.Format("{0} ,", column));

            columnsOutput = columnsOutput.TrimEnd(new[] { ',' });

            // Show the preview
            PublishResults(m_parseResults.Item1);
        }
Пример #3
0
        private void btnBrowseCsv_Click(object sender, EventArgs e)
        {
            LinkedInManager.linkedInDictionaryExcelInput.Clear();

            try
            {
                using (OpenFileDialog ofd = new OpenFileDialog())
                {
                    ofd.InitialDirectory = Application.StartupPath;
                    ofd.Filter           = "CSV Files (*.csv)|*.csv";
                    listSftwareinputData.Clear();
                    if (ofd.ShowDialog() == DialogResult.OK)
                    {
                        txtsoftwaregeneratedinputfile.Text = ofd.FileName;
                        listArrSftwareinputData            = CSVUtilities.parseCSV(ofd.FileName);
                    }
                }
            }
            catch { }
        }
Пример #4
0
    public async Task <FileStreamResult> ComparableActionProcessingDryRun()
    {
        var supportedYears = await _interLeagueService.GetSupportedYears();

        SystemWideValues systemWideValues = await _interLeagueService.GetSystemWideValues();

        var currentYear = supportedYears.First(x => !x.Finished && x.OpenForPlay);

        IReadOnlyList <LeagueYear> allLeagueYears = await _adminService.GetLeagueYears(currentYear.Year);

        var nextBidTime   = _clock.GetNextBidTime();
        var actionResults = await _adminService.GetActionProcessingDryRun(systemWideValues, currentYear.Year, nextBidTime, allLeagueYears);

        var viewModels = actionResults.Results.LeagueActions.Select(x => new ComparableLeagueActionViewModel(x))
                         .OrderBy(x => x.LeagueID).ThenBy(x => x.PublisherID).ToList();

        var csvStream = CSVUtilities.GetCSVStream(viewModels);

        return(new FileStreamResult(csvStream, "text/csv")
        {
            FileDownloadName = $"ComparableActions_{nextBidTime.ToEasternDate().ToISOString()}.csv"
        });
    }
Пример #5
0
        public void GetRecords(ref GlobusHttpHelper HttpHelper)
        {
            try
            {
                string csrfToken      = string.Empty;
                string LastName       = string.Empty;
                string FirstName      = string.Empty;
                string Industry       = string.Empty;
                string Postalcode     = string.Empty;
                string Distance       = string.Empty;
                string contentSummary = string.Empty;
                string Title          = string.Empty;
                string Company        = string.Empty;
                string school         = string.Empty;
                string Country        = string.Empty;
                string countrycode    = string.Empty;
                string industrycode   = string.Empty;
                string rsid           = string.Empty;

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

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


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

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

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

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

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

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

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

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


                    RecordCount = objIndustry.GetPageNo(FirstGetResponse);

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

                    string CSVHeader   = "PostalCode" + "," + "Distance" + "," + "IndustryType" + "," + "LastName" + "," + "UserName" + "," + "Password" + "," + "Proxy" + "," + "ProxyPwd " + "," + "Number Of Result";                                                                                                                                                                      // + "," + "Connection" + "," + "Recommendations " + "," + "SkillAndExpertise " + "," + "Experience " + "," + " Education" + "," + "Groups" + "," + "UserEmail" + "," + "UserContactNumber" + "," + "PastTitles" + "," + "PastCompany" + "," + "Location" + "," + "Country" + "," + "Industry" + "," + "WebSites" + "," + "LinkedinLogInID" + ",";
                    string CSV_Content = postalCode.Replace(",", ";") + "," + distance.Replace(",", ";") + "," + industryType.Replace(",", ";") + "," + lastName.Replace(",", ";") + "," + accountUser.Replace(",", ";") + "," + accountPass.Replace(",", ";") + "," + prxyadress.Replace(",", ";") + "," + proxyPassword.Replace(",", ";") + "," + RecordCount.ToString().Replace(",", ";"); //+ "," + Connection.Replace(",", ";") + "," + recomandation.Replace(",", string.Empty) + "," + Skill.Replace(",", ";") + "," + LDS_Experience.Replace(",", string.Empty) + "," + EducationCollection.Replace(",", ";") + "," + groupscollectin.Replace(",", ";") + "," + USERemail.Replace(",", ";") + "," + LDS_UserContact.Replace(",", ";") + "," + LDS_PastTitles + "," + AllComapny.Replace(",", ";") + "," + country.Replace(",", ";") + "," + location.Replace(",", ";") + "," + Industry.Replace(",", ";") + "," + Website.Replace(",", ";") + "," + accountUser + ",";// +TypeOfProfile + ",";
                    CSVUtilities.ExportDataCSVFile(CSVHeader, CSV_Content, Globals.path_InBoardProGetDataResultCount);
                }
                catch { }
            }
            catch { }
        }
Пример #6
0
        private void SendInvitation(ref GlobusHttpHelper httpHelper, string pageSource, string key1, string authToken1, string goback1, string firstName_Guest1, string lastName_Guest1)
        {
            try
            {
                Log("[ " + DateTime.Now + " ] => [ Start Sending Invitation With Username >>> " + _UserName + " ]");

                string reason             = string.Empty;
                string existingPositionIC = string.Empty;
                string greeting           = string.Empty;
                string key                  = string.Empty;
                string firstName_Guest      = string.Empty;
                string lastName_Guest       = string.Empty;
                string authToken            = string.Empty;
                string subject              = string.Empty;
                string defaultText          = string.Empty;
                string csrfToken            = string.Empty;
                string sourceAlias          = string.Empty;
                string goback               = string.Empty;
                string userName             = string.Empty;
                string userFirstName        = string.Empty;
                string userLastName         = string.Empty;
                string resultForUserDetails = FindTheUserName(pageSource);

                try
                {
                    resultForUserDetails = resultForUserDetails.Substring(resultForUserDetails.IndexOf("alt="), resultForUserDetails.IndexOf("height") - resultForUserDetails.IndexOf("alt=")).Replace("alt=", string.Empty).Replace("/", string.Empty).Trim();
                    userFirstName        = resultForUserDetails.Split(' ')[0].Replace("\"", string.Empty).Replace(",", string.Empty);
                    userLastName         = resultForUserDetails.Split(' ')[1].Replace("\"", string.Empty).Replace(",", string.Empty);
                }
                catch { }

                firstName_Guest = GetValue(pageSource, "firstName");

                if (string.IsNullOrEmpty(firstName_Guest))
                {
                    firstName_Guest = firstName_Guest1;
                }

                lastName_Guest = GetValue(pageSource, "lastName");

                if (string.IsNullOrEmpty(lastName_Guest))
                {
                    lastName_Guest = lastName_Guest1;
                }

                reason = GetValue(pageSource, "reason");

                existingPositionIC = GetValue(pageSource, "existingPositionIC");
                firstName_Guest    = firstName_Guest.Replace("&quot;", "\"");

                greeting = PersonalNote.Replace("<FIRSTNAME>", firstName_Guest).Replace("<PROFILEFIRSTNAME>", userFirstName).Trim();
                ClsInviteMemberThroughProfileURL.Listgreetmsg = SpinnedListGenerator.GetSpinnedList(new List <string> {
                    greeting
                });
                string messagebody = string.Empty;
                messagebody = greeting;

                if (spintaxsearch)
                {
                    try
                    {
                        messagebody = Listgreetmsg[RandomNumberGenerator.GenerateRandom(0, Listgreetmsg.Count - 1)];
                    }
                    catch
                    { }
                }

                key = GetValue(pageSource, "key");

                if (string.IsNullOrEmpty(key))
                {
                    key = key1;
                }

                authToken = GetValue(pageSource, "authToken");

                if (string.IsNullOrEmpty(authToken))
                {
                    authToken = authToken1;
                }

                subject = GetValue(pageSource, "subject");

                defaultText = GetValue(pageSource, "defaultText");

                csrfToken = GetValue(pageSource, "csrfToken");

                sourceAlias = GetValue(pageSource, "sourceAlias");

                goback = GetValue(pageSource, "goback").Replace("/", "%2F");

                if (string.IsNullOrEmpty(goback))
                {
                    goback = goback1;
                }

                string postData     = "existingPositionIC=&companyName.0=&titleIC.0=&startYearIC.0=&endYearIC.0=&schoolText=&schoolID=&existingPositionIB=&companyName.1=&titleIB.0=&startYearIB.0=&endYearIB.0=&reason=IF&otherEmail=&greeting=" + Uri.EscapeDataString(messagebody) + "&iweReconnectSubmit=Send+Invitation&key=" + key + "&firstName=" + firstName_Guest + "&lastName=" + lastName_Guest + "&authToken=" + authToken + "&authType=name&trk=prof-0-sb-connect-button&iweLimitReached=false&companyID.0=&companyID.1=&schoolID=&schoolcountryCode=&schoolprovinceCode=&javascriptEnabled=false&existingAssociation=Job+Openings%2C+Job+Leads+and+Job+Connections%21&subject=" + subject + "&defaultText=" + defaultText + "&csrfToken=" + csrfToken + "&sourceAlias=" + sourceAlias + "&goback=" + goback + "";
                string postResponse = httpHelper.postFormData(new Uri("http://www.linkedin.com/people/iweReconnectAction"), postData);

                if (postResponse.Contains("Invitation to") || postResponse.Contains("invitación a"))
                {
                    Log("[ " + DateTime.Now + " ] => [ Invitation Sent successfully To >>> " + firstName_Guest + " With Username >>> " + _UserName + " ]");

                    #region Data Saved In CSV File

                    if (!string.IsNullOrEmpty(firstName_Guest) || !string.IsNullOrEmpty(_UserName))
                    {
                        try

                        {
                            string CSVHeader   = "_UserName" + "," + "firstName_Guest" + "," + "lastName_Guest" + "," + "userFirstName" + "," + "userLastName" + ",";
                            string CSV_Content = _UserName + "," + firstName_Guest + "," + lastName_Guest + "," + userFirstName + "," + userLastName + ","; // +TypeOfProfile + ",";
                            CSVUtilities.ExportDataCSVFile(CSVHeader, CSV_Content, Globals.path_LinkedininvitememberResultUrlData);                         //path_LinkedinSearchSearchByProfileURL);
                            Log("[ " + DateTime.Now + " ] => [ Data Saved In CSV File ! ]");
                        }
                        catch { }
                    }

                    #endregion

                    int delay = new Random().Next(MinDelay, MaxDelay);
                    Log("[ " + DateTime.Now + " ] => [ Delay >>> " + delay + " Seconds With Username >>> " + _UserName + " ]");
                    Log("[ " + DateTime.Now + " ] => [---------------------------------------------------------------------]");
                    Thread.Sleep(delay * 1000);
                }
                else if (postResponse.Contains("Request Error") || postResponse.Contains("Solicitud de error"))
                {
                    Log("[ " + DateTime.Now + " ] => [ Request Error With Username >>> " + _UserName + " ]");

                    if (pageSource.Contains("Sorry, there was a problem processing your request. Please try again"))
                    {
                        Log("[ " + DateTime.Now + " ] => [ Sorry, there was a problem processing your request. Please try again With Username >>> " + _UserName + " ]");
                    }

                    if (pageSource.Contains("You have no confirmed email addresses"))
                    {
                        Log("[ " + DateTime.Now + " ] => [ You have no confirmed email addresses With Username >>> " + _UserName + " ]");
                    }
                }
                else
                {
                    if (pageSource.Contains("Sorry, there was a problem processing your request. Please try again"))
                    {
                        Log("[ " + DateTime.Now + " ] => [ Sorry, there was a problem processing your request. Please try again With Username >>> " + _UserName + " ]");
                    }

                    else if (pageSource.Contains("You have no confirmed email addresses"))
                    {
                        Log("[ " + DateTime.Now + " ] => [ You have no confirmed email addresses With Username >>> " + _UserName + " ]");
                    }
                    else
                    {
                        Log("[ " + DateTime.Now + " ] => [ Error in request With Username >>> " + _UserName + " ]");
                    }
                    int delay = new Random().Next(MinDelay, MaxDelay);
                    Log("[ " + DateTime.Now + " ] => [ Delay >>> " + delay + " Seconds With Username >>> " + _UserName + " ]");
                    Log("[ " + DateTime.Now + " ] => [---------------------------------------------------------------------]");
                    Thread.Sleep(delay * 1000);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error >>> " + ex.StackTrace);
            }
        }
Пример #7
0
        public void PostFinalMsgGroupMember(ref GlobusHttpHelper HttpHelper, Dictionary <string, string> SlectedContacts, string msg, string body, string UserName, string FromemailId, string FromEmailNam, int mindelay, int maxdelay)
        {
            try
            {
                string postdata       = string.Empty;
                string postUrl        = string.Empty;
                string ResLogin       = string.Empty;
                string csrfToken      = string.Empty;
                string sourceAlias    = string.Empty;
                string ReturnString   = string.Empty;
                string PostMsgSubject = string.Empty;
                string PostMsgBody    = string.Empty;

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

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

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


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

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

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


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

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

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

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

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

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

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

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


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

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

                                    #endregion

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

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

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

                            int delay = RandomNumberGenerator.GenerateRandom(mindelay, maxdelay);
                            Log("[ " + DateTime.Now + " ] => [ Delay for : " + delay + " Seconds ]");
                            Thread.Sleep(delay * 1000);
                        }
                        catch (Exception ex)
                        {
                            GlobusFileHelper.AppendStringToTextfileNewLine(" Error:" + ex.Message + "StackTrace --> >>>" + ex.StackTrace, Globals.path_MessageGroupMember);
                        }
                    }
                }
                catch (Exception ex)
                {
                    GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error -->  PostFinalMsgGroupMember() --> 1 --> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace, Globals.Path_LinkedinErrorLogs);
                    GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error --> PostFinalMsgGroupMember() --> 1 --> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace, Globals.path_MessageGroupMember);
                }
            }
            catch (Exception ex)
            {
                GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error -->  PostFinalMsgGroupMember() --> 2 --> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace, Globals.Path_LinkedinErrorLogs);
                GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error --> PostFinalMsgGroupMember() --> 2 --> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace, Globals.path_MessageGroupMember);
            }
        }
Пример #8
0
        public void PostFinalMsgGroupMember_1By1(ref GlobusHttpHelper HttpHelper, Dictionary <string, string> SlectedContacts, List <string> GrpMemSubjectlist, List <string> GrpMemMessagelist, string msg, string body, string UserName, string FromemailId, string FromEmailNam, string SelectedGrpName, string grpId, bool mesg_with_tag, bool msg_spintaxt, int mindelay, int maxdelay, bool preventMsgSameGroup, bool preventMsgWithoutGroup, bool preventMsgGlobal)
        {
            try
            {
                MsgGroupMemDbManager objMsgGroupMemDbMgr = new MsgGroupMemDbManager();

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

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

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

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

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

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

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

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

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

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

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

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

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

                            Nstring += "}";

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

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


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

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

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

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



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

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


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

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

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

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

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

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

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

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


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

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

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

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

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

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

                                int delay = RandomNumberGenerator.GenerateRandom(mindelay, maxdelay);
                                Log("[ " + DateTime.Now + " ] => [ Delay for : " + delay + " Seconds ]");
                                Thread.Sleep(delay * 1000);
                            }
                            catch (Exception ex)
                            {
                                //Log("[ " + DateTime.Now + " ] => [ Error:" + ex.Message + "StackTrace --> >>>" + ex.StackTrace + " ]");
                                GlobusFileHelper.AppendStringToTextfileNewLine(" Error:" + ex.Message + "StackTrace --> >>>" + ex.StackTrace, Globals.path_MessageGroupMember);
                            }
                        }
                        catch (Exception ex)
                        {
                            //Log("[ " + DateTime.Now + " ] => [ Error:" + ex.Message + "StackTrace --> >>>" + ex.StackTrace);
                            GlobusFileHelper.AppendStringToTextfileNewLine(" Error:" + ex.Message + "StackTrace --> >>>" + ex.StackTrace, Globals.path_MessageGroupMember);
                        }
                    }
                }
                catch (Exception ex)
                {
                    GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error -->  PostFinalMsgGroupMember() --> 1 --> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace, Globals.Path_LinkedinErrorLogs);
                    GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error --> PostFinalMsgGroupMember() --> 1 --> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace, Globals.path_MessageGroupMember);
                }
            }
            catch (Exception ex)
            {
                GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error -->  PostFinalMsgGroupMember() --> 2 --> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace, Globals.Path_LinkedinErrorLogs);
                GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error --> PostFinalMsgGroupMember() --> 2 --> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace, Globals.Path_LinkedinComposeMessageErrorLogs);
            }
        }
Пример #9
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
            {
            }
        }
Пример #10
0
        public Dictionary <string, string> PostAddOpenGroups(ref GlobusHttpHelper HttpHelper, string SearchKeyword, string username)
        {
            try
            {
                int           count         = 5;
                string        IncodePost    = string.Empty;
                string        PostMessage   = string.Empty;
                string        PostMessage1  = string.Empty;
                string        MemFullName   = string.Empty;
                string        SearchId      = string.Empty;
                string        TotResult     = string.Empty;
                string        Grpurl        = string.Empty;
                string        GrpName       = string.Empty;
                string        IsOpenGrp     = string.Empty;
                string        GrpType       = string.Empty;
                string        GrpId         = string.Empty;
                string        GroupMember   = string.Empty;
                List <string> checkDupGrpId = new List <string>();

                OpenGroupDtl.Clear();

                {
                    count = BoxGroupCount;
                }

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

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

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

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

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

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

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

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

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

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

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

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

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

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


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

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

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

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

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

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

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

                return(OpenGroupDtl);
            }
            catch (Exception ex)
            {
                GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error --> Add Search Groups --> PostAddOpenGroups() >>>> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace, Globals.Path_LinkedinErrorLogs);
                GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error --> Add Search Groups --> PostAddOpenGroups() >>>> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace, Globals.Path_LinkedinAddSearchGroupErrorLogs);
                return(OpenGroupDtl);
            }
        }
        public void GetMultipleRecords(ref GlobusHttpHelper HttpHelper)
        {
            try
            {
                string csrfToken      = string.Empty;
                string LastName       = string.Empty;
                string FirstName      = string.Empty;
                string Industry       = string.Empty;
                string Postalcode     = string.Empty;
                string Distance       = string.Empty;
                string contentSummary = string.Empty;
                string Title          = string.Empty;
                string Company        = string.Empty;
                string school         = string.Empty;
                string Country        = string.Empty;
                string countrycode    = string.Empty;
                string industrycode   = string.Empty;
                string rsid           = string.Empty;

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

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

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

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

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

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

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

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

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

                    RecordCount = objIndustry.GetPageNo(FirstGetResponse);

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

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

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

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

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

                    if (lastName == string.Empty && industryType == string.Empty)
                    {
                        string CSVHeader   = "CentralZipCode" + "," + "DistanceFromZipCode" + "," + "Number Of Result" + "," + "UserName" + "," + "Password" + "," + "Proxy" + "," + "ProxyPwd ";
                        string CSV_Content = postalCode.ToString().Replace(",", ";") + "," + distance.ToString().Replace(",", ";") + "," + RecordCount.ToString().Replace(",", ";") + "," + accountUser.Replace(",", ";") + "," + accountPass.Replace(",", ";") + "," + prxyadress.Replace(",", ";") + "," + proxyPassword.Replace(",", ";");
                        CSVUtilities.ExportDataCSVFile(CSVHeader, CSV_Content, Globals.path_InBoardProGetDataResultCountZipCodeWise);
                    }
                }
                catch { }
            }
            catch { }
        }
Пример #12
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 { }
        }
Пример #13
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)
            {
            }
        }
Пример #14
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("&amp;", "&");

                            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);
            }
        }
Пример #15
0
        public void SendInvitation(ref GlobusHttpHelper HttpHelper, string grpURL, string grpId)
        {
            try
            {
                string FString     = string.Empty;
                string Nstring     = string.Empty;
                string connId      = string.Empty;
                string FullName    = string.Empty;
                string ToMsg       = string.Empty;
                string ContactName = string.Empty;

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

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

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

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

                // SucessfullySendInvitationToFriend();

                //int counter = 1;

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

                        //counter++;

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

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

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

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


                        string ToCd = itemChecked.Key;

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

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

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

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

                    //}
                    Nstring += "}";


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

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

                    //if (response.Contains("You have successfully sent invitations to this group") || response.Contains("Upgrade Your Account"))
                    if (response.Contains("You have successfully sent invitations to this group"))
                    {
                        Log("[ " + DateTime.Now + " ] => [ You have successfully sent invitations to Group : " + grpURL + " With Username : "******"Invite user : "******" ]");
                        string CSVHeader  = "GroupUrl" + "," + "UserName" + "," + "Invite User";
                        string CSVContent = grpURL + "," + accountUser + "," + FullName;
                        CSVUtilities.ExportDataCSVFile(CSVHeader, CSVContent, Globals.path_SentInvitationGroup);
                        // GlobusFileHelper.AppendStringToTextfileNewLine(content, Globals.path_SentInvitationGroup);
                    }
                    else
                    {
                        Log("[ " + DateTime.Now + " ] => [ Couldn't Send Invitation With Username : "******" ]");
                        string CSVHeader  = "GroupUrl" + "," + "UserName";
                        string CSVContent = grpURL + "," + accountUser;
                        CSVUtilities.ExportDataCSVFile(CSVHeader, CSVContent, Globals.path_NotSentInvitationGroup);
                        //GlobusFileHelper.AppendStringToTextfileNewLine(content, Globals.path_NotSentInvitationGroup);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error >>> " + ex.StackTrace);
            }
        }
Пример #16
0
        public string PostAddCompanyUsingUrl(ref GlobusHttpHelper HttpHelper, string username, int mindelay, int maxdelay)
        {
            string ReturnString = string.Empty;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


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

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

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

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

                                #region Data Saved In CSV File

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


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

                                #region Data Saved In CSV File

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

                                #region Data Saved In CSV File

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

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

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

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

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

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