public void CreateByTemp(String ids, ForumTopic topic) { int[] arrIds = cvt.ToIntArray(ids); if (arrIds.Length == 0) { return; } ForumTopicService topicService = new ForumTopicService(); ForumPost post = topicService.GetPostByTopic(topic.Id); int attachmentCount = 0; foreach (int id in arrIds) { AttachmentTemp _temp = AttachmentTemp.findById(id); if (_temp == null) { continue; } Attachment a = new Attachment(); a.AppId = _temp.AppId; a.Guid = _temp.Guid; a.FileSize = _temp.FileSize; a.Type = _temp.Type; a.Name = _temp.Name; a.Description = _temp.Description; a.ReadPermission = _temp.ReadPermission; a.Price = _temp.Price; a.TopicId = topic.Id; a.PostId = post.Id; a.OwnerId = topic.OwnerId; a.OwnerType = topic.OwnerType; a.OwnerUrl = topic.OwnerUrl; a.Creator = topic.Creator; a.CreatorUrl = topic.CreatorUrl; a.insert(); _temp.delete(); attachmentCount++; } if (attachmentCount > 0) { String msg = string.Format("上传附件 <a href=\"{0}\">{1}</a>,获得奖励", alink.ToAppData(topic), topic.Title); incomeService.AddIncome(topic.Creator, UserAction.Forum_AddAttachment.Id, msg); } topicService.UpdateAttachments(topic, attachmentCount); }
public void CreateByTemp(String ids, ForumTopic topic) { int[] arrIds = cvt.ToIntArray(ids); if (arrIds.Length == 0) { return; } ForumTopicService topicService = new ForumTopicService(); ForumPost post = topicService.GetPostByTopic(topic.Id); int attachmentCount = 0; foreach (int id in arrIds) { AttachmentTemp at = AttachmentTemp.findById(id); if (at == null) { continue; } Attachment a = new Attachment(); a.AppId = at.AppId; a.Guid = at.Guid; a.FileSize = at.FileSize; a.Type = at.Type; a.Name = at.Name; a.Description = at.Description; a.ReadPermission = at.ReadPermission; a.Price = at.Price; a.TopicId = topic.Id; a.PostId = post.Id; a.OwnerId = topic.OwnerId; a.OwnerType = topic.OwnerType; a.OwnerUrl = topic.OwnerUrl; a.Creator = topic.Creator; a.CreatorUrl = topic.CreatorUrl; a.insert(); at.delete(); attachmentCount++; } topicService.UpdateAttachments(topic, attachmentCount); }
//-------------------------------------------------------------------------------------------------------------- public virtual Result CreateTemp(AttachmentTemp a, User user, IMember owner) { a.OwnerId = owner.Id; a.OwnerType = owner.GetType().FullName; a.OwnerUrl = owner.Url; a.Creator = user; a.CreatorUrl = user.Url; a.Guid = Guid.NewGuid().ToString(); return(db.insert(a)); }
public virtual void DeleteTempAttachment(int id) { AttachmentTemp at = AttachmentTemp.findById(id); if (at == null) { return; } at.delete(); Img.DeleteImgAndThumb(at.FileUrl); }
private AttachmentTemp savePostData( HttpFile postedFile, Result result ) { // 将附件存入数据库 AttachmentTemp uploadFile = new AttachmentTemp(); uploadFile.FileSize = postedFile.ContentLength; uploadFile.Type = postedFile.ContentType; uploadFile.Name = result.Info.ToString(); uploadFile.Description = ctx.Post( "FileDescription" ); uploadFile.ReadPermission = ctx.PostInt( "FileReadPermission" ); uploadFile.Price = ctx.PostInt( "FilePrice" ); uploadFile.AppId = ctx.app.Id; attachService.CreateTemp( uploadFile, (User)ctx.viewer.obj, ctx.owner.obj ); return uploadFile; }
private AttachmentTemp savePostData(HttpFile postedFile, Result result) { // 将附件存入数据库 AttachmentTemp uploadFile = new AttachmentTemp(); uploadFile.FileSize = postedFile.ContentLength; uploadFile.Type = postedFile.ContentType; uploadFile.Name = result.Info.ToString(); uploadFile.Description = ctx.Post("FileDescription"); uploadFile.ReadPermission = ctx.PostInt("FileReadPermission"); uploadFile.Price = ctx.PostInt("FilePrice"); uploadFile.AppId = ctx.app.Id; attachService.CreateTemp(uploadFile, (User)ctx.viewer.obj, ctx.owner.obj); return(uploadFile); }
public void SaveUpload() { HttpFile postedFile = ctx.GetFileSingle(); Result result = Uploader.SaveFileOrImage(postedFile); if (result.HasErrors) { errors.Join(result); run(UploadForm); return; } AttachmentTemp uploadFile = savePostData(postedFile, result); // 返回数据给主页面 set("objFile", SimpleJsonString.ConvertObject(uploadFile)); set("deleteLink", to(DeleteTempAttachment)); }
public virtual void SaveUpload() { long boardId = ctx.GetLong("boardId"); HttpFile postedFile = ctx.GetFileSingle(); Result result = Uploader.SaveFileOrImage(postedFile); if (result.HasErrors) { errors.Join(result); run(UploadForm); return; } AttachmentTemp uploadFile = savePostData(postedFile, result); // 返回数据给主页面 set("objFile", Json.ToString(uploadFile.GetJsonObject())); set("deleteLink", to(DeleteTempAttachment) + "?boardId=" + boardId); }
public void SaveFlashUpload() { HttpFile postedFile = ctx.GetFileSingle(); Result result = Uploader.SaveFileOrImage(postedFile); if (result.HasErrors) { errors.Join(result); echoError(); return; } AttachmentTemp uploadFile = savePostData(postedFile, result); // 返回json给主页面 String json = "{deleteLink:'" + to(DeleteTempAttachment) + "', photo:" + SimpleJsonString.ConvertObject(uploadFile) + "}"; echoText(json); }
public virtual void SaveFlashUpload() { long boardId = ctx.GetLong("boardId"); HttpFile postedFile = ctx.GetFileSingle(); Result result = Uploader.SaveFileOrImage(postedFile); if (result.HasErrors) { logger.Error(result.ErrorsText); errors.Join(result); echoError(); return; } AttachmentTemp uploadFile = savePostData(postedFile, result); // 返回json给主页面 String photoJson = Json.ToString(uploadFile.GetJsonObject()); String json = "{\"deleteLink\":\"" + to(DeleteTempAttachment) + "?boardId=" + boardId + "\", \"photo\":" + photoJson + "}"; echoText(json); }
//-------------------------------------------------------------------------------------------------------------- public virtual Result CreateTemp( AttachmentTemp a, User user, IMember owner ) { a.OwnerId = owner.Id; a.OwnerType = owner.GetType().FullName; a.OwnerUrl = owner.Url; a.Creator = user; a.CreatorUrl = user.Url; a.Guid = Guid.NewGuid().ToString(); return db.insert( a ); }
public virtual DataPage <AttachmentTemp> GetByUser(int userId, int pageSize) { return(AttachmentTemp.findPage("OwnerId=" + userId, pageSize)); }