Example #1
0
 public override bool Contains(IDbSchemaProvider value)
 {
     lock (this._root)
     {
         return(this._collection.Contains(value));
     }
 }
        private List <IDbSchemaProvider> LoadProviders()
        {
            List <IDbSchemaProvider> list = new List <IDbSchemaProvider>();

            List <String> fileProvider = new List <String>();

            foreach (string folder in this.ProviderSearchDirectories)
            {
                fileProvider.AddRange(Directory.GetFiles(folder, "*Provider.dll"));
            }

            foreach (string str2 in fileProvider)
            {
                try
                {
                    foreach (Type type in Assembly.LoadFrom(str2).GetTypes())
                    {
                        if (type.GetInterface(typeof(IDbSchemaProvider).FullName) != null)
                        {
                            IDbSchemaProvider provider = (IDbSchemaProvider)Activator.CreateInstance(type);
                            if (list.Where(p => p.Name == provider.Name).Count() == 0)
                            {
                                list.Add(provider);
                            }
                        }
                    }
                    continue;
                }
                catch (Exception)
                {
                    continue;
                }
            }
            return(list);
        }
Example #3
0
        /// <summary>根据配置信息初始化对象</summary>
        /// <param name="generatorName"></param>
        /// <param name="configuration"></param>
        public override void Init(string taskName, CodeBuilderConfiguration configuration)
        {
            // 模板文件位置
            this.TemplateFile = configuration.Tasks[taskName].Properties["TemplateFile"] == null ? null : configuration.Tasks[taskName].Properties["TemplateFile"].Value;

            // 实体类名称
            this.ClassName = configuration.Tasks[taskName].Properties["ClassName"].Value;
            // 数据表名称
            this.DataTableName = configuration.Tasks[taskName].Properties["DataTable"].Value;

            // 设置 table 信息
            IDbSchemaProvider provider = (IDbSchemaProvider)Assembly.Load(configuration.DatabaseProvider.Assembly).CreateInstance(configuration.DatabaseProvider.ClassName,
                                                                                                                                  false, BindingFlags.Default,
                                                                                                                                  null, new object[] { configuration.DatabaseProvider.ConnectionString },
                                                                                                                                  null, null);

            DatabaseSchema database = new DatabaseSchema();

            database.Name      = provider.GetDatabaseName();
            database.OwnerName = configuration.DatabaseProvider.OwnerName;

            var table = provider.GetTable(database.Name, database.OwnerName, configuration.Tasks[taskName].Properties["DataTable"].Value);

            this.fields = GetFields(table);

            // 设置 输出文件
            if (configuration.Tasks[taskName].Properties["File"] == null)
            {
                configuration.Tasks[taskName].Properties.Add(new X3Platform.CodeBuilder.Configuration.TaskProperty("File", configuration.Tasks[taskName].Properties["ClassName"].Value + ".py"));
            }
            else if (string.IsNullOrEmpty(configuration.Tasks[taskName].Properties["File"].Value))
            {
                configuration.Tasks[taskName].Properties["File"].Value = configuration.Tasks[taskName].Properties["ClassName"].Value + ".py";
            }
        }
Example #4
0
 public DatabaseSchema(IDbSchemaProvider provider, string connectionString)
 {
     this.provider = provider;
     this.connectionString = connectionString;
     this.database = this;
     this.Refresh();
 }
Example #5
0
 public override void Insert(int index, IDbSchemaProvider value)
 {
     lock (this._root)
     {
         this._collection.Insert(index, value);
     }
     return;
 }
Example #6
0
 public override void Remove(IDbSchemaProvider value)
 {
     lock (this._root)
     {
         this._collection.Remove(value);
     }
     return;
 }
Example #7
0
        public override void Init(string taskName, CodeBuilderConfiguration configuration)
        {
            // 作者
            this.Author = configuration.Author;

            // 名称空间前缀
            this.DataTableName = configuration.Tasks[taskName].Properties["DataTable"].Value;

            // 名称空间
            this.Package = ((string.IsNullOrEmpty(configuration.NamespaceRoot)) ? string.Empty : (configuration.NamespaceRoot + ".")) +
                           configuration.Tasks[taskName].Properties["Package"].Value;

            // 类名称
            this.ClassName = configuration.Tasks[taskName].Properties["ClassName"] == null ? "" : configuration.Tasks[taskName].Properties["ClassName"].Value;

            // 实体类所在的包名称
            this.EntityClassPackage = configuration.Tasks[taskName].Properties["EntityClassPackage"] == null ? "" : configuration.Tasks[taskName].Properties["EntityClassPackage"].Value;

            // 实体类名称
            this.EntityClass = configuration.Tasks[taskName].Properties["EntityClass"].Value;

            // 应用名称
            this.ApplicationName = configuration.Tasks[taskName].Properties["ApplicationName"] == null ? "" : configuration.Tasks[taskName].Properties["ApplicationName"].Value;

            // 数据层接口
            this.DataAccessInterface = configuration.Tasks[taskName].Properties["DataAccessInterface"] == null ? "" : configuration.Tasks[taskName].Properties["DataAccessInterface"].Value;

            // 数据层接口
            this.SupportAuthorization = configuration.Tasks[taskName].Properties["SupportAuthorization"] == null ? "" : configuration.Tasks[taskName].Properties["SupportAuthorization"].Value;

            //设置 table 信息
            IDbSchemaProvider provider = (IDbSchemaProvider)Assembly.Load(configuration.DatabaseProvider.Assembly).CreateInstance(configuration.DatabaseProvider.ClassName,
                                                                                                                                  false, BindingFlags.Default,
                                                                                                                                  null, new object[] { configuration.DatabaseProvider.ConnectionString },
                                                                                                                                  null, null);

            DatabaseSchema database = new DatabaseSchema();

            database.Name      = provider.GetDatabaseName();
            database.OwnerName = configuration.DatabaseProvider.OwnerName;

            table = provider.GetTable(database.Name, database.OwnerName, this.DataTableName);

            var noPrimaryKeyColumns = provider.GetNoPrimaryKeyColumns(table);

            this.fields = GetFields(table);

            // 设置 输出文件
            if (configuration.Tasks[taskName].Properties["File"] == null)
            {
                configuration.Tasks[taskName].Properties.Add(new X3Platform.CodeBuilder.Configuration.TaskProperty("File", this.ClassName + ".cs"));
            }
            else if (string.IsNullOrEmpty(configuration.Tasks[taskName].Properties["File"].Value))
            {
                configuration.Tasks[taskName].Properties["File"].Value = this.ClassName + ".cs";
            }
        }
Example #8
0
            public override int BinarySearch(IDbSchemaProvider value)
            {
                // This item is obfuscated and can not be translated.
                int num;

                lock (this._root)
                {
                    num = this._collection.BinarySearch(value);
                }

                return(num);
            }
        public DatabaseSchema(IDbSchemaProvider provider, string connectionString)
        {
            base._Database = this;

            this._Commands         = null;
            this._ConnectionString = string.Empty;
            this._DatabaseName     = string.Empty;
            this._Initialized      = false;

            this._Provider         = provider;
            this._ConnectionString = connectionString;
        }
Example #10
0
 public static DatabaseSchema Get(string databaseType, string dbName, string userName)
 {
     if (Schemas.ContainsKey(dbName))
     {
         return(Schemas[dbName]);
     }
     else
     {
         IDbSchemaProvider provider = GetProvider(databaseType, dbName, userName);
         DatabaseSchema    dbSchema = new DatabaseSchema(provider, dbName);
         Schemas.Add(dbName, dbSchema);
         return(dbSchema);
     }
 }
Example #11
0
            public override int Add(IDbSchemaProvider value)
            {
                // This item is obfuscated and can not be translated.
                int    num;
                object obj2;

                Monitor.Enter(obj2 = this._root);
                try
                {
                    num = this._collection.Add(value);
                }
                finally
                {
                    Monitor.Exit(obj2);
                }
                return(num);
            }
Example #12
0
            public override int IndexOf(IDbSchemaProvider value)
            {
                int    index;
                object obj2;

                Monitor.Enter(obj2 = this._root);
                try
                {
                    index = this._collection.IndexOf(value);
                }
                finally
                {
                    goto Label_0021;

Label_0021:
                    Monitor.Exit(obj2);
                }
                return(index);
            }
        /// <summary>
        /// Create a new DataSource with DatabaseService and add it to the workspace
        /// </summary>
        /// <param name="sourceName"></param>
        /// <param name="provider"></param>
        /// <param name="connectionString"></param>
        internal void AddSource(string sourceName, IDbSchemaProvider provider, string connectionString)
        {
            Tracer.Verbose("DatabaseExplorerService:AddSource", "START");

            if (this.treeViewDB == null)
            {
                return;
            }
            try
            {
                DataSource ds = DatabaseService.Instance.CreateSource(sourceName, provider, connectionString);
                WorkspaceService.Instance.Entity.DataSources.Add(ds);
            }
            catch (Exception err)
            {
                Tracer.Error("DatabaseExplorerService.AddSource", err);
            }

            Tracer.Verbose("DatabaseExplorerService:AddSource", "END");
        }
Example #14
0
        public override void Init(string taskName, CodeBuilderConfiguration configuration)
        {
            provider = (X3Platform.CodeBuilder.Data.IDbSchemaProvider)Assembly.Load(configuration.DatabaseProvider.Assembly).CreateInstance(configuration.DatabaseProvider.ClassName,
                                                                                                                                            false, BindingFlags.Default,
                                                                                                                                            null, new object[] { configuration.DatabaseProvider.ConnectionString },
                                                                                                                                            null, null);

            database = new X3Platform.CodeBuilder.Data.DatabaseSchema();

            database.Name      = provider.GetDatabaseName();
            database.OwnerName = configuration.DatabaseProvider.OwnerName;

            // table = provider.GetTable(database.Name, database.OwnerName, configuration.Tasks[taskName].Properties["DataTable"].Value);

            // 设置 输出文件
            if (configuration.Tasks[taskName].Properties["File"] == null)
            {
                configuration.Tasks[taskName].Properties.Add(new X3Platform.CodeBuilder.Configuration.TaskProperty("File", configuration.Tasks[taskName].Properties["DataTable"].Value + ".StorageProcedure.sql"));
            }
            else if (string.IsNullOrEmpty(configuration.Tasks[taskName].Properties["File"].Value))
            {
                configuration.Tasks[taskName].Properties["File"].Value = configuration.Tasks[taskName].Properties["DataTable"].Value + ".StorageProcedure.sql";
            }
        }
Example #15
0
 public override int BinarySearch(IDbSchemaProvider value)
 {
     return(this._collection.BinarySearch(value));
 }
Example #16
0
 private void btnCancel_Click(object sender, System.Windows.RoutedEventArgs e)
 {
     this.SelectedProvider = null;
     this.DialogResult     = false;
     this.Close();
 }
Example #17
0
 private void btnOk_Click(object sender, System.Windows.RoutedEventArgs e)
 {
     this.SelectedProvider = (IDbSchemaProvider)this.ListBoxProviders.SelectedItem;
     this.DialogResult     = true;
     this.Close();
 }
 public DataSource CreateSource(string sourceName, IDbSchemaProvider provider, string connectionString)
 {
     return(new DataSource(sourceName, connectionString, provider.GetType()));
 }
Example #19
0
 public override void Remove(IDbSchemaProvider value)
 {
     throw new NotSupportedException("Read-only collections cannot be modified.");
 }
Example #20
0
 public override int IndexOf(IDbSchemaProvider value)
 {
     return(this._collection.IndexOf(value));
 }
Example #21
0
 public DatabaseSchema(IDbSchemaProvider provider, string dbName)
 {
     this._databaseName = dbName;
     base._database     = this;
     this._provider     = provider;
 }