private bool PushFeedToDiscuzCloud(TopicInfo topic, PostInfo post, AttachmentInfo[] attachments, int feedStatus) { //如果传入数据不合法,以及主题需要审核或者是回复可见的,需要付费的,就不推送到云平台 if (topic == null || post == null || topic.Tid < 0 || topic.Posterid < 0 || post.Tid != topic.Tid || post.Pid < 0 || topic.Displayorder < 0 || topic.Hide == 1 || topic.Price > 0 || post.Invisible != 0 || feedStatus < 0 || feedStatus > 3) { return(false); } UserConnectInfo userConnectInfo = DiscuzCloud.GetUserConnectInfo(topic.Posterid); if (userConnectInfo == null || feedStatus == 0) { return(false); } //设置用户自选的操作状态 userConnectInfo.AllowPushFeed = feedStatus; if (DiscuzCloud.PushFeedToDiscuzCloud(topic, post, attachments, userConnectInfo, ip, rootUrl)) { TopicPushFeedInfo feedInfo = new TopicPushFeedInfo(); feedInfo.TopicId = topic.Tid; feedInfo.Uid = topic.Posterid; feedInfo.AuthorToken = userConnectInfo.Token; feedInfo.AuthorSecret = userConnectInfo.Secret; DiscuzCloud.CreateTopicPushFeedLog(feedInfo); return(true); } return(false); }
/// <summary> /// 创建主题pushfeed到云平台的日志 /// </summary> /// <param name="feedInfo"></param> /// <returns></returns> public static int CreateTopicPushFeedLog(TopicPushFeedInfo feedInfo) { if (feedInfo == null || feedInfo.TopicId < 0 || feedInfo.Uid < 0 || feedInfo.AuthorToken.Length < 16 || feedInfo.AuthorSecret.Length < 16) { return(-1); } return(Data.DiscuzCloud.CreateTopicPushFeedLog(feedInfo)); }
/// <summary> /// 发送删除已发送feed的请求到云平台接口 /// </summary> /// <param name="feedInfo"></param> /// <param name="ip"></param> /// <returns></returns> public static bool DeletePushedFeedInDiscuzCloud(TopicPushFeedInfo feedInfo, string ip) { DiscuzCloudConfigInfo config = DiscuzCloudConfigs.GetConfig(); List <DiscuzOAuthParameter> parmlist = new List <DiscuzOAuthParameter>(); parmlist.Add(new DiscuzOAuthParameter("client_ip", ip)); parmlist.Add(new DiscuzOAuthParameter("thread_id", feedInfo.TopicId.ToString())); DiscuzOAuth oAuth = new DiscuzOAuth(); string queryStr = ""; string deleteFeedUrl = oAuth.GetOAuthUrl(API_CONNECT_URL + "connect/feed/remove", "POST", config.Connectappid, config.Connectappkey, feedInfo.AuthorToken, feedInfo.AuthorSecret, "", "", parmlist, out queryStr); Utils.GetHttpWebResponse(deleteFeedUrl, queryStr); return(true); }
/// <summary> /// 获取指定主题id的pushfeed日志的信息 /// (当论坛删除某主题时,需要调用该方法以判断该主题是否有feed到云平台,如果有该主题的信息, /// 则需要使用日志中记录的作者accessToken和accessSecret值来调用云平台接口,删除之前的feed) /// </summary> /// <param name="tid"></param> /// <returns></returns> public static TopicPushFeedInfo GetTopicPushFeedLog(int tid) { IDataReader reader = DatabaseProvider.GetInstance().GetTopicPushFeedLog(tid); TopicPushFeedInfo feedInfo = null; if (reader.Read()) { feedInfo = new TopicPushFeedInfo(); feedInfo.TopicId = TypeConverter.ObjectToInt(reader["tid"]); feedInfo.Uid = TypeConverter.ObjectToInt(reader["uid"]); feedInfo.AuthorToken = reader["authortoken"].ToString(); feedInfo.AuthorSecret = reader["authorsecret"].ToString(); reader.Close(); } return(feedInfo); }
private bool DeletePushedFeedInCloud(int tid) { if (tid < 0) { return(false); } TopicPushFeedInfo feedInfo = DiscuzCloud.GetTopicPushFeedLog(tid); if (feedInfo == null) { return(false); } bool result = DiscuzCloud.DeletePushedFeedInDiscuzCloud(feedInfo, ip); if (result) { DiscuzCloud.DeleteTopicPushFeedLog(tid); } return(true); }
/// <summary> /// 创建主题pushfeed到云平台的日志 /// </summary> /// <param name="feedInfo"></param> /// <returns></returns> public static int CreateTopicPushFeedLog(TopicPushFeedInfo feedInfo) { return(DatabaseProvider.GetInstance().CreateTopicPushFeedLog(feedInfo)); }