コード例 #1
0
        public int Insert(string website, string username, string title, string password)
        {
            DataBase db  = new DataBase();
            int      res = -1;

            if (db.getInfoFromDB(website, username, title).Count == 0)
            {
                while (true)
                {
                    res = HIOStaticValues.BaS.AmISyncedSwitch();
                    if (res == 1)
                    {
                        break;
                    }
                    else if (res == -2)
                    {
                        HIOStaticValues.popUp("HIO is not connected");
                        return(0);
                    }
                    else
                    {
                        HIOStaticValues.SyncOpration();
                    }
                }
                res = HIOStaticValues.BaS.InsertToSwitch(new LoginFieldS {
                    url = website, userName = username, title = title, password = password, appID = ""
                });
                if (res > 0)
                {
                    db.insertToDatabase(res.ToString(), website, username, "", title);
                    HIOStaticValues.username = username;
                    return(1);
                }

                else
                {
                    return(0);
                }
            }
            else
            {
                System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                {
                    HIOStaticValues.popUp("This user already exists,You can modify it in the Edit Form.");
                }));
                return(-4);
            }
        }
コード例 #2
0
        public bool Delete(string rowid)
        {
            DataBase db = new DataBase();

            int rowidInt = Int32.Parse(rowid);

            byte[] rowidByteArray = BitConverter.GetBytes(rowidInt).ToArray();
            string result         = HIOStaticValues.BaS.DeleteFromSwitch(rowidByteArray);

            if (result == StatusWord.SW_NO_ERROR)
            {
                db.deleteFromDatabase(rowid);
                return(true);
            }
            else
            {
                System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                {
                    HIOStaticValues.popUp("Something was wrong!\nPlease check log file.");
                }));
            }
            return(false);
        }
コード例 #3
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)
            {
            }
        }