예제 #1
0
        private static string GetProviderConfigText(MasterStore.ProvidersRow provider)
        {
            const bool buildIfDefault = false;
            StringBuilder sbService = new StringBuilder();

            sbService.Append("\t\t\t<add name=\"" + provider.Name + "\" type=\"SubSonic." + provider.ProviderType.InternalName + ", SubSonic\"");
            if(!provider.IsConnectionStringIdNull())
                AddConfigProperty(sbService, ConfigurationPropertyName.CONNECTION_STRING_NAME, provider.ConnectionString.Name);
            AddConfigProperty(sbService, ConfigurationPropertyName.APPEND_WITH, provider, MM.Providers.AppendWithColumn, buildIfDefault);
            AddConfigProperty(sbService, ConfigurationPropertyName.ADDITIONAL_NAMESPACES, provider, MM.Providers.AdditionalNamespacesColumn, buildIfDefault);
            AddConfigProperty(sbService, ConfigurationPropertyName.EXCLUDE_PROCEDURE_LIST, provider, MM.Providers.ExcludeProcedureListColumn, buildIfDefault);
            AddConfigProperty(sbService, ConfigurationPropertyName.EXCLUDE_TABLE_LIST, provider, MM.Providers.ExcludeTableListColumn, buildIfDefault);
            AddConfigProperty(sbService, ConfigurationPropertyName.EXTRACT_CLASS_NAME_FROM_SP_NAME, provider, MM.Providers.ExtractClassNameFromSPNameColumn, buildIfDefault);
            AddConfigProperty(sbService, ConfigurationPropertyName.FIX_DATABASE_OBJECT_CASING, provider, MM.Providers.FixDatabaseObjectCasingColumn, buildIfDefault);
            AddConfigProperty(sbService, ConfigurationPropertyName.FIX_PLURAL_CLASS_NAMES, provider, MM.Providers.FixPluralClassNamesColumn, buildIfDefault);
            AddConfigProperty(sbService, ConfigurationPropertyName.GENERATED_NAMESPACE, provider, MM.Providers.GeneratedNamespaceColumn, buildIfDefault);
            AddConfigProperty(sbService, ConfigurationPropertyName.GENERATE_LAZY_LOADS, provider, MM.Providers.GenerateLazyLoadsColumn, buildIfDefault);
            AddConfigProperty(sbService, ConfigurationPropertyName.GENERATE_NULLABLE_PROPERTIES, provider, MM.Providers.GenerateNullablePropertiesColumn, buildIfDefault);
            AddConfigProperty(sbService, ConfigurationPropertyName.GENERATE_ODS_CONTROLLERS, provider, MM.Providers.GenerateODSControllersColumn, buildIfDefault);
            AddConfigProperty(sbService, ConfigurationPropertyName.GENERATE_RELATED_TABLES_AS_PROPERTIES, provider, MM.Providers.GenerateRelatedTablesAsPropertiesColumn,
                buildIfDefault);
            AddConfigProperty(sbService, ConfigurationPropertyName.INCLUDE_PROCEDURE_LIST, provider, MM.Providers.IncludeProcedureListColumn, buildIfDefault);
            AddConfigProperty(sbService, ConfigurationPropertyName.INCLUDE_TABLE_LIST, provider, MM.Providers.IncludeTableListColumn, buildIfDefault);
            AddConfigProperty(sbService, ConfigurationPropertyName.REGEX_DICTIONARY_REPLACE, provider, MM.Providers.RegexDictionaryReplaceColumn, buildIfDefault);
            AddConfigProperty(sbService, ConfigurationPropertyName.REGEX_IGNORE_CASE, provider, MM.Providers.RegexIgnoreCaseColumn, buildIfDefault);
            AddConfigProperty(sbService, ConfigurationPropertyName.REGEX_MATCH_EXPRESSION, provider, MM.Providers.RegexMatchExpressionColumn, buildIfDefault);
            AddConfigProperty(sbService, ConfigurationPropertyName.REGEX_REPLACE_EXPRESSION, provider, MM.Providers.RegexReplaceExpressionColumn, buildIfDefault);
            AddConfigProperty(sbService, ConfigurationPropertyName.RELATED_TABLE_LOAD_PREFIX, provider, MM.Providers.RelatedTableLoadPrefixColumn, buildIfDefault);
            AddConfigProperty(sbService, ConfigurationPropertyName.REMOVE_UNDERSCORES, provider, MM.Providers.RemoveUnderscoresColumn, buildIfDefault);
            AddConfigProperty(sbService, ConfigurationPropertyName.SET_PROPERTY_DEFAULTS_FROM_DATABASE, provider, MM.Providers.SetPropertyDefaultsFromDatabaseColumn, buildIfDefault);
            AddConfigProperty(sbService, ConfigurationPropertyName.SP_STARTS_WITH, provider, MM.Providers.SPStartsWithColumn, buildIfDefault);
            AddConfigProperty(sbService, ConfigurationPropertyName.STORED_PROCEDURE_CLASS_NAME, provider, MM.Providers.StoredProcedureBaseClassColumn, buildIfDefault);
            AddConfigProperty(sbService, ConfigurationPropertyName.STORED_PROCEDURE_CLASS_NAME, provider, MM.Providers.SPClassNameColumn, buildIfDefault);
            AddConfigProperty(sbService, ConfigurationPropertyName.STRIP_COLUMN_TEXT, provider, MM.Providers.StripColumnTextColumn, buildIfDefault);
            AddConfigProperty(sbService, ConfigurationPropertyName.STRIP_PARAM_TEXT, provider, MM.Providers.StripParamTextColumn, buildIfDefault);
            AddConfigProperty(sbService, ConfigurationPropertyName.STRIP_STORED_PROCEDURE_TEXT, provider, MM.Providers.StripSPTextColumn, buildIfDefault);
            AddConfigProperty(sbService, ConfigurationPropertyName.STRIP_TABLE_TEXT, provider, MM.Providers.StripTableTextColumn, buildIfDefault);
            AddConfigProperty(sbService, ConfigurationPropertyName.STRIP_VIEW_TEXT, provider, MM.Providers.StripViewTextColumn, buildIfDefault);
            AddConfigProperty(sbService, ConfigurationPropertyName.TABLE_BASE_CLASS, provider, MM.Providers.TableBaseClassColumn, buildIfDefault);
            AddConfigProperty(sbService, ConfigurationPropertyName.USE_EXTENDED_PROPERTIES, provider, MM.Providers.UseExtendedPropertiesColumn, buildIfDefault);
            AddConfigProperty(sbService, ConfigurationPropertyName.USE_STORED_PROCEDURES, provider, MM.Providers.UseSPsColumn, buildIfDefault);
            AddConfigProperty(sbService, ConfigurationPropertyName.USE_UTC_TIMES, provider, MM.Providers.UseUTCColumn, buildIfDefault);
            AddConfigProperty(sbService, ConfigurationPropertyName.VIEW_BASE_CLASS, provider, MM.Providers.ViewBaseClassColumn, buildIfDefault);
            AddConfigProperty(sbService, ConfigurationPropertyName.VIEW_STARTS_WITH, provider, MM.Providers.ViewStartsWithColumn, buildIfDefault);
            sbService.AppendLine("/>");

            return sbService.ToString();
        }
예제 #2
0
        private void BuildConfig(MasterStore.ProjectsRow project)
        {
            //bool buildIfDefault = false;
            if(project != null)
            {
                string newConfig = configTemplate;

                StringBuilder sbConnections = new StringBuilder();
                List<int> addedConnections = new List<int>();
                foreach(MasterStore.ProvidersRow provider in project.Providers())
                {
                    if(!provider.IsConnectionStringIdNull() && !addedConnections.Contains(provider.ConnectionStringId))
                    {
                        sbConnections.AppendLine("\t\t<add name=\"" + provider.ConnectionString.Name + "\" connectionString=\"" + provider.ConnectionString.ConnectionString +
                                                 "\"/>");
                        addedConnections.Add(provider.ConnectionStringId);
                    }
                }
                newConfig = newConfig.Replace(TEMPLATE_CONNECTION_STRINGS, sbConnections.ToString());

                if(!project.IsDefaultProviderNull())
                    newConfig = newConfig.Replace(TEMPLATE_DEFAULT_PROVIDER, project.DefaultProviderEntry.Name);
                newConfig = newConfig.Replace(TEMPLATE_TEMPLATE_DIRECTORY, project.TemplateDirectory);
                newConfig = newConfig.Replace(TEMPLATE_ENABLE_TRACE, project.EnableTrace.ToString().ToLower());

                StringBuilder sbService = new StringBuilder();
                foreach(MasterStore.ProvidersRow provider in project.Providers())
                    sbService.Append(GetProviderConfigText(provider));

                newConfig = newConfig.Replace(TEMPLATE_PROVIDERS, sbService.ToString());
                tbxConfigOutput.Text = newConfig;

                ActivateConfig();
                InstantiateProvider(project);
            }
        }
예제 #3
0
        private void PopulateProviderNodeData(MasterStore.ProvidersRow provider)
        {
            StageNode findNode = FindNodeByRow(provider);
            if(findNode != null)
            {
                findNode.Nodes.Clear();

                if(DataService.Providers[provider.Name] != null)
                {
                    DataService.Providers[provider.Name].ReloadSchema();
                    TableSchema.Table[] tables = DataService.GetTables(provider.Name);
                    if(tables.Length > 0)
                    {
                        StageNode tableFolderNode = MakeNode(TABLES, TABLES, TABLES, StageNodeType.TableFolder, null, provider);
                        findNode.Nodes.Add(tableFolderNode);

                        foreach(TableSchema.Table table in tables)
                        {
                            string displayName = miUseGeneratedNames.Checked ? table.ClassName : table.Name;
                            StageNodeType nodeType = table.HasPrimaryKey ? StageNodeType.Table : StageNodeType.TableWithoutPrimaryKey;
                            nodeType = CodeService.ShouldGenerate(table.Name, DataService.Providers[provider.Name].Name) ? nodeType : StageNodeType.TableExcluded;
                            StageNode tableNode = MakeNode(displayName, table.Name, table.ClassName, nodeType, table.Name, provider);
                            if(!table.HasPrimaryKey)
                            {
                                tableNode.ForeColor = Color.Red;
                                tableNode.ToolTipText = "There is no Primary Key on this table.";
                            }
                            tableFolderNode.Nodes.Add(tableNode);

                            TableSchema.TableColumnCollection columns = table.Columns;
                            foreach(TableSchema.TableColumn column in columns)
                            {
                                string displayColumnName = miUseGeneratedNames.Checked ? column.PropertyName : column.ColumnName;
                                StageNodeType columnNodeType = column.IsPrimaryKey ? StageNodeType.ColumnPrimaryKeyNode : StageNodeType.ColumnNode;
                                StageNode columnNode = MakeNode(displayColumnName, column.ColumnName, column.PropertyName, columnNodeType, column.ColumnName, provider);
                                tableNode.Nodes.Add(columnNode);
                            }
                        }
                    }

                    TableSchema.Table[] views = DataService.GetViews(provider.Name);
                    if(views.Length > 0)
                    {
                        StageNode viewFolderNode = MakeNode(VIEWS, VIEWS, VIEWS, StageNodeType.ViewFolder, null, provider);
                        findNode.Nodes.Add(viewFolderNode);
                        foreach(TableSchema.Table view in views)
                        {
                            StageNodeType nodeType = StageNodeType.View;
                            nodeType = CodeService.ShouldGenerate(view.Name, DataService.Providers[provider.Name].Name) ? nodeType : StageNodeType.ViewExcluded;
                            string displayName = miUseGeneratedNames.Checked ? view.ClassName : view.Name;
                            StageNode viewNode = MakeNode(displayName, view.Name, view.ClassName, nodeType, view.Name, provider);
                            viewFolderNode.Nodes.Add(viewNode);

                            TableSchema.TableColumnCollection columns = view.Columns;
                            foreach(TableSchema.TableColumn column in columns)
                            {
                                string displayColumnName = miUseGeneratedNames.Checked ? column.PropertyName : column.ColumnName;
                                StageNodeType columnNodeType = column.IsPrimaryKey ? StageNodeType.ColumnPrimaryKeyNode : StageNodeType.ColumnNode;
                                StageNode columnNode = MakeNode(displayColumnName, column.ColumnName, column.PropertyName, columnNodeType, column.ColumnName, provider);
                                viewNode.Nodes.Add(columnNode);
                            }
                        }
                    }

                    List<StoredProcedure> storedProcedures = DataService.GetSPSchemaCollection(provider.Name);
                    if(storedProcedures.Count > 0)
                    {
                        StageNode spFolderNode = MakeNode(STORED_PROCEDURES, STORED_PROCEDURES, STORED_PROCEDURES, StageNodeType.StoredProcedureFolder, null, provider);
                        findNode.Nodes.Add(spFolderNode);
                        foreach(StoredProcedure storedProcedure in storedProcedures)
                        {
                            string displayName = miUseGeneratedNames.Checked ? storedProcedure.DisplayName : storedProcedure.Name;
                            DataProvider thisProvider = DataService.Providers[provider.Name];
                            StageNodeType nodeType = CodeService.ShouldGenerate(storedProcedure.Name, thisProvider.IncludeProcedures, thisProvider.ExcludeProcedures, thisProvider)
                                                         ? StageNodeType.StoredProcedure
                                                         : StageNodeType.StoredProcedureExcluded;
                            StageNode spNode = MakeNode(displayName, storedProcedure.Name, storedProcedure.DisplayName, nodeType, storedProcedure.Name, provider);
                            spFolderNode.Nodes.Add(spNode);

                            StoredProcedure.ParameterCollection parameters = storedProcedure.Parameters;
                            foreach(StoredProcedure.Parameter parameter in parameters)
                            {
                                string paramDisplayName = miUseGeneratedNames.Checked ? parameter.DisplayName : parameter.Name;
                                StageNode spParamNode = MakeNode(paramDisplayName, parameter.Name, parameter.DisplayName, StageNodeType.StoredProcedureParameter, parameter.Name,
                                    provider);
                                spNode.Nodes.Add(spParamNode);
                            }
                        }
                    }
                }
            }
        }