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);
        }