Пример #1
0
        public override void Executing(IJobExecutionContext context)
        {
            var broker           = PersistBrokerFactory.GetPersistBroker();
            var focusUserService = new FocusUserService();
            var user             = UserIdentityUtil.GetCurrentUser();
            var focusUserList    = focusUserService.GetFocusUserList();

            Logger.Debug($"获取到{focusUserList.count}条微信公众号关注用户");
            if (focusUserList.count > 0)
            {
                var user_list = new List <OpenId>();
                focusUserList.data.openid.ForEach(item => user_list.Add(new OpenId()
                {
                    openid = item, lang = "zh_CN"
                }));
                var focusUsers = focusUserService.GetFocusUsers(JsonConvert.SerializeObject(new { user_list }));
                broker.ExecuteTransaction(() =>
                {
                    var dataList = focusUsers.user_list
                                   .Select(focusUser =>
                    {
                        var wechat_user = new wechat_user()
                        {
                            Id              = focusUser.openid,
                            subscribe       = Convert.ToInt32(focusUser.subscribe),
                            nickname        = focusUser.nickname,
                            name            = focusUser.nickname,
                            sex             = focusUser.sex,
                            language        = focusUser.language,
                            city            = focusUser.city,
                            province        = focusUser.province,
                            country         = focusUser.country,
                            headimgurl      = focusUser.headimgurl,
                            subscribe_time  = focusUser.subscribe_time.ToDateTime(),
                            unionid         = focusUser.unionid,
                            remark          = focusUser.remark,
                            groupid         = focusUser.groupid,
                            subscribe_scene = focusUser.subscribe_scene,
                            qr_scene        = focusUser.qr_scene,
                            qr_scene_str    = focusUser.qr_scene_str,
                            createdBy       = user.Id,
                            createdByName   = user.Name,
                            modifiedBy      = user.Id,
                            modifiedByName  = user.Name,
                            createdOn       = DateTime.Now,
                            modifiedOn      = DateTime.Now,
                        };
                        return(wechat_user);
                    })
                                   .ToList();
                    broker.BulkCreateOrUpdate(dataList);
                    Logger.Debug($"创建或更新{dataList.Count}条关注用户信息");
                });
            }
        }
Пример #2
0
        /// <summary>
        /// 修改密码
        /// </summary>
        /// <param name="password"></param>
        public void EditPassword(string password)
        {
            var sql       = $@"
UPDATE auth_user
SET password = @password
WHERE user_infoid = @id;
";
            var user      = UserIdentityUtil.GetCurrentUser();
            var paramList = new Dictionary <string, object>()
            {
                { "@id", user.Id }, { "@password", password }
            };

            Broker.Execute(sql, paramList);
        }
Пример #3
0
 public FriendBlogProfile()
 {
     CreateMap <Jobs.SyncBlogJob.BlogDetail, FriendBlog.friend_blog>()
     .ForMember(dest => dest.Id, opt => opt.MapFrom(item => item.id))
     .ForMember(dest => dest.name, opt => opt.MapFrom(item => item.title))
     .ForMember(dest => dest.content, opt => opt.MapFrom(item => item.content))
     .ForMember(dest => dest.description, opt => opt.MapFrom(item => item.description))
     .ForMember(dest => dest.createdOn, opt => opt.MapFrom(item => item.createTime.ToDateTime()))
     .ForMember(dest => dest.createdBy, opt => opt.MapFrom(item => UserIdentityUtil.GetCurrentUserId()))
     .ForMember(dest => dest.createdByName, opt => opt.MapFrom(item => UserIdentityUtil.GetCurrentUser().Name))
     .ForMember(dest => dest.modifiedOn, opt => opt.MapFrom(item => item.updateTime.ToDateTime()))
     .ForMember(dest => dest.modifiedBy, opt => opt.MapFrom(item => UserIdentityUtil.GetCurrentUserId()))
     .ForMember(dest => dest.modifiedByName, opt => opt.MapFrom(item => UserIdentityUtil.GetCurrentUser().Name))
     .ForMember(dest => dest.first_picture, opt => opt.MapFrom(item => item.firstPicture));
 }
Пример #4
0
        public override void Executing(IJobExecutionContext context)
        {
            var broker = PersistBrokerFactory.GetPersistBroker();

            Logger.Debug("开始同步微信公众号图文素材");
            try
            {
                broker.ExecuteTransaction(() =>
                {
                    var result   = new WeChatNewsService(broker).GetDataList(1, 5000);
                    var user     = UserIdentityUtil.GetCurrentUser() ?? UserIdentityUtil.GetSystem();
                    var dataList = (from item in result.item
                                    let news = item.content.news_item.FirstOrDefault()
                                               select new wechat_news()
                    {
                        wechat_newsId = item.media_id,
                        html_content = new WeChatNewsMaterialService(broker).ConvertWeChatUrlToLocalUrl(news?.content),
                        media_id = item.media_id,
                        update_time = item.update_time,
                        name = news?.title,
                        author = news?.author,
                        digest = news?.digest,
                        thumb_media_id = news?.thumb_media_id,
                        content_source_url = news?.content_source_url,
                        createdBy = user.Id,
                        createdByName = user.Name,
                        modifiedBy = user.Id,
                        modifiedByName = user.Name,
                        createdOn = DateTime.Now,
                        modifiedOn = DateTime.Now,
                    })
                                   .ToList();
                    broker.BulkCreateOrUpdate(dataList);
                    Logger.Debug($"发现{result.item_count}篇文章需要同步");
                    Logger.Debug($"同步微信公众号图文素材成功,共同步:{dataList.Count()}篇文章");
                });
            }
            catch (Exception e)
            {
                Logger.Error("同步微信公众号图文素材失败", e);
            }
        }