Exemplo n.º 1
0
        private void UpdateDriveMappings()
        {
            string output, command;

            MOG_Ini loader = new MOG_Ini(LoaderConfigFile);

            if (loader.KeyExist("LOADER", "updateDriveMappings"))
            {
                if (loader.GetString("LOADER", "updateDriveMappings") == "0")
                {
                    return;
                }
            }

            command = String.Concat("\\\\Gandalf\\Main FileServer - Advent\\S - System Drive\\", "MOG_Drive_Update.exe");

            // Run the batch file.
            Process p = new Process();

            p.StartInfo.FileName = command;

            p.StartInfo.WindowStyle    = ProcessWindowStyle.Hidden;
            p.StartInfo.CreateNoWindow = true;

            p.StartInfo.RedirectStandardOutput = true;
            p.StartInfo.UseShellExecute        = false;

            p.Start();
            p.WaitForExit();
            output = p.StandardOutput.ReadToEnd();

            p.Close();

            MapLogs.Text = output;
        }
Exemplo n.º 2
0
        public bool PutFile(MOG_Ini iniFile)
        {
            string section, key, value;

            // Loop through all the sections and keys and add them to our ini
            for (int x = 0; x < iniFile.CountSections(); x++)
            {
                section = iniFile.GetSectionByIndex(x);

                if (iniFile.CountKeys(section) != 0)
                {
                    for (int y = 0; y < iniFile.CountKeys(section); y++)
                    {
                        key   = iniFile.GetKeyNameByIndex(section, y);
                        value = iniFile.GetKeyByIndex(section, y);

                        PutString(section, key, value);
                    }
                }
                else
                {
                    // Add the section with no keys into our ini
                    PutSectionString(section, "");
                }
            }

            return(true);
        }
Exemplo n.º 3
0
        private void UpdateAndRunCheckBox_Click(object sender, System.EventArgs e)
        {
            // Save this setting
            MOG_Ini loader = new MOG_Ini("MOG.ini");

            loader.PutString("LOADER", "UpdateRun", UpdateAndRunCheckBox.Checked.ToString());
            loader.Save();
            UserAbort = false;
        }
Exemplo n.º 4
0
        public void SaveMOGConfiguration()
        {
            // Save out our MOG.ini
            MOG_Ini repositoryIni = new MOG_Ini(Environment.CurrentDirectory + "\\" + LoaderTargetDirectory + "\\MOG.ini");

            // Save repository
            repositoryIni.PutString("MOG", "SystemRepositoryPath", mRepositoryPath);
            repositoryIni.PutString("MOG", "SystemConfiguration", "{SystemRepositoryPath}\\Tools\\" + SystemConfigFile);

            // Save the ini
            repositoryIni.Save();
        }
Exemplo n.º 5
0
        public bool PutFile(string iniFile)
        {
            MOG_Ini temp = new MOG_Ini();

            // Load the ini file
            if (temp.Load(iniFile) == false)
            {
                return(false);
            }

            PutFile(temp);

            temp.Close();

            return(true);
        }
Exemplo n.º 6
0
        public FormLoader(SplashForm splash)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            mSplash   = splash;
            UserAbort = false;
            bRunning  = false;

            MOG_Ini loader = new MOG_Ini(LoaderConfigFile);

            if (loader.KeyExist("LOADER", "UpdateRun"))
            {
                UpdateAndRunCheckBox.Checked = Convert.ToBoolean(loader.GetString("LOADER", "UpdateRun"));
            }

            mMainProcess      = new Thread(new ThreadStart(this.Process));
            mMainProcess.Name = "FormLoader.cs::MainProcessThread";
            mMainProcess.Start();
        }
Exemplo n.º 7
0
        public void LoadSysIni()
        {
            try
            {
                // Start the progressBar
                ZipProgressBar(10);

                // Load system Ini
                MOG_Ini loader = new MOG_Ini(LoaderConfigFile);

                // Clear our box
                CheckListBox.Items.Clear();

                // Locate the Master Archive drive
                for (int i = 0; i < loader.CountKeys("UPDATE"); i++)
                {
                    string SectionToBeUpdated = loader.GetKeyNameByIndexSLOW("UPDATE", i);

                    // Get bin locations
                    string gSourceLocation = mRepositoryPath + "\\" + loader.GetString(SectionToBeUpdated, "BINLOCATION");
                    string TargetLocation  = loader.GetString("LOADER", "BINLOCATION");

                    if (TargetLocation.CompareTo("NONE") == 0)
                    {
                        TargetLocation = String.Concat(Environment.CurrentDirectory, "\\" + LoaderTargetDirectory);

                        DirectoryInfo dir = new DirectoryInfo(TargetLocation);
                        if (dir.Exists != true)
                        {
                            dir.Create();
                        }
                    }

                    // Make sure we have a valid fileList in the target drive
                    if (!File.Exists(gSourceLocation + "\\FileList.ini"))
                    {
                        throw new Exception("Current version of (" + SectionToBeUpdated + ") does not exist at:\n\n " + gSourceLocation + "\n\n Aborting...");
                    }

                    // Load the filelist associated with this section
                    MOG_Ini files = new MOG_Ini(gSourceLocation + "\\FileList.ini");


                    // Either update the directory box or the ini
                    if (TargetDir.Text == "")
                    {
                        if (gSourceLocation.CompareTo("") == 0)
                        {
                            TargetDir.Text = String.Concat(Environment.CurrentDirectory, "\\" + LoaderTargetDirectory);
                            gBinLocation   = TargetDir.Text;
                            loader.PutString("LOADER", "BINLOCATION", TargetDir.Text);
                            loader.Save();
                        }
                        else
                        {
                            TargetDir.Text = TargetLocation;
                            gBinLocation   = TargetLocation;
                            loader.PutString("LOADER", "BINLOCATION", TargetDir.Text);
                            loader.Save();
                        }
                    }
                    else
                    {
                        gBinLocation = TargetDir.Text;
                        loader.PutString("LOADER", "BINLOCATION", TargetDir.Text);
                        loader.Save();
                    }

                    // Get the executable to launch with the run button
                    string exeFile = files.GetString(SectionToBeUpdated, "EXE");

                    // Make sure the exe is not NONE
                    if (String.Compare(exeFile, "NONE", true) != 0)
                    {
                        gExeFile = exeFile;
                    }

                    // Walk thru all files
                    for (int x = 0; x < files.CountKeys("FILES"); x++)
                    {
                        ListViewItem item    = new ListViewItem();
                        string       curFile = String.Concat(TargetLocation, "\\", files.GetKeyNameByIndexSLOW("FILES", x));
                        string       newFile = String.Concat(gSourceLocation, "\\", files.GetKeyNameByIndexSLOW("FILES", x));

                        // Check current version against new version
                        FileInfo CurrentBin, NewBin;

                        // Check for special folders
                        if (curFile.IndexOf("<WIN_SYSTEM>") != -1)
                        {
                            // Fix path to reflect new dir
                            curFile = string.Concat(Environment.GetFolderPath(Environment.SpecialFolder.System), curFile.Substring(curFile.IndexOf(">") + 1));
                            newFile = string.Concat(newFile.Substring(0, newFile.IndexOf("<")), newFile.Substring(newFile.IndexOf(">") + 1));
                        }

                        CurrentBin = new FileInfo(curFile);
                        NewBin     = new FileInfo(newFile);

                        // Add file to the menu
                        item.Text = files.GetKeyNameByIndexSLOW("FILES", x);
                        item.SubItems.Add(newFile);
                        item.SubItems.Add(gSourceLocation);                          // Source directory

                        if ((CurrentBin.LastWriteTime.CompareTo(NewBin.LastWriteTime) != 0) || !(CurrentBin.Exists))
                        {
                            Debug.Write("Copy - " + curFile + " \tCurrent:" + CurrentBin.LastWriteTime.ToString() + " New:" + NewBin.LastWriteTime.ToString(), "\nNew Check");
                        }
                        else
                        {
                            Debug.Write("Skip - " + curFile + " \tCurrent:" + CurrentBin.LastWriteTime.ToString() + " New:" + NewBin.LastWriteTime.ToString(), "\nNew Check");
                        }

                        if ((CurrentBin.LastWriteTime.CompareTo(NewBin.LastWriteTime) != 0) || !(CurrentBin.Exists))
                        {
                            if (NewBin.Exists)
                            {
                                // Enable buttons
                                UpdateButton.Enabled    = true;
                                UpdateRunButton.Enabled = true;
                                RunButton.Enabled       = true;
                                allUpToDate             = false;

                                // Check the old file
                                item.Checked = true;
                            }
                            else
                            {
                                item.Remove();
                            }
                        }

                        // Make sure we don't add an asset twice to the list
                        bool alreadyExists = false;
                        foreach (ListViewItem lItem in CheckListBox.Items)
                        {
                            if (String.Compare(lItem.Text, item.Text) == 0)
                            {
                                alreadyExists = true;
                            }
                        }

                        if (alreadyExists == false)
                        {
                            CheckListBox.Items.Add(item);
                        }
                    }
                }

                if (loader.KeyExist("LOADER", "UpdateRun") && !allUpToDate)
                {
                    if (string.Compare(loader.GetString("LOADER", "UpdateRun"), "true", true) == 0)
                    {
                        mSplash.updateSplash("Auto Updating to current version...", 500);

                        if (!UserAbort)
                        {
                            if (UpdateBinary())
                            {
                                allUpToDate   = true;
                                DisableEvents = false;
                                RunBinary();
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(this, e.Message, "Error updating to latest version");
                allUpToDate = false;
                Application.Exit();
            }
        }
Exemplo n.º 8
0
        public bool InitializeMogRepository()
        {
            // FIRST check if we have a valid repository saved in our loader file
            // Load system Ini
            MOG_Ini loader = new MOG_Ini(LoaderConfigFile);

            if (loader != null && loader.CountSections() > 0)
            {
                if (loader.SectionExist("Loader"))
                {
                    if (loader.KeyExist("Loader", "SystemRepositoryPath"))
                    {
                        // Lets verify if the repository that was saved is really still a repository?
                        if (Directory.Exists(loader.GetString("Loader", "SystemRepositoryPath") + "\\Tools") &&
                            Directory.Exists(loader.GetString("Loader", "SystemRepositoryPath") + "\\ProjectTemplates") &&
                            Directory.Exists(loader.GetString("Loader", "SystemRepositoryPath") + "\\Updates"))
                        {
                            mRepositoryPath = loader.GetString("Loader", "SystemRepositoryPath");

                            // SECOND make sure that we have the mog.ini saved correctly in the current directory
                            if (File.Exists(Environment.CurrentDirectory + "\\" + LoaderTargetDirectory + "\\MOG.ini"))
                            {
                                // Also make sure it has a valid repository
                                MOG_Ini targetLoader = new MOG_Ini(Environment.CurrentDirectory + "\\" + LoaderTargetDirectory + "\\MOG.ini");
                                if (targetLoader != null && targetLoader.CountSections() > 0)
                                {
                                    if (targetLoader.SectionExist("MOG"))
                                    {
                                        if (targetLoader.KeyExist("MOG", "SystemRepositoryPath"))
                                        {
                                            // Lets verify if the repository that was saved is really still a repository?
                                            if (Directory.Exists(targetLoader.GetString("MOG", "SystemRepositoryPath") + "\\Tools") &&
                                                Directory.Exists(targetLoader.GetString("MOG", "SystemRepositoryPath") + "\\ProjectTemplates") &&
                                                Directory.Exists(targetLoader.GetString("MOG", "SystemRepositoryPath") + "\\Updates"))
                                            {
                                                return(true);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            // If any of the above conditions fail, have the user locate our repository path for us
            MogForm_RepositoryBrowser_ClientLoader form = new MogForm_RepositoryBrowser_ClientLoader();

LocateRepository:
            try
            {
                mSplash.Opacity  = 0;
                this.WindowState = FormWindowState.Minimized;
                this.Opacity     = 1;
                if (form.ShowDialog() == DialogResult.OK)
                {
                    // Determine if the path selected is valid
                    if (!File.Exists(form.MOGSelectedRepository + "\\MogRepository.ini"))
                    {
                        MessageBox.Show(this, "The selected path is not a valid MOG repository.", "Invalid repository");
                        goto LocateRepository;
                    }
                    else
                    {
                        // Load the MogRepository.ini file found at the location specified by the user
                        MOG_Ini repository = new MOG_Ini(form.MOGSelectedRepository + "\\MogRepository.ini");

                        // Does this MogRepository have at least one valid repository path
                        if (repository.SectionExist("Mog_Repositories"))
                        {
                            // If there is only one specified repository, choose that one
                            if (repository.CountKeys("Mog_Repositories") == 1)
                            {
                                // Get the section
                                string section = repository.GetKeyNameByIndexSLOW("Mog_Repositories", 0);

                                // Get the path from that section
                                if (repository.SectionExist(section) && repository.KeyExist(section, "SystemRepositoryPath"))
                                {
                                    mRepositoryPath = repository.GetString(section, "SystemRepositoryPath");
                                }
                                else
                                {
                                    MessageBox.Show(this, "The selected path does not have or is missing a repository path.", "Invalid repository");
                                    goto LocateRepository;
                                }
                            }
                            else if (repository.CountKeys("Mog_Repositories") > 1)
                            {
                                // The user must now choose which repository to use
                                MogForm_MultiRepository multiRep = new MogForm_MultiRepository();
                                for (int i = 0; i < repository.CountKeys("Mog_Repositories"); i++)
                                {
                                    multiRep.RepositoryComboBox.Items.Add(repository.GetKeyNameByIndexSLOW("Mog_Repositories", i));
                                }
                                multiRep.RepositoryComboBox.SelectedIndex = 0;

                                // Show the form to the user and have him select between the repository sections found
                                if (multiRep.ShowDialog() == DialogResult.OK)
                                {
                                    // Get the section
                                    string userSection = multiRep.RepositoryComboBox.Text;

                                    // Get the path from that section
                                    if (repository.SectionExist(userSection) && repository.KeyExist(userSection, "SystemRepositoryPath"))
                                    {
                                        mRepositoryPath = repository.GetString(userSection, "SystemRepositoryPath");
                                    }
                                    else
                                    {
                                        MessageBox.Show(this, "The selected path does not have or is missing a repository path.", "Invalid repository");
                                        goto LocateRepository;
                                    }
                                }
                                else
                                {
                                    goto LocateRepository;
                                }
                            }
                            else
                            {
                                MessageBox.Show(this, "The selected path does not have or is missing a repository path.", "Invalid repository");
                                goto LocateRepository;
                            }
                        }
                    }
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(this, e.Message, "Invalid repository");
                goto LocateRepository;
            }


            // Double check that we got a valid mog repository path
            if (mRepositoryPath.Length == 0)
            {
                goto LocateRepository;
            }
            else
            {
                // Yup, all is well save it out
                loader.PutString("Loader", "SystemRepositoryPath", mRepositoryPath);
                loader.Save();

                // Save out our MOG.ini
                SaveMOGConfiguration();

                this.Opacity     = 0;
                mSplash.Opacity  = 1;
                this.WindowState = FormWindowState.Normal;
                return(true);
            }
        }