示例#1
0
        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));
            }
        }
示例#2
0
        public ReturnKnowType AstroSet(STATIONNAME StationName, DEVICENAME DeviceName, dynamic CommandName, Object[] Values, DateTime CommandDateTime)
        {
            DEVICECATEGORY DeviceCategory = TTCSHelper.ConvertDeviceNameToDeviceCategory(StationName, DeviceName);

            return(AstroData.SetCommandHandler(StationName, DeviceCategory, DeviceName, CommandName, Values, CommandDateTime));
        }