private void GetOnlineStation() { ReturnKnowType ThisResult = AstroData.GetAllOnlineStation(); if (ThisResult.ReturnValue != null) { List <StationHandler> AllStation = (List <StationHandler>)ThisResult.ReturnValue; List <String> OnlineStation = new List <string>(); foreach (StationHandler ThisStation in AllStation) { if (ThisStation.IsStationConnected) { OnlineStation.Add(ThisStation.StationName.ToString()); } } if (OnlineStation.Count > 0) { AstroData.NewASTROSERVERInformation(STATIONNAME.ASTROSERVER, DEVICENAME.ASTROPARK_SERVER, ASTROSERVER.ASTROSERVER_ALLONLINESTATION, String.Join(", ", OnlineStation), DateTime.UtcNow); } } else { AstroData.NewASTROSERVERInformation(STATIONNAME.ASTROSERVER, DEVICENAME.ASTROPARK_SERVER, ASTROSERVER.ASTROSERVER_ONLINEDEVICES, "", DateTime.UtcNow); } }
private void CreateAstroStation() { ReturnKnowType ReturnResult = AstroData.CreateStation(STATIONNAME.ASTROSERVER, "ASTROSERVER", this); if (ReturnResult.ReturnType == ReturnStatus.FAILED) { IsStopTTCSLoop = true; } }
public static ReturnKnowType DefineReturn(ReturnStatus ReturnType, String ReturnMessage, Object ReturnValue) { ReturnKnowType NewResult = new ReturnKnowType(); NewResult.ReturnType = ReturnType; NewResult.ReturnMessage = ReturnMessage; NewResult.ReturnDateTime = DateTime.UtcNow; NewResult.ReturnValue = ReturnValue; PrintMessage(ReturnType, ReturnMessage, NewResult); return(NewResult); }
public static void UserCheckerLoop() { Task UserTask = Task.Run(() => { while (true) { TransectionBuffer ThisUser; if (BufferList.TryPeek(out ThisUser)) { List <String> StationArr = ThisUser.UserInformation.UserStationPermission.Split(new char[] { ',' }).ToList(); foreach (String StationNameStr in StationArr) { if (StationNameStr == "All Station") { StationArr.Add("AIRFORCE"); StationArr.Add("CHACHOENGSAO"); StationArr.Add("NAKHONRATCHASIMA"); StationArr.Add("CHINA"); StationArr.Add("USA"); //StationArr.Add("ASTROPARK"); break; } } StationArr.Remove("All Station"); StationArr.Remove("NULL"); Boolean IsSend = true; foreach (String StationName in StationArr) { ReturnKnowType ReturnResult = AstroData.UpdateStationUser(ThisUser.UserInformation.UserID, ThisUser.UserInformation.UserName, ThisUser.UserInformation.UserLoginName, ThisUser.UserInformation.UserLoginPassword, ThisUser.UserInformation.UserPermissionType, ThisUser.UserInformation.UserStationPermission, StationName, ThisUser.UserAction); if (ReturnResult.ReturnType != ReturnStatus.SUCESSFUL) { IsSend = false; } } if (IsSend) { BufferList.TryDequeue(out ThisUser); } } Thread.Sleep(1000); } }); }
private void GetMissingData() { ReturnKnowType ThisResult = AstroData.GetAllOnlineStation(); if (ThisResult.ReturnValue != null) { List <StationHandler> AllStation = (List <StationHandler>)ThisResult.ReturnValue; foreach (StationHandler ThisStation in AllStation) { if (ThisStation.IsStationConnected && ThisStation.StationName != STATIONNAME.ASTROSERVER) { StationHandler StationCommunication = AstroData.GetStationObject(ThisStation.StationName); StationCommunication.CheckLastesInformation(DateTime.UtcNow.Ticks); } } } }
private static void PrintMessage(ReturnStatus ReturnType, String ReturnMessage, ReturnKnowType NewResult) { if (ReturnMessage != null && ReturnMessage != "") { LogType ThisType = LogType.MESSAGE; switch (ReturnType) { case ReturnStatus.FAILED: ThisType = LogType.ERROR; break; case ReturnStatus.ONCALLBACK: ThisType = LogType.COMMUNICATION; break; case ReturnStatus.SUCESSFUL: ThisType = LogType.MESSAGE; break; case ReturnStatus.WORKING: ThisType = LogType.MESSAGE; break; } TTCSLog.NewLogInformation(STATIONNAME.ASTROSERVER, NewResult.ReturnDateTime, ReturnMessage, ThisType, null); } }
private static Boolean VerifyScript(STATIONNAME StationName, List <ScriptStructureNew> ScriptCollection, out String Message) { foreach (ScriptStructureNew ThisScript in ScriptCollection) { //DUMMY ONLY //ThisScript.TargetID = "XXXXXX"; if (String.IsNullOrEmpty(ThisScript.ScriptID)) { Message = "Invalid ScriptID can't be null or empty value. Please check."; return(false); } if (String.IsNullOrEmpty(ThisScript.BlockID)) { Message = "Invalid BlockID can't be null or empty value at Script ID : " + ThisScript.ScriptID + ". Please check."; return(false); } STATIONNAME ScriptStationName = TTCSHelper.StationStrConveter(ThisScript.StationName); if (StationName == STATIONNAME.NULL) { Message = "Invalid station same at script ID : " + ThisScript.BlockID + ". Please check spelling."; return(false); } if (StationName != ScriptStationName) { Message = "Invalid station name not match in folder at script ID : " + ThisScript.BlockID + ". Please check spelling."; return(false); } DEVICENAME DeviceName = TTCSHelper.DeviceNameStrConverter(ThisScript.DeviceName); if (DeviceName == DEVICENAME.NULL) { Message = "Invalid device name at script ID : " + ThisScript.BlockID + ". Please check spelling."; return(false); } DEVICECATEGORY DeviceCategory = TTCSHelper.ConvertDeviceNameToDeviceCategory(StationName, DeviceName); if (DeviceCategory == DEVICECATEGORY.NULL) { Message = "Invalid devicecategory at script ID : " + ThisScript.BlockID + ". Please check spelling."; return(false); } Object CommandName = TTCSHelper.CommandNameConverter(DeviceCategory, ThisScript.CommandName); if (CommandName == null) { Message = "Invalid command name at script ID : " + ThisScript.BlockID + ". Please check spelling."; return(false); } Int64 StartDateLong = 0; if (!Int64.TryParse(ThisScript.ExecutionTimeStart, out StartDateLong)) { Message = "Invalid start datetime at script ID : " + ThisScript.BlockID + ". Please check spelling."; return(false); } Int64 EndDateLong = 0; if (!Int64.TryParse(ThisScript.ExecutionTimeEnd, out EndDateLong)) { Message = "Invalid end datetime at script ID : " + ThisScript.BlockID + ". Please check spelling."; return(false); } int Life = 0; if (!int.TryParse(ThisScript.Life, out Life)) { Message = "Invalid life time at " + ThisScript.BlockID + ". Please check spelling."; return(false); } if (String.IsNullOrEmpty(ThisScript.TargetID)) { Message = "Invalid TargetID can't be null or empty value at Script ID : " + ThisScript.BlockID + ". Please check."; return(false); } if (String.IsNullOrEmpty(ThisScript.Owner)) { Message = "Invalid Owner can't be null or empty value at Script ID : " + ThisScript.BlockID + ". Please check."; return(false); } ReturnKnowType CommandResult = CommandDefinition.VerifyCommand(StationName, DeviceCategory, CommandName, ThisScript.Parameters.ToArray()); if (CommandResult.ReturnType == ReturnStatus.FAILED) { Message = "Invalid parameter at script ID : " + ThisScript.ScriptID + " at Command " + CommandName + ". With: " + CommandResult.ReturnMessage + ". Please check spelling."; return(false); } } Message = "All script verified."; return(true); }