コード例 #1
0
        public List <Organization> GetList(TableObject table)
        {
            string CacheEnable = ConfigurationManager.AppSettings["CacheEnable"];
            string key         = CacheUtility.GetKey(table);
            object obj         = CacheUtility.Get(key);

            if (obj != null)
            {
                return((List <Organization>)obj);
            }
            string sqlStr = "select * from Organization where BranchID=@BranchID and SchoolID=@SchoolID and LastModified>@LastModified";

            List <MySqlParameter> pms = new List <MySqlParameter>();

            pms.Add(new MySqlParameter("BranchID", table.BranchID));
            pms.Add(new MySqlParameter("SchoolID", table.SchoolID));
            pms.Add(new MySqlParameter("LastModified", table.LastModifiedDate));
            //if (!string.IsNullOrEmpty(table.StartDate))
            //{
            //    sqlStr += " and OperateTime>@StartDate";
            //    pms.Add(new MySqlParameter("StartDate", table.StartDate));
            //}
            //if (!string.IsNullOrEmpty(table.EndDate))
            //{
            //    sqlStr += " and OperateTime<@EndDate";
            //    pms.Add(new MySqlParameter("EndDate", table.EndDate));
            //}
            List <Organization> list = OrganizationBLL.Search(sqlStr, pms.ToArray());

            if (list.Count > 0)
            {
                byte[] b = new byte[8];
                if (CacheUtility.GetCollectionKey(table.LastModified) == CacheUtility.GetCollectionKey(b))
                {
                    CacheUtility.Insert(key, list);
                }
                else
                {
                    if (CacheEnable == "true")
                    {
                        CacheUtility.Insert(key, list);
                    }
                }
            }
            return(list);
        }