Beispiel #1
0
        private void UploadS3()
        {
            try
            {
                LoginS3(S3UP);
                string uploadURL = "https://i.randstad.pt/PortalS3/UploadWizard.aspx?CloudClientId=4";
                //IWebElement i = S3.FindElement(By.Id("RandstadTheme_wt101_block_wtActions_wtbtnUpload"));
                //i.Click();
                S3UP.Navigate().GoToUrl(uploadURL);

                foreach (Settings.UploadFile item in setts.UploadFiles.Where(x => x.Refresh.ToLower() == "true"))
                {
                    try
                    {
                        string tempFile = item.Documento;
                        if (tempFile.Contains("{Now}"))
                        {
                            tempFile = tempFile.Replace("{Now}", DateTime.Now.AddDays(-1).ToString("dd-MM-yyyy"));
                        }
                        ExcelLink tempEx = new ExcelLink(tempFile); tempEx.RefreshAll();
                    }
                    catch (Exception ex)
                    {
                        continue;
                    }
                }
                foreach (Settings.UploadFile item in setts.UploadFiles.Where(x => x.Active == "true" || x.Active == "True"))
                {
                    try
                    {
                        string tempFile = item.Documento;
                        if (tempFile.Contains("{Now}"))
                        {
                            tempFile = tempFile.Replace("{Now}", DateTime.Now.AddDays(-1).ToString("dd-MM-yyyy"));
                        }
                        // if (item.Refresh.ToLower() == "true") { ExcelLink tempEx = new ExcelLink(tempFile); tempEx.RefreshAll();  }
                        S3UP.FindElement(By.CssSelector("#WebPatterns_wt3_block_wtMainContent_wt2_wtfiles input[type=file]")).SendKeys(tempFile);
                    }
                    catch (Exception ex)
                    {
                        continue;
                    }
                }
                //WebPatterns_wt3_block_wtMainContent_wt2_wtTempUploadedFileTable
                System.Collections.ObjectModel.ReadOnlyCollection <IWebElement> t;
                do
                {
                    t = S3UP.FindElements(By.CssSelector(".qq-upload-list li"));
                } while (t.Count > 0);
                S3UP.FindElement(By.CssSelector(".qq-upload-button .button.Button")).Click();
            }
            catch (Exception ex)
            {
                WriteLogFile.WriteLog("LogS3.txt", String.Format("[{0}]:{1}->Function:Upload", DateTime.Now, ex.Message));
            }
            uploadDate = DateTime.Now.ToShortDateString();
        }
Beispiel #2
0
        public void DownloadS3()
        {
            try
            {
                setts = ser.Deserialize <Settings>((string)File.ReadAllText(@"Settings.xml"));
                if (nextRefreshS3 > DateTime.Parse(FimS3.Text))
                {
                    nextRefreshS3 = DateTime.Parse(InicioS3.Text);
                }
                else
                {
                    nextRefreshS3 = DateTime.Now.AddMinutes(Int32.Parse(intervaloS3.Text));
                }
                foreach (Settings.Clientes url in setts.ClientesList.Where(x => x.Active == "true"))
                {
                    try { S3.FindElement(By.Id("RandstadTheme_wt101_block_wtHeader_wt99_wt4_wtLogoutLink")).Click(); } catch {
                        //string uploadURL = "https://i.randstad.pt/PortalS3/UploadWizard.aspx?CloudClientId=4";
                        //S3.Navigate().GoToUrl(uploadURL);

                        //foreach (Settings.UploadFile item in setts.UploadFiles)
                        //{
                        //    string tempFile = item.Documento;
                        //    if (tempFile.Contains("{Now}")) tempFile = tempFile.Replace("{Now}", DateTime.Now.AddDays(-1).ToString("dd-MM-yyyy"));
                        //    S3.FindElement(By.CssSelector("#WebPatterns_wt3_block_wtMainContent_wt2_wtfiles input[type=file]")).SendKeys(tempFile);
                        // }
                    }
                    try { Thread.Sleep(1000); S3.Navigate().GoToUrl(DownSetts.Read("S3")); LoginS3(S3); } catch (Exception ex) { WriteLogFile.WriteLog("Log.txt", String.Format("[{0}]:{1}->Function:DownloadS3", DateTime.Now, ex.Message)); }
                    Thread.Sleep(1000);
                    S3.FindElement(By.Id("RandstadTheme_wt101_block_wtMainContent_WebPatterns_wt42_block_wtColumn1_wtStartDate")).Clear(); S3.FindElement(By.Id("RandstadTheme_wt101_block_wtMainContent_WebPatterns_wt42_block_wtColumn1_wtEndDate")).Clear();
                    S3.FindElement(By.Id("RandstadTheme_wt101_block_wtMainContent_WebPatterns_wt42_block_wtColumn1_wtStartDate")).SendKeys(DateTime.Now.Date.ToString("yyyy-MM-dd")); S3.FindElement(By.Id("RandstadTheme_wt101_block_wtMainContent_WebPatterns_wt42_block_wtColumn1_wtEndDate")).SendKeys(DateTime.Now.Date.ToString("yyyy-MM-dd"));
                    S3.FindElement(By.Id("RandstadTheme_wt101_block_wtMainContent_wt68")).Click(); //botao Filtrar

                    Thread.Sleep(1000);
                    System.Collections.ObjectModel.ReadOnlyCollection <IWebElement> options = S3.FindElements(By.CssSelector(".select2-results-dept-0.select2-result.select2-result-selectable"));
                    IWebElement item2 = options.Where(x => x.Text == url.Cliente).FirstOrDefault();
                    item2.Click();
                    Thread.Sleep(1000);
                    System.Collections.ObjectModel.ReadOnlyCollection <IWebElement> linhas = S3.FindElements(By.CssSelector("table.TableRecords.OSFillParent.OSAutoMarginTop tbody tr "));
                    foreach (IWebElement d in linhas)
                    {
                        IWebElement file = d.FindElement(By.CssSelector("td:nth-of-type(2)"));
                        if (File.Exists(pathDownloadS3.Text + "\\" + file.Text))
                        {
                            continue;
                        }
                        d.FindElement(By.CssSelector("td div:not(.OSAutoMarginTop) a")).Click();
                        Thread.Sleep(1000);
                    }
                    Thread.Sleep(1000);
                }
            }catch (Exception ex) { WriteLogFile.WriteLog("LogS3.txt", String.Format("[{0}]:{1}->Function:DownloadS3", DateTime.Now, ex.Message)); }
            ctrlS3 = true;
            S3.Navigate().GoToUrl(DownSetts.Read("S3"));
            delaytimeS3 = DateTime.Now.AddSeconds(30);
            // lastRunS3LB.Text = DateTime.Now.ToString();
        }
Beispiel #3
0
 //Takes near around 35 seconds to call onDisconnect
 public override Task OnDisconnected(bool stopCalled)
 {
     if (!stopCalled)
     {
         var userToBeRemove = _listUserConnetion.Find(o => o.ConnectionID == Context.ConnectionId);
         _listUserConnetion.Remove(userToBeRemove);
         WriteLogFile.WriteLog(string.Format("SignalR disconneted for Username: {0}, ConntectionId: {1}, User count: {2}", userToBeRemove.UserName, userToBeRemove.ConnectionID, _listUserConnetion.Count));
     }
     return(base.OnDisconnected(false));
 }
Beispiel #4
0
        public override Task OnReconnected()
        {
            var checkUserIsExists = _listUserConnetion.Find(o => o.ConnectionID == Context.ConnectionId);

            if (checkUserIsExists != null)
            {
                WriteLogFile.WriteLog(string.Format("Trying to reconnect SignalR for Username: {0}, ConntectionId: {1}, User count: {2}", checkUserIsExists.UserName, checkUserIsExists.ConnectionID, _listUserConnetion.Count));
                SendData(checkUserIsExists.ConnectionID);
            }
            return(base.OnReconnected());
        }
Beispiel #5
0
        public void DownloadCGI()
        {
            string baseUrl = DownSetts.Read("CGI");
            string mainURL = baseUrl + "download/";

            try { CGI.Navigate().GoToUrl(baseUrl); LoginCGI(); Thread.Sleep(1000); } catch (Exception ex) {
                WriteLogFile.WriteLog("Log.txt", String.Format("[{0}]:{1}->Function:DownloadCGI", DateTime.Now, ex.Message));
            }
            setts = ser.Deserialize <Settings>((string)File.ReadAllText(@"Settings.xml"));
            if (nextRefreshCGI > DateTime.Parse(FimCGI.Text))
            {
                nextRefreshCGI = DateTime.Parse(InicioCGI.Text);
            }
            else
            {
                nextRefreshCGI = DateTime.Now.AddMinutes(Int32.Parse(intervaloCGI.Text));
            }
            try
            {
                foreach (Settings.Links url in setts.DownloadLinks.Where(x => x.Active == "True" || x.Active == "true"))
                {
                    CGI.Navigate().GoToUrl(mainURL + url.Link); Thread.Sleep(4000);
                    IWebElement fileName = CGI.FindElement(By.CssSelector(".ui.small.animated.divided.selection.middle.aligned.list .item .header"));
                    string      path     = pathDownloadCGITxt.Text + "\\" + fileName.Text;
                    if (File.Exists(path))
                    {
                        continue;
                    }
                    IWebElement i = CGI.FindElement(By.CssSelector(".ui.green.mini.button"));
                    i.Click(); Thread.Sleep(4000);
                    if (File.Exists(path))
                    {
                        CGIalertas.Add(new Alertas()
                        {
                            Alerta = TipoAlerta.Sucesso, Ficheiro = fileName.Text, TimeError = DateTime.Now
                        });
                    }
                    else
                    {
                        CGIalertas.Add(new Alertas()
                        {
                            Alerta = TipoAlerta.Erro, Ficheiro = fileName.Text, TimeError = DateTime.Now
                        });
                    }
                }
            }
            catch (Exception ex) { WriteLogFile.WriteLog("Log.txt", String.Format("[{0}]:{1}->Function:DownloadCGI", DateTime.Now, ex.Message)); }
            ctrlCGI = true;
            CGI.Navigate().GoToUrl(baseUrl);
            delaytimeCGI = DateTime.Now.AddSeconds(30);
            //  lastRunCGILB.Text = DateTime.Now.ToString();
            this.lastRunCGILB.BeginInvoke((MethodInvoker) delegate() { this.lastRunCGILB.Text = DateTime.Now.ToString(); });
        }
Beispiel #6
0
 public void LoginCGI()
 {
     try
     {
         System.Collections.ObjectModel.ReadOnlyCollection <IWebElement> links = CGI.FindElements(By.CssSelector(".ui.fluid.left.icon.input input"));
         links[0].SendKeys(userCGI.Text);
         links[1].SendKeys(passCGI.Text);
         links[0].Submit();
         DownSetts.Write("User", userCGI.Text, "CGI");
         DownSetts.Write("Pass", passCGI.Text, "CGI");
     }
     catch (Exception ex) { WriteLogFile.WriteLog("Log.txt", String.Format("[{0}]:{1}->Function:LoginCGI", DateTime.Now, ex.Message)); }
 }
Beispiel #7
0
        public override Task OnConnected()
        {
            var us = new UserConnection();

            us.UserName     = Context.Request.QueryString["UserName"].ToString();
            us.ConnectionID = Context.ConnectionId;
            _listUserConnetion.Add(us);
            if (_listUserConnetion != null)
            {
                WriteLogFile.WriteLog(string.Format("SignalR Connected for Username: {0}, ConntectionId: {1}, User count: {2}", us.UserName, us.ConnectionID, _listUserConnetion.Count));
                SendData(us.ConnectionID);
            }
            return(base.OnConnected());
        }
Beispiel #8
0
 public void LoginS3(IWebDriver web)
 {
     try
     {
         System.Collections.ObjectModel.ReadOnlyCollection <IWebElement> links = web.FindElements(By.CssSelector("input.OSFillParent.Mandatory"));
         links[0].SendKeys(userS3.Text);
         links[1].SendKeys(passS3.Text);
         // links[0].Submit();
         web.FindElement(By.CssSelector(".Button.Is_Default.OSFillParent")).Click();
         DownSetts.Write("User", userS3.Text, "S3");
         DownSetts.Write("Pass", passS3.Text, "S3");
     }
     catch (Exception ex) { WriteLogFile.WriteLog("LogS3.txt", String.Format("[{0}]:{1}->Function:LoginS3", DateTime.Now, ex.Message)); }
 }
Beispiel #9
0
        public List <StockExchange> FetchData()
        {
            OleDbConnection      conn        = null;
            List <StockExchange> listStudent = new List <StockExchange>();
            string FilePath         = @"D:\Auth\SignalR\SignalR\Excel\ExcelData.xlsx";
            string ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + FilePath + ";Extended Properties=\"Excel 12.0;ReadOnly=true;HDR=Yes;\"";
            string Command          = "SELECT TOP 4 Id, CompanyName, Price FROM [Sheet1$] ORDER BY Id Desc";

            try
            {
                using (conn = new OleDbConnection(ConnectionString))
                {
                    using (OleDbCommand cmd = new OleDbCommand(Command, conn))
                    {
                        conn.Open();
                        using (OleDbDataAdapter da = new OleDbDataAdapter(cmd))
                        {
                            DataSet id = new DataSet();
                            da.Fill(id);

                            DataTable idtable = id.Tables[0];

                            listStudent = (from s in idtable.AsEnumerable()
                                           select new StockExchange
                            {
                                Id = Convert.ToInt32(s["Id"].ToString()),
                                Name = s["CompanyName"].ToString(),
                                Price = Convert.ToDouble(s["Price"])
                            }).ToList();

                            return(listStudent);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                WriteLogFile.WriteLog(ex.Message);
            }
            finally
            {
                if (conn != null || conn.State == ConnectionState.Open)
                {
                    conn.Close();
                }
            }
            return(listStudent);
        }
Beispiel #10
0
 private void TimersCheck(IWebDriver Web, string url, string caminho, ref bool CTRL, string Inicio, string Fim, ref DateTime nextDown, DateTime delay, ref bool CTRLDel, ref Thread script, ref Thread del, string Portal)
 {
     try
     {
         //inicio
         MethodInfo mi = this.GetType().GetMethod("Download" + Portal);
         if (CTRL && DateTime.Now.ToShortTimeString() == DateTime.Parse(Inicio).ToShortTimeString())
         {
             CTRL   = false;
             script = new Thread(new ThreadStart(delegate() { mi.Invoke(this, null); }));
             script.Start();
         }//fim
         else if (CTRL && DateTime.Now.ToShortTimeString() == DateTime.Parse(Fim).ToShortTimeString())
         {
             script.Abort();
             nextDown = DateTime.Now.AddHours(-2);
             delay    = DateTime.Now.AddMinutes(1);
         }
         else
         { //intervalos
             if (CTRL && DateTime.Now.ToShortTimeString() == nextDown.ToShortTimeString())
             {
                 CTRL   = false;
                 script = new Thread(new ThreadStart(delegate() { mi.Invoke(this, null); }));
                 script.Start();
             }
             else if (CTRLDel && DateTime.Now.ToShortTimeString() == DateTime.Parse(delCGI.Text).ToShortTimeString())
             {
                 CTRLDel = false;
                 del     = new Thread(new ThreadStart(delegate { apagarFicheiros(caminho, Portal); }));
                 del.Start();
             }
             else
             {
                 if (script != null)
                 {
                     if (script.IsAlive)
                     {
                         CGIAlertasSource.ResetBindings(false);
                     }
                 }
                 CGIAlertasSource.Sort = "TimeError DESC";
             }
         }
     }catch (Exception ex) { WriteLogFile.WriteLog("Log.txt", String.Format("[{0}]:{1}->Function:TimerCheck():{2}", DateTime.Now, ex.Message, Portal)); }
 }