public static void NewLogInformation(STATIONNAME StationName, DateTime LogDate, String Message, LogType LogCategory, long?UserID) { InformationLogs NewLog = new InformationLogs(); NewLog.LogID = (long)(DateTime.UtcNow - DateTime.MinValue).TotalMilliseconds; NewLog.UserID = UserID; NewLog.LogName = "Log from " + StationName.ToString(); NewLog.LogDate = LogDate; NewLog.LogValue = null; NewLog.LogMessage = Message; NewLog.LogCategory = LogCategory; NewLog.StationName = StationName; TTCSLogInformation.Add(NewLog); TTCSTempLogInformation.Add(NewLog); if (!TTCSLog.IsSearchByAllStation) { AddLogToGrid(StationName, LogDate, Message, LogCategory, null, UserID); } else if (TTCSLog.IsSearchByAllStation && LogDate >= StartDate && LogDate <= EndDate) { AddLogToGrid(StationName, LogDate, Message, LogCategory, null, UserID); } }
public static void NewLogInformation(STATIONNAME StationName, DateTime LogDate, String LogName, Object[] Value, String Message, LogType LogCategory, long?UserID) { InformationLogs NewLog = new InformationLogs(); NewLog.LogID = (long)(DateTime.UtcNow - DateTime.MinValue).TotalMilliseconds; NewLog.UserID = UserID; NewLog.LogName = LogName; NewLog.LogDate = LogDate; NewLog.LogValue = Value != null?String.Join(", ", Value) : null; NewLog.LogMessage = Message; NewLog.LogCategory = LogCategory; NewLog.StationName = StationName; if (DateTime.UtcNow.Hour == 1) { TTCSTempLogInformation.Clear(); } TTCSLogInformation.Add(NewLog); TTCSTempLogInformation.Add(NewLog); if (!TTCSLog.IsSearchByAllStation) { AddLogToGrid(StationName, LogDate, Message, LogCategory, NewLog.LogValue, UserID); } else if (TTCSLog.IsSearchByAllStation && LogDate >= StartDate && LogDate <= EndDate) { AddLogToGrid(StationName, LogDate, Message, LogCategory, NewLog.LogValue, UserID); } }
public static void GetLogBySearchInformarion(STATIONNAME StationName, DateTime StartDate, DateTime EndDate, Boolean IsSearchByAllStation) { List <InformationLogs> TTCSLogBySearch = TTCSLogInformation; TTCSLog.StartDate = StartDate; TTCSLog.EndDate = EndDate; TTCSLog.IsSearchByAllStation = IsSearchByAllStation; if (IsSearchByAllStation) { if (StationName == STATIONNAME.NULL) { TTCSLogBySearch = TTCSLogInformation.Where(Item => Item.LogDate.Date >= StartDate.Date && Item.LogDate.Date <= EndDate.Date).ToList(); } else { TTCSLogBySearch = TTCSLogInformation.Where(Item => Item.StationName == StationName && Item.LogDate.Date >= StartDate.Date && Item.LogDate.Date <= EndDate.Date).ToList(); } } TTCSLogGrid.Rows.Clear(); if (TTCSLogBySearch != null) { for (int i = 0; i < TTCSLogBySearch.Count; i++) { AddLogToGrid(TTCSLogBySearch[i].StationName, TTCSLogBySearch[i].LogDate, TTCSLogBySearch[i].LogMessage, TTCSLogBySearch[i].LogCategory, TTCSLogBySearch[i].LogValue, TTCSLogBySearch[i].UserID); } } }
public static List <TTCSCommandDisplay> GetListCommandName(STATIONNAME StationName, DEVICECATEGORY DeviceCategory) { List <TCSCommandStructure> ListOfCommands = CommandList.Where(Item => Item.StationOwner.Exists(Item2 => Item2 == StationName) && Item.DeviceCategory == DeviceCategory).ToList(); List <TTCSCommandDisplay> ListOfDisplayCommand = new List <TTCSCommandDisplay>(); foreach (TCSCommandStructure ThisCommand in ListOfCommands) { TTCSCommandDisplay NewReturnCommand = new TTCSCommandDisplay(); NewReturnCommand.CommandName = ThisCommand.Command.ToString(); String ParameterStr = ""; if (ThisCommand.Parameter != null) { ParameterStr = String.Join(", ", ThisCommand.Parameter); } ParameterStr = ParameterStr.Replace("System.", ""); NewReturnCommand.Parameter = ParameterStr; String ParaDesc = ""; if (ThisCommand.ParameterDescription != null) { ParaDesc = String.Join("<br>", ThisCommand.ParameterDescription); } NewReturnCommand.ParameterDescription = ParaDesc; ListOfDisplayCommand.Add(NewReturnCommand); } return(ListOfDisplayCommand); }
public static void SendScriptToStation(ScriptTB CompletedScript) { STATIONNAME DestinationStation = STATIONNAME.NULL; List <ScriptTB> ScriptArr = ScriptDBBuffer.Values.Where(Item => Item.BlockID == CompletedScript.BlockID).ToList(); ScriptStructure[] StructureArr = ConvertScriptTBToScriptStructure(ScriptArr); foreach (ScriptTB ThisScript in ScriptArr) { DestinationStation = TTCSHelper.StationStrConveter(ThisScript.StationName); ThisScript.ScriptState = SCRIPTSTATE.WAITINGSERVER.ToString(); UpdateScriptToMonitoring(ThisScript); } StationHandler ThisStation = AstroData.GetStationObject(DestinationStation); if (ThisStation.IsStationConnected) { StructureArr.OrderBy(Item => Item.ExecutionNumber); AstroData.ScriptHandler(DestinationStation, StructureArr); foreach (ScriptTB ThisScript in ScriptArr) { ThisScript.ScriptState = SCRIPTSTATE.SENDINGTOSTATION.ToString(); UpdateScriptToMonitoring(ThisScript); } } }
private void AllStationEnableSearch_CheckedChanged(object sender, EventArgs e) { if (SearchStationStartDate.Value.Date > SearchStationEndDate.Value.Date) { MessageBox.Show("Invalid search information. Please check.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { if (StationEnableSearch.Checked) { SearchStationName.Enabled = true; SearchStationStartDate.Enabled = true; SearchStationEndDate.Enabled = true; } else { SearchStationName.Enabled = false; SearchStationStartDate.Enabled = false; SearchStationEndDate.Enabled = false; } STATIONNAME StationName = GetStationNameForSearch(SearchStationName.Text); TTCSLog.GetLogBySearchInformarion(StationName, SearchStationStartDate.Value, SearchStationEndDate.Value, StationEnableSearch.Checked); } }
public static void DisplayToUI(STATIONNAME StationName, DEVICENAME DeviceNameStr, INFORMATIONSTRUCT ThisInformation) { if (ActiveStation == StationName && ActiveDeviceNameStr == DeviceNameStr.ToString()) { Boolean IsFound = false; ThreadTextHandler(StationStatus, "Online"); ThreadTextHandler(StationLastestTimeUpdate, ThisInformation.UpdateTime.Value.ToString("MM/dd/yyyy HH:mm:ss.fff")); for (int i = 0; i < DeviceGrid.RowCount; i++) { if (DeviceGrid[1, i].Value.ToString() == ThisInformation.FieldName.ToString()) { DeviceGrid[2, i].Value = ThisInformation.Value.ToString().Length > 30 ? "Too large information to display." : ThisInformation.Value; DeviceGrid[3, i].Value = ThisInformation.UpdateTime; IsFound = true; ThreadTextHandler(DeviceStatus, "Online"); break; } } if (!IsFound) { ThreadAddDataGridHandler(ThisInformation.FieldName.ToString(), ThisInformation.Value.ToString(), ThisInformation.UpdateTime.ToString()); } } else if (ActiveStation == StationName && DeviceCombo.Items.Count == 0) { SetDeviceList(); } }
public static void RefreshScript(STATIONNAME StationName) { StationScript stationScript = GetStationScript(StationName); if (stationScript != null) { stationScript.RemoveAllScript(); } else { stationScript = new StationScript(StationName); ScriptStation.Add(stationScript); } String LastestScript = GetLastestFile("\\\\192.168.2.110\\ftp\\Script\\" + StationName); if (ExtractScriptData(LastestScript, StationName, scriptConfigure, false)) { SendScriptToStation(StationName); } else { DisplayScript("", StationName); } }
//public Boolean DelayScheduleEvented(ScriptStructureNew[] Scripts) //{ // foreach (ScriptStructureNew Script in Scripts) // { // DBScheduleEngine.UpdateSchedule(Script); // } // return true; //} public void GetNextScriptPart(STATIONNAME StationName) { String Output = ""; StationHandler ThisStation = AstroData.GetStationObject(StationName); ThisStation.NextScriptInformation(out Output); }
public ReturnKnowType AstroCreateStation(STATIONNAME StationName, Double Version = 0) { try { if (Version != RequirePackageVersion) { return(ReturnKnowType.DefineReturn(ReturnStatus.FAILED, "(#Co003) Failed to create " + StationName + ". Your client version is " + Version + " (Require version " + RequirePackageVersion + ").")); } else { OperationContext context = OperationContext.Current; ServerCallBack SiteCallBack = OperationContext.Current.GetCallbackChannel <ServerCallBack>(); CallBackHandler.AddSiteConnection(StationName, context.SessionId, SiteCallBack); OperationContext.Current.Channel.Closed += StationChannel_Closed; OperationContext.Current.Channel.Faulted += StationChannel_Closed; ReturnKnowType CreateSiteResult = AstroData.CreateStation(StationName, context.SessionId, SiteCallBack); return(CreateSiteResult); } } catch (Exception e) { return(ReturnKnowType.DefineReturn(ReturnStatus.FAILED, "(#Co001) Failed to create site at TTCSCreateSite see. (" + e.Message + ")")); } }
public void SubscribeInformation(STATIONNAME StationName, DEVICENAME DeviceName, dynamic FieldName) { ServerCallBack ClientCallBack = OperationContext.Current.GetCallbackChannel <ServerCallBack>(); OperationContext Context = OperationContext.Current; AstroData.SubscribeInformation(StationName, DeviceName, FieldName, Context.SessionId, ClientCallBack); }
public void AddASTROSERVER(STATIONNAME StationName, DEVICENAME DeviceName, ASTROSERVER[] FieldName, Object[] Value, DateTime[] DateTime) { for (int i = 0; i < FieldName.Count(); i++) { AstroData.NewASTROSERVERInformation(StationName, DeviceName, FieldName[i], Value[i], DateTime[i]); } }
//--------------------------------------------------------------------------------------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 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); }); } }
public void AddWEATHERSTATION(STATIONNAME StationName, DEVICENAME DeviceName, WEATHERSTATION[] FieldName, Object[] Value, DateTime[] DateTime) { for (int i = 0; i < FieldName.Count(); i++) { AstroData.NewWEATHERSTATIONInformation(StationName, DeviceName, FieldName[i], Value[i], DateTime[i]); } }
public void AddLANOUTLET(STATIONNAME StationName, DEVICENAME DeviceName, LANOUTLET[] FieldName, Object[] Value, DateTime[] DateTime) { for (int i = 0; i < FieldName.Count(); i++) { AstroData.NewLANOUTLETInformation(StationName, DeviceName, FieldName[i], Value[i], DateTime[i]); } }
public static StationHandler GetStationObject(STATIONNAME StationName) { if (KeeperData != null) { return(KeeperData.FirstOrDefault(Item => Item.StationName == StationName)); } return(null); }
public static void CreateStation(STATIONNAME StationName, List <DEVICEMAPPER> AvaliableDevices) { StationHandler NewStation = new StationHandler(); NewStation.CreateEngine(StationName, AvaliableDevices); KeeperData.Add(NewStation); }
public static STATIONNAME StationStrConveter(String Name) { String ThisName = Name.Trim(); List <STATIONNAME> AllStationName = Enum.GetValues(typeof(STATIONNAME)).Cast <STATIONNAME>().ToList(); STATIONNAME StationName = AllStationName.FirstOrDefault(Item => Item.ToString() == ThisName); return(StationName); }
private static void DisplayAllField(STATIONNAME StationName, String DeviceNameStr, dynamic FieldName, INFORMATIONSTRUCT ThisInformation) { String FieldNameStr = FieldName.ToString(); if (ActiveStation == StationName && FieldNameStr != "NULL") { ThreadAddDataGridHandler(FieldNameStr, ThisInformation.Value == null ? "-" : ThisInformation.Value.ToString(), ThisInformation.UpdateTime == null ? "-" : ThisInformation.UpdateTime.ToString()); } }
public static void SubscribeInformation(STATIONNAME StationName, DEVICENAME DeviceName, dynamic FieldName, String SessionID, Object CallBackObject) { StationHandler SiteInformation = KeeperData.FirstOrDefault(Item => Item.StationName == StationName); if (SiteInformation != null) { SiteInformation.SubscribeInformation(DeviceName, FieldName, SessionID, CallBackObject); } }
public static void NewASTROSERVERInformation(STATIONNAME StationName, DEVICENAME DeviceName, ASTROSERVER FieldName, Object Value, DateTime DataTimestamp) { StationHandler ExistingStation = KeeperData.FirstOrDefault(Item => Item.StationName == StationName); if (ExistingStation != null) { ExistingStation.NewASTROSERVERInformation(DeviceName, FieldName, Value, DataTimestamp); } }
public static void NewGPSInformation(String DataGroupID, STATIONNAME StationName, DEVICENAME DeviceName, GPS FieldName, Object Value, DateTime DataTimestamp, Boolean IsHistory) { StationHandler ExistingStation = KeeperData.FirstOrDefault(Item => Item.StationName == StationName); if (ExistingStation != null) { ExistingStation.NewGPSInformation(DataGroupID, DeviceName, FieldName, Value, DataTimestamp, IsHistory); } }
public Boolean AddASTROCLIENT(STATIONNAME StationName, DEVICENAME DeviceName, ASTROCLIENT[] FieldName, Object[] Value, DateTime[] DateTime) { for (int i = 0; i < FieldName.Count(); i++) { AstroData.NewASTROCLIENTInformation(StationName, DeviceName, FieldName[i], Value[i], DateTime[i]); } return(true); }
public static void ReturnSubscribe(STATIONNAME _StationName, DEVICECATEGORY _DeviceName, String _CommandName, Object _Value, DateTime _UpdateTime) { SubscribeStructure ThisSubscribe = SubscribeList.FirstOrDefault(Item => Item.StationName == _StationName && Item.DeviceName == _DeviceName && Item.CommandName == _CommandName); for (int i = 0; i < SubscribeList.Count; i++) { //if(SubscribeList[i].StationName == _StationName && SubscribeList[i].DeviceName == DeviceName.NULL && SubscribeList[i].CommandName == null) } }
public static void UnsubscribeByFieldName(String SessionID, STATIONNAME StationName, DEVICENAME DeviceName, dynamic FieldName) { StationHandler ThisSite = KeeperData.FirstOrDefault(Item => Item.StationName == StationName); if (ThisSite != null) { ThisSite.UnsubscribeByFieldName(SessionID, DeviceName, FieldName); } }
public void AddGPS(String DataGroupID, STATIONNAME StationName, DEVICENAME DeviceName, GPS[] FieldName, Object[] Value, DateTime[] DateTime, Boolean IsHistory) { for (int i = 0; i < FieldName.Count(); i++) { AstroData.NewGPSInformation(DataGroupID, StationName, DeviceName, FieldName[i], Value[i], DateTime[i], IsHistory); } AstroData.ReturnAckState(DataGroupID, StationName, DeviceName); }
public static List <OUTPUTSTRUCT> GetInformation(STATIONNAME StationName) { StationHandler SiteInformation = KeeperData.FirstOrDefault(Item => Item.StationName == StationName); if (SiteInformation != null) { return(SiteInformation.GetInformation()); } return(null); }
public static INFORMATIONSTRUCT GetInformationObject(STATIONNAME StationName, DEVICENAME DeviceName, dynamic FieldName) { StationHandler SiteInformation = KeeperData.FirstOrDefault(Item => Item.StationName == StationName); if (SiteInformation != null) { return(SiteInformation.GetInformationObject(DeviceName, FieldName)); } return(null); }
public static void AddSiteConnection(STATIONNAME StationName, String SiteSessionID, ServerCallBack SiteCallBack) { SiteConnection NewSiteConnection = new SiteConnection(); NewSiteConnection.StationName = StationName; NewSiteConnection.SiteSessionID = SiteSessionID; NewSiteConnection.SiteCallBack = SiteCallBack; SiteConnectionList.Add(NewSiteConnection); }