コード例 #1
0
        private void AddNew()
        {
            if (User.Current != null)
            {
                Account account = new Account();

                bool check = account.CheckExists(tbxName.Text);

                string message = Language.Resource.Message;

                if (check)
                {
                    MessageBox.Show(Language.Resource.NameExists, message);
                }
                else
                {
                    account.Name = tbxName.Text;
                    account.Username = tbxUsername.Text;
                    account.Password = tbxPassword.Text;
                    account.Description = tbxDescription.Text;
                    int result = account.Add();

                    if (result == 1)
                    {
                        frmManager manager = (frmManager)Application.OpenForms["frmManager"];
                        manager.SelectTab("tabAccounts");
                        this.Close();
                    }
                }
            }
        }
コード例 #2
0
 public void DeleteAccount(string name)
 {
     Account account = new Account();
     account.Name = name;
     bool result = account.Delete();
     if (result)
     {
         LoadAccount();
     }
 }
コード例 #3
0
        public frmAccountUpdate(string name)
        {
            _IsAdd = false;
            _name = name;
            InitializeComponent();

            if (User.Current != null)
            {
                Account account = new Account();
                var acc = account.GetBy(name);

                if (acc != null)
                {
                    tbxName.Text = acc.Name;
                    tbxUsername.Text = acc.Username;
                    tbxPassword.Text = acc.Password;
                    tbxDescription.Text = acc.Description;
                }
            }
        }
コード例 #4
0
        public void UpdateAccount(string name)
        {
            if (User.Current != null)
            {
                Account account = new Account();
                var currentAccount = account.GetBy(name);

                if (currentAccount != null)
                {
                    account.Name = tbxName.Text;
                    account.Username = tbxUsername.Text;
                    account.Password = tbxPassword.Text;
                    account.Description = tbxDescription.Text;
                    int result = account.Update();

                    if (result == 1)
                    {
                        frmManager manager = (frmManager)Application.OpenForms["frmManager"];
                        manager.SelectTab("tabAccounts");
                        this.Close();
                    }
                }
            }
        }
コード例 #5
0
ファイル: Main.cs プロジェクト: EricBlack/web-automation
        public string GetAccountBy(string name)
        {
            string result = "";

            if (User.Current != null)
            {
                Account account = new Account();
                result = account.GetByJSON(name);
            }
            return result;
        }
コード例 #6
0
        public string GetAccount(string name)
        {
            string result = "";

            Account account = new Account();
            result = account.GetByJSON(name);

            return result;
        }
コード例 #7
0
ファイル: Account.cs プロジェクト: EricBlack/web-automation
        public string GetByJSON(string name)
        {
            string result = "";

            Account account = new Account();

            if (User.Current != null)
            {
                Security security = new Security();
                XmlDocument accounts = security.ReadAccountConfiguration(User.Current.Path);

                XmlNode node = accounts.SelectSingleNode("/root/accounts/account[name='" + name + "']");
                if (node != null)
                {
                    account.Name = node.SelectSingleNode("name").InnerText;
                    account.Username = node.SelectSingleNode("username").InnerText;
                    account.Password = node.SelectSingleNode("password").InnerText;
                    account.Description = node.SelectSingleNode("description").InnerText;

                    result = new JavaScriptSerializer().Serialize(account);
                }
            }

            return result;
        }
コード例 #8
0
ファイル: Account.cs プロジェクト: EricBlack/web-automation
        public Account GetBy(string name)
        {
            Account account = new Account();
            if (User.Current != null)
            {
                Security security = new Security();
                XmlDocument accounts = security.ReadAccountConfiguration(User.Current.Path);

                XmlNode node = accounts.SelectSingleNode("/root/accounts/account[name='" + name + "']");
                if (node != null)
                {
                    account.Name = node.SelectSingleNode("name").InnerText;
                    account.Username = node.SelectSingleNode("username").InnerText;
                    account.Password = node.SelectSingleNode("password").InnerText;
                    account.Description = node.SelectSingleNode("description").InnerText;
                }
            }
            return account;
        }
コード例 #9
0
ファイル: Account.cs プロジェクト: EricBlack/web-automation
        public string GetAllJSON()
        {
            string result = "";

            List<Account> lstAccount = new List<Account>();

            if (User.Current != null)
            {
                ThangDC.Core.Securities.Security security = new ThangDC.Core.Securities.Security();
                System.Xml.XmlDocument accounts = security.ReadAccountConfiguration(User.Current.Path);

                foreach (System.Xml.XmlNode node in accounts.SelectNodes("root/accounts/account"))
                {
                    Account account = new Account();
                    account.Name = node.SelectSingleNode("name").InnerText;
                    account.Username = node.SelectSingleNode("username").InnerText;
                    account.Password = node.SelectSingleNode("password").InnerText;
                    account.Description = node.SelectSingleNode("description").InnerText;

                    lstAccount.Add(account);
                }

                result = new JavaScriptSerializer().Serialize(lstAccount);
            }

            return result;
        }
コード例 #10
0
        private void LoadAccount()
        {
            Account account = new Account();
            List<Account> lstAccount = new List<Account>();
            lstAccount = account.GetAll();

            lvAccounts.Items.Clear();
            Security security = new Security();

            foreach (Account acc in lstAccount)
            {
                ListViewItem item = new ListViewItem(new[] { acc.Name, acc.Username, security.encrypt(User.Current.PublicKey, acc.Password), acc.Description });
                lvAccounts.Items.Add(item);
            }
        }