Пример #1
0
        public void Save()
        {
            if (File.Exists(this.configFilename))
            {
                MOG_Ini ini = new MOG_Ini(this.configFilename);
                if (ini != null)
                {
                    if (this.type == PurgeCommandType.INTERVAL)
                    {
                        ini.PutString("INTERVAL", "LastExecuted", this.lastExecuted.ToString());
                        ini.PutString("INTERVAL", "DayInterval", this.dayInterval.ToString());
                        ini.PutString("INTERVAL", "HourInterval", this.hourInterval.ToString());
                        ini.PutString("INTERVAL", "MinInterval", this.minInterval.ToString());

                        if (ini.KeyExist("TRASH", "Scope"))
                        {
                            if (this.scope.ToString().ToLower() != ini.GetString("TRASH", "Scope").ToLower())
                            {
                                ini.PutString("INTERVAL", "Scope", this.scope.ToString());
                            }
                        }

                        ini.Save();
                        ini.Close();
                    }
                }
            }
        }
Пример #2
0
        private void MilestoneTargetTextBox_TextChanged(object sender, System.EventArgs e)
        {
            // Check if any other patches exist
            string patchInfo = string.Concat(MilestoneTargetTextBox.Text, "\\MOG\\Patches\\Patches.Info");

            if (DosUtils.FileExist(patchInfo))
            {
                PatchNameComboBox.Items.Clear();

                // Open it and add it to our patch list
                MOG_Ini patches = new MOG_Ini(patchInfo);

                // Add a key for our local build first.
                PatchNameComboBox.Items.Add("Local");

                if (patches.SectionExist("PATCHES"))
                {
                    for (int i = 0; i < patches.CountKeys("PATCHES"); i++)
                    {
                        PatchNameComboBox.Items.Add(patches.GetKeyNameByIndex("PATCHES", i));
                    }
                }

                if (patches.SectionExist("Local") && patches.KeyExist("Local", "Current"))
                {
                    PatchNameComboBox.Text = patches.GetString("Local", "Current");
                }
                else
                {
                    PatchNameComboBox.Text = "Unknown";
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Does this button exist in the project defined defaults and is it different?
        /// </summary>
        /// <param name="str"></param>
        /// <param name="platform"></param>
        /// <param name="config"></param>
        /// <returns></returns>
        private bool CheckButtonMatch(string str, string platform, MOG_Ini config)
        {
            string projectName     = mainForm.gMog.GetProject().GetProjectName();
            string platformButtons = projectName + "." + platform + ".Buttons";

            if (config.SectionExist(platformButtons))
            {
                // Lets attempt to set up each button handle found in the handles array
                for (int k = 0; k < config.CountKeys(platformButtons); k++)
                {
                    string buttonKey = "Button" + k.ToString();
                    if (config.KeyExist(platformButtons, buttonKey))
                    {
                        // Get the command string
                        string buttonDefault = config.GetString(platformButtons, buttonKey);

                        // Now assign the name and tool if it was defined
                        if (string.Compare(buttonDefault, str, true) == 0)
                        {
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
Пример #4
0
        public bool Load(string filename)
        {
            if (DosUtils.ExistFast(filename))
            {
                MOG_Ini ini = new MOG_Ini(filename);
                if (ini != null)
                {
                    Clear();
                    AddExclusions(ini.GetString("Sync", "Exclusions"));
                    AddInclusions(ini.GetString("Sync", "Inclusions"));
                    return(true);
                }
            }

            return(false);
        }
Пример #5
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;
        }
Пример #6
0
        private int CreateComboControls(int startY, MOG_Ini dialogInfo, string section)
        {
            int x = 8;
            int y = startY;

            SuspendLayout();
            for (int i = 0; i < dialogInfo.CountKeys(section); i++)
            {
                string key        = dialogInfo.GetKeyNameByIndexSLOW(section, i);
                string keySection = section + "." + key;

                if (dialogInfo.SectionExist(keySection))
                {
                    if (dialogInfo.KeyExist(keySection, "Description"))
                    {
                        y = CreateLabelControl(x, y, dialogInfo.GetString(keySection, "Description"));
                    }
                    else
                    {
                        MOG_Prompt.PromptMessage("Custom Tool", "Cound not correctly create ComboControl due to missing (Description) field in info", Environment.StackTrace);
                    }

                    if (dialogInfo.KeyExist(keySection, "range"))
                    {
                        if (dialogInfo.KeyExist(keySection, "defaultValue"))
                        {
                            y = CreateComboBoxControl(x, y, dialogInfo.GetString(keySection, "range"), dialogInfo.GetString(keySection, "defaultValue"));
                        }
                        else
                        {
                            y = CreateComboBoxControl(x, y, dialogInfo.GetString(keySection, "range"), "0");
                        }
                    }
                    else
                    {
                        MOG_Prompt.PromptMessage("Custom Tool", "Cound not correctly create ComboControl due to missing (Range) field in info", Environment.StackTrace);
                    }
                }
            }

            ResumeLayout(false);

            return(y);
        }
Пример #7
0
        public void Update()
        {
            if (DosUtils.FileExist(string.Concat(mMog.GetProject().GetProjectPath(), "\\Surveys\\Contents.info")))
            {
                MOG_Ini contentsInfo = new MOG_Ini(string.Concat(mMog.GetProject().GetProjectPath(), "\\Surveys\\Contents.info"));
                mainForm.SurveyListView.Items.Clear();

                for (int i = 0; i < contentsInfo.CountKeys("SURVEYS"); i++)
                {
                    string       SurveyName = contentsInfo.GetKeyNameByIndex("SURVEYS", i);
                    ListViewItem item       = new ListViewItem(contentsInfo.GetString(SurveyName, "Title"));
                    item.SubItems.Add(contentsInfo.GetString(SurveyName, "Time"));
                    item.SubItems.Add(contentsInfo.GetString(SurveyName, "Category"));
                    item.SubItems.Add(contentsInfo.GetString(SurveyName, "Status"));
                    item.SubItems.Add(contentsInfo.GetString(SurveyName, "Priority"));

                    mainForm.SurveyListView.Items.Add(item);
                }
            }
        }
Пример #8
0
        public bool LoadRepositories(string iniFilename)
        {
            if (!Directory.Exists(Path.GetDirectoryName(iniFilename)))
            {
                return(false);
            }

            MOG_Ini ini = new MOG_Ini(iniFilename);

            if (ini == null)
            {
                return(false);
            }

            if (ini.SectionExist("REPOSITORIES"))
            {
                for (int i = 0; i < ini.CountKeys("REPOSITORIES"); i++)
                {
                    string key = ini.GetKeyNameByIndexSLOW("REPOSITORIES", i);
                    if (key.ToLower() == "default")
                    {
                        continue;
                    }

                    if (!ini.SectionExist("REPOSITORIES." + key))
                    {
                        continue;
                    }

                    string name = ini.GetString("REPOSITORIES." + key, "name");
                    string path = ini.GetString("REPOSITORIES." + key, "path");
                    AddRepository(name, path);
                }
            }

            ini.Close();
            return(true);
        }
Пример #9
0
        static public string LoadPref(string section, string key)
        {
            if (ini.KeyExist(section, key))
            {
                return(ini.GetString(section, key));
            }

            return("");
        }
Пример #10
0
        private void LoadButtons(MOG_Ini config)
        {
            foreach (guiPlatformButtonHandles platformButton in PlatformButtonHandles)
            {
                string projectName     = mainForm.gMog.GetProject().GetProjectName();
                string platformButtons = projectName + "." + platformButton.mPlatform + ".Buttons";

                if (config.SectionExist(platformButtons))
                {
                    // Lets attempt to set up each button handle found in the handles array
                    for (int k = 0; k < platformButton.mButtonHandles.Count; k++)
                    {
                        string buttonKey = "Button" + k.ToString();
                        if (config.KeyExist(platformButtons, buttonKey))
                        {
                            string buttonName = "";
                            string buttonTool = "";

                            // Split the value of this key by the :
                            string [] parts = config.GetString(platformButtons, buttonKey).Split("@".ToCharArray());
                            if (parts.Length >= 2)
                            {
                                buttonName = parts[0];
                                buttonTool = parts[1];
                            }
                            else if (parts.Length == 1)
                            {
                                buttonName = parts[0];
                            }

                            // Now assign the name and tool if it was defined
                            if (buttonName.Length != 0 && buttonTool.Length != 0)
                            {
                                ((Button)platformButton.mButtonHandles[k]).Text    = buttonName;
                                ((Button)platformButton.mButtonHandles[k]).Tag     = buttonTool;
                                ((Button)platformButton.mButtonHandles[k]).Visible = true;
                            }
                            // Buttons with a name but no tool specified are to be set to inVisible
                            else if (buttonName.Length != 0)
                            {
                                ((Button)platformButton.mButtonHandles[k]).Text    = buttonName;
                                ((Button)platformButton.mButtonHandles[k]).Tag     = "";
                                ((Button)platformButton.mButtonHandles[k]).Visible = false;
                            }
                        }
                    }
                }
            }
        }
Пример #11
0
        public void ProjectRemove()
        {
            // TODO JKB move some of this into the dll?


            if (mainForm.ConfigProjectsListView.SelectedItems.Count <= 0)
            {
                return;
            }

            string projectName = mainForm.ConfigProjectsListView.SelectedItems[0].Text;

            // remove project called 'projectName' from MOG
            if (MessageBox.Show(string.Concat("Are you sure you want to remove project '", projectName, "'?"), "Confirm delete", MessageBoxButtons.YesNo) == DialogResult.No)
            {
                return;
            }

//			MOG_ControllerSystem.GetSystem().ProjectRemove(projectName);

            // TODO: Put this in MOG_System.cpp
            // mark it as deleted in the INI file
            MOG_Ini ini = MOG_ControllerSystem.GetSystem().GetConfigFile();

            ini.RemoveString("projects", projectName);
            ini.PutString("projects.deleted", projectName, "");
            string configFile = ini.GetString(projectName, "ConfigFile");
            string projPath   = MOG_ControllerProject.GetProject().GetProjectPath();

            configFile = configFile.Replace(projPath, string.Concat(projPath, ".deleted"));
            ini.RemoveSection(projectName);
            ini.PutString(string.Concat(projectName, ".deleted"), "ConfigFile", configFile);
            MOG_ControllerSystem.GetSystem().GetProjectNames().Remove(projectName);

            ini.Save();

            // rename directory
            string dirName = MOG_ControllerProject.GetProject().GetProjectPath();

            if (Directory.Exists(dirName) && !Directory.Exists(string.Concat(dirName, ".deleted")))
            {
                Directory.Move(dirName, string.Concat(dirName, ".deleted"));
            }

            // Refresh the MOG system
            MOG_ControllerSystem.GetSystem().GetConfigFile().Load();
            InitializeConfigurations();
        }
Пример #12
0
        private string ExtractRepositoryLocation(string iniFilename)
        {
            string  path     = this.mRepositoryPath;
            MOG_Ini reposIni = new MOG_Ini(iniFilename);

            if (reposIni.SectionExist("MOG_REPOSITORIES") && reposIni.CountKeys("MOG_REPOSITORIES") > 0)
            {
                string firstReposName = reposIni.GetKeyNameByIndexSLOW("MOG_REPOSITORIES", 0);
                if (reposIni.SectionExist(firstReposName))
                {
                    path = reposIni.GetString(firstReposName, "SystemRepositoryPath");
                }
            }
            reposIni.Close();

            return(path);
        }
Пример #13
0
        public SQLConnectForm()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            packetSize      = "4096";
            security        = "SSPI";
            persistSecurity = "False";
            dataSource      = "";
            initialCatalog  = "MOG";

            MOG_Ini config = new MOG_Ini(MOG_Main.GetExecutablePath() + "\\MOG.ini");

            if (config.KeyExist("SQL", "ConnectionString"))
            {
                string    connectionString = config.GetString("SQL", "ConnectionString");
                string [] tokens;
                tokens = connectionString.Split(";".ToCharArray());
                foreach (string token in tokens)
                {
                    string [] values = token.Split("=".ToCharArray());
                    if (values != null && values.Length >= 2)
                    {
                        switch (values[0].ToLower())
                        {
                        case "data source":
                            dataSource = values[1];
                            break;

                        case "initial catalog":
                            initialCatalog = values[1];
                            break;
                        }
                    }
                }
            }

            // packet size=4096;integrated security=SSPI;data source="NEMESIS";persist security info=False;initial catalog=mog

            SQLServerComboBox.Text   = dataSource;
            SQLDatabaseComboBox.Text = initialCatalog;

            mConnectString = "";
        }
Пример #14
0
        public bool GetTasksFromBox(string box, string section, Color textColor, System.Windows.Forms.ListView listViewToFill)
        {
            MOG_Ini contents = new MOG_Ini();

            // Get a handle to the inbox\contents.info
            FileInfo file = new FileInfo(String.Concat(mParent.mMog.GetActiveUser().GetUserPath(), "\\", box, "\\Contents.info"));

            // If the .info file exists, open it
            if (file.Exists)
            {
                // Load the file
                contents.Load(file.FullName);

                // Find the items in the INBOX section
                if (contents.SectionExist(section))
                {
                    for (int i = 0; i < contents.CountKeys(section); i++)
                    {
                        ListViewItem node = new ListViewItem();

                        String assetName = contents.GetKeyNameByIndex(section, i);

                        // Set the due date
                        MOG_Time t = new MOG_Time();
                        t.SetTimeStamp(contents.GetString(assetName, "DUEDATE"));
                        DateTime dueDate = t.ToDateTime();

                        node.Text = (contents.GetString(assetName, "TITLE"));                                           // Name
                        node.SubItems.Add(dueDate.ToString());
                        node.SubItems.Add(contents.GetString(assetName, "TIME"));
                        node.SubItems.Add(contents.GetString(assetName, "CREATOR"));
                        node.SubItems.Add(contents.GetString(assetName, "PRIORITY"));
                        node.SubItems.Add(contents.GetString(assetName, "STATUS"));
                        node.SubItems.Add(contents.GetString(assetName, "ASSET"));
                        node.SubItems.Add(String.Concat(file.DirectoryName, "\\", assetName));                          // Fullname
                        node.SubItems.Add(box);                                                                         // Current box
                        node.ForeColor = textColor;

                        node.ImageIndex = 0;                        //SetAssetIcon(String.Concat(mParent.mMog.GetActiveUser().GetUserPath(), "\\", box, "\\", assetName));
                        listViewToFill.Items.Add(node);
                    }
                }

                contents.Close();
            }

            return(true);
        }
Пример #15
0
        private int AppendSummary(string section, string comment, Color nodeColor)
        {
            // Get all the file copies
            if (mSummary.SectionExist(section))
            {
                string[] keys = mSummary.GetSectionKeys(section);
                foreach (string key in keys)
                {
                    // Get the asset/file information from the summary file
                    string assetName = mSummary.GetString(section, key);
                    string fileName  = key;

                    // Trim any starting '\'
                    if (fileName != null && fileName.Length > 0)
                    {
                        fileName = fileName.TrimStart("\\".ToCharArray());
                    }

                    try
                    {
                        string fullfilename = MOG_ControllerProject.GetCurrentSyncDataController().GetSyncDirectory() + "\\" + fileName;

                        ListViewItem item = new ListViewItem();
                        item.Text      = Path.GetFileName(fileName);
                        item.ForeColor = nodeColor;

                        FileInfo file = new FileInfo(fullfilename);
                        item.SubItems.Add(file.LastWriteTime.ToShortDateString() + " " + file.LastWriteTime.ToShortTimeString());
                        item.SubItems.Add(comment);

                        item.ImageIndex = MogUtil_AssetIcons.GetFileIconIndex(fullfilename);

                        SummaryListView.Items.Add(item);
                    }
                    catch (Exception e)
                    {
                        MOG_Report.ReportMessage("Update Summary", e.Message, e.StackTrace, MOG.PROMPT.MOG_ALERT_LEVEL.ERROR);
                    }
                }

                return(mSummary.CountKeys(section));
            }

            return(0);
        }
Пример #16
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"));
            }
        }
Пример #17
0
        /// <summary>
        /// Reset the button that was clicked on to the projects default state
        /// </summary>
        /// <param name="resetButton"></param>
        public void Reset(Button resetButton)
        {
            // Get the project defaults
            string projectDefaultButtonsFile = mainForm.gMog.GetProject().GetProjectToolsPath() + "\\" + mainForm.gMog.GetProject().GetProjectName() + ".Client.Buttons.Default.info";

            if (DosUtils.FileExist(projectDefaultButtonsFile))
            {
                MOG_Ini defaults = new MOG_Ini(projectDefaultButtonsFile);

                string projectName     = mainForm.gMog.GetProject().GetProjectName();
                string platformButtons = projectName + "." + mainForm.gMog.GetActivePlatform().mPlatformName + ".Buttons";

                string buttonKey = "Button" + GetButtonPrefsString(resetButton);

                if (defaults.KeyExist(platformButtons, buttonKey))
                {
                    string buttonName = "";
                    string buttonTool = "";

                    // Split the value of this key by the @ sign
                    string [] parts = defaults.GetString(platformButtons, buttonKey).Split("@".ToCharArray());
                    if (parts.Length >= 2)
                    {
                        buttonName = parts[0];
                        buttonTool = parts[1];
                    }
                    else if (parts.Length == 1)
                    {
                        buttonName = parts[0];
                    }

                    // Now assign the name and tool if it was defined
                    if (buttonName.Length != 0)
                    {
                        resetButton.Text = buttonName;
                        resetButton.Tag  = buttonTool;
                        Save();
                    }
                }
            }
        }
Пример #18
0
        public bool GetTasksFromBox(string box, string section, Color textColor, ListView listViewToFill)
        {
            MOG_Ini contents = new MOG_Ini();

            // Get a handle to the inbox\contents.info
            FileInfo file = new FileInfo(String.Concat(mParent.mMog.GetActiveUser().GetUserPath(), "\\", box, "\\Contents.info"));

            // If the .info file exists, open it
            if (file.Exists)
            {
                // Load the file
                contents.Load(file.FullName);

                // Find the items in the INBOX section
                if (contents.SectionExist(section))
                {
                    for (int i = 0; i < contents.CountKeys(section); i++)
                    {
                        ListViewItem node = new ListViewItem();

                        String assetName = contents.GetKeyNameByIndex(section, i);

                        node.Text = (contents.GetString(assetName, "SUBJECT"));                                         // Name
                        node.SubItems.Add(contents.GetString(assetName, "TO"));
                        node.SubItems.Add(contents.GetString(assetName, "TIME"));
                        node.SubItems.Add(contents.GetString(assetName, "FROM"));
                        node.SubItems.Add(contents.GetString(assetName, "STATUS"));
                        node.SubItems.Add("");
                        node.SubItems.Add(String.Concat(file.DirectoryName, "\\", assetName));                          // Fullname
                        node.SubItems.Add(box);                                                                         // Current box
                        node.ForeColor = textColor;

                        if (string.Compare(contents.GetString(assetName, "STATUS"), "New", true) == 0)
                        {
                            node.Font = new Font(node.Font, FontStyle.Bold);
                        }

                        node.ImageIndex = 0;                        //SetAssetIcon(String.Concat(mParent.mMog.GetActiveUser().GetUserPath(), "\\", box, "\\", assetName));
                        listViewToFill.Items.Add(node);
                    }
                }
                contents.Close();
            }

            return(true);
        }
Пример #19
0
        public void AddShallowRepositories()
        {
            this.lvIniFile.Items.Clear();

            foreach (string drive in Directory.GetLogicalDrives())
            {
                int type = (int)GetDriveType(drive);
                if (type == DRIVE_TYPE_HD || type == DRIVE_TYPE_NETWORK)
                {
                    if (Directory.Exists(drive))
                    {
                        // look for a repository marker
                        if (File.Exists(drive + "MogRepository.ini"))
                        {
                            // repository exists, open it up
                            MOG_Ini ini = new MOG_Ini(drive + "MogRepository.ini");
                            if (!ini.SectionExist("MOG_REPOSITORIES"))
                            {
                                continue;
                            }

                            for (int sectionIndex = 0; sectionIndex < ini.CountKeys("MOG_REPOSITORIES"); sectionIndex++)
                            {
                                string sectionName = ini.GetKeyNameByIndexSLOW("MOG_REPOSITORIES", sectionIndex);
                                if (ini.SectionExist(sectionName) && ini.KeyExist(sectionName, "SystemRepositoryPath"))
                                {
                                    ListViewItem item = new ListViewItem(sectionName + " on " + drive.Trim("\\".ToCharArray()));
                                    item.SubItems.Add(ini.GetString(sectionName, "SystemRepositoryPath"));
                                    this.lvRepositories.Items.Add(item);
                                }
                            }

                            ini.Close();
                        }
                    }
                }
            }
        }
Пример #20
0
        public void PlayStatusSound(string bank, string status)
        {
            if (!mSoundAvailable)
            {
                return;
            }

            // Create the section name from the theme and back
            string schemeBank = string.Concat(mTheme, ".", bank);

            if (mConfig != null)
            {
                if (mConfig.KeyExist(schemeBank, status))
                {
                    // Get the sound fileName and make a full path
                    string filename = string.Concat(mSoundPath, "\\", mConfig.GetString(schemeBank, status));
                    if (DosUtils.FileExist(filename))
                    {
                        PlaySound(filename);
                    }
                }
            }
        }
        private void CloseButton_Click(object sender, System.EventArgs e)
        {
LocateRepository:

            try
            {
                // Determine if the path selected is valid
                if (!File.Exists(MOGSelectedRepository + "\\MogRepository.ini"))
                {
                    MessageBox.Show(this, "The selected path is not a valid MOG repository.", "Invalid repository");
                    this.DialogResult = DialogResult.Retry;
                    return;
                }
                else
                {
                    // Load the MogRepository.ini file found at the location specified by the user
                    MOG_Ini repository = new MOG_Ini(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");

                                // Now set the config
                                if (repository.SectionExist(section) && repository.KeyExist(section, "SystemConfiguration"))
                                {
                                    mConfigFile = repository.GetString(section, "SystemConfiguration");
                                }
                                else
                                {
                                    MessageBox.Show(this, "The selected path does not have or is missing a System Configuration file.", "Invalid repository");
                                    goto LocateRepository;
                                }
                            }
                            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");

                                    // Now set the config
                                    if (repository.SectionExist(userSection) && repository.KeyExist(userSection, "SystemConfiguration"))
                                    {
                                        mConfigFile = repository.GetString(userSection, "SystemConfiguration");
                                    }
                                    else
                                    {
                                        MessageBox.Show(this, "The selected path does not have or is missing a System Configuration file.", "Invalid repository");
                                        goto LocateRepository;
                                    }
                                }
                                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;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Invalid repository");
                goto LocateRepository;
            }


            // Double check that we got a valid mog repository path
            if (mRepositoryPath.Length == 0)
            {
                goto LocateRepository;
            }
            else
            {
                // Save out our MOG.ini
                SaveMOGConfiguration();

                if (mForceRestart)
                {
                    // Close our application
                    MessageBox.Show(this, "Changing of the MOG repository requires MOG to restart.  We are now shutting down the client. When complete, restart MOG for changes to be effective.", "Shutting down MOG", MessageBoxButtons.OK);
                }
            }
        }
Пример #22
0
        private void ExecucteCustomToolWindow(string toolGroup, string toolName, guiAssetTreeTag tag)
        {
            string  infoFilename = mCustomToolsInfo.Replace("*", toolGroup);
            MOG_Ini customTools  = new MOG_Ini(infoFilename);

            string command  = "";
            string argAsset = "";

            System.Diagnostics.ProcessWindowStyle windowMode = System.Diagnostics.ProcessWindowStyle.Normal;
            bool createWindow = false;

            if (customTools.SectionExist(toolName))
            {
                // Get command
                if (customTools.KeyExist(toolName, "Command"))
                {
                    command = FormatString(tag, customTools.GetString(toolName, "Command"));
                }

                // Get argAsset
                if (customTools.KeyExist(toolName, "argAsset"))
                {
                    argAsset = FormatString(tag, customTools.GetString(toolName, "argAsset"));
                }

                // Get window mode
                if (customTools.KeyExist(toolName, "windowMode"))
                {
                    string mode = FormatString(tag, customTools.GetString(toolName, "windowMode"));

                    if (string.Compare(mode, "Hidden", true) == 0)
                    {
                        windowMode = System.Diagnostics.ProcessWindowStyle.Hidden;
                    }
                    else if (string.Compare(mode, "Maximise", true) == 0)
                    {
                        windowMode = System.Diagnostics.ProcessWindowStyle.Maximized;
                    }
                    else if (string.Compare(mode, "Minimized", true) == 0)
                    {
                        windowMode = System.Diagnostics.ProcessWindowStyle.Minimized;
                    }
                    else if (string.Compare(mode, "Normal", true) == 0)
                    {
                        windowMode = System.Diagnostics.ProcessWindowStyle.Normal;
                    }
                    else
                    {
                        windowMode = System.Diagnostics.ProcessWindowStyle.Normal;
                    }
                }

                // Get Toggle Options
                if (customTools.KeyExist(toolName, "ToggleOptions"))
                {
                    createWindow = true;
                }

                // Get Numerical Options
                if (customTools.KeyExist(toolName, "NumericalOptions"))
                {
                    createWindow = true;
                }

                // Get String Options
                if (customTools.KeyExist(toolName, "StringOptions"))
                {
                    createWindow = true;
                }

                if (createWindow)
                {
                    //CustomToolOptionsForm form = new CustomToolOptionsForm();
                    //form.Text = toolName;

                    //if (form.ShowDialog() == DialogResult.OK)
                    //{
                    // Do stuff
                    //}
                }
                else
                {
                    string output     = "";
                    Report outputForm = new Report(mainForm);
                    if (windowMode == System.Diagnostics.ProcessWindowStyle.Hidden)
                    {
                        outputForm.LogRichTextBox.Text = "GENERATING REPORT.  PLEASE WAIT...";
                        outputForm.LogOkButton.Enabled = false;

                        // Load saved positions
                        //mainForm.mUserPrefs.Load("ReportForm", outputForm);
                        guiUserPrefs.LoadDynamic_LayoutPrefs("ReportForm", outputForm);

                        outputForm.Show(mainForm);
                        Application.DoEvents();
                    }

                    guiCommandLine.ShellSpawn(command.Trim(), argAsset.Trim(), windowMode, ref output);

                    if (windowMode == System.Diagnostics.ProcessWindowStyle.Hidden)
                    {
                        outputForm.LogRichTextBox.Text = output;
                        outputForm.LogOkButton.Enabled = true;
                    }
                }
            }
        }
Пример #23
0
        public bool InitializeMogRepository()
        {
            // First we are going to attempt to load our loader.ini and check if a Repository path was saved froma previous load
            // 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"))
                    {
                        // Now double check that the path specified actually has a Repository.ini at that location
                        // 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") + "\\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") + "\\Updates"))
                                            {
                                                return(true);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

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

            form.ForceRepositorySelection = true;
            form.RepositoryViewVisible    = false;
            form.RepositoryViewVisible    = false;

LocateRepository:

            try
            {
                mSplash.Opacity  = 0;
                this.WindowState = FormWindowState.Minimized;
                if (form.ShowDialog() == DialogResult.OK)
                {
                    // Determine if the path selected is valid
                    if (!File.Exists(form.SelectedPath + "\\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.SelectedPath + "\\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
            {
                //Warn the user if the repository was on a local drive
                string drive = Path.GetPathRoot(mRepositoryPath);
                int    type  = (int)GetDriveType(drive);
                if (type != DRIVE_TYPE_NETWORK)
                {
                    if (MessageBox.Show(this, "It is not recommended to place a MOG Repository on a local drive because it will not be accessible to other users on the network.", "Local Drive Warning", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
                    {
                        goto LocateRepository;
                    }
                }

                // 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);
            }
        }
Пример #24
0
        public void RefreshTab()
        {
            int     newItems = 0;
            MOG_Ini contents = new MOG_Ini();

            // Determine which boxes we are looking at, Inbox or outBox
            string  boxName     = "Unknown";
            TabPage pagePointer = null;

            if (string.Compare(mParent.mainForm.AssetManagerBoxesTabControl.SelectedTab.Name, "AssetManagerInboxTabPage") == 0)
            {
                boxName     = "Inbox";
                pagePointer = mParent.mainForm.AssetManagerInboxTabControl.TabPages[(int)guiAssetManager.InboxTabOrder.MESSAGES];
            }
            else if (string.Compare(mParent.mainForm.AssetManagerBoxesTabControl.SelectedTab.Name, "AssetManagerOutboxTabPage") == 0)
            {
                boxName     = "Outbox";
                pagePointer = mParent.mainForm.AssetManagerOutboxTabControl.TabPages[(int)guiAssetManager.OutboxTabOrder.MESSAGES];
            }
            else
            {
                MOG_REPORT.ShowMessageBox("ERROR", "No valid box selected in mAssetManager.Messages.RefreshTab", MessageBoxButtons.OK);
                return;
            }

            // Check all tasks for the new status
            FileInfo file = new FileInfo(String.Concat(mParent.mMog.GetActiveUser().GetUserPath(), "\\", boxName, "\\Contents.info"));

            // If the .info file exists, open it
            if (file.Exists)
            {
                // Load the file
                contents.Load(file.FullName);

                // Find the items in the TASKS section
                if (contents.SectionExist("Messages"))
                {
                    for (int i = 0; i < contents.CountKeys("Messages"); i++)
                    {
                        string messageName   = contents.GetKeyNameByIndex("Messages", i);
                        string messageStatus = contents.GetString(messageName, "Status");
                        if (string.Compare(messageStatus, "New", true) == 0)
                        {
                            newItems++;
                        }
                    }
                }
            }

            // If we have new items, update the tab
            string tabName;

            if (newItems > 0)
            {
                tabName = string.Concat("Messages ", boxName, "(", newItems.ToString(), ") New");
            }
            else
            {
                tabName = string.Concat("Messages ", boxName);
            }

            // Store this count
            mNewMessageCount = newItems;

            // Set the tab name
            if (pagePointer != null)
            {
                pagePointer.Text = tabName;
            }
        }
Пример #25
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(String.Concat(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();
            }
        }
Пример #26
0
        /// <summary> InitializeAssetIcons
        /// Loads all the bmp's specified in the asset declarations
        /// in the Project.ini files.  Each bmp is added to a
        /// list allong with its key added to a corresponding list
        /// for later searching.
        /// </summary>
        static public void AssetIconInitialize()
        {
            // Check to see if our project is loaded
            if (!MOG_ControllerProject.IsProject())
            {
                return;
            }

            // Only allow population of the images array once
            if (mAssetTypes.Count > 0)
            {
                return;
            }

            // Add the active item icon first
            // Get the image
            if (DosUtils.FileExist(string.Concat(MOG_ControllerSystem.GetSystem().GetSystemToolsPath(), "\\Images\\SelectIcon.bmp")))
            {
                // Get the group image
                Image myImage = new Bitmap(string.Concat(MOG_ControllerSystem.GetSystem().GetSystemToolsPath(), "\\Images\\SelectIcon.bmp"));

                // Add the image and the type to the arrayLists
                mAssetTypeImages.Images.Add(myImage);
                mAssetTypes.Add("dot");
            }

            // Open the project.ini
            MOG_Ini ini = new MOG_Ini(MOG_ControllerProject.GetProject().GetProjectConfigFilename());

            // Walk through all the assets
            for (int x = 0; x < ini.CountKeys("Assets"); x++)
            {
                // Get the asset name
                string imageName = ini.GetString(ini.GetKeyNameByIndex("Assets", x), "Icon");
                // Check if we have an image?
                if (imageName.Length > 0)
                {
                    string assetKey = ini.GetKeyNameByIndex("Assets", x).ToLower();
                    LoadIcon(imageName, ini.GetKeyNameByIndex("Assets", x).ToLower());

                    // Check for a lock image
                    string lockImageName     = Path.GetFileNameWithoutExtension(imageName) + "_locked";
                    string lockFullImageName = imageName.Replace(Path.GetFileNameWithoutExtension(imageName), lockImageName);
                    LoadIcon(lockFullImageName, assetKey + "_locked");

                    // Check for a ReadLock image
                    lockImageName     = Path.GetFileNameWithoutExtension(imageName) + "_readlocked";
                    lockFullImageName = imageName.Replace(Path.GetFileNameWithoutExtension(imageName), lockImageName);
                    LoadIcon(lockFullImageName, assetKey + "_readlocked");
                }
            }

            if (DosUtils.FileExist(string.Concat(MOG_ControllerSystem.GetSystem().GetSystemToolsPath(), "\\Images\\Group.bmp")))
            {
                // Get the group image
                Image myImage = new Bitmap(string.Concat(MOG_ControllerSystem.GetSystem().GetSystemToolsPath(), "\\Images\\Group.bmp"));

                // Add the image and the type to the arrayLists
                mAssetTypeImages.Images.Add(myImage);
                mAssetTypes.Add("group");
            }

            mAssetTypeImages.TransparentColor = Color.Magenta;

            // Initialize state icons
            if (DosUtils.DirectoryExist(MOG_ControllerSystem.GetSystem().GetSystemToolsPath() + "\\Images\\States"))
            {
                FileInfo [] stateImages = DosUtils.FileGetList(MOG_ControllerSystem.GetSystem().GetSystemToolsPath() + "\\Images\\States", "*.bmp");

                foreach (FileInfo stateImage in stateImages)
                {
                    LoadRawIcon(mStateTypeImages, mStateTypes, stateImage.FullName, Path.GetFileNameWithoutExtension(stateImage.Name));
                }
            }
        }
Пример #27
0
        /// <summary>
        /// Fromt he given directory, make a versionNode and return it
        /// </summary>
        /// <param name="directoryName"></param>
        /// <param name="directoryFullName"></param>
        /// <returns></returns>
        private VersionNode CreateVersionNode(string directoryName, string directoryFullName)
        {
            // Can we find a valid version descriptor and the target dir is not a 'current' dir
            if (DosUtils.FileExist(directoryFullName + "\\VERSION.INI"))
            {
                MOG_Ini info = new MOG_Ini(directoryFullName + "\\VERSION.INI");

                // get basic info
                string Name     = info.GetString("INFO", "Name").Replace("\"", "").Trim();
                long   MajorVer = Convert.ToInt64(info.GetString("INFO", "MajorVersion"));
                long   MinorVer = 0;

                // Add code to handle new code drops
                if (info.GetString("INFO", "MinorVersion").Contains("."))
                {
                    MinorVer = Convert.ToInt64(info.GetString("INFO", "MinorVersion").Replace(".", ""));
                }
                else
                {
                    MinorVer = Convert.ToInt64(info.GetString("INFO", "MinorVersion"));
                }

                string type = info.GetString("INFO", "Type").Trim();

                VersionNode versionNode = new VersionNode(Name);

                // Create the version node
                versionNode.FolderName      = directoryName;
                versionNode.MajorVersion    = MajorVer;
                versionNode.MinorVersion    = MinorVer;
                versionNode.SourceDirectory = directoryFullName;
                versionNode.Type            = type;

                // Apply some special settings based on type
                switch (type.ToUpper())
                {
                case "SERVER":
                    versionNode.ImageIndex         = SERVER_ICON;
                    versionNode.ServerMajorVersion = 0;
                    versionNode.ServerMinorversion = 0;
                    break;

                case "CLIENT":
                    long SMajorVer = Convert.ToInt64(info.GetString("SERVERCOMPATABILITY", "ServerMajorVersion"));
                    long SMinorVer = 0;

                    // Add code to handle new code drops
                    if (info.GetString("SERVERCOMPATABILITY", "ServerMinorversion").Contains("."))
                    {
                        SMinorVer = Convert.ToInt64(info.GetString("SERVERCOMPATABILITY", "ServerMinorversion").Replace(".", ""));
                    }
                    else
                    {
                        SMinorVer = Convert.ToInt64(info.GetString("SERVERCOMPATABILITY", "ServerMinorversion"));
                    }

                    versionNode.ServerMajorVersion = SMajorVer;
                    versionNode.ServerMinorversion = SMinorVer;
                    versionNode.ImageIndex         = CLIENT_ICON;
                    break;

                case "BRIDGE":
                    long BMajorVer = Convert.ToInt64(info.GetString("SERVERCOMPATABILITY", "ServerMajorVersion"));
                    long BMinorVer = 0;

                    // Add code to handle new code drops
                    if (info.GetString("SERVERCOMPATABILITY", "ServerMinorversion").Contains("."))
                    {
                        BMinorVer = Convert.ToInt64(info.GetString("SERVERCOMPATABILITY", "ServerMinorversion").Replace(".", ""));
                    }
                    else
                    {
                        BMinorVer = Convert.ToInt64(info.GetString("SERVERCOMPATABILITY", "ServerMinorversion"));
                    }

                    versionNode.ServerMajorVersion = BMajorVer;
                    versionNode.ServerMinorversion = BMinorVer;
                    versionNode.ImageIndex         = BRIDGE_ICON;
                    break;

                default:
                    long dMajorVer = Convert.ToInt64(info.GetString("SERVERCOMPATABILITY", "ServerMajorVersion"));
                    long dMinorVer = 0;

                    // Add code to handle new code drops
                    if (info.GetString("SERVERCOMPATABILITY", "ServerMinorversion").Contains("."))
                    {
                        dMinorVer = Convert.ToInt64(info.GetString("SERVERCOMPATABILITY", "ServerMinorversion").Replace(".", ""));
                    }
                    else
                    {
                        dMinorVer = Convert.ToInt64(info.GetString("SERVERCOMPATABILITY", "ServerMinorversion"));
                    }


                    versionNode.ServerMajorVersion = dMajorVer;
                    versionNode.ServerMinorversion = dMinorVer;
                    versionNode.ImageIndex         = BRIDGE_ICON;
                    break;
                }

                return(versionNode);
            }

            return(null);
        }
Пример #28
0
        public void PopulateVersions()
        {
            if (DosUtils.FileExist(MOG.MOG_Main.GetExecutablePath() + "\\PostVersions.info"))
            {
                MOG_Ini versions = new MOG_Ini(MOG.MOG_Main.GetExecutablePath() + "\\PostVersions.info");

                // Client
                if (versions.SectionExist("Client"))
                {
                    if (versions.KeyExist("Client", "MajorVersion"))
                    {
                        mClientMajorVersion = versions.GetString("Client", "MajorVersion");
                    }

                    if (versions.KeyExist("Client", "MinorVersion"))
                    {
                        mClientMinorVersion = versions.GetString("Client", "MinorVersion");
                    }

                    if (versions.KeyExist("Client", "Name"))
                    {
                        mClientLabel = versions.GetString("Client", "Name");
                    }
                }

                // Server
                if (versions.SectionExist("Server"))
                {
                    if (versions.KeyExist("Server", "MajorVersion"))
                    {
                        mServerMajorVersion = versions.GetString("Client", "MajorVersion");
                    }

                    if (versions.KeyExist("Server", "MinorVersion"))
                    {
                        mServerMinorVersion = versions.GetString("Client", "MinorVersion");
                    }

                    if (versions.KeyExist("Server", "Name"))
                    {
                        mServerLabel = versions.GetString("Client", "Name");
                    }
                }
            }

            if (mClientMajorVersion.ToLower() == "<auto>")
            {
                mClientMajorVersion = GetAutoVersion();
            }
            if (mClientMinorVersion.ToLower() == "<auto>")
            {
                mClientMinorVersion = GetAutoVersion();
            }
            if (mServerMajorVersion.ToLower() == "<auto>")
            {
                mServerMajorVersion = GetAutoVersion();
            }
            if (mServerMinorVersion.ToLower() == "<auto>")
            {
                mServerMinorVersion = GetAutoVersion();
            }
        }
Пример #29
0
        bool RequestNewSlave(MOG_Command pCommand)
        {
            MOG_Command pClient            = null;
            bool        bAutoLaunchedSlave = false;
            bool        bThisSpecificSlaveBeingRequested = false;

            // Check if we should wait a bit longer before we request a slave?
            if (DateTime.Now < mNextSlaveRequstTime)
            {
                // Ignore this request
                return(false);
            }

            // Check for a 'SlaveMachine' section in the System's config file?
            MOG_Ini pConfigFile = MOG_ControllerSystem.GetSystem().GetConfigFile();

            string[] validSlaveMachines = null;
            if (pConfigFile.SectionExist("SlaveMachines"))
            {
                validSlaveMachines = pConfigFile.GetSectionKeys("SlaveMachines");
            }

            // Check if we obtained a list of validSlaveMachines?
            if (validSlaveMachines != null &&
                validSlaveMachines.Length > 0)
            {
                // Scan all the slaves specifically listed in our config file first
                // Walk list of specified SlaveMachines?
                foreach (string machineName in validSlaveMachines)
                {
                    // Get the SlaveMachine info
                    string machinePriority = pConfigFile.GetString("SlaveMachines", machineName);

                    bThisSpecificSlaveBeingRequested = false;

                    // Check if we have already requested this slave?
                    if (IsAlreadyRequestedSlave(machineName))
                    {
                        // We can skip this machine because we have already issued a request for a slave
                        continue;
                    }

                    // Check if we had a specific list of validSlaves specified?
                    if (pCommand.GetValidSlaves().Length != 0)
                    {
                        // Check if this machineName isn't listed in the command's validSlaves?
                        if (IsSlaveListed(machineName, pCommand.GetValidSlaves()))
                        {
                            bThisSpecificSlaveBeingRequested = true;
                        }
                        else
                        {
                            // We can skip this machine because it isn't listed as a validSlave
                            continue;
                        }
                    }

                    // Check if there is already a slave running on this machine?
                    if (mServerCommandManager.LocateRegisteredSlaveByComputerName(machineName) != null)
                    {
                        continue;
                    }

                    // Make sure there is a client running on this machine?
                    pClient = mServerCommandManager.LocateClientByComputerName(machineName);
                    if (pClient != null)
                    {
                        // Check if this Slave should be considered an AutoLaunchedSlave?
                        if (String.Compare(machinePriority, "Always", true) != 0 &&
                            String.Compare(machinePriority, "Yes", true) != 0 &&
                            String.Compare(machinePriority, "True", true) != 0)
                        {
                            // Indicate this slave should be terminated when it is no longer needed
                            bAutoLaunchedSlave = true;
                        }
                        break;
                    }
                }
            }

            // Check if we are still missing a client to launch a slave on?
            if (pClient == null)
            {
                // Scan all the registered clients looking for one that we can send this request to?
                ArrayList registeredClients = this.mServerCommandManager.GetRegisteredClients();
                for (int c = 0; c < registeredClients.Count; c++)
                {
                    MOG_Command pRegisteredClient = (MOG_Command)registeredClients[c];
                    string      machineName       = pRegisteredClient.GetComputerName();

                    bThisSpecificSlaveBeingRequested = false;

                    // Check if we have already requested this slave?
                    if (IsAlreadyRequestedSlave(machineName))
                    {
                        // We can skip this machine because we have already issued a request for a slave
                        continue;
                    }

                    // Check if there is already a slave running on this machine?
                    if (mServerCommandManager.LocateRegisteredSlaveByComputerName(machineName) != null)
                    {
                        continue;
                    }

                    // Check if we had a specific list of validSlaves specified?
                    if (pCommand.GetValidSlaves().Length != 0)
                    {
                        // Check if this machineName isn't listed in the specified validSlaves?
                        if (IsSlaveListed(machineName, pCommand.GetValidSlaves()))
                        {
                            bThisSpecificSlaveBeingRequested = true;
                        }
                        else
                        {
                            // We can skip this machine because it isn't listed as a validSlave
                            continue;
                        }
                    }
                    else
                    {
                        // Check if there was a list of validSlaveMachines specified?
                        if (validSlaveMachines != null)
                        {
                            // Check if this computer was listed?
                            if (pConfigFile.KeyExist("SlaveMachines", machineName))
                            {
                                // Make sure this isn't listed as an exclusion?
                                string machinePriority = pConfigFile.GetString("SlaveMachines", machineName);
                                if (String.Compare(machinePriority, "Never", true) != 0 ||
                                    String.Compare(machinePriority, "No", true) != 0 ||
                                    String.Compare(machinePriority, "Exempt", true) != 0 ||
                                    String.Compare(machinePriority, "Ignore", true) != 0 ||
                                    String.Compare(machinePriority, "Skip", true) != 0)
                                {
                                    continue;
                                }
                            }
                        }
                    }

                    // Looks like we can use this client
                    pClient = pRegisteredClient;
                    // Indicate this slave should be terminated when it is no longer needed
                    bAutoLaunchedSlave = true;
                    break;
                }
            }

            // Check if this is just a generic slave request?
            if (!bThisSpecificSlaveBeingRequested)
            {
                // Check if we have a maximum number of slaves to auto launch? and
                // Check if we are over our maximum number of slaves?
                if (mManagedSlavesMax != 0 &&
                    mManagedSlavesMax < mAutoLaunchedSlaveNames.Count)
                {
                    // No need to launch this slave because we have exceeded our max
                    return(false);
                }
            }

            // Check if we found a client that we can request a new slave from?
            if (pClient != null)
            {
                // Instruct this client to launch a slave
                MOG_ControllerSystem.LaunchSlave(pClient.GetNetworkID());
                // Track when this last request was made
                mNextSlaveRequstTime = DateTime.Now.AddSeconds(5);

                // Add this slave to our list of requested slave names
                AddRequestedSlave(pClient.GetComputerName());
                // Check if we should add this slave as an AutoLaunchedSlave?
                if (bAutoLaunchedSlave)
                {
                    AddAutoLaunchedSlaveName(pClient.GetComputerName());
                }

                // Indicate we launched a new slave
                return(true);
            }

            // Check if it is time to report a missing slave error?
            if (DateTime.Now > mNextNoSlaveReportTime)
            {
                // Check if there was a specific validslaves listed?
                if (pCommand.GetValidSlaves().Length > 0)
                {
                    bool bWarnUser = true;

                    // Split up the specified ValidSlaves
                    String   delimStr   = ",;";
                    Char[]   delimiter  = delimStr.ToCharArray();
                    String[] SlaveNames = pCommand.GetValidSlaves().Trim().Split(delimiter);
                    // Check the registered slaves to see if a valid slave is running
                    for (int n = 0; n < SlaveNames.Length; n++)
                    {
                        // Check if we found our matching slave name?
                        if (mServerCommandManager.LocateRegisteredSlaveByComputerName(SlaveNames[n]) != null)
                        {
                            // We found a match...this command will eventually get processed
                            bWarnUser = false;
                            break;
                        }
                    }

                    // Check if we decided to warn the user?
                    if (bWarnUser)
                    {
                        // Setup the Broadcast message indicating that there are no valid slaves running
                        string message = String.Concat("MOG Server is trying to process a command containing a 'ValidSlaves' property and has been unable to launch the needed Slave.\n",
                                                       "VALIDSLAVES=", pCommand.GetValidSlaves(), "\n\n",
                                                       "Please check this machine to ensure it is connected to the MOG Server.");
                        MOG_ControllerSystem.NetworkBroadcast(pCommand.GetUserName(), message);
                        // Record the time when this report was sent
                        mNextNoSlaveReportTime = DateTime.Now.AddMinutes(5);
                    }
                }
            }

            // Indicate that we failed to find a qualified slave
            return(false);
        }
Пример #30
0
        private bool InitializeFileMap()
        {
            mPlatformSync = new MOG_Ini();

            // Get the platformSinc.info file
            string platformSyncFile = mMog.GetProject().GetProjectToolsPath() + "\\" + mProjectSyncFile;

            if (DosUtils.Exist(platformSyncFile))
            {
                // Open the global sinc file to determine what to sinc
                mPlatformSync.Open(platformSyncFile, FileShare.Read);
                mPlatformSync.SetFilename(mMog.GetUser().GetUserToolsPath() + "\\platformSinc." + mMog.GetActivePlatform().mPlatformName + ".Merge.info", false);
            }

            // Check if the user has a custom sync file
            string userSyncFile = mMog.GetUser().GetUserToolsPath() + "\\" + mUserSyncFile;

            if (DosUtils.FileExist(userSyncFile))
            {
                // Should we force ourselves to use only the user sync file?
                if (string.Compare(mProjectSyncFile, "none", true) == 0)
                {
                    mPlatformSync.CloseNoSave();
                    mPlatformSync.Open(userSyncFile, FileShare.Read);
                }
                else
                {
                    // Lets merge the two then
                    mPlatformSync.PutFile(userSyncFile);
                }
            }

            // Make sure we got 'a' Map file loaded
            if (mPlatformSync.GetFilename().Length > 0)
            {
                // Is this a local sync
                if (Path.IsPathRooted(mTargetConsole))
                {
                    string root = "";
                    // Get our local directory root path
                    // Get our console root path
                    if (mUseDefaultUser)
                    {
                        root = FormatString(mPlatformSync.GetString(mMog.GetActivePlatform().mPlatformName, "SpecialRoot").ToLower());
                    }
                    else
                    {
                        root = FormatString(mPlatformSync.GetString(mMog.GetActivePlatform().mPlatformName, "Root").ToLower());
                    }

                    // Fix up the pc console name
                    mSyncRoot    = mTargetConsole + "\\" + Path.GetFileNameWithoutExtension(root);
                    mConsoleCopy = false;
                }
                else
                {
                    // Get our console root path
                    if (mUseDefaultUser)
                    {
                        mSyncRoot = FormatString(mPlatformSync.GetString(mMog.GetActivePlatform().mPlatformName, "SpecialRoot").ToLower());
                    }
                    else
                    {
                        mSyncRoot = FormatString(mPlatformSync.GetString(mMog.GetActivePlatform().mPlatformName, "Root").ToLower());
                    }
                }
            }
            else
            {
                throw(new Exception("Valid platform sync file never properly loaded!"));
            }

            return(true);
        }