public ActionResult AjaxPostAdd(FormCollection Fm) { if (base.currentUser == null) { return base.Content("NoLogin"); } if (base.currentUser.UserType == "AA") { return base.Content("AA"); } bool flag = Globals.SafeBool(Maticsoft.BLL.SysManage.ConfigSystem.GetValueByCache("SNSIsStatic"), false); string str = Fm["Type"]; string str2 = Fm["ImageUrl"]; string str3 = InjectionFilter.Filter(Fm["ShareDes"]); string str4 = Fm["VideoUrl"]; string str5 = Fm["PostExUrl"]; string str6 = Fm["AudioUrl"]; string productName = Fm["ProductName"]; int photoCateId = Globals.SafeInt(Fm["PhotoCateId"], 0); int ablumId = Globals.SafeInt(Fm["AblumId"], 0); long pid = Globals.SafeLong(Fm["Pid"], (long) 0L); string photoAddress = Fm["Address"]; string mapLng = Fm["MapLng"]; string mapLat = Fm["MapLat"]; base.PostsModel.Description = str3; base.PostsModel.CreatedDate = DateTime.Now; base.PostsModel.CreatedNickName = base.currentUser.NickName; base.PostsModel.CreatedUserID = base.currentUser.UserID; base.PostsModel.ImageUrl = str2; base.PostsModel.UserIP = base.Request.UserHostAddress; base.PostsModel.AudioUrl = str6; if (!string.IsNullOrWhiteSpace(base.PostsModel.ImageUrl) && (str != "Product")) { string savePath = "/Upload/SNS/Images/Photos/" + DateTime.Now.ToString("yyyyMMdd") + "/"; string saveThumbsPath = "/Upload/SNS/Images/PhotosThumbs/" + DateTime.Now.ToString("yyyyMMdd") + "/"; base.PostsModel.ImageUrl = Maticsoft.BLL.SNS.Photos.MoveImage(base.PostsModel.ImageUrl, savePath, saveThumbsPath); } if (str == "Product") { base.PostsModel.Type = 2; Maticsoft.BLL.SNS.Products products = new Maticsoft.BLL.SNS.Products(); if (products.Exsit(productName, base.currentUser.UserID)) { return base.Content("ProductRepeat"); } } else if (str == "Photo") { base.PostsModel.Type = 1; } else { base.PostsModel.Type = 0; if (!string.IsNullOrEmpty(str4) && !string.IsNullOrEmpty(str5)) { base.PostsModel.VideoUrl = str4; base.PostsModel.PostExUrl = str5; } } base.PostsModel.Status = 1; base.PostsModel = base.PostsBll.AddPost(base.PostsModel, ablumId, pid, photoCateId, photoAddress, mapLng, mapLat, true); base.PostsModel.Description = ViewModelBase.RegexNickName(base.PostsModel.Description); Maticsoft.ViewModel.SNS.Posts item = new Maticsoft.ViewModel.SNS.Posts(); if (!string.IsNullOrEmpty(base.PostsModel.ImageUrl) && (str != "Product")) { base.PostsModel.ImageUrl = base.PostsModel.ImageUrl.Split(new char[] { '|' })[0]; } if (base.PostsModel.Type == 2) { Maticsoft.Model.SNS.Products modelByCache = new Maticsoft.BLL.SNS.Products().GetModelByCache((long) base.PostsModel.TargetId); if (flag && (modelByCache != null)) { base.PostsModel.Description = (string) base.PostsModel.Description.Replace("{ProductUrl}", (dynamic) string.IsNullOrWhiteSpace(modelByCache.StaticUrl) ? ((((dynamic) base.ViewBag).BasePath + "Product/Detail/") + base.PostsModel.TargetId) : modelByCache.StaticUrl); } else { base.PostsModel.Description = (string) base.PostsModel.Description.Replace("{ProductUrl}", (((dynamic) base.ViewBag).BasePath + "Product/Detail/") + base.PostsModel.TargetId); } } item.Post = base.PostsModel; base.list.Add(item); return this.PartialView(base.CurrentThemeViewPath + "/UserProfile/LoadPostData.cshtml", base.list); }
public ActionResult AjaxAddBlog(FormCollection Fm) { if (base.currentUser == null) { return base.Content("NoLogin"); } if (base.currentUser.UserType == "AA") { return base.Content("AA"); } string str = InjectionFilter.Filter(Fm["Title"]); string str2 = Fm["Des"]; base.PostsModel.Description = str; base.PostsModel.CreatedDate = DateTime.Now; base.PostsModel.CreatedNickName = base.currentUser.NickName; base.PostsModel.CreatedUserID = base.currentUser.UserID; base.PostsModel.UserIP = base.Request.UserHostAddress; Maticsoft.Model.SNS.UserBlog blogModel = new Maticsoft.Model.SNS.UserBlog { Title = str, Description = str2, UserID = base.currentUser.UserID, UserName = base.currentUser.NickName, CreatedDate = DateTime.Now }; base.PostsModel.Status = 1; base.PostsModel = base.PostsBll.AddBlogPost(base.PostsModel, blogModel, true); base.PostsModel.Description = ViewModelBase.RegexNickName(base.PostsModel.Description); Maticsoft.ViewModel.SNS.Posts item = new Maticsoft.ViewModel.SNS.Posts(); base.PostsModel.Description = (string) base.PostsModel.Description.Replace("{BlogUrl}", (((dynamic) base.ViewBag).BasePath + "Blog/BlogDetail/") + base.PostsModel.TargetId); item.Post = base.PostsModel; base.list.Add(item); return this.PartialView(base.CurrentThemeViewPath + "/UserProfile/LoadPostData.cshtml", base.list); }
public List<Maticsoft.ViewModel.SNS.Posts> GetPostByType(int UserId, int StartIndex, int EndIndex, EnumHelper.PostType Type, int PostId, bool includeProduct = true) { List<Maticsoft.Model.SNS.Posts> list = new List<Maticsoft.Model.SNS.Posts>(); List<Maticsoft.Model.SNS.Posts> modelList = new List<Maticsoft.Model.SNS.Posts>(); Dictionary<int, Maticsoft.Model.SNS.Posts> dictionary = new Dictionary<int, Maticsoft.Model.SNS.Posts>(); List<Maticsoft.ViewModel.SNS.Posts> list3 = new List<Maticsoft.ViewModel.SNS.Posts>(); string strWhere = ""; string str2 = ""; switch (Type) { case EnumHelper.PostType.All: strWhere = " Status=" + 1; break; case EnumHelper.PostType.Fellow: strWhere = string.Concat(new object[] { " Status=", 1, " and CreatedUserId in (SELECT PassiveUserID FROM SNS_UserShip WHERE ActiveUserID=", UserId, " UNION SELECT ", UserId, ")" }); break; case EnumHelper.PostType.User: strWhere = string.Concat(new object[] { " Status=", 1, " and CreatedUserId=", UserId }); break; case EnumHelper.PostType.OnePost: strWhere = " PostID=" + PostId; break; case EnumHelper.PostType.ReferMe: strWhere = string.Concat(new object[] { " Status=", 1, " and PostID in (SELECT TagetID FROM SNS_ReferUsers WHERE ReferUserID=", UserId, " and Type=0)" }); break; case EnumHelper.PostType.EachOther: strWhere = string.Concat(new object[] { " Status=", 1, " and CreatedUserId in ( SELECT PassiveUserID FROM dbo.SNS_UserShip WHERE ActiveUserID=", UserId, " and Type=1)" }); break; case EnumHelper.PostType.Photo: strWhere = string.Concat(new object[] { " Status=", 1, " and CreatedUserId=", UserId, " and Type=", 1 }); break; case EnumHelper.PostType.Product: strWhere = string.Concat(new object[] { " Status=", 1, " and CreatedUserId=", UserId, " and Type=", 2 }); break; case EnumHelper.PostType.Video: strWhere = string.Concat(new object[] { " Status=", 1, " and CreatedUserId=", UserId, " and VideoUrl is not null" }); break; case EnumHelper.PostType.Blog: strWhere = string.Concat(new object[] { " Status=", 1, " and CreatedUserId=", UserId, " and Type=", 4 }); break; default: strWhere = "Status=" + 1; break; } if (!includeProduct) { strWhere = strWhere + " and Type<>" + 2; } list = this.DataTableToList(this.GetListByPage(strWhere, "PostId Desc", StartIndex, EndIndex).Tables[0]); int[] values = (from item in list where item.OriginalID != 0 select item.OriginalID).Distinct<int>().ToArray<int>(); string str3 = string.Join<int>(",", values); if (!string.IsNullOrEmpty(str3)) { str2 = "PostId in(" + str3 + ")"; modelList = this.GetModelList(str2); } foreach (Maticsoft.Model.SNS.Posts posts in modelList) { dictionary.Add(posts.PostID, posts); } foreach (Maticsoft.Model.SNS.Posts posts2 in list) { Maticsoft.ViewModel.SNS.Posts posts3 = new Maticsoft.ViewModel.SNS.Posts(); posts2.Description = ViewModelBase.RegexNickName(posts2.Description); posts3.Post = posts2; if (dictionary.ContainsKey(posts2.OriginalID)) { posts3.OrigPost = dictionary[posts2.OriginalID]; posts3.OrigPost.Description = ViewModelBase.RegexNickName(posts3.OrigPost.Description); } list3.Add(posts3); } if (Type == EnumHelper.PostType.ReferMe) { new Maticsoft.BLL.SNS.ReferUsers().UpdateReferStateToRead(UserId, 0); } return list3; }