Exemplo n.º 1
0
        public GoodsService()
        {
            var dapperDbContext =
                new DapperDbContext(new SqlConnection(WebConfigSetting.Instance.I200DbConnectionString));

            _goodsSummaryRepository = new DapperRepository <GoodsInfoSummary>(dapperDbContext);
        }
Exemplo n.º 2
0
        public Response <List <StaffWorkInfo> > getOnlieInfo(StaffOnlieModel model)
        {
            Response <List <StaffWorkInfo> > rsp = new Response <List <StaffWorkInfo> >();

            try
            {
                model.line = getUserLine(model.user);

                string sql = @"select   a.WorkID empno, a.WorkerName empname ,a.PostName job,a.line ,a.shift_no shift , b.Status_flag 
                             from  m_auxiliary_manpower a LEFT JOIN (select * from  mfg_onlinewip where work_date=@work_date ) b on a.WorkID=b.empNo
                             where   b.empNo is NULL  and a.line=@line and  a.IsEnabled='Y' ";
                if (model.status == 1)
                {
                    sql = @"select a.empNo ,a.empName ,b.PostName job , a.Status_flag  from mfg_onlinewip a ,m_auxiliary_manpower b where a.line=@line and a.work_date=@work_date
                         and a.line=b.line and a.empNo=b.WorkID";
                }
                rsp.data = DapperRepository.Query <StaffWorkInfo>(sql, new { line = model.line, shift = model.shift, work_date = model.workdate });
            }
            catch (Exception ex)
            {
                rsp.flag = 0;
                rsp.msg  = ex.Message.ToString();
            }
            return(rsp);
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            DapperRepository dapperRepository = new DapperRepository("Server=localhost;Database=Northwind;User Id=sa;pwd=1234xxx$@superpwd");
            int total = dapperRepository.ReadAll().Count;

            System.Console.WriteLine($"Total: {total}");
        }
Exemplo n.º 4
0
        public ActionResult Blacklist(string username)
        {
            var repo = new DapperRepository();

            repo.removeBlacklist(System.Web.HttpContext.Current.User.Identity.GetUserId(), username);
            return(new EmptyResult());
        }
        public SqlServerRepositoryFixture()
        {
            _settings = new ConnectionStringSettings
            {
                ConnectionString = "Data Source=.;Initial Catalog=dapperRepoTest;Integrated Security=true;Application Name=LyphTEC.Repository.Dapper.Tests;",
                Name             = "RepoTest",
                ProviderName     = "System.Data.SqlClient"
            };

            // being explicit here, but this should be default
            DapperExtensions.DapperExtensions.SqlDialect = new SqlServerDialect();

            var mappingAss = new[]
            {
                typeof(InvoiceMapper).Assembly,
                typeof(Address).Assembly
            };

            DapperRepository.SetMappingAssemblies(mappingAss);

            Cleanup();

            var scripts = new[]
            {
                "CreateCustomerTable",
                "CreateInvoiceTable"
            };

            ExecuteScripts(scripts);
        }
Exemplo n.º 6
0
        public Response <List <StaffWorkInfo> > getpostinfo(StaffOnlieModel model)
        {
            Response <List <StaffWorkInfo> > rsp = new Response <List <StaffWorkInfo> >();

            try
            {
                model.line = getUserLine(model.user);

                string sql = @"select a.empNo ,a.empName ,CASE when a.old_line is null then a.line else a.old_line end source_line ,a.line,a.shift_no,a.Status_flag,b.postname job
                             from mfg_onlinewip a ,m_auxiliary_manpower b
                             where a.line=b.line and a.empNo=b.WorkID
                             and a.line=@line and a.work_date=@work_date and a.Status_flag ='0' ";
                if (model.status == 1)
                {
                    sql = @"select a.empNo ,a.empName  ,a.line,a.shift_no,a.Status_flag,a.ligang_mark,a.ligang_time,b.postname job 
                         from mfg_onlinewip a ,m_auxiliary_manpower b
                          where a.line=b.line and a.empNo=b.WorkID
                        and a.line=@line and a.work_date=@work_date
                           and a.Status_flag ='1'";
                }
                rsp.data = DapperRepository.Query <StaffWorkInfo>(sql, new { line = model.line, shift = model.shift, work_date = model.workdate });
            }
            catch (Exception ex)
            {
                rsp.flag = 0;
                rsp.msg  = ex.Message.ToString();
            }
            return(rsp);
        }
Exemplo n.º 7
0
 /// <summary>
 /// </summary>
 public NpocOvsEFvsAdonetvsDapper()
 {
     _efRepo     = new EFRepository(conetionString);
     _npocoRepo  = new NpocoRepository(conetionString);
     _adodbRepo  = new AdodbRepository(conetionString);
     _dapperRepo = new DapperRepository(conetionString);
 }
Exemplo n.º 8
0
        /// <summary>
        /// 构造初始化
        /// </summary>
        public SharedService()
        {
            var dapperDbContext =
                new DapperDbContext(new SqlConnection(WebConfigSetting.Instance.I200DbConnectionString));

            _accountUser = new DapperRepository <AccountUser>(dapperDbContext);
        }
Exemplo n.º 9
0
 //SQLite存储float类型的话会有精度问题
 public SQLiteDatabaseTest()
 {
     Tools.MappingStrategyHelper.SetStrategy(IdentifierMappingStrategy.Underline);
     SQLiteHelper.CreateTableIfNoExist("dapper_all_test");
     SQLiteHelper.CreateTableIfNoExist("test_table");
     _dapper = MockGenerator();
 }
Exemplo n.º 10
0
        /// <summary>
        ///     初始化
        /// </summary>
        public SettingsService()
        {
            var dapperDbContext =
                new DapperDbContext(new SqlConnection(WebConfigSetting.Instance.I200DbConnectionString));

            _smsTemplateDapperRepository = new DapperRepository <SmsTemplates>(dapperDbContext);
        }
Exemplo n.º 11
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();

            //injeção de dependência dos bancos / connectionString
            Configuration = Injection.Configuration;
            var connectionString = Configuration["ConnectionStrings:SqlServer"];

            //injetando serviço do dapper
            var dapperContext    = new DapperContext(connectionString);
            var dapperRepository = new DapperRepository(dapperContext);
            var dapperService    = new DapperService(dapperRepository);

            services.AddSingleton <DapperService>(dapperService);

            //injetando serviço do entity
            var entityContext    = new EntityContext(connectionString);
            var entityRepository = new EntityRepository(entityContext);
            var entityService    = new EntityService(entityRepository);

            services.AddSingleton <EntityService>(entityService);


            //injetando serviço do datareader
            var readerContext    = new DataReaderContext(connectionString);
            var readerRepository = new DataReaderRepository(readerContext);
            var readerService    = new DataReaderService(readerRepository);

            services.AddSingleton <DataReaderService>(readerService);
        }
Exemplo n.º 12
0
        public ActionResult Blacklist()
        {
            var repo = new DapperRepository();

            ViewBag.list = repo.getBlockedUsernames(System.Web.HttpContext.Current.User.Identity.GetUserId());
            return(View());
        }
Exemplo n.º 13
0
        private void MockGenerator()
        {
            var optionsMock = new Mock <IOptions <DapperDatabaseOptions> >();
            var options     = new DapperDatabaseOptions
            {
                DefaultConnectionName = "default",
                ConnectionStrings     = new Dictionary <string, string>
                {
                    { "default", helper.ConnectionString }
                }
            };
            var builder = new DapperDataFeatureBuilder(options);

            builder.Conventions(convention =>
            {
                convention
                .AutoGenerateKey <TimeTest>(x => x.Id)
                .Ignore <TimeTest>(x => x.Time)
                .Types(s => s == typeof(TimeTest))
                .IsEntity();
            });
            builder.Build();
            optionsMock.Setup(o => o.Value).Returns(options);
            var loggerFactory = new LoggerFactory();

            loggerFactory.AddDebug(LogLevel.Trace);
            _testContext = new DapperContext(new DapperRuntime(optionsMock.Object,
                                                               new IDapperMetadataProvider[] { new DapperMetadataProviderInstance(), })
                                             , loggerFactory);
            _dapper  = new DapperRepository <DapperTestEntity>(_testContext);
            _dapper1 = new DapperRepository <TimeTest>(_testContext);
        }
Exemplo n.º 14
0
 public ArrearsDetailsService(DapperRepository repository,
                              IDbConnection context,
                              ArrearsDataService arrearsDataService)
 {
     _repository         = repository;
     _context            = context;
     _arrearsDataService = arrearsDataService;
 }
Exemplo n.º 15
0
 public MappingStrategyTest()
 {
     Tools.MappingStrategyHelper.SetStrategy(IdentifierMappingStrategy.Underline);
     helper = MySQLHelper.Default;
     helper.CreateDataBaseIfNoExist("test");
     helper.CreateTableIfNoExist(new[] { "dapper_all_test" });
     _dapper = MockGenerator();
 }
        public void SetFixture(SqlCeRepositoryFixture data)
        {
            _fixture      = data;
            _customerRepo = new DapperRepository <Customer>(data.Settings);
            _geRepo       = new DapperRepository <GuidEntity>(data.Settings);

            CustomerRepo = _customerRepo;
        }
        public void SetFixture(SQLiteRepositoryFixture data)
        {
            _fixture      = data;
            _customerRepo = new DapperRepository <Customer>(data.Settings);
            _invoiceRepo  = new DapperRepository <Invoice>(data.Settings);

            CustomerRepo = _customerRepo;
        }
Exemplo n.º 18
0
        private DapperRepository <WorkflowInstance> GetWorkflowInstanceRepo()
        {
            string dataConnectionString = ConfigurationManager.ConnectionStrings["BaseEAM"].ConnectionString;
            var    dapperContext        = new DapperContext(dataConnectionString);
            var    repo = new DapperRepository <WorkflowInstance>(dapperContext);

            return(repo);
        }
        public void Test()
        {
            var dapperRepository = new DapperRepository();

            var id = dapperRepository.Insert(new User {
                UserName = "******"
            });
        }
Exemplo n.º 20
0
 public LegacySupportTest()
 {
     Tools.MappingStrategyHelper.SetStrategy(IdentifierMappingStrategy.PascalCase);
     helper = MySQLHelper.Default;
     helper.CreateDataBaseIfNoExist("test");
     helper.CreateTableIfNoExist(new[] { "DapperAllTest" });
     _dapper = MockGenerator();
 }
Exemplo n.º 21
0
        public UserCouponService()
        {
            var dapperContext =
                new DapperDbContext(new SqlConnection(WebConfigSetting.Instance.I200DbConnectionString));

            _couponInfoDapperRepository = new DapperRepository <CouponInfo>(dapperContext);
            _couponListDapperRepository = new DapperRepository <CouponList>(dapperContext);
        }
Exemplo n.º 22
0
        public ActionResult ChangePicture()
        {
            var repo = new DapperRepository();
            var Id   = System.Web.HttpContext.Current.User.Identity.GetUserId();

            ViewBag.img = repo.getProfilePicture(Id);
            return(View());
        }
Exemplo n.º 23
0
        public IActionResult GetCustomer()
        {
            DapperRepository _DapperRepo = new DapperRepository();
            string           test        = "Postgrey";

            //cust = _DapperRepo.GetUsersWithDapper();
            return(Ok(test));
        }
Exemplo n.º 24
0
        public FeedbackService()
        {
            var dapperContext =
                new DapperDbContext(new SqlConnection(WebConfigSetting.Instance.I200SysDbConnectionString));

            _checkSysTaskDailyDapperRepository = new DapperRepository <string>(dapperContext);
            _sysTaskDailyDapperRepository      = new DapperRepository <SysTaskDaily>(dapperContext);
            _sysAccountDapperRepository        = new DapperRepository <SysAccount>(dapperContext);
        }
Exemplo n.º 25
0
        public ExpensesService()
        {
            var dapperDbContext =
                new DapperDbContext(new SqlConnection(WebConfigSetting.Instance.I200DbConnectionString));

            _expensesRepository         = new DapperRepository <PayRecord>(dapperDbContext);
            _expensesCategoryRepository = new DapperRepository <PayClass>(dapperDbContext);
            _cacheManager = new NullCache();
        }
Exemplo n.º 26
0
        public ActionResult ChangeInfo()
        {
            var repo = new DapperRepository();

            ViewBag.cityList = repo.getCities();
            var info = repo.getProfileInfo(System.Web.HttpContext.Current.User.Identity.GetUserId());

            return(View(info));
        }
Exemplo n.º 27
0
        /// <summary>
        /// 初始化
        /// </summary>
        public MoodService()
        {
            var dapperContext = new DapperDbContext(new SqlConnection(WebConfigSetting.Instance.I200DbConnectionString));

            _accountUserLogSignDapperRepository = new DapperRepository <LogSign>(dapperContext);
            _accountBusinessDapperRepository    = new DapperRepository <Business>(dapperContext);
            _accountUserLogInfoDapperRepository = new DapperRepository <LogInfo>(dapperContext);
            _accountMoodDapperRepository        = new DapperRepository <MoodInfo>(dapperContext);
        }
Exemplo n.º 28
0
        /// <summary>
        /// 初始化
        /// </summary>
        public ModuleService()
        {
            var dapperContext = new DapperDbContext(new SqlConnection(WebConfigSetting.Instance.I200DbConnectionString));

            _moduleDapperRepository            = new DapperRepository <Module>(dapperContext);
            _moduleAccountUserDapperRepository = new DapperRepository <AccountUserModule>(dapperContext);
            _moduleUserDapperRepository        = new DapperRepository <Entity.Model.Modules.AccountUserModule>(dapperContext);

            _accountBusinessDapperRepository = new DapperRepository <Business>(dapperContext);
        }
Exemplo n.º 29
0
        public OnlineMallService()
        {
            var dapperDbContext = new DapperDbContext(new SqlConnection(WebConfigSetting.Instance.I200DbConnectionString));

            _materialGoods     = new DapperRepository <T_MaterialGoods2>(dapperDbContext);
            _materalgoodspic   = new DapperRepository <T_MaterialGoodsPic>(dapperDbContext);
            _mobileEvaluation  = new DapperRepository <MobileEvaluation>(dapperDbContext);
            _receiveAddress    = new DapperRepository <T_Receiving_Address>(dapperDbContext);
            _receiveAddressAdd = new DapperRepository <ReceiveingAddressAdd>(dapperDbContext);
        }
Exemplo n.º 30
0
        /// <summary>
        /// 根据类型获取Repository对象
        /// </summary>
        /// <typeparam name="T">Repository对象类型</typeparam>
        /// <returns></returns>
        protected virtual DapperRepository <T> GetRepositoryInstance <T>(string connStr = null) where T : class, new()
        {
            if (_connection == null)
            {
                _connection = DbContextFactory.CreateDbConnection(ESqlConnector.MySql, connStr);
            }
            var repository = new DapperRepository <T>(_connection, ESqlConnector.MySql);

            return(repository);
        }