コード例 #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>
        /// 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));
        }