Example #1
0
        private static int LoadFromDbase(Shotgun.Database.IBaseDataClass2 dBase)
        {
            var sql = "SELECT cpls.id,cpls.cp_pool_id,tn.sp_trone_id,tod.trone_id,trone_order_id,priority,"
                      + " ( cpls.status=1 and stn.status=1 and tn.status=1 and tod.disable=0 and stn.is_on_api=1) status"
                      + " FROM daily_config.tbl_cp_pool_set cpls "
                      + "left join tbl_cp_pool cpl on cpl.id= cpls.cp_pool_id "
                      + "left join tbl_trone_order tod on cpls.trone_order_id= tod.id "
                      + "left join tbl_trone tn on tn.id= tod.trone_id "
                      + "left join tbl_sp_trone stn on stn.id= tn.sp_trone_id "
                      + "where  cpl.status=1 ";
            var cmd = dBase.Command();

            cmd.CommandText = sql;
            System.Data.IDataReader rd = null;
            int c = 0;

            try
            {
                rd = dBase.ExecuteReader(cmd);
                lock (cache.SyncRoot)
                {
                    cache.ClearCache();
                    while (rd.Read())
                    {
                        PoolSetModel pm = new PoolSetModel();
                        pm.id             = rd.GetInt32(0);
                        pm.cp_pool_id     = rd.GetInt32(1);
                        pm.sp_trone_id    = rd.GetInt32(2);
                        pm.trone_id       = rd.GetInt32(3);
                        pm.trone_order_id = rd.GetInt32(4);
                        pm.priority       = rd.GetInt32(5);
                        pm.status         = rd.GetInt32(6);
                        cache.InsertItem(pm);
                        c++;
                    }
                }
            }
            finally
            {
                if (rd != null)
                {
                    rd.Dispose();
                }
                cmd.Dispose();
            }
            return(c);
        }
Example #2
0
        static IEnumerable <CustomFeeModel> LoadFromDBase(Shotgun.Database.IBaseDataClass2 dBase, int spTroneId, string customId)
        {
            var trones = LightDataModel.tbl_troneItem.GetTroneIdsBySptroneId(dBase, spTroneId);

            if (trones.Count() == 0)
            {
                return new CustomFeeModel[] { }
            }
            ;
            string sql;

            if (string.IsNullOrEmpty(customId))
            {//整个通道信息
                sql = string.Format("SELECT trone_id,fee_date= current_Date() isToday , sum(count)  FROM daily_log.tbl_custom_fee_count "
                                    + " where trone_id in({0}) "
                                    + " group by trone_id,isToday",
                                    string.Join(",", trones.Select(e => e.id)), DateTime.Today);
            }
            else
            {//用户计费信息
                sql = string.Format("SELECT trone_id,fee_date= current_Date() isToday , sum(count)  FROM daily_log.tbl_custom_fee_count "
                                    + " where trone_id in({0}) and custom_id='{1}'"
                                    + " group by trone_id,isToday",
                                    string.Join(",", trones.Select(e => e.id)), dBase.SqlEncode(customId));
            }


            var cmd = dBase.Command();

            cmd.CommandText = sql;
            System.Data.IDataReader dr  = null;
            List <CustomFeeModel>   rlt = new List <CustomFeeModel>();

            try
            {
                dr = dBase.ExecuteReader(cmd);
                while (dr.Read())
                {
                    var m = new CustomFeeModel();
                    m.CustomId = customId;
                    m.SpToneId = spTroneId;
                    m.TroneId  = dr.GetInt32(0);
                    m.Date     = dr.GetBoolean(1) ? DateTime.Today : DateTime.Today.AddDays(-1);
                    m.Count    = dr.GetInt32(2);
                    m.Fee      = decimal.ToInt32(100 * trones.First(e => e.id == m.TroneId).price);
                    rlt.Add(m);
                    cache.InsertItem(m);
                }
            }
            finally
            {
                if (dr != null)
                {
                    dr.Dispose();
                }
                cmd.Dispose();
            }
            if (rlt.Count == 0)
            {//表示该用户,日月限缓存已经建立
                var trone = trones.First();
                var m     = new CustomFeeModel();
                m.CustomId = customId;
                m.SpToneId = spTroneId;
                m.TroneId  = trone.id;
                m.Date     = DateTime.Today;
                m.Count    = 0;
                m.Fee      = decimal.ToInt32(100 * trone.price);
                rlt.Add(m);
                cache.InsertItem(m);
            }
            return(rlt);
        }