コード例 #1
0
 /// <summary>
 /// Sets the generate button text.
 /// </summary>
 /// <param name="node">The node.</param>
 private void SetGenerateButtonText(StageNode node)
 {
     switch(node.NodeType)
     {
         case StageNodeType.StoredProcedure: //Nothing for now - where not going to get to here - TODO: make this work
         case StageNodeType.StoredProcedureExcluded: //where not going to get to here (never shows up)
             break;
         case StageNodeType.Table:
         case StageNodeType.TableWithoutPrimaryKey:
             cmiGenerateObjectEnabled.Text = "Disable Generate Table";
             break;
         case StageNodeType.TableExcluded:
             cmiGenerateObjectEnabled.Text = "Enable Generate Table";
             break;
         case StageNodeType.View:
             cmiGenerateObjectEnabled.Text = "Disable Generate View";
             break;
         case StageNodeType.ViewExcluded:
             cmiGenerateObjectEnabled.Text = "Enable Generate View";
             break;
         default:
             cmiGenerateObjectEnabled.Text = "Generate Object?";
             break;
     }
 }
コード例 #2
0
 private void PopulateProviderData(StageNode node)
 {
     MasterStore.ProjectsRow projectRow = node.Project;
     InstantiateProvider(projectRow);
     treeView1.BeginUpdate();
     if(node.IsProjectNode)
     {
         foreach(MasterStore.ProvidersRow provider in projectRow.Providers())
             PopulateProviderNodeData(provider);
     }
     else if(node.IsProviderNode)
     {
         MasterStore.ProvidersRow provider = node.Provider;
         if(provider != null)
             PopulateProviderNodeData(provider);
     }
     treeView1.EndUpdate();
 }
コード例 #3
0
        private void SelectNode(StageNode node)
        {
            //ShowStatus("Ready.");
            if(node.IsProjectNode)
            {
                LoadProjectProperties(node);
                BuildConfig(node.Project);
                string path = GetNodeGenerationPath(node);
                BuildDirectoryTree(path);
                NavigateFileBrowser(path);
            }
            else if(node.IsProviderNode)
            {
                LoadProviderProperties(node);
                BuildConfig(node.Project);
                string path = GetNodeGenerationPath(node);
                BuildDirectoryTree(path);
                NavigateFileBrowser(path);
            }
            else if(node.IsConnectionStringNode)
                LoadConnectionStringProperties(node);
            else if(node.IsTableNode || node.IsViewNode)
                LoadTableProperties(node);
            else if(node.IsColumnNode)
                LoadColumnProperties(node);
            else if(node.NodeType == StageNodeType.StoredProcedure)
                LoadStoredProcedureProperties(node);
            else if(node.NodeType == StageNodeType.StoredProcedureParameter)
                LoadStoredProcedureParameterProperties(node);
            else if(node.NodeType == StageNodeType.SubStageConfiguration)
                LoadConfigurationProperties(node);

            ToggleToolbarItems(node);
            TogglePropertyGridButtons(node);

            LoadScaffold(node);
        }
コード例 #4
0
 private static StageNode MakeNode(string text, StageNodeType nodeType, int nodeId, DataRow row)
 {
     StageNode node = new StageNode(text, row);
     node.NodeType = nodeType;
     node.ImageKey = GetImageKey(nodeType);
     node.SelectedImageKey = GetImageKey(nodeType);
     node.RowId = nodeId;
     node.DatabaseName = text;
     node.SubSonicName = text;
     return node;
 }
コード例 #5
0
 private void GenerateCode(StageNode node)
 {
     MasterStore.ProjectsRow projectRow = node.Project;
     InstantiateProvider(projectRow);
     tabDetail.SelectedTab = tabDetailLog;
     tabDetailLog.Focus();
     string navigateTo = GenerateProviderCode(node);
     tabDetail.SelectedTab = tabDetailFileBrowser;
     tabDetailFileBrowser.Focus();
     BuildDirectoryTree(navigateTo);
     NavigateFileBrowser();
 }
コード例 #6
0
 private void TogglePropertyGridButtons(StageNode node)
 {
     pgbTestConnection.Visible = node.NodeType == StageNodeType.Provider;
 }
コード例 #7
0
 private static StageNode GetCurrentProviderNode(StageNode selectedNode, ProviderBase provider)
 {
     if(selectedNode.IsProjectNode && selectedNode.Nodes.Count > 0)
     {
         foreach(StageNode childNode in selectedNode.Nodes)
         {
             if(childNode.Provider != null)
             {
                 if(Utility.IsMatch(childNode.Provider.Name, provider.Name))
                     return childNode;
             }
         }
     }
     return selectedNode;
 }
コード例 #8
0
        private void LoadProjectProperties(StageNode node)
        {
            if(node.Project != null)
            {
                pGrid.Tag = node;
                pGrid.ShowCustomProperties = true;
                pGrid.Items.Clear();
                const string category = "Project Properties";
                pGrid.Items.Add(CreateCustomProperty(node.Project, MM.Projects.NameColumn, false, true, category));
                pGrid.Items.Add(CreateCustomProperty(node.Project, MM.Projects.OriginalLocationColumn, true, true, category));

                pGrid.Items.Add(CreateCustomProperty(node.Project, MM.Projects.EnableTraceColumn, false, true, category));

                if(node.Project.Providers().Length > 0)
                {
                    if(node.Project.IsDefaultProviderNull())
                    {
                        node.Project.DefaultProvider = node.Project.Providers()[0].ProviderId;
                        MM.Save();
                    }
                    string displayValue = node.Project.DefaultProviderEntry.Name;
                    pGrid.Items.Add(MM.Projects.DefaultProviderColumn.ColumnName, displayValue, false, category, MM.Projects.DefaultProviderColumn.Caption,
                        true);
                    int currentIndex = pGrid.Items.Count - 1;
                    pGrid.Items[currentIndex].Tag = MM.Projects.DefaultProviderColumn.ColumnName + "|" + node.Project.ProjectId;
                    pGrid.Items[currentIndex].ValueMember = MM.Providers.ProviderIdColumn.ColumnName;
                    pGrid.Items[currentIndex].DisplayMember = MM.Providers.NameColumn.ColumnName;
                    pGrid.Items[currentIndex].Datasource = node.Project.Providers();
                    pGrid.Items[currentIndex].SelectedValue = node.Project.DefaultProvider;
                }
                else
                {
                    pGrid.Items.Add(MM.Projects.DefaultProviderColumn.ColumnName, "No Providers Available", true, category,
                        MM.Projects.DefaultProviderColumn.Caption, true);
                }

                CustomProperty cpCodeGenerationPath = CreateCustomProperty(node.Project, MM.Projects.CodeGenerationPathColumn, false, true, CODE_GENERATION);
                cpCodeGenerationPath.CustomEditor = new FolderNameEditor();
                pGrid.Items.Add(cpCodeGenerationPath);

                pGrid.Items.Add(CreateCustomProperty(node.Project, MM.Projects.OrganizeCodeByProviderColumn, false, true, CODE_GENERATION));

                CustomProperty cpTemplateDirectory = CreateCustomProperty(node.Project, MM.Projects.TemplateDirectoryColumn, false, true, CODE_GENERATION);
                cpTemplateDirectory.CustomEditor = new FolderNameEditor();
                pGrid.Items.Add(cpTemplateDirectory);

                pGrid.Refresh();
            }
        }
コード例 #9
0
        private void LoadProviderProperties(StageNode node)
        {
            if(node.Provider != null)
            {
                pGrid.Tag = node;
                pGrid.ShowCustomProperties = true;
                pGrid.Items.Clear();
                const string category = "General";
                pGrid.Items.Add(CreateCustomProperty(node.Provider, MM.Providers.NameColumn, false, true, category));
                pGrid.Items.Add(CreateCustomProperty(node.Provider, MM.Providers.GeneratedNamespaceColumn, false, true, category));

                if(MM.ConnectionStrings.Count > 0)
                {
                    if(node.Provider.IsConnectionStringIdNull())
                    {
                        node.Provider.ConnectionStringId = MM.ConnectionStrings[0].ConnectionStringId;
                        MM.Save();
                    }
                    string displayValue = node.Provider.ConnectionString.Name;
                    pGrid.Items.Add(MM.Providers.ConnectionStringIdColumn.ColumnName, displayValue, false, category, "Connection String", true);
                    int currentIndex = pGrid.Items.Count - 1;
                    pGrid.Items[currentIndex].Tag = MM.Providers.ConnectionStringIdColumn.ColumnName + "|" + node.Provider.ProviderId;
                    pGrid.Items[currentIndex].ValueMember = MM.ConnectionStrings.ConnectionStringIdColumn.ColumnName;
                    pGrid.Items[currentIndex].DisplayMember = MM.ConnectionStrings.NameColumn.ColumnName;
                    pGrid.Items[currentIndex].Datasource = MM.ConnectionStrings;
                    pGrid.Items[currentIndex].SelectedValue = node.Provider.ConnectionStringId;
                }
                else
                {
                    pGrid.Items.Add(MM.Providers.ConnectionStringIdColumn.ColumnName, "No Connection Strings Available", true, category,
                        MM.Providers.ConnectionStringIdColumn.Caption, true);
                }

                if(MM.ProviderTypes.Count > 0)
                {
                    if(node.Provider.IsProviderTypeIdNull())
                    {
                        node.Provider.ProviderTypeId = MM.ProviderTypes[0].ProviderTypeId;
                        MM.Save();
                    }
                    string displayValue = node.Provider.ProviderType.DisplayName;
                    pGrid.Items.Add(MM.Providers.ProviderTypeIdColumn.ColumnName, displayValue, false, category, MM.Providers.ProviderTypeIdColumn.Caption, true);
                    int currentIndex = pGrid.Items.Count - 1;
                    pGrid.Items[currentIndex].Tag = MM.Providers.ProviderTypeIdColumn.ColumnName + "|" + node.Provider.ProviderId;
                    pGrid.Items[currentIndex].ValueMember = MM.ProviderTypes.ProviderTypeIdColumn.ColumnName;
                    pGrid.Items[currentIndex].DisplayMember = MM.ProviderTypes.DisplayNameColumn.ColumnName;
                    pGrid.Items[currentIndex].Datasource = MM.ProviderTypes;
                    pGrid.Items[currentIndex].SelectedValue = node.Provider.ProviderType;
                }

                CustomProperty cpCodeGenerationPath = CreateCustomProperty(node.Provider, MM.Providers.CodeGenerationPathColumn, false, true, CODE_GENERATION);
                cpCodeGenerationPath.CustomEditor = new FolderNameEditor();
                pGrid.Items.Add(cpCodeGenerationPath);
                pGrid.Items.Add(CreateCustomProperty(node.Provider, MM.Providers.OrganizeCodeByProviderColumn, false, true, CODE_GENERATION));

                pGrid.Items.Add(CreateCustomProperty(node.Provider, MM.Providers.RemoveUnderscoresColumn, false, true, GLOBAL));
                pGrid.Items.Add(CreateCustomProperty(node.Provider, MM.Providers.AppendWithColumn, false, true, GLOBAL));
                pGrid.Items.Add(CreateCustomProperty(node.Provider, MM.Providers.AdditionalNamespacesColumn, false, true, GLOBAL));
                pGrid.Items.Add(CreateCustomProperty(node.Provider, MM.Providers.FixDatabaseObjectCasingColumn, false, true, GLOBAL));
                pGrid.Items.Add(CreateCustomProperty(node.Provider, MM.Providers.FixPluralClassNamesColumn, false, true, GLOBAL));
                pGrid.Items.Add(CreateCustomProperty(node.Provider, MM.Providers.GenerateNullablePropertiesColumn, false, true, GLOBAL));
                pGrid.Items.Add(CreateCustomProperty(node.Provider, MM.Providers.GenerateODSControllersColumn, false, true, GLOBAL));
                pGrid.Items.Add(CreateCustomProperty(node.Provider, MM.Providers.SetPropertyDefaultsFromDatabaseColumn, false, true, GLOBAL));
                pGrid.Items.Add(CreateCustomProperty(node.Provider, MM.Providers.UseExtendedPropertiesColumn, false, true, GLOBAL));
                pGrid.Items.Add(CreateCustomProperty(node.Provider, MM.Providers.UseUTCColumn, false, true, GLOBAL));

                pGrid.Items.Add(CreateCustomProperty(node.Provider, MM.Providers.RelatedTableLoadPrefixColumn, false, true, TABLES));
                pGrid.Items.Add(CreateCustomProperty(node.Provider, MM.Providers.GenerateRelatedTablesAsPropertiesColumn, false, true, TABLES));
                pGrid.Items.Add(CreateCustomProperty(node.Provider, MM.Providers.GenerateLazyLoadsColumn, false, true, TABLES));
                pGrid.Items.Add(CreateCustomProperty(node.Provider, MM.Providers.ManyToManySuffixColumn, false, true, TABLES));
                pGrid.Items.Add(CreateCustomProperty(node.Provider, MM.Providers.StripTableTextColumn, false, true, TABLES));
                pGrid.Items.Add(CreateCustomProperty(node.Provider, MM.Providers.StripColumnTextColumn, false, true, TABLES));
                pGrid.Items.Add(CreateCustomProperty(node.Provider, MM.Providers.IncludeTableListColumn, false, true, TABLES));
                pGrid.Items.Add(CreateCustomProperty(node.Provider, MM.Providers.ExcludeTableListColumn, false, true, TABLES));
                pGrid.Items.Add(CreateCustomProperty(node.Provider, MM.Providers.TableBaseClassColumn, false, true, TABLES));

                pGrid.Items.Add(CreateCustomProperty(node.Provider, MM.Providers.ViewBaseClassColumn, false, true, VIEWS));
                pGrid.Items.Add(CreateCustomProperty(node.Provider, MM.Providers.ViewStartsWithColumn, false, true, VIEWS));
                pGrid.Items.Add(CreateCustomProperty(node.Provider, MM.Providers.StripViewTextColumn, false, true, VIEWS));

                pGrid.Items.Add(CreateCustomProperty(node.Provider, MM.Providers.UseSPsColumn, false, true, STORED_PROCEDURES));
                pGrid.Items.Add(CreateCustomProperty(node.Provider, MM.Providers.SPClassNameColumn, false, true, STORED_PROCEDURES));
                pGrid.Items.Add(CreateCustomProperty(node.Provider, MM.Providers.SPStartsWithColumn, false, true, STORED_PROCEDURES));
                pGrid.Items.Add(CreateCustomProperty(node.Provider, MM.Providers.ExtractClassNameFromSPNameColumn, false, true, STORED_PROCEDURES));
                pGrid.Items.Add(CreateCustomProperty(node.Provider, MM.Providers.StripSPTextColumn, false, true, STORED_PROCEDURES));
                pGrid.Items.Add(CreateCustomProperty(node.Provider, MM.Providers.StripParamTextColumn, false, true, STORED_PROCEDURES));
                pGrid.Items.Add(CreateCustomProperty(node.Provider, MM.Providers.IncludeProcedureListColumn, false, true, STORED_PROCEDURES));
                pGrid.Items.Add(CreateCustomProperty(node.Provider, MM.Providers.ExcludeProcedureListColumn, false, true, STORED_PROCEDURES));
                pGrid.Items.Add(CreateCustomProperty(node.Provider, MM.Providers.StoredProcedureBaseClassColumn, false, true, STORED_PROCEDURES));

                pGrid.Items.Add(CreateCustomProperty(node.Provider, MM.Providers.RegexIgnoreCaseColumn, false, true, REGULAR_EXPRESSIONS));
                pGrid.Items.Add(CreateCustomProperty(node.Provider, MM.Providers.RegexDictionaryReplaceColumn, false, true, REGULAR_EXPRESSIONS));
                pGrid.Items.Add(CreateCustomProperty(node.Provider, MM.Providers.RegexMatchExpressionColumn, false, true, REGULAR_EXPRESSIONS));
                pGrid.Items.Add(CreateCustomProperty(node.Provider, MM.Providers.RegexReplaceExpressionColumn, false, true, REGULAR_EXPRESSIONS));

                pGrid.Refresh();
            }
        }
コード例 #10
0
        private void LoadConfigurationProperties(StageNode node)
        {
            pGrid.Tag = node;
            pGrid.ShowCustomProperties = true;
            pGrid.Items.Clear();

            pGrid.Items.Add(CreateCustomProperty(config, MM.SubStageConfiguration.CodeGenerationLanguageColumn, false, true, CODE_GENERATION));

            CustomProperty cpCodeGenerationPath = CreateCustomProperty(config, MM.SubStageConfiguration.CodeGenerationPathColumn, false, true, CODE_GENERATION);
            cpCodeGenerationPath.CustomEditor = new FolderNameEditor();
            pGrid.Items.Add(cpCodeGenerationPath);

            pGrid.Items.Add(CreateCustomProperty(config, MM.SubStageConfiguration.OrganizeCodeByProviderColumn, false, true, CODE_GENERATION));

            const string category = "Embedded Web Server";

            CustomProperty cpWebServerRootPath = CreateCustomProperty(config, MM.SubStageConfiguration.WebServerRootPathColumn, false, true, category);
            cpWebServerRootPath.CustomEditor = new FolderNameEditor();
            pGrid.Items.Add(cpWebServerRootPath);

            pGrid.Items.Add(CreateCustomProperty(config, MM.SubStageConfiguration.WebServerPortColumn, false, true, category));
            pGrid.Refresh();
        }
コード例 #11
0
        private void LoadConnectionStringProperties(StageNode node)
        {
            if(node.ConnectionString != null)
            {
                pGrid.Tag = node;
                pGrid.ShowCustomProperties = true;
                pGrid.Items.Clear();
                const string category = "Connection String Properties";
                pGrid.Items.Add(CreateCustomProperty(node.ConnectionString, MM.ConnectionStrings.NameColumn, false, true, category));
                pGrid.Items.Add(CreateCustomProperty(node.ConnectionString, MM.ConnectionStrings.ConnectionStringColumn, false, true, category));

                pGrid.Refresh();
            }
        }
コード例 #12
0
        private void LoadColumnProperties(StageNode node)
        {
            if(node.Provider != null)
            {
                TableType tableType = node.IsTableNode ? TableType.Table : TableType.View;
                InstantiateProvider(node.Provider);

                TableSchema.Table table = DataService.GetInstance(node.Provider.Name).GetTableSchema(((StageNode)node.Parent).ItemKey, tableType);
                if(table != null)
                {
                    TableSchema.TableColumn column = table.GetColumn(node.ItemKey);
                    if(column != null)
                    {
                        pGrid.Tag = node;
                        pGrid.ShowCustomProperties = true;
                        pGrid.Items.Clear();

                        pGrid.Items.Add(CreateCustomProperty("Property Name", column.PropertyName, "The name of the generated property."));
                        pGrid.Items.Add(CreateCustomProperty("Display Name", column.DisplayName, "The formatted display name."));
                        pGrid.Items.Add(CreateCustomProperty("Database Name", column.ColumnName, "The name of the underlying database object."));
                        pGrid.Items.Add(CreateCustomProperty("Data Type", column.DataType.ToString(), "The data type of the property."));
                        pGrid.Items.Add(CreateCustomProperty("System Type", column.GetPropertyType().ToString(), "The system type of the property."));
                        pGrid.Items.Add(CreateCustomProperty("Default Setting", column.DefaultSetting, "The default setting of the property."));
                        pGrid.Items.Add(CreateCustomProperty("Max Length", column.MaxLength.ToString(), "The maximum length of this property value."));

                        pGrid.Items.Add(CreateCustomProperty("Numeric", BoolToYesNo(column.IsNumeric), "Whether or not this property is numeric."));
                        pGrid.Items.Add(CreateCustomProperty("Date/Time", BoolToYesNo(column.IsDateTime), "Whether or not this property is date/time."));
                        pGrid.Items.Add(CreateCustomProperty("Nullable", BoolToYesNo(column.IsNullable), "Whether or not this property is nullable."));
                        pGrid.Items.Add(CreateCustomProperty("Read Only", BoolToYesNo(column.IsReadOnly), "Whether or not this property is read only."));
                        pGrid.Items.Add(
                            CreateCustomProperty("Managed by SubSonic", BoolToYesNo(column.IsReservedColumn), "Whether or not SubSonic manages the value of this property."));

                        pGrid.Refresh();
                    }
                }
            }
        }
コード例 #13
0
        private string GetNodeGenerationPath(StageNode node)
        {
            const string backSlash = "\\";
            string outDir = config.CodeGenerationPath;
            if(node.Provider != null)
            {
                if(!String.IsNullOrEmpty(node.Provider.CodeGenerationPath))
                    outDir = node.Provider.CodeGenerationPath;
                else if(!String.IsNullOrEmpty(node.Project.CodeGenerationPath))
                    outDir = node.Project.CodeGenerationPath;

                if(!outDir.EndsWith(backSlash))
                outDir = String.Concat(outDir, backSlash);

                if (node.Provider.OrganizeCodeByProvider)
                    outDir = String.Concat(outDir, node.Provider.Name, backSlash);

            }
            if (!outDir.EndsWith(backSlash))
                outDir = String.Concat(outDir, backSlash);
            return outDir;
        }
コード例 #14
0
        private string GenerateProviderCode(StageNode selectedNode)
        {
            TurboCompiler turboCompiler = new TurboCompiler();

            ICodeLanguage language;
            if(miGenerateVB.Checked)
                language = new VBCodeLanguage();
            else
                language = new CSharpCodeLanguage();

            //string outDir = codeDestination;

            DataProviderCollection generationProviders = new DataProviderCollection();
            string navigatePath = config.CodeGenerationPath;
            if (selectedNode.IsProjectNode)
            {
                generationProviders = DataService.Providers;
                if (selectedNode.Nodes.Count > 1)
                    navigatePath = GetNodeGenerationPath(selectedNode);
            }
            else if (selectedNode.IsProviderNode)
            {
                generationProviders.Add(DataService.Providers[selectedNode.Provider.Name]);
                navigatePath = GetNodeGenerationPath(selectedNode);
            }

            foreach(DataProvider provider in generationProviders)
            {
                StageNode currentNode = GetCurrentProviderNode(selectedNode, provider);
                if(currentNode != null)
                {
                    string providerDir = GetNodeGenerationPath(currentNode);
                    if(!Directory.Exists(providerDir))
                        Directory.CreateDirectory(providerDir);

                    string[] tables = DataService.GetTableNames(provider.Name);

                    foreach(string tbl in tables)
                    {
                        if(CodeService.ShouldGenerate(tbl, provider.Name))
                        {
                            ShowStatus(String.Format("Generating {0}...", tbl));
                            string className = DataService.GetSchema(tbl, provider.Name, TableType.Table).ClassName;
                            TurboTemplate tt = CodeService.BuildClassTemplate(tbl, language, provider);
                            tt.OutputPath = Path.Combine(providerDir, className + language.FileExtension);
                            turboCompiler.AddTemplate(tt);

                            if(provider.GenerateODSControllers && provider.TableBaseClass != "RepositoryRecord")
                            {
                                TurboTemplate ttODS = CodeService.BuildODSTemplate(tbl, language, provider);
                                ttODS.OutputPath = Path.Combine(providerDir, className + "Controller" + language.FileExtension);
                                turboCompiler.AddTemplate(ttODS);
                            }
                        }
                    }

                    string[] views = DataService.GetViewNames(provider.Name);
                    foreach(string tbl in views)
                    {
                        if(CodeService.ShouldGenerate(tbl, provider.Name))
                        {
                            ShowStatus(String.Format("Generating {0}...", tbl));
                            string className = DataService.GetSchema(tbl, provider.Name, TableType.View).ClassName;
                            TurboTemplate tt = CodeService.BuildViewTemplate(tbl, language, provider);
                            tt.OutputPath = Path.Combine(providerDir, className + language.FileExtension);
                            turboCompiler.AddTemplate(tt);
                        }
                    }

                    if(provider.UseSPs)
                    {
                        ShowStatus("Generating Stored Procedures...");
                        string outPath = Path.Combine(providerDir, provider.SPClassName + language.FileExtension);
                        TurboTemplate tt = CodeService.BuildSPTemplate(language, provider);
                        tt.OutputPath = outPath;
                        turboCompiler.AddTemplate(tt);
                    }

                    ShowStatus("Generating Structs...");
                    string structPath = Path.Combine(providerDir, "AllStructs" + language.FileExtension);
                    TurboTemplate ttStructs = CodeService.BuildStructsTemplate(language, DataService.Provider);
                    ttStructs.OutputPath = structPath;
                    turboCompiler.AddTemplate(ttStructs);

                    if(miScriptSchemas.Checked && provider.NamedProviderType == DataProviderTypeName.SQL_SERVER)
                    {
                        ShowStatus("Scripting Schema...");
                        string schema = ScriptSchema(provider.DefaultConnectionString);
                        string outSchemaFileName =
                            string.Format("{0}_{1}_{2}_{3}_{4}_Schema.sql", DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, Environment.UserName, provider.Name);
                        Files.CreateToFile(Path.Combine(providerDir, outSchemaFileName), schema);
                    }

                    if(miScriptData.Checked)
                    {
                        string outFileName = string.Format("{0}_Data_{1}_{2}_{3}.sql", provider.Name, DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
                        string outPath = Path.Combine(providerDir, outFileName);

                        using(StreamWriter sw = File.CreateText(outPath))
                        {
                            foreach(string tbl in tables)
                            {
                                if(CodeService.ShouldGenerate(tbl, provider.Name))
                                {
                                    Utility.WriteTrace(String.Format("Scripting Table: {0}", tbl));
                                    string dataScript = DataService.ScriptData(tbl, provider.Name);
                                    sw.Write(dataScript);
                                    sw.Write(Environment.NewLine);
                                }
                            }
                        }
                    }
                }
            }

            turboCompiler.Run();
            foreach(TurboTemplate template in turboCompiler.Templates)
            {
                ShowStatus(String.Concat("Writing ", template.TemplateName, " as ", template.OutputPath.Substring(template.OutputPath.LastIndexOf("\\") + 1)));
                Files.CreateToFile(template.OutputPath, template.FinalCode);
            }

            ShowStatus("Finished.");
            Application.DoEvents();
            return navigatePath;
        }
コード例 #15
0
 private void ToggleContextMenuItems(StageNode node)
 {
     cmiTreeDeleteProject.Enabled = node.IsProjectNode;
     cmiTreeAddProvider.Enabled = node.IsProjectNode;
     cmiTreeDeleteProvider.Enabled = node.IsProviderNode;
     cmiTreeAddConnectionString.Enabled = node.IsConnectionStringFolderNode;
     cmiTreeDeleteConnectionString.Enabled = node.IsConnectionStringNode;
     if(node.IsTableNode || node.IsViewNode)
     {
         cmiGenerateObjectEnabled.Visible = true;
         //cmiGenerateObjectEnabled.Enabled = true;
         SetGenerateButtonText(node);
     }
     else
     {
         cmiGenerateObjectEnabled.Visible = false;
         //cmiGenerateObjectEnabled.Enabled = false;
     }
 }
コード例 #16
0
        private void LoadScaffold(StageNode node)
        {
            if(node != null && tabMaster.SelectedTab == tabMasterScaffolds && node.Project != null)
            {
                string outputText = null;
                if(node.IsTableNode)
                {
                    outputText = scaffoldTemplate.Replace(TEMPLATE_SCAFFOLD_PROPERTIES,
                        "ScaffoldType=\"Normal\" TableName=\"" + node.DatabaseName + "\" ProviderName=\"" + node.Provider.Name + "\"");
                }
                else if(node.IsProjectNode)
                    outputText = scaffoldTemplate.Replace(TEMPLATE_SCAFFOLD_PROPERTIES, "ScaffoldType=\"Auto\"");

                if(!String.IsNullOrEmpty(outputText))
                {
                    if(File.Exists(scaffoldFilePath))
                        File.Delete(scaffoldFilePath);
                    File.WriteAllText(scaffoldFilePath, outputText);
                    while(!File.Exists(scaffoldFilePath))
                    {
                        //wait
                    }
                    webScaffolds.Navigate(scaffoldUrlPath + "?nocache=" + Guid.NewGuid());
                }
                else
                    webScaffolds.Navigate(scaffoldInfoUrlPath);
            }
        }
コード例 #17
0
        private void ToggleNodeNames(StageNode node)
        {
            node.Text = miUseDatabaseNames.Checked ? node.DatabaseName : node.SubSonicName;

            foreach(StageNode subNode in node.Nodes)
                ToggleNodeNames(subNode);
        }
コード例 #18
0
        private void LoadStoredProcedureParameterProperties(StageNode node)
        {
            if(node.Provider != null)
            {
                InstantiateProvider(node.Provider);

                StoredProcedure storedProcedure = null;
                List<StoredProcedure> storedProcedures = DataService.GetSPSchemaCollection(node.Provider.Name);

                foreach(StoredProcedure sp in storedProcedures)
                {
                    if(sp.Name == ((StageNode)node.Parent).ItemKey)
                    {
                        storedProcedure = sp;
                        break;
                    }
                }

                if(storedProcedure != null)
                {
                    StoredProcedure.Parameter parameter = null;
                    foreach(StoredProcedure.Parameter p in storedProcedure.Parameters)
                    {
                        if(p.Name == node.ItemKey)
                        {
                            parameter = p;
                            break;
                        }
                    }

                    if(parameter != null)
                    {
                        pGrid.Tag = node;
                        pGrid.ShowCustomProperties = true;
                        pGrid.Items.Clear();

                        pGrid.Items.Add(CreateCustomProperty("Display Name", parameter.DisplayName, "The formatted display name."));
                        pGrid.Items.Add(CreateCustomProperty("Database Name", parameter.Name, "The name of the underlying database object."));
                        pGrid.Items.Add(CreateCustomProperty("Parameter Mode", parameter.Mode.ToString(), "The mode that this parameter operates in."));
                        pGrid.Items.Add(CreateCustomProperty("Database Type", parameter.DBType.ToString(), "The database type of the parameter."));

                        pGrid.Refresh();
                    }
                }
            }
        }
コード例 #19
0
 private void ToggleToolbarItems(StageNode node)
 {
     btnNewProvider.Enabled = node.IsProjectNode;
     btnAddConnectionString.Enabled = node.IsConnectionStringFolderNode;
     btnInvokeProviders.Enabled = (node.IsProjectNode || node.IsProviderNode);
     btnSplitGenerateCode.Enabled = (node.IsProjectNode || node.IsProviderNode);
 }
コード例 #20
0
        private void LoadStoredProcedureProperties(StageNode node)
        {
            if(node.Provider != null)
            {
                InstantiateProvider(node.Provider);

                StoredProcedure storedProcedure = null;
                List<StoredProcedure> storedProcedures = DataService.GetSPSchemaCollection(node.Provider.Name);

                foreach(StoredProcedure sp in storedProcedures)
                {
                    if(sp.Name == node.ItemKey)
                    {
                        storedProcedure = sp;
                        break;
                    }
                }

                if(storedProcedure != null)
                {
                    pGrid.Tag = node;
                    pGrid.ShowCustomProperties = true;
                    pGrid.Items.Clear();

                    pGrid.Items.Add(CreateCustomProperty("Display Name", storedProcedure.DisplayName, "The formatted display name."));
                    pGrid.Items.Add(CreateCustomProperty("Database Name", storedProcedure.Name, "The name of the underlying database object."));
                    pGrid.Items.Add(CreateCustomProperty("Schema Name", storedProcedure.SchemaName, "The name of the schema this stored procedure belongs to."));

                    pGrid.Refresh();
                }
            }
        }
コード例 #21
0
        private static bool IsNodeMatch(DataRow row, StageNode node)
        {
            if(node.IsProjectNode && row is MasterStore.ProjectsRow && ((MasterStore.ProjectsRow)row).ProjectId == node.Project.ProjectId)
                return true;
            if(node.IsProviderNode && row is MasterStore.ProvidersRow && ((MasterStore.ProvidersRow)row).ProviderId == node.Provider.ProviderId)
                return true;
            if(node.IsConnectionStringNode && row is MasterStore.ConnectionStringsRow &&
               ((MasterStore.ConnectionStringsRow)row).ConnectionStringId == node.ConnectionString.ConnectionStringId)
                return true;

            return false;
        }
コード例 #22
0
        private void LoadTableProperties(StageNode node)
        {
            if(node.Provider != null)
            {
                TableType tableType = node.IsTableNode ? TableType.Table : TableType.View;
                InstantiateProvider(node.Provider);
                TableSchema.Table table = DataService.GetInstance(node.Provider.Name).GetTableSchema(node.ItemKey, tableType);

                if(table != null)
                {
                    pGrid.Tag = node;
                    pGrid.ShowCustomProperties = true;
                    pGrid.Items.Clear();

                    pGrid.Items.Add(CreateCustomProperty("Class Name", table.ClassName, "The name of the generated class."));
                    pGrid.Items.Add(CreateCustomProperty("Database Name", table.Name, "The name of the underlying database object."));
                    pGrid.Items.Add(CreateCustomProperty("Has Primary Key", BoolToYesNo(table.HasPrimaryKey), "Whether or not the table has at least one primary key."));
                    pGrid.Items.Add(CreateCustomProperty("Has Foreign Keys", BoolToYesNo(table.HasForeignKeys), "Whether or not the table has one or more foreign keys."));
                    pGrid.Refresh();
                }
            }
        }
コード例 #23
0
 private static StageNode MakeNode(string text, string databaseName, string subSonicName, StageNodeType nodeType, string nodeKey, DataRow row)
 {
     StageNode node = new StageNode(text, row);
     node.NodeType = nodeType;
     node.ImageKey = GetImageKey(nodeType);
     node.SelectedImageKey = GetImageKey(nodeType);
     node.ItemKey = nodeKey;
     node.DatabaseName = databaseName;
     node.SubSonicName = subSonicName;
     return node;
 }
コード例 #24
0
 private static StageNode MakeNode(string text, StageNodeType nodeType, int nodeId, DataRow row)
 {
     StageNode node = new StageNode(text, row)
                          {
                              NodeType = nodeType,
                              ImageKey = GetImageKey(nodeType),
                              SelectedImageKey = GetImageKey(nodeType),
                              RowId = nodeId,
                              DatabaseName = text,
                              SubSonicName = text
                          };
     return node;
 }