/// <summary> /// Obtiene un Accion a partir del id /// </summary> internal Models.Accion Select(Int32 t383_idaccion) { Models.Accion oAccion = null; IDataReader dr = null; SqlParameter[] dbparams = new SqlParameter[1] { Param(enumDBFields.t383_idaccion, t383_idaccion), }; try { dr = cDblib.DataReader("SUP_ACCION_S", dbparams); if (dr.Read()) { oAccion = new Models.Accion(); oAccion.t383_fcreacion = Convert.ToDateTime(dr["T383_fcreacion"]); oAccion.t382_idasunto = Convert.ToInt32(dr["T382_idasunto"]); oAccion.t383_alerta = Convert.ToString(dr["T383_alerta"]); oAccion.t383_avance = Convert.ToByte(dr["T383_avance"]); oAccion.t383_desaccion = Convert.ToString(dr["T383_desaccion"]); oAccion.t383_desaccionlong = Convert.ToString(dr["T383_desaccionlong"]); oAccion.t383_dpto = Convert.ToString(dr["T383_dpto"]); if (!Convert.IsDBNull(dr["T383_ffin"])) { oAccion.t383_ffin = Convert.ToDateTime(dr["T383_ffin"]); } if (!Convert.IsDBNull(dr["T383_flimite"])) { oAccion.t383_flimite = Convert.ToDateTime(dr["T383_flimite"]); } oAccion.t383_idaccion = Convert.ToInt32(dr["T383_idaccion"]); oAccion.t383_obs = Convert.ToString(dr["T383_obs"]); } return(oAccion); } catch (Exception ex) { throw ex; } finally { if (dr != null) { if (!dr.IsClosed) { dr.Close(); } dr.Dispose(); } } }
///// <summary> ///// Elimina un Accion a partir del id ///// </summary> //internal int Delete() //{ // try // { // return (int)cDblib.Execute("_Accion_DEL", dbparams); // } // catch (Exception ex) // { // throw ex; // } //} ///// <summary> ///// Obtiene todos los Accion ///// </summary> //internal List<Models.Accion> Catalogo(Models.Accion oAccionFilter) //{ // Models.Accion oAccion = null; // List<Models.Accion> lst = new List<Models.Accion>(); // IDataReader dr = null; // try // { // SqlParameter[] dbparams = new SqlParameter[8] { // Param(enumDBFields.T383_fcreacion, oTEMP_AccionFilter.T383_fcreacion), // Param(enumDBFields.T382_idasunto, oTEMP_AccionFilter.T382_idasunto), // Param(enumDBFields.T383_avance, oTEMP_AccionFilter.T383_avance), // Param(enumDBFields.T383_desaccion, oTEMP_AccionFilter.T383_desaccion), // Param(enumDBFields.T383_ffin, oTEMP_AccionFilter.T383_ffin), // Param(enumDBFields.T383_flimite, oTEMP_AccionFilter.T383_flimite), // Param(enumDBFields.T383_idaccion, oTEMP_AccionFilter.T383_idaccion), // Param(enumDBFields.T382_responsable, oTEMP_AccionFilter.T382_responsable) // }; // dr = cDblib.DataReader("_Accion_CAT", dbparams); // while (dr.Read()) // { // oAccion = new Models.Accion(); // oAccion.T383_fcreacion=Convert.ToDateTime(dr["T383_fcreacion"]); // oAccion.T382_idasunto=Convert.ToInt32(dr["T382_idasunto"]); // oAccion.T383_avance=Convert.ToByte(dr["T383_avance"]); // oAccion.T383_desaccion=Convert.ToString(dr["T383_desaccion"]); // if(!Convert.IsDBNull(dr["T383_ffin"])) // oAccion.T383_ffin=Convert.ToDateTime(dr["T383_ffin"]); // if(!Convert.IsDBNull(dr["T383_flimite"])) // oAccion.T383_flimite=Convert.ToDateTime(dr["T383_flimite"]); // oAccion.T383_idaccion=Convert.ToInt32(dr["T383_idaccion"]); // oAccion.T382_responsable=Convert.ToInt32(dr["T382_responsable"]); // lst.Add(oAccion); // } // return lst; // } // catch (Exception ex) // { // throw ex; // } // finally // { // if (dr != null) // { // if (!dr.IsClosed) dr.Close(); // dr.Dispose(); // } // } //} /// <summary> /// Obtiene todos las acciones de un Asunto /// </summary> internal List <Models.Accion> Catalogo(int nAsunto) { Models.Accion oAccion = null; List <Models.Accion> lst = new List <Models.Accion>(); IDataReader dr = null; try { SqlParameter[] dbparams = new SqlParameter[1] { Param(enumDBFields.t382_idasunto, nAsunto), }; dr = cDblib.DataReader("SUP_ACCION_CAT", dbparams); while (dr.Read()) { oAccion = new Models.Accion(); oAccion.t383_idaccion = Convert.ToInt32(dr["idAccion"]); oAccion.t383_desaccion = Convert.ToString(dr["desAccion"]); if (!Convert.IsDBNull(dr["fLimite"])) { oAccion.t383_flimite = Convert.ToDateTime(dr["fLimite"]); } oAccion.t383_avance = Convert.ToByte(dr["nAvance"]); if (!Convert.IsDBNull(dr["fFin"])) { oAccion.t383_ffin = Convert.ToDateTime(dr["fFin"]); } lst.Add(oAccion); } return(lst); } catch (Exception ex) { throw ex; } finally { if (dr != null) { if (!dr.IsClosed) { dr.Close(); } dr.Dispose(); } } }
/// <summary> /// Actualiza un Accion a partir del id /// </summary> internal int Update(Models.Accion oAccion) { try { SqlParameter[] dbparams = new SqlParameter[9] { Param(enumDBFields.t383_alerta, oAccion.t383_alerta), Param(enumDBFields.t383_avance, oAccion.t383_avance), Param(enumDBFields.t383_desaccion, oAccion.t383_desaccion), Param(enumDBFields.t383_desaccionlong, oAccion.t383_desaccionlong), Param(enumDBFields.t383_dpto, oAccion.t383_dpto), Param(enumDBFields.t383_ffin, oAccion.t383_ffin), Param(enumDBFields.t383_flimite, oAccion.t383_flimite), Param(enumDBFields.t383_idaccion, oAccion.t383_idaccion), Param(enumDBFields.t383_obs, oAccion.t383_obs), }; return((int)cDblib.Execute("SUP_ACCION_U", dbparams)); } catch (Exception ex) { throw ex; } }
///// <summary> /// Inserta un Accion /// </summary> internal int Insert(Models.Accion oAccion) { try { SqlParameter[] dbparams = new SqlParameter[10] { Param(enumDBFields.t383_fcreacion, oAccion.t383_fcreacion), Param(enumDBFields.t382_idasunto, oAccion.t382_idasunto), Param(enumDBFields.t383_alerta, oAccion.t383_alerta), Param(enumDBFields.t383_avance, oAccion.t383_avance), Param(enumDBFields.t383_desaccion, oAccion.t383_desaccion), Param(enumDBFields.t383_desaccionlong, oAccion.t383_desaccionlong), Param(enumDBFields.t383_dpto, oAccion.t383_dpto), Param(enumDBFields.t383_ffin, oAccion.t383_ffin), Param(enumDBFields.t383_flimite, oAccion.t383_flimite), Param(enumDBFields.t383_obs, oAccion.t383_obs), }; return((int)cDblib.ExecuteScalar("[SUP_ACCION_I]", dbparams)); } catch (Exception ex) { throw ex; } }
public int grabar(Models.Accion DatosGenerales, List <Models.AccionRecursos> Integrantes, List <Models.AccionTareas> Tareas) { int idReferencia; bool bConTransaccion = false; Guid methodOwnerID = new Guid("5590F1B4-7073-4B5F-A4DB-9F301648D151"); OpenDbConn(); if (cDblib.Transaction.ownerID.Equals(new Guid())) { bConTransaccion = true; } if (bConTransaccion) { cDblib.beginTransaction(methodOwnerID); } try { DAL.Accion oAccion = new DAL.Accion(cDblib); DAL.AccionRecursos oRecursoDAL = new DAL.AccionRecursos(cDblib); DAL.AccionTareas oTareaDAL = new DAL.AccionTareas(cDblib); if (DatosGenerales.t383_idaccion == -1) { DatosGenerales.t383_fcreacion = System.DateTime.Now; idReferencia = oAccion.Insert(DatosGenerales); } else { oAccion.Update(DatosGenerales); idReferencia = DatosGenerales.t383_idaccion; } foreach (Models.AccionRecursos oRecurso in Integrantes) { switch (oRecurso.accionBD) { case "I": //Inserción oRecurso.T383_idaccion = idReferencia; oRecursoDAL.Insert(oRecurso); break; case "D": //delete oRecursoDAL.Delete(oRecurso); break; case "U": //update oRecursoDAL.Update(oRecurso); break; } } foreach (Models.AccionTareas oTarea in Tareas) { switch (oTarea.accionBD) { case "I": //Inserción oTareaDAL.Insert(oTarea); break; case "D": //delete oTareaDAL.Delete(oTarea); break; } } if (bConTransaccion) { cDblib.commitTransaction(methodOwnerID); } return(idReferencia); } catch (Exception ex) { //rollback if (cDblib.Transaction.ownerID.Equals(new Guid())) { cDblib.rollbackTransaction(methodOwnerID); } throw new Exception(ex.Message); } finally { //nota.Dispose(); } }
public void EnviarCorreo(Models.Accion DatosGenerales, List <Models.AccionRecursos> Integrantes, bool bAlta) { string sTexto = "", sTO = "", sToAux = "", sAux, sIdResponsable, slMails; string sAsunto = ""; ArrayList aListCorreo = new ArrayList(); StringBuilder sb = new StringBuilder(); sIdResponsable = DatosGenerales.t382_responsable.ToString(); slMails = DatosGenerales.t383_alerta.ToString(); if (slMails == "" && sIdResponsable == "") { return; } sAsunto = "Alerta de acción en Bitácora de proyecto económico."; if (bAlta) { sb.Append("<BR>SUPER le informa de la generación de la siguiente acción:<BR><BR>"); } else { sb.Append("<BR>SUPER le informa de la modificación de la siguiente acción:<BR><BR>"); } sb.Append("<label style='width:120px'>Proyecto económico: </label>" + DatosGenerales.t301_idproyecto.ToString() + @" - " + DatosGenerales.DesPE + "<br>"); sb.Append("<label style='width:120px'>Asunto: </label><b>" + DatosGenerales.t382_idasunto.ToString() + @" - " + DatosGenerales.t382_desasunto + "</b><br><br>"); sb.Append("<label style='width:120px'>Acción: </label><b>" + DatosGenerales.t383_idaccion + @" - " + DatosGenerales.t383_desaccion + "</b><br><br>"); sb.Append("<b>Información de la acción:</b><br>"); //sb.Append("<label style='width:120px'>Responsable: </label>" + DatosGenerales.Responsable + "<br>"); if (DatosGenerales.t383_flimite == null) { sAux = ""; } else { sAux = DatosGenerales.t383_flimite.ToString().Substring(0, 10); } sb.Append("<label style='width:120px'>F/Límite: </label>" + sAux + "<br>"); if (DatosGenerales.t383_ffin == null) { sAux = ""; } else { sAux = DatosGenerales.t383_ffin.ToString().Substring(0, 10); } sb.Append("<label style='width:120px'>F/Fin: </label>" + sAux + "<br>"); sb.Append("<label style='width:120px'>Avance: </label>" + DatosGenerales.t383_avance + "<br><br>"); //descripcion larga sb.Append("<b><label style='width:120px'>Descripción: </label></b>" + DatosGenerales.t383_desaccionlong + "<br><br>"); //observaciones sb.Append("<b><label style='width:120px'>Observaciones: </label></b>" + DatosGenerales.t383_obs + "<br><br>"); //Departamento sb.Append("<b><label style='width:120px'>Departamento: </label></b>" + DatosGenerales.t383_dpto + "<br><br>"); //Obtengo la lista de e-mail a los que alertar if (!slMails.Contains(";")) { slMails += ";"; } string[] aMails = Regex.Split(slMails, ";"); //Genero una tabla con la lista de e-mails a notificar sb.Append("<b><label style='width:400px'>Relación de e-mails a notificar: </label></b> <br>"); sb.Append("<table width='400px' style='padding:10px;'>"); sb.Append("<colgroup><col style='width:400px;' /></colgroup>"); sb.Append("<tbody>"); for (int i = 0; i < aMails.Length; i++) { sToAux = aMails[i].Trim(); if (sToAux != "") { sb.Append("<tr><td style='padding-left:5px;font-size:11px;'>"); sTO = sToAux; sAux = sTO.Substring(0, 2); if (sAux == "\r\n") { sTO = sTO.Substring(2); } sb.Append(sTO); sb.Append("</td></tr>"); } } sb.Append("</tbody>"); sb.Append("</table><br>"); //Genero una tabla con la lista de profesionales a notificar sb.Append("<b><label style='width:400px'>Relación de profesionales asignados: </label> </b><br>"); sb.Append("<table width='400px' style='padding:10px;'>"); sb.Append("<colgroup><col style='width:400px;' /></colgroup>"); sb.Append("<tbody>"); foreach (Models.AccionRecursos oRecurso in Integrantes) { if (oRecurso.accionBD != "D") { sb.Append("<tr><td style='padding-left:5px;font-size:11px;'>"); sb.Append(oRecurso.nomRecurso); sb.Append("</td></tr>"); } } sb.Append("</tbody>"); sb.Append("</table><br>"); sTexto = sb.ToString(); //Envío e-mail al responsable del asunto if (sIdResponsable != "") { BLL.Recursos oRecursos = new BLL.Recursos(); Models.Recursos oRecursoModel = new Models.Recursos(); try { oRecursoModel = oRecursos.establecerUsuarioIAP("", int.Parse(sIdResponsable)); } catch (Exception ex) { throw new Exception(System.Uri.EscapeDataString("Error al obtener el código de red" + ex.Message)); } finally { oRecursos.Dispose(); } sTO = oRecursoModel.t001_codred; string[] aMail = { sAsunto, sTexto, sTO }; aListCorreo.Add(aMail); } //Obtengo la lista de e-mail a los que alertar y envío un correo a cada uno for (int i = 0; i < aMails.Length; i++) { if (aMails[i] != "") { sTO = aMails[i]; //sTO.Replace((char)10, (char)160); //sTO.Replace((char)13, (char)160); sAux = sTO.Substring(0, 2); if (sAux == "\r\n") { sTO = sTO.Substring(2); } sTO.Trim(); string[] aMail = { sAsunto, sTexto, sTO }; aListCorreo.Add(aMail); } } //Obtengo la lista de profesionales a los que notificar y envío un correo a cada uno foreach (Models.AccionRecursos oRecurso in Integrantes) { if (oRecurso.T389_notificar) { string[] aMail = { sAsunto, sTexto, oRecurso.mail }; aListCorreo.Add(aMail); } } Correo.EnviarCorreos(aListCorreo); }