Ejemplo n.º 1
0
        private static void Main(string[] args)
        {
            var connectionString = $@"Server=docker-host;Database=TestDb;User ID=sa;Password=yourStrong(!)Password";

            DapperInitializer.RegisterAnnotatedTypeMap(); // register typeMap for entities with [TableAttribute]

            using (var txManager = new TransactionManager())
            {
                using (var dbManager = (DatabaseManager)DatabaseManager.NewBuilder(new DbContextOptionsBuilder()
                                                                                   .UseSqlServer(connectionString)
                                                                                   .Options)
                                       .SetTransactionManager(txManager)
                                       .SetQueryBuilder(new SqlServerQueryBuilder())
                                       .Build())
                {
                    var userRepository = new UserRepository(dbManager);
                    using (var txSupport = txManager.Begin())
                    {
                        //userRepository.FindAll();
                        //userRepository.FindAll(Enumerables.List(new UserEntity()));
                        //userRepository.Get(new UserEntity());
                        //userRepository.Add(new UserEntity());
                        //userRepository.AddAll(Enumerables.List(new UserEntity()));
                        //userRepository.Update(new UserEntity());
                        //userRepository.UpdateAll(Enumerables.List(new UserEntity()));
                        //userRepository.Delete(new UserEntity());
                        //userRepository.DeleteAll(Enumerables.List(new UserEntity()));

                        Console.WriteLine(userRepository.CountAll());
                        txSupport.Complete();
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public SqlStorageViaDapperTests()
        {
            DapperInitializer.InitDapper();
            var configurationMock = new Mock <IConfiguration>();

            configurationMock.Setup(m => m.GetValue("connectionString"))
            .Returns("Server=127.0.0.1,1423;Database=Potestas;User Id=SA;Password=DOCKERTASK_1");

            _sqlStorage = new FlashObservationsSqlStorage(configurationMock.Object);
        }
Ejemplo n.º 3
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            DapperInitializer.Initialize();


            RedisCacheProvider.SetRedisCluster(AppSettingManager.AppSettings["redisServer"]);

            MemcachedProvider.SetMemcachedCluster(AppSettingManager.AppSettings["memcacheServer"].Split(','));
            EnyimMemcachedClient.SetMemcachedCluster(Shangpin.Ocs.Service.Common.AppSettingManager.AppSettings["memcached"].Split(','));
        }
Ejemplo n.º 4
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddTransient <Potestas.Configuration.IConfiguration, Configuration.Configuration>();
            services.AddTransient <IEnergyObservationStorage <FlashObservation>, FlashObservationsSqlStorage>();
            services.AddTransient <IEnergyObservationAnalizer, SqlAnalyzer>();
            DapperInitializer.InitDapper();

            services.AddControllers();

            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "Potestas API", Version = "v1"
                });
            });

            services.AddHealthChecks().AddCheck("PotestasDb", new SqlServerHealthCheck(Configuration["connectionString"]));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 设计器支持所需的方法 - 不要
        /// 使用代码编辑器修改此方法的内容。
        /// </summary>
        private void InitializeComponent()
        {
            this.button1  = new System.Windows.Forms.Button();
            this.label1   = new System.Windows.Forms.Label();
            this.textBox1 = new System.Windows.Forms.TextBox();
            this.label2   = new System.Windows.Forms.Label();
            this.textBox2 = new System.Windows.Forms.TextBox();
            this.textBox3 = new System.Windows.Forms.TextBox();
            this.label3   = new System.Windows.Forms.Label();
            this.textBox4 = new System.Windows.Forms.TextBox();
            this.label4   = new System.Windows.Forms.Label();
            this.SuspendLayout();
            //
            // button1
            //
            this.button1.Location = new System.Drawing.Point(172, 202);
            this.button1.Name     = "button1";
            this.button1.Size     = new System.Drawing.Size(131, 23);
            this.button1.TabIndex = 0;
            this.button1.Text     = "生成微码";
            this.button1.UseVisualStyleBackColor = true;
            this.button1.Click += new System.EventHandler(this.button1_Click);
            //
            // label1
            //
            this.label1.AutoSize = true;
            this.label1.Font     = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.label1.Location = new System.Drawing.Point(113, 50);
            this.label1.Name     = "label1";
            this.label1.Size     = new System.Drawing.Size(57, 17);
            this.label1.TabIndex = 5;
            this.label1.Text     = "活动ID:";
            //
            // textBox1
            //
            this.textBox1.Location = new System.Drawing.Point(172, 47);
            this.textBox1.Name     = "textBox1";
            this.textBox1.Size     = new System.Drawing.Size(131, 21);
            this.textBox1.TabIndex = 6;
            //
            // label2
            //
            this.label2.AutoSize = true;
            this.label2.Font     = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.label2.Location = new System.Drawing.Point(101, 124);
            this.label2.Name     = "label2";
            this.label2.Size     = new System.Drawing.Size(68, 17);
            this.label2.TabIndex = 5;
            this.label2.Text     = "生成数量:";
            //
            // textBox2
            //
            this.textBox2.Location = new System.Drawing.Point(172, 121);
            this.textBox2.Name     = "textBox2";
            this.textBox2.Size     = new System.Drawing.Size(131, 21);
            this.textBox2.TabIndex = 7;
            //
            // textBox3
            //
            this.textBox3.Location = new System.Drawing.Point(172, 87);
            this.textBox3.Name     = "textBox3";
            this.textBox3.Size     = new System.Drawing.Size(131, 21);
            this.textBox3.TabIndex = 9;
            //
            // label3
            //
            this.label3.AutoSize = true;
            this.label3.Font     = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.label3.Location = new System.Drawing.Point(101, 87);
            this.label3.Name     = "label3";
            this.label3.Size     = new System.Drawing.Size(68, 17);
            this.label3.TabIndex = 8;
            this.label3.Text     = "活动编码:";
            //
            // textBox4
            //
            this.textBox4.Location = new System.Drawing.Point(172, 160);
            this.textBox4.Name     = "textBox4";
            this.textBox4.Size     = new System.Drawing.Size(131, 21);
            this.textBox4.TabIndex = 11;
            //
            // label4
            //
            this.label4.AutoSize = true;
            this.label4.Font     = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.label4.Location = new System.Drawing.Point(110, 163);
            this.label4.Name     = "label4";
            this.label4.Size     = new System.Drawing.Size(56, 17);
            this.label4.TabIndex = 10;
            this.label4.Text     = "操作人:";
            //
            // VcodeCreate
            //
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
            this.AutoScaleMode       = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize          = new System.Drawing.Size(456, 276);
            this.Controls.Add(this.textBox4);
            this.Controls.Add(this.label4);
            this.Controls.Add(this.textBox3);
            this.Controls.Add(this.label3);
            this.Controls.Add(this.textBox2);
            this.Controls.Add(this.textBox1);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.label1);
            this.Controls.Add(this.button1);
            this.Name = "VcodeCreate";
            this.Text = "微码生成工具";
            this.ResumeLayout(false);
            this.PerformLayout();


            DapperInitializer.Initialize();
            RedisCacheProvider.SetRedisCluster(AppSettingManager.AppSettings["redisServer"]);

            MemcachedProvider.SetMemcachedCluster(AppSettingManager.AppSettings["memcacheServer"].Split(','));
            EnyimMemcachedClient.SetMemcachedCluster(Shangpin.Ocs.Service.Common.AppSettingManager.AppSettings["memcached"].Split(','));
        }
Ejemplo n.º 6
0
 public SaveToSqlProcessorViaDapperTests()
 {
     DapperInitializer.InitDapper();
 }
Ejemplo n.º 7
0
 public DapperProcessingFactory(IConfiguration configuration)
 {
     _configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
     DapperInitializer.InitDapper();
 }