コード例 #1
0
ファイル: BOAdv.cs プロジェクト: vothaituyen/netlife
        /// <summary>
        /// Dành cho trường hợp nhúng Embed vào trang của Ambient hoặc Infinity.
        /// </summary>
        /// <param name="zoneId"></param>
        /// <param name="catId"></param>
        /// <returns></returns>
        public static string GetAdvEmbedScriptItemById(int zoneId, int catId)
        {
            DataTable advItemById;
            string    cacheName = string.Format("GetAdvEmbedScriptItemById_{0}__{1}", zoneId, catId);
            var       fromCache = Utils.GetFromCache <string>(cacheName);

            if (fromCache == null)
            {
                using (MainDB ndb = new MainDB())
                {
                    advItemById = ndb.StoredProcedures.GetAdvItemById(zoneId, catId);
                }
                fromCache = string.Empty;
                string str3   = string.Empty;
                var    entity = new AdvItemEntity();
                int    num    = (advItemById != null) ? advItemById.Rows.Count : 0;
                for (int i = 0; i < num; i++)
                {
                    DataRow row = advItemById.Rows[i];

                    entity.Type = (row["Type"] != null) ? Utils.GetObj <int>(row["Type"]) : 0;

                    if (entity.Type == 5)
                    {
                        str3 += (row["SourceFile"] != null) ? Utils.GetObj <string>(row["SourceFile"]) : string.Empty;
                    }
                }
                str3 = str3.Trim();


                fromCache = str3 + fromCache;
                Utils.SaveToCacheDependency(TableName.DATABASE_NAME, new string[] { TableName.QUANGCAO_ITEM, TableName.ZONE_ITEM }, cacheName, fromCache);
            }
            return(fromCache);
        }
コード例 #2
0
ファイル: BOAdv.cs プロジェクト: vothaituyen/netlife
        // Methods
        public static List <AdvItemEntity> GetAdvByZoneId(int zoneId)
        {
            string cacheName = string.Format("GetAdvByZoneId_{0}", zoneId);
            List <AdvItemEntity> fromCache = Utils.Get_MemCache <List <AdvItemEntity> >(cacheName) ?? Utils.GetFromCache <List <AdvItemEntity> >(cacheName);

            if (fromCache == null)
            {
                DataTable advByZoneId;
                using (var ndb = new MainDB())
                {
                    advByZoneId = ndb.StoredProcedures.GetAdvByZoneId(zoneId);
                }
                int num = (advByZoneId != null) ? advByZoneId.Rows.Count : 0;
                if (num > 0)
                {
                    for (int i = 0; i < num; i++)
                    {
                        DataRow row  = advByZoneId.Rows[0];
                        var     item = new AdvItemEntity();
                        item.ID         = Utils.GetObj <int>(row["ID"]);
                        item.isActive   = (row["isActive"] != null) && Convert.ToBoolean(row["isActive"]);
                        item.Name       = Utils.GetObj <string>(row["Name"]);
                        item.SourceFile = Utils.GetObj <string>(row["SourceFile"]);
                        item.STT        = Utils.GetObj <int>(row["STT"]);
                        item.TargetUrl  = Utils.GetObj <string>(row["TargetUrl"]);
                        item.Type       = Utils.GetObj <int>(row["Type"]);
                        fromCache.Add(item);
                    }
                }

                if (!Utils.Add_MemCache(cacheName, fromCache))
                {
                    Utils.SaveToCacheDependency(TableName.DATABASE_NAME, TableName.QUANGCAO_ITEM, cacheName, fromCache);
                }
            }

            return(fromCache ?? (fromCache = new List <AdvItemEntity>()));
        }