zoukankan      html  css  js  c++  java
  • 开张了

      终于在博客园开了空间,意味着,再也不用在Sohu Blog里粘代码了

      先粘两段爽一下:

    using System;
    using System.Web;
    using System.Collections;
    using System.Web.Services;
    using System.Web.Services.Protocols;
    using System.Collections.Generic;
    using System.Web.Caching;
    using System.Text;

    using IndieCommon;
    using IndieORM;
    using IndieDB;
    using IndieLogic;

    /// <summary>
    /// Vote 获取当前调查
    /// 的投票选项统计结果
    /// </summary>

    [WebService(Namespace = "http://localhost/")]
    [WebServiceBinding(ConformsTo 
    = WsiProfiles.BasicProfile1_1)]
    public class Vote : System.Web.Services.WebService
    {

        
    public Vote()
        
    {
            
            
    //如果使用设计的组件,请取消注释以下行 
            
    //InitializeComponent(); 
        }


        [WebMethod]
        
    public string GetVoteStatus()
        
    {
            
    // 缓存的键名
            string key = "CurrInvest";
            
    // 存储
            addInvestToCache(key);

            
    // 从缓存中获取
            Invest invest = (Invest)HttpContext.Current.Cache[key];

            
    返回结果
        }


        
    /// <summary>
        
    /// 缓存被删除回调方法
        
    /// </summary>
        
    /// <param name="key"></param>
        
    /// <param name="value"></param>
        
    /// <param name="reason">原因</param>

        private void removalCallBack(string key, object value, CacheItemRemovedReason reason)
        
    {
            
    // SQL依赖项被改变
            if (reason == CacheItemRemovedReason.DependencyChanged)
            
    {
                
    // 投票项被删除
                if (key == "CurrInvest")
                
    {
                    addInvestToCache(
    "CurrInvest");
                }

            }

        }


        
    /// <summary>
        
    /// 在缓存中插入最近一期INVEST对象
        
    /// </summary>
        
    /// <param name="key"></param>

        private void addInvestToCache(string key)
        
    {
            
    // 调查操作对象
            InvestOperation io = new InvestOperation();

            
    // 进行数据缓存
            if (HttpContext.Current.Cache[key] == null)
            
    {
                
    // 获取当前期调查            
                Invest currInvest = io.GetLastInvest();

                
    if (currInvest != null)
                
    {
                    
    // 数据库和表名
                    string datatabase = "Indie";
                    
    string tablename = "TB_INVEST";
                    SqlCacheDependency dependency 
    = new SqlCacheDependency(datatabase,tablename);
                    
    // 回调
                    CacheItemRemovedCallback removal = new CacheItemRemovedCallback(removalCallBack);

                    
    // SQL SERVER 依赖轮询缓存
                    HttpContext.Current.Cache.Insert("CurrInvest", currInvest, dependency
                        ,DateTime.MaxValue,Cache.NoSlidingExpiration,CacheItemPriority.Normal,
                        removal);
                }

            }

        }

    }



     

  • 相关阅读:
    第七节:扩展组件(lodash/富文本/echart/nprogress) 和 帮助类(日期格式化)
    第六节:基础组件(Cascader/Tab/Steps/Upload/TimeLine/alert) 之 参数/商品/订单
    第九节:Vuex简介、基本使用、核心功能(State、Mutation、Action、Getter) 和 案例实战演练
    第四节:基础组件(Breadcrumb、Card、Input、Dialog、Switch、Select、MessageBox) 之 用户管理
    第三节:基础组件(Container布局、NavMenu导航) 之 系统主页面搭建
    第二节:基础配置(路由、less、静态资源、axios、ESLint)、基础组件(Form、Message) 之登录页面搭建
    第七节:框架全面升级5.x版本及常规组件的升级和集成
    第一节:项目初始化(ElementUI、axios)、Git版本管理、基本环境搭建
    第八节:Vue Cli简介/安装、两种Create项目的方式、相关配置说明
    第三节:ES6模块化历史 及 默认、按需、直接导入导出、Vue单文件
  • 原文地址:https://www.cnblogs.com/moye/p/815602.html
Copyright © 2011-2022 走看看