コード例 #1
0
 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);
 }