private void DoAddMessage()
        {
            var messags = txtMessage.Text.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);

            foreach (var item in txtUsers.Text.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries))
            {
                if (!string.IsNullOrWhiteSpace(item))
                {
                    DeleteTempFollowersFile(item);
                }
            }
            foreach (string strmessage in messags)
            {
                List <TwitterAtomationWa.Message> Messages = new List <Message>();
                if (rdoRandomSelect.Checked)
                {
                    Messages = GetRandomMessages(strmessage, 1, (int)nUNumber.Value);
                }
                else
                {
                    Messages = GetMessages(strmessage, 1);
                }
                int i = 0;
                foreach (var item in Messages)
                {
                    i++;

                    en.Messages.AddObject(item);
                    if (i % 150 == 0)
                    {
                        en.SaveChanges();
                    }
                }
                en.SaveChanges();
            }



            this.BeginInvoke(new MethodInvoker(delegate()
            {
                SsWaiting.Visible = false;
                CanClose          = true;
                EnabledAllControl();
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
                this.Close();
            }));
        }
Пример #2
0
        private static void DeleteUser(Account vUser)
        {
            var db       = new TwitterAtomationWa.DataEntities();
            var messages = db.Messages.Where(aa => aa.SenderscreenName == vUser.ScreenName);

            foreach (var message in messages)
            {
                db.Messages.DeleteObject(message);
                db.SaveChanges();
            }
            var vU = db.Accounts.FirstOrDefault(aa => aa.ScreenName == vUser.ScreenName);

            db.Accounts.DeleteObject(vU);
            db.SaveChanges();

            SaveDeleteUserInTempFile(vUser);
        }
Пример #3
0
        private void SendNextMessage(Account item)
        {
            var Message = db.Messages.Where(aa => aa.DateSended == null && aa.UserID == item.id).OrderBy(a => Guid.NewGuid()).FirstOrDefault();

            if (Message == null)
            {
                return;
            }

            int xMessageCount = GetLastOneHourMessagesCount(Message, item);

            if (xMessageCount > Classes.AppSetting.MessageCount)
            {
                AddMessage("Message Form " + item.ScreenName + " Are exceed Limit");
                Message.nextTryDate = DateTime.Now.AddMinutes(10);
                db.SaveChanges();
                return;
            }

            RequestResult result = RequestResult.ConnectionFailure;

            var bResValue = Classes.TwitterHelper.SendDmMessage(Message.UserID, Message.rScreenName, Message.Message1, out result);

            if (bResValue)
            {
                AddMessage(string.Format("({0}) Message Send To @{1}.", Message.SenderscreenName, Message.rScreenName));

                //db.Messages.DeleteObject(v);
                Message.DateSended = DateTime.Now;
                db.SaveChanges();

                messageGridView.DataSource = null;
                int x = db.Messages.Count(aa => aa.DateSended == null);
                messageGridView.DataSource = db.Messages.Where(aa => aa.DateSended == null).OrderBy(aa => aa.nextTryDate);
            }
            else
            {
                //Message.nextTryDate = DateTime.Now.AddMonths(10);
                try
                {
                    db.Messages.DeleteObject(Message);
                    db.SaveChanges();
                }
                catch
                {
                }
                messageGridView.DataSource = db.Messages.Where(aa => aa.DateSended == null).OrderBy(aa => aa.nextTryDate);
                AddMessage("Message not send to " + Message.rScreenName + ".");
            }
        }
Пример #4
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            var address   = txtAddress.Text;
            var port      = txtPort.Text;
            var proxyname = txtProxyName.Text;

            var username = txtUsername.Text;
            var password = txtPassword.Text;

            Proxy P;

            if (rdoAL.Checked)
            {
                P = new Proxy()
                {
                    DateCreated = DateTime.Now,
                    ProxyAddres = address,
                    ProxyPort   = Convert.ToInt32(port),
                    ProxyName   = proxyname,
                };
            }
            else
            {
                P = new Proxy()
                {
                    DateCreated   = DateTime.Now,
                    ProxyAddres   = address,
                    ProxyUsername = username,
                    ProxyPort     = Convert.ToInt32(port),
                    ProxyName     = proxyname,
                    ProxyPassword = password
                };
            }
            db.Proxies.AddObject(P);
            db.SaveChanges();
            dataGridView1.DataSource = null;
            dataGridView1.DataSource = db.Proxies.ToList();
            dataGridView1.FirstDisplayedScrollingRowIndex = dataGridView1.RowCount - 1;

            txtAddress.Text   = "";
            txtPort.Text      = "";
            txtProxyName.Text = "";
            txtUsername.Text  = "";
            txtPassword.Text  = "";
        }
Пример #5
0
        private void txtDelete_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count > 0)
            {
                if (MessageBox.Show("Do you Want to delete this account(s)?", "Delete Account", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
                {
                    foreach (DataGridViewRow item in dataGridView1.SelectedRows)
                    {
                        var account = item.DataBoundItem as Account;

                        var messages = db.Messages.Where(aa => aa.SenderscreenName == account.ScreenName);
                        foreach (var message in messages)
                        {
                            db.Messages.DeleteObject(message);
                        }
                        db.Accounts.DeleteObject(account);
                        db.SaveChanges();
                    }

                    dataGridView1.DataSource = null;
                    dataGridView1.DataSource = db.Accounts.ToList();
                }
            }
        }
Пример #6
0
        public static bool LoginUser(string username, string password, string proxyaddress = "")
        {
            try
            {
                #region Login Part

                WebProxy P = GetProxy(proxyaddress);

                OAuthTokenResponse requestToken = OAuthUtility.GetRequestToken(Classes.AppSetting.ConsumerKey, Classes.AppSetting.ConsumerSecret, "oob");
                // Direct or instruct the user to the following address:
                Uri authorizationUri = OAuthUtility.BuildAuthorizationUri(requestToken.Token);
                //authenticity_token=aa84db7931040b1ed321372ae2b001ccf4f6e20e&oauth_token=uT3RaA72ld4sIZMwtUxlx1021VRjCkS0VEPyeYj3Fys&session%5Busername_or_email%5D=omidam81&session%5Bpassword%5D=omidomid

                HttpWebRequest R = (HttpWebRequest)HttpWebRequest.Create(authorizationUri);
                R.Proxy = P;
                CookieContainer Cookies = new CookieContainer();
                R.CookieContainer = Cookies;
                using (HttpWebResponse W = (HttpWebResponse)R.GetResponse())
                {
                    System.IO.StreamReader sr = new System.IO.StreamReader(W.GetResponseStream());

                    var str1111 = sr.ReadToEnd();
                    HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
                    doc.LoadHtml(str1111);
                    var    authenticity_token = doc.DocumentNode.SelectSingleNode("//input[@name='authenticity_token']").Attributes["value"].Value;
                    string url = string.Format("authenticity_token={0}&oauth_token={1}&session%5Busername_or_email%5D={2}&session%5Bpassword%5D={3}",
                                               authenticity_token, requestToken.Token, username, password);
                    url = "https://twitter.com/oauth/authorize?" + System.Web.HttpUtility.HtmlDecode(url);

                    HttpWebRequest RP = (HttpWebRequest)HttpWebRequest.Create(url);
                    RP.Proxy = P;


                    RP.Method          = "POST";
                    RP.CookieContainer = new CookieContainer();
                    foreach (Cookie item in W.Cookies)
                    {
                        RP.CookieContainer.Add(item);
                    }
                    HttpWebResponse WP = (HttpWebResponse)RP.GetResponse();
                    sr      = new System.IO.StreamReader(WP.GetResponseStream());
                    str1111 = sr.ReadToEnd();
                    doc     = new HtmlAgilityPack.HtmlDocument();
                    doc.LoadHtml(str1111);
                    #endregion
                    var code = doc.DocumentNode.SelectSingleNode("//kbd[@aria-labelledby='code-desc']/code").InnerHtml;
                    OAuthTokenResponse resp = OAuthUtility.GetAccessToken(Classes.AppSetting.ConsumerKey, Classes.AppSetting.ConsumerSecret, requestToken.Token, code);
                    #region Save To Database
                    var db      = new TwitterAtomationWa.DataEntities();
                    var account = db.Accounts.FirstOrDefault(aa => aa.ScreenName == username);
                    if (account == null)
                    {
                        account = new Account()
                        {
                            DateCreated  = DateTime.Now,
                            TokenSecret  = resp.TokenSecret,
                            Token        = resp.Token,
                            ScreenName   = resp.ScreenName,
                            Name         = password,
                            ProxyAddress = proxyaddress
                        };
                        db.Accounts.AddObject(account);
                        db.SaveChanges();
                    }
                    else
                    {
                        account.Token        = resp.Token;
                        account.TokenSecret  = resp.TokenSecret;
                        account.ProxyAddress = proxyaddress;
                        db.SaveChanges();
                    }
                }



                return(true);

                #endregion
            }
            catch
            {
                return(false);
            }
        }