Ejemplo n.º 1
0
        public void PostGroupMsgUpdate(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);

                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;
                string user = item.Key;

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

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

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

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

                if (chkGroupCollection.InvokeRequired)
                {
                    chkGroupCollection.Invoke(new MethodInvoker(delegate
                    {
                        foreach (string Userid in chkGroupCollection.CheckedItems)
                        {
                            string[] Uid = Userid.Split(':');
                            GetCheckedItems.Add(Uid[1]);
                        }
                    }));
                }

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

                foreach (KeyValuePair<string, Dictionary<string, string>> NewValue in GrpMess)
                {
                    if (NewValue.Key == item.Key)
                    {
                        foreach (KeyValuePair<string, string> GroupId in NewValue.Value)
                        {
                            foreach (string selectedgroup in GetCheckedItems)
                            {
                                if (GroupId.Key.Contains(selectedgroup))
                                {
                                    SelectedItem.Add(GroupId + ":" + selectedgroup);

                                }
                            }
                        }
                    }
                }

                int minDelay = 20;
                int maxDelay = 25;

                if (!string.IsNullOrEmpty(txtGroupUpdateMinDelay.Text) && NumberHelper.ValidateNumber(txtGroupUpdateMinDelay.Text))
                {
                    minDelay = Convert.ToInt32(txtGroupUpdateMinDelay.Text);
                }
                if (!string.IsNullOrEmpty(txtGroupUpdateMaxDelay.Text) && NumberHelper.ValidateNumber(txtGroupUpdateMaxDelay.Text))
                {
                    maxDelay = Convert.ToInt32(txtGroupUpdateMaxDelay.Text);
                }

                if (chkSameMessageForAllGroup.Checked)
                {

                    obj_GroupUpdate.PostGroupSameMessageForAllGroup(ref HttpHelper, SelectedItem, new object[] { item, user }, minDelay, maxDelay);
                    return;
                }

                if (!chkAttachLinkGroupUpdate.Checked == true)
                {
                    obj_GroupUpdate.PostGroupMsg(ref HttpHelper, SelectedItem, new object[] { item, user }, minDelay, maxDelay);

                }
                else
                {
                    obj_GroupUpdate.PostAttachLinkGroupUpdate(ref HttpHelper, SelectedItem, new object[] { item, user }, minDelay, maxDelay);
                }

                Thread.Sleep(2000);
            }
            catch (Exception ex)
            {
                GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error --> Group Update --> PostGroupMsgUpdate() >>>> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace, Globals.Path_LinkedinErrorLogs);
                GlobusFileHelper.AppendStringToTextfileNewLine("DateTime :- " + DateTime.Now + " :: Error --> Group Update --> PostGroupMsgUpdate() >>>> " + ex.Message + "StackTrace --> >>>" + ex.StackTrace, Globals.Path_LinkedinGetGroupMemberErrorLogs);
            }
            finally
            {
                counter_GroupMemberSearch--;
                int cnt = LinkedInManager.linkedInDictionary.Count - 1;
                if (counter_GroupMemberSearch == cnt)
                {
                    if (btnGroupUpdate.InvokeRequired)
                    {
                        btnGroupUpdate.Invoke(new MethodInvoker(delegate
                        {
                            AddLoggerGroupStatus("[ " + DateTime.Now + " ] => [ PROCESS COMPLETED ]");
                            AddLoggerGroupStatus("----------------------------------------------------------------------------------------------------------------------------");
                            btnGroupUpdate.Enabled = true;
                            btnGroupUpdate.Cursor = Cursors.Default;

                        }));
                    }
                }

            }
        }