Exemplo n.º 1
0
 public List <Report_data> get_reports(string query)
 {
     try
     {
         List <Report_data> all_reports = new List <Report_data>();
         this.open_connection();
         NpgsqlCommand    cmd        = new NpgsqlCommand(query, get_connection());
         NpgsqlDataReader dataReader = cmd.ExecuteReader();
         while (dataReader.Read())
         {
             Report_data report = new Report_data();
             report.login_pass = dataReader["login_pass"].ToString();
             report.login_user = dataReader["login_user"].ToString();
             all_reports.Add(report);
         }
         if (this.connection.State == ConnectionState.Open)
         {
             this.close_connection();
         }
         return(all_reports);
     }
     catch (Exception e)
     {
         if (this.connection.State == ConnectionState.Open)
         {
             this.close_connection();
         }
         return(null);
     }
 }
Exemplo n.º 2
0
        public void Get_reports_screen_shots(IWebDriver driver, Report_data report, string from, string to)
        {
            if (!File.Exists(folder_path + "\\" + report.campaign_name + ".png"))
            {
                Func.check_if_folder_exists(folder_path);
                TextWriter tw = Func.check_if_log_file_exists(file_path);
                try
                {
                    IJavaScriptExecutor js = (IJavaScriptExecutor)driver;
                    var wait_login         = new WebDriverWait(driver, TimeSpan.FromSeconds(20));
                    driver.Navigate().GoToUrl(login_url);
                    js.ExecuteScript("document.querySelector(\"input[type='text']\").value=\"" + report.login_user + "\"");
                    js.ExecuteScript("document.querySelector(\"input[type='password']\").value=\"" + report.login_pass + "\"");
                    js.ExecuteScript("document.querySelector(\"input[type='submit']\").click()");
                    Thread.Sleep(5000);
                    driver.Navigate().GoToUrl("http://publishers.adsterra.com/stats/");

                    string from_slash = from.Replace(@"-", "/");
                    string to_slash   = to.Replace(@"-", "/");

                    IWebElement start = driver.FindElement(By.CssSelector("body > div:nth-child(1) > div.page.statistics > form > span:nth-child(6) > span > input[type='text']"));
                    js.ExecuteScript("$(arguments[0]).prop('readonly',false)", start);
                    js.ExecuteScript("arguments[0].value = arguments[1];", start, from_slash);
                    IWebElement finish = driver.FindElement(By.CssSelector("body > div:nth-child(1) > div.page.statistics > form > span:nth-child(7) > span > input[type='text']"));
                    js.ExecuteScript("$(arguments[0]).prop('readonly',false)", finish);
                    js.ExecuteScript("arguments[0].value = arguments[1];", finish, to_slash);
                    Thread.Sleep(3500);

                    driver.FindElement(By.XPath("/html/body/div[1]/div[2]/form/span[6]/span/input[2]")).SendKeys(Keys.ArrowDown + Keys.Enter);
                    driver.FindElement(By.XPath("html/body/div[1]/div[2]/form/span[8]/input")).Click();
                    Thread.Sleep(5000);
                    int document_height       = Convert.ToInt32((string)js.ExecuteScript("return document.body.scrollHeight").ToString());
                    int client_height         = Convert.ToInt32((string)js.ExecuteScript("return document.body.clientHeight").ToString());
                    int number_of_screen_shot = (document_height / client_height) + 1;
                    for (int i = 0; i < number_of_screen_shot; i++)
                    {
                        Func.take_screenshot(report.campaign_name, folder_path, i + 1);
                        js.ExecuteScript("window.scrollTo(0 ," + client_height + ")");
                        Thread.Sleep(2000);
                    }
                    Func.take_screenshot(report.campaign_name, folder_path);
                    Func.clear_local_storage(driver);
                    driver.Navigate().GoToUrl("http://publishers.adsterra.com/");
                    tw.Close();
                }
                catch (Exception e)
                {
                    Func.clear_local_storage(driver);
                    tw.WriteLine(report.campaign_name + " Exception while screen shot try again");
                    tw.Close();
                }
            }
        }
Exemplo n.º 3
0
        public void generate_screenshot(Report_data report, string path, string folders_name)
        {
            switch (report.advertiser_name)
            {
            case "propellerads":
                Propellerads propellerads = new Propellerads(path + folders_name);
                propellerads.Get_reports_screen_shots(driver, report);
                break;

            case "wigitmedia":
                Wigitmedia wigitmedia = new Wigitmedia(path + folders_name);
                wigitmedia.Get_reports_screen_shots(driver, report);
                break;

            case "AdCash":
                AdCash adcash = new AdCash(path + folders_name);
                if (adcash_users_no_dups.Count() == 0)
                {
                    adcash_users_no_dups[report.login_user] = report;
                    adcash.Get_reports_screen_shots(driver, report);
                    break;
                }
                if (adcash_users_no_dups.ContainsKey(report.login_user))
                {
                    break;
                }
                else
                {
                    adcash_users_no_dups[report.login_user] = report;
                    adcash.Get_reports_screen_shots(driver, report);
                    break;
                }

            case "Revenue_hits":
                Revenue_Hits revenue_hits = new Revenue_Hits(path + folders_name);
                revenue_hits.Get_reports_screen_shots(driver, report);
                break;

            case "Ad6Media":
            {
                Ad6media ad6meida = new Ad6media(path + folders_name);
                ad6meida.Get_reports_screen_shots(driver, report);
                break;
            }

            case "AdsTerra":
            {
                if (adSterraSameUser == 0)
                {
                    AdsTerra adsTerra = new AdsTerra(path + folders_name);
                    adsTerra.Get_reports_screen_shots(driver, report, from, to);
                    adSterraSameUser++;
                }
                break;
            }

            case "Adsupply":
            {
                if (adsupplySameUser == 0)
                {
                    Adsupply adsupply = new Adsupply(path + folders_name);
                    adsupply.Get_reports_screen_shots(driver, report);
                    adsupplySameUser++;
                }
                break;
            }

            case "Pubdirecte":
            {
                if (pubDirecteSameUser == 0)
                {
                    Pubdirecte pubDirecte = new Pubdirecte(path + folders_name);
                    pubDirecte.Get_reports_screen_shots(driver, report, month_formatted[1]);
                    pubDirecteSameUser++;
                }
                break;
            }

            case "Revtop":
            {
                if (revtopSameUser == 0)
                {
                    Revtop revtop = new Revtop(path + folders_name);
                    revtop.Get_reports_screen_shots(driver, report);
                    revtopSameUser++;
                }
                break;
            }

            case "InfinityAds":
            {
                if (infinitySameUser == 0)
                {
                    InfinityAds infinity = new InfinityAds(path + folders_name);
                    infinity.Get_reports_screen_shots(driver, report);
                    infinitySameUser++;
                }
                break;
            }

            case "Exoclick":
            {
                if (exoclickSameUser == 0)
                {
                    Exoclick exoclick = new Exoclick(path + folders_name);
                    exoclick.Get_reports_screen_shots(driver, report, from, to);
                    exoclickSameUser++;
                }
                break;
            }

            case "Popunder":
                if (popunderSameUser == 0)
                {
                    Popunder popunder = new Popunder(path + folders_name);
                    popunder.Get_reports_screen_shots(driver, report, from, to);
                    popunderSameUser++;
                }
                break;

            case "Velis":
                if (report.connection_url.IndexOf("ply2c") > -1)
                {
                    Ply2c velis2C = new Ply2c(path + folders_name, "https://velis.ply2c.com", report.advertiser_name);
                    velis2C.Get_reports_screen_shots(driver, report);
                    break;
                }

                Velis velis = new Velis(path + folders_name);
                velis.Get_reports_screen_shots(driver, report);
                break;

            case "152 Media":
            {
                Ply2c media = new Ply2c(path + folders_name, report.connection_url, report.advertiser_name);
                media.Get_reports_screen_shots(driver, report);
            }
            break;

            case "ad_maven":
            {
                Ply2c admaven = new Ply2c(path + folders_name, report.connection_url, report.advertiser_name);
                admaven.Get_reports_screen_shots(driver, report);
            }
            break;

            case "Adplex":
            {
                Ply2c adplex = new Ply2c(path + folders_name, report.connection_url, report.advertiser_name);
                adplex.Get_reports_screen_shots(driver, report);
            }
            break;

            case "Adstract":
            {
                Ply2c adstract = new Ply2c(path + folders_name, report.connection_url, report.advertiser_name);
                adstract.Get_reports_screen_shots(driver, report);
            }
            break;

            case "Dmg_Dsnr":
            {
                Ply2c dmg = new Ply2c(path + folders_name, report.connection_url, report.advertiser_name);
                dmg.Get_reports_screen_shots(driver, report);
            }
            break;

            case "snw":
            {
                if (report.connection_url.Contains("epom"))
                {
                    SnwEpom epom = new SnwEpom(path + folders_name, "https://n159.epom.com/", report.advertiser_name);
                    epom.Get_reports_screen_shots(driver, report);
                }
                if (report.connection_url.Contains("ply2c"))
                {
                    Ply2c snw = new Ply2c(path + folders_name, report.connection_url, report.advertiser_name);
                    snw.Get_reports_screen_shots(driver, report);
                }
            }
            break;

            case "Matomy":
            {
                Ply2c matomy = new Ply2c(path + folders_name, report.connection_url, report.advertiser_name);
                matomy.Get_reports_screen_shots(driver, report);
            }
            break;

            case "Mango":
            {
                Ply2c mango = new Ply2c(path + folders_name, report.connection_url, report.advertiser_name);
                mango.Get_reports_screen_shots(driver, report);
            }
            break;

            case "HarrenMedia":
            {
                Ply2c harren = new Ply2c(path + folders_name, report.connection_url, report.advertiser_name);
                harren.Get_reports_screen_shots(driver, report);
            }
            break;

            case "BabaNetwork":
            {
                Ply2c baba = new Ply2c(path + folders_name, report.connection_url, report.advertiser_name);
                baba.Get_reports_screen_shots(driver, report);
            }
            break;

            case "mari_media":
            {
                if (report.connection_url.IndexOf("ply2c") > -1)
                {
                    Ply2c ply2c = new Ply2c(path + folders_name, report.connection_url, report.advertiser_name);
                    ply2c.Get_reports_screen_shots(driver, report);
                }
                if (report.connection_url.IndexOf("epom") > -1)
                {
                    MarimediaEpom mari = new MarimediaEpom(path + folders_name, "https://n106.epom.com", report.advertiser_name);
                    mari.Get_reports_screen_shots(driver, report);
                }
            }
            break;

            case "Adland":
            {
                Adland adland = new Adland(path + folders_name, "https://n152.epom.com", report.advertiser_name);
                adland.Get_reports_screen_shots(driver, report);
            }
            break;

            case "Saludo":
            {
                Saludo saludo = new Saludo(path + folders_name, "https://n162.epom.com", report.advertiser_name);
                saludo.Get_reports_screen_shots(driver, report);
            }
            break;

            case "xertive":
            {
                Xertive xertive = new Xertive(path + folders_name, "https://n80.epom.com", report.advertiser_name);
                xertive.Get_reports_screen_shots(driver, report);
            }
            break;
            }
        }