zoukankan      html  css  js  c++  java
  • asp.net 定时器

    using System;
    using System.Collections.Generic;
    using System.Web;
    using System.IO;
    using System.Web.Security;
    using System.Web.SessionState;
    using System.Net.Mail;
    using System.Configuration;
    using CCWOnline.Management.iknow.Web;
    using CSI.Management.Model;
    using CCWOnline.Management.Web.MyServiceChampion.Interface;
    using System.Linq;
    using System.Data;

    namespace website
    {
    public class GlobalSuper : System.Web.HttpApplication
    {
    protected void Application_Start(object sender, EventArgs e)
    {
    // 在应用程序启动时运行的代码 Create by wuyaunyaun 2014/02/28 星魔力抽奖活动
    System.Timers.Timer timer = new System.Timers.Timer(1000);//每秒钟执行以
    timer.AutoReset = true;
    timer.Enabled = true;
    timer.Elapsed += new System.Timers.ElapsedEventHandler(EachDayJob);//使用委托
    }

    protected void Session_Start(object sender, EventArgs e)
    {

    }

    protected void Application_BeginRequest(object sender, EventArgs e)
    {

    }

    protected void Application_AuthenticateRequest(object sender, EventArgs e)
    {

    }

    protected void Application_Error(object sender, EventArgs e)
    {
    Exception exception = this.Server.GetLastError();
    HttpResponse Response = this.Response;
    HttpRequest Request = this.Request;

    //发送调试邮件
    if (exception != null && ConfigurationManager.AppSettings["DebugerEnable"].ToLower() == "true")
    {
    if (exception.InnerException != null)
    {
    SendErrorEmail(exception.InnerException);
    }
    else
    {
    SendErrorEmail(exception);
    }


    //跳转到错误页
    // string errorPage = System.Web.Configuration.WebConfigurationManager.AppSettings["ErrorPage"];
    // Response.Redirect(errorPage);
    }


    }

    protected void Session_End(object sender, EventArgs e)
    {

    }

    protected void Application_End(object sender, EventArgs e)
    {

    }

    protected void SendErrorEmail(Exception e)
    {

    }

    protected string ParseTemplate(Exception e)
    {

    }


    /// <summary>
    /// 定时抽奖事件
    /// Create By wuyaunyaun 2014/02/28
    /// </summary>
    /// <param name="source"></param>
    /// <param name="e"></param>
    #region
    void EachDayJob(object source, System.Timers.ElapsedEventArgs e)//执行的事件
    {
        EachDayAward();
    }

    protected void EachDayAward()//自定义要执行的方法
    {

    }


    /// <summary>
    /// 获取中奖奖品名称
    /// </summary>
    /// <param name="Turntable"></param>
    /// <returns></returns>
    protected string Getname(List<ZhiWeiClass> Turntable)
    {
       return LuckDrow(Turntable).ZhiWei;
    }

    /// <summary>
    /// 计算概率
    /// </summary>
    /// <param name="Turntable"></param>
    /// <returns></returns>
    private ZhiWeiClass LuckDrow(List<ZhiWeiClass> Turntable)
    {
    Random Rnd = new Random();
    return (from x in Enumerable.Range(0, 1000000) //最多支100万次骰子
    let ZhiWeiClass = Turntable[Rnd.Next(Turntable.Count())]
    let Sieve = Rnd.Next(0, 100)
    where Sieve < ZhiWeiClass.Chance
    select ZhiWeiClass).First();
    }
    #endregion

    }
    }

  • 相关阅读:
    Feature分支
    Bug分支
    分支管理策略
    解决冲突
    创建与合并分支
    分支管理
    Java并发与多线程教程(1)
    Java Thread(线程)案例详解sleep和wait的区别
    Spring在Thread中注入Bean无效的解决方式
    浅谈Java中的hashcode方法
  • 原文地址:https://www.cnblogs.com/wwy224y/p/3611847.html
Copyright © 2011-2022 走看看