예제 #1
0
 public void Click(ShowcaseRankInfo kw, int maxQueryPageNumber, AliAccounts account, bool canInquiry, InquiryMessages msg)
 {
     this.item = kw;
     this.currentPage = 1;
     this.aliAccount = account;
     this.inquiryMessage = msg;
     this.canInquiry = canInquiry;
     this.maxQueryPage = maxQueryPageNumber;
     this.eventX = new ManualResetEvent(false);
     if (this.aliAccount == null)
     {
         this.canInquiry = false;
     }
     this.clickKey = item.RankKeyword;
     searchProductUrl = string.Format(SEARCH_URL1, clickKey.Replace(" ", "+"));
     ClickingEvent(item, @"Clicking " + searchProductUrl);
     browser.DocumentCompleted -= new WebBrowserDocumentCompletedEventHandler(browser_DocumentCompleted);
     browser.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(browser_DocumentCompleted);
     IEHandleUtils.Navigate(browser, searchProductUrl, null, additionalHeaders);
     //browser.Navigate(currentRequestUrl, "_self", null, additionalHeaders);
     eventX.WaitOne(Timeout.Infinite, true);
     item = null;
     aliAccount = null;
     inquiryMessage = null;
     Console.WriteLine("线程池结束!");
 }
예제 #2
0
        public bool DoLogin(AliAccounts account)
        {
            this.UserName = account.Account;
            this.Password = account.Password;
            browser.DocumentCompleted -= new WebBrowserDocumentCompletedEventHandler(browser_LogoinCompleted);
            browser.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(browser_LogoinCompleted);

            string html = HttpHelper.GetHtml(loginUrl);
            string dmtrackPageid = GetDmtrackPageid(html);
            if (string.IsNullOrEmpty(dmtrackPageid))
            {
                return false;
            }
            string token = GetToken(this.UserName, this.Password, dmtrackPageid);
            if (string.IsNullOrEmpty(token))
            {
                return false;
            }
            string st = GetST(token);
            if (string.IsNullOrEmpty(st))
            {
                return false;
            }
            CookieContainer cookieContainer = new CookieContainer();
            bool logined = GetLoginUrl(this.UserName, this.Password, dmtrackPageid, st, ref cookieContainer);
            if (logined == false)
            {
                return false;
            }
            List<Cookie> cookies = IEHandleUtils.GetAllCookies(cookieContainer);
            string cookie_string = string.Empty;
            foreach (Cookie cookie in cookies)
            {
                string cookstring = cookie.Name + "=" + cookie.Value + ";";
                //System.Diagnostics.Trace.WriteLine(cookie.Domain.ToString() + " = " + cookstring);
                cookie_string = cookstring + cookie_string;
                IEHandleUtils.InternetSetCookie(homeUrl, cookie.Name, cookie.Value);
            }
            ShareCookie.Instance.LoginCookie = cookie_string;
            ShareCookie.Instance.LoginCookies = cookies;
            browser.Navigate(homeUrl, "_self", null, Constants.UserAgent);

            eventX.WaitOne(Timeout.Infinite, true);
            Console.WriteLine("登录线程结束!");
            return LoginSuccess;
        }
예제 #3
0
        void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            Workbook workBook = new Workbook();
            try
            {
                workBook.Open(SelectExcelFile);
            }
            catch (Exception ex)
            {
                this.ErrorMsg.Text = "打开选定的Excel文件出错: " + ex.Message;
                return;
            }
            List<AliAccounts> accountList = new List<AliAccounts>();
            foreach (Worksheet sheet in workBook.Worksheets)
            {
                int AccountCol = -1;
                int PasswordCol = -1;
                int CountryCol = -1;
                int LoginIpCol = -1;
                string sheetName = sheet.Name;
                Cells cells = sheet.Cells;
                for (int j = 0; j < cells.MaxDataColumn + 1; j++)
                {
                    string value = sheet.Cells[0, j].StringValue.Trim();
                    if ("account".Equals(value.ToLower()))
                    {
                        AccountCol = j;
                    }
                    if ("password".Equals(value.ToLower()))
                    {
                        PasswordCol = j;
                    }
                    if ("country".Equals(value.ToLower()))
                    {
                        CountryCol = j;
                    }
                    if ("loginip".Equals(value.ToLower()))
                    {
                        LoginIpCol = j;
                    }
                    //System.Diagnostics.Trace.WriteLine(value);
                }

                for (int i = 1; i < cells.MaxDataRow + 1; i++)
                {
                    if (AccountCol == -1)
                    {
                        continue;
                    }
                    string Account = sheet.Cells[i, AccountCol].StringValue.Trim();
                    if (!FormatValidation.IsEmail(Account))
                    {
                        continue;
                    }
                    AliAccounts model = new AliAccounts();
                    model.Account = Account;
                    if (PasswordCol != -1)
                    {
                        model.Password = sheet.Cells[i, PasswordCol].StringValue.Trim();
                    }
                    if (CountryCol != -1)
                    {
                        model.Country = sheet.Cells[i, CountryCol].StringValue.Trim();
                    }
                    if (LoginIpCol != -1)
                    {
                        model.LoginIp = sheet.Cells[i, LoginIpCol].StringValue.Trim();
                    }
                    accountList.Add(model);
                }
            }

            if (accountList.Count == 0)
            {
                this.ErrorMsg.Text = "此Excel中未包含任何邮件数据。请重新选择。";
                return;
            }
            inquiryDAO.ImportAccounts(accountList);
            if (dataGridView.InvokeRequired)
            {
                UpdateDataGridView uActive = LoadDataview;
                this.BeginInvoke(uActive, null);
            }
            else
            {
                LoadDataview();
            }
        }
예제 #4
0
 private void InsertBtn_Click(object sender, EventArgs e)
 {
     AliAccounts model = new AliAccounts();
     model.Account = this.AccountBox.Text.Trim();
     if (string.IsNullOrEmpty(model.Account))
     {
         ErrorMsg.Text = "帐号不能为空.";
         return;
     }
     model.Password = PasswordBox.Text.Trim();
     if (string.IsNullOrEmpty(model.Password))
     {
         ErrorMsg.Text = "密码不能为空.";
         return;
     }
     model.Country = CountryBox.Text.Trim();
     if (string.IsNullOrEmpty(model.Country))
     {
         ErrorMsg.Text = "国家不能为空.";
         return;
     }
     bool existAddress = inquiryDAO.ExistAccount(model.Account);
     if (existAddress)
     {
         ErrorMsg.Text = "帐号已经存在列表中.";
         return;
     }
     inquiryDAO.InsertAccount(model);
     AccountBox.Text = "";
     PasswordBox.Text = "";
     LoadDataview();
 }
예제 #5
0
 public List<AliAccounts> GetAccounts()
 {
     DataTable dt = dbHelper.ExecuteDataTable(
         "SELECT a.AccountId, a.Account, "
         +" a.Password, a.Country, a.LoginIp, a.Enable,"
         +" (select count(1) from InquiryInfos i where a.Account=i.Account) as InquiryNum "
         +" from AliAccounts a", null);
     List<AliAccounts> list = new List<AliAccounts>();
     foreach (DataRow row in dt.Rows)
     {
         AliAccounts kw = new AliAccounts();
         kw.AccountId = Convert.ToInt32(row["AccountId"]);
         kw.Account = (string)row["Account"];
         kw.Password = (string)row["Password"];
         kw.Country = (string)row["Country"];
         kw.LoginIp = (string)row["LoginIp"];
         kw.Enable = Convert.ToInt32(row["Enable"]);
         kw.InquiryNum = Convert.ToInt32(row["InquiryNum"]);
         list.Add(kw);
     }
     return list;
 }
예제 #6
0
 public void InsertAccount(AliAccounts model)
 {
     string sql = @"INSERT INTO AliAccounts(Account, Password, Country)values(@Account, @Password, @Country)";
     SQLiteParameter[] parameter = new SQLiteParameter[]
     {
         new SQLiteParameter("@Account",model.Account),
         new SQLiteParameter("@Password",model.Password),
         new SQLiteParameter("@Country",model.Country)
     };
     dbHelper.ExecuteNonQuery(sql, parameter);
 }
예제 #7
0
        /// <summary>
        /// 查询今天可用来发询盘的帐号
        /// </summary>
        /// <param name="yesterday"></param>
        /// <returns></returns>
        public AliAccounts GetCanInquiryAccount(int today)
        {
            DataTable dt = dbHelper.ExecuteDataTable(
                "select distinct a.AccountId, a.Account, a.Password,a.Country from aliaccounts  a "
                + "left join inquiryInfos i on a.Account=i.Account "
                + "where a.Enable = 1 and (i.Account is null  or i.inquiryDate < " + today + ")", null);
            List<AliAccounts> list = new List<AliAccounts>();
            foreach (DataRow row in dt.Rows)
            {
                AliAccounts kw = new AliAccounts();
                kw.AccountId = Convert.ToInt32(row["AccountId"]);
                kw.Account = (string)row["Account"];
                kw.Password = (string)row["Password"];
                kw.Country = (string)row["Country"];
                list.Add(kw);
            }
            if (list.Count > 0)
            {
                int randomNumber = new Random().Next(0, list.Count - 1);
                return list[randomNumber];
            }

            string sql = "select a.AccountId, a.Account, a.Password, a.Country from aliaccounts a  "
                + "where a.Enable = 1 and (a.LoginTime is null or a.LoginTime < @LoginTime)";
            SQLiteParameter[] parameter = new SQLiteParameter[]
            {
                new SQLiteParameter("@LoginTime", DateTime.Now.AddHours(-2))
            };
            dt = dbHelper.ExecuteDataTable(sql, parameter);
            foreach (DataRow row in dt.Rows)
            {
                AliAccounts kw = new AliAccounts();
                kw.AccountId = Convert.ToInt32(row["AccountId"]);
                kw.Account = (string)row["Account"];
                kw.Password = (string)row["Password"];
                kw.Country = (string)row["Country"];
                list.Add(kw);
            }
            if (list.Count > 0)
            {
                int randomNumber = new Random().Next(0, list.Count - 1);
                return list[randomNumber];
            }
            return null;
        }