Exemplo n.º 1
0
        public void StartDMMultiThreadedGroupUser(object parameter)
        {
            try
            {
                try
                {
                    if (!IsStop)
                    {
                        lstGroupUpdateThread.Add(Thread.CurrentThread);
                        lstGroupUpdateThread.Distinct().ToList();
                        Thread.CurrentThread.IsBackground = true;
                    }
                }
                catch
                {
                }
                Array paramsArray = new object[1];
                paramsArray = (Array)parameter;

                KeyValuePair<string, LinkedInMaster> item = (KeyValuePair<string, LinkedInMaster>)paramsArray.GetValue(0);
                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;

                GlobusHttpHelper HttpHelper = new GlobusHttpHelper();

                Groups.GroupUpdate obj_GroupUpdate = new Groups.GroupUpdate(Login.accountUser, Login.accountPass, Login.proxyAddress, Login.proxyPort, Login.proxyUserName, Login.proxyPassword);

                obj_GroupUpdate.logger.addToLogger += new EventHandler(AddToLogger_GroupStatus);

                Login.logger.addToLogger += new EventHandler(AddToLogger_GroupStatus);

                if (!Login.IsLoggedIn)
                {
                    Login.LoginHttpHelper(ref HttpHelper);
                }

                AddLoggerGroupStatus("[ " + DateTime.Now + " ] => [ Starting Search For Groups >>> To Send Group Messages ]");

                try
                {
                    if (Login.IsLoggedIn)
                    {
                        GroupStatus dataScrape = new GroupStatus();
                        Dictionary<string, string> Data = new Dictionary<string, string>();
                        Data.Clear();

                        Data = obj_GroupUpdate.PostCreateGroupNames(ref HttpHelper, Login.accountUser);
                        GrpMess.Add(Login.accountUser, Data);
                        obj_GroupUpdate.logger.addToLogger -= new EventHandler(AddToLogger_GroupStatus);

                        if (cmbGroupUser.InvokeRequired)
                        {
                            new Thread(() =>
                            {
                                cmbGroupUser.Invoke(new MethodInvoker(delegate
                                {
                                    cmbGroupUser.Items.Add(Login.accountUser);
                                }));
                            }).Start();
                        }

                        AddLoggerGroupStatus("[ " + DateTime.Now + " ] => [ Groups Added in : " + item.Value._Username + "]");
                    }
                    else
                    {
                        AddLoggerGroupStatus("[ " + DateTime.Now + " ] => [ LinkedIn account : " + Login.accountUser + " has been temporarily restricted ]");
                    }
                }
                catch (Exception ex)
                {
                    GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error --> Group Update --> StartDMMultiThreadedGroupUser() >>>> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace, Globals.Path_LinkedinErrorLogs);
                    GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error --> Group Update --> StartDMMultiThreadedGroupUser() >>>> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace, Globals.Path_LinkedinGetGroupMemberErrorLogs);
                }
                finally
                {
                    counter_GroupMemberSearch--;

                    if (counter_GroupMemberSearch == 0)
                    {
                        if (cmbGroupUser.InvokeRequired)
                        {
                            cmbGroupUser.Invoke(new MethodInvoker(delegate
                            {
                                AddLoggerGroupStatus("[ " + DateTime.Now + " ] => [ PROCESS COMPLETED ]");
                                AddLoggerGroupStatus("-------------------------------------------------------------------------------------------------------------------------");
                                cmbGroupUser.Enabled = true;
                                btnGetUser.Cursor = Cursors.Default;

                            }));
                        }

                        //btnGetUser.Invoke(new MethodInvoker(delegate
                        //{
                        //    AddLoggerGroupStatus("[ " + DateTime.Now + " ] => [ PROCESS COMPLETED ]");
                        //    AddLoggerGroupStatus("-------------------------------------------------------------------------------------------------------------------------");

                        //    btnGetUser.Cursor = Cursors.Default;
                        //}));
                    }
                }
            }
            catch (Exception ex)
            {
                GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error --> Group Update --> StartDMMultiThreadedGroupUser() >>>> " + ex.StackTrace, Globals.Path_LinkedinErrorLogs);
                GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error --> Group Update --> StartDMMultiThreadedGroupUser() >>>> " + ex.StackTrace, Globals.Path_LinkedinGetGroupMemberErrorLogs);
            }
        }