Пример #1
0
            /*
             *  Node for each store, repo, and note
             *
             *  Attributes
             *  Store:  Location - Path to store
             *  Repo:   Name - Name of the repository, not path
             *          Status - Current status of the repository i.e New, Development, Production
             *  Note    Title - The title of the note
             *
             *  Other Data
             *  Note body needs to be inner text of the Note node
             */

            public static bool Serialize_Condensed_All(string file, CircularProgressBar.CircularProgressBar cpb = null)
            {
                XmlDocument Config = new XmlDocument();

                Config.Load(file);

                try
                {
                    Config.DocumentElement.RemoveAll();
                    Config.Save(file);
                }

                catch
                {
                    return(false);
                }

                XmlNode storeNode = null;
                XmlNode repoNode  = null;
                XmlNode noteNode  = null;

                XmlAttribute storeLocationAttr = null;
                XmlAttribute repoNameAttr      = Config.CreateAttribute("Name");
                XmlAttribute repoStatusAttr    = Config.CreateAttribute("Status");
                XmlAttribute noteTitleAttr     = Config.CreateAttribute("Title");

                if (ManagerData.Stores.Count > 0)
                {
                    // Cycle through each store cell and create a node.
                    // The only attribute is the location of the store.
                    foreach (StoreCell storeCell in ManagerData.Stores.Values)
                    {
                        storeLocationAttr       = Config.CreateAttribute("Location");
                        storeLocationAttr.Value = storeCell._Path;

                        // Create a store node and add the location attribute
                        storeNode = Config.CreateElement("Store");
                        storeNode.Attributes.Append(storeLocationAttr);

                        try
                        {
                            if (storeCell._Repos.Count > 0)
                            {
                                // Cycle through each store's repo cells and create nodes
                                // Attributes: Name, Status
                                foreach (RepoCell repoCell in storeCell._Repos.Values)
                                {
                                    repoNameAttr       = Config.CreateAttribute(File.ATTRIBUTE_T_ToString(File.ATTRIBUTE_T.NAME));
                                    repoNameAttr.Value = repoCell.Name;

                                    repoStatusAttr       = Config.CreateAttribute(File.ATTRIBUTE_T_ToString(File.ATTRIBUTE_T.STATUS));
                                    repoStatusAttr.Value = RepoCell.Status.ToString(repoCell.Current_Status);

                                    // Create a repo node and add all it's attributes
                                    repoNode = Config.CreateElement("Repo");
                                    repoNode.Attributes.Append(repoNameAttr);
                                    repoNode.Attributes.Append(repoStatusAttr);

                                    if (repoCell.Notes.Count > 0)
                                    {
                                        // Cycle through each repo's notes and create nodes
                                        // The only attribute is the note's title
                                        // The inner text is the note body
                                        foreach (KeyValuePair <string, string> note in repoCell.Notes)
                                        {
                                            noteTitleAttr       = Config.CreateAttribute("Title");
                                            noteTitleAttr.Value = note.Key;

                                            // Create a note node and add it's attribute as well as body
                                            noteNode = Config.CreateElement("Note");
                                            noteNode.Attributes.Append(noteTitleAttr);
                                            noteNode.InnerText = note.Value;

                                            repoNode.AppendChild(noteNode);
                                        }
                                    }

                                    storeNode.AppendChild(repoNode);
                                }
                            }
                        }

                        catch
                        {
                        }

                        // After all information has been added to the store node add it to the file.
                        Config.DocumentElement.AppendChild(storeNode);
                    }
                }

                Config.Save(file);

                return(true);
            }