public static ResultStoreProcedure GetLog() { var fileName = $"{AppDomain.CurrentDomain.BaseDirectory}\\App_Data\\log.txt"; var methodBase = MethodBase.GetCurrentMethod(); var resultGetLog = new ResultStoreProcedure { ClassName = methodBase.DeclaringType?.ToString(), Method = methodBase.Name, Status = Status.Ok, Date = DateTime.Now }; try { File.Copy(fileName, @"c:\Temp\log.txt", true); return(resultGetLog); } catch (Exception e) { resultGetLog.Description = e.Message; return(resultGetLog); } finally { Util.WriteLog(resultGetLog); } }
public static void WriteLog(ResultStoreProcedure resultStoreProcedure) { var fileName = $"{AppDomain.CurrentDomain.BaseDirectory}\\App_Data\\log.txt"; using (var sw = new System.IO.StreamWriter(fileName, true)) { sw.WriteLine(resultStoreProcedure.ToString()); } }
public static List <ResultStoreProcedure> InsertCampana(string connectionString, DataInsertTCampana dataInsertTCampana) { var listResultStoreProcedure = new List <ResultStoreProcedure>(); var resultStoreProcedure = new ResultStoreProcedure(MethodBase.GetCurrentMethod(), dataInsertTCampana.ToUri()); listResultStoreProcedure.Add(resultStoreProcedure); try { using (var sqlConnection = new SqlConnection(connectionString)) { sqlConnection.Open(); using (var sqlCommand = new SqlCommand()) { sqlCommand.Connection = sqlConnection; sqlCommand.CommandType = CommandType.StoredProcedure; sqlCommand.CommandText = "pa_Insert_T_Campañas"; sqlCommand.Parameters.Add(new SqlParameter("@nsDescripcion", dataInsertTCampana.Descripcion)); sqlCommand.Parameters.Add(new SqlParameter("@dtDesde", dataInsertTCampana.Desde)); sqlCommand.Parameters.Add(new SqlParameter("@dtHasta", dataInsertTCampana.Hasta)); var returnParam = new SqlParameter { ParameterName = "@return", Direction = ParameterDirection.ReturnValue }; sqlCommand.Parameters.Add(returnParam); sqlCommand.ExecuteNonQuery(); resultStoreProcedure.Code = Convert.ToInt64(returnParam.Value); resultStoreProcedure.Status = resultStoreProcedure.Code > 0 ? Status.Ok : Status.Error; resultStoreProcedure.Description = GetDescriptionError(resultStoreProcedure.Code); Util.WriteLog(resultStoreProcedure); return(listResultStoreProcedure); } } } catch (Exception e) { resultStoreProcedure.Status = Status.Exception; resultStoreProcedure.Description = e.Message; return(listResultStoreProcedure); } }
public static ResultStoreProcedure InsertFichaRamasClasificacion(string connectionString, DataFichaRamasClasificacion dataFichaRamasClasificacion) { var resultStoreProcedure = new ResultStoreProcedure(MethodBase.GetCurrentMethod(), dataFichaRamasClasificacion.ToUri()); try { using (var sqlConnection = new SqlConnection(connectionString)) { sqlConnection.Open(); using (var sqlCommand = new SqlCommand()) { sqlCommand.Connection = sqlConnection; sqlCommand.CommandType = CommandType.StoredProcedure; sqlCommand.CommandText = "pa_InsertE2_RAMASCLASIF_FICHAS"; sqlCommand.Parameters.Add(new SqlParameter("@sIdInterno", dataFichaRamasClasificacion.IdInterno)); sqlCommand.Parameters.Add(new SqlParameter("@sIdClasificacion", dataFichaRamasClasificacion.IdClasificacion)); sqlCommand.Parameters.Add(new SqlParameter("@sUsuario", dataFichaRamasClasificacion.UsuarioCreacion)); var returnParam = new SqlParameter { ParameterName = "@return", Direction = ParameterDirection.ReturnValue }; sqlCommand.Parameters.Add(returnParam); sqlCommand.ExecuteNonQuery(); resultStoreProcedure.Code = Convert.ToInt64(returnParam.Value); resultStoreProcedure.Status = resultStoreProcedure.Code == 1 ? Status.Ok : Status.Error; resultStoreProcedure.Description = GetDescriptionError(resultStoreProcedure.Code); return(resultStoreProcedure); } } } catch (Exception e) { resultStoreProcedure.Status = Status.Exception; resultStoreProcedure.Description = e.Message; return(resultStoreProcedure); } }
public long?pa_Insert_T_Campanas(DataInsertTCampana dataInsertTCampana) { var resultStoreProcedure = new ResultStoreProcedure(MethodBase.GetCurrentMethod(), dataInsertTCampana.ToUri()); try { var returnParam = new SqlParameter { ParameterName = "@return", Direction = ParameterDirection.ReturnValue }; Context.Database.SqlQuery <long>( "exec dbo.[pa_Insert_T_Campañas] @nsDescripcion, @dtDesde, @dtHasta", new SqlParameter("@nsDescripcion", dataInsertTCampana.Descripcion), new SqlParameter("@dtDesde", dataInsertTCampana.Desde), new SqlParameter("@dtHasta", dataInsertTCampana.Hasta), returnParam); resultStoreProcedure.Code = Convert.ToInt64(returnParam.Value); resultStoreProcedure.Status = resultStoreProcedure.Code == 1 ? Status.Ok : Status.Error; return(resultStoreProcedure.Code); } catch (Exception e) { resultStoreProcedure.Status = Status.Exception; resultStoreProcedure.Description = e.Message; throw; } finally { var fileName = $"{AppDomain.CurrentDomain.BaseDirectory}\\App_Data\\log.txt"; using (var sw = new System.IO.StreamWriter(fileName, true)) { sw.WriteLine(resultStoreProcedure.ToString()); } } }
public static List <ResultStoreProcedure> InsertFichaBase(string connectionString, DataFichasBase dataFichasBase) { var listResultStoreProcedure = new List <ResultStoreProcedure>(); var resultStoreProcedure = new ResultStoreProcedure(MethodBase.GetCurrentMethod(), dataFichasBase.ToUri()); listResultStoreProcedure.Add(resultStoreProcedure); try { using (var sqlConnection = new SqlConnection(connectionString)) { sqlConnection.Open(); using (var sqlCommand = new SqlCommand()) { sqlCommand.Connection = sqlConnection; sqlCommand.CommandType = CommandType.StoredProcedure; sqlCommand.CommandText = "pa_InsertFichasBase"; sqlCommand.Parameters.Add(new SqlParameter("@sIdInterno", dataFichasBase.IdInterno)); sqlCommand.Parameters.Add(new SqlParameter("@nsTitulo", dataFichasBase.Titulo)); sqlCommand.Parameters.Add(new SqlParameter("@nIdLineaNegocio", dataFichasBase.IdLineaNegocio)); sqlCommand.Parameters.Add(new SqlParameter("@nCoeditorial", dataFichasBase.Coeditorial ?? (object)DBNull.Value)); sqlCommand.Parameters.Add(new SqlParameter("@nIdioma", dataFichasBase.Idioma)); sqlCommand.Parameters.Add(new SqlParameter("@sCodLinea_P", dataFichasBase.CodLinea_P)); sqlCommand.Parameters.Add(new SqlParameter("@nIdTipoMaterialSAP", dataFichasBase.IdTipoMaterialSAP)); sqlCommand.Parameters.Add(new SqlParameter("@sCodigoGrupo", dataFichasBase.CodigoGrupo)); sqlCommand.Parameters.Add(new SqlParameter("@nIdProyecto", dataFichasBase.IdProyecto ?? (object)DBNull.Value)); sqlCommand.Parameters.Add(new SqlParameter("@nIdProyectoAdicional", dataFichasBase.IdProyectoAdicional ?? (object)DBNull.Value)); sqlCommand.Parameters.Add(new SqlParameter("@nIdProyectoGestion", dataFichasBase.IdProyectoGestion ?? (object)DBNull.Value)); sqlCommand.Parameters.Add(new SqlParameter("@nIdCampaña", dataFichasBase.IdCampana)); sqlCommand.Parameters.Add(new SqlParameter("@nIdUsoComercial", dataFichasBase.IdUsoComercial ?? (object)DBNull.Value)); sqlCommand.Parameters.Add(new SqlParameter("@dtFechaComerializacion", dataFichasBase.FechaComerializacion)); sqlCommand.Parameters.Add(new SqlParameter("@dtNecesidadInfo", dataFichasBase.NecesidadInfo ?? string.Empty)); sqlCommand.Parameters.Add(new SqlParameter("@nIdColeccion", dataFichasBase.IdColeccion ?? (object)DBNull.Value)); sqlCommand.Parameters.Add(new SqlParameter("@nNumColeccion", dataFichasBase.NumColeccion)); sqlCommand.Parameters.Add(new SqlParameter("@nIdSerie", dataFichasBase.IdSerie ?? (object)DBNull.Value)); sqlCommand.Parameters.Add(new SqlParameter("@nNumSerie", dataFichasBase.NumSerie)); sqlCommand.Parameters.Add(new SqlParameter("@nZGeografica", dataFichasBase.ZGeografica ?? (object)DBNull.Value)); sqlCommand.Parameters.Add(new SqlParameter("@nsUsuarioCreacion", dataFichasBase.UsuarioCreacion)); sqlCommand.Parameters.Add(new SqlParameter("@sIdInternoOrigen", dataFichasBase.IdInternoOrigen ?? string.Empty)); sqlCommand.Parameters.Add(new SqlParameter("@sIdInternoOrigenSAP", dataFichasBase.IdInternoOrigenSAP ?? string.Empty)); sqlCommand.Parameters.Add(new SqlParameter("@iIdPais", dataFichasBase.IdPais)); sqlCommand.Parameters.Add(new SqlParameter("@nPorcentajeCoedicion", dataFichasBase.PorcentajeCoedicion ?? (object)DBNull.Value)); sqlCommand.Parameters.Add(new SqlParameter("@nTipoMaterialEducativo", dataFichasBase.TipoMaterialEducativo ?? (object)DBNull.Value)); var returnParam = new SqlParameter { ParameterName = "@return", Direction = ParameterDirection.ReturnValue }; sqlCommand.Parameters.Add(returnParam); sqlCommand.ExecuteNonQuery(); resultStoreProcedure.Code = Convert.ToInt64(returnParam.Value); resultStoreProcedure.Status = resultStoreProcedure.Code == 1 ? Status.Ok : Status.Error; resultStoreProcedure.Description = GetDescriptionError(resultStoreProcedure.Code); Util.WriteLog(resultStoreProcedure); if (resultStoreProcedure.Status == Status.Ok) { resultStoreProcedure = InsertFichaRamasClasificacion(connectionString, new DataFichaRamasClasificacion { IdInterno = dataFichasBase.IdInterno, IdClasificacion = dataFichasBase.JerarquiaProducto, UsuarioCreacion = dataFichasBase.UsuarioCreacion }); listResultStoreProcedure.Add(resultStoreProcedure); Util.WriteLog(resultStoreProcedure); } return(listResultStoreProcedure); } } } catch (Exception e) { resultStoreProcedure.Status = Status.Exception; resultStoreProcedure.Description = e.Message; return(listResultStoreProcedure); } }
public long pa_InsertFichasBase(DataFichasBase dataFichasBase) { var resultStoreProcedure = new ResultStoreProcedure(MethodBase.GetCurrentMethod(), dataFichasBase.ToUri()); try { var result = Context.Database.SqlQuery <long>("exec dbo.[pa_InsertFichasBase] " + "@sIdInterno, " + "@nsTitulo, " + "@nIdLineaNegocio, " + "@nCoeditorial, " + "@nIdioma, " + "@sCodLinea_P, " + "@nIdTipoMaterialSAP, " + "@sCodigoGrupo, " + "@nIdProyecto, " + "@nIdProyectoAdicional, " + "@nIdProyectoGestion, " + "@nIdCampaña, " + "@nIdUsoComercial, " + "@dtFechaComerializacion, " + "@dtNecesidadInfo, " + "@nIdColeccion, " + "@nNumColeccion, " + "@nIdSerie, " + "@nNumSerie, " + "@nZGeografica, " + "@nsUsuarioCreacion, " + "@sIdInternoOrigen, " + "@sIdInternoOrigenSAP, " + "@iIdPais, " + "@nPorcentajeCoedicion, " + "@nTipoMaterialEducativo", new SqlParameter("@sIdInterno", dataFichasBase.IdInterno), new SqlParameter("@nsTitulo", dataFichasBase.Titulo), new SqlParameter("@nIdLineaNegocio", dataFichasBase.IdLineaNegocio), new SqlParameter("@nCoeditorial", dataFichasBase.Coeditorial ?? (object)DBNull.Value), new SqlParameter("@nIdioma", dataFichasBase.Idioma), new SqlParameter("@sCodLinea_P", dataFichasBase.CodLinea_P), new SqlParameter("@nIdTipoMaterialSAP", dataFichasBase.IdTipoMaterialSAP), new SqlParameter("@sCodigoGrupo", dataFichasBase.CodigoGrupo), new SqlParameter("@nIdProyecto", dataFichasBase.IdProyecto ?? (object)DBNull.Value), new SqlParameter("@nIdProyectoAdicional", dataFichasBase.IdProyectoAdicional ?? (object)DBNull.Value), new SqlParameter("@nIdProyectoGestion", dataFichasBase.IdProyectoGestion ?? (object)DBNull.Value), new SqlParameter("@nIdCampaña", dataFichasBase.IdCampana), new SqlParameter("@nIdUsoComercial", dataFichasBase.IdUsoComercial ?? (object)DBNull.Value), new SqlParameter("@dtFechaComerializacion", dataFichasBase.FechaComerializacion), new SqlParameter("@dtNecesidadInfo", dataFichasBase.NecesidadInfo ?? string.Empty), new SqlParameter("@nIdColeccion", dataFichasBase.IdColeccion ?? (object)DBNull.Value), new SqlParameter("@nNumColeccion", dataFichasBase.NumColeccion), new SqlParameter("@nIdSerie", dataFichasBase.IdSerie ?? (object)DBNull.Value), new SqlParameter("@nNumSerie", dataFichasBase.NumSerie), new SqlParameter("@nZGeografica", dataFichasBase.ZGeografica ?? (object)DBNull.Value), new SqlParameter("@nsUsuarioCreacion", dataFichasBase.UsuarioCreacion), new SqlParameter("@sIdInternoOrigen", dataFichasBase.IdInternoOrigen ?? string.Empty), new SqlParameter("@sIdInternoOrigenSAP", dataFichasBase.IdInternoOrigenSAP ?? string.Empty), new SqlParameter("@iIdPais", dataFichasBase.IdPais), new SqlParameter("@nPorcentajeCoedicion", dataFichasBase.PorcentajeCoedicion ?? (object)DBNull.Value), new SqlParameter("@nTipoMaterialEducativo", dataFichasBase.TipoMaterialEducativo ?? (object)DBNull.Value)); var code = result.Single(); resultStoreProcedure.Code = code; resultStoreProcedure.Status = code == 1 ? Status.Ok : Status.Error; return(code); } catch (Exception e) { resultStoreProcedure.Status = Status.Exception; resultStoreProcedure.Description = e.Message; throw; } finally { var fileName = $"{AppDomain.CurrentDomain.BaseDirectory}\\App_Data\\log.txt"; using (var sw = new System.IO.StreamWriter(fileName, true)) { sw.WriteLine(resultStoreProcedure.ToString()); } } }