public static void Save(string path, ProcessFile process, DateTime fecha) { FechaProceso = fecha; //Copia el template CSS var css = ConfigurationManager.AppSettings["CSS"]; if (!File.Exists(css)) { css = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, css); if (!File.Exists(css)) { css = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "TemplateClassic.css"); } } FileCss = Path.GetFileName(css); File.Copy(css, Path.Combine(path, FileCss)); //Crea el html PageCasos(Path.Combine(path, "Index.html"), process.CasosNegocio, Pagina.CasosNegocio); if (process.CasosNegocio.Config.AutomaticSpecialTest) { PageCasos(Path.Combine(path, "SpecialTests.html"), process.CasosBorde, Pagina.CasosBorde); } else { PageSinCasosBorde(Path.Combine(path, "SpecialTests.html"), process.CasosNegocio); } PageInfo(Path.Combine(path, "Info.html"), process.CasosNegocio); }
private static string Notify(int i, Summary xmlRequest, ProcessFile processFile, string path) { string fechaEjecucion = DateTime.Now.ToString("yyyyMMdd_HHmmss"); string mensaje = string.Empty; xmlRequest.Request.Path = WriteXml(i.ToString(), path, xmlRequest.Request?.ContentArray ?? new string[] { "" }, fechaEjecucion, processFile.CasosNegocio.Name, "Request"); Stopwatch watch = new Stopwatch(); watch.Start(); xmlRequest.Response = HttpCall(xmlRequest.Request.ContentArray, processFile.CasosNegocio.Config); watch.Stop(); xmlRequest.IsCorrect = ValidateSection(xmlRequest.Response.Content, processFile.CasosNegocio.Config.Validations); xmlRequest.TimeOut = watch.Elapsed; if (xmlRequest.IsCorrect) { xmlRequest.Response.Path = WriteXml(i.ToString(), path, xmlRequest.Response.Content, fechaEjecucion, processFile.CasosNegocio.Name, "Response_Ok"); mensaje = string.Format("Caso {0} procesado\tOk\tTimeout: {1}", i, watch.Elapsed); Console.WriteLine(mensaje); } else { xmlRequest.Response.Path = WriteXml(i.ToString(), path, xmlRequest.Response.Content, fechaEjecucion, processFile.CasosNegocio.Name, "Response_Error"); mensaje = string.Format("Caso {0} procesado\tError\tTimeout: {1}", i, watch.Elapsed); Console.WriteLine(mensaje); } return(mensaje); }
public static string[] Start(string path, ProcessFile processFile) { List <string> result = new List <string>(); int i = 1; foreach (var xmlRequest in processFile.CasosNegocio.Excel.RequestXml) { Notify(i, xmlRequest, processFile, path); i++; } return(result.ToArray()); }
private static void ProcesarCasos(Parameters input, ProcessFile fileItem, IHttpHelper http, bool ejecutarCasosNegocio) { input.Workspace = System.IO.Path.GetDirectoryName(fileItem.CasosNegocio.FileTemplate); Console.WriteLine("Config:\t{0}", fileItem.CasosNegocio.FileConfig.Replace(input.Workspace, "")); Console.WriteLine("Xml:\t{0}", fileItem.CasosNegocio.FileTemplate.Replace(input.Workspace, "")); Console.WriteLine("Xls:\t{0}", fileItem.CasosNegocio.FileData.Replace(input.Workspace, "")); //Config Console.WriteLine("\nSOAP"); fileItem.CasosNegocio.Config = new Config(fileItem.CasosNegocio.FileConfig, input.Url); Console.WriteLine("\tURL: {0}", fileItem.CasosNegocio.Config.Url); if (fileItem.CasosNegocio.Config.Headers.Count == 0) { Console.WriteLine("\tError: No existen encabezados soap."); } else { foreach (var item in fileItem.CasosNegocio.Config.Headers) { Console.WriteLine("\t{0}: {1}", item.Key, item.Value); } } //XML fileItem.CasosNegocio.Xml = new Xml(fileItem.CasosNegocio.FileTemplate); if (fileItem.CasosNegocio.Xml.Fields.Count == 0 && ( fileItem.CasosNegocio.Config.Type == Config.TypeProtocol.SOAP || (fileItem.CasosNegocio.Config.Type == Config.TypeProtocol.REST && (fileItem.CasosNegocio.Config.Method == Config.TypeMethod.POST || fileItem.CasosNegocio.Config.Method == Config.TypeMethod.POST) ) ) ) { Console.WriteLine("\nCampos detectatos en XML: {0}", fileItem.CasosNegocio.Xml.Fields.Count); Console.WriteLine("\tError: No existen campos mapeados."); } else { Console.WriteLine("\nCampos detectatos en XML: {0}", fileItem.CasosNegocio.Xml.Fields.Count); if (fileItem.CasosNegocio.Xml.Fields.Count > 0) { foreach (var item in fileItem.CasosNegocio.Xml.Fields) { Console.WriteLine("\t{0}", item); } } else { Console.WriteLine("\tNo existen campos mapeados."); } } var fecha = DateTime.Now; string fechaEjecucion = fecha.ToString("yyyyMMdd_HHmmss"); //Procesar casos de negocio fileItem.CasosNegocio.Excel = new Excel(fileItem.CasosNegocio.FileData, fileItem.CasosNegocio.Xml, 2); if (ejecutarCasosNegocio) { Console.WriteLine("\nEjecución de Casos de Prueba:"); resumenCasosPrueba.Add(new SoapManager(http).Start(Path.Combine(input.Workspace, "Reports", $"{fileItem.CasosNegocio.Name}_{fechaEjecucion}", "Results_Basics"), fileItem.CasosNegocio)); } if (fileItem.CasosNegocio.Config.AutomaticSpecialTest) { //Procesar casos de borde Console.WriteLine("\nEjecución de Casos de Borde:"); fileItem.CasosBorde.Config = fileItem.CasosNegocio.Config; fileItem.CasosBorde.Xml = fileItem.CasosNegocio.Xml; fileItem.CasosBorde.FileData = fileItem.CasosNegocio.FileData; fileItem.CasosBorde.Excel = new ExcelCasoBorde(fileItem.CasosNegocio.Excel.Fields, fileItem.CasosBorde.Xml); resumenCasosBorde.Add(new SoapManager(http).Start(Path.Combine(input.Workspace, "Reports", $"{fileItem.CasosNegocio.Name}_{fechaEjecucion}", "Results_Specials"), fileItem.CasosBorde)); } //Publicar informe Publish.Save(Path.Combine(input.Workspace, "Reports", $"{fileItem.CasosNegocio.Name}_{fechaEjecucion}"), fileItem, fecha); }