Esempio n. 1
0
        public TOTransaction <PqrTransactionLoad> GetInitialDataWpqinqr(string cli_coda, int emp_codi)
        {
            BOGnPaise  boPaise  = new BOGnPaise();
            BOGnDepar  boDepar  = new BOGnDepar();
            BOGnMunic  boMunic  = new BOGnMunic();
            BOGnItems  boItems  = new BOGnItems();
            BOGnDigfl  boFlag   = new BOGnDigfl();
            BOPqDpara  boPerte  = new BOPqDpara();
            BOGnArbol  boArbol  = new BOGnArbol();
            DAOGnParam daoParam = new DAOGnParam();
            DAOGnLogo  daoLogo  = new DAOGnLogo();
            DAOCtContr daoContr = new DAOCtContr();

            try
            {
                PqrTransactionLoad result    = new PqrTransactionLoad();
                GnParam            param     = daoParam.GetGnParam(emp_codi);
                GnFlag             spq000001 = boFlag.GetGnDigfl("SPQ000001");
                if (param == null)
                {
                    throw new Exception(string.Format("Parámetros de empresa no definidos para empresa {0}", emp_codi));
                }
                List <GnPaise>  countries      = boPaise.GetGnPaise();
                List <GnDepar>  states         = boDepar.GetGnDepar(param.pai_codi);
                List <GnMunic>  cities         = boMunic.GetAllGnMunic(param.pai_codi);
                GnFlag          flag           = boFlag.GetGnDigfl("SPQ000002");
                List <GnItem>   pqrType        = boItems.GetGnItems(327);
                List <GnItem>   pqrSubject     = boItems.GetGnItems(330);
                List <GnItem>   pqrInscription = boItems.GetGnItems(331);
                List <TOGPerte> pqrGrpups      = boPerte.GetPqDpara(emp_codi);
                GnFlag          flag008        = boFlag.GetGnDigfl("SGN000008");

                result.countries      = countries;
                result.states         = states;
                result.cities         = cities;
                result.pqrInscription = pqrInscription;
                result.pqrSubject     = pqrSubject;
                result.pqrType        = pqrType;
                result.pqrGroup       = pqrGrpups;
                result.digiflag       = flag;
                result.pqrImage       = daoLogo.GetGnLogo(emp_codi).emp_logs;
                result.SGN000008      = flag008.dig_valo;

                if (emp_codi > 0 && cli_coda != null && cli_coda != "undefined")
                {
                    FaClien client = DAOFaClien.GetFaClien(emp_codi, cli_coda);
                    if (client == null)
                    {
                        throw new Exception(string.Format("No se encontraron clientes con identificación {0} y empresa {1}", cli_coda, emp_codi));
                    }
                    result.client    = client;
                    result.contracts = daoContr.GetCtContr(emp_codi, cli_coda);
                }
                if (spq000001 != null)
                {
                    result.spq000001 = spq000001;
                }


                return(new TOTransaction <PqrTransactionLoad>()
                {
                    objTransaction = result, txtRetorno = "", retorno = 0
                });
            }
            catch (Exception ex)
            {
                return(new TOTransaction <PqrTransactionLoad>()
                {
                    objTransaction = null, retorno = 1, txtRetorno = ex.Message
                });
            }
        }
Esempio n. 2
0
        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
                });
            }
        }