public static void Show(Form owner, string title, string information, string fileListTitle, IList <string> files)
 {
     using (ShowGenerationResult form = new ShowGenerationResult())
     {
         form.Owner    = owner;
         form.Text     = title;
         form.FileList = files;
         form.tbGenerationInformation.Text = information;
         form.gbGenerationInformation.Text = fileListTitle;
         form.ShowDialog();
     }
 }
Esempio n. 2
0
        private void ThreadWork(object state)
        {
            try
            {
                generateStartTime = DateTime.Now;

                var selectedModules = (from id in (List <string>) state
                                       select modelService.GetDomainObject <Domain.Module>(Guid.Parse(id))).ToList();

                string referencePath           = referencePathTbx.Text;
                string solutionFileNameAndPath = Path.Combine(solutionPathTbx.Text, solutionNameTbx.Text + ".sln");

                modelService.GenerateFrontendFromGUI(selectedModules.ToList <Domain.Module>(), FrontendApplication, solutionFileNameAndPath, referencePath);

                UpdateStatusAndTime("Done!", 0, 0, 0);

                string info = string.Format("Code generation complete.\r\n{0} files generated, {1} files written to disk", FileCacheManager.GetWrites(), FileCacheManager.GetWritesToDisk());

                if (this.InvokeRequired)
                {
                    this.Invoke(new System.Action(() =>
                    {
                        ShowGenerationResult.Show(this, "Generation Result", info, "Files written to disk", FileCacheManager.GetWrittenFilesToDisk());
                    })
                                );
                }
                else
                {
                    ShowGenerationResult.Show(this, "Generation Result", info, "Files written to disk", FileCacheManager.GetWrittenFilesToDisk());
                }
            }
            finally
            {
                if (this.InvokeRequired)
                {
                    this.Invoke(new System.Action(() =>
                    {
                        Cursor.Current    = Cursors.Default;
                        pProgress.Visible = false;
                        EnableDisableButtons();
                    })
                                );
                }
                else
                {
                    Cursor.Current    = Cursors.Default;
                    pProgress.Visible = false;
                    EnableDisableButtons();
                }
            }
        }
Esempio n. 3
0
        private void ThreadWork(object state)
        {
            try
            {
                try
                {
                    using (new SessionScope(MetaManagerServices.GetSessionFactory(), MetaManagerServices.GetDomainInterceptor(), true, FlushMode.Never, true))
                    {
                        ((DataAccess.DomainInterceptor)MetaManagerServices.GetDomainInterceptor()).GetDataFromConfigurationManagement = true;

                        generateStartTime = DateTime.Now;

                        var selectedServices = (from id in (List <string>) state
                                                select modelService.GetDomainObject <Service>(Guid.Parse(id))).ToList();

                        // Get which business entities we need to generate depending on the selected services.
                        Dictionary <Guid, BusinessEntity> entityDictionary = new Dictionary <Guid, BusinessEntity>();

                        //Dictionary<Guid, IDomainObject> loadedObjects = new Dictionary<Guid, IDomainObject>();
                        List <Service> loadedServices = new List <Service>();

                        foreach (Service service in selectedServices)
                        {
                            //Service loadedService = (Service)loadedObjects[service.Id];
                            Service loadedService = modelService.GetDomainObject <Service>(service.Id);

                            loadedServices.Add(loadedService);

                            foreach (ServiceMethod method in loadedService.ServiceMethods)
                            {
                                if (method != null)
                                {
                                    if (!entityDictionary.ContainsKey(method.MappedToAction.BusinessEntity.Id))
                                    {
                                        entityDictionary.Add(method.MappedToAction.BusinessEntity.Id, method.MappedToAction.BusinessEntity);
                                    }
                                }
                            }
                        }

                        ApplicationTemplate template = new ApplicationTemplate();
                        template.entities           = entityDictionary.Values.ToList <BusinessEntity>();
                        template.services           = loadedServices;
                        template.solutionFileName   = Path.Combine(solutionPathTbx.Text, solutionNameTbx.Text + ".sln");
                        template.referenceDirectory = referencePathTbx.Text;
                        template.templateCallback   = CodeSmithTemplateCallback;

                        template.Render(TextWriter.Null);

                        UpdateStatusAndTime("Done!", 0, 0, 0);
                    }

                    string info = string.Format("Code generation complete.\r\n{0} files generated, {1} files written to disk", FileCacheManager.GetWrites(), FileCacheManager.GetWritesToDisk());


                    if (this.InvokeRequired)
                    {
                        this.Invoke(new System.Action(() =>
                        {
                            ShowGenerationResult.Show(this, "Generation Result", info, "Files written to disk", FileCacheManager.GetWrittenFilesToDisk());
                        })
                                    );
                    }
                    else
                    {
                        ShowGenerationResult.Show(this, "Generation Result", info, "Files written to disk", FileCacheManager.GetWrittenFilesToDisk());
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString(), "Error in Codegeneration", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            finally
            {
                ((DataAccess.DomainInterceptor)MetaManagerServices.GetDomainInterceptor()).GetDataFromConfigurationManagement = false;

                if (this.InvokeRequired)
                {
                    this.Invoke(new System.Action(() =>
                    {
                        Cursor.Current    = Cursors.Default;
                        pProgress.Visible = false;
                        EnableDisableButtons();
                    })
                                );
                }
                else
                {
                    Cursor.Current    = Cursors.Default;
                    pProgress.Visible = false;
                    EnableDisableButtons();
                }
            }
        }
        private void okBtn_Click(object sender, EventArgs e)
        {
            try
            {
                if (!CheckPaths())
                {
                    return;
                }

                okBtn.Enabled             = false;
                cancelBtn.Enabled         = false;
                btnStopGeneration.Enabled = true;
                doBreak = false;

                Cursor.Current = Cursors.WaitCursor;

                // Save to config file
                Config.Backend.XMLSchemaFolder    = tbXMLSchemaFolder.Text;
                Config.Backend.PLSQLPackageFolder = tbPLSQLPackageFolder.Text;
                Config.Save();

                try
                {
                    // Reset progressbar and make the panel visible
                    progressBar.Value   = 0;
                    pProgress.Visible   = true;
                    lblTimeElapsed.Text = string.Empty;

                    lblProgressText.Text = "Extracting Data from Database...";
                    System.Windows.Forms.Application.DoEvents();

                    using (new SessionScope(MetaManagerServices.GetSessionFactory(), MetaManagerServices.GetDomainInterceptor(), true, FlushMode.Never, true))
                    {
                        IList <Report> reports = new List <Report>();

                        List <IDomainObject> selectedReports = modelService.GetAllDomainObjectsByApplicationId <Report>(BackendApplication.Id).OrderBy(r => (r.Name)).ToList <IDomainObject>();

                        foreach (Report report in selectedReports)
                        {
                            Report readReport = modelService.GetDomainObject <Report>(report.Id);
                            reports.Add(readReport);
                        }

                        ReportTemplate template = new ReportTemplate();

                        // Create the plsql body and spec directories if they don't exist
                        string plsqlBodyDirectory = Path.Combine(tbPLSQLPackageFolder.Text.Trim(), "body");
                        string plsqlSpecDirectory = Path.Combine(tbPLSQLPackageFolder.Text.Trim(), "spec");

                        if (!Directory.Exists(plsqlBodyDirectory))
                        {
                            Directory.CreateDirectory(plsqlBodyDirectory);
                        }

                        if (!Directory.Exists(plsqlSpecDirectory))
                        {
                            Directory.CreateDirectory(plsqlSpecDirectory);
                        }

                        template.reports                  = reports;
                        template.xsdDirectory             = tbXMLSchemaFolder.Text.Trim();
                        template.plsqlBodyDirectory       = plsqlBodyDirectory;
                        template.plsqlSpecDirectory       = plsqlSpecDirectory;
                        template.printDocumentPackageName = "PrintDocument"; // Name of package for printing document
                        template.templateCallback         = CodeSmithTemplateCallback;

                        generateStartTime = DateTime.Now;

                        template.Render(TextWriter.Null);

                        UpdateTime();
                    }

                    if (FileCacheManager.GetFilesNotSaved().Count > 0)
                    {
                        string notSavedFiles = FileCacheManager.GetFilesNotSaved().Aggregate((current, next) => current + Environment.NewLine + '\t' + next);

                        string txt = "There were one or more files that couldn't be saved.\r\n" +
                                     "Probable cause is that the file is located in a dynamic Clearcase view and is not checked out.\r\n" +
                                     "Check out the file(s) and generate again.";

                        ShowGenerationResult.Show(this, "Generation Result: Not saved files", txt, "Files not saved", FileCacheManager.GetFilesNotSaved());
                    }

                    string text = string.Format("Code generation complete.\r\n{0} files generated, {1} files written to disk.",
                                                FileCacheManager.GetWrites(),
                                                FileCacheManager.GetWritesToDisk());

                    ShowGenerationResult.Show(this, "Generation Result", text, "Files written to disk", FileCacheManager.GetWrittenFilesToDisk());
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString(), "Error in Codegeneration", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            finally
            {
                Cursor.Current    = Cursors.Default;
                pProgress.Visible = false;
                EnableDisableButtons();
            }
        }