private HttpResponseMessage GetByDeviceName(String StationName, String DeviceCategory, String SessionID) { XmlDocument myXml = new XmlDocument(); XPathNavigator xNav = myXml.CreateNavigator(); if (UserSessionHandler.VerifyTimeout(SessionID)) { STATIONNAME ThisStation = HostingHelper.ConvertStationNameStrToSTATIONNAME(StationName); DeviceCategory.Replace("WEATHER", "WEATHERSTATION"); var TempDeviceName = DeviceCategory.Split('_'); DEVICECATEGORY ThisDeviceCategory = HostingHelper.ConvertDevicecCategoryStrToDEVICECATEGORY(DeviceCategory); if (TempDeviceName.Length > 1) { ThisDeviceCategory = HostingHelper.ConvertDevicecCategoryStrToDEVICECATEGORY(TempDeviceName[1]); } if (ThisStation == STATIONNAME.NULL) { return(HostingHelper.ReturnError("Invalid station name. Please check.", myXml, xNav)); } if (ThisDeviceCategory == DEVICECATEGORY.NULL) { return(HostingHelper.ReturnError("Invalid device name. Please check.", myXml, xNav)); } List <OUTPUTSTRUCT> InformationResult = AstroData.GetInformation(ThisStation, ThisDeviceCategory); if (InformationResult != null) { JavaScriptSerializer Serializer = new JavaScriptSerializer(); Serializer.MaxJsonLength = Int32.MaxValue; var json = Serializer.Serialize(InformationResult); return(new HttpResponseMessage() { Content = new StringContent(json, Encoding.UTF8, "application/json") }); } else { return(HostingHelper.ReturnError("An error occur while getting information", myXml, xNav)); } } else { return(HostingHelper.ReturnError("Session is timeout. Please login to the system.", myXml, xNav)); } }
public HttpResponseMessage Operation(String SessionID) { XmlDocument myXml = new XmlDocument(); XPathNavigator xNav = myXml.CreateNavigator(); ReturnKnowType LoggoutResult = UserSessionHandler.Loggout(SessionID); XmlSerializer xmlSerializer = new XmlSerializer(typeof(ReturnKnowType)); using (var xs = xNav.AppendChild()) { xmlSerializer.Serialize(xs, LoggoutResult); } return(new HttpResponseMessage() { Content = new StringContent(myXml.OuterXml, Encoding.UTF8, "text/xml") }); }
private HttpResponseMessage GetByCommandName(String StationName, String DeviceName, String FieldName, String SessionID) { XmlDocument myXml = new XmlDocument(); XPathNavigator xNav = myXml.CreateNavigator(); if (UserSessionHandler.VerifyTimeout(SessionID)) { STATIONNAME ThisStation = HostingHelper.ConvertStationNameStrToSTATIONNAME(StationName); DEVICENAME ThisDevice = HostingHelper.ConvertDevicecNameStrToDEVICENAME(DeviceName); dynamic ThisFieldName = HostingHelper.ConvertFieldNameStrToFIELDNAME(FieldName); if (ThisStation == STATIONNAME.NULL) { return(HostingHelper.ReturnError("Invalid station name. Please check.", myXml, xNav)); } if (ThisDevice == DEVICENAME.NULL) { return(HostingHelper.ReturnError("Invalid device name. Please check.", myXml, xNav)); } if (ThisFieldName == null) { return(HostingHelper.ReturnError("Invalid field name. Please check.", myXml, xNav)); } OUTPUTSTRUCT InformationResult = AstroData.GetInformation(ThisStation, ThisDevice, FieldName); if (InformationResult != null) { JavaScriptSerializer Serializer = new JavaScriptSerializer(); Serializer.MaxJsonLength = Int32.MaxValue; var json = Serializer.Serialize(InformationResult); return(new HttpResponseMessage() { Content = new StringContent(json, Encoding.UTF8, "application/json") }); } else { return(HostingHelper.ReturnError("An error occur while getting information", myXml, xNav)); } } else { return(HostingHelper.ReturnError("Session is timeout. Please login to the system.", myXml, xNav)); } }
private HttpResponseMessage GetSetCommandStructure(String StationNameStr, String DeviceCategoryStr, String SessionID) { XmlDocument myXml = new XmlDocument(); XPathNavigator xNav = myXml.CreateNavigator(); if (UserSessionHandler.VerifyTimeout(SessionID)) { STATIONNAME ThisStation = HostingHelper.ConvertStationNameStrToSTATIONNAME(StationNameStr); var TempDeviceName = DeviceCategoryStr.Split('_'); DEVICECATEGORY ThisDeviceCategory = HostingHelper.ConvertDevicecCategoryStrToDEVICECATEGORY(DeviceCategoryStr); if (TempDeviceName.Length > 1) { ThisDeviceCategory = HostingHelper.ConvertDevicecCategoryStrToDEVICECATEGORY(TempDeviceName[1]); Console.WriteLine(ThisDeviceCategory); } if (ThisStation == STATIONNAME.NULL) { return(HostingHelper.ReturnError("Invalid station name. Please check.", myXml, xNav)); } if (ThisDeviceCategory == DEVICECATEGORY.NULL) { return(HostingHelper.ReturnError("Invalid device name. Please check.", myXml, xNav)); } TTCSCommandDisplay[] ListOfDisplayCommand = CommandDefinition.GetListCommandName(ThisStation, ThisDeviceCategory).ToArray(); if (ListOfDisplayCommand != null) { var json = new JavaScriptSerializer().Serialize(ListOfDisplayCommand); return(new HttpResponseMessage() { Content = new StringContent(json, Encoding.UTF8, "application/json") }); } else { return(HostingHelper.ReturnError("There are no set command avaliable on this stationName and DeviceName.", myXml, xNav)); } } else { return(HostingHelper.ReturnError("Session is timeout. Please login to the system.", myXml, xNav)); } }
private HttpResponseMessage Operation(String StationName, String DeviceName, String CommandName, String Value, String SessionID) { XmlDocument myXml = new XmlDocument(); XPathNavigator xNav = myXml.CreateNavigator(); if (UserSessionHandler.VerifyTimeout(SessionID)) { STATIONNAME ThisStation = HostingHelper.ConvertStationNameStrToSTATIONNAME(StationName); DEVICENAME ThisDeviceName = HostingHelper.ConvertDevicecNameStrToDEVICENAME(DeviceName); DEVICECATEGORY ThisDeviceCategory = HostingHelper.ConvertDeviceNameToDeviceCategory(ThisStation, ThisDeviceName); if (ThisStation == STATIONNAME.NULL) { return(HostingHelper.ReturnError("Invalid station name. Please check.", myXml, xNav)); } if (ThisDeviceName == DEVICENAME.NULL) { return(HostingHelper.ReturnError("Invalid device name. Please check.", myXml, xNav)); } ReturnKnowType VerificationResult = CommandDefinition.VerifyCommand(ThisStation, ThisDeviceCategory, CommandName, HostingHelper.SplitValue(Value)); if (VerificationResult.ReturnType == ReturnStatus.SUCESSFUL) { dynamic ThisCommandName = CommandDefinition.GetCommandNameENUM(CommandName); XmlSerializer xmlSerializer2 = new XmlSerializer(typeof(ReturnMessage)); ReturnKnowType CommandResult = AstroData.SetCommandHandler(ThisStation, ThisDeviceCategory, ThisDeviceName, ThisCommandName.Value, CommandDefinition.ValueConvertion(HostingHelper.SplitValue(Value)), DateTime.UtcNow); XmlSerializer xmlSerializer3 = new XmlSerializer(typeof(ReturnKnowType)); using (var xs = xNav.AppendChild()) { xmlSerializer3.Serialize(xs, CommandResult); } return(new HttpResponseMessage() { Content = new StringContent(myXml.OuterXml, Encoding.UTF8, "text/xml") }); } return(HostingHelper.ReturnError(VerificationResult.ReturnMessage, myXml, xNav)); } else { return(HostingHelper.ReturnError("Session is timeout. Please login to the system.", myXml, xNav)); } }
private ReturnKnowType Operation(String UserName, String Password) { XmlDocument myXml = new XmlDocument(); XPathNavigator xNav = myXml.CreateNavigator(); ReturnKnowType ThisUser = UserSessionHandler.UserVerification(UserName, Password); XmlSerializer xmlSerializer = new XmlSerializer(typeof(SessionStructure)); if (ThisUser.ReturnType == ReturnStatus.SUCESSFUL) { //using (var xs = xNav.AppendChild()) { xmlSerializer.Serialize(xs, ThisUser.ReturnValue); } //return new HttpResponseMessage() { Content = new StringContent(myXml.OuterXml, Encoding.UTF8, "text/xml") }; return(ThisUser); } else { return(ThisUser); } }
private HttpResponseMessage GetSetCommandStructure(String StationNameStr, String TargetIDStr, String SessionID) { XmlDocument myXml = new XmlDocument(); XPathNavigator xNav = myXml.CreateNavigator(); if (UserSessionHandler.VerifyTimeout(SessionID)) { STATIONNAME ThisStation = HostingHelper.ConvertStationNameStrToSTATIONNAME(StationNameStr); if (ThisStation == STATIONNAME.NULL) { return(HostingHelper.ReturnError("Invalid station name. Please check.", myXml, xNav)); } if (DBScheduleEngine.IsFoundScheduleByTargetID(StationNameStr, TargetIDStr)) { StationHandler StationHandle = AstroData.GetStationObject(ThisStation); StationHandle.CancelScript(TargetIDStr); return(HostingHelper.ReturnSuccess(ThisStation, "OK", myXml, xNav)); } else { return(HostingHelper.ReturnError("There are no TargetID in Database.", myXml, xNav)); } /* * TTCSCommandDisplay[] ListOfDisplayCommand = CommandDefinition.GetListCommandName(ThisStation, ThisDeviceCategory).ToArray(); * if (ListOfDisplayCommand != null) * { * var json = new JavaScriptSerializer().Serialize(ListOfDisplayCommand); * return new HttpResponseMessage() { Content = new StringContent(json, Encoding.UTF8, "application/json") }; * } * else * return HostingHelper.ReturnError("There are no set command avaliable on this stationName and DeviceName.", myXml, xNav); */ } else { return(HostingHelper.ReturnError("Session is timeout. Please login to the system.", myXml, xNav)); } }
private HttpResponseMessage RelayCommand(String Ra, String Dec, String FOV, String SessionID) { XmlDocument myXml = new XmlDocument(); XPathNavigator xNav = myXml.CreateNavigator(); if (UserSessionHandler.VerifyTimeout(SessionID)) { ReturnKnowType CommandResult = AstroData.GRBHandler(Ra, Dec, FOV, DateTime.UtcNow); XmlSerializer xmlSerializer3 = new XmlSerializer(typeof(ReturnKnowType)); using (var xs = xNav.AppendChild()) { xmlSerializer3.Serialize(xs, CommandResult); } return(new HttpResponseMessage() { Content = new StringContent(myXml.OuterXml, Encoding.UTF8, "text/xml") }); } else { return(HostingHelper.ReturnError("Session is timeout. Please login to the system.", myXml, xNav)); } }