Esempio n. 1
0
        private Server CreateServer()
        {
            Server s = new Server();
            s.Name = txtServerName.Text;
            s.Space = Convert.ToDouble(txtThreshhold.Text);
            s.spaceType = (SpaceType)cbThreshholdUnits.SelectedIndex;
            foreach (Folder f in folders)
            {
                s.AddFolder(f);
            }

            return s;
        }
Esempio n. 2
0
        public void LoadConfiguration(string path = @"config.xml")
        {
            if(!File.Exists(path)) return;

            var settings = new XmlReaderSettings {IgnoreComments = true, IgnoreWhitespace = true};

            XmlReader r = XmlReader.Create(path, settings);

            r.ReadToDescendant("Mail");
            defaultMail = (r["default"] != "") ? r["default"] : "*****@*****.**";
            MailString = r["recipients"].Replace(",", ", ");

            r.ReadToFollowing("FileTypes");
            FileTypes = (r["patterns"] != "") ? r["patterns"] : "*.tib, *.bak";

            r.ReadToFollowing("Servers");
            r.ReadToDescendant("Server");
            do
            {
                var server = new Server
                    {
                        Name = r["name"],
                        Space = Convert.ToDouble(r["spaceValue"]),
                        spaceType = (SpaceType) Convert.ToInt16(r["spaceType"])
                    };

                //folders loop

                r.ReadToDescendant("Folder");
                do
                {
                    var folder = new Folder(r["path"], Convert.ToBoolean(Convert.ToInt16(r["recurse"])));
                    server.AddFolder(folder);
                } while (r.ReadToNextSibling("Folder"));

               AddServer(server);
            } while (r.ReadToNextSibling("Server"));

            r.Close();
        }