コード例 #1
0
        private void PopuniServersFromXml()
        {
            XElement element = XElement.Load(xmlPathString);
            var storeElement = element;
            var serverElements = storeElement.Elements().Where(x => x.Name == "cServer");

            foreach (var serverElement in serverElements)
            {
                string decryptedPassword = cCryption.DecryptStringAES(serverElement.Element("Psw").Value.ToString(), "darko");
                cServer server = new cServer()
                {

                    Server = serverElement.Element("Server").Value.ToString(),
                    User = serverElement.Element("User").Value.ToString(),
                    Psw = decryptedPassword,
                    Prikazi = (bool)serverElement.Element("Prikazi")
                };

                Servers.Add(server);
            }
        }
コード例 #2
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                this.Servers.Clear();

                foreach (DataGridViewRow dtRow in dgServers.Rows)
                {
                    var encryptedPassword = cCryption.EncryptStringAES(Convert.ToString(dtRow.Cells["Psw"].Value), "darko");
                    cServer cSrv = new cServer
                                (
                                    Convert.ToString(dtRow.Cells["Server"].Value)
                                  , Convert.ToString(dtRow.Cells["User"].Value)
                                  , encryptedPassword
                                  , Convert.ToBoolean(dtRow.Cells["Prikazi"].Value)
                                );

                    this.Servers.Add(cSrv);
                }

                //sada te podatke treba negdje spremiti

                LoginClass.Servers = this.Servers;
                LoginClass.Korisnik = WindowsIdentity.GetCurrent().Name;
                LoginClass.SaveAll();
                this.xmlPathString = LoginClass.xmlFilePath;

                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, ex.Source, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #3
0
ファイル: frmLogin.cs プロジェクト: dickjones00/MultisetOrder
        private void FillServersAndSettingsFromXml()
        {
            Servers.Clear();
            try
            {
                XElement element = XElement.Load(xmlFilePath);
                var storeElement = element;

                var serverElements = storeElement.Elements().Where(x => x.Name == "cServer");
                var NazivServera = storeElement.Elements().Where(x => x.Name == "zadnjiServer").FirstOrDefault();
                var NazivBaze = storeElement.Elements().Where(x => x.Name == "zadnjaBaza").FirstOrDefault();
                if (NazivBaze == null || NazivServera == null)
                {
                    LoginClass.NazivServera = string.Empty;
                    LoginClass.NazivBaze = string.Empty;
                }
                else
                {
                    LoginClass.NazivBaze = NazivBaze.Value;
                    LoginClass.NazivServera = NazivServera.Value;
                }
                foreach (var serverElement in serverElements)
                {
                    string decryptedPassword = cCryption.DecryptStringAES(serverElement.Element("Psw").Value.ToString(), "darko");
                    cServer server = new cServer();
                    server.Server = serverElement.Element("Server").Value.ToString();
                    server.User = serverElement.Element("User").Value.ToString();
                    server.Psw = serverElement.Element("Psw").Value.ToString();
                    server.Prikazi = (bool)serverElement.Element("Prikazi");

                    Servers.Add(server);
                }
            }
            catch (Exception)
            {
                File.Move(xmlFilePath, xmlFilePath + "_bak");
                MessageBox.Show("Greška prilikom čitanja konfiguracijske datoteke. Napravljena je sigurnosna kopija datoteke:\r\n" + xmlFilePath,
                                "Greška", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }