• .net4缓存笔记


    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using HR.BusinessLogic.Control;
    using HR.BusinessLogic.Report;
    using BMSP.DBAccesser.DBScript;
    using System.Runtime.Caching;
    using HR.Model.Customer;
    using System.Data;
    
    namespace HR.UI.Reports
    {
        public partial class TmallMan : SysBasePage
        {
            public List<string> tps = new List<string>();
            public string BeginDate = DateTime.Now.ToString("yyyy-01-01");
            public string EndDate = DateTime.Now.ToString("yyyy-01-31");
            public string NowDate = DateTime.Now.AddMonths(-1).ToString("yyyyMM");
    
            protected void Page_Load(object sender, EventArgs e)
            {
                top1.mRoleId = SysUser.ROLE_ID;
                TmallAction vAction = new TmallAction();
                tps = vAction.GetTypes();
                ObjectCache oc = MemoryCache.Default;
                if (!oc.Contains("products"))
                {
                    List<ProductModel> list = new List<ProductModel>();
                    DBManager vDBManager = new DBManager();
                    vDBManager.ConnectionOpen();
                    try
                    {
                        string sql = @"SELECT PRODUCTID,PRODUCTNAME 
                            FROM (select PRODUCTID,PRODUCTNAME from XXX GROUP BY PRODUCTID,PRODUCTNAME
                            UNION ALL 
                            select PRODUCTID,PRODUCTNAME from XXX GROUP BY PRODUCTID,PRODUCTNAME) v 
                            GROUP BY PRODUCTID,PRODUCTNAME";
                        DataTable dt = vDBManager.Query(sql).Tables[0];
                        int num = 0;
                        if (dt != null) 
                        {
                            num = dt.Rows.Count;
                            foreach (DataRow dr in dt.Rows) 
                            {
                                ProductModel vModel = new ProductModel();
                                vModel.ProductId = dr["PRODUCTID"].ToString();
                                vModel.ProductName = dr["PRODUCTNAME"].ToString();
                                list.Add(vModel);
                            }
                            dt.Dispose();
                        }
                        string isql = "insert into cache_log (ldate,luser,lnum) values (sysdate,:luser,:lnum)";
                        vDBManager.AddParameter(":luser", SysUser.USER_ID);
                        vDBManager.AddParameter(":lnum", num);
                        vDBManager.ExecuteSql(isql);
                    }
                    catch (Exception ex)
                    {
    
                    }
                    finally 
                    {
                        vDBManager.ConnectionClose();
                    }
                    CacheItemPolicy cp = new CacheItemPolicy();
                    oc.Set("products", list, cp);
                }
            }
        }
    }
  • 相关阅读:
    深圳移动 神州行(大众卡/轻松卡/幸福卡)套餐资费(含香港日套餐)信息及使用方法
    PHP设置时区,记录日志文件的方法
    微信公众平台消息接口使用指南
    C#日期时间格式化
    使用CMD实现批量重命名[转]
    Python高效编程技巧
    实用WordPress后台MySQL操作命令
    ubuntu-wine
    Javascript 笔记与总结(2-8)对象2
    Swift5.3 语言指南(十) 枚举
  • 原文地址:https://www.cnblogs.com/wpcnblog/p/6090096.html
Copyright © 2020-2023  润新知