示例#1
0
        // checks projName against known project names, both those in the repository and in the database
        public static bool DuplicateProjectNameCheck(string projName, bool verbose)
        {
            // make sure we don't have a project called projName locally
            foreach (string existingProjName in MOG_ControllerSystem.GetSystem().GetProjectNames())
            {
                if (existingProjName.ToLower() == projName.ToLower())
                {
                    if (verbose)
                    {
                        Utils.ShowMessageBoxExclamation("Duplicate project name.\nA project called " + projName + " already exists.", "Duplicate Project Name");
                    }

                    return(false);
                }
            }

            // make sure projName doesn't exist in the tables
            if (MOG_ControllerSystem.GetDB().ProjectTablesExist(projName))
            {
                // allow user to overwrite the tables if he wants
                if (Utils.ShowMessageBoxConfirmation("Project information tables for a project named " + projName + " currently exist in the database.\nWould you like to overwrite these tables?", "Overwrite Duplicate Tables?") == MOGPromptResult.No)
                {
                    return(false);
                }

                // remove the tables
                MOG_ControllerSystem.GetDB().DeleteProjectTables(projName);
            }

            return(true);
        }
示例#2
0
        public VersionManagerClass(MOG_ServerManagerMainForm main)
        {
            mainForm = main;
            mainForm.VersionFilesListView.SmallImageList = MogUtil_AssetIcons.Images;
            ListViewSortManager serverVersions = new ListViewSortManager(mainForm.ServerListView, new Type[] {
                typeof(ListViewTextCaseInsensitiveSort),
                typeof(ListViewTextCaseInsensitiveSort)
            });
            ListViewSortManager clientVersions = new ListViewSortManager(mainForm.ClientListView, new Type[] {
                typeof(ListViewTextCaseInsensitiveSort),
                typeof(ListViewTextCaseInsensitiveSort)
            });

            mListViewSort_Manager.Add(serverVersions);
            mListViewSort_Manager.Add(clientVersions);
            mListViewSort_Manager.Add(new ListViewSortManager(mainForm.VersionFilesListView, new Type[] {
                typeof(ListViewTextCaseInsensitiveSort),
                typeof(ListViewDateSort),
                typeof(ListViewInt64Sort)
            }
                                                              ));

            serverVersions.Sort(0, SortOrder.Descending);
            clientVersions.Sort(0, SortOrder.Descending);

            DeploymentDirectory = MOG_ControllerSystem.GetSystem().GetConfigFile().GetString("MOG", "Updates");
            DeploymentDirectory = DeploymentDirectory.ToLower().Replace(MOG_Tokens.GetSystemRepositoryPath().ToLower(), MOG_ControllerSystem.GetSystemRepositoryPath());
        }
示例#3
0
        static public List <string> GetPlatforms(string project)
        {
            List <string> platformNames = new List <string>();

            MOG_Project projectPtr;

            if (project.Length != 0)
            {
                projectPtr = MOG_ControllerSystem.GetSystem().GetProject(project);
            }
            else
            {
                projectPtr = MOG_ControllerProject.GetProject();
            }

            // Make sure we have an active project
            if (projectPtr != null)
            {
                ArrayList platforms = MOG_ControllerProject.GetProject().GetPlatforms();

                // Add a comboBox item for every platform
                foreach (MOG_Platform platform in platforms)
                {
                    platformNames.Add(platform.mPlatformName);
                }
            }

            return(platformNames);
        }
        bool Initialize()
        {
            // Load the Network settings from the MOG_SYSTEM_CONFIGFILENAME
            MOG_Ini pConfigFile = MOG_ControllerSystem.GetSystem().GetConfigFile();

            // Check if this server has a managed slave setting?
            if (pConfigFile.KeyExist("Slaves", "ManagedSlavesMax"))
            {
                // Initialize the Server's ManagedSlavesMax
                mManagedSlavesMax = pConfigFile.GetValue("Slaves", "ManagedSlavesMax");
            }

            return(true);
        }
示例#5
0
        static public List <string> GetProjects()
        {
            List <string> projects = new List <string>();

            // Make sure the system has the latest project info
            MOG_ControllerSystem.GetSystem().Load();

            foreach (string project in MOG_ControllerSystem.GetSystem().GetProjectNames())
            {
                projects.Add(project);
            }

            return(projects);
        }
示例#6
0
        public MOGAutoTest()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            foreach (string projectName in MOG_ControllerSystem.GetSystem().GetProjectNames())
            {
                this.AutoTestProjectComboBox.Items.Add(projectName);
            }

            if (UserPrefs.LoadPref("AutoTest", "Project").Length != 0)
            {
                this.AutoTestProjectComboBox.Text = UserPrefs.LoadPref("AutoTest", "Project");
            }

            this.AutoTestFileTextBox.Text = UserPrefs.LoadPref("AutoTest", "File");
            if (UserPrefs.LoadPref("AutoTest", "Time").Length != 0)
            {
                this.AutoTestTimeTrackBar.Value = Convert.ToInt32(UserPrefs.LoadPref("AutoTest", "Time"));
                this.AutoTestTimeTextBox.Text   = UserPrefs.LoadPref("AutoTest", "Time");
            }

            if (UserPrefs.LoadPref("AutoTest", "Delay").Length != 0)
            {
                this.AutoTestDelayTrackBar.Value = Convert.ToInt32(UserPrefs.LoadPref("AutoTest", "Delay"));
                this.AutoTestDelayTextBox.Text   = UserPrefs.LoadPref("AutoTest", "Delay");
            }

            foreach (string testName in MOG_SystemUtilities.GetAutomatedTestNames())
            {
                this.AutoTestTestNameComboBox.Items.Add(testName);
            }

            if (UserPrefs.LoadPref("AutoTest", "Name").Length != 0)
            {
                this.AutoTestTestNameComboBox.Text = UserPrefs.LoadPref("AutoTest", "Name");
            }

            if (UserPrefs.LoadPref("AutoTest", "CopyFileLocal").Length != 0)
            {
                this.AutoTestCopyFileLocalCheckBox.Checked = Convert.ToBoolean(UserPrefs.LoadPref("AutoTest", "CopyFileLocal"));
            }

            if (UserPrefs.LoadPref("AutoTest", "StartIndex").Length != 0)
            {
                this.AutoTestStartIndexTextBox.Text = UserPrefs.LoadPref("AutoTest", "StartIndex");
            }
        }
        private void LoadProjects(TreeNode root)
        {
            // Clear all the projects
            //this.lvProjects.Items.Clear();

            // Get all the projects listed in the mog system
            foreach (string projectName in MOG_ControllerSystem.GetSystem().GetProjectNames())
            {
                MOG_Project pProject = MOG_ControllerSystem.GetSystem().GetProject(projectName);
                if (pProject != null)
                {
                    root.Nodes.Add(CreateProjectNode(pProject));
                }
            }
        }
示例#8
0
        public void ProjectCreate()
        {
            NewProjectForm npf = new NewProjectForm();

            if (npf.ShowDialog() == DialogResult.OK && MessageBox.Show("Are you sure you want to add project '" + npf.NewProjectNameTextBox.Text + "'?", "Confirm project add", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                string projectName = npf.NewProjectNameTextBox.Text;
                MOG_ControllerSystem.GetSystem().ProjectCreate(projectName);

                // Refresh the MOG system
                MOG_ControllerSystem.GetSystem().GetConfigFile().Load();

                InitializeConfigurations();
            }
        }
示例#9
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();
        }
示例#10
0
        public CreateNewProjectForm(string defaultProjName)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            RefreshDemoProjectsListView();

            this.projectInfoControl.ProjectsPath             = MOG_ControllerSystem.GetSystem().GetSystemProjectsPath();
            this.projectInfoControl.ProjectName_TextChanged += new EventHandler(projectInfoControl_ProjectName_TextChanged);

            this.projectInfoControl.ProjectName = defaultProjName;
            if (defaultProjName != null)
            {
                this.projectInfoControl.ProjectNameSelectAll();
            }
        }
示例#11
0
        internal static List <string> GetDepartments(string projectname)
        {
            List <string> departments = new List <string>();

            MOG_Project project = MOG_ControllerSystem.GetSystem().GetProject(projectname);

            if (project != null)
            {
                foreach (MOG_User user in project.GetUsers())
                {
                    if (departments.Contains(user.GetUserDepartment()) == false)
                    {
                        departments.Add(user.GetUserDepartment());
                    }
                }
            }

            return(departments);
        }
示例#12
0
        public static bool SetOffline(MogMainForm mainForm, bool offline)
        {
            if (offline)
            {
                // TODO KIER How do we go offline now?

//				string targetPath = string.Concat(MOG_ControllerProject.GetGameData().GetGameDataPath(), "\\MOG\\Offline");
//				if (MOG_ControllerProject.GetProject().Offline(targetPath))
//				{
//					// Disconnect from the server
//					MOG_ControllerSystem.GoOffline();
//
//					if (MOG_ControllerSystem.GetSystem().Load(MOG_Main.BuildDefaultConfigFile(targetPath, "", "")))
//					{
//						// Reload the project
//						MOG_ControllerProject.LoginProject(MOG_ControllerProject.GetProjectName(), MOG_ControllerProject.GetBranchName());
//
//						// Set our gui
//						guiStartup.ConnectionStatus(mainForm, false);
//					}
//				}
            }
            else
            {
                // Connect to the server
                MOG_ControllerSystem.GoOnline();

                if (MOG_ControllerSystem.GetSystem().Load(MOG_Main.BuildDefaultConfigFile()))
                {
                    // Reload the project
                    MOG_ControllerProject.LoginProject(MOG_ControllerProject.GetProjectName(), MOG_ControllerProject.GetBranchName());

                    // Login user
                    MOG_ControllerProject.LoginUser(MOG_ControllerProject.GetUser().GetUserName());

                    // Set our gui
                    guiStartup.ConnectionStatus(mainForm, true);
                }
            }

            return(true);
        }
示例#13
0
        static public void MOGGlobalProjectsInit(bool force)
        {
            // Add all valid login projects
            if (mainForm.projectsToolStripMenuItem.DropDownItems.Count == 0 || force)
            {
                mainForm.projectsToolStripMenuItem.DropDownItems.Clear();

                // Reload the system ini
                MOG_ControllerSystem.GetSystem().Load(MOG_ControllerSystem.GetSystem().GetConfigFilename());

                foreach (string project in MOG_ControllerSystem.GetSystem().GetProjectNames())
                {
                    ToolStripMenuItem Item = new ToolStripMenuItem(project);
                    Item.Click += new System.EventHandler(MainMenuProjectsClass.MOGGlobalProjects_Click);
                    mainForm.projectsToolStripMenuItem.DropDownItems.Add(Item);
                }

                mainForm.projectsToolStripMenuItem.Enabled = true;
            }
        }
示例#14
0
        static public List <string> GetUsers(string projectname, string department)
        {
            List <string> users = new List <string>();

            MOG_Project project = MOG_ControllerSystem.GetSystem().GetProject(projectname);

            if (project != null)
            {
                foreach (MOG_User user in project.GetUsers())
                {
                    // Is this user within the same department as the one specified
                    if (string.Compare(user.GetUserDepartment(), department, true) == 0)
                    {
                        users.Add(user.GetUserName());
                    }
                }
            }

            return(users);
        }
示例#15
0
        public void InitializeConfigurations()
        {
            // Clear all the projects
            mainForm.AutoBuildOptionsProjectComboBox.Items.Clear();
            mainForm.ConfigProjectsListView.Items.Clear();

            // Get all the projects listed in the mog system
            foreach (string projectName in MOG_ControllerSystem.GetSystem().GetProjectNames())
            {
                ListViewItem project = new ListViewItem();

                project.Text = projectName;

                mainForm.ConfigProjectsListView.Items.Add(project);

                // Populate the AutoBuild project comboBox
                mainForm.AutoBuildOptionsProjectComboBox.Items.Add(projectName);

                //project.SubItems.Add(lMog.GetSystem().);
            }
        }
        public static bool InitializeServer(string configFilename, MOG_CommandServerCS server)
        {
            MOG_ControllerSystem.InitializeSystem(configFilename, server);
            MOG_System system = MOG_ControllerSystem.GetSystem();

            if (system != null)
            {
                // Initialize the server mode?
                MOG_ControllerSystem.SetSystemMode(MOG_SystemMode.MOG_SystemMode_Server);

                // Recover saved locks from database
                if (!server.GetDatabaseLocks())
                {
                    // Display the broadcasted message
                    MOG_Prompt.PromptMessage("Database Connection Failed", "Unable to recover persistant locks from the database.", Environment.StackTrace);
                }

                return(true);
            }

            return(false);
        }
示例#17
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);
        }
示例#18
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));
                }
            }
        }
示例#19
0
        private void CreateProject_Worker(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;

            MOG_Project project = new MOG_Project();

            try
            {
                MOG_System sys = MOG_ControllerSystem.GetSystem();
                if (sys != null)
                {
                    project = sys.ProjectCreate(this.projectInfoControl.ProjectName);
                    if (project != null)
                    {
                        worker.ReportProgress(0, "Setting project info...");

                        // project info
                        project.SetProjectPath(this.projectInfoControl.ProjectPath);
                        project.SetProjectToolsPath(this.projectInfoControl.ProjectPath + "\\Tools");
                        project.SetProjectUsersPath(this.projectInfoControl.ProjectPath + "\\Users");

                        worker.ReportProgress(0, "Copying tools...");

                        worker.ReportProgress(0, "Saving and logging in...");

                        // create project and login
                        project.Save();

                        MOG_ControllerProject.LoginProject(this.projectInfoControl.ProjectName, "");

                        worker.ReportProgress(0, "Creating current branch...");

                        // create default branch
                        MOG_ControllerProject.BranchCreate("", "Current");

                        worker.ReportProgress(0, "Creating classification tree...");

                        // platforms
                        MOG_Platform pcPlatform = new MOG_Platform();
                        pcPlatform.mPlatformName = "PC";
                        project.PlatformAdd(pcPlatform);

                        // create classifications
                        MogUtil_ClassificationLoader classLoader = new MogUtil_ClassificationLoader();
                        classLoader.ProjectName = this.projectInfoControl.ProjectName;
                        foreach (MOG_Properties props in classLoader.GetClassPropertiesListFromFiles())
                        {
                            if (props.Classification.ToLower() == project.GetProjectName().ToLower())
                            {
                                // create only project name root class node
                                project.ClassificationAdd(props.Classification);
                                MOG_Properties properties = project.GetClassificationProperties(props.Classification);
                                properties.SetImmeadiateMode(true);
                                properties.SetProperties(props.GetPropertyList());
                                break;
                            }
                        }

                        project.Save();
                    }
                    else
                    {
                        throw new Exception("Failed to create the project.");
                    }
                }
                else
                {
                    throw new Exception("System not initialized.");
                }
            }
            catch (Exception ex)
            {
                MOG_Report.ReportMessage("Project Creation Failed", ex.Message, ex.StackTrace, MOG_ALERT_LEVEL.CRITICAL);
            }

            e.Result = project;
        }