Exemplo n.º 1
0
        public override void After(object returnValue, MethodInfo method, object[] args, object target)
        {
            Microblog blog = args[0] as Microblog;

            if (blog == null || blog.ParentId > 0)
            {
                return;
            }
            if (blog.User == null || blog.User.Id <= 0)
            {
                return;
            }

            if (QQWeiboJobHelper.IsQQWeiboSync(blog.Id))
            {
                return;                                            // 是否已经同步过
            }
            UserConnect uc = ObjectContext.Create <UserConnectService>()
                             .GetConnectInfo(blog.User.Id, typeof(QQWeiboConnect).FullName);

            // 1. 检查:用户是否绑定,是否允许同步
            if (uc == null)
            {
                return;             // 绑定
            }
            if (uc.NoSync == 1)
            {
                logger.Info("取消同步,因为用户明确禁止");
                return;
            }

            // 2. 获取 access token
            AccessToken x = new AccessToken();

            x.Token = uc.AccessToken;
            x.Uid   = uc.Uid;

            // 3. 同步
            QQWeiboConnect connect = AuthConnectFactory.GetConnect(typeof(QQWeiboConnect).FullName) as QQWeiboConnect;

            connect.Publish(x, _blogContent, getPicDiskPath(blog.Pic));

            // 设置已经同步标记
            QQWeiboJobHelper.AddQQWeiboSyncItem(blog.Id);
        }
Exemplo n.º 2
0
 // 必须的默认参数
 private Dictionary<String, String> defaultParams( QQWeiboConnect connect )
 {
     Dictionary<String, String> items = new Dictionary<String, String>();
     items.Add( "oauth_consumer_key", connect.ConsumerKey );
     //items.Add( "access_token", accessToken );
     items.Add( "oauth_version", "2.a" );
     items.Add( "scope", "all" );
     items.Add( "openid", openId );
     items.Add( "format", "json" );
     items.Add( "clientip", "8.8.8.8" );
     return items;
 }