public string Add_Adword(AdwordConfig objAdwordConfig)
        {
            string strReturn = "";
            if (objAdwordConfig.ID > 0)
            {
                var adwordConfig = SeoAutomationEntities.AdwordConfigs.FirstOrDefault(o => o.ID == objAdwordConfig.ID);
                //adwordConfig.ID = objAdwordConfig.ID;
                adwordConfig.URL = objAdwordConfig.URL;
                adwordConfig.KeyWord = objAdwordConfig.KeyWord;
                adwordConfig.IntervalClick = objAdwordConfig.IntervalClick;
                adwordConfig.IsAdsen = objAdwordConfig.IsAdsen;
                adwordConfig.IsBackLink = objAdwordConfig.IsBackLink;
                adwordConfig.LinkQuantityClick = objAdwordConfig.LinkQuantityClick;
                adwordConfig.PageLimit = objAdwordConfig.PageLimit;
                adwordConfig.TextLink = objAdwordConfig.TextLink;
                strReturn = "Updated";
            }
            else
            {
                SeoAutomationEntities.AdwordConfigs.Add(objAdwordConfig);
                strReturn = "Added";
            }

            SeoAutomationEntities.SaveChanges();
            return strReturn;
        }
        public bool Add_Adword(AdwordConfig obAdwordConfig)
        {
            bool status = false;
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(APIURI);
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                // New code:
                var response = client.PostAsJsonAsync("api/GoogleAdword/Add_addWord", obAdwordConfig).Result;

                if (response.EnsureSuccessStatusCode().StatusCode == System.Net.HttpStatusCode.OK)
                {
                    status = true;
                }

            }
            return status;
        }
        public void Add(AdwordConfig objAdwordConfig)
        {
            if (objAdwordConfig.ID > 0)
            {
                var adwordConfig=SeoAutomationEntities.AdwordConfigs.FirstOrDefault(o => o.ID == objAdwordConfig.ID);
                //adwordConfig.ID = objAdwordConfig.ID;
                adwordConfig.URL = objAdwordConfig.URL;
                adwordConfig.KeyWord = objAdwordConfig.KeyWord;
                adwordConfig.IntervalClick = objAdwordConfig.IntervalClick;
                adwordConfig.IsAdsen = objAdwordConfig.IsAdsen;
                adwordConfig.IsBackLink= objAdwordConfig.IsBackLink;
                adwordConfig.LinkQuantityClick = objAdwordConfig.LinkQuantityClick;
                adwordConfig.PageLimit = objAdwordConfig.PageLimit;
                adwordConfig.TextLink = objAdwordConfig.TextLink;
            }
            else
            {
                SeoAutomationEntities.AdwordConfigs.Add(objAdwordConfig);
            }

            SeoAutomationEntities.SaveChanges();
        }
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                AdwordConfig obAdwordConfig = new AdwordConfig();
                obAdwordConfig.URL = txtURL.Text;
                obAdwordConfig.LinkQuantityClick = txtQuantityClick.Text;
                obAdwordConfig.KeyWord = txtKeyWord.Text;
                obAdwordConfig.IntervalClick = txtIntervalClick.Text;
                obAdwordConfig.PageLimit = int.Parse(txtPageLimit.Text);
                obAdwordConfig.IsBackLink = chkBackLink.Checked;
                obAdwordConfig.TextLink = txtTextLink.Text;
                obAdwordConfig.IsAdsen = chkAdsen.Checked;

                _googleAdwordService.Add(obAdwordConfig);
            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
 public string Add_addWord(AdwordConfig adword)
 {
     return _googleAdwordService.Add_Adword(adword);
 }
        private void ViewLink()
        {
            if (numberURL <= lstAdwordConfigs.Count - 1)
            {

                if (lstAdwordConfigs != null && lstAdwordConfigs.Count > 0)
                {
                    objAdwordConfig = lstAdwordConfigs[numberURL];
                }

                string[] arrKeyWord = objAdwordConfig.KeyWord.Split(',');
                string[] arrclickLimit = objAdwordConfig.LinkQuantityClick.Split(',');
                if (arrclickLimit.Length > 0)
                {
                    Random rdClickLimit = new Random();
                    clickLimit = rdClickLimit.Next(int.Parse(arrclickLimit[0]), int.Parse(arrclickLimit[1]));
                    //MessageBox.Show("số lần click tối đa : " + clickLimit.ToString());
                }
                if (arrKeyWord.Length > 0)
                {
                    int i = 0;
                    //rdKeyWord.Next(0,arrKeyWord.Count()-1]
                    Random rdKeyWord = new Random();
                    string strQuery = HttpUtility.UrlEncode(arrKeyWord[i]);
                    // geckoBrower.Dispose();
                    geckoBrower.Navigate(googleURL + strQuery);

                }

            }
            else
            {
                clickLinkTimer.Stop();
                clickLinkTimer.Enabled = false;
                clickLinkTimer.Dispose();
                //MessageBox.Show("Done Number URL : " + numberURL);
                WriteLogIP("NewIP");

                //click adsen

                //clickAdsenTimer = new Timer();
                //clickAdsenTimer.Interval = (1 * 20 * 1000);
                //clickAdsenTimer.Tick += new EventHandler(clickAdsenTimer_Tick);
                //clickAdsenTimer.Start();

                ////Loop khi reset IP

                System.Threading.Thread.Sleep(3 * 60000);
                IPPublic = getPublicIP();
                WriteLog(IPPublic.ToString());
                if (!IPPublic.Equals(IPPublic.ToString()))
                {

                    MessageBox.Show(IPPublic);

                }

                numberURL = 0;
                nsIBrowserHistory historyMan = Xpcom.GetService<nsIBrowserHistory>(Gecko.Contracts.NavHistoryService);
                historyMan = Xpcom.QueryInterface<nsIBrowserHistory>(historyMan);
                historyMan.RemoveAllPages();
                //clear cache

                nsICookieManager CookieMan;
                CookieMan = Xpcom.GetService<nsICookieManager>("@mozilla.org/cookiemanager;1");
                CookieMan = Xpcom.QueryInterface<nsICookieManager>(CookieMan);
                CookieMan.RemoveAll();
                loop_ViewLinkWithIP();

            }
        }