private bool ValidacionesArchivo(string tipoArchivo, int tipoRegla) { var exitoValidacion = 0; try { string regla = null; using (var context = new DISEntities()) { if (tipoRegla == 2 & Errores == 0) { var valorRetorno = context.pa_file_ArchivoValido(IdArchivo); InsertaAuditoria(Convert.ToInt32(UsuarioModificacion), "Se valida archivo", "pa_file_ArchivoValido", IdArchivo); exitoValidacion = int.Parse(valorRetorno.ToString()); if (exitoValidacion == 0) { Errores = Errores + 1; Errors = "Error en Cuadratura de primas"; InsertaAuditoria(Convert.ToInt32(UsuarioModificacion), Errors, NombreArchivo, IdArchivo); return false; } } var resultado = context.pa_file_ObtieneReglavalidacionArchivo(tipoArchivo, tipoRegla); regla = resultado.FirstOrDefault(); } if (!string.IsNullOrEmpty(regla)) { string[] conditionString = null; regla = regla.Replace("@NombreArchivo", NombreArchivo); regla = regla.Replace("@IdArchivo", IdArchivo.ToString()); conditionString = regla.Split(';'); switch (conditionString[0].Substring(0, 3)) { case "SP#": if (ExecSpBool(conditionString[0].Substring(3))) { exitoValidacion = 1; } else { exitoValidacion = 0; } InsertaAuditoria(Convert.ToInt32(UsuarioModificacion), conditionString[0].Substring(3), conditionString[0].Substring(3), IdArchivo); break; } if (exitoValidacion == 1) { switch (conditionString[1].Substring(0, 3)) { case "SP#": if (ExecSpBool(conditionString[1].Substring(3))) { exitoValidacion = 1; } else { exitoValidacion = 0; } InsertaAuditoria(Convert.ToInt32(UsuarioModificacion), conditionString[1].Substring(3), conditionString[1].Substring(3), IdArchivo); break; } } else { switch (conditionString[2].Substring(0, 3)) { case "SP#": if (ExecSpBool(conditionString[2].Substring(3))) { exitoValidacion = 1; } else { exitoValidacion = 0; } InsertaAuditoria(Convert.ToInt32(UsuarioModificacion), conditionString[2].Substring(3), conditionString[2].Substring(3), IdArchivo); break; } } return exitoValidacion == 1; } return true; } catch (Exception ex) { Observacion = ex.Message; return false; } }