Exemplo n.º 1
0
        private void SaveRepository(SystemRepositoryRoot RepositoryManager)
        {
            XmlSerializer Serializer      = new XmlSerializer(typeof(SystemRepositoryRoot));
            FileStream    RepositoryWrite = new FileStream(RepositoryFile, FileMode.Create, FileAccess.Write);

            Serializer.Serialize(RepositoryWrite, RepositoryManager);
            RepositoryWrite.Close();
        }
Exemplo n.º 2
0
        public void AddToRepository(string SystemName)
        {
            SystemRepositoryRoot RepositoryManager = ReadRepository();
            SystemAttributes     SystemAttrib      = new SystemAttributes();

            SystemAttrib.SystemName = SystemName;
            RepositoryManager.SystemRepository.Add(SystemAttrib);
            SaveRepository(RepositoryManager);
        }
Exemplo n.º 3
0
        public void RemoveFromRepository(string MachineName)
        {
            bool MachineFound = false;
            SystemRepositoryRoot SystemListRoot = ReadRepository();
            SystemAttributes     TargetMachine  = SystemListRoot.SystemRepository.RetrieveMachine(MachineName, ref MachineFound);

            if (MachineFound)
            {
                SystemListRoot.SystemRepository.Delete(TargetMachine);
                SaveRepository(SystemListRoot);
            }
        }
Exemplo n.º 4
0
        public SystemRepositoryRoot ReadRepository()
        {
            XmlSerializer Deserialize = new XmlSerializer(typeof(SystemRepositoryRoot));

            SystemRepositoryRoot RepositoryManager = new SystemRepositoryRoot();

            try
            {
                if (File.Exists(RepositoryFile))
                {
                    FileStream RepositoryFileRead = new FileStream(RepositoryFile, FileMode.Open, FileAccess.Read);
                    RepositoryManager = Deserialize.Deserialize(RepositoryFileRead) as SystemRepositoryRoot;
                    RepositoryFileRead.Close();
                }
            }
            catch (Exception Ex)
            {
                RepositoryManager = new SystemRepositoryRoot();
            }
            return(RepositoryManager);
        }