Пример #1
0
        public void EndorsingPerDay(object parameter)
        {
            try
            {

                lstEndorsementThread.Add(Thread.CurrentThread);
                lstEndorsementThread = lstEndorsementThread.Distinct().ToList();
                Thread.CurrentThread.IsBackground = true;

                int NoOfEndorsementPerDay = 10;
                int Counter = 0;
                int MinDelay = 20;
                int MaxDelay = 25;

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

                //NoOfEndorsementPerDay = int.Parse(txtNoOfEndorsementPerDay.Text);
                Array paramsArray = new object[1];
                paramsArray = (Array)parameter;

                NoOfEndorsementPerDay = (int)paramsArray.GetValue(1);
                EndorsePeople.no_of_Skils = (int)paramsArray.GetValue(2);
                MinDelay = (int)paramsArray.GetValue(3);
                MaxDelay = (int)paramsArray.GetValue(4);

                KeyValuePair<string, LinkedInMaster> item = (KeyValuePair<string, LinkedInMaster>)paramsArray.GetValue(0);
                AddLoggerEndorsePeople("[ " + DateTime.Now + " ] => [ Logging In With " + item.Key + " ]");

                if (!item.Value.IsLoggedIn)
                {
                    GlobusHttpHelper HttpHelper = new GlobusHttpHelper();
                    LinkedinLogin Login = new LinkedinLogin();
                    Login.accountUser = item.Key;
                    Login.accountPass = item.Value._Password;
                    Login.proxyAddress = item.Value._ProxyAddress;
                    Login.proxyPort = item.Value._ProxyPort;
                    Login.proxyUserName = item.Value._ProxyUsername;
                    Login.proxyPassword = item.Value._ProxyPassword;
                    Login.LoginHttpHelper(ref HttpHelper);

                    if (Login.IsLoggedIn)
                    {
                        AddLoggerEndorsePeople("[ " + DateTime.Now + " ] => [ Logged In With " + item.Key + " ]");
                    }
                    else
                    {
                        AddLoggerEndorsePeople("[ " + DateTime.Now + " ] => [ Not Logged In With " + item.Key + " ]");
                        return;
                    }

                    if (Login.IsLoggedIn)
                    {
                        //GroupStatus dataScrape = new GroupStatus();
                        string query = "Select * From tb_endorsement WHERE  (Username = '******')";
                        DataSet ds = DataBaseHandler.SelectQuery(query, "tb_endorsement");
                        DataTable dt = ds.Tables["tb_endorsement"];
                        string Username = string.Empty;
                        if (dt.Rows.Count > 0)
                        {
                            Username = dt.Rows[0]["Username"].ToString();
                        }

                        if (Username != item.Key)
                        {
                            AddLoggerEndorsePeople("[ " + DateTime.Now + " ] => [ Scraping 1st Connection from Account : " + item.Key + " ]");
                            GroupStatus MemberScrape = new GroupStatus();

                            GroupStatus.moduleLog = "endorsecamp";
                            Dictionary<string, string> Result = MemberScrape.PostAddMembers(ref HttpHelper, Login.accountUser);
                            AddLoggerEndorsePeople("[ " + DateTime.Now + " ] => [ Scraping process completed from Account : " + item.Key + " ]");
                        }

                        AddLoggerEndorsePeople("[ " + DateTime.Now + " ] => [ Starting Endorsing People ]");

                        string SelectQuery = "select * from tb_endorsement where Username = '******' and Status=0";
                        DataSet dst = DataBaseHandler.SelectQuery(SelectQuery, "tb_endorsement");
                        DataTable dt1 = dst.Tables["tb_endorsement"];

                        foreach (DataRow dr in dt1.Rows)
                        {
                            if (Counter <= NoOfEndorsementPerDay)
                            {
                                string FriendId = dr["FriendId"].ToString();

                                LstFriendId.Add(FriendId);
                                Counter++;
                            }
                            else
                            {
                                break;
                            }
                        }
                    }

                    EndorsePeople EnorsePeople = new EndorsePeople();
                    EnorsePeople.Username = item.Key;

                    foreach (string _FriendId in LstFriendId)
                    {
                        int delay = RandomNumberGenerator.GenerateRandom(MinDelay, MaxDelay);

                        try
                        {
                            EnorsePeople.EndorsingPeople(ref HttpHelper, _FriendId);

                            string strQuery = "UPDATE tb_endorsement SET Status='" + "1" + "' WHERE Status='0' AND FriendId ='" + _FriendId + "' AND Username ='******' ";
                            DataBaseHandler.UpdateQuery(strQuery, "tb_endorsement");

                            AddLoggerEndorsePeople("[ " + DateTime.Now + " ] => [ Delay for : " + delay + " Seconds ]");
                            Thread.Sleep(delay * 1000);
                        }
                        catch { }
                    }
                }
            }
            catch (Exception ex)
            {
                GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error -->EndorsingPeople() >>>> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace, Globals.Path_LinkedinErrorLogs);
                GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error --> EndorsingPeople() >>>> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace, Globals.path_EndorsePeople);
            }
            finally
            {
                Count_Endorse--;

                if (Count_Endorse == 0)
                {

                    btnstartEndorse.Invoke(new MethodInvoker(delegate
                    {
                        AddLoggerEndorsePeople("[ " + DateTime.Now + " ] => [ PROCESS COMPLETED ]");
                        AddLoggerEndorsePeople("-------------------------------------------------------------------------------------------------------------------------------");
                        btnStartCampaingEndorsement.Cursor = Cursors.Default;
                    }));
                }
            }
        }
Пример #2
0
        public void EndorsingPeople(object parameter)
        {
            try
            {
                int MinDelay = 20;
                int MaxDelay = 25;

                lstEndorsementThread.Add(Thread.CurrentThread);
                lstEndorsementThread = lstEndorsementThread.Distinct().ToList();
                Thread.CurrentThread.IsBackground = true;

                Array paramsArray = new object[1];
                paramsArray = (Array)parameter;
                KeyValuePair<string, LinkedInMaster> item = (KeyValuePair<string, LinkedInMaster>)paramsArray.GetValue(0);
                MinDelay = (int)paramsArray.GetValue(1);
                MaxDelay = (int)paramsArray.GetValue(2);

                //AddLoggerEndorsePeople("[ " + DateTime.Now + " ] => [ Logging In With " + item.Key + " ]");

                try
                {
                    if (!item.Value.IsLoggedIn)
                    {
                        GlobusHttpHelper HttpHelper = new GlobusHttpHelper();

                        LinkedinLogin Login = new LinkedinLogin();
                        Login.accountUser = item.Key;
                        try
                        {
                            CheckDuplicate.Add(Login.accountUser, Login.accountUser);
                        }
                        catch (Exception)
                        {

                            return;
                        }

                        Login.accountPass = item.Value._Password;
                        Login.proxyAddress = item.Value._ProxyAddress;
                        Login.proxyPort = item.Value._ProxyPort;
                        Login.proxyUserName = item.Value._ProxyUsername;
                        Login.proxyPassword = item.Value._ProxyPassword;
                        Login.LoginHttpHelper(ref HttpHelper);

                        if (Login.IsLoggedIn)
                        {
                            try
                            {
                                Globals.tempDict.Add(item.Key, "");
                                AddLoggerEndorsePeople("[ " + DateTime.Now + " ] => [ Logged In With " + item.Key + " ]");
                                AddLoggerEndorsePeople("[ " + DateTime.Now + " ] => [ Starting Endorsing People ]");
                            }
                            catch
                            { }
                        }
                        else
                        {
                            AddLoggerEndorsePeople("[ " + DateTime.Now + " ] => [ Not Logged In With " + item.Key + " ]");
                            return;
                        }

                        EndorsePeople EnorsePeople = new EndorsePeople();
                        EnorsePeople.Username = item.Key;

                        counter1 = EndorsePeople.Endorse_excelData.Count;

                        foreach (string[] itemArr in EndorsePeople.Endorse_excelData)
                        {
                            int delay = RandomNumberGenerator.GenerateRandom(MinDelay, MaxDelay);

                            EnorsePeople.EndorsingPeople(ref HttpHelper, itemArr[1]);

                            AddLoggerEndorsePeople("[ " + DateTime.Now + " ] => [ Delay for : " + delay + " Seconds ]");
                            Thread.Sleep(delay * 1000);
                        }
                    }
                }
                catch
                {
                    //repeated ID
                }
            }
            catch (Exception ex)
            {
                GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error -->EndorsingPeople() >>>> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace, Globals.Path_LinkedinErrorLogs);
                GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error --> EndorsingPeople() >>>> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace, Globals.path_EndorsePeople);
            }
            finally
            {
                counter1--;

                if (counter1 == 0)
                {
                    btnstartEndorse.Invoke(new MethodInvoker(delegate
                    {
                        AddLoggerEndorsePeople("[ " + DateTime.Now + " ] => [ PROCESS COMPLETED ]");
                        AddLoggerEndorsePeople("----------------------------------------------------------------------------------------------------------------------------------------");
                        btnstartEndorse.Cursor = Cursors.Default;
                    }));
                }
            }
        }