Пример #1
0
        private void Restore(string projName, string iniFilename)
        {
            // make sure iniFilename points to valid file
            if (File.Exists(iniFilename))
            {
                // make sure directory exists
                if (Directory.Exists(MOG_ControllerSystem.GetSystemDeletedProjectsPath() + "\\" + projName))
                {
                    if (DosUtils.DirectoryExistFast(MOG_ControllerSystem.GetSystemProjectsPath() + "\\" + projName))
                    {
                        // A project of this name already exists
                        MOG_Prompt.PromptMessage("Project Name Conflict", "Projects cannot be restored over the top of another active project.");
                        return;
                    }

                    List <string> args = new List <string>();
                    args.Add(projName);
                    args.Add(iniFilename);

                    string message = "Please wait while MOG restores deleted project.\n" +
                                     "   PROJECT: " + projName;
                    ProgressDialog progress = new ProgressDialog("Restoring project", message, Restore_Worker, args, false);
                    progress.ShowDialog();
                }
            }
        }
Пример #2
0
        private void Purge_Worker(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker      = sender as BackgroundWorker;
            List <string>    args        = e.Argument as List <string>;
            string           projName    = args[0];
            string           iniFilename = args[1];

            // open the ini file
            MOG_Ini ini = new MOG_Ini(iniFilename);

            if (ini != null)
            {
                bool bFailed = false;

                // Attempt to remove the project
                if (DosUtils.DirectoryExist(MOG_ControllerSystem.GetSystemDeletedProjectsPath() + "\\" + projName))
                {
                    if (!DosUtils.DirectoryDeleteFast(MOG_ControllerSystem.GetSystemDeletedProjectsPath() + "\\" + projName))
                    {
                        Utils.ShowMessageBoxExclamation("Can't purge " + projName + ", probably because of a sharing violation", "Project Removal Failure");
                        bFailed = true;
                    }
                }

                if (!bFailed)
                {
                    // make sure projName is a deleted project
                    if (ini.SectionExist(projName + ".Deleted"))
                    {
                        // Remove the project from the list of deleted projects
                        ini.RemoveString("Projects.Deleted", projName);
                        ini.RemoveSection(projName + ".Deleted");

                        BlankInfoBox();

                        ini.Save();
                    }
                }

                ini.Close();

                LoadIniFile(iniFilename);
            }
        }
Пример #3
0
        private void Restore_Worker(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker      = sender as BackgroundWorker;
            List <string>    args        = e.Argument as List <string>;
            string           projName    = args[0];
            string           iniFilename = args[1];

            // open the ini file
            MOG_Ini ini = new MOG_Ini(iniFilename);

            if (ini != null)
            {
                // make sure projName is a deleted project
                if (ini.SectionExist(projName + ".Deleted"))
                {
                    // Attempt to move the project's directory
                    if (DosUtils.DirectoryMoveFast(MOG_ControllerSystem.GetSystemDeletedProjectsPath() + "\\" + projName, MOG_ControllerSystem.GetSystemProjectsPath() + "\\" + projName, true))
                    {
                        // Restore the project to the active projects list
                        ini.PutString("Projects", projName, "");
                        ini.RemoveString("Projects.Deleted", projName);
                        ini.RenameSection(projName + ".Deleted", projName);

                        // Restore the project's database
                        MOG_ControllerSystem.GetDB().VerifyTables(projName);
                        MOG_Database.ImportProjectTables(projName, this.mogProjectsPath + "\\" + projName);
                    }

                    BlankInfoBox();

                    ini.Save();
                }

                ini.Close();

                LoadIniFile(iniFilename);
            }
        }
Пример #4
0
        private void LoadIniFile(string iniFilePath)
        {
            if (!File.Exists(iniFilePath))
            {
                return;
            }

            // setup list view and ini reader
            this.lvRemovedProjects.Items.Clear();
            MOG_Ini ini = new MOG_Ini(iniFilePath);

            // Make sure the section exists?
            if (ini.SectionExist("Projects.Deleted"))
            {
                // for each "deleted" project listed
                for (int i = 0; i < ini.CountKeys("Projects.Deleted"); i++)
                {
                    string projName = ini.GetKeyNameByIndexSLOW("Projects.Deleted", i);

                    // Check if the deleted project's directory is missing?
                    if (!DosUtils.DirectoryExistFast(MOG_ControllerSystem.GetSystemDeletedProjectsPath() + "\\" + projName))
                    {
                        // Auto clean this deleted project from the ini
                        ini.RemoveSection(projName + ".Deleted");
                        ini.RemoveString("projects.deleted", projName);
                        continue;
                    }

                    ListViewItem item = new ListViewItem();
                    item.Text = projName;
//					item.Tag = new RemovedProjectInfo( configFile );
                    this.lvRemovedProjects.Items.Add(item);
                }
            }

            ini.Close();
        }