コード例 #1
0
        public async static void Disconnect_Click(object sender, EventArgs e)
        {
            if (HIOStaticValues.CheckSyncingData())
            {
                return;
            }
            CloseDuplicateWindows();
            if (BaS.dev is BLEDevice bleDevice)
            {
                await bleDevice.Unpair();
            }
            App.Current.Dispatcher.BeginInvoke((Action)(() => tmain.SettingManager.AddNewDevice()));

            // BaS.UnBondSwitch(HIOStaticValues.blea.mac);
        }
コード例 #2
0
        /// <summary>
        /// For Extensions
        /// </summary>
        /// <param name="data">recieve data from browser</param>
        /// <param name="source">check refrence of data</param>
        /// <param name="tMain">parent handler</param>

        public void ProcessRecieveMessage(JObject data, Source source)
        {
            try
            {
                if (data == null)
                {
                    return;
                }
                Converts conv = new Converts();
                Dictionary <string, string> dicData = new Dictionary <string, string> ();
                string url = "", title = "", message = "", username = "";
                TCheckingData(data, ref url, ref title, ref message, ref username);

                DataBase db = new DataBase();
                if (HIOStaticValues.CONNECTIONBHIO == false)
                {
                    dicData.Add("CMD", "CONNCETION");
                    dicData.Add("DATA", "false");


                    HIOStaticValues.BaS.Write(dicData, source);
                    if (message != "INIT" && message != "SUBMIT")
                    {
                        HIOStaticValues.popUp("HIO is not connected!");
                    }
                    return;
                }
                if (message != "INIT" && !HIOStaticValues.TPinStatus())
                {
                    return;
                }


                if (HIOStaticValues.CheckSyncingData())
                {
                    return;
                }

                switch (message)
                {
                case "exit":
                    //Environment.Exit(0);
                    break;

                case "MENUCHROME":
                    List <LoginFieldS> listUsers = db.getInfoFromDB("*", "", "");
                    System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        HIOStaticValues.AdminExtention.CloseAll();
                        HIOStaticValues.AdminExtention.ExtentionMenu.Initialize(url, title);
                        HIOStaticValues.AdminExtention.ExtentionMenu.Show();
                    }));

                    break;


                //case "DASHBOARD":
                //    System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                //    {
                //        TMain.Instance.Show();
                //    }));
                //    break;
                //case "MANAGEALLUSER":
                //    List<LoginFieldS> lnFields = db.getInfoFromDB("*", "", "");
                //    System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                //    {


                //        HIOStaticValues.AdminExtention.CloseAll();
                //        HIOStaticValues.AdminExtention.Extention08.Initialize(lnFields);
                //        HIOStaticValues.AdminExtention.Extention08.Show();

                //    }));

                //    break;
                //case "ADDUSER":

                //    System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                //    {
                //        HIOStaticValues.AdminExtention.CloseAll();
                //        HIOStaticValues.AdminExtention.Extention02.Show(new TAccountItem { Url = url, Name = title });
                //    }));
                //    break;
                case "READYDATA":
                    //ready for fill username
                    dicData.Add("CMD", "USER");
                    dicData.Add("USER", HIOStaticValues.username);
                    HIOStaticValues.BaS.Write(dicData, source, true);
                    break;

                case "READYDATAPASS":
                    //ready for fill password
                    //  Dictionary<string, string> dicData = new Dictionary<string, string> { { "CMD", "USER" }, { "USER", HIOStaticValues.username } };
                    dicData.Add("CMD", "PASS");
                    dicData.Add("DATA", HIOStaticValues.password);
                    HIOStaticValues.BaS.Write(dicData, source, true);
                    break;

                case "INIT":
                    dicData.Add("CMD", "CONNCETION");
                    dicData.Add("DATA", HIOStaticValues.CONNECTIONBHIO.ToString().ToLower());
                    HIOStaticValues.BaS.Write(dicData, source);
                    break;

                case "MANAGEUSER":
                    break;

                case "CANNOTFIND":
                    System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() => {
                        HIOStaticValues.popUp("HIO could not find the login form." +
                                              "\nMove the cursor inside the Username or Password field.");
                    }));
                    break;
                //case "GENERATEPASSWORDNOFILL":


                //    System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                //    {

                //        try
                //        {
                //            HIOStaticValues.AdminExtention.CloseAll();
                //            HIOStaticValues.AdminExtention.Extentiongp.Show(false,false);

                //        }
                //        catch (Exception ex)
                //        {

                //            ;
                //        }
                //    }));

                //    break;
                case "GENERATEPASSWORD":
                    TGeneratePasswordForm();

                    break;

                case "JUSTMENU":

                    url = (url.Length < 257) ? url : url.Substring(0, 256);
                    // action = data["action"].Value<string>().ToLower();
                    title = (data["title"].Value <string>().Length < 65) ? data["title"].Value <string>() : data["title"].Value <string>().Substring(0, 64);
                    List <LoginFieldS> lgnpack = db.getInfoFromDB(url, "", "");

                    System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        HIOStaticValues.AdminExtention.CloseAll();
                        HIOStaticValues.AdminExtention.ExtentionManage.Initialize(lgnpack, false, source, url);
                        HIOStaticValues.AdminExtention.ExtentionManage.Show();
                    }));

                    break;

                case "SUBMIT":
                    url = (url.Length < 257) ? url : url.Substring(0, 256);
                    string passwd = (data["password"].Value <string>().Length < 64) ? data["password"].Value <string>() : data["password"].Value <string>().Substring(0, 64);

                    List <LoginFieldS> listlgnpck = db.getInfoFromDB(url, username, "");
                    if (listlgnpck.Count == 0)
                    {
                        System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                        {
                            HIOStaticValues.AdminExtention.CloseAll();
                            HIOStaticValues.AdminExtention.Extention10.Initialize(new LoginFieldS {
                                url = url, title = title, userName = username, password = passwd
                            });
                            HIOStaticValues.AdminExtention.Extention10.Show();
                        }));
                    }

                    break;

                case "CHECKPASS":
                    dicData.Add("CMD", "CHECKPASS");

                    HIOStaticValues.BaS.Write(dicData, source);
                    break;

                case "GETUSER":
                    HIOStaticValues.username = "";
                    url = (url.Length < 257) ? url : url.Substring(0, 256);

                    TGetUsername(url, title, source, db);

                    break;

                case "GETPASS":

                    url = (url.Length < 257) ? url : url.Substring(0, 256);
                    TGetPassword(url, title, db, source);


                    break;
                }
            }
            catch (Exception ex)
            {
            }
        }