Пример #1
0
        /// <summary>
        /// Procesa un mensaje de tipo Receipt
        /// </summary>
        /// <param name="msg">El mensaje Receipt</param>
        public void ProcessReceipt(ReceiptType receipt)
        {
            decimal?price = null;

            if (receipt.ReceiptCode == receiptCodeType.Item0 && receipt.ReferenceId.Length > 0)
            {
                //Era un recibo correspondiente a un REQUERIMIENTO?
                var sprm = new ShipPositionRequestDataAccess();
                if (sprm.RequestExists(receipt.ReferenceId) == true)
                {
                    var pman = new PricingManager();
                    price = pman.GetPriceForRequest(receipt.ReferenceId, receipt.Originator);
                    if (price == null)
                    {
                        log.Warn(string.Format("ProcessReceipt: Se recibio un receipt codigo 0 {0}, no podemos poner precio", receipt.MessageId));
                    }
                }
                else
                {
                    log.Warn(string.Format("ProcessReceipt: recibo 0 {0} no referido a Requerimiento", receipt.MessageId));
                }
            }

            using (var dao = new ReceiptDataAccess())
            {
                dao.Create(TypeHelper.Map2DB(receipt), 0, price);
            }
            log.Info(string.Format("Receipt successfully processed: price {0}", price));
        }
Пример #2
0
        /// <summary>
        /// Envia un mensaje de tipo ShipPositionReport al IDE
        /// </summary>
        /// <param name="msg">Mensaje ShipPositionReport</param>
        private string SendShipPositionReport(Message msg)
        {
            DataCenterLogic.DataCenterTypesIDE.ShipPositionReportType shipPositionReport = (DataCenterLogic.DataCenterTypesIDE.ShipPositionReportType)(msg.Body);

            //Send to IDE
            if (System.Configuration.ConfigurationManager.AppSettings["send2servers"] != "False")
            {
                shipPositionReport.test = DataCenterLogic.DataCenterTypesIDE.testType.Item0;
                ideClient.ShipPositionReport(shipPositionReport);
                log.Info("SendShipPositionReport: shipPositionReport sent to IDE");
            }

            //ReferenceID puede ser de un report o "" si es SO
            //DataUserProvider deberia ser siempre 1005
            var     pricing = new PricingManager();
            decimal?price   = pricing.GetPriceForRequest(shipPositionReport.ReferenceId, shipPositionReport.DataUserProvider);

            //No tengo precio y es Es una reporte NO SAR?
            if (price == null)
            {
                log.Warn(string.Format("SendShipPositionReport: Se manda un reporte {0} de posicion sin precio", shipPositionReport.MessageId));
            }

            //Guarda el mensaje en la base de datos
            using (var dao = new ShipPositionReportDataAccess())
            {
                dao.Create(TypeHelper.Map2DB(shipPositionReport), 1, price);
            }
            log.Info(string.Format("ShipPositionReport stored: price {0}", price));
            return(shipPositionReport.MessageId);
        }
Пример #3
0
        /// <summary>
        /// Envia un mensaje de tipo Receipt al IDE
        /// </summary>
        /// <param name="msg">Mensaje Receipt</param>
        private string SendReceipt(Message msg)
        {
            DataCenterLogic.DataCenterTypesIDE.ReceiptType receipt = (DataCenterLogic.DataCenterTypesIDE.ReceiptType)(msg.Body);

            //Send to IDE
            if (System.Configuration.ConfigurationManager.AppSettings["send2servers"] != "False")
            {
                receipt.test = DataCenterLogic.DataCenterTypesIDE.testType.Item0;
                ideClient.Receipt(receipt);
                log.Info("SendReceipt: receipt sent to IDE");
            }

            //Get price for receipt
            //El codigo 0 dice todo, si es codigo 0 quiere decir que este recibo se esta mandando por que no se pudo mandar una posicion
            //Por lo tanto el request debe existir o sino fue de una standing order.
            decimal?price = null;

            if (receipt.ReceiptCode == 0)
            {
                var pman = new PricingManager();
                price = pman.GetPriceForRequest(receipt.ReferenceId, receipt.Originator);
                if (price == null)
                {
                    log.Warn(string.Format("SendReceipt: Se manda un receipt codigo 0 {0} sin precio", receipt.MessageId));
                }
            }

            //Guarda el mensaje en la base de datos
            using (var dao = new ReceiptDataAccess())
            {
                dao.Create(TypeHelper.Map2DB(receipt), 1, price);
            }

            log.Info(string.Format("Receipt stored: price {0}", price));
            return(receipt.MessageId);
        }
Пример #4
0
        /// <summary>
        /// Procesa un mensaje de tipo ShipPositionReport
        /// </summary>
        /// <param name="msg">El mensaje ShipPositionReport</param>
        public void ProcessShipPositionReport(DataCenterTypes.ShipPositionReportType shipPositionReport)
        {
            var configMgr = new ConfigurationManager();

            //Verifica si existe el Data User que requiere la información
            var cgm  = new ContractingGovermentManager();
            var ddpm = new DDPVersionManager();

            var ddpVersion = ddpm.GetCurrentDDPVersion();

            var contractingGoverment = cgm.GetContractingGovermentByLRITId(shipPositionReport.DataUserRequestor, ddpVersion.Id);

            if (contractingGoverment == null)
            {
                string strError = string.Format("Specified LDU '{0}' does not exist", shipPositionReport.DataUserRequestor);

                //Arma mensaje de Recibo
                DataCenterLogic.DataCenterTypes.ReceiptType receipt = new DataCenterLogic.DataCenterTypes.ReceiptType();


                receipt.DDPVersionNum = DDPVersionManager.currentDDP();
                receipt.Destination   = shipPositionReport.DCId;
                receipt.Message       = strError;
                receipt.MessageId     = MessageIdManager.Generate();
                receipt.MessageType   = DataCenterLogic.DataCenterTypes.messageTypeType3.Item7;
                receipt.Originator    = configMgr.Configuration.DataCenterID;
                receipt.ReceiptCode   = DataCenterLogic.DataCenterTypes.receiptCodeType.Item7;
                receipt.ReferenceId   = shipPositionReport.MessageId;
                receipt.schemaVersion = decimal.Parse(configMgr.Configuration.SchemaVersion);
                receipt.test          = DataCenterLogic.DataCenterTypes.testType.Item1;
                receipt.TimeStamp     = DateTime.UtcNow;

                Message msgout = new Message(receipt);
                msgout.Label = "receipt";

                //Encola mensaje
                QueueManager.Instance().EnqueueOut(msgout);

                log.Error(strError);
                return;
            }

            //Verifica si el existe el Id de referencia
            if (shipPositionReport.ReferenceId != "")
            {
                var sprda = new ShipPositionRequestDataAccess();
                if (sprda.RequestExists(shipPositionReport.ReferenceId) == false)
                {
                    string strError = string.Format("MessageID not found for ReferenceID '{0}'", shipPositionReport.ReferenceId);

                    //Envía Recibo
                    DataCenterLogic.DataCenterTypes.ReceiptType receipt = new DataCenterLogic.DataCenterTypes.ReceiptType();
                    receipt.DDPVersionNum = DDPVersionManager.currentDDP();
                    receipt.Destination   = shipPositionReport.DCId;
                    receipt.Message       = strError;
                    receipt.MessageId     = MessageIdManager.Generate();
                    receipt.MessageType   = DataCenterLogic.DataCenterTypes.messageTypeType3.Item7;
                    receipt.Originator    = configMgr.Configuration.DataCenterID;
                    receipt.ReceiptCode   = DataCenterLogic.DataCenterTypes.receiptCodeType.Item7;
                    receipt.ReferenceId   = shipPositionReport.MessageId;
                    receipt.schemaVersion = decimal.Parse(configMgr.Configuration.SchemaVersion);
                    receipt.test          = DataCenterLogic.DataCenterTypes.testType.Item1;
                    receipt.TimeStamp     = DateTime.UtcNow;

                    Message msgout = new Message(receipt);
                    msgout.Label = "receipt";

                    //Envia mensaje
                    QueueManager.Instance().EnqueueOut(msgout);

                    log.Error(strError);
                    return;
                }
            }

            //ReferenceID puede ser de un report o "" si es SO
            //DataUserProvider es el usuario que nos manda (deberiamos tener contrato con el)
            var     pricing = new PricingManager();
            decimal?price   = pricing.GetPriceForRequest(shipPositionReport.ReferenceId, shipPositionReport.DataUserProvider);

            //No tengo precio?
            if (price == null)
            {
                log.Warn(string.Format("SendShipPositionReport: Se recibio un reporte {0} de posicion, no podemos poner precio", shipPositionReport.MessageId));
            }

            //Save position report to DB
            using (var dao = new ShipPositionReportDataAccess())
            {
                dao.Create(TypeHelper.Map2DB(shipPositionReport), 0, price);
            }

            log.Info(string.Format("ShipPositionReport successfully processed: price {0}", price));
        }