/// <summary> /// 加载feed信息 /// </summary> /// <param name="reader"></param> /// <returns></returns> private static MiniFeedInfo LoadSingleFeedInfo(IDataReader reader) { MiniFeedInfo feedInfo = new MiniFeedInfo(); feedInfo.FeedId = TypeConverter.ObjectToInt(reader["feedid"]); feedInfo.Uid = TypeConverter.ObjectToInt(reader["uid"]); feedInfo.FeedType = (FeedTypeEnum)TypeConverter.ObjectToInt(reader["feedtype"]); feedInfo.AppId = TypeConverter.ObjectToInt(reader["appid"]); feedInfo.UserName = reader["username"].ToString(); feedInfo.DateTime = reader["datetime"].ToString(); feedInfo.TitleTemplate = reader["titletemplate"].ToString(); feedInfo.TitleData = reader["titledata"].ToString(); feedInfo.BodyTemplate = reader["bodytemplate"].ToString(); feedInfo.BodyData = reader["bodydata"].ToString(); feedInfo.BodyGeneral = reader["bodygeneral"].ToString(); feedInfo.Image1Url = reader["image1"].ToString(); feedInfo.Image1Link = reader["image1link"].ToString(); feedInfo.Image2Url = reader["image2"].ToString(); feedInfo.Image2Link = reader["image2link"].ToString(); feedInfo.Image3Url = reader["image3"].ToString(); feedInfo.Image3Link = reader["image3link"].ToString(); feedInfo.Image4Url = reader["image4"].ToString(); feedInfo.Image4Link = reader["image4link"].ToString(); return feedInfo; }
public string PublishTemplatizedAction() { try { //JsonParams = "{\"uId\":\"1\",\"appId\":1048438,\"titleTemplate\":\"{actor} \u6dfb\u52a0\u4e86 {app} \u5e94\u7528\",\"titleData\":{},\"bodyTemplate\":null,\"bodyData\":[],\"bodyGeneral\":null,\"image1\":null,\"image1Link\":null,\"image2\":null,\"image2Link\":null,\"image3\":null,\"image3Link\":null,\"image4\":null,\"image4Link\":null,\"targetIds\":null,\"privacy\":\"public\",\"hashTemplate\":null,\"hashData\":null}"; PublishTemplatizedActionParams actionParams = JavaScriptConvert.DeserializeObject<PublishTemplatizedActionParams>(UnicodeToString(JsonParams).Replace("[]", "{}"));//将PHP的空keyvalue数组格式json转换为.net的空keyvalue数组格式 MiniFeedInfo feedInfo = new MiniFeedInfo(); feedInfo.Uid = actionParams.Uid; feedInfo.UserName = Forum.Users.GetShortUserInfo(actionParams.Uid).Username; feedInfo.AppId = actionParams.AppId; feedInfo.FeedType = FeedTypeEnum.Application; feedInfo.BodyGeneral = actionParams.BodyGeneral ?? string.Empty; feedInfo.BodyTemplate = actionParams.BodyTemplate ?? string.Empty; feedInfo.TitleTemplate = actionParams.TitleTemplate ?? string.Empty; feedInfo.BodyData = actionParams.BodyData.Count == 0 ? "" : JavaScriptConvert.SerializeObject(actionParams.BodyData); feedInfo.TitleData = actionParams.TitleData.Count == 0 ? "" : JavaScriptConvert.SerializeObject(actionParams.TitleData); feedInfo.Image1Link = actionParams.Image1Link ?? string.Empty; feedInfo.Image1Url = actionParams.Image1Url ?? string.Empty; feedInfo.Image2Link = actionParams.Image2Link ?? string.Empty; feedInfo.Image2Url = actionParams.Image2Url ?? string.Empty; feedInfo.Image3Link = actionParams.Image3Link ?? string.Empty; feedInfo.Image3Url = actionParams.Image3Url ?? string.Empty; feedInfo.Image4Link = actionParams.Image4Link ?? string.Empty; feedInfo.Image4Url = actionParams.Image4Url ?? string.Empty; return GetResult(MiniFeeds.PublishFeed(feedInfo) > 0); } catch (Exception e) { return e.ToString(); } }
/// <summary> /// 发布feed信息 /// </summary> /// <param name="feedInfo"></param> /// <returns></returns> public static int PublishFeed(MiniFeedInfo feedInfo) { if (feedInfo.Uid <= 0) return 0; return Data.MiniFeeds.PublishFeed(feedInfo); }
/// <summary> /// 发布feed信息 /// </summary> /// <param name="feedInfo"></param> /// <returns></returns> public static int PublishFeed(MiniFeedInfo feedInfo) { return DatabaseProvider.GetInstance().PublishFeed(feedInfo); }