private bool SaveData() { try { var db = SingletonDB.getInstance().DB; var dir = wrapper.GetDictionary(); int des = 0, vas = 0; dir.ForEach(m => des += m.Value.tbl_variable_desactualizada.Count()); dir.ForEach(m => vas += m.Value.tbl_variable_prioritaria.Count()); int total = des + vas + dir.Count(); wrapper = new WrapperObject <string, int, tbl_paciente_prioritario>(); int saved = 0; foreach (var item in dir) { try { db.tbl_paciente_prioritario.Add(item.Value); saved += db.SaveChanges(); } catch (Exception ex) { } } } catch (Exception ex) { IOUtilities.WriteExceptionLog(ex, Configuration.GetClassName <PriorityPatient>()); return(false); } return(true); }
public void Build(byte[] binaryFile, string idArchivo, string nameFile) { try { this.idArchivo = idArchivo; desactualizado = new WrapperObject <tbl_variable_desactualizada, string, string>(); variable_prioritaria = new WrapperObject <tbl_variable_prioritaria, string, string>(); wrapper = new WrapperObject <string, int, tbl_paciente_prioritario>(); IXLTableRows rows = initFileWorkSheet(binaryFile, nameFile); if (rows != null) { ValidatePriorityPatient(rows); SaveData(); //Task.Factory.StartNew(() => ValidatePriorityPatient(rows)); //Task.Factory.StartNew(() => SaveData()); //Task.Factory.StartNew(() => Analsis()); } else { throw new Exception("El archivo enviado no tiene un formato valido para se analizado. Debe ser CSV, XLS o XLSX"); } } catch (Exception ex) { throw ex; } }
/// <summary> private void Analsis() { foreach (var temp in desactualizado.GetList()) { string content = $"{temp.tbl_paciente_prioritario.nombres}@{temp.nombreVariable}@{temp.valorVariable}@{temp.mesesDesactualizado}"; //IOUtilities.WriteLog(content, @"PILOTO", $@"{DateTime.Now.ToString("yyyy-MM-dd HH")}_variable_desactualizadas.txt"); } desactualizado = new WrapperObject <tbl_variable_desactualizada, string, string>(); foreach (var temp in variable_prioritaria.GetList()) { string content = $"{temp.tbl_paciente_prioritario.nombres}@{temp.nombreVariable}@{temp.valorVariable}@{temp.valorUmbral}"; //IOUtilities.WriteLog(content, @"PILOTO", $@"{DateTime.Now.ToString("yyyy-MM-dd HH")}_variable_prioritaria.txt"); } variable_prioritaria = new WrapperObject <tbl_variable_prioritaria, string, string>(); }
//ConcurrentBag<string> log = new ConcurrentBag<string>(); public static void SaveAnalysis(double elepsedtime, ValidatorResult <DTOValidacionArchivo> validator_result) { //JavaScriptSerializer json_serializer = new JavaScriptSerializer(); //json_serializer.MaxJsonLength = 2147483647; //Task<string> output = Task<string>.Factory.StartNew(() => json_serializer.Serialize(validator_result.GetResult())); //Task.Factory.StartNew(() => IOUtilities.WriteLog(output.Result, "PILOTO", $"{DateTime.Now.ToString("yyyy-MM-dd HH")}_json_serializer.json", true)); //Task.Factory.StartNew(() => SaveLog($"{DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss")}\tTiempo actual {elepsedtime}.")); //Task.Factory.StartNew(() => log.ForEach(m => IOUtilities.WriteLog(m, "PILOTO",$"{DateTime.Now.ToString("yyyy-MM-dd HH")}_linea.txt", false))); validator_result.GetResult().OrderBy(m => m.Columna).ForEach(m => IOUtilities.WriteLog(m.ToString(), "PILOTO", $"{DateTime.Now.ToString("yyyy-MM-dd HH")}_result_validation.txt", false)); //Task.Factory.StartNew(() => validator_result.GetResult().OrderBy(m => m.Columna).ForEach(m => IOUtilities.WriteLog(m.ToString(), "PILOTO", $"{DateTime.Now.ToString("yyyy-MM-dd HH")}_result_validation.txt", false))); analisis1.GetList().ForEach(m => IOUtilities.WriteLog(m, "PILOTO", $"{DateTime.Now.ToString("yyyy-MM-dd HH")}_lista_de_errores.txt", false)); //Task task1 = Task.Factory.StartNew(() => analisis1.GetList().ForEach(m => IOUtilities.WriteLog(m, "PILOTO", $"{DateTime.Now.ToString("yyyy-MM-dd HH")}_lista_de_errores.txt", false))); foreach (var keyvalue in analisis1.GetDictionary()) { string concat = ""; //keyvalue.Value.ForEach(m => concat = $"{concat},{m}"); concat = keyvalue.Value.Count() > 0 ? $"@{keyvalue.Value[0]}" : ""; IOUtilities.WriteLog($"{keyvalue.Key}{concat}", "PILOTO", $"{DateTime.Now.ToString("yyyy-MM-dd HH")}_lista_sin_errores.txt", false); } foreach (var keyvalue in analisis2.GetDictionary()) { string concat = ""; keyvalue.Value.ForEach(m => concat = $"{concat}@{m}"); IOUtilities.WriteLog($"{keyvalue.Key}{concat}", "PILOTO", $"{DateTime.Now.ToString("yyyy-MM-dd HH")}_lineas_todos.txt", false); } foreach (var keyvalue in analisis2.GetList()) { IOUtilities.WriteLog($"{keyvalue}", "PILOTO", $"{DateTime.Now.ToString("yyyy-MM-dd HH")}_lineas_todos.txt", false); } analisis1 = new WrapperObject <string, string, string[]>(); analisis2 = new WrapperObject <string, string, string[]>(); //Task.WaitAll(task1); }