Esempio 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);
        }
Esempio n. 2
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 }));
        }
Esempio n. 3
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);
        }