Beispiel #1
0
        public void Load()
        {
            string[] subDirectories = System.IO.Directory.GetDirectories(System.IO.Directory.GetCurrentDirectory());

            for (int i = 0; i < subDirectories.Length; i++)
            {
                _global.projects.Add(new ProjectClass_2());

                XmlSerializer serBasic         = new XmlSerializer(typeof(basicProps));
                FileStream    fs               = new FileStream(subDirectories[i] + "/" + "basic.xml", FileMode.Open);
                _global.projects.Last().basics = (basicProps)serBasic.Deserialize(fs);

                XmlSerializer serLinks = new XmlSerializer(typeof(Links));
                fs = new FileStream(subDirectories[i] + "/" + "links.xml", FileMode.Open);
                _global.projects.Last().log.links = (Links)serLinks.Deserialize(fs);

                XmlSerializer serEntries = new XmlSerializer(typeof(EntryList));
                fs = new FileStream(subDirectories[i] + "/" + "entries.xml", FileMode.Open);
                EntryList el = (EntryList)serEntries.Deserialize(fs);
                _global.projects.Last().log.entries = el.ls;
            }
        }
        public void Save()
        {
            //First, establish directory
            //Second, ensure all fields are synced
            //Third, save each component in turn
            //--basics
            //--links
            //--entries

            if (System.IO.Directory.Exists(System.IO.Directory.GetCurrentDirectory() + "/" + proj.basics.designation))
            {
            }
            else
            {
                System.IO.Directory.CreateDirectory(
                    System.IO.Directory.GetCurrentDirectory() + "/" + proj.basics.designation);
            }
            //MessageBox.Show(openProjectCheckBox.IsChecked.ToString());
            //bool? t = true;
            //bool? f = false;

            //proj.basics.open = openProjectCheckBox.IsChecked;
            switch (openProjectCheckBox.IsChecked)
            {
            case true:
                proj.basics.open = 0;
                break;

            case false:
                proj.basics.open = 1;
                break;

            case null:
                proj.basics.open = 2;
                break;
            }

            //proj.basics.dateStarted

            //dateClosed

            proj.basics.currentRev  = proj.log.entries.Last().rev;
            proj.basics.projectName = projNameTextBox.Text;
            proj.basics.partNum     = partNoTextBox.Text;
            proj.basics.description = descTextBox.Text;


            XmlSerializer serBasic        = new XmlSerializer(typeof(basicProps));
            string        path            = System.IO.Directory.GetCurrentDirectory() + "/" + proj.basics.designation + "/";
            string        basicFileName   = path + "basic.xml";
            XmlSerializer serLinks        = new XmlSerializer(typeof(Links));
            string        linksFileName   = path + "links.xml";
            XmlSerializer serEntries      = new XmlSerializer(typeof(EntryList));
            string        entriesFileName = path + "entries.xml";
            EntryList     el = new EntryList(proj.log.entries);


            TextWriter writer = new StreamWriter(basicFileName);

            serBasic.Serialize(writer, proj.basics);
            writer.Close();

            writer = new StreamWriter(linksFileName);
            serLinks.Serialize(writer, proj.log.links);
            writer.Close();

            writer = new StreamWriter(entriesFileName);
            serEntries.Serialize(writer, el);
            writer.Close();
        }