///// <summary> ///// Obtiene un AccionPT a partir del id ///// </summary> internal Models.AccionPT Select(int t410_idaccion) { Models.AccionPT oAccionPT = null; IDataReader dr = null; try { SqlParameter[] dbparams = new SqlParameter[1] { Param(enumDBFields.T410_idaccion, t410_idaccion), }; dr = cDblib.DataReader("SUP_ACCION_PT_S", dbparams); if (dr.Read()) { oAccionPT = new Models.AccionPT(); oAccionPT.T410_fcreacion = Convert.ToDateTime(dr["T410_fcreacion"]); oAccionPT.T409_idasunto = Convert.ToInt32(dr["T409_idasunto"]); oAccionPT.T410_alerta = Convert.ToString(dr["T410_alerta"]); oAccionPT.T410_avance = Convert.ToByte(dr["T410_avance"]); oAccionPT.T410_desaccion = Convert.ToString(dr["T410_desaccion"]); oAccionPT.T410_desaccionlong = Convert.ToString(dr["T410_desaccionlong"]); oAccionPT.T410_dpto = Convert.ToString(dr["T410_dpto"]); if (!Convert.IsDBNull(dr["T410_ffin"])) { oAccionPT.T410_ffin = Convert.ToDateTime(dr["T410_ffin"]); } if (!Convert.IsDBNull(dr["T410_flimite"])) { oAccionPT.T410_flimite = Convert.ToDateTime(dr["T410_flimite"]); } oAccionPT.T410_idaccion = Convert.ToInt32(dr["T410_idaccion"]); oAccionPT.T410_obs = Convert.ToString(dr["T410_obs"]); oAccionPT.t314_idusuario_responsable = Convert.ToInt32(dr["t314_idusuario_responsable"]); oAccionPT.t301_idproyecto = Convert.ToInt32(dr["t301_idproyecto"]); oAccionPT.t301_denominacion = Convert.ToString(dr["t301_denominacion"]); oAccionPT.t331_idpt = Convert.ToInt32(dr["t331_idpt"]); oAccionPT.t331_despt = Convert.ToString(dr["t331_despt"]); } return(oAccionPT); } catch (Exception ex) { throw ex; } finally { if (dr != null) { if (!dr.IsClosed) { dr.Close(); } dr.Dispose(); } } }
///// <summary> ///// Obtiene todos los AccionPT ///// </summary> //internal List<Models.AccionPT> Catalogo(Models.AccionPT oAccionPTFilter) //{ // Models.AccionPT oAccionPT = null; // List<Models.AccionPT> lst = new List<Models.AccionPT>(); // IDataReader dr = null; // try // { // SqlParameter[] dbparams = new SqlParameter[11] { // Param(enumDBFields.T410_fcreacion, oTEMP_AccionPTFilter.T410_fcreacion), // Param(enumDBFields.T409_idasunto, oTEMP_AccionPTFilter.T409_idasunto), // Param(enumDBFields.T410_alerta, oTEMP_AccionPTFilter.T410_alerta), // Param(enumDBFields.T410_avance, oTEMP_AccionPTFilter.T410_avance), // Param(enumDBFields.T410_desaccion, oTEMP_AccionPTFilter.T410_desaccion), // Param(enumDBFields.T410_desaccionlong, oTEMP_AccionPTFilter.T410_desaccionlong), // Param(enumDBFields.T410_dpto, oTEMP_AccionPTFilter.T410_dpto), // Param(enumDBFields.T410_ffin, oTEMP_AccionPTFilter.T410_ffin), // Param(enumDBFields.T410_flimite, oTEMP_AccionPTFilter.T410_flimite), // Param(enumDBFields.T410_idaccion, oTEMP_AccionPTFilter.T410_idaccion), // Param(enumDBFields.T410_obs, oTEMP_AccionPTFilter.T410_obs) // }; // dr = cDblib.DataReader("_AccionPT_CAT", dbparams); // while (dr.Read()) // { // oAccionPT = new Models.AccionPT(); // oAccionPT.T410_fcreacion=Convert.ToDateTime(dr["T410_fcreacion"]); // oAccionPT.T409_idasunto=Convert.ToInt32(dr["T409_idasunto"]); // oAccionPT.T410_alerta=Convert.ToString(dr["T410_alerta"]); // oAccionPT.T410_avance=Convert.ToByte(dr["T410_avance"]); // oAccionPT.T410_desaccion=Convert.ToString(dr["T410_desaccion"]); // oAccionPT.T410_desaccionlong=Convert.ToString(dr["T410_desaccionlong"]); // oAccionPT.T410_dpto=Convert.ToString(dr["T410_dpto"]); // if(!Convert.IsDBNull(dr["T410_ffin"])) // oAccionPT.T410_ffin=Convert.ToDateTime(dr["T410_ffin"]); // if(!Convert.IsDBNull(dr["T410_flimite"])) // oAccionPT.T410_flimite=Convert.ToDateTime(dr["T410_flimite"]); // oAccionPT.T410_idaccion=Convert.ToInt32(dr["T410_idaccion"]); // oAccionPT.T410_obs=Convert.ToString(dr["T410_obs"]); // lst.Add(oAccionPT); // } // return lst; // } // catch (Exception ex) // { // throw ex; // } // finally // { // if (dr != null) // { // if (!dr.IsClosed) dr.Close(); // dr.Dispose(); // } // } //} //#endregion internal List <Models.AccionPT> Catalogo(int nAsunto) { Models.AccionPT oAccion = null; List <Models.AccionPT> lst = new List <Models.AccionPT>(); IDataReader dr = null; try { SqlParameter[] dbparams = new SqlParameter[1] { Param(enumDBFields.T409_idasunto, nAsunto), }; dr = cDblib.DataReader("SUP_ACCION_PT_C", dbparams); while (dr.Read()) { oAccion = new Models.AccionPT(); oAccion.T410_idaccion = Convert.ToInt32(dr["T410_idaccion"]); oAccion.T410_desaccion = Convert.ToString(dr["T410_desaccion"]); if (!Convert.IsDBNull(dr["T410_flimite"])) { oAccion.T410_flimite = Convert.ToDateTime(dr["T410_flimite"]); } oAccion.T410_avance = Convert.ToByte(dr["T410_avance"]); if (!Convert.IsDBNull(dr["T410_ffin"])) { oAccion.T410_ffin = Convert.ToDateTime(dr["T410_ffin"]); } oAccion.t314_idusuario_responsable = Convert.ToInt32(dr["T409_responsable"]); lst.Add(oAccion); } return(lst); } catch (Exception ex) { throw ex; } finally { if (dr != null) { if (!dr.IsClosed) { dr.Close(); } dr.Dispose(); } } }
/// <summary> /// Actualiza un AccionPT a partir del id /// </summary> internal int Update(Models.AccionPT oAccionPT) { try { SqlParameter[] dbparams = new SqlParameter[9] { Param(enumDBFields.T410_alerta, oAccionPT.T410_alerta), Param(enumDBFields.T410_avance, oAccionPT.T410_avance), Param(enumDBFields.T410_desaccion, oAccionPT.T410_desaccion), Param(enumDBFields.T410_desaccionlong, oAccionPT.T410_desaccionlong), Param(enumDBFields.T410_dpto, oAccionPT.T410_dpto), Param(enumDBFields.T410_ffin, oAccionPT.T410_ffin), Param(enumDBFields.T410_flimite, oAccionPT.T410_flimite), Param(enumDBFields.T410_idaccion, oAccionPT.T410_idaccion), Param(enumDBFields.T410_obs, oAccionPT.T410_obs) }; return((int)cDblib.Execute("SUP_ACCION_PT_U", dbparams)); } catch (Exception ex) { throw ex; } }
public int grabar(Models.AccionPT DatosGenerales, List <Models.AccionRecursosPT> Integrantes, List <Models.AccionTareasPT> 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.AccionPT oAccion = new DAL.AccionPT(cDblib); DAL.AccionRecursosPT oRecursoDAL = new DAL.AccionRecursosPT(cDblib); DAL.AccionTareasPT oTareaDAL = new DAL.AccionTareasPT(cDblib); if (DatosGenerales.T410_idaccion == -1) { DatosGenerales.T410_fcreacion = System.DateTime.Now; idReferencia = oAccion.Insert(DatosGenerales); } else { oAccion.Update(DatosGenerales); idReferencia = DatosGenerales.T410_idaccion; } foreach (Models.AccionRecursosPT oRecurso in Integrantes) { switch (oRecurso.accionBD) { case "I": //Inserción oRecurso.t410_idaccion = idReferencia; oRecursoDAL.Insert(oRecurso); break; case "D": //delete oRecursoDAL.Delete(oRecurso); break; case "U": //update oRecursoDAL.Update(oRecurso); break; } } foreach (Models.AccionTareasPT 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(methodOwnerID)) { cDblib.rollbackTransaction(methodOwnerID); } throw new Exception(ex.Message); } finally { //nota.Dispose(); } }
public void EnviarCorreo(Models.AccionPT DatosGenerales, List <Models.AccionRecursosPT> Integrantes, bool bAlta) { string sTexto = "", sTO = "", sToAux = "", sAux, sIdResponsable, slMails; string sAsunto = ""; ArrayList aListCorreo = new ArrayList(); StringBuilder sb = new StringBuilder(); sIdResponsable = DatosGenerales.t314_idusuario_responsable.ToString(); slMails = DatosGenerales.T410_alerta.ToString(); if (slMails == "" && sIdResponsable == "") { return; } sAsunto = "Alerta de acción en Bitácora de proyecto técnico."; 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.t301_denominacion + "<br>"); sb.Append("<label style='width:120px'>Proyecto técnico: </label>" + DatosGenerales.t331_idpt.ToString() + @" - " + DatosGenerales.t331_despt + "<br>"); sb.Append("<label style='width:120px'>Asunto: </label><b>" + DatosGenerales.T409_idasunto.ToString() + @" - " + DatosGenerales.T409_desasunto + "</b><br><br>"); sb.Append("<label style='width:120px'>Acción: </label><b>" + DatosGenerales.T410_idaccion + @" - " + DatosGenerales.T410_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.T410_flimite == null) { sAux = ""; } else { sAux = DatosGenerales.T410_flimite.ToString().Substring(0, 10); } sb.Append("<label style='width:120px'>F/Límite: </label>" + sAux + "<br>"); if (DatosGenerales.T410_ffin == null) { sAux = ""; } else { sAux = DatosGenerales.T410_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.T410_avance + "<br><br>"); //descripcion larga sb.Append("<b><label style='width:120px'>Descripción: </label></b>" + DatosGenerales.T410_desaccionlong + "<br><br>"); //observaciones sb.Append("<b><label style='width:120px'>Observaciones: </label></b>" + DatosGenerales.T410_obs + "<br><br>"); //Departamento sb.Append("<b><label style='width:120px'>Departamento: </label></b>" + DatosGenerales.T410_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.AccionRecursosPT 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.AccionRecursosPT oRecurso in Integrantes) { if (oRecurso.t414_notificar) { string[] aMail = { sAsunto, sTexto, oRecurso.MAIL }; aListCorreo.Add(aMail); } } Correo.EnviarCorreos(aListCorreo); }