Beispiel #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //判断是否有登录
            if (Session["UserID"] != null)
            {
                Response.Redirect("Default.aspx");
            }

            if (!IsPostBack)
            {
                var dd = new DingClient();

                string accessToken = dd.GetToken(dd.AppKey, dd.AppSecret);
                string timestamp   = dd.GetTimestamp();
                string noncestr    = dd.GetNoncestr();
                string ticket      = dd.GetTicket(accessToken);
                string url         = dd.GetUrl();
                string signature   = dd.GetSignature(ticket, noncestr, timestamp, url);

                //dingding参数
                dic.Add("accessToken", accessToken);
                dic.Add("agentId", dd.AgentId);
                dic.Add("corpId", dd.CorpId);
                dic.Add("timeStamp", timestamp);
                dic.Add("nonceStr", noncestr);
                dic.Add("signature", signature);

                //if (Request.Cookies["UserCookie"] != null)
                //{
                //    this.UserName.Text = Request.Cookies["UserCookie"].Value;
                //}
            }
        }
Beispiel #2
0
        /// <summary>
        /// Executes a task
        /// </summary>
        public void Execute()
        {
            using (var db = new AALifeDbContext())
            {
                var    startDate = DateTime.Now.AddDays(-1).Date;
                var    endDate   = DateTime.Now.Date;
                var    result    = db.ItemTable.Where(a => a.ModifyDate >= startDate && a.ModifyDate < endDate);
                string msg       = string.Format("每日统计\n\n{0} 日,共记录消费 {1} 条。", startDate.ToString("yyyy/MM/dd"), result.Count());

                var    dd          = new DingClient();
                string accessToken = dd.GetToken(dd.AppKey, dd.AppSecret);

                //ding
                DingHelper.SendMessage(dd.AgentId, accessToken, "统计消息", msg, dd.AdminUser);
            }
        }