Ejemplo n.º 1
0
        private string EndTraffic(FiltroTrafico Fil)
        {
            var resu = "";

            mRHCC = dRHCC.GetConsoTrafico(Fil.CONSO);
            if (mRHCC != null)
            {
                //var xml = GeneraXMLEnd(mRHCC.HPLACA, mRHCC.HMANIF, "brinsa", "brinsa2017", int.Parse(consoli));
                var hh        = new com.nygsoft.huella.Servicioingresonuevotrafico();
                var respuesta = hh.finalizarTrafico(mRHCC.HPLACA, mRHCC.HMANIF, "brinsa", "brinsa2017", int.Parse(Fil.CONSO));
                resu = respuesta[0].mensaje;
                var nRFTASK = new RFTASK()
                {
                    TKEY     = Fil.CONSO,
                    TKEYWORD = Fil.CONSO,
                    TPRM     = Fil.CONSO,
                    TPGM     = resu
                };
                resu = dRFTASK.AddEndTraffic(nRFTASK);
                if (!resu.Contains("ERROR"))
                {
                    try
                    {
                        var filtro = new FiltroServicios()
                        {
                            USUARIO  = Fil.USUARIO,
                            PASSWORD = Fil.PASSWORD,
                            ACCION   = "RUTINA",
                            IDTAREA  = resu
                        };
                        var s    = new ServiciosController();
                        var res  = s.Rutinas(filtro);
                        var res2 = ((System.Web.Http.Results.JsonResult <RespuestaRutina>)res).Content;
                        resu = res2.Mensaje;
                    }
                    catch (Exception ex)
                    {
                        var nRFLOG = new RFLOG()
                        {
                            OPERACION = "ENDTRAFFIC",
                            EVENTO    = "ERROR",
                            TXTSQL    = ex.Message.Replace("'", "''"),
                            ALERT     = "0"
                        };
                        resu = dRFLOG.Add(nRFLOG);
                        resu = "ERROR Tarea: " + resu + ex.Message;
                        if (ex.InnerException != null)
                        {
                            resu = resu + " - " + ex.InnerException;
                        }
                        if (ex.StackTrace != null)
                        {
                            resu = resu + " - " + ex.StackTrace;
                        }
                    }
                }
            }

            return(resu);
        }
Ejemplo n.º 2
0
        public string UpdateHESTAD(RHCC rhcc)
        {
            string        res;
            StringBuilder query = new StringBuilder();

            query.Append(" UPDATE RHCC");
            query.Append(" SET");
            query.Append(" HESTAD = 6, HFESTAD = '" + rhcc.HFESTAD + "'");
            query.Append(" WHERE HCONSO = '" + rhcc.HCONSO + "'");

            try
            {
                db.Execute(query.ToString(), rhcc);
                res = "OK";
            }
            catch (iDB2SQLErrorException ex)
            {
                res = ex.Message;
            }
            catch (iDB2Exception ex)
            {
                res = ex.Message;
            }
            catch (Exception ex)
            {
                res = ex.Message;
            }
            return(res);
        }
Ejemplo n.º 3
0
        private string ChkTruePlanilla(string xPlanilla, string pSender, string pHora, string regA)
        {
            string result = "";
            string ECELOK = "";

            mRDCC = dRDCC.GetInfo(xPlanilla);
            if (mRDCC != null)
            {
                mRRCC.RPLANI  = xPlanilla;
                mRRCC.HCONSO  = mRDCC.DCONSO;
                mRRCC.RSTSC   = mRDCC.HSTS;
                mRRCC.RFECREP = pHora;
                mRRCC.RREPORT = xPlanilla + " Fin de Entrega";
                mRRCC.RCRTUSR = pSender;
                result        = dRRCC.AddRPLANI(mRRCC);
                if (result == "OK")
                {
                    mRHCC         = null;
                    mRHCC         = new RHCC();
                    mRHCC.RREPORT = xPlanilla + " Fin de Entrega";
                    mRHCC.RFECREP = pHora;
                    mRHCC.HCONSO  = mRDCC.DCONSO;
                    result        = dRHCC.UpdateHREPORT(mRHCC);
                    if (result == "OK")
                    {
                        if (pSender.Trim() == mRDCC.HCELU.Replace(" ", "").Replace("-", ""))
                        {
                            ECELOK = "1";
                        }
                        result = dRECC.UpdateESTS2(pHora, xPlanilla, ECELOK);
                        if (result == "OK")
                        {
                            if (regA == "0" || regA == "" || regA == null)
                            {
                                ActualizaRECC(mRDCC.DCONSO);
                            }
                            result = dRECC.UpdateConso2(mRDCC.DCONSO);
                            if (result == "OK")
                            {
                                lmRECC = dRECC.GetData3(mRDCC.DCONSO);
                                if (lmRECC == null || lmRECC.Count == 0)
                                {
                                    mRHCC         = null;
                                    mRHCC         = new RHCC();
                                    mRHCC.HFESTAD = pHora;
                                    mRHCC.HCONSO  = mRDCC.DCONSO;
                                    result        = dRHCC.UpdateHESTAD(mRHCC);
                                }
                            }
                        }
                    }
                }
            }

            return(result);
        }
Ejemplo n.º 4
0
        public RHCC GetConsoSalida(RHCC rhcc)
        {
            StringBuilder query = new StringBuilder();

            query.Append(" SELECT HCONSO, HSTS, HPROVE");
            query.Append(" FROM RHCC");
            query.Append(" WHERE HCONSO = '" + rhcc.HCONSO + "'");
            query.Append(" AND HSTS > 30");
            if (rhcc.HPLTA != null)
            {
                query.Append(" AND HPLTA = '" + rhcc.HPLTA + "'");
            }
            return(db.Query <RHCC>(query.ToString()).SingleOrDefault());
        }
Ejemplo n.º 5
0
        public string Update(RHCC rhcc)
        {
            string        res;
            StringBuilder query = new StringBuilder();

            query.Append(" UPDATE RHCC");
            query.Append(" SET");
            query.Append(" HESTAD = " + rhcc.HESTAD + ", HFESTAD = NOW(),");
            if (rhcc.HLLEGA != null)
            {
                query.Append(" HLLEGA = '" + rhcc.HLLEGA + "'");
            }
            if (rhcc.HSALE != null)
            {
                query.Append(" HSALE = '" + rhcc.HSALE + "'");
            }
            query.Append(" WHERE HCONSO = '" + rhcc.HCONSO + "' AND HSTS <= " + rhcc.HSTS);

            try
            {
                db.Execute(query.ToString(), rhcc);
                res = "OK";
            }
            catch (iDB2SQLErrorException ex)
            {
                res = ex.Message;
            }
            catch (iDB2Exception ex)
            {
                res = ex.Message;
            }
            catch (Exception ex)
            {
                res = ex.Message;
            }
            return(res);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// API central de Reporte
        /// </summary>
        /// <param name="FT">
        /// </param>
        /// <returns></returns>
        public IHttpActionResult Reporte(FiltroTrafico FT)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var           res = "";
            StringBuilder txt = new StringBuilder();

            try
            {
                txt.Append("{\"ACCION\":\"" + FT.ACCION + "\",");
                txt.Append(" \"USUARIO\":\"" + FT.USUARIO + "\",");
                txt.Append(" \"PASSWORD\":\"" + FT.PASSWORD + "\",");
                txt.Append(" \"CONSO\":\"" + FT.CONSO + "\",");
                txt.Append(" \"REPORTE\":\"" + FT.REPORTE + "\",");
                txt.Append(" \"PLANILLA\":\"" + FT.PLANILLA + "\",");
                txt.Append(" \"PLACA\":\"" + FT.PLACA + "\",");
                txt.Append(" \"FECREP\":\"" + FT.FECREP.ToString("yyyy-MM-dd HH:mm:ss") + "\",");
                txt.Append(" \"CODDANE\":\"" + FT.CODDANE + "\",");
                txt.Append(" \"CODNOVEDAD\":\"" + FT.CODNOVEDAD + "\",");
                txt.Append(" \"NUMERO\":\"" + FT.NUMERO + "\"}");

                var nRFLOG = new RFLOG()
                {
                    OPERACION = "CapturaJson",
                    EVENTO    = "Trafico",
                    TXTSQL    = txt.ToString().Replace("'", "''"),
                    ALERT     = "0"
                };
                res = dRFLOG.Add(nRFLOG);

                res = dRCAU.ExisteUSR(FT.USUARIO, FT.PASSWORD);
                if (res == "OK")
                {
                    switch (FT.ACCION.ToUpper())
                    {
                    case "NUEVOTRAFICO":
                        res = NewTraffic(FT.CONSO);
                        break;

                    case "ENTRANSITO":
                        var resu = InTransit();
                        return(Json(resu));

                    case "REPORTAR":
                        var resul = "";
                        var nRRCC = new RRCC()
                        {
                            RCONSO  = FT.CONSO.Trim(),
                            RPLANI  = (FT.PLANILLA == "") ? "0" : FT.PLANILLA,
                            RPLACA  = FT.PLACA,
                            RFECREP = FT.FECREP.ToString("yyyy-MM-dd-HH.mm.ss.000000"),
                            RUBIC   = FT.CODDANE,
                            RTIPNOV = FT.CODNOVEDAD,
                            RREPORT = FT.REPORTE,
                            RCRTUSR = FT.USUARIO,
                            RWINDAT = DateTime.Now.ToString("yyyy-MM-dd-HH.mm.ss.000000")
                        };
                        resul = dRRCC.AddReporte(nRRCC);
                        if (!resul.Contains("ERROR"))
                        {
                            res = "OK";
                        }
                        else
                        {
                            res = resul;
                        }
                        if (res == "OK")
                        {
                            var rep = "";
                            if (FT.REPORTE.Length > 50)
                            {
                                rep = FT.REPORTE.Substring(0, 50);
                            }
                            else
                            {
                                rep = FT.REPORTE;
                            }
                            var uRHCC = new RHCC()
                            {
                                RFECREP = FT.FECREP.ToString("yyyy-MM-dd-HH.mm.ss.000000"),
                                RREPORT = rep,
                                HCONSO  = FT.CONSO.Trim()
                            };
                            res = dRHCC.UpdateHREPORT(uRHCC);
                            if (res == "OK")
                            {
                                res = resul;
                            }
                        }
                        break;

                    case "FINALIZARTRAFICO":
                        res = EndTraffic(FT);
                        break;

                    case "NUEVOSEGUIMIENTO":
                        res = NewFllowUp(FT.NUMERO);
                        break;

                    case "NUEVOTRAFICOXML":
                        res = GeneraXMLNew2(FT.CONSO);
                        break;

                    case "NUEVOSEGUIMIENTOXML":
                        res = GeneraXMLFollow2(FT.NUMERO);
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                res = "ERROR: " + ex.Message;
                if (ex.InnerException != null)
                {
                    res = res + " - " + ex.InnerException;
                }
                if (ex.StackTrace != null)
                {
                    res = res + " - " + ex.StackTrace;
                }
                res = res + txt.ToString();
            }
            finally
            {
                if (res.Contains("ERROR"))
                {
                    var nRFLOG = new RFLOG()
                    {
                        OPERACION = "TRAFICO",
                        EVENTO    = "ERROR",
                        TXTSQL    = res.Replace("'", "''"),
                        ALERT     = "0"
                    };
                    dRFLOG.Add(nRFLOG);
                }
            }
            return(Json(new { Resultado = res }));
        }
Ejemplo n.º 7
0
        private string GeneraXMLNew2(string consoli)
        {
            mRHCC = dRHCC.GetConsoTrafico(consoli);
            if (mRHCC != null)
            {
                var Sts       = 0;
                var Destinos  = "";
                var Planillas = "";
                if (mRHCC.HSTS < 50)
                {
                    Sts = 54;
                }
                else
                {
                    Sts = 24;
                }

                lmRDCC = dRDCC.GetDestino(consoli);
                if (lmRDCC != null)
                {
                    if (lmRDCC.Count > 0)
                    {
                        Destinos = "";
                        foreach (var item in lmRDCC)
                        {
                            if (Destinos == "")
                            {
                                Destinos = item.Destino.Trim();
                            }
                            else
                            {
                                Destinos = Destinos + "," + item.Destino.Trim();
                            }
                        }
                    }
                }

                lmRDCC = dRDCC.GetPlanilla(consoli);
                if (lmRDCC != null)
                {
                    if (lmRDCC.Count > 0)
                    {
                        Planillas = "";
                        foreach (var item in lmRDCC)
                        {
                            if (Planillas == "")
                            {
                                Planillas = item.DPLANI.Trim();
                            }
                            else
                            {
                                Planillas = Planillas + "," + item.DPLANI.Trim();
                            }
                        }
                    }
                }

                StringBuilder xmml = new StringBuilder();
                xmml.Append("<soapenv:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:web='http://localhost:1001/webservice/'>");
                xmml.Append("    <soapenv:Header />");
                xmml.Append("    <soapenv:Body>");
                xmml.Append("        <web:nuevoTrafico soapenv:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'>");
                xmml.AppendFormat("            <placa xsi:type='xsd:string'>{0}</placa>", mRHCC.HPLACA);
                xmml.AppendFormat("            <manifiesto xsi:type='xsd:string'>{0}</manifiesto>", mRHCC.HMANIF);
                xmml.AppendFormat("            <ccConductor xsi:type='xsd:string'>{0}</ccConductor>", mRHCC.HCEDUL);
                xmml.AppendFormat("            <NombreConductor xsi:type='xsd:string'>{0}</NombreConductor>", mRHCC.HCHOFE);
                xmml.AppendFormat("            <celular xsi:type='xsd:string'>{0}</celular>", mRHCC.HCELU);
                xmml.AppendFormat("            <origen xsi:type='xsd:int'>{0}</origen>", int.Parse((mRHCC.Origen == "") ? "0" : mRHCC.Origen.Trim()));
                xmml.AppendFormat("            <destino xsi:type='xsd:string'>{0}</destino>", Destinos);
                xmml.AppendFormat("            <observacion xsi:type='xsd:string'>{0}</observacion>", "");
                xmml.AppendFormat("            <fechaInicio xsi:type='xsd:date'>{0}</fechaInicio>", DateTime.Now.ToString("yyyy-MM-dd-HH:mm"));
                xmml.AppendFormat("            <horaInicio xsi:type='xsd:time'>{0}</horaInicio>", DateTime.Now.ToString("HH:mm:ss"));
                xmml.AppendFormat("            <UrlGps xsi:type='xsd:string'>{0}</UrlGps>", mRHCC.XCGPSPAG);
                xmml.AppendFormat("            <usuarioGps xsi:type='xsd:string'>{0}</usuarioGps>", mRHCC.XCGPSUSR);
                xmml.AppendFormat("            <ContrasenaGps xsi:type='xsd:string'>{0}</ContrasenaGps>", mRHCC.XCGPSPASS);
                xmml.AppendFormat("            <Usuario xsi:type='xsd:string'>{0}</Usuario>", "brinsa");
                xmml.AppendFormat("            <Clave xsi:type='xsd:string'>{0}</Clave>", "brinsa2017");
                xmml.AppendFormat("            <item1 xsi:type='xsd:string'>{0}</item1>", "");
                xmml.AppendFormat("            <item2 xsi:type='xsd:string'>{0}</item2>", "");
                xmml.AppendFormat("            <item3 xsi:type='xsd:string'>{0}</item3>", "");
                xmml.AppendFormat("            <generadorCarga xsi:type='xsd:string'>{0}</generadorCarga>", "");
                xmml.AppendFormat("            <estado xsi:type='xsd:int'>{0}</estado>", Sts);
                xmml.AppendFormat("            <consolidado xsi:type='xsd:int'>{0}</consolidado>", int.Parse(consoli));
                xmml.AppendFormat("            <planilla xsi:type='xsd:string'>{0}</planilla>", Planillas);
                xmml.Append("        </web:nuevoTrafico>");
                xmml.Append("    </soapenv:Body>");
                xmml.Append("</soapenv:Envelope>");

                return(xmml.ToString());
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 8
0
        private string NewTraffic(string consoli)
        {
            var resu = "";

            mRHCC = dRHCC.GetConsoTrafico(consoli);
            if (mRHCC != null)
            {
                var Sts       = 0;
                var Destinos  = "";
                var Planillas = "";
                if (mRHCC.HSTS < 50)
                {
                    Sts = 54;
                }
                else
                {
                    Sts = 24;
                }

                lmRDCC = dRDCC.GetDestino(consoli);
                if (lmRDCC != null)
                {
                    if (lmRDCC.Count > 0)
                    {
                        Destinos = "";
                        foreach (var item in lmRDCC)
                        {
                            if (Destinos == "")
                            {
                                Destinos = item.Destino.Trim();
                            }
                            else
                            {
                                Destinos = Destinos + "," + item.Destino.Trim();
                            }
                        }
                    }
                }

                lmRDCC = dRDCC.GetPlanilla(consoli);
                if (lmRDCC != null)
                {
                    if (lmRDCC.Count > 0)
                    {
                        Planillas = "";
                        foreach (var item in lmRDCC)
                        {
                            if (Planillas == "")
                            {
                                Planillas = item.DPLANI.Trim();
                            }
                            else
                            {
                                Planillas = Planillas + "," + item.DPLANI.Trim();
                            }
                        }
                    }
                }

                //var xml = GeneraXMLNew(mRHCC.HPLACA, mRHCC.HMANIF, mRHCC.HCEDUL, mRHCC.HCHOFE, mRHCC.HCELU, int.Parse(mRHCC.Origen.Trim()), Destinos, "", DateTime.Now.ToString("yyyy-MM-dd-HH:mm"), DateTime.Now.ToString("HH:mm:ss"), mRHCC.XCGPSPAG, mRHCC.XCGPSUSR, mRHCC.XCGPSPASS, "brinsa", "brinsa2017", "", "", "", "", Sts, int.Parse(consoli), Planillas);
                var hh        = new com.nygsoft.huella.Servicioingresonuevotrafico();
                var respuesta = hh.nuevoTrafico(mRHCC.HPLACA, mRHCC.HMANIF, mRHCC.HCEDUL, mRHCC.HCHOFE, mRHCC.HCELU, int.Parse((mRHCC.Origen == "") ? "0" : mRHCC.Origen.Trim()), Destinos, "", DateTime.Now, DateTime.Now, mRHCC.XCGPSPAG, mRHCC.XCGPSUSR, mRHCC.XCGPSPASS, "brinsa", "brinsa2017", "", "", "", "", Sts, int.Parse(consoli), Planillas);

                resu = respuesta[0].mensaje;
            }

            return(resu);
        }
Ejemplo n.º 9
0
        private string Conso(string consoli, string hora, string entrada, string planta)
        {
            string result = "";
            bool   sale   = false;
            bool   entra  = false;
            var    Prove  = "";

            mRHCC = null;
            mRHCC = new RHCC()
            {
                HCONSO = consoli,
                HPLTA  = planta
            };
            mRHCC = dRHCC.GetConsoSalida(mRHCC);
            if (mRHCC != null)
            {
                Prove   = mRHCC.HPROVE;
                entrada = "False";
                if (mRHCC.HSTS >= 30 && mRHCC.HSTS <= 50)
                {
                    sale    = true;
                    entrada = "False";
                }
                else
                {
                    mRFLOG.OPERACION = "Consulta RHCC Estado";
                    mRFLOG.EVENTO    = "Consolidado " + consoli + " con estado " + mRHCC.HSTS;
                    mRFLOG.ALERT     = "0";
                    mRFLOG.USUARIO   = "";
                    result           = dRFLOG.Add(mRFLOG);
                    if (result == "OK")
                    {
                        result = "RHCC Estado no esta entre 30 y 50";
                    }
                }
                if (mRHCC.HSTS > 50)
                {
                    sale    = false;
                    entrada = "False";
                }

                if (entrada == "OK")
                {
                    mRRCC.RREPORT = "Llegada a Planta";
                    mRRCC.RCRTDAT = hora;
                    mRRCC.RAPP    = "SMSENTRADA";
                    mRRCC.HCONSO  = consoli;
                    result        = dRRCC.Add(mRRCC);
                    if (result == "OK")
                    {
                        mRRCCT.RFEC17 = hora;
                        mRRCCT.RCONSO = consoli;
                        result        = dRRCCT.Update(mRRCCT);
                        if (result == "OK" && entra)
                        {
                            mRHCC.HESTAD = "17";
                            mRHCC.HLLEGA = hora;
                            mRHCC.HCONSO = consoli;
                            mRHCC.HSTS   = 20;
                            result       = dRHCC.Update(mRHCC);
                        }
                    }
                }
                else
                {
                    var condespacho = dRDCC.GetDespacho(consoli);
                    if (condespacho.Count != 0)
                    {
                        var existRRCC = dRRCC.FindConso(consoli, "SMSSALIDA");
                        if (existRRCC.Count == 0)
                        {
                            if (sale)
                            {
                                mRHCC = null;
                                mRHCC = new RHCC
                                {
                                    HESTAD = "5",
                                    HSALE  = hora,
                                    HCONSO = consoli,
                                    HSTS   = 50
                                };
                                result = dRHCC.Update(mRHCC);
                            }
                            else
                            {
                                result = "OK";
                            }
                            if (result == "OK")
                            {
                                mRRCC.RREPORT = "Salida de Planta";
                                mRRCC.RCRTDAT = hora;
                                mRRCC.RAPP    = "SMSSALIDA";
                                mRRCC.HCONSO  = consoli;
                                result        = dRRCC.Add(mRRCC);
                                if (result == "OK")
                                {
                                    mRDRIVERDAT = dRDRIVERDAT.GetInfo(consoli);
                                    if (mRDRIVERDAT == null)
                                    {
                                        result = dRDRIVERDAT.Add(consoli);
                                    }
                                    if (result == "OK")
                                    {
                                        mRRCCT        = null;
                                        mRRCCT        = new RRCCT();
                                        mRRCCT.RFEC50 = hora;
                                        mRRCCT.RCONSO = consoli;
                                        result        = dRRCCT.Update(mRRCCT);
                                    }
                                }
                            }
                            var nRFTASK = new RFTASK()
                            {
                                TPRM     = "|CONSO=" + consoli,
                                TKEY     = consoli,
                                TKEYWORD = consoli,
                                TCRTUSR  = "******"
                            };
                            result = dRFTASK.Add(nRFTASK);
                        }
                        else
                        {
                            result = "Ya se realizó la salida";
                        }
                    }
                    else
                    {
                        mRFLOG.OPERACION = "Consulta Despacho";
                        mRFLOG.EVENTO    = "Consolidado " + consoli + " sin despacho";
                        mRFLOG.ALERT     = "1";
                        result           = dRFLOG.Add(mRFLOG);
                    }
                }
                if (Prove == "5115")
                {
                    var nTra = new FiltroTrafico()
                    {
                        ACCION   = "nuevotrafico",
                        USUARIO  = "BSS2",
                        PASSWORD = "******",
                        CONSO    = consoli
                    };
                    var t = new TraficoController();
                    t.Reporte(nTra);
                }
            }
            else
            {
                mRFLOG.OPERACION = "Consulta Consolidado";
                mRFLOG.EVENTO    = "No Existe Consolidado " + consoli;
                mRFLOG.ALERT     = "1";
                result           = dRFLOG.Add(mRFLOG);
            }

            return(result);
        }