Example #1
0
        static void Main(string[] args)
        {
            var builder = CRL.SettingConfigBuilder.CreateInstance();

            builder.UseMongoDB();

            var configBuilder = new CRL.Core.ConfigBuilder();

            configBuilder.UseRedis("[email protected]:6389")
            .UseRedisSession();
            //自定义定位
            builder.RegisterLocation <Code.Sharding.MemberSharding>((t, a) =>
            {
                var tableName = t.TableName;
                if (a.Name == "hubro")
                {
                    tableName = "MemberSharding1";
                    return(new CRL.Sharding.Location("testdb2", tableName));
                }
                //返回定位库和表名
                return(new CRL.Sharding.Location("testdb", tableName));
            });
            builder.RegisterDBAccessBuild(dbLocation =>
            {
                if (dbLocation.ManageName == "mongo")
                {
                    var conn = CRL.Core.CustomSetting.GetConfigKey("mongodb");
                    return(new CRL.DBAccessBuild(DBType.MongoDB, conn));
                }
                return(null);
            });
            builder.RegisterDBAccessBuild(dbLocation =>
            {
                //定位库
                if (dbLocation.ShardingLocation != null)
                {
                    return(new CRL.DBAccessBuild(DBType.MSSQL, "Data Source=.;Initial Catalog=" + dbLocation.ShardingLocation.DataBaseSource + ";User ID=sa;Password=123"));
                }
                return(new CRL.DBAccessBuild(DBType.MSSQL, "server=.;database=testDb; uid=sa;pwd=123;"));
            });


            //Code.MemberManage.Instance.QueryItem(1);
            //Code.OrderManage.Instance.QueryItem(1);
            //Code.ProductDataManage.Instance.QueryItem(1);
            string str    = "111";
            var    client = new CRL.Core.RedisProvider.RedisClient(4);

label1:
            Code.ContextTest.Test();
            //testFormat();
            //MongoDBTestManage.Instance.GroupTest();
            //TestAll();
            //testCallContext("data3");
            Console.ReadLine();
            goto label1;
            Console.ReadLine();
        }
Example #2
0
        static void Main(string[] args)
        {
            var builder = new CRL.SettingConfigBuilder();

            builder.UseMongoDB();
            builder.UseOracle();
            var configBuilder = new CRL.Core.ConfigBuilder();

            configBuilder.UseRedis("[email protected]:6389")
            .UseRedisSession();
            //自定义定位
            builder.RegisterLocation <Code.Sharding.MemberSharding>((t, a) =>
            {
                var tableName = t.TableName;
                if (a.Name == "hubro")
                {
                    tableName = "MemberSharding1";
                    return(new CRL.Sharding.Location("testdb2", tableName));
                }
                //返回定位库和表名
                return(new CRL.Sharding.Location("testdb", tableName));
            });
            builder.RegisterDBAccessBuild(dbLocation =>
            {
                if (dbLocation.ManageName == "mongo")
                {
                    var conn = CRL.Core.CustomSetting.GetConfigKey("mongodb");
                    return(new CRL.DBAccessBuild(DBType.MongoDB, conn));
                }
                return(null);
            });
            builder.RegisterDBAccessBuild(dbLocation =>
            {
                //定位库
                if (dbLocation.ShardingLocation != null)
                {
                    return(new CRL.DBAccessBuild(DBType.MSSQL, "Data Source=.;Initial Catalog=" + dbLocation.ShardingLocation.DataBaseName + ";User ID=sa;Password=123"));
                }
                if (dbLocation.ManageType == typeof(Code.OracleModelManage))
                {
                    return(new CRL.DBAccessBuild(DBType.ORACLE, "User Id=test;Password=test123;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=orcl)))"));
                }
                return(new CRL.DBAccessBuild(DBType.MSSQL, "server=.;database=testDb; uid=sa;pwd=123;"));
            });


            //Code.MemberManage.Instance.QueryItem(1);
            //Code.OrderManage.Instance.QueryItem(1);
            //Code.ProductDataManage.Instance.QueryItem(1);
            string str    = "111";
            var    client = new CRL.Core.RedisProvider.RedisClient(4);

label1:
            //testFormat();
            //MongoDBTestManage.Instance.GroupTest();
            //testSpeed();
            Code.OracleModelManage.Instance.Test();
            //testCallContext("data3");
            Console.ReadLine();
            goto label1;
            Console.ReadLine();
        }
 static ConfigBuilder()
 {
     __Current = new ConfigBuilder();
 }