Ejemplo n.º 1
0
        private Image GetImageFromExcel(string path, string range)
        {
            Image     i     = null;
            ExcelLink teste = null;

            try
            {
                teste = new ExcelLink(tempPath, true);
            }
            catch (Exception)
            {
                MessageBox.Show("Ficheiro:" + path + "\n Não encontrado");
                ListaAlertas.Add(new Alertas()
                {
                    Alerta = TipoAlerta.Erro, Ficheiro = path, TimeError = DateTime.Now
                });

                //throw ex ;
            }
            //  teste.copyChart();
            if (teste != null)
            {
                i = teste.CopyImage(range); rngAl.Visible = false;
                teste.closeFile(false);
            }
            else
            {
                // GetAutomatismo();
            }

            return(i);
        }
Ejemplo n.º 2
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();
        }
Ejemplo n.º 3
0
        private void RefreshAutos()
        {
            List <string> Folders = SearchFolder.GetDirectories(setts.MainFolder);

            foreach (var folder in Folders)
            {
                AutomatismosClass.Automatismo t = autos.Automatismos.Find(x => x.Path.Equals(folder));
                if (t == null)
                {
                    //Adicionar Nova pasta á strutura
                }
                else
                {
                    foreach (var file in new DirectoryInfo(@"" + t.Path + "\\01. Script").GetFiles().Where(f => !f.Attributes.HasFlag(FileAttributes.Hidden)))
                    {
                        AutomatismosClass.Automatismo.Ficheiro f = t.Ficheiros.Find(x => x.Nome.Equals(file.Name));
                        if (f == null)
                        { //Adicionar Ficheiro
                        }
                        else
                        {
                            ExcelLink teste = new ExcelLink(t.Path + "\\01. Script\\" + f.Nome);
                            Range     r     = teste.GetRange("C6:E36", "");
                            foreach (Range item in r.Rows)
                            {
                                if (item.Cells[1, 3].Value == null)
                                {
                                    break;
                                }
                                AutomatismosClass.Automatismo.Ficheiro.Consulta lig = f.Ligacoes.Find(l => l.Nome.Equals(item.Cells[1, 3].Value));
                                if (lig == null)
                                { //Adicionar Consulta
                                }
                                else
                                {
                                    lig.Nome            = item.Cells[1, 3].Value;
                                    lig.Ok              = item.Cells[1, 1].Value;
                                    lig.VOlBD_Export    = item.Cells[1, 4].Value;
                                    lig.Seq_Data_Report = item.Cells[1, 5].Value;
                                    lig.DA_Mod          = item.Cells[1, 9].Value.ToString("dd/MM/yyyy");
                                    lig.FO_Mod          = item.Cells[1, 15].Value;
                                    lig.FO_Trans        = (item.Cells[1, 13].value == null ? "" : item.Cells[1, 13].Value.ToString("dd/MM/yyyy"));
                                    if (lig.Range != "")
                                    {
                                        lig.Image = teste.CopyImage(r, lig.Range);
                                    }
                                    teste.closeFile(false);
                                }
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
        private List <AutomatismosClass.Automatismo.Ficheiro.Consulta> GetLigacoesFromFile(string file)
        {
            ExcelLink Tb = new ExcelLink(file, true);
            List <AutomatismosClass.Automatismo.Ficheiro.Consulta> Ligs = new List <AutomatismosClass.Automatismo.Ficheiro.Consulta>();
            Range r = Tb.GetRange("C6", "R25");

            foreach (Range item in r.Rows)
            {
                try
                {
                    if (item.Cells[1, 3].Value == null)
                    {
                        break;
                    }
                    AutomatismosClass.Automatismo.Ficheiro.Consulta Lig = new AutomatismosClass.Automatismo.Ficheiro.Consulta()
                    {
                        Nome            = item.Cells[1, 3].Value,
                        Ok              = item.Cells[1, 1].Value,
                        VOlBD_Export    = item.Cells[1, 4].Value,
                        Seq_Data_Report = item.Cells[1, 5].Value,
                        Range           = (autos.Automatismos.FirstOrDefault(x => x.Ficheiros.Contains(x.Ficheiros.FirstOrDefault(y => y.Ligacoes.Contains(y.Ligacoes.FirstOrDefault(z => z.Nome == item.Cells[1, 3].Value))))).Ficheiros.FirstOrDefault(x => x.Ligacoes.Contains(x.Ligacoes.FirstOrDefault(z => z.Nome == item.Cells[1, 3].Value))).Ligacoes.FirstOrDefault(x => x.Nome == item.Cells[1, 3].Value).Range),
                        // Image = (Range != null )
                        DA_Mod   = item.Cells[1, 9].Value.ToString("dd/MM/yyyy"),
                        FO_Mod   = item.Cells[1, 15].Value,
                        FO_Trans = (item.Cells[1, 13].value == null ? "" : item.Cells[1, 13].Value.ToString("dd/MM/yyyy"))
                    };
                    Ligs.Add(Lig);
                }
                catch (Exception)
                {
                    //throw;
                }
            }
            Tb.closeFile(false);

            return(Ligs);
        }