Exemplo n.º 1
0
        public async Task <ActionResult> BindReminder(int id)
        {
            var info = UserApi.Info(appId, WeUser.openid);

            if (info.subscribe == 0)
            {
                return(Redirect("/WeiXin/GuanZhu"));
            }
            var tactic = await TacticManager.Repository.GetAll().IgnoreQueryFilters().Where(o => o.Id == id).SingleOrDefaultAsync();

            if (tactic == null)
            {
                return(Redirect("/WeiXin/Error?msg=" + "未找到对应提醒策略".UrlEncode()));
            }
            var bindPersons = await TacticManager.GetTacticReminders(id);

            if (bindPersons.Exists(o => o.GetPropertyValue <string>("OpenId") == WeUser.openid))
            {
                return(Redirect("/WeiXin/Error?msg=" + "您已经绑定此提醒策略".UrlEncode()));
            }

            ViewBag.TenancyName = tactic.Tenant != null?tactic.Tenant.TenancyName:"管理系统";
            ViewBag.TacticName  = tactic.TacticName;
            ViewBag.TacticId    = id;
            return(View());
        }
Exemplo n.º 2
0
        public virtual void HandleEvent(EntityCreatedEventData <Tenant> eventData)
        {
            try
            {
                var tactic = _tacticManager.GetAll().IgnoreQueryFilters().Where(o => o.TacticName == "注册提醒" && o.TenantId == null && o.IsActive).FirstOrDefault();
                if (tactic != null)
                {
                    //获取所有的被提醒人
                    var remindPersons = _tacticManager.GetTacticReminders(tactic.Id).Result;
                    foreach (var remindPerson in remindPersons)
                    {
                        var openid = remindPerson.GetPropertyValue <string>("OpenId");
                        var arg    = new SendRegisteredMessageJobArgs()
                        {
                            OpenId      = openid,
                            TenancyName = eventData.Entity.TenancyName,
                            Mobile      = eventData.Entity.GetPropertyValue <string>("Mobile"),
                            PersonName  = eventData.Entity.GetPropertyValue <string>("PersonName")
                        };

                        //发送注册提醒至管理人员
                        _backgroundJobManager.Enqueue <SendRegisteredMessageJob, SendRegisteredMessageJobArgs>(arg);
                    }
                }
            }
            catch
            {
            }
        }