Ejemplo n.º 1
0
        public void Setup()
        {
            var servcies = new ServiceCollection();

            servcies.AddDbContext <TestDbContext>(opt => { opt.UseMySql("Server=localhost; Database=YunyongDataExchangeTestDB_20190109; Uid=SkyUser; Pwd=Sky@4321;SslMode=none;"); });

            var provider = servcies.BuildServiceProvider();

            var scope   = provider.CreateScope();
            var context = scope.ServiceProvider.GetService <TestDbContext>();

            context.Database.EnsureCreated();


            if (Conn.CountAsync <UserInfo>(a => true).Result == 0)
            {
                var rand = new Random();
                for (int i = 0; i < 100; i++)
                {
                    var tmp = EntityFactory.Create <UserInfo>();
                    tmp.Name = $"TestUser{rand.Next(1000, 9999):0000}";
                    Conn.CreateAsync(tmp).GetAwaiter().GetResult();
                }
            }
        }
Ejemplo n.º 2
0
        public async Task Create_Shotcut()
        {
            var m1 = new BodyFitRecord
            {
                Id                  = Guid.Parse("1fbd8a41-c75b-45c0-9186-016544284e2e"),
                CreatedOn           = DateTime.Now,
                UserId              = Guid.NewGuid(),
                BodyMeasureProperty = "{xxx:yyy,mmm:nnn}"
            };

            await PreCreate(m1);

            xx = string.Empty;

            // 新建
            var res1 = await Conn.CreateAsync(m1);

            Assert.True(res1 == 1);



            /********************************************************************************************************************************/

            xx = string.Empty;
        }
Ejemplo n.º 3
0
        public async Task test()
        {
            /****************************************************************************************/

            var xx15 = "";

            var pk  = Guid.Parse("8f2cbb64-8356-4482-88ee-016558c05b2d");
            var m15 = new AlipayPaymentRecord
            {
                Id              = pk,
                CreatedOn       = DateTime.Parse("2018-08-20 19:12:05.933786"),
                PaymentRecordId = Guid.Parse("e94f747e-1a6d-4be6-af51-016558c05b29"),
                OrderId         = Guid.Parse("f60f08e7-9678-41a8-b4aa-016558c05afc"),
                TotalAmount     = 0.010000000000000000000000000000M,
                Description     = null,
                PaymentSN       = "2018082021001004180510465833",
                PayedOn         = DateTime.Parse("2018-08-20 20:36:35.720525"),
                CanceledOn      = null,
                PaymentUrl      = "https://openapi.xxx?charset=UTF-8&app_id=xxx&biz_content=xxx&charset=UTF-8&format=JSON&method=zzz&return_url=xxx&sign_type=yyy&timestamp=zzz&version=1.0"
            };
            await Conn.DeleteAsync <AlipayPaymentRecord>(pk);

            var res15 = await Conn.CreateAsync <AlipayPaymentRecord>(m15);

            Assert.True(res15 == 1);

            var tuple15 = (XDebug.SQL, XDebug.Parameters, XDebug.SqlWithParams);

            var res151 = await Conn.GetAsync <AlipayPaymentRecord>(pk);

            Assert.NotNull(res151);

            /****************************************************************************************/

            var xx16 = "";

            var json   = File.ReadAllText(@"C:\Users\liume\Desktop\Work\DalTestDB\ProfileData.json");
            var list16 = JsonConvert.DeserializeObject <List <UserInfo> >(json);

            foreach (var item in list16)
            {
                item.Id        = Guid.NewGuid();
                item.CreatedOn = DateTime.Now;
            }
            var res16 = await Conn.CreateBatchAsync <UserInfo>(list16);

            Assert.True(list16.Count == res16);

            var tuple16 = (XDebug.SQL, XDebug.Parameters, XDebug.SqlWithParams);

            /****************************************************************************************/
        }
Ejemplo n.º 4
0
        private async Task <BodyFitRecord> PreQuery()
        {
            var m = new BodyFitRecord
            {
                Id                  = Guid.Parse("1fbd8a41-c75b-45c0-9186-016544284e2e"),
                CreatedOn           = Convert.ToDateTime("2018-08-23 13:36:58"),
                UserId              = Guid.NewGuid(),
                BodyMeasureProperty = "xxxx"
            };

            // 清理数据
            var resd = await Conn.DeleteAsync <BodyFitRecord>(it => it.Id == m.Id);

            // 造数据
            var resc = await Conn.CreateAsync(m);

            return(m);
        }
Ejemplo n.º 5
0
        private async Task <BodyFitRecord> CreateDbData()
        {
            var m = new BodyFitRecord
            {
                Id                  = Guid.Parse("1fbd8a41-c75b-45c0-9186-016544284e2e"),
                CreatedOn           = DateTime.Now,
                UserId              = Guid.NewGuid(),
                BodyMeasureProperty = "{xxx:yyy,mmm:nnn}"
            };

            // 删
            var res1 = await Conn
                       .Deleter <BodyFitRecord>()
                       .Where(it => it.Id == m.Id)
                       .DeleteAsync();

            // 建
            var res2 = await Conn.CreateAsync(m);

            return(m);
        }
Ejemplo n.º 6
0
        private async Task <BodyFitRecord> PreDelete()
        {
            xx = string.Empty;

            // 造数据
            var m = new BodyFitRecord
            {
                Id                  = Guid.Parse("1fbd8a41-c75b-45c0-9186-016544284e2e"),
                CreatedOn           = DateTime.Now,
                UserId              = Guid.NewGuid(),
                BodyMeasureProperty = "{xxx:yyy,mmm:nnn}"
            };

            var res = await Conn
                      .Deleter <BodyFitRecord>()
                      .Where(it => it.Id == m.Id)
                      .DeleteAsync();

            var res0 = await Conn.CreateAsync(m);

            return(m);
        }
Ejemplo n.º 7
0
        public async Task History_03()
        {
            xx = string.Empty;

            var m = new AlipayPaymentRecord
            {
                Id              = Guid.Parse("8f2cbb64-8356-4482-88ee-016558c05b2d"),
                CreatedOn       = DateTime.Parse("2018-08-20 19:12:05.933786"),
                PaymentRecordId = Guid.Parse("e94f747e-1a6d-4be6-af51-016558c05b29"),
                OrderId         = Guid.Parse("f60f08e7-9678-41a8-b4aa-016558c05afc"),
                TotalAmount     = 0.010000000000000000000000000000M,
                Description     = null,
                PaymentSN       = "2018082021001004180510465833",
                PayedOn         = DateTime.Parse("2018-08-20 20:36:35.720525"),
                CanceledOn      = null,
                PaymentUrl      = "https://openapi.xxx?charset=UTF-8&app_id=zzz&version=1.0"
            };

            // 删除一条数据: AlipayPaymentRecord
            await Conn.DeleteAsync <AlipayPaymentRecord>(it => it.Id == m.Id);

            // 新增一条数据: AlipayPaymentRecord
            var res1 = await Conn.CreateAsync(m);

            Assert.True(res1 == 1);



            var res11 = await Conn.QueryOneAsync <AlipayPaymentRecord>(it => it.Id == m.Id);

            Assert.NotNull(res11);

            /****************************************************************************************/

            xx = string.Empty;
        }
Ejemplo n.º 8
0
        private async Task <BodyFitRecord> Pre01()
        {
            // 造数据
            var m = new BodyFitRecord
            {
                Id                  = Guid.Parse("1fbd8a41-c75b-45c0-9186-016544284e2e"),
                CreatedOn           = DateTime.Now,
                UserId              = Guid.NewGuid(),
                BodyMeasureProperty = "{xxx:yyy,mmm:nnn}"
            };

            // 清理数据
            var resx1 = await Conn.QueryOneAsync <BodyFitRecord>(it => it.Id == m.Id);

            if (resx1 != null)
            {
                var resx2 = await Conn.DeleteAsync <BodyFitRecord>(it => it.Id == resx1.Id);
            }

            // 新建
            var res0 = await Conn.CreateAsync(m);

            return(m);
        }
Ejemplo n.º 9
0
        public async Task History_01()
        {
            /********************************************************************************************************************************/

            var m2 = new Agent
            {
                Id                = Guid.NewGuid(),
                CreatedOn         = DateTime.Now,
                UserId            = Guid.NewGuid(),
                PathId            = "x-xx-xxx-xxxx",
                Name              = "张三",
                Phone             = "18088889999",
                IdCardNo          = "No.12345",
                CrmUserId         = "yyyyy",
                AgentLevel        = AgentLevel.DistiAgent,
                ActivedOn         = null, // DateTime?
                ActiveOrderId     = null, // Guid?
                DirectorStarCount = 5
            };

            xx = string.Empty;

            var res2 = await Conn.CreateAsync(m2);

            Assert.True(res2 == 1);



            /********************************************************************************************************************************/

            xx = string.Empty;

            var res5 = await Conn.CreateAsync(new Agent
            {
                Id                = Guid.NewGuid(),
                CreatedOn         = Convert.ToDateTime("2018-10-07 17:02:05"),
                UserId            = Guid.NewGuid(),
                PathId            = "xx-yy-zz-mm-nn",
                Name              = "meng-net",
                Phone             = "17600000000",
                IdCardNo          = "876987698798",
                CrmUserId         = Guid.NewGuid().ToString(),
                AgentLevel        = null,
                ActivedOn         = null,
                ActiveOrderId     = null,
                DirectorStarCount = 1
            });



            /********************************************************************************************************************************/

            xx = string.Empty;

            await ClearData6();

            var m6 = new Agent
            {
                Id                = Guid.Parse("ea1ad309-56f7-4e3e-af12-0165c9121e9b"),
                CreatedOn         = Convert.ToDateTime("2018-10-07 17:02:05"),
                UserId            = Guid.NewGuid(),
                PathId            = "xx-yy-zz-mm-nn",
                Name              = "meng-net",
                Phone             = "17600000000",
                IdCardNo          = "876987698798",
                CrmUserId         = Guid.NewGuid().ToString(),
                AgentLevel        = AgentLevel.DistiAgent,
                ActivedOn         = null,
                ActiveOrderId     = null,
                DirectorStarCount = 1
            };

            var res6 = await Conn.CreateAsync(m6);



            var res61 = await Conn.QueryOneAsync <Agent>(it => it.Id == Guid.Parse("ea1ad309-56f7-4e3e-af12-0165c9121e9b"));

            Assert.True(res61.AgentLevel == AgentLevel.DistiAgent);

            /********************************************************************************************************************************/

            xx = string.Empty;

            await ClearData7();

            var m7 = new Agent
            {
                Id                = Guid.Parse("08d60369-4fc1-e8e0-44dc-435f31635e6d"),
                CreatedOn         = Convert.ToDateTime("2018-08-16 19:34:25.116759"),
                UserId            = Guid.NewGuid(),
                PathId            = "xx-yy-zz-mm-nn",
                Name              = "meng-net",
                Phone             = "17600000000",
                IdCardNo          = "876987698798",
                CrmUserId         = Guid.NewGuid().ToString(),
                AgentLevel        = AgentLevel.DistiAgent,
                ActivedOn         = null,
                ActiveOrderId     = null,
                DirectorStarCount = 1
            };

            var res7 = await Conn.CreateAsync(m7);



            var res71 = await Conn.QueryOneAsync <Agent>(it => it.Id == Guid.Parse("08d60369-4fc1-e8e0-44dc-435f31635e6d"));

            Assert.True(res71.CreatedOn == Convert.ToDateTime("2018-08-16 19:34:25.116759"));

            /********************************************************************************************************************************/

            xx = string.Empty;
        }
Ejemplo n.º 10
0
        public async Task CreateAsync_SQL()
        {
            xx = string.Empty;

            var m = new AlipayPaymentRecord
            {
                Id              = Guid.Parse("DDED9817-A73B-490F-9289-016558ECB41C"),
                CreatedOn       = DateTime.Parse("2018-08-20 13:48:03.320317"),
                PaymentRecordId = Guid.Parse("99b4afd3-9442-4556-a4bf-01655797af73"),
                OrderId         = Guid.Parse("c18aa87e-3367-4813-952d-01655797af41"),
                TotalAmount     = 293.000000000000000000000000000000M,
                Description     = null,
                PaymentSN       = null,
                PayedOn         = null,
                CanceledOn      = null,
                PaymentUrl      = "https://openapi.alipay.com/gateway.do?charset=UTF-8"
            };

            // 删除一条数据: AlipayPaymentRecord
            await Conn.DeleteAsync <AlipayPaymentRecord>(it => it.Id == m.Id);

            var sql   = @"
                                insert into `alipaypaymentrecord` 
                                (`Id`,`CreatedOn`,`PaymentRecordId`,`OrderId`,`TotalAmount`,`Description`,`PaymentSN`,`PayedOn`,`CanceledOn`,`PaymentUrl`)
                                values 
                                (@Id,@CreatedOn,@PaymentRecordId,@OrderId,@TotalAmount,@Description,@PaymentSN,@PayedOn,@CanceledOn,@PaymentUrl);
                            ";
            var paras = new List <XParam>
            {
                new XParam {
                    ParamName = "Id", ParamValue = m.Id
                },
                new XParam {
                    ParamName = "CreatedOn", ParamValue = m.CreatedOn
                },
                new XParam {
                    ParamName = "PaymentRecordId", ParamValue = m.PaymentRecordId
                },
                new XParam {
                    ParamName = "OrderId", ParamValue = m.OrderId
                },
                new XParam {
                    ParamName = "TotalAmount", ParamValue = m.TotalAmount
                },
                new XParam {
                    ParamName = "Description", ParamValue = m.Description
                },
                new XParam {
                    ParamName = "PaymentSN", ParamValue = m.PaymentSN
                },
                new XParam {
                    ParamName = "PayedOn", ParamValue = m.PayedOn
                },
                new XParam {
                    ParamName = "CanceledOn", ParamValue = m.CanceledOn
                },
                new XParam {
                    ParamName = "PaymentUrl", ParamValue = m.PaymentUrl
                }
            };

            // 新增一条数据: AlipayPaymentRecord
            var res1 = await Conn.CreateAsync(sql, paras);

            Assert.True(res1 == 1);



            var res11 = await Conn.QueryOneAsync <AlipayPaymentRecord>(it => it.Id == m.Id);

            Assert.NotNull(res11);

            xx = string.Empty;
        }
Ejemplo n.º 11
0
        public async Task MySQL_PreData(char pk, int num)
        {
            xx = string.Empty;

            await Conn.DeleteAsync <MySQL_EveryType>(it => it.Char == $"{pk}-char");

            var flag = num % 2 == 0;

            var m = new MySQL_EveryType();

            m.Char      = $"{pk}-char";
            m.Char_Null = flag ? null : $"{pk}- char null";

            m.VarChar      = $"{pk}-var char";
            m.VarChar_Null = flag ? null : $"{pk}-var char null";

            m.TinyText      = $"{pk}-tiny text";
            m.TinyText_Null = flag ? null : $"{pk}-tiny text null";

            m.Text      = $"{pk}-text";
            m.Text_Null = flag ? null : $"{pk}-text null";

            m.MediumText      = $"{pk}-medium text";
            m.MediumText_Null = flag ? null : $"{pk}-medium text null";

            m.LongText      = $"{pk}-long text";
            m.LongText_Null = flag ? null : $"{pk}-long text null";

            m.TinyBlob      = Encoding.UTF8.GetBytes($"{pk}-tiny blob");
            m.TinyBlob_Null = flag ? null : Encoding.UTF8.GetBytes($"{pk}- tiny blob null");

            m.Blob      = Encoding.UTF8.GetBytes($"{pk}-blob");
            m.Blob_Null = flag ? null : Encoding.UTF8.GetBytes($"{pk}-blob null");

            m.MediumBlob      = Encoding.UTF8.GetBytes($"{pk}-medium blob");
            m.MediumBlob_Null = flag ? null : Encoding.UTF8.GetBytes($"{pk}-medium blob null");

            m.LongBlob      = Encoding.UTF8.GetBytes($"{pk}-long blob");
            m.LongBlob_Null = flag ? null : Encoding.UTF8.GetBytes($"{pk}-long blob null");

            m.Binary      = Encoding.UTF8.GetBytes($"{pk}-binary");
            m.Binary_Null = flag ? null : Encoding.UTF8.GetBytes($"{pk}-binary null");

            m.VarBinary      = Encoding.UTF8.GetBytes($"{pk}-var binary");
            m.VarBinary_Null = flag ? null : Encoding.UTF8.GetBytes($"{pk} var binary null");

            m.Enum      = MySQL_Enum.A;
            m.Enum_Null = flag ? null : (MySQL_Enum?)MySQL_Enum.B;

            m.Set = string.Join(",", new List <string> {
                "music", "movie"
            });
            m.Set_Null = flag ? null : string.Join(",", new List <string> {
                "swimming"
            });

            m.TinyInt      = (byte)pk;
            m.TinyInt_Null = flag ? null : (byte?)pk;

            m.SmallInt      = short.MaxValue;
            m.SmallInt_Null = flag ? null : (short?)short.MinValue;

            m.MediumInt      = 1000000;
            m.MediumInt_Null = flag ? null : (int?)1000000;

            m.Int      = int.MaxValue;
            m.Int_Null = flag ? null : (int?)int.MinValue;

            m.BigInt      = long.MaxValue;
            m.BigInt_Null = flag ? null : (long?)long.MinValue;

            m.Float      = 50.00F;
            m.Float_Null = flag ? null : (float?)50.00F;

            m.Double      = double.MaxValue;
            m.Double_Null = flag ? null : (double?)double.MinValue;

            m.Decimal      = 600.00M;
            m.Decimal_Null = flag ? null : (decimal?)600.00M;

            m.Date      = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
            m.Date_Null = flag ? null : (DateTime?)DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));

            m.DateTime      = DateTime.Now;
            m.DateTime_Null = flag ? null : (DateTime?)DateTime.Now;

            m.TimeStamp      = DateTime.Now;
            m.TimeStamp_Null = flag ? null : (DateTime?)DateTime.Now;

            m.Year      = DateTime.Now.Year.ToString();
            m.Year_Null = flag ? null : DateTime.Now.Year.ToString();

            m.Time      = DateTime.Now - DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
            m.Time_Null = flag ? null : (TimeSpan?)(DateTime.Now - DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd")));

            m.Bit      = true;
            m.Bit_Null = flag ? null : (bool?)false;

            await Conn.CreateAsync(m);

            xx = string.Empty;
        }