/Docs/07-Implementacion/Source/trunk/EDUAR_Regular/EDUAR_SI/EDUAR_SI_DataAccess/DAProcesosEjecutados.cs

http://blpm.googlecode.com/ · C# · 76 lines · 61 code · 7 blank · 8 comment · 6 complexity · 8763afcd1fb346b5b243ecfb7cb38dc3 MD5 · raw file

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EDUAR_Entities;
  6. using System.Data.SqlClient;
  7. using System.Data;
  8. using EDUAR_Utility.Excepciones;
  9. using EDUAR_Utility.Enumeraciones;
  10. namespace EDUAR_SI_DataAccess
  11. {
  12. public class DAProcesosEjecutados : DABase
  13. {
  14. #region --[Atributos]--
  15. private const string ClassName = "DAProcesosEjecutados";
  16. #endregion
  17. #region --[Constructores]--
  18. /// <summary>
  19. /// Constructor. LLama al constructor de la clase base DABase.
  20. /// </summary>
  21. /// <param name="connectionString">Cadena de conexión a la base de datos</param>
  22. public DAProcesosEjecutados(String connectionString)
  23. : base(connectionString)
  24. {
  25. }
  26. #endregion
  27. #region --[Métodos Públicos]--
  28. /// <summary>
  29. /// Creates the specified resultado proceso.
  30. /// </summary>
  31. /// <param name="resultadoProceso">The resultado proceso.</param>
  32. public void Create(ProcesosEjecutados resultadoProceso)
  33. {
  34. SqlTransaction transaccion = null;
  35. try
  36. {
  37. using (SqlCommand command = new SqlCommand())
  38. {
  39. if (sqlConnectionConfig.State == ConnectionState.Closed) sqlConnectionConfig.Open();
  40. command.Connection = sqlConnectionConfig;
  41. command.CommandType = System.Data.CommandType.StoredProcedure;
  42. command.CommandText = "ProcesosEjecutados_Insert";
  43. command.CommandTimeout = 10;
  44. transaccion = sqlConnectionConfig.BeginTransaction();
  45. command.Transaction = transaccion;
  46. command.Parameters.AddWithValue("fechaEjecucion", resultadoProceso.fechaEjecucion);
  47. command.Parameters.AddWithValue("resultado", resultadoProceso.resultado);
  48. command.Parameters.AddWithValue("descripcionError", resultadoProceso.descripcionError);
  49. command.Parameters.AddWithValue("idProcesoAutomatico", resultadoProceso.idProcesoAutomatico);
  50. command.ExecuteNonQuery();
  51. transaccion.Commit();
  52. }
  53. }
  54. catch (SqlException ex)
  55. {
  56. if (transaccion != null) transaccion.Rollback();
  57. throw new CustomizedException(String.Format("Fallo en {0} - Create()", ClassName),
  58. ex, enuExceptionType.SqlException);
  59. }
  60. catch (Exception ex)
  61. {
  62. if (transaccion != null) transaccion.Rollback();
  63. throw new CustomizedException(String.Format("Fallo en {0} - Create()", ClassName),
  64. ex, enuExceptionType.DataAccesException);
  65. }
  66. }
  67. #endregion
  68. }
  69. }