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); }); } }
//--------------------------------------------------------------------------------------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); }); }
public bool Save() { return(DBQueueEngine.UpdateObject(this)); }
public MainWindows() { DBEngine.ConnectDB(); DBScheduleEngine.ConnectDB(); DBQueueEngine.ConnectDB(); InitializeComponent(); InitializeInterface(); InitializeServer(); InitializeWebService(); InitializeSetCommand(); InitializeWS(); Task TaskPost = Task.Run(async() => { while (true) { IQueryable <AstroQueueImpl> IAstroQueues = DBQueueEngine.Find(QUEUE_STATUS.WAITINGSERVER, SENDING_STATUS.IDLE); if (IAstroQueues.Count() > 0) { Dictionary <STATIONNAME, List <AstroQueueImpl> > dictionaryGroup = new Dictionary <STATIONNAME, List <AstroQueueImpl> >(); List <AstroQueueImpl> astroQueues = IAstroQueues.ToList(); foreach (AstroQueueImpl astroQueue in astroQueues) { if (!dictionaryGroup.ContainsKey(astroQueue.Target.StationName)) { dictionaryGroup.Add(astroQueue.Target.StationName, new List <AstroQueueImpl>()); } dictionaryGroup[astroQueue.Target.StationName].Add(astroQueue); } if (dictionaryGroup.Count() > 0) { foreach (KeyValuePair <STATIONNAME, List <AstroQueueImpl> > groupAstroQueues in dictionaryGroup) { StationHandler StationCommunication = AstroData.GetStationObject(groupAstroQueues.Key); if (StationCommunication != null) { StationCommunication.SendingNewTarget(groupAstroQueues.Value); } } } } /* * StationHandler StationCommunication = AstroData.GetStationObject(astroQueue.Target.StationName); * * if (StationCommunication != null) * { * StationCommunication.SendingNewTarget(astroQueue); * } */ await Task.Delay(1000); } }); /* * QueueStatus astroQueues2 = DBQueueEngine.FindLastestStatus(STATIONNAME.ASTROPARK, "5a4db62e30932557d4ba7445"); * Console.WriteLine(astroQueues2); */ }