/// <summary>
        /// 从缓存中获取日月限制
        /// </summary>
        /// <param name="spTroneId"></param>
        /// <param name="cpId"></param>
        /// <param name="date"></param>
        /// <returns></returns>
        public static tbl_day_month_limitItem GetOrCreateItem(IBaseDataClass2 dBase, int spTroneId, int cpId, DateTime date)
        {
            var m = cache.FindFirstData(e => e.sp_trone_id == spTroneId && e.cp_id == cpId && e.fee_date.Date == date.Date);

            if (m != null)
            {
                return(m);
            }

            var l = GetQueries(dBase);

            l.Filter.AndFilters.Add(Fields.sp_trone_id, spTroneId);
            l.Filter.AndFilters.Add(Fields.cp_id, cpId);
            l.Filter.AndFilters.Add(Fields.fee_date, date.Date);
            m = l.GetRowByFilters();
            if (m != null)
            {
                cache.InsertItem(m);
                return(m);
            }

            m             = new tbl_day_month_limitItem();
            m.fee_date    = date.Date;
            m.cp_id       = cpId;
            m.sp_trone_id = spTroneId;

            return(m);
        }
Beispiel #2
0
 public DynamicTableList(IBaseDataClass2 dBase, string SchemaName, string fixTabName, DateTime date)
 {
     this.Schema        = SchemaName;
     this._fixTableName = fixTabName;
     this.TableDate     = date;
     base.dBase         = dBase;
 }
Beispiel #3
0
        /// <summary>
        /// 此方法用于静态方法GetRowById()并填充自己,如无数据则销毁自身。
        /// 不能用于其它方式调用
        /// </summary>
        /// <param name="id"></param>
        /// <param name="dBase"></param>
        /// <returns></returns>
        protected R getRowById(int id, IBaseDataClass2 dBase)
        {
            if (dBase == null)
            {
                this.Dispose();
                throw new NullReferenceException("数据库对像不能为空");
            }

            if (this.PrimaryKey.Length != 1)
            {
                this.Dispose();
                throw new Exception("表[" + this.TableName + "] 主键数量不等于1");
            }
            string sql = "select * from [{0}] where {1}={2}";

            if (dBase is IBaseDataSpecial &&
                ((IBaseDataSpecial)dBase).FieldMask == Shotgun.Model.Filter.EM_Safe_Field_MASK.MySQLMode)
            {
                sql = "select * from `{0}` where {1}={2}";
            }

            sql = string.Format(sql, this.TableName, this.PrimaryKey[0].ColumnName, id);

            try
            {
                dBase.TableFill(sql, this);
            }
            catch
            {
                this.Dispose();
                throw;
            }
            if (this.Rows.Count == 0)
            {
                this.Dispose();
                return(null);
            }
            return(this[0]);
        }
Beispiel #4
0
        /// <summary>
        /// 根据传手机或IMSI查得归属地,优先手机号
        /// </summary>
        /// <param name="dBase"></param>
        /// <returns>始终不为空</returns>
        public static LightDataModel.tbl_cityItem GetCityInfo(IBaseDataClass2 dBase, string phone, string imsi)
        {
            if (string.IsNullOrEmpty(phone) && string.IsNullOrEmpty(imsi))
            {
                return new LightDataModel.tbl_cityItem()
                       {
                           id = 416, province_id = 32
                       }
            }
            ;

            if (phone == null)
            {
                phone = string.Empty;
            }

            int spNum = 0;

            if (phone.Length == 11 && phone.StartsWith("1"))//传统手机
            {
                int.TryParse(phone.Substring(0, 7), out spNum);
            }
            else if (phone.Length != 15) //非手机号 非IMSI
            {
                phone = imsi;
                if (string.IsNullOrEmpty(phone) || phone.Length != 15)
                {
                    return new LightDataModel.tbl_cityItem()
                           {
                               id = 416, province_id = 32
                           }
                }
                ;
            } //else 长为15

            if (spNum == 0)
            {
                if (phone.Length == 15 && phone.StartsWith("460"))//IMSI
                {
                    var t = GetPhoneByImsi(phone);

                    if (string.IsNullOrEmpty(t) || t.Length != 7)
                    {
                        return new LightDataModel.tbl_cityItem()
                               {
                                   id = 416, province_id = 32
                               }
                    }
                    ;
                    spNum = int.Parse(t);
                }
                else
                {
                    return new LightDataModel.tbl_cityItem()
                           {
                               id = 416, province_id = 32
                           }
                };
            }



            var cityInfo = LightDataModel.tbl_phone_locateItem.GetRowByMobile(dBase, spNum);

            if (cityInfo == null)
            {
                return new LightDataModel.tbl_cityItem()
                       {
                           id = 416, province_id = 32
                       }
            }
            ;

            return(cityInfo);
        }
    }
}
Beispiel #5
0
 public static LightDataModel.tbl_cityItem FillAreaInfo(IBaseDataClass2 dBase, Logical.ISMS_DataItem m)
 {
     return n8wan.Public.Library.GetCityInfo(dBase, m.mobile, m.imsi);
 }
 /// <summary>
 /// 从缓存中获取日月限制
 /// </summary>
 /// <param name="spTroneId"></param>
 /// <param name="cpId"></param>
 /// <param name="date"></param>
 /// <returns></returns>
 public static tbl_day_month_limitItem GetOrCreateItem(IBaseDataClass2 dBase, int spTroneId, int cpId)
 {
     return(GetOrCreateItem(dBase, spTroneId, cpId, DateTime.Today));
 }
Beispiel #7
0
        protected R getRowById(int id, IBaseDataClass2 dBase, string[] Fields)
        {
            if (dBase == null)
            {
                this.Dispose();
                throw new NullReferenceException("数据库对像不能为空");
            }

            Shotgun.Model.Filter.EM_Safe_Field_MASK fieldMask;

            if (dBase is IBaseDataSpecial &&
                ((IBaseDataSpecial)dBase).FieldMask == Shotgun.Model.Filter.EM_Safe_Field_MASK.MySQLMode)
            {
                fieldMask = Shotgun.Model.Filter.EM_Safe_Field_MASK.MySQLMode;
            }
            else
            {
                fieldMask = Shotgun.Model.Filter.EM_Safe_Field_MASK.MsSQLMode;
            }


            ClearEmptyColume(this, Fields);
            if (this.PrimaryKey.Length != 1)
            {
                this.Dispose();
                throw new Exception("表[" + this.TableName + "] 主键数量不等于1,或不包括在输出列中");
            }

            string sql = string.Empty;

            if (Fields == null || Fields.Length != 0)
            {
                sql = "select * ";
            }
            else
            {
                if (fieldMask == Shotgun.Model.Filter.EM_Safe_Field_MASK.MySQLMode)
                {
                    foreach (string f in Fields)
                    {
                        sql += ",`" + f + "`";
                    }
                }
                else
                {
                    foreach (string f in Fields)
                    {
                        sql += ",[" + f + "]";
                    }
                }
                sql = "select " + sql.Substring(1);
            }

            if (fieldMask == Shotgun.Model.Filter.EM_Safe_Field_MASK.MySQLMode)
            {
                sql += string.Format(" from `{0}` where {1}={2}", this.TableName, this.PrimaryKey[0].ColumnName, id);
            }
            else
            {
                sql += string.Format(" from [{0}] where {1}={2}", this.TableName, this.PrimaryKey[0].ColumnName, id);
            }



            try
            {
                dBase.TableFill(sql, this);
            }
            catch
            {
                this.Dispose();
                throw;
            }
            if (this.Rows.Count == 0)
            {
                this.Dispose();
                return(null);
            }
            return(this[0]);
        }
Beispiel #8
0
        public static PoolSetModel TroneOrderToPoolSetMode(IBaseDataClass2 dBase, int troneOrderId)
        {
            var          data = cache.GetCacheData(false);
            PoolSetModel m    = null;

            if (data == null)
            {//此处要保证正常poolset的加载
                QueryPoolSetById(dBase, 0);
            }
            else
            {
                lock (cache.SyncRoot)
                {
                    m = data.FirstOrDefault(e => e.trone_order_id == troneOrderId);
                }
            }
            if (m != null)
            {
                return(m);
            }

            var sql = "select sp_trone_id,tod.trone_id  ,  ( stn.status=1 and tn.status=1 and tod.disable=0 and stn.is_on_api=1) status "
                      + " FROM tbl_trone_order tod "
                      + " 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 tod.id= " + troneOrderId;
            var cmd = dBase.Command();

            cmd.CommandText = sql;
            IDataReader dr = null;

            m = new PoolSetModel();
            m.trone_order_id = troneOrderId;
            m.id             = 100000 + troneOrderId;
            m.priority       = 30;

            try
            {
                dr = dBase.ExecuteReader(cmd);
                if (!dr.Read())
                {
                    m.status = 0;
                }
                else
                {
                    m.sp_trone_id = dr.GetInt32(0);
                    m.trone_id    = dr.GetInt32(1);
                    m.status      = dr.GetInt32(2);
                }
            }
            finally
            {
                if (dr != null)
                {
                    dr.Dispose();
                }
                cmd.Dispose();
            }

            lock (cache)
                cache.InsertItem(m);

            return(m);
        }
Beispiel #9
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="dBase"></param>
 /// <param name="fixTabName">固定的表头名</param>
 public DynamicTableList(IBaseDataClass2 dBase, string SchemaName, string fixTabName)
     : this(dBase, SchemaName, fixTabName, DateTime.Today)
 {
 }