예제 #1
0
        /// <summary>
        /// Procesa un mensaje de tipo PricingNotification
        /// </summary>
        /// <param name="msg">El mensaje PricingNotification</param>
        public void ProcessPricingNotification(PricingNotificationType pricingNotification)
        {
            ConfigurationManager cmgr = new ConfigurationManager();

            DataCenterTypesIDE.PricingRequestType preq = new DataCenterLogic.DataCenterTypesIDE.PricingRequestType();
            preq.DDPVersionNum = DDPVersionManager.currentDDP();
            preq.MessageId     = MessageIdManager.Generate();
            preq.MessageType   = DataCenterLogic.DataCenterTypesIDE.messageTypeType6.Item14;
            preq.Originator    = cmgr.Configuration.DataCenterID;
            preq.ReferenceId   = pricingNotification.MessageId;
            preq.schemaVersion = decimal.Parse(cmgr.Configuration.SchemaVersion);
            preq.test          = DataCenterLogic.DataCenterTypesIDE.testType.Item0;
            preq.TimeStamp     = DateTime.UtcNow;

            //Enqueue DDPrequest
            Message msgout = new Message(preq);

            msgout.Label = "priceRequest";
            QueueManager.Instance().EnqueueOut(msgout);

            using (PricingNotificationDataAccess dao = new PricingNotificationDataAccess())
            {
                dao.Create(TypeHelper.Map2DB(pricingNotification), 0);
            }
            log.Info("PricingNotification successfully processed");
        }
예제 #2
0
        /// <summary>
        /// Procesa un mensaje de tipo SARSurpicRequest.
        /// </summary>
        /// <param name="msg">Mensaje SARSURPICRequest</param>
        public void ProcessSARSURPICRequest(SARSURPICType SARSURPICRequest)
        {
            var configMgr           = new ConfigurationManager();
            var shipPositionManager = new ShipPositionManager();

            List <ShipPosition> shipPositions;

            if (SARSURPICRequest.ItemElementName == DataCenterLogic.DataCenterTypes.ItemChoiceType1.SARCircularArea)
            {
                shipPositions = shipPositionManager.GetLastPositionsInCircularArea(SARSURPICRequest.Item, int.Parse(SARSURPICRequest.NumberOfPositions));
            }
            else
            {
                shipPositions = shipPositionManager.GetLastPositionsInRectangularArea(SARSURPICRequest.Item, int.Parse(SARSURPICRequest.NumberOfPositions));
            }

            if (shipPositions.Count == 0)
            {
                DataCenterTypesIDE.ReceiptType receipt = new DataCenterLogic.DataCenterTypesIDE.ReceiptType();
                receipt.DDPVersionNum = DDPVersionManager.currentDDP();
                receipt.Destination   = SARSURPICRequest.DataUserRequestor;
                receipt.Message       = "No positions";
                receipt.MessageId     = MessageIdManager.Generate();
                receipt.MessageType   = DataCenterLogic.DataCenterTypesIDE.messageTypeType3.Item7;
                receipt.Originator    = "1005";
                receipt.ReceiptCode   = DataCenterLogic.DataCenterTypesIDE.receiptCodeType.Item7;
                receipt.ReferenceId   = SARSURPICRequest.MessageId;
                receipt.schemaVersion = decimal.Parse(configMgr.Configuration.SchemaVersion);
                receipt.test          = DataCenterLogic.DataCenterTypesIDE.testType.Item1;
                receipt.TimeStamp     = DateTime.UtcNow;

                //Receipt sent
                Message msgout = new Message(receipt);
                msgout.Label = "receipt";
                QueueManager.Instance().EnqueueOut(msgout);
            }
            else
            {
                using (var shipdao = new ShipDataAccess())
                {
                    var sprm = new ShipPositionReportManager();
                    foreach (ShipPosition shipPos in shipPositions)
                    {
                        sprm.SendReport(SARSURPICRequest.DataUserRequestor, shipPos, SARSURPICRequest.MessageId, DataCenterLogic.DataCenterTypesIDE.responseTypeType.Item4, DataCenterLogic.DataCenterTypesIDE.messageTypeType.Item3);
                    }
                }
            }

            using (var dao = new SARSURPICRequestDataAccess())
            {
                dao.Create(TypeHelper.Map2DB(SARSURPICRequest), 0);
            }
            log.Info("SARSURPICRequest successfully processed");
        }
예제 #3
0
        public void SendReport(string requestor, ShipPosition position, string referenceId, DataCenterTypesIDE.responseTypeType responseType, DataCenterLogic.DataCenterTypesIDE.messageTypeType messageType)
        {
            //Configuracion del datacenter
            var configMgr = new ConfigurationManager();

            //DataCenterTypesIDE.responseTypeType responseType = getResponseTypeFromRequest(spr);
            //DataCenterLogic.DataCenterTypesIDE.messageTypeType messageType = getMessageTypeFromRequest(spr);

            //Obtengo el ship al que pertenece la posicion
            using (var shipdao = new ShipDataAccess())
            {
                Ship ship = shipdao.getById(position.ShipId);

                var shipPosReport = new DataCenterTypesIDE.ShipPositionReportType();

                var point = SqlGeography.STPointFromWKB(new System.Data.SqlTypes.SqlBytes(position.Position.ToArray()), 4326);

                shipPosReport.ASPId = configMgr.Configuration.ASPId;

                shipPosReport.DataUserProvider = "1005";
                //if( responseType == DataCenterLogic.DataCenterTypesIDE.responseTypeType.Item4 )
                //  shipPosReport.DataUserProvider = "3005";

                shipPosReport.DataUserRequestor = requestor;
                shipPosReport.DCId                 = configMgr.Configuration.DataCenterID;
                shipPosReport.DDPVersionNum        = DDPVersionManager.currentDDP();
                shipPosReport.IMONum               = ship.IMONum;
                shipPosReport.Latitude             = WGS84LatFormat(point.Lat.Value);
                shipPosReport.Longitude            = WGS84LongFormat(point.Long.Value);
                shipPosReport.MessageId            = MessageIdManager.Generate();
                shipPosReport.MessageType          = messageType;
                shipPosReport.MMSINum              = ship.MMSINum;
                shipPosReport.ReferenceId          = referenceId;
                shipPosReport.ResponseType         = responseType;
                shipPosReport.schemaVersion        = decimal.Parse(configMgr.Configuration.SchemaVersion);
                shipPosReport.ShipborneEquipmentId = ship.EquipID;
                shipPosReport.ShipName             = ship.Name;
                shipPosReport.test                 = DataCenterLogic.DataCenterTypesIDE.testType.Item1;
                shipPosReport.TimeStamp1           = position.TimeStamp;
                shipPosReport.TimeStamp2           = position.TimeStampInASP;
                shipPosReport.TimeStamp3           = position.TimeStampOutASP;
                shipPosReport.TimeStamp4           = position.TimeStampInDC;
                shipPosReport.TimeStamp5           = DateTime.UtcNow;

                log.Debug("Enqueing Report for ship: " + shipPosReport.IMONum + " Pos. Long. Lat.:" + shipPosReport.Longitude + " " + shipPosReport.Latitude + " Requestor: " + shipPosReport.DataUserRequestor);
                QueueManager.Instance().EnqueueOut(shipPosReport, "shipPositionReport");
            }
        }
예제 #4
0
        /// <summary>
        /// Procesa un mensaje de tipo DDP Notification.
        /// Esta funcion incorpora el mensaje a la base de datos y pide al DDP un requerimiento de actualizacion
        /// </summary>
        /// <param name="msg">Mensaje DDPNotification</param>
        public void ProcessDDPNotification(DDPNotificationType ddpNotification)
        {
            var ddpRequest = new DataCenterLogic.DDPServerTypes.DDPRequestType();

            ConfigurationManager configMgr = new ConfigurationManager();

            var dver = new DDPVersionDataAccess();
            var ver  = dver.TodaysDDP();

            ddpRequest.ArchivedDDPTimeStamp          = DateTime.UtcNow;
            ddpRequest.ArchivedDDPTimeStampSpecified = false;
            ddpRequest.ArchivedDDPVersionNum         = null;
            ddpRequest.DDPVersionNum = ver.regularVer + ":" + ver.inmediateVer;
            ddpRequest.MessageId     = MessageIdManager.Generate();
            ddpRequest.MessageType   = DataCenterLogic.DDPServerTypes.messageTypeType.Item9;
            ddpRequest.Originator    = configMgr.Configuration.DataCenterID;
            ddpRequest.schemaVersion = decimal.Parse(configMgr.Configuration.SchemaVersion);
            ddpRequest.test          = DataCenterLogic.DDPServerTypes.testType.Item1;
            ddpRequest.TimeStamp     = DateTime.UtcNow;

            //Si el notification es 0 (Regular) pedimos regular
            if (ddpNotification.UpdateType == DDPNotificationTypeUpdateType.Item0)
            {
                ddpRequest.UpdateType = DataCenterLogic.DDPServerTypes.DDPRequestTypeUpdateType.Item0;
            }

            //Si el notification es 1 (Inmediate) pedimos inmediate
            if (ddpNotification.UpdateType == DDPNotificationTypeUpdateType.Item1)
            {
                ddpRequest.UpdateType = DataCenterLogic.DDPServerTypes.DDPRequestTypeUpdateType.Item1;
            }

            //Enqueue DDPrequest
            Message msgout = new Message(ddpRequest);

            msgout.Label = "ddpRequest";
            QueueManager.Instance().EnqueueOut(msgout);

            using (DDPNotificationDataAccess dao = new DDPNotificationDataAccess())
            {
                dao.Create(TypeHelper.Map2DB(ddpNotification), 0);
            }
            log.Info("DDPNotification successfully processed");
        }
예제 #5
0
        public Message MakeDDPRequest(DDPServerTypes.DDPRequestType ddpRequest)
        {
            ConfigurationManager configMgr = new ConfigurationManager();

            var ddpverda = new DDPVersionManager();
            var ddpver   = ddpverda.DDPFromDate(DateTime.UtcNow);

            //Fill necesary parameters
            ddpRequest.DDPVersionNum = ddpver.regularVer + ":" + ddpver.inmediateVer;
            ddpRequest.MessageId     = MessageIdManager.Generate();
            ddpRequest.MessageType   = DataCenterLogic.DDPServerTypes.messageTypeType.Item9;
            ddpRequest.Originator    = configMgr.Configuration.DataCenterID;
            //ddpRequest.ReferenceId
            ddpRequest.schemaVersion = decimal.Parse(configMgr.Configuration.SchemaVersion);
            ddpRequest.TimeStamp     = DateTime.UtcNow;

            //Enqueue DDPrequest
            Message msgout = new Message(ddpRequest);

            msgout.Label = "ddpRequest";

            return(msgout);
        }
예제 #6
0
        /// <summary>
        /// Envia un Recibo a el Destino especificado.
        /// </summary>
        /// <param name="Destination">Destino del recibo</param>
        /// <param name="ReferenceId">ID LRIT del mensaje al que hace referencia este recibo</param>
        /// <param name="receiptCode">Codigo del recibo</param>
        /// <param name="msg">Mensaje de texto decribiendo el porque del recibo</param>
        static public void SendReceipt(string Destination, string ReferenceId, DataCenterLogic.DataCenterTypesIDE.receiptCodeType receiptCode, string msg)
        {
            //The ship does not exists in our system, send receipt
            var configMgr = new ConfigurationManager();

            DataCenterTypesIDE.ReceiptType receipt = new DataCenterLogic.DataCenterTypesIDE.ReceiptType();
            receipt.DDPVersionNum = DDPVersionManager.currentDDP();
            receipt.Destination   = Destination;
            receipt.Message       = msg;
            receipt.MessageId     = MessageIdManager.Generate();
            receipt.MessageType   = DataCenterLogic.DataCenterTypesIDE.messageTypeType3.Item7;
            receipt.ReceiptCode   = receiptCode;
            receipt.Originator    = "1005";
            receipt.ReferenceId   = ReferenceId;
            receipt.schemaVersion = decimal.Parse(configMgr.Configuration.SchemaVersion);
            receipt.test          = DataCenterLogic.DataCenterTypesIDE.testType.Item1;
            receipt.TimeStamp     = DateTime.UtcNow;

            Message msgout = new Message(receipt);

            msgout.Label = "receipt";

            QueueManager.Instance().EnqueueOut(msgout);
        }
예제 #7
0
        /// <summary>
        /// Valida la combinacion de accesType y requestType para un ShipPositionRequest.
        /// Si hay algun error esta funcion envia un Receipt al requisitor, informandole el problema.
        /// </summary>
        /// <param name="shipPositionRequest">El mensaje ShipPositionRequest a ser analizado.</param>
        /// <returns>Verdadero, si el mensaje es valido, False otra cosa</returns>
        private bool ValidateShipPositionRequest(DataCenterLogic.DataCenterTypes.ShipPositionRequestType shipPositionRequest)
        {
            var ddpm       = new DDPVersionManager();
            var ddpVersion = ddpm.GetCurrentDDPVersion();

            log.Info("Validando SPR");
            #region Port state with time trigger could not be used with RequestType 1,7 or 9:
            //log.Debug("Port state with time trigger could not be used with RequestType 1,7 or 9");
            if (shipPositionRequest.AccessType == DataCenterLogic.DataCenterTypes.accessTypeType.Item3 &&
                (shipPositionRequest.RequestType == DataCenterLogic.DataCenterTypes.requestTypeType.Item1 ||
                 shipPositionRequest.RequestType == DataCenterLogic.DataCenterTypes.requestTypeType.Item7 ||
                 shipPositionRequest.RequestType == DataCenterLogic.DataCenterTypes.requestTypeType.Item9))
            {
                log.Error("Validacion erronea, se envia receipt");
                ReceiptManager.SendReceipt(shipPositionRequest.DataUserRequestor, shipPositionRequest.MessageId, DataCenterLogic.DataCenterTypesIDE.receiptCodeType.Item7,
                                           string.Format("Invalid request parameters: Port could not be used with RequestType 1,7 or 9"));
                return(false);
            }
            #endregion
            #region Access type 0 only with message 4 and request 0
            //log.Debug("AccessType 0 (reset) solo valido con RT 0 y MS 4");
            if (shipPositionRequest.AccessType == DataCenterLogic.DataCenterTypes.accessTypeType.Item0 || shipPositionRequest.RequestType == requestTypeType.Item0)
            {
                //Invalid request parameters: AccessType 0 only valid with MessageType 4
                if (shipPositionRequest.MessageType != DataCenterLogic.DataCenterTypes.messageTypeType1.Item4)
                {
                    ReceiptManager.SendReceipt(shipPositionRequest.DataUserRequestor, shipPositionRequest.MessageId, DataCenterLogic.DataCenterTypesIDE.receiptCodeType.Item7,
                                               string.Format("Invalid request parameters: AccessType 0 only valid with MessageType 4"));
                    log.Error("Validacion erronea, se envia receipt");
                    return(false);
                }

                // Invalid request parameters: AccessType 0 only valid with RequestType 0
                if (shipPositionRequest.RequestType != DataCenterLogic.DataCenterTypes.requestTypeType.Item0 || shipPositionRequest.AccessType != DataCenterLogic.DataCenterTypes.accessTypeType.Item0)
                {
                    ReceiptManager.SendReceipt(shipPositionRequest.DataUserRequestor, shipPositionRequest.MessageId, DataCenterLogic.DataCenterTypesIDE.receiptCodeType.Item7,
                                               string.Format("Invalid request parameters: AccessType 0 only valid with RequestType 0"));
                    log.Info("Validacion erronea, se envia receipt");
                    return(false);
                }
            }
            #endregion
            #region REVISAR

            /*
             * log.Debug("Port State");
             * //Invalid request parameters: Port state and RequestTypes 1,7 and 9 only valid with AccessType 5
             * if( shipPositionRequest.ItemElementName == DataCenterLogic.DataCenterTypes.ItemChoiceType.Port ||
             *  shipPositionRequest.ItemElementName == DataCenterLogic.DataCenterTypes.ItemChoiceType.PortFacility
             *  && ( shipPositionRequest.RequestType == DataCenterLogic.DataCenterTypes.requestTypeType.Item1 ||
             *       shipPositionRequest.RequestType == DataCenterLogic.DataCenterTypes.requestTypeType.Item7 ||
             *       shipPositionRequest.RequestType == DataCenterLogic.DataCenterTypes.requestTypeType.Item9 )
             *  && shipPositionRequest.AccessType != DataCenterLogic.DataCenterTypes.accessTypeType.Item5 )
             * {
             * ReceiptManager.SendReceipt(shipPositionRequest.DataUserRequestor, shipPositionRequest.MessageId, DataCenterLogic.DataCenterTypesIDE.receiptCodeType.Item7,
             *  string.Format("Invalid request parameters: Port state and RequestTypes 1,7 and 9 only valid with AccessType 5"));
             *
             * return false;
             * } */
            #endregion
            #region Invalid request parameters: RequestTypes 1,7 and 9 are the only valid for MessageType 5
            //log.Debug("Si es mensaje de tipo 5 (Sar) RT solo puede ser 1 o 9");
            if (shipPositionRequest.MessageType == DataCenterLogic.DataCenterTypes.messageTypeType1.Item5 &&
                shipPositionRequest.RequestType != DataCenterLogic.DataCenterTypes.requestTypeType.Item1 &&
                shipPositionRequest.RequestType != DataCenterLogic.DataCenterTypes.requestTypeType.Item7 &&
                shipPositionRequest.RequestType != DataCenterLogic.DataCenterTypes.requestTypeType.Item9)
            {
                log.Error("Validacion erronea, se envia receipt");
                ReceiptManager.SendReceipt(shipPositionRequest.DataUserRequestor, shipPositionRequest.MessageId, DataCenterLogic.DataCenterTypesIDE.receiptCodeType.Item7,
                                           string.Format("Invalid request parameters: RequestTypes 1,7 and 9 are the only valid for MessageType 5"));
                return(false);
            }
            #endregion
            #region Distance is only valid with access type 3
            log.Debug("Distance is only valid with access type 3");
            if (shipPositionRequest.Distance != "0" && shipPositionRequest.AccessType != DataCenterLogic.DataCenterTypes.accessTypeType.Item3)
            {
                log.Info("Validacion erronea, se envia receipt");
                ReceiptManager.SendReceipt(shipPositionRequest.DataUserRequestor, shipPositionRequest.MessageId, DataCenterLogic.DataCenterTypesIDE.receiptCodeType.Item7,
                                           string.Format("Invalid request parameters: Distance is only valid with access type 3"));
                return(false);
            }
            #endregion
            #region Request Duration not valid for one time poll
            log.Debug("Request Duration not valid for one time poll");
            if (ShipPositionRequestHelper.IsOneTimePoll(shipPositionRequest.RequestType) &&
                (shipPositionRequest.RequestDuration != null && (shipPositionRequest.RequestDuration.startTimeSpecified == true || shipPositionRequest.RequestDuration.stopTimeSpecified == true)))
            {
                log.Info("Validacion erronea, se envia receipt");
                ReceiptManager.SendReceipt(shipPositionRequest.DataUserRequestor, shipPositionRequest.MessageId, DataCenterLogic.DataCenterTypesIDE.receiptCodeType.Item7,
                                           string.Format("Invalid request parameters: Request Duration not valid for one time poll"));
                return(false);
            }
            #endregion
            #region Port State
            log.Debug("Validacion Para PortStates");
            if (shipPositionRequest.AccessType == DataCenterLogic.DataCenterTypes.accessTypeType.Item3 ||
                shipPositionRequest.AccessType == DataCenterLogic.DataCenterTypes.accessTypeType.Item5)
            {
                if (shipPositionRequest.ItemElementName != ItemChoiceType.Port && shipPositionRequest.ItemElementName != ItemChoiceType.PortFacility)
                {
                    log.Info("invalid fields for port state request, ItemElementName not port or portfacility");
                    ReceiptManager.SendReceipt(shipPositionRequest.DataUserRequestor, shipPositionRequest.MessageId, DataCenterLogic.DataCenterTypesIDE.receiptCodeType.Item7,
                                               string.Format("Invalid fields for port state request, ItemElementName not port or portfacility"));
                    return(false);
                }
                string portName = shipPositionRequest.Item.ToString();
                using (var pda = new PlaceDataAccess())
                {
                    if (pda.PortExists(portName, ddpVersion.Id) == false && pda.PortFacilityExists(portName, ddpVersion.Id) == false)
                    {
                        log.Info("invalid fields for port state request, Item" + shipPositionRequest.Item.ToString() + " doesn't exists");
                        ReceiptManager.SendReceipt(shipPositionRequest.DataUserRequestor, shipPositionRequest.MessageId, DataCenterLogic.DataCenterTypesIDE.receiptCodeType.Item7,
                                                   string.Format("invalid fields for port state request, Item" + shipPositionRequest.Item.ToString() + " doesn't exists")
                                                   );
                        return(false);
                    }
                }
            }
            #endregion
            #region AccessType2
            log.Debug("Validacion Para AccessType2");
            if (shipPositionRequest.AccessType == DataCenterLogic.DataCenterTypes.accessTypeType.Item2 &&
                shipPositionRequest.RequestType != requestTypeType.Item7)
            {
                ReceiptManager.SendReceipt(shipPositionRequest.DataUserRequestor, shipPositionRequest.MessageId, DataCenterLogic.DataCenterTypesIDE.receiptCodeType.Item7,
                                           string.Format("Access type 2 only valid for archived data"));
                return(false);
            }
            #endregion
            //Verifica si existe el Data User que requiere la información
            var cgm = new ContractingGovermentManager();

            var contractingGoverment = cgm.GetContractingGovermentByLRITId(shipPositionRequest.DataUserRequestor, ddpVersion.Id);
            if (contractingGoverment == null)
            {
                string strError = string.Format("Specified LDU '{0}' does not exist", shipPositionRequest.DataUserRequestor);

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

                var cmgr = new ConfigurationManager();

                receipt.DDPVersionNum = DDPVersionManager.currentDDP();
                receipt.Destination   = shipPositionRequest.DataUserRequestor;
                receipt.Message       = strError;
                receipt.MessageId     = MessageIdManager.Generate();
                receipt.MessageType   = DataCenterLogic.DataCenterTypes.messageTypeType3.Item7;
                receipt.Originator    = cmgr.Configuration.DataCenterID;
                receipt.ReceiptCode   = DataCenterLogic.DataCenterTypes.receiptCodeType.Item7;
                receipt.ReferenceId   = shipPositionRequest.MessageId;
                receipt.schemaVersion = decimal.Parse(cmgr.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(false);
            }

            log.Info("Validacion Ok");
            return(true);
        }
예제 #8
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));
        }