Beispiel #1
0
        public async Task <ActionResult> ReportView(int id)
        {
            //todo:需要验证当前微信用户是否可以属于报工信息对应企业的策略提醒人
            var remindPersons = (await TacticManager.GetRemindPersonsByReport(id)).Select(o => o.Person);

            var currentPerson = await PersonManager.GetPersonByWeUserOrInsert(WeUser);

            if (!remindPersons.Contains(currentPerson))
            {
                return(Redirect("/WeiXin/Error?msg=" + "无权查看此报工信息".UrlEncode()));
            }

            var jssdkUiPackage = JSSDKHelper.GetJsSdkUiPackage(appId, appSecret, Request.AbsoluteUri());

            return(View(jssdkUiPackage));
        }
        public virtual void HandleEvent(EntityCreatedEventData <ProcessTaskReport> eventData)
        {
            //获取所有的被提醒人
            var remindInfos = _tacticManager.GetRemindPersonsByReport(eventData.Entity.Id).Result;

            foreach (var remindInfo in remindInfos)
            {
                var timespan     = remindInfo.GetAvailableRemindTimeSpan();
                var remindPerson = remindInfo.Person;
                var openid       = remindPerson.GetPropertyValue <string>("OpenId");
                //先产生一条提醒记录
                var remindLog = new RemindLog()
                {
                    RemindType = "报工提醒",
                    Name       = remindPerson.Name,
                    TenantId   = eventData.Entity.TenantId,
                    Message    = eventData.Entity.ReportType.ToString(),
                };
                if (timespan.TotalMinutes > 0)
                {
                    remindLog.SetPropertyValue("errMsg", $"延迟{timespan.TotalMinutes.ToString("0")}分钟后运行");
                }
                var remindLogId = RemindLogManager.InsertAndGetIdAsync(remindLog).Result;

                var arg = new SendWeiXinMessageJobArgs()
                {
                    OpenId      = openid,
                    DataId      = eventData.Entity.Id,
                    RemindLogId = remindLogId,
                };


                _backgroundJobManager.Enqueue <SendReportWeiXinMessageJob, SendWeiXinMessageJobArgs>(arg, BackgroundJobPriority.Normal, timespan);
                //_backgroundJobManager.Enqueue<SendReportWeiXinMessageJob, SendWeiXinMessageJobArgs>(arg);
                //WeiXin.WeiXinHelper.SendTemplateMessage(openid, templateId, url, message);
            }
            //_backgroundJobManager.Enqueue<SendReportWeiXinMessageJob, int>(eventData.Entity.Id);
        }