public TOTransaction <PqInpqr> GetInfoDataPqr(int emp_codi, int inp_cont) { DAOPqDinPq daoDinpq = new DAOPqDinPq(); DAOPqInpqr DAOPqr = new DAOPqInpqr(); try { List <PqInpqr> pqrList = DAOPqr.getPqInPqrEncuestas(inp_cont, emp_codi); PqInpqr pqr = pqrList.FirstOrDefault(); if (pqr == null) { throw new Exception("No se encontraron datos con los parámetros especificados"); } pqr.seguimientos = daoDinpq.getpqDinPq(inp_cont, emp_codi); return(new TOTransaction <PqInpqr>() { objTransaction = pqr, retorno = 0, txtRetorno = "" }); } catch (Exception ex) { return(new TOTransaction <PqInpqr>() { objTransaction = null, retorno = 1, txtRetorno = ex.Message }); } }
public TOTransaction <PqInpqr> GetInfoPqrGenerated(int inp_cont, string inp_pass, int emp_codi) { DAOPqDinPq daoDinpq = new DAOPqDinPq(); try { List <PqInpqr> pqrList = DAOPqr.getPqInPqr(inp_cont); PqInpqr pqr = pqrList.Where(f => string.Concat(f.inp_cont, f.inp_fech.ToString("yyyyMMdd")) == inp_pass.Trim()).FirstOrDefault(); if (pqr == null) { throw new Exception("No se encontraron datos con los parámetros especificados"); } //pqr.genratedKey = GetPassword(pqr, "C"); //if (inp_pass != pqr.genratedKey) // throw new Exception("La constraseña para este documento no es correcta"); pqr.seguimientos = daoDinpq.getpqDinPq(inp_cont, emp_codi); return(new TOTransaction <PqInpqr>() { objTransaction = pqr, retorno = 0, txtRetorno = "" }); } catch (Exception ex) { return(new TOTransaction <PqInpqr>() { objTransaction = null, retorno = 1, txtRetorno = ex.Message }); } //Setear el key antes de devolverlo a la pagina principal, teniendo en cuentas las condiciones }
private void insertPqr(PqInpqr pqr, string typeRequest) { DAOPqParam daoPqParam = new DAOPqParam(); DAOGnInsta daoInsta = new DAOGnInsta(); DAOGnLogo daoLogo = new DAOGnLogo(); if (string.IsNullOrEmpty(pqr.inp_nide)) { pqr.inp_nide = "."; } int result = daoPqr.InseRSELFANG(pqr); pqr.genratedKey = mailHandler.GetPassword(pqr); // valida si tiene parametrizado Manejo Correo de Ingreso PQR en PQ_PARAM var MailPQParam = daoPqParam.GetMailParam(pqr.emp_codi); if (MailPQParam.par_mcin == "S") // Si tiene configurado envio de correo al ingresar un PQR { if (MailPQParam.par_tcin == null) // si no tiene una plantilla configurada para ingreso de PQR, continua con el metodo original para Defensa Civil { pqr.genratedKey = mailHandler.GetPassword(pqr); Mail mail = mailHandler.generateMail(pqr, MailPQParam, typeRequest); Mail mailModulo = mailHandler.generateMail(pqr, MailPQParam, "", "Modulo"); GnInsta insta = daoInsta.GetGnInsta(); mailHandler.sendMail(mail, insta); mailHandler.sendMail(mailModulo, insta); } else { Gnlogo Logo = daoLogo.GetGnLogo(pqr.emp_codi); MailImages ItemList = new MailImages(); ItemList.imageType = "Jpeg"; ItemList.sourceName = "logo"; ItemList.imgBytes = Logo.emp_logs; List <MailImages> LstImg = new List <MailImages>(); LstImg.Add(ItemList); Mail mail = mailHandler.generateMailFromPQParam(pqr, MailPQParam, typeRequest); Mail mailModulo = mailHandler.generateMailFromPQParam(pqr, MailPQParam, "", "Modulo"); GnInsta insta = daoInsta.GetGnInsta(); mailHandler.sendMail(mail, insta, true, LstImg); mailHandler.sendMail(mailModulo, insta, true, LstImg); } } }
public string GetPassword(PqInpqr pqr, string type = "") { string password = ""; //Si es consulta if (type == "C") { password = string.Format("{0}{1}", pqr.inp_cont, pqr.inp_fech.ToString("yyyyMMdd")); } else { password = string.Format("{0}{1}", pqr.inp_cont, DateTime.Now.ToString("yyyyMMdd")); } return(password); }
public string BuildDinamicMail(String source, int emp_codi, int inp_cont, PqInpqr pqr, string link = "") { string body = source; try { List <string> filedNames = new List <string>(); var sourceFields = source.Split('#'); foreach (string field in sourceFields) { string fieldName = field.Substring(0, 8); filedNames.Add(fieldName); } filedNames.Remove(filedNames.FirstOrDefault()); string query = string.Join(",", filedNames.ToArray()); if (!string.IsNullOrEmpty(query)) { var resultQuery = daoPqr.GetMailInformationDinamic(query, emp_codi, inp_cont); if (resultQuery.Tables[0].Rows.Count > 0) { foreach (DataRow fila in resultQuery.Tables[0].Rows) { for (int i = 0; i < filedNames.Count; i++) { body = body.Replace(filedNames[i], fila[i].ToString()); } } } body = body.Replace("#", ""); body = body.Replace("<<PASSWORD>>", pqr.genratedKey); if (!string.IsNullOrEmpty(link)) { body = body.Replace("<<LINK>>", string.Format("<a href = '{0}'> Consultar Solicitud </a>", link)); } } } catch (Exception ex) { } return(body); }
public string GetDescriptionPqrMessage(PqInpqr pqr) { string description = ""; string texto = ""; try { string password = pqr.genratedKey; texto = createMessage(); texto = texto.Replace("@inp_cont", pqr.inp_cont.ToString()); texto = texto.Replace("@password", password); description = texto; } catch (Exception ex) { description = ex.Message; } return(description); }
public Mail generateMailFromPQParam(PqInpqr pqr, TOPqParam MailPQParam, string typeResquest = "", string typeMail = "") { mailHandler mailHandler = new mailHandler(); string codeSite = MailPQParam.par_urle; //ConfigurationManager.AppSettings["SearchSitePqr"].ToString(); string codeUrl = string.Format("{0}consulta?psw={1}&pqr={2}", codeSite, pqr.genratedKey, pqr.inp_cont); Mail mail = new Mail(); if (typeMail == "") { MailPQParam.par_tcin = mailHandler.BuildDinamicMail(MailPQParam.par_tcin, pqr.emp_codi, pqr.inp_cont, pqr, codeUrl); //mail.subject = string.Format("Derecho de petición No. {0} ({1}) con código {2}", pqr.inp_cont, typeResquest, pqr.genratedKey.ToUpper()); mail.subject = mailHandler.BuildDinamicMail(MailPQParam.par_asui, pqr.emp_codi, pqr.inp_cont, pqr); StringBuilder body = new StringBuilder(); body.AppendLine("<!DOCTYPE html><html><head></head><body>"); body.AppendLine("<div>" + MailPQParam.par_tcin.Replace("\r\n", "<br>") + "</div>"); body.AppendLine("<div style='margin-top:50px;'>"); body.AppendLine("<img src='cid:logo'/>"); body.AppendLine("</div>"); body.Append("</body>"); body.Append("</html>"); mail.body = body.ToString(); mail.mailTo = pqr.inp_mail; } else { StringBuilder body = new StringBuilder(); mail.subject = string.Format("Derecho de petición No. {0}.", pqr.inp_cont); body.AppendLine(" Cordial Saludo.<br> "); body.AppendLine(string.Format(" Informamos que ha sido creada una solicitud de {0} {1}, en el sistema de Atención al Ciudadano.<br>", pqr.inp_nomb, pqr.inp_apel)); body.AppendLine("POR FAVOR NO RESPONDA ESTE MAIL."); body.AppendLine("<div style='margin-top:50px;'>"); body.AppendLine("<img src='cid:logo'/>"); body.AppendLine("</div>"); mail.body = body.ToString(); mail.mailTo = daoPqr.GetRespModulo(); } return(mail); }
public Mail generateMail(PqInpqr pqr, TOPqParam MailPQParam, string typeResquest = "", string typeMail = "") { string codeSite = MailPQParam.par_urle; //ConfigurationManager.AppSettings["SearchSitePqr"].ToString(); string codeUrl = string.Format("{0}?psw={1}&pqr={2}", codeSite, pqr.genratedKey, pqr.inp_cont); Mail mail = new Mail(); if (typeMail == "") { mail.subject = string.Format("Derecho de petición No. {0} ({1}) con código {2}", pqr.inp_cont, typeResquest, pqr.genratedKey.ToUpper()); StringBuilder body = new StringBuilder(); body.AppendLine(string.Format("Apreciado(a) <b>{0} {1}.</b><br>", pqr.inp_nomb, pqr.inp_apel)); body.AppendLine("<br>"); body.AppendLine("Cordial saludo de Defensa Civil Colombiana. <br>"); body.AppendLine(string.Format("Informamos que hemos recibido su <b>{0}</b> el {1} y está siendo trámitado.<br>", typeResquest, DateTime.Now.ToString())); body.AppendLine("<br>"); body.AppendLine(string.Format("Su código de radicado es: <b>{0}.</b><br>", pqr.inp_cont)); body.AppendLine(string.Format("Su contraseña es: <b>{0}</b><br>", pqr.genratedKey)); body.AppendLine("<br>"); body.AppendLine(string.Format("<a href='{0}'>Consulte el estado de su solicitud aquí</a><br>", codeUrl)); body.AppendLine("<br>"); body.AppendLine("Agradecemos su retroalimentación, la cual contribuye al mejoramiento de nuestro servicio y"); body.Append("al cumplimiento de nuestro objetivo más importante, la satisfacción de las necesidades de personas que como usted han confiado "); body.Append("en nuestra Institución.<br> <b> POR FAVOR NO RESPONDA ESTE MAIL. </b>"); mail.body = body.ToString(); mail.mailTo = pqr.inp_mail; } else { StringBuilder body = new StringBuilder(); mail.subject = string.Format("Derecho de petición No. {0}.", pqr.inp_cont); body.AppendLine(" Cordial Saludo de la Defensa Civil Colombiana.<br> "); body.AppendLine(string.Format(" Informamos que ha sido creada una solicitud de {0} {1}, en el sistema de Atención al Ciudadano.<br>", pqr.inp_nomb, pqr.inp_apel)); body.AppendLine("POR FAVOR NO RESPONDA ESTE MAIL."); mail.body = body.ToString(); mail.mailTo = daoPqr.GetRespModulo(); } return(mail); }
public string createWorkFlow(PqInpqr pqr, string TypeRequest) { swflup.SWFRFLUP ws = new swflup.SWFRFLUP(); swflup.TOWfRflup to = new swflup.TOWfRflup(); to.cam_name = "INP_CONT"; to.cas_desc = String.Format("Creación de PQR # {0} , Tipo de Solicitud : {1}", pqr.inp_cont, TypeRequest); to.cas_narc = ""; to.emp_codi = pqr.emp_codi; to.frm_codi = "SPQINPQR"; to.num_cont = pqr.inp_cont.ToString(); to.pro_codi = "SPQINPQR"; to.tbl_name = "PQ_INPQR"; to.usu_codi = ConfigurationManager.AppSettings["usu_codi"].ToString(); var response = ws.EnviarWF(to); if (response.Retorno != "0") { throw new Exception(string.Format("Error creando flujo :{0}", response.TxtError)); } return(response.Tra_cont); }
public TOTransaction <PqInpqrSalida> PostPqr(PqInpqr pqr) { DAOGnArbol daoArbol = new DAOGnArbol(); DAOGnItems daoItems = new DAOGnItems(); BOGnRadju boRdju = new BOGnRadju(); DAOGnParam daoParam = new DAOGnParam(); try { if (pqr.inp_tcli != "F") { pqr.inp_tcli = "O"; } string emp_codi = new tools.General().GetEmpCodi(pqr.emp_codi).ToString(); if (pqr.inp_tcli == "F") { var thirdPartie = DAOGnTerce.GetGnTerce(int.Parse(emp_codi), pqr.inp_nide); if (thirdPartie == null) { throw new Exception(string.Format("No se encontró tercero asociado a la identificación {0}", pqr.inp_nide)); } pqr.ter_codi = thirdPartie.ter_codi; } GnParam param = daoParam.GetGnParam(int.Parse(emp_codi)); string typeRequest = daoItems.GetGnItems(327, "").Where(i => i.ite_cont == pqr.ite_tpqr).FirstOrDefault().ite_nomb; if (string.IsNullOrEmpty(emp_codi)) { throw new Exception("Código de empresa no parametrizado en api."); } mailHandler.uploadFile(); pqr.emp_codi = int.Parse(emp_codi); pqr.inp_cont = daoPqr.GetCont("PQ_INPQR", "INP_CONT"); if (string.IsNullOrEmpty(pqr.arb_sucu)) { pqr.arb_sucu = "0"; } pqr.arb_sucu = daoArbol.GetGnArbol("2", pqr.arb_sucu, int.Parse(emp_codi))[0].arb_cont.ToString(); List <GnItem> data = daoItems.GetGnItems(326, "3"); if (data.Count > 0) { pqr.ite_frec = data[0].ite_cont.ToString(); } else { pqr.ite_frec = "0"; } pqr.arb_cecr = daoArbol.GetGnArbol("3", "0", int.Parse(emp_codi))[0].arb_cont.ToString(); if (pqr.pai_codi == param.pai_codi) { //Cuando se selecciona el país de instalación el municipio contiene también la región separada por - int mun_codi = int.Parse(pqr.mun_codi.Split('-')[0]); pqr.reg_codi = int.Parse(pqr.mun_codi.Split('-')[1]); pqr.mun_codi = mun_codi.ToString(); } else { pqr.reg_codi = 0; pqr.mun_codi = "0"; } insertPqr(pqr, typeRequest); string cas_cont = mailHandler.createWorkFlow(pqr, typeRequest); if (cas_cont.AsInt() > 0) { daoPqr.updatePqr(pqr.inp_cont, cas_cont); } string msg = mailHandler.GetDescriptionPqrMessage(pqr); return(new TOTransaction <PqInpqrSalida>() { objTransaction = new PqInpqrSalida() { inp_cont = pqr.inp_cont, msg = msg }, retorno = 0, txtRetorno = "" }); } catch (Exception ex) { if (pqr.inp_cont > 0) { daoPqr.deletePqr(pqr.inp_cont); } return(new TOTransaction <PqInpqrSalida>() { objTransaction = null, retorno = 1, txtRetorno = ex.Message }); } }
public int InseRSELFANG(PqInpqr pqr) { DateTime date = DateTime.Now; StringBuilder sql = new StringBuilder(); sql.Append(" INSERT INTO PQ_INPQR( "); sql.Append(" AUD_ESTA,AUD_USUA,AUD_UFAC,EMP_CODI,INP_CONT,INP_NFOR,INP_FECH,INP_FEVE,INP_ESTA,INP_FCIE,ARB_SUCU,INP_TCLI,INP_NCAR,INP_NIDE, "); sql.Append(" INP_NOMB,INP_APEL,INP_NTEL,INP_MAIL,ITE_FREC,ITE_TPQR,ARB_CECO,ITE_SPRE,ITE_ANCU,INP_MPQR,ARB_CECA,ARB_CECR,ITE_TIPI,ITE_STIP,TER_CODI,ING_CONT,INV_CODI,INV_CONT,SOC_CONT,"); sql.Append(" SBE_CONT,MAC_NUME,CAS_CONT,INP_TIDO,INP_DIRE,INP_NCEL,PAI_CODI,REG_CODI,DEP_CODI,MUN_CODI,INP_MRES,DPA_CODI,CON_CONT,ITE_STAD)VALUES "); sql.Append(" (@AUD_ESTA,@AUD_USUA,@AUD_UFAC,@EMP_CODI,@INP_CONT,@INP_NFOR,@INP_FECH,@INP_FEVE,@INP_ESTA,@INP_FCIE,@ARB_SUCU,@INP_TCLI,@INP_NCAR, "); sql.Append(" @INP_NIDE,@INP_NOMB,@INP_APEL,@INP_NTEL,@INP_MAIL,@ITE_FREC,@ITE_TPQR,@ARB_CECO,@ITE_SPRE,@ITE_ANCU,@INP_MPQR,@ARB_CECA,@ARB_CECR, "); sql.Append(" @ITE_TIPI,@ITE_STIP,@TER_CODI,@ING_CONT,@INV_CODI,@INV_CONT,@SOC_CONT,@SBE_CONT,@MAC_NUME,@CAS_CONT,@INP_TIDO,@INP_DIRE,@INP_NCEL, "); sql.Append(" @PAI_CODI,@REG_CODI,@DEP_CODI,@MUN_CODI,@INP_MRES,@INP_GPER,@CON_CONT,@ITE_STAD) "); List <Parameter> parametros = new List <Parameter>(); parametros.Add(new Parameter("@AUD_ESTA ", "A")); parametros.Add(new Parameter("@AUD_USUA", "Seven")); parametros.Add(new Parameter("@AUD_UFAC", date)); parametros.Add(new Parameter("@EMP_CODI", pqr.emp_codi)); //pendiente parametros.Add(new Parameter("@INP_NFOR", 0)); parametros.Add(new Parameter("@INP_FECH", date)); parametros.Add(new Parameter("@INP_FEVE", date)); parametros.Add(new Parameter("@INP_ESTA", "A")); parametros.Add(new Parameter("@INP_FCIE", date)); parametros.Add(new Parameter("@ARB_SUCU", pqr.arb_sucu)); parametros.Add(new Parameter("@INP_TCLI", pqr.inp_tcli)); parametros.Add(new Parameter("@INP_NCAR", "0")); parametros.Add(new Parameter("@INP_NIDE", pqr.inp_nide)); parametros.Add(new Parameter("@INP_NOMB", pqr.inp_nomb)); parametros.Add(new Parameter("@INP_APEL", pqr.inp_apel)); parametros.Add(new Parameter("@INP_NTEL", pqr.inp_ntel)); parametros.Add(new Parameter("@INP_CONT", pqr.inp_cont)); parametros.Add(new Parameter("@INP_MAIL", pqr.inp_mail)); parametros.Add(new Parameter("@ITE_FREC", pqr.ite_frec)); //Pendiente parametros.Add(new Parameter("@ITE_TPQR", pqr.ite_tpqr)); parametros.Add(new Parameter("@ARB_CECO", 0)); parametros.Add(new Parameter("@ITE_SPRE", 0)); parametros.Add(new Parameter("@ITE_ANCU", 0)); parametros.Add(new Parameter("@INP_MPQR", pqr.inp_mpqr)); parametros.Add(new Parameter("@ARB_CECA", 0)); parametros.Add(new Parameter("@ARB_CECR", pqr.arb_cecr)); parametros.Add(new Parameter("@ITE_TIPI", pqr.ite_tipi)); parametros.Add(new Parameter("@ITE_STIP", pqr.ite_stip)); parametros.Add(new Parameter("@TER_CODI", pqr.ter_codi)); parametros.Add(new Parameter("@ING_CONT", 0)); parametros.Add(new Parameter("@INV_CODI", 0)); parametros.Add(new Parameter("@INV_CONT", 0)); parametros.Add(new Parameter("@SOC_CONT", 0)); parametros.Add(new Parameter("@SBE_CONT", 0)); parametros.Add(new Parameter("@MAC_NUME", 0)); parametros.Add(new Parameter("@CAS_CONT", 0)); parametros.Add(new Parameter("@INP_TIDO", pqr.inp_tido)); parametros.Add(new Parameter("@INP_DIRE", pqr.inp_dire)); parametros.Add(new Parameter("@INP_NCEL", pqr.inp_ncel)); parametros.Add(new Parameter("@PAI_CODI", pqr.pai_codi)); parametros.Add(new Parameter("@REG_CODI", pqr.reg_codi)); parametros.Add(new Parameter("@DEP_CODI", pqr.dep_codi)); parametros.Add(new Parameter("@MUN_CODI", pqr.mun_codi)); parametros.Add(new Parameter("@INP_MRES", pqr.inp_mres)); parametros.Add(new Parameter("@INP_GPER", pqr.inp_gper)); parametros.Add(new Parameter("@CON_CONT", pqr.con_cont)); parametros.Add(new Parameter("@ITE_STAD", 0)); OTOContext pTOContext = new OTOContext(); var conection = DBFactory.GetDB(pTOContext); return(conection.Insert(pTOContext, sql.ToString(), parametros.ToArray())); }
public TOTransaction <PqInpqrSalida> Post(PqInpqr pqr) { BOPqInpqr bo = new BOPqInpqr(); return(bo.PostPqr(pqr)); }