Exemplo n.º 1
0
 private void buttonSave_Click(object sender, EventArgs e)
 {
     ProjectContainer.GetInstance().ConnectionStrings.Clear();
     ProjectContainer.GetInstance().ConnectionStrings = ConvertGridToDictionary();
     ProjectContainer.GetInstance().SaveConnectionStrings();
     Classes.Mediation.FormMediator.GetInstance().SendMessage("Database Settings Updated");
 }
Exemplo n.º 2
0
 public Generation()
 {
     InitializeComponent();
     LoadForm();
     ProjectContainer.GetInstance().Reload += ProjectChanged;
     this._generationResults = new Dictionary <string, string>();
 }
Exemplo n.º 3
0
        private void Create(string projectName)
        {
            List <ProjectTemplate> templateList = new List <ProjectTemplate>();

            foreach (var item in checkedListBoxTemplates.CheckedItems)
            {
                ProjectTemplate projectTemplate = new ProjectTemplate();
                projectTemplate.TemplateName = item.ToString();
                projectTemplate.ScreenParameters["OutputDirectory"] = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Application.ExecutablePath), "projects", textBoxName.Text, "Output");
                projectTemplate.ParametersTree = new System.Xml.Linq.XElement("parameterTree", "");
                System.Xml.Linq.XElement root = new System.Xml.Linq.XElement("root");
                root.SetAttributeValue("name", "root");
                root.Add(new System.Xml.Linq.XElement("children"));
                projectTemplate.ParametersTree.Add(root);
                templateList.Add(projectTemplate);
            }
            Project project = new Project();

            project.Name = projectName;
            project.ProjectTemplateList.Clear();
            project.ProjectTemplateList.AddRange(templateList);
            ProjectContainer.GetInstance().UpdateProject(project);
            ProjectContainer.GetInstance().Save();
            ProjectContainer.GetInstance().Reload(this, EventArgs.Empty);
            Classes.Mediation.FormMediator.GetInstance().SendMessage("Project Created");
        }
Exemplo n.º 4
0
 private void LoadForm()
 {
     dataGridViewParameters.Rows.Clear();
     foreach (string key in ProjectContainer.GetInstance().ConnectionStrings.Keys)
     {
         dataGridViewParameters.Rows.Add(key, ProjectContainer.GetInstance().ConnectionStrings[key]);
     }
 }
Exemplo n.º 5
0
 public void LoadForm()
 {
     comboBoxDataInterface.Items.Clear();
     foreach (string key in  ProjectContainer.GetInstance().ConnectionStrings.Keys)
     {
         comboBoxDataInterface.Items.Add(key);
     }
 }
Exemplo n.º 6
0
        public void LoadStaticClasses()
        {
            TemplateContainer.GetInstance();
            ProjectContainer.GetInstance();

            TemplateContainer.GetInstance().Load();
            ProjectContainer.GetInstance().Load();

            FormMediator.GetInstance().BroadCastMessageEvent += BroadCastMessageEventHandler;
            FormMediator.GetInstance().BroadCastErrorEvent   += BroadCastErrorEventHandler;
        }
Exemplo n.º 7
0
        private void Save()
        {
            string   table            = comboBoxTable.SelectedItem.ToString();
            string   schema           = comboBoxSchemas.SelectedItem.ToString();
            string   connectionString = ProjectContainer.GetInstance().ConnectionStrings[comboBoxDataInterface.SelectedItem.ToString()];
            XElement fields           = Codenesium.GenerationLibrary.Database.MSSQL.GetFieldListFromTable(table, schema, connectionString);

            this._projectTemplate.ParametersTree.Elements("root").Elements("children").FirstOrDefault().RemoveAll();
            this._projectTemplate.ParametersTree.Elements("root").Elements("children").FirstOrDefault().Add(fields);
            this.Close();
        }
Exemplo n.º 8
0
        private void toolStripMenuItemMapToDatabaseField_Click(object sender, EventArgs e)
        {
            XElement nodeXML = (XElement)this._currentlySelectNode.Tag;

            if (nodeXML.Attribute("type") != null && nodeXML.Attribute("type").Value.ToString() == "databaseField")
            {
                ProjectTemplate template = (ProjectTemplate)comboBoxTemplates.SelectedItem;


                if (!template.ScreenParameters.ContainsKey("DataInterfaceKey"))
                {
                    MessageBox.Show("To use database field mapping you must add a 'DataInterfaceKey' parameter to the template and set the value to a key on the Data Interfaces tab", "Error");
                    return;
                }

                if (!template.ScreenParameters.ContainsKey("Table"))
                {
                    MessageBox.Show("To use database field mapping you must add a 'Table' parameter to the template and set a table from the database as the value", "Error");
                    return;
                }

                if (!template.ScreenParameters.ContainsKey("Schema"))
                {
                    MessageBox.Show("To use database field mapping you must add a 'Schema' parameter to the template and set a table from the database as the value", "Error");
                    return;
                }


                string connectionString            = ProjectContainer.GetInstance().ConnectionStrings[template.ScreenParameters["DataInterfaceKey"].ToString()].ToString();
                string schema                      = ProjectContainer.GetInstance().ConnectionStrings[template.ScreenParameters["Schema"].ToString()].ToString();
                Forms.FormMapToDatabase mapperForm = new Forms.FormMapToDatabase(template.ScreenParameters["Table"].ToString(), schema, connectionString);
                mapperForm.ShowDialog();

                XElement mappedDatabaseField = (from f in nodeXML.Element("children").Elements()
                                                where f.Attribute("name") != null && f.Attribute("name").Value == "mappedDatabaseFieldName"
                                                select f).FirstOrDefault();

                mappedDatabaseField.SetAttributeValue("value", mapperForm.ColumnName);

                XElement mappedDatabaseFieldType = (from f in nodeXML.Element("children").Elements()
                                                    where f.Attribute("name") != null && f.Attribute("name").Value == "mappedDatabaseFieldType"
                                                    select f).FirstOrDefault();

                mappedDatabaseFieldType.SetAttributeValue("value", mapperForm.SqlType);

                XElement mappedDatabaseFieldLength = (from f in nodeXML.Element("children").Elements()
                                                      where f.Attribute("name") != null && f.Attribute("name").Value == "mappedDatabaseFieldLength"
                                                      select f).FirstOrDefault();

                mappedDatabaseFieldLength.SetAttributeValue("value", mapperForm.MaxLength);
            }
        }
Exemplo n.º 9
0
 private void buttonGenerate_Click(object sender, EventArgs e)
 {
     this.tabControlOutput.Controls.Clear();
     if (comboBoxProjects.SelectedIndex > -1)
     {
         ProjectContainer.GetInstance().Load();
         TemplateContainer.GetInstance().Load();
         this._selectedProject             = (Project)comboBoxProjects.SelectedItem;
         progressSpinnerGeneration.Visible = true;
         Action action   = new Action(StartGeneration);
         Task   generate = Task.Factory.StartNew(action).ContinueWith(x => GenerationComplete());
     }
 }
Exemplo n.º 10
0
        private void LoadForm()
        {
            int currentSelectedProject = comboBoxProjects.SelectedIndex;

            comboBoxProjects.DataSource    = new BindingList <Project>(ProjectContainer.GetInstance().ProjectList);
            comboBoxProjects.DisplayMember = "Name";
            if (currentSelectedProject == -1 && comboBoxProjects.Items.Count > 0)
            {
                comboBoxProjects.SelectedIndex = 0;
            }
            else
            {
                comboBoxProjects.SelectedIndex = currentSelectedProject;
            }
        }
Exemplo n.º 11
0
 private void LoadTables()
 {
     if (comboBoxDataInterface.SelectedIndex > -1)
     {
         comboBoxTable.Items.Clear();
         string schema           = comboBoxSchemas.SelectedItem.ToString();
         string connectionString = ProjectContainer.GetInstance().ConnectionStrings[comboBoxDataInterface.SelectedItem.ToString()];
         MSSQL  mssqlInterface   = new MSSQL(connectionString);
         mssqlInterface.TestConnection();
         if (mssqlInterface.ConnectionTestResult)
         {
             comboBoxTable.Items.AddRange(MSSQL.GetTableListAsStrings(connectionString, schema).ToArray());
         }
         else
         {
             MessageBox.Show("Unable to connect to SQL Server", "Error");
         }
     }
 }
Exemplo n.º 12
0
        private void comboBoxProjects_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (comboBoxProjects.SelectedIndex > -1)
            {
                UncheckAll();

                textBoxName.Text = comboBoxProjects.SelectedItem.ToString();

                Project project = ProjectContainer.GetInstance().ProjectList.FirstOrDefault(x => x.Name == comboBoxProjects.SelectedItem.ToString());

                foreach (ProjectTemplate template in project.ProjectTemplateList.ToList())
                {
                    int index = checkedListBoxTemplates.FindStringExact(template.TemplateName);
                    if (index > -1)
                    {
                        checkedListBoxTemplates.SetItemChecked(index, true);
                    }
                }
            }
        }
Exemplo n.º 13
0
        private void Save()
        {
            treeViewParameters.SelectedNode = null;
            ClearTextFields();
            Dictionary <string, object> parameters = ConvertGridToDictionary();
            ProjectTemplate             template   = (ProjectTemplate)comboBoxTemplates.SelectedItem;
            Project project = (Project)comboBoxProjects.SelectedItem;

            template.ScreenParameters = parameters;
            template.ParametersTree   = SaveTree();

            int index = project.ProjectTemplateList.FindIndex(x => x.TemplateName == template.TemplateName);

            project.ProjectTemplateList[index] = template;


            ProjectContainer.GetInstance().Save();
            ProjectContainer.GetInstance().Load();
            LoadForm();
            Classes.Mediation.FormMediator.GetInstance().SendMessage("Project Template Saved");
        }
Exemplo n.º 14
0
        private void LoadForm()
        {
            checkedListBoxTemplates.Items.Clear();//checkedlistbox doesn't support databinding
            foreach (Template template in TemplateContainer.GetInstance().TemplateList)
            {
                checkedListBoxTemplates.Items.Add(template.Name);
            }

            int currentSelectedProject = comboBoxProjects.SelectedIndex;

            comboBoxProjects.DataSource = new BindingList <string>(ProjectContainer.GetInstance().ProjectList.Select(x => x.Name).ToList());

            if (currentSelectedProject == -1 && comboBoxProjects.Items.Count > 0)
            {
                comboBoxProjects.SelectedIndex = 0;
            }
            else
            {
                comboBoxProjects.SelectedIndex = currentSelectedProject;
            }
        }
Exemplo n.º 15
0
 private void LoadSchemas()
 {
     if (comboBoxDataInterface.SelectedIndex > -1)
     {
         comboBoxSchemas.Items.Clear();
         string connectionString = ProjectContainer.GetInstance().ConnectionStrings[comboBoxDataInterface.SelectedItem.ToString()];
         MSSQL  mssqlInterface   = new MSSQL(connectionString);
         mssqlInterface.TestConnection();
         if (mssqlInterface.ConnectionTestResult)
         {
             List <string> schemaList = MSSQL.GetSchemaList(connectionString);
             foreach (string item in schemaList)
             {
                 comboBoxSchemas.Items.Add(item);
             }
         }
         else
         {
             MessageBox.Show("Unable to connect to SQL Server", "Error");
         }
     }
 }
Exemplo n.º 16
0
        private void StartGeneration()
        {
            Classes.Mediation.FormMediator.GetInstance().SendMessage("Starting Generation");
            try
            {
                this._generationResults.Clear();
                Project project = ProjectContainer.GetInstance().ProjectList.ToList().Where(x => x == this._selectedProject).FirstOrDefault();
                Classes.Generation.GenerationParameterManager parameterManager = new GenerationParameterManager();
                parameterManager.TransformParameters(project);
                string workingDirectory = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "WorkingDirectory");
                Classes.Generation.GenerationManager generationManager = new GenerationManager();

                foreach (ProjectTemplate projectTemplate in project.ProjectTemplateList)
                {
                    Template template = TemplateContainer.GetInstance().TemplateList.Where(x => x.Name == projectTemplate.TemplateName).FirstOrDefault();
                    List <TemplateExecutionResult> results = generationManager.ExecuteForEachTemplate(workingDirectory, template, projectTemplate.TransformedParameters, projectTemplate.ParametersTree);

                    string resultDisplay = String.Empty;
                    foreach (TemplateExecutionResult result in results)
                    {
                        resultDisplay += result.TransformedText;
                        resultDisplay += result.ErrorMessage + Environment.NewLine;
                    }
                    this._generationResults[template.Name] = resultDisplay;
                    FormMediator.GetInstance().AddGenerationScreenMessage(resultDisplay);
                }

                Classes.Mediation.FormMediator.GetInstance().SendMessage("Generation Complete");
            }
            catch (Exception ex)
            {
                Classes.Mediation.FormMediator.GetInstance().SendMessage("Exception in Generation");
                FormMediator.GetInstance().AddGenerationScreenMessage(ex.ToString());
            }

            Classes.Mediation.FormMediator.GetInstance().GenerationComplete();
        }
Exemplo n.º 17
0
        private void Save()
        {
            if (comboBoxProjects.SelectedIndex > -1)
            {
                Project project = ProjectContainer.GetInstance().ProjectList.FirstOrDefault(x => x.Name == comboBoxProjects.SelectedItem.ToString());

                List <string> checkedItems = new List <string>();
                foreach (var item in checkedListBoxTemplates.CheckedItems)
                {
                    checkedItems.Add(item.ToString());
                }

                project.ProjectTemplateList.RemoveAll(x => !checkedItems.Contains(x.TemplateName)); //if we unchecked a template remove it
                project.Name = textBoxName.Text;

                foreach (string templateName in checkedItems)
                {
                    if (!project.ProjectTemplateList.Any(x => x.TemplateName == templateName)) //iterate the list of checked items. If we're missing a template add it.
                    {
                        ProjectTemplate projectTemplate = new ProjectTemplate();
                        projectTemplate.ScreenParameters["OutputDirectory"] = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Application.ExecutablePath), "projects", textBoxName.Text, "Output");
                        projectTemplate.ParametersTree = new System.Xml.Linq.XElement("parameterTree", "");
                        System.Xml.Linq.XElement root = new System.Xml.Linq.XElement("root");
                        root.SetAttributeValue("name", "root");
                        root.Add(new System.Xml.Linq.XElement("children"));
                        projectTemplate.ParametersTree.Add(root);
                        projectTemplate.TemplateName = templateName;
                        project.ProjectTemplateList.Add(projectTemplate);
                    }
                }

                ProjectContainer.GetInstance().UpdateProject(project);
                ProjectContainer.GetInstance().Save();
                ProjectContainer.GetInstance().Reload(this, EventArgs.Empty);
                Classes.Mediation.FormMediator.GetInstance().SendMessage("Project Updated");
            }
        }
Exemplo n.º 18
0
        private void LoadForm()
        {
            ClearFields();
            int currentSelectedProject  = comboBoxProjects.SelectedIndex;
            int currentSelectedTemplate = comboBoxTemplates.SelectedIndex;

            comboBoxProjects.DataSource    = new BindingList <Project>(ProjectContainer.GetInstance().ProjectList);
            comboBoxProjects.DisplayMember = "Name";
            comboBoxProjects.ValueMember   = "ID";

            if (currentSelectedProject == -1 && comboBoxProjects.Items.Count > 0)
            {
                comboBoxProjects.SelectedIndex = 0;
            }
            else
            {
                comboBoxProjects.SelectedIndex = currentSelectedProject;
            }

            if (currentSelectedTemplate == -1 && comboBoxTemplates.Items.Count > 0)
            {
                comboBoxTemplates.SelectedIndex = 0;
            }
            else
            {
                comboBoxTemplates.SelectedIndex = currentSelectedTemplate;
            }
            treeViewParameters.BeginUpdate();
            PopulateParameterTree();
            if (this._currentlySelectNode != null)
            {
                treeViewParameters.ExpandAll();
                treeViewParameters.SelectedNode = this._currentlySelectNode;
            }
            treeViewParameters.EndUpdate();
        }
Exemplo n.º 19
0
 private void buttonRefresh_Click(object sender, EventArgs e)
 {
     ProjectContainer.GetInstance().Load();
     TemplateContainer.GetInstance().Load();
 }
Exemplo n.º 20
0
 public Templates()
 {
     InitializeComponent();
     LoadForm();
     ProjectContainer.GetInstance().Reload += ProjectChanged;
 }