Пример #1
0
        //-------------------------------------------------------------------------

        private void manageProfilesBtn_Click(object sender, EventArgs e)
        {
            try
            {
                TemplateCommonValueCollectionEntry selectedProfile =
                    (profileCbo.SelectedItem as TemplateCommonValueCollectionEntry);

                ProjectProfileManagementForm form =
                    new ProjectProfileManagementForm(projectList.SelectedItem as Project);

                form.ShowDialog();

                RefreshProfileCbo();

                // re-select the profile that was selected
                if (profileCbo.Items.Contains(selectedProfile))
                {
                    profileCbo.SelectedItem = selectedProfile;
                }
            }
            catch (Exception ex)
            {
                ErrorMsg(ex.Message);
            }
        }
        //-------------------------------------------------------------------------

        private void newBtn_Click(object sender, EventArgs e)
        {
            try
            {
                // already exists? do nothing
                foreach (TemplateEntry entry in m_project.Template.CommonValueCollections)
                {
                    if (entry.Description.ToLower() == "new profile")
                    {
                        return;
                    }
                }

                // create new profile
                TemplateCommonValueCollectionEntry newProfile = new
                                                                TemplateCommonValueCollectionEntry();

                newProfile.Description = "New Profile";

                m_project.Template.AddEntry(newProfile);

                RefreshProfileList();
            }
            catch (Exception ex)
            {
                ErrorMsg(ex.Message);
            }
        }
        //-------------------------------------------------------------------------

        private void copyBtn_Click(object sender, EventArgs e)
        {
            try
            {
                TemplateCommonValueCollectionEntry source =
                    (profileList.SelectedItem as TemplateCommonValueCollectionEntry);

                if (source != null)
                {
                    string newDescription = "Copy of " + source.Description;

                    // already exists? do nothing
                    foreach (TemplateEntry entry in m_project.Template.CommonValueCollections)
                    {
                        if (entry.Description.ToLower() == newDescription.ToLower())
                        {
                            return;
                        }
                    }

                    // create copy
                    TemplateCommonValueCollectionEntry newProfile =
                        source.Copy(newDescription);

                    m_project.Template.AddEntry(newProfile);

                    RefreshProfileList();
                }
            }
            catch (Exception ex)
            {
                ErrorMsg(ex.Message);
            }
        }
        //-------------------------------------------------------------------------

        private void commonValuesBtn_Click(object sender, EventArgs e)
        {
            try
            {
                TemplateCommonValueCollectionEntry values =
                    (profileList.SelectedItem as TemplateCommonValueCollectionEntry);

                if (values == null)
                {
                    return;
                }

                m_project.ActiveCommonValueCollection = values;

                PairedValueSetupForm form =
                    new PairedValueSetupForm(m_project.CommonValues,
                                             new List <string>(),
                                             "PRJ_");

                form.Text = "Project '" + m_project.Name + "' Common Values Setup";
                form.ShowDialog();

                if (form.DialogResult == DialogResult.OK)
                {
                    m_project.CommonValues = form.PairedValues;
                    m_project.WriteToFile();
                }

                form.Dispose();
            }
            catch (Exception ex)
            {
                ErrorMsg(ex.Message);
            }
        }
        //-------------------------------------------------------------------------

        private void deleteBtn_Click(object sender, EventArgs e)
        {
            try
            {
                TemplateCommonValueCollectionEntry toDelete =
                    (profileList.SelectedItem as TemplateCommonValueCollectionEntry);

                if (toDelete != null &&
                    m_project.Template.CommonValueCollections.Count > 1)
                {
                    // sure?
                    if (MessageBox.Show("Delete profile '" + toDelete.Description + "'?",
                                        "Delete?",
                                        MessageBoxButtons.YesNo,
                                        MessageBoxIcon.Exclamation,
                                        MessageBoxDefaultButton.Button2) == DialogResult.No)
                    {
                        return;
                    }

                    // delete it
                    m_project.Template.DeleteEntry(toDelete);

                    RefreshProfileList();
                }
            }
            catch (Exception ex)
            {
                ErrorMsg(ex.Message);
            }
        }
Пример #6
0
        //-------------------------------------------------------------------------

        private void RefreshActiveCommonValueCollection()
        {
            // find the active collection
            foreach (TemplateCommonValueCollectionEntry entry in m_template.CommonValueCollections)
            {
                if (entry.IsActive)
                {
                    m_activeCommonValueCollection = entry;
                    break;
                }
            }

            // none marked as being active?
            if (m_activeCommonValueCollection == null)
            {
                // use the first one
                if (m_template.CommonValueCollections.Count > 0)
                {
                    m_activeCommonValueCollection = m_template.CommonValueCollections[0];
                }
                else
                {
                    m_activeCommonValueCollection             = new TemplateCommonValueCollectionEntry();
                    m_activeCommonValueCollection.Description = "Default";

                    m_template.AddEntry(m_activeCommonValueCollection);

                    WriteToFile();
                }
            }
        }
Пример #7
0
        //-------------------------------------------------------------------------

        public TemplateCommonValueCollectionEntry Copy(string newDescription)
        {
            TemplateCommonValueCollectionEntry copy = new TemplateCommonValueCollectionEntry();

            copy.Description = newDescription;
            copy.Values      = new Dictionary <string, string>(m_values);

            return(copy);
        }
Пример #8
0
        //-------------------------------------------------------------------------

        public void LoadFromFile(string fullFilename)
        {
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load(fullFilename);

            // template info
            XmlNodeList nodes       = xmlDoc.GetElementsByTagName("Info");
            XmlElement  infoElement = nodes[0] as XmlElement;

            m_name = infoElement.Attributes["name"].Value;

            if (infoElement.HasAttribute("isArchived"))
            {
                m_isArchived = Boolean.Parse(infoElement.Attributes["isArchived"].Value);
            }

            // entries
            XmlNodeList entryElements = xmlDoc.GetElementsByTagName("Entry");

            foreach (XmlNode xmlNode in entryElements)
            {
                TemplateEntry newEntry = null;

                // get the type
                XmlElement entryElement = (xmlNode as XmlElement);

                string type = entryElement.Attributes["type"].Value;

                // create the specified type of entry
                switch (type)
                {
                case TemplateShortcutEntry.c_typeName:
                    newEntry = new TemplateShortcutEntry(entryElement);
                    break;

                case TemplateCommonValueCollectionEntry.c_typeName:
                    newEntry = new TemplateCommonValueCollectionEntry(entryElement);
                    break;
                }

                // add it to the list
                if (newEntry != null)
                {
                    AddEntry(newEntry);
                }
            }
        }
        //-------------------------------------------------------------------------

        private void profileList_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                TemplateCommonValueCollectionEntry entry =
                    (profileList.SelectedItem as TemplateCommonValueCollectionEntry);

                if (entry != null)
                {
                    nameTxt.Text = entry.Description;
                }
            }
            catch (Exception ex)
            {
                ErrorMsg(ex.Message);
            }
        }
Пример #10
0
        //-------------------------------------------------------------------------

        private void createBtn_Click(object sender, EventArgs e)
        {
            //-- Validate input.
            if (typeCbo.Text == "" ||
                masterconfigTxt.Text == "" ||
                nameTxt.Text == "" ||
                sourceFolderTxt.Text == "" ||
                sourceFolderTxt.Text == c_exampleSourceFolder)
            {
                ErrorMsg("Incomplete information!");
                return;
            }

            //-- Create a Project.
            try
            {
                m_project = Program.g_projectManager.CreateProject(nameTxt.Text);
            }
            catch (Exception ex)
            {
                ErrorMsg(ex.Message);
                return;
            }

            //-- Profiles?
            bool useTestProfileOnly = (profilesCbo.Text == "TEST ONLY");

            //-- Create profiles.
            TemplateCommonValueCollectionEntry newProfile = new TemplateCommonValueCollectionEntry();

            newProfile.Description = "TEST";
            newProfile.Values.Add("PRJ_PROFILE", "TEST");
            newProfile.Values.Add("PRJ_DEVELOPER_MODE", "0");
            newProfile.Values.Add("PRJ_FOLDER_DEPOLOYED_PROJECT", deployedFolderTxt.Text);
            newProfile.Values.Add("PRJ_MASTERCONFIG", deployedFolderTxt.Text + masterconfigTxt.Text + ".masterconfig");
            newProfile.Values.Add("PRJ_LAUNCH_BAT", projectFolderTxt.Text + "Launch.bat");
            m_project.Template.AddEntry(newProfile);

            if (useTestProfileOnly == false)
            {
                newProfile             = new TemplateCommonValueCollectionEntry();
                newProfile.Description = "DEV";
                newProfile.Values.Add("PRJ_PROFILE", "DEV");
                newProfile.Values.Add("PRJ_DEVELOPER_MODE", "1");
                newProfile.Values.Add("PRJ_FOLDER_DEPOLOYED_PROJECT", m_devDeployFolder);
                newProfile.Values.Add("PRJ_MASTERCONFIG", m_devDeployFolder + masterconfigTxt.Text + ".masterconfig");
                newProfile.Values.Add("PRJ_LAUNCH_BAT", projectFolderTxt.Text + "Launch.bat");
                m_project.Template.AddEntry(newProfile);
            }

            //-- Create shortcuts.
            TemplateShortcutEntry newShortcut = new TemplateShortcutEntry();

            newShortcut.Description          = "Build (PRJ_PROFILE)";
            newShortcut.Type                 = TemplateEntry.EntryType.Type_Shortcut;
            newShortcut.Filename             = projectFolderTxt.Text + "Build.bat";
            newShortcut.UiGroupName          = "Shortcuts";
            newShortcut.ConfirmBeforeRunning = true;
            newShortcut.EnvironmentVars.Add("DEVELOPERMODE", "PRJ_DEVELOPER_MODE");
            newShortcut.EnvironmentVarStates.Add("DEVELOPERMODE", true);
            m_project.Template.AddEntry(newShortcut);

            newShortcut                      = new TemplateShortcutEntry();
            newShortcut.Description          = "Gather (PRJ_PROFILE)";
            newShortcut.Type                 = TemplateEntry.EntryType.Type_Shortcut;
            newShortcut.Filename             = projectFolderTxt.Text + "Gather.bat";
            newShortcut.UiGroupName          = "Shortcuts";
            newShortcut.ConfirmBeforeRunning = true;
            newShortcut.EnvironmentVars.Add("DEVELOPERMODE", "PRJ_DEVELOPER_MODE");
            newShortcut.EnvironmentVarStates.Add("DEVELOPERMODE", true);
            m_project.Template.AddEntry(newShortcut);

            newShortcut                      = new TemplateShortcutEntry();
            newShortcut.Description          = "Deploy (PRJ_PROFILE)";
            newShortcut.Type                 = TemplateEntry.EntryType.Type_Shortcut;
            newShortcut.Filename             = projectFolderTxt.Text + "Deploy.bat";
            newShortcut.UiGroupName          = "Shortcuts";
            newShortcut.ConfirmBeforeRunning = false;
            newShortcut.EnvironmentVars.Add("DEVELOPERMODE", "PRJ_DEVELOPER_MODE");
            newShortcut.EnvironmentVarStates.Add("DEVELOPERMODE", true);
            m_project.Template.AddEntry(newShortcut);

            newShortcut                      = new TemplateShortcutEntry();
            newShortcut.Description          = "Deploy Binder Art";
            newShortcut.Type                 = TemplateEntry.EntryType.Type_Shortcut;
            newShortcut.Filename             = Program.g_driveLetter + @":\dev\main\Source\Sim400\Bin\SimDeploy_BinderArt.bat";
            newShortcut.UiGroupName          = "Shortcuts";
            newShortcut.ConfirmBeforeRunning = false;
            m_project.Template.AddEntry(newShortcut);

            newShortcut                      = new TemplateShortcutEntry();
            newShortcut.Description          = "Launch (PRJ_PROFILE)";
            newShortcut.Type                 = TemplateEntry.EntryType.Type_Shortcut;
            newShortcut.Filename             = @"ALICE_APP_PATH\res\DevMasterConfigLaunch.bat";
            newShortcut.UiGroupName          = "Shortcuts";
            newShortcut.ConfirmBeforeRunning = false;
            newShortcut.EnvironmentVars.Add("DEVELOPERMODE", "PRJ_DEVELOPER_MODE");
            newShortcut.EnvironmentVarStates.Add("DEVELOPERMODE", true);
            newShortcut.EnvironmentVars.Add("MASTERCONFIGPATH", "PRJ_MASTERCONFIG");
            newShortcut.EnvironmentVarStates.Add("MASTERCONFIGPATH", true);
            newShortcut.EnvironmentVars.Add("LAUNCHPATH", "PRJ_LAUNCH_BAT");
            newShortcut.EnvironmentVarStates.Add("LAUNCHPATH", true);
            m_project.Template.AddEntry(newShortcut);

            //-- Create folder shortcuts.
            newShortcut             = new TemplateShortcutEntry();
            newShortcut.Description = "Project";
            newShortcut.Type        = TemplateEntry.EntryType.Type_Shortcut;
            newShortcut.Filename    = projectFolderTxt.Text;
            newShortcut.UiGroupName = "Folders";
            m_project.Template.AddEntry(newShortcut);

            newShortcut             = new TemplateShortcutEntry();
            newShortcut.Description = "Deployed Project";
            newShortcut.Type        = TemplateEntry.EntryType.Type_Shortcut;
            newShortcut.Filename    = "PRJ_FOLDER_DEPOLOYED_PROJECT";
            newShortcut.UiGroupName = "Folders";
            m_project.Template.AddEntry(newShortcut);

            //-- Save.
            m_project.WriteToFile();

            //-- Copy the files to the project folder.
            try
            {
                // Build .bat file.
                string batFilenameSrc  = Program.g_path + @"\res\GenerateContainerProject\" + typeCbo.Text + @"\Build.bat";
                string batFilenameDest = projectFolderTxt.Text + "Build.bat";

                // File already exists?
                if (File.Exists(batFilenameDest))
                {
                    if (MessageBox.Show("'" + batFilenameDest + "' already exists, replace?",
                                        "Replace existing file?",
                                        MessageBoxButtons.YesNo,
                                        MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        File.SetAttributes(batFilenameDest, File.GetAttributes(batFilenameDest) & ~FileAttributes.ReadOnly);
                        File.Delete(batFilenameDest);
                    }
                }

                // Copy it.
                File.Copy(batFilenameSrc,
                          batFilenameDest,
                          true);

                // Gather .bat file.
                CreateGatherBatchFileFromTemplate(Program.g_path + @"\res\GenerateContainerProject\" + typeCbo.Text + @"\Gather.bat",
                                                  projectFolderTxt.Text + "Gather.bat");

                // Gather .deploy files.
                CreateGatherDeployFileFromTemplate(Program.g_path + @"\res\GenerateContainerProject\" + typeCbo.Text + @"\Gather.deploy",
                                                   projectFolderTxt.Text + "Gather.deploy",
                                                   false);

                if (useTestProfileOnly == false)
                {
                    CreateGatherDeployFileFromTemplate(Program.g_path + @"\res\GenerateContainerProject\" + typeCbo.Text + @"\Gather.deploy",
                                                       projectFolderTxt.Text + "DEV_Gather.deploy",
                                                       true);
                }

                // Deploy .bat file.
                string newDeployFilename = projectFolderTxt.Text + "Deploy.bat";
                bool   copyDeployFile    = true;

                // File already exists?
                if (File.Exists(newDeployFilename))
                {
                    if (MessageBox.Show("'" + newDeployFilename + "' already exists, replace?",
                                        "Replace existing file?",
                                        MessageBoxButtons.YesNo,
                                        MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        File.SetAttributes(newDeployFilename, File.GetAttributes(newDeployFilename) & ~FileAttributes.ReadOnly);
                        File.Delete(newDeployFilename);
                    }
                    else
                    {
                        copyDeployFile = false;
                    }
                }

                if (copyDeployFile)
                {
                    File.Copy(Program.g_path + @"\res\GenerateContainerProject\" + typeCbo.Text + @"\Deploy.bat", newDeployFilename);
                }

                // SimDeploy.xml files.
                CreateSimDeployFileFromTemplate(Program.g_path + @"\res\GenerateContainerProject\" + typeCbo.Text + @"\SimDeploy.xml",
                                                projectFolderTxt.Text + "SimDeploy.xml",
                                                false);

                if (useTestProfileOnly == false)
                {
                    CreateSimDeployFileFromTemplate(Program.g_path + @"\res\GenerateContainerProject\" + typeCbo.Text + @"\SimDeploy.xml",
                                                    projectFolderTxt.Text + "DEV_SimDeploy.xml",
                                                    true);
                }

                // Launch .bat file.
                CreateLaunchBatchFileFromTemplate(Program.g_path + @"\res\GenerateContainerProject\" + typeCbo.Text + @"\Launch.bat",
                                                  projectFolderTxt.Text + "Launch.bat");
            }
            catch (Exception ex)
            {
                ErrorMsg("Error while copying batch files to the project folder:\n\n" + ex.Message);
            }

            //-- Done.
            Hide();
        }