Example #1
0
        //--------------------------------------------------------------------------------------Queue----------------------------------------------------------------------------------

        public void AstroQueueUpdate(String jSon)
        {
            jSon = StringCompression.DecompressString(jSon);
            JObject obj = JObject.Parse(jSon);

            STATIONNAME stationName = TTCSHelper.StationStrConveter(obj["StationName"].ToString());
            String      Id          = obj["Id"].ToString();
            String      Event       = obj["Event"].ToString();
            DateTime    TimeStamp   = DateTime.Parse(obj["TimeStamp"].ToString());

            Console.WriteLine("[AstroQueueUpdate] " + obj["StationName"] + " : " + obj["Event"] + " --> " + Id);

            AstroQueueImpl astroQueue = DBQueueEngine.FindById(stationName, Id);

            if (Event == "RECEIVED")
            {
                QueueStatus queueStatus = new QueueStatus(QUEUE_STATUS.WAITINGSTATION, SENDING_STATUS.COMPLETED, TimeStamp);

                astroQueue.QueueStatus.Add(queueStatus);
                astroQueue.Save();
            }

            Task task = Task.Run(async() =>
            {
                await Task.Delay(100);

                StationHandler StationCommunication = AstroData.GetStationObject(stationName);
                StationCommunication.AckTarget(astroQueue, QUEUE_STATUS.WAITINGSTATION, SENDING_STATUS.COMPLETED);
            });
        }
Example #2
0
        public void AstroQueueUpdateExposure(String jSon)
        {
            jSon = StringCompression.DecompressString(jSon);
            JObject obj = JObject.Parse(jSon);

            STATIONNAME    stationName        = TTCSHelper.StationStrConveter(obj["StationName"].ToString());
            String         Id                 = obj["Id"].ToString();
            String         AstroQueueId       = obj["AstroQueueId"].ToString();
            ExposedHistory exposedHistoryRecv = (ExposedHistory)JsonConvert.DeserializeObject(obj["ExposedHistory"].ToString(), typeof(ExposedHistory));

            Console.WriteLine("[AstroQueueUpdateExposure] " + obj["StationName"] + " : " + exposedHistoryRecv.filterName + " --> " + Id);

            AstroQueueImpl astroQueue     = DBQueueEngine.FindById(stationName, AstroQueueId);
            ExposedHistory exposedHistory = astroQueue.Target.exposedHistory.Find(Item => Item.filterName == exposedHistoryRecv.filterName && Item.executedStatus == EXECUTESTATUS.WAIT);

            if (exposedHistory != null)
            {
                exposedHistory.executedStatus = exposedHistoryRecv.executedStatus;
                exposedHistory.executedDate   = exposedHistoryRecv.executedDate;

                astroQueue.Save();

                Task task = Task.Run(async() =>
                {
                    await Task.Delay(100);

                    StationHandler StationCommunication = AstroData.GetStationObject(stationName);
                    StationCommunication.AckExposure(Id, SENDING_STATUS.COMPLETED);
                });
            }
        }
Example #3
0
        public static bool UpdateObject(AstroQueueImpl astroQueue)
        {
            if (_database == null)
            {
                return(false);
            }

            try
            {
                var collection = _database.GetCollection <AstroQueueImpl>("QUEUES");
                var filter     = Builders <AstroQueueImpl> .Filter.Eq("_id", ObjectId.Parse(astroQueue.Id));

                var Doc = collection.ReplaceOne(filter, astroQueue);
                return(true);
            }
            catch { }

            return(false);
        }