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)); } }
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)); } }
public List <INFORMATIONSTRUCT> GetInformation(STATIONNAME StationName, DEVICENAME DeviceName, dynamic FieldName) { return(AstroData.GetInformation(StationName, DeviceName, FieldName)); }