Example #1
0
 /// <summary>
 /// Creates add form.
 /// </summary>
 public ManageTaskForm()
 {
     db = new MyDbConnection();
     InitializeComponent();
     InitializeErrorProviders();
     InitializeStatuses();
 }
Example #2
0
 public void RestoreConnection(MyDbConnection conn)
 {
     try
     {
         Monitor.Enter(key);
         m_connections.Enqueue(conn);
     }
     finally
     {
         Monitor.Exit(key);
     }
 }
Example #3
0
        private void SetupDbComand(bool isAdmin = false)
        {
            //setup for UserDbServiceHelper.GetAppUserByIdAsync() because it uses execute scaler
            MyDbConnection con = new MyDbConnection();
            //setup command
            MyDbCommand command = new MyDbCommand(isAdmin ? 1 : 0 /*not admin*/);

            command.Connection = con;
            //setup repository
            repo.Setup(x => x.CreateDbCommand(It.IsAny <CommandType>(), It.IsAny <string>(), It.IsAny <Dictionary <string, object> >())).Returns(command);
            //setup service
            //Mock<IDbService<AspNetUser>> service = new Mock<IDbService<AspNetUser>>();
            userService.Setup(x => x.GetRepo()).Returns(repo.Object);
        }
Example #4
0
        protected void Application_Start(object sender, EventArgs e)
        {
            string applicationName = ConfigurationManager.AppSettings["ApplicationName"];
            if( !string.IsNullOrEmpty(applicationName) ) {
                MyDbConnection myConn = new MyDbConnection(applicationName);
                //初始化Map的数据库链接
                Mysoft.Map.Extensions.Initializer.UnSafeInit(myConn.GetConnectionString());

                //独立部署验证
                Application.Lock();
                Application["ESBToken"] = ConfigurationManager.AppSettings["ESBToken"];
                Application.UnLock();
            }
        }
Example #5
0
        public ActionResult Index()
        {
            using (var conn = new MyDbConnection().Open())
            {
                var users = conn.Query <Users>(
                    sql: @"select * from Users;"
                    ).ToList();

                var viewModel = new IndexViewModel
                {
                    Name  = "My Website",
                    Users = users
                };

                return(View(viewModel));
            }
        }
        public void Get_App_User_By_Id_Async_Should_Return_Null()
        {
            //setup connection
            MyDbConnection con = new MyDbConnection();
            //setup command
            MyDbCommand command = new MyDbCommand(0 /*not admin*/);

            command.Connection = con;
            //setup repository
            Mock <IDbRepository <AspNetUser> > repo = new Mock <IDbRepository <AspNetUser> >();

            repo.Setup(x => x.CreateDbCommand(It.IsAny <CommandType>(), It.IsAny <string>(), It.IsAny <Dictionary <string, object> >())).Returns(command);
            //setup service
            Mock <IDbService <AspNetUser> > service = new Mock <IDbService <AspNetUser> >();

            service.Setup(x => x.FindSingleWhere(It.IsAny <Expression <Func <AspNetUser, bool> > >()));
            service.Setup(x => x.GetRepo()).Returns(repo.Object);
            var data = UserDbServiceHelper.GetAppUserByIdAsync(service.Object, UserOne.Id).Result;

            Assert.Null(data);
        }
Example #7
0
        public FinishTaskForm(TaskModel task)
        {
            db          = new MyDbConnection();
            taskId      = task.Id;
            newStatusId = ++task.Status.Id;
            List <StatusModel> statuses  = db.GetStatuses();
            StatusModel        newStatus = statuses.FirstOrDefault(x => x.Id == newStatusId);

            if (newStatus == null)
            {
                this.Opacity = 0;
                MessageBox.Show("Błąd podczas wyznaczania nowego statusu!", "Błąd.");
                this.Close();
                return;
            }

            InitializeComponent();
            labelTaskManufacturer.Text = task.BikeManufacturer;
            labelTaskModel.Text        = task.BikeModel;
            labelTaskPhone.Text        = task.PhoneNumber;
            labelTaskStatus.Text       = newStatus.Value;
        }
        public void Get_User_By_Shop_Domain_Sould_Return_Valid_User_For_Valid_Shop()
        {
            //setup connection
            MyDbConnection con = new MyDbConnection();
            //setup command
            MyDbCommand command = new MyDbCommand(1 /*admin*/);

            command.Connection = con;
            //setup repository
            Mock <IDbRepository <AspNetUser> > repo = new Mock <IDbRepository <AspNetUser> >();

            repo.Setup(x => x.CreateDbCommand(It.IsAny <CommandType>(), It.IsAny <string>(), It.IsAny <Dictionary <string, object> >())).Returns(command);
            //setup service
            Mock <IDbService <AspNetUser> > service = new Mock <IDbService <AspNetUser> >();

            service.Setup(x => x.FindSingleWhere(It.IsAny <Expression <Func <AspNetUser, bool> > >())).Returns(UserOne);
            service.Setup(x => x.GetRepo()).Returns(repo.Object);
            var data = UserDbServiceHelper.GetUserByShopDomain(service.Object, UserOne.MyShopifyDomain).Result;

            Assert.NotNull(data);
            Assert.Equal(UserOne.Id, data.Id);
        }
Example #9
0
 public ClientRepository(MyDbConnection context)
 {
     _context = context;
 }
Example #10
0
 /// <summary>
 /// Processes the type of for each asynchronous operation.
 /// </summary>
 /// <param name="applicationName">Name of the application.</param>
 /// <param name="processor">The processor.</param>
 private static void ProcessForEachAsyncOperationType(string applicationName, AsyncOperationTypeProcessor processor)
 {
     MyDbConnection myConn;
     try
     {
         myConn = new MyDbConnection(applicationName);
     }
     catch
     {
         throw new AsyncServiceException(string.Format("未配置注册表数据库连接参数【{0}】,请确认已经在注册表中配置了该参数并拥有权限读取注册表!", applicationName));
     }
     //初始化Map1的数据库链接
     Mysoft.Map.Extensions.Initializer.UnSafeInit(myConn.GetConnectionString());
 }
Example #11
0
 public UnitOfWork()
 {
     _context         = new MyDbConnection(); //вот тут неуверен что делаю правильно
     ClientRepository = new ClientRepository(_context);
 }