Exemplo n.º 1
0
        public static PageData <RuleConfig> GetConfigRules(int pageIndex, string keyWords, string requestType, string serviceName, int?runStatus, int?status)
        {
            var conn       = DapperDbContext.GetConnection;
            var sqlBuilder = new StringBuilder();

            sqlBuilder.AppendLine("select r.*,rownum as rowno from ruleconfig r where 1=1 ");
            if (!string.IsNullOrEmpty(keyWords))
            {
                sqlBuilder.AppendFormat("and (Upper(r.Description) like Upper('%{0}%') or Upper(r.Method) like Upper('%{0}%') or Upper(r.PostBody) like Upper('%{0}%') or Upper(r.ContentType) like Upper('%{0}%') or Upper(userName) like Upper('%{0}%')) ", keyWords.ToUpper()).AppendLine();
            }
            if (!string.IsNullOrEmpty(requestType))
            {
                sqlBuilder.AppendFormat("and upper(r.method) like Upper('%{0}%') ", requestType.ToUpper()).AppendLine();
            }
            if (runStatus.HasValue && runStatus > 0)
            {
                sqlBuilder.AppendFormat("and r.RunStatus = {0} ", runStatus.Value).AppendLine();
            }
            if (status.HasValue && status > 0)
            {
                sqlBuilder.AppendFormat("and r.status = {0} ", status.Value).AppendLine();
            }
            if (!string.IsNullOrEmpty(serviceName))
            {
                sqlBuilder.AppendFormat("and Upper(r.ServiceName) like Upper('%{0}') ", serviceName.ToUpper()).AppendLine();
            }

            return(DapperDbContext.ExecuteWithPageing <RuleConfig>(sqlBuilder.ToString(), pageIndex));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 构造初始化
        /// </summary>
        public SharedService()
        {
            var dapperDbContext =
                new DapperDbContext(new SqlConnection(WebConfigSetting.Instance.I200DbConnectionString));

            _accountUser = new DapperRepository <AccountUser>(dapperDbContext);
        }
Exemplo n.º 3
0
        private static void Query(DapperDbContext db)
        {
            var a1 = db.Query <User>(x => x.Name == "张三").Select(x => new { title = x.Name }).ToList();

            var a2 = db.Query <User>(x => x.Id > 0).ToList();

            var a3 = db.SqlQueryDynamic(" select * from users ", null);

            var a4 = db.Query <User>(x => x.Id == 12).FirstOrDefault();

            var a5    = db.Query <User>(x => x.Id > 1).OrderBy(x => x.Id).ThenByDescending(x => x.Age).ToList();
            var total = 0;

            var a6 = db.Query <User>(x => x.Id > 1).OrderBy(x => x.Id).ThenByDescending(x => x.Age).ToPageList(1, 5, out total);

            var a7 = db.Query <User>(x => x.Id > 0).GroupBy(x => x.Age).Select(x => x.Id).ToList();

            var a8 = db.Query <User>(x => x.Id > 0).Max(x => x.Id);

            var a9  = db.Query <User>().Where("age=1").FirstOrDefault();
            var id  = 10;
            var a10 = db.Query <User>(x => x.Id == id).FirstOrDefault();

            var g   = true;
            var a11 = db.Query <User>(x => x.Gender1 && x.Gender1 == g).FirstOrDefault();
        }
Exemplo n.º 4
0
        /// <summary>
        ///     初始化
        /// </summary>
        public SettingsService()
        {
            var dapperDbContext =
                new DapperDbContext(new SqlConnection(WebConfigSetting.Instance.I200DbConnectionString));

            _smsTemplateDapperRepository = new DapperRepository <SmsTemplates>(dapperDbContext);
        }
Exemplo n.º 5
0
        private void button2_Click(object sender, EventArgs e)
        {
            DapperDbContext context = new DapperDbContext(CurrentConfig.ConnectionString);
            var             list    = context.QueryAmountData(dateTimePicker1.Value, dateTimePicker2.Value);

            dataGridView1.DataSource = list;
        }
Exemplo n.º 6
0
        void refreshList()
        {
            DapperDbContext context = new DapperDbContext(CurrentConfig.ConnectionString);
            var             list    = context.QueryTableConfigs();

            dataGridView1.DataSource = list;
        }
Exemplo n.º 7
0
        public static PageData <MonitorLogRecordConfigView> GetConfigRulesWithLogs(int pageIndex, string keyWords, string method, string serviceName, int?status, DateTime beginTime, DateTime endTime)
        {
            var sqlBuilder = new StringBuilder();

            sqlBuilder.AppendLine("select m.responseMessage,m.ruleconfigid,m.operationtype,m.message,m.createtime,m.executetime,m.statusCode,m.statusCodeDescription,r.*,rownum as rowno from monitorlogrecord m inner join ruleconfig r on m.ruleconfigid = r.id where 1=1 ");
            if (!string.IsNullOrEmpty(keyWords))
            {
                sqlBuilder.AppendFormat("and (Upper(r.Description) like Upper('%{0}%') or Upper(r.Method) like Upper('%{0}%') or Upper(r.PostBody) like Upper('%{0}%') or Upper(r.ContentType) like Upper('%{0}%') or Upper(userName) like Upper('%{0}%')) ", keyWords.ToUpper()).AppendLine();
            }
            if (!string.IsNullOrEmpty(method))
            {
                sqlBuilder.AppendFormat("and upper(r.Method) like Upper('%{0}%') ", method.ToUpper()).AppendLine();
            }
            if (status.HasValue && status > 0)
            {
                sqlBuilder.AppendFormat("and r.Status = {0} ", status.Value).AppendLine();
            }
            if (!string.IsNullOrEmpty(serviceName))
            {
                sqlBuilder.AppendFormat("and upper(r.ServiceName) like Upper('%{0}') ", serviceName.ToUpper()).AppendLine();
            }

            sqlBuilder.AppendFormat("and m.CreateTime >= to_date('{0:yyyy-MM-dd}','yyyy-mm-dd') ", beginTime).AppendLine();
            sqlBuilder.AppendFormat("and m.CreateTime <= to_date('{0:yyyy-MM-dd}','yyyy-mm-dd') ", endTime.AddDays(1)).AppendLine();

            return(DapperDbContext.ExecuteWithPageing <MonitorLogRecordConfigView>(sqlBuilder.ToString(), pageIndex));
        }
Exemplo n.º 8
0
        public GoodsService()
        {
            var dapperDbContext =
                new DapperDbContext(new SqlConnection(WebConfigSetting.Instance.I200DbConnectionString));

            _goodsSummaryRepository = new DapperRepository <GoodsInfoSummary>(dapperDbContext);
        }
Exemplo n.º 9
0
        private void button1_Click(object sender, EventArgs e)
        {
            TableConfig item = new TableConfig
            {
                name       = textBox1.Text.Trim(),
                alias      = textBox2.Text.Trim(),
                url        = textBox3.Text.Trim(),
                Bid        = textBox4.Text.Trim(),
                sourcesite = comboBox1.SelectedItem.ToString().Trim()
            };

            try
            {
                DapperDbContext context = new DapperDbContext(CurrentConfig.ConnectionString);
                if (!context.InsertTableConfigs(item))
                {
                    MessageBox.Show("新增保存失败.");
                    return;
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
                return;
            }
            refreshList();
        }
Exemplo n.º 10
0
        /// <summary>
        /// 不同币种的订单和订单详情数据入库
        /// </summary>
        /// <param name="prefix"></param>
        /// <param name="order"></param>
        /// <param name="list"></param>
        private void RequestHandler_NotifyOrderData(string prefix, OrderEntity order, List <OrderDetailEntity> list)
        {
            DapperDbContext context = new DapperDbContext(CurrentConfig.ConnectionString);

            context.InsertOrderData(prefix, order, list);
            //BTMrefreshSign = true;
        }
Exemplo n.º 11
0
        public DefaultLogger()
        {
            var dapperDbContext = new DapperDbContext(new SqlConnection(WebConfigSetting.Instance.WebAPILogDbConnection));

            _requestlogRepository = new DapperRepository <RequestLog>(dapperDbContext);
            _logRepository        = new DapperRepository <Log>(dapperDbContext);
            _nLogger = new NLogger();
        }
Exemplo n.º 12
0
        public static int UpdateState(DapperDbContext db, long orderId, EnmOrderDetailState state)
        {
            var now = DateTime.Now;

            return(db.Update <OrderDetail>(x => x.Id == orderId, x => new OrderDetail {
                Status = state, ReceivingTime = now
            }));
        }
Exemplo n.º 13
0
 public static void Init(DapperDbContext db)
 {
     //var user = db.Query<User>(x => x.Name == "张三").FirstOrDefault();
     //Add(db);
     //Delete(db);
     Update(db, 200202, EnmUserGender.男);
     //Query(db);
 }
Exemplo n.º 14
0
        public UserCouponService()
        {
            var dapperContext =
                new DapperDbContext(new SqlConnection(WebConfigSetting.Instance.I200DbConnectionString));

            _couponInfoDapperRepository = new DapperRepository <CouponInfo>(dapperContext);
            _couponListDapperRepository = new DapperRepository <CouponList>(dapperContext);
        }
Exemplo n.º 15
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.º 16
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.º 17
0
        void BindBiCheckBoxList()
        {
            DapperDbContext context = new DapperDbContext(CurrentConfig.ConnectionString);
            var             list    = context.QueryTableConfigs();

            checkedListBox1.DataSource    = list;
            checkedListBox1.DisplayMember = "name";
            checkedListBox1.ValueMember   = "alias";
        }
Exemplo n.º 18
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.º 19
0
 public void Main()
 {
     using (IQuery con = new DapperDbContext(DatabaseConst.SMSGateway))
     {
         keywords = con.Query <QuizModel>("GetKeyword");
     }
     ipStr   = ConfigurationManager.AppSettings["SMSGWIPServer"];
     portStr = ConfigurationManager.AppSettings["SMSGWPortServer"];;
 }
Exemplo n.º 20
0
 public void Main()
 {
     using (IQuery con = new DapperDbContext(DatabaseConst.SMSGateway))
     {
         keywords = con.Query<QuizModel>("GetKeyword");
     }
     ipStr = ConfigurationManager.AppSettings["SMSGWIPServer"];
     portStr = ConfigurationManager.AppSettings["SMSGWPortServer"];;
 }
Exemplo n.º 21
0
        public BasicDataService()
        {
            var dapperDbContext =
                new DapperDbContext(new SqlConnection(WebConfigSetting.Instance.I200DbConnectionString));

            _addressBaseRepository    = new DapperRepository <AddressBase>(dapperDbContext);
            _accountRepository        = new DapperRepository <Entity.Model.Account.Account>(dapperDbContext);
            _userRankRepository       = new DapperRepository <UserRank>(dapperDbContext);
            _userInfoDetailRepository = new DapperRepository <UserInfoDetail>(dapperDbContext);
        }
Exemplo n.º 22
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.º 23
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.º 24
0
        private static void Delete(DapperDbContext db)
        {
            var user = db.Query <User>(x => x.Name == "张三").FirstOrDefault();

            db.Delete(user);
            Add(db);
            db.Delete <User>(x => x.Name == "张三");
            Add(db);
            db.DeleteAll <User>();
            Add(db);
        }
Exemplo n.º 25
0
 public void AddDbContext(DapperDbContext dbContext)
 {
     if (ActiveDbContexts.ContainsKey(dbContext.GetKey()))
     {
         return;
     }
     ActiveDbContexts.Add(dbContext.GetKey(), dbContext);
     if (_dbContextAddedEvent != null)
     {
         _dbContextAddedEvent(dbContext);
     }
 }
Exemplo n.º 26
0
        private static void Update(DapperDbContext db, int id, EnmUserGender g)
        {
            //var user = db.Query<User>(x => x.Name == "张三").FirstOrDefault();
            //user.Age = 20;

            var now = DateTime.Now;

            UpdateState(db, 3, EnmOrderDetailState.确认收货完成订单);
            //db.Update<User>(x => x.Id == id, x => new User { Gender = g, OpTime=now });
            //db.Update(user);
            //db.Update<User>(x => x.Name == "张三", x => new User { Gender = EnmUserGender.男 });
        }
Exemplo n.º 27
0
        private static void Add(DapperDbContext db)
        {
            var user = new User
            {
                Age     = 1,
                Gender  = EnmUserGender.女,
                Name    = "张三",
                OpTime  = DateTime.Now,
                Gender1 = true
            };

            db.Add <User>(user);
        }
Exemplo n.º 28
0
        public AdvertService()
        {
            _logger = new NLogger();

            var dapperDbContext =
                new DapperDbContext(new SqlConnection(WebConfigSetting.Instance.I200StationDbConnectionString));

            _advertDataRepository =
                new DapperRepository <Entity.Model.Advert.Advert>(dapperDbContext);
            _advertResourcesDataRepository =
                new DapperRepository <AdvertResources>(dapperDbContext);
            _advertLogDataRepository = new DapperRepository <AdvertLog>(dapperDbContext);
        }
        public UserStoreMoneyCardService()
        {
            var dapperDbContext =
                new DapperDbContext(new SqlConnection(WebConfigSetting.Instance.I200DbConnectionString));

            _userInfoRepository = new DapperRepository <UserInfoDetail>(dapperDbContext);
            _userLogRepository  = new DapperRepository <UserLogInfo>(dapperDbContext);
            _userStoreMoneyTransactionDapperRepository =
                new DapperRepository <UserStoreTransactionRecordResultItem>(dapperDbContext);
            _userStoreTransactionRecordSumRepository =
                new DapperRepository <UserStoreTransactionRecordResult>(dapperDbContext);
            _userStoreMoneyCardDapperRepository = new DapperRepository <UserStoreMoneySearchResultItem>(dapperDbContext);
            _useraddDapperRepository            = new DapperRepository <UserHandle>(dapperDbContext);
        }
Exemplo n.º 30
0
        /// <summary>
        /// 初始化
        /// </summary>
        public SalesService()
        {
            var dapperContext =
                new DapperDbContext(new SqlConnection(WebConfigSetting.Instance.I200DbConnectionString));

            _salesDapperRepository     = new DapperRepository <SalesInfo>(dapperContext);
            _salesListDapperRepository = new DapperRepository <SalesList>(dapperContext);
            _salesLogDapperRepository  = new DapperRepository <SaleLogInfo>(dapperContext);

            _goodsSummaryDapperRepository = new DapperRepository <GoodsInfoSummary>(dapperContext);

            _iUserTimesCardService      = new UserTimesCardService();
            _iUserStoreMoneyCardService = new UserStoreMoneyCardService();
            _iUserService = new UserService();

            _accountDapperRepository  = new DapperRepository <Entity.Model.Account.Account>(dapperContext);
            _userInfoDapperRepository = new DapperRepository <UserInfoDetail>(dapperContext);
            _userLogRepository        = new DapperRepository <UserLogInfo>(dapperContext);
        }
        public DapperDbContextDir(string tableName)
        {
            var key = settingDis.ContainsKey(tableName) ? tableName : "default";

            SqlConnectionString();
            config = settingDis[key];

            if (dicDbConnectionPool.ContainsKey(key))
            {
                return;
            }

            lock (dicDbConnectionPool)
            {
                if (!dicDbConnectionPool.ContainsKey(key))
                {
                    dicDbConnectionPool[key] = new DapperDbContext(config.ConnectionString);
                }
            }
        }
Exemplo n.º 32
0
 //public void OnDataSent(string data)
 //{
     
 //}
 
 public void OnDataReceived(string data)
 {
     List<BaseResult<SMSReadResult>> list = JsonHelper.JsonDeserialize<List<BaseResult<SMSReadResult>>>(data);
     if (list.Count > 0)
     {
         foreach (BaseResult<SMSReadResult> read in list)
         {
             if (read.Response.TypeName.Contains("SMSRead"))
             { 
                 if (keywords.Any())
                 {
                     foreach (QuizModel keyword in keywords)
                     {
                         Match match = new Regex(@"(.*[a-zA-Z]) (.*[a-zA-Z])").Match(keyword.Keyword); 
                         if (match.Success)
                         {
                             if (read.Response.Message.ToLower().Contains(match.Groups[1].Value.ToLower()))
                             {
                                 string[] arg = read.Response.Message.ToLower().Split(new string[] { match.Groups[1].Value.ToLower() }, StringSplitOptions.RemoveEmptyEntries);
                                 using (IQuery con = new DapperDbContext(DatabaseConst.SMSGateway))
                                 {
                                     List<Answer> result = con.Query<Answer>(keyword.Response, new { KeyID = arg[0].Trim() });
                                     if (result.Any())
                                     {
                                         smsSender = new GSMClient.Client(ipStr, Convert.ToInt32(portStr));
                                         smsSender.Open();
                                         smsSender.Send(string.Format(GSMClient.Command.CommandCollection.SMSSend, read.Response.From, result.SingleOrDefault().Description));
                                         smsSender.Close();
                                     }
                                 }
                                 break;
                             }
                         }  
                     }  
                 } 
             }
         } 
     }
 }