Exemplo n.º 1
0
        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));
            }
        }