示例#1
0
        public override string postBackProc(string page, string data, string user, int userRights)
        {
            System.Collections.Specialized.NameValueCollection parts = null;
            parts = HttpUtility.ParseQueryString(data);

            Console.WriteLine(data);

            string id = parts["id"];

            if (parts["pin_code"] != null)
            {
                pin_code = parts["pin_code"];
                Console.WriteLine(pin_code);
            }
            if (parts["id"] != null && parts["id"].Contains("access_button"))
            {
                using (var nest = new NestConnection())
                {
                    if (nest.retrieveAccess(pin_code))
                    {
                        pageCommands.Add("popmessage", "Successfully reset Access Token");
                    }
                    else
                    {
                        pageCommands.Add("popmessage", "Failed to reset Access Token");
                    }
                }
            }

            return(base.postBackProc(page, data, user, userRights));
        }
        public override string postBackProc(string page, string data, string user, int userRights)
        {
            System.Collections.Specialized.NameValueCollection parts = null;
            parts = HttpUtility.ParseQueryString(data);

            Console.WriteLine(data);

            string id = parts["id"];

            if (parts["pin_code"] != null)
            {
                pin_code = parts["pin_code"];
                Console.WriteLine(pin_code);
            }
            if (parts["id"] != null && parts["id"].Contains("access_button"))
            {
                using (var nest = new NestConnection())
                {
                    if (nest.retrieveAccess(pin_code))
                    {
                        pageCommands.Add("popmessage", "Successfully reset Access Token");
                    }
                    else
                    {
                        pageCommands.Add("popmessage", "Failed to reset Access Token");
                    }
                }
            }
            if (id == "devices_button")
            {
                using (var nest = new NestConnection())
                {
                    nest.setInitialConnectionProps();
                    if (nest.isAccessNotNull())
                    {
                        using (var nestData = nest.getNestData())
                        {
                            Util.Find_Create_Devices(nestData.Devices, true);
                            Util.Find_Create_Structures(nestData.Structures, true);
                        }
                    }

                    else
                    {
                        Util.Log("Access Token is null", Util.LogType.LOG_TYPE_ERROR);
                    }
                }
            }

            return(base.postBackProc(page, data, user, userRights));
        }