public virtual void UpdateCount(PhotoApp app) { int count = PhotoPost.count("AppId=" + app.Id); app.PhotoCount = count; app.update("PhotoCount"); }
// app count private void updateCountApp(PhotoApp app) { int count = db.count <PhotoPost>("AppId=" + app.Id); app.PhotoCount = count; db.update(app, "PhotoCount"); }
public virtual void UpdateCommentCount(PhotoApp app) { int count = PhotoPostComment.find("AppId=" + app.Id).count(); app.CommentCount = count; app.update("CommentCount"); }
private long getAlbumAppId(long userId) { PhotoApp app = photoService.GetByUser(userId); if (app == null) { return(0); } return(app.Id); }
private int getDefaultPhotoAppId(int userId) { PhotoApp photo = db.find <PhotoApp>("OwnerId=" + userId).first(); if (photo == null) { throw new Exception("the photo app is not found"); } return(photo.Id); }
public static String ToAdminAlbum(User u) { PhotoApp app = PhotoApp.find("OwnerId=" + u.Id).first(); if (app == null) { return(""); } return(Link.To(u, new Photo.Admin.AlbumController().List, app.Id)); }
private static PhotoAlbum createUserAlbum( User creator, PhotoApp app ) { PhotoAlbum album = new PhotoAlbum(); album.Name = "我的图片"; album.OwnerId = creator.Id; album.OwnerUrl = creator.Url; album.OwnerId = creator.Id; album.OwnerUrl = creator.Url; album.AppId = app.Id; album.insert(); return album; }
public virtual Result CreatePost( PhotoPost post, PhotoApp app ) { if (strUtil.IsNullOrEmpty( post.Title )) { post.Title = Path.GetFileNameWithoutExtension( post.DataUrl ); } post.Title = strUtil.CutString( post.Title, 30 ); Result result = db.insert( post ); if (result.IsValid) { this.updatePostCount( app ); } return result; }
public virtual void Photo() { PhotoApp app = photoAppService.GetByUser(ctx.owner.Id); if (app == null) { echoError("app不存在"); return; } String lnkApp = Link.To(ctx.owner.obj, new Photo.PhotoController().Index, app.Id); redirectDirect(lnkApp); }
private static PhotoAlbum createUserAlbum(User creator, PhotoApp app) { PhotoAlbum album = new PhotoAlbum(); album.Name = "我的图片"; album.OwnerId = creator.Id; album.OwnerUrl = creator.Url; album.OwnerId = creator.Id; album.OwnerUrl = creator.Url; album.AppId = app.Id; album.insert(); return(album); }
public virtual void Add() { User u = ctx.viewer.obj as User; PhotoApp app = photoService.GetByUser(u.Id); if (app == null) { echoError("请先添加PhotoApp"); return; } redirectUrl(Link.To(u, new Photo.Admin.PostController().Add, app.Id)); }
public virtual Result CreatePost(PhotoPost post, PhotoApp app) { if (strUtil.IsNullOrEmpty(post.Title)) { post.Title = Path.GetFileNameWithoutExtension(post.DataUrl); } post.Title = strUtil.CutString(post.Title, 30); Result result = db.insert(post); if (result.IsValid) { this.updatePostCount(app); } return(result); }
// flash上传(逐个保存) public void SaveUpload() { int albumId = ctx.PostInt("PhotoAlbumId"); int systemCategoryId = ctx.PostInt("SystemCategoryId"); if (ctx.HasUploadFiles == false) { echoText(lang("exPlsUpload")); return; } HttpFile file = ctx.GetFileSingle(); logger.Info(file.FileName + "=>" + file.ContentType); Result result = Uploader.SaveImg(file); if (result.HasErrors) { errors.Join(result); echoText(result.ErrorsText); } else { PhotoPost post = newPost(Path.GetFileNameWithoutExtension(file.FileName), result.Info.ToString(), albumId, systemCategoryId); PhotoApp app = ctx.app.obj as PhotoApp; postService.CreatePost(post, app); // 统计 User user = ctx.owner.obj as User; user.Pins = PhotoPost.count("OwnerId=" + user.Id); user.update("Pins"); // feed String photoHtml = string.Format("<a href='{0}'><img src='{1}'/></a> ", alink.ToAppData(post), post.ImgThumbUrl); String templateData = string.Format("photoCount: {0}, photos: \"{1}\" ", 1, photoHtml); templateData = "{" + templateData + "}"; TemplateBundle tplBundle = TemplateBundle.GetPhotoTemplateBundle(); feedService.publishUserAction((User)ctx.viewer.obj, typeof(PhotoPost).FullName, tplBundle.Id, templateData, "", ctx.Ip); echoAjaxOk(); } }
public virtual Result CreatePost(PhotoPost post, PhotoApp app) { if (strUtil.IsNullOrEmpty(post.Title)) { post.Title = Path.GetFileNameWithoutExtension(post.DataUrl); } post.Title = strUtil.CutString(post.Title, 30); Result result = db.insert(post); if (result.IsValid) { this.updateCountApp(app); this.updateCountAlbum(post.PhotoAlbum); String msg = string.Format("上传图片 <a href=\"{0}\">{1}</a>,得到奖励", alink.ToAppData(post), post.Title); incomeService.AddIncome(post.Creator, UserAction.Photo_CreatePost.Id, msg); } return(result); }
// flash上传(逐个保存) public void SaveUpload() { int albumId = ctx.PostInt("PhotoAlbumId"); int systemCategoryId = ctx.PostInt("SystemCategoryId"); if (ctx.HasUploadFiles == false) { echoText(lang("exPlsUpload")); return; } HttpFile file = ctx.GetFileSingle(); logger.Info(file.FileName + "=>" + file.ContentType); Result result = Uploader.SaveImg(file); if (result.HasErrors) { errors.Join(result); echoError(result); } else { PhotoPost post = newPost(Path.GetFileNameWithoutExtension(file.FileName), result.Info.ToString(), albumId, systemCategoryId); PhotoApp app = ctx.app.obj as PhotoApp; postService.CreatePost(post, app); // 统计 User user = ctx.owner.obj as User; user.Pins = PhotoPost.count("OwnerId=" + user.Id); user.update("Pins"); Dictionary <String, int> dic = new Dictionary <String, int>(); dic.Add("Id", post.Id); echoJsonMsg("ok", true, dic); } }
public List <PhotoApp> GetAppAll() { return(PhotoApp.findAll()); }
public PhotoApp GetByUser(int userId) { return(PhotoApp.find("OwnerId=" + userId).first()); }
public void Create() { int albumId = ctx.PostInt("PhotoAlbumId"); int systemCategoryId = ctx.PostInt("SystemCategoryId"); if (albumId <= 0) { errors.Add(alang("exAlbumSelect")); run(NewPost, albumId); return; } if (systemCategoryId <= 0) { errors.Add(alang("exSysCategoryRequire")); run(NewPost, albumId); return; } if (ctx.GetFiles().Count <= 0) { errors.Add(alang("exUploadImg")); run(NewPost, albumId); return; } List <PhotoPost> imgs = new List <PhotoPost>(); for (int i = 0; i < ctx.GetFiles().Count; i++) { HttpFile file = ctx.GetFiles()[i]; if (file.ContentLength < 10) { continue; } // 发生任何错误,则返回 Result result = Uploader.SaveImg(file); if (result.HasErrors) { echo(result.ErrorsHtml); return; } PhotoPost post = newPost(ctx.Post("Text" + (i + 1)), result.Info.ToString(), albumId, systemCategoryId); PhotoApp app = ctx.app.obj as PhotoApp; postService.CreatePost(post, app); imgs.Add(post); } // 如果没有上传的图片 if (imgs.Count == 0) { errors.Add(alang("exUploadImg")); run(NewPost, albumId); return; } // 统计 User user = ctx.owner.obj as User; user.Pins = PhotoPost.count("OwnerId=" + user.Id); user.update("Pins"); // feed消息 int photoCount = imgs.Count; String photoHtml = ""; foreach (PhotoPost post in imgs) { photoHtml += string.Format("<a href='{0}'><img src='{1}'/></a> ", alink.ToAppData(post), post.ImgThumbUrl); } String templateData = string.Format("photoCount: {0}, photos: \"{1}\" ", photoCount, photoHtml); templateData = "{" + templateData + "}"; TemplateBundle tplBundle = TemplateBundle.GetPhotoTemplateBundle(); feedService.publishUserAction((User)ctx.viewer.obj, typeof(PhotoPost).FullName, tplBundle.Id, templateData, "", ctx.Ip); echoRedirectPart(lang("opok"), to(new MyController().My), 1); }
private void updatePostCount( PhotoApp app ) { int count = db.count<PhotoPost>( "AppId=" + app.Id ); app.PhotoCount = count; db.update( app, "PhotoCount" ); }
private PhotoApp getPhotoAppByUser(User creator) { PhotoApp app = PhotoApp.find("OwnerId=" + creator.Id).first(); return(app); }
public virtual PhotoApp GetByUser(long userId) { return(PhotoApp.find("OwnerId=" + userId).first()); }
public virtual Result CreatePost( PhotoPost post, PhotoApp app ) { if (strUtil.IsNullOrEmpty( post.Title )) { post.Title = Path.GetFileNameWithoutExtension( post.DataUrl ); } post.Title = strUtil.CutString( post.Title, 30 ); Result result = db.insert( post ); if (result.IsValid) { updatePhotoSize( post ); this.updateCountApp( app ); this.updateCountAlbum( post.PhotoAlbum ); String msg = string.Format( "上传图片 <a href=\"{0}\">{1}</a>,得到奖励", alink.ToAppData( post ), post.Title ); incomeService.AddIncome( post.Creator, UserAction.Photo_CreatePost.Id, msg ); } return result; }
public virtual void UpdateCommentCount( PhotoApp app ) { int count = PhotoPostComment.find( "AppId=" + app.Id ).count(); app.CommentCount = count; app.update( "CommentCount" ); }
public virtual void UpdateCount( PhotoApp app ) { int count = PhotoPost.count( "AppId=" + app.Id ); app.PhotoCount = count; app.update( "PhotoCount" ); }
public void Create() { int albumId = ctx.PostInt("PhotoAlbumId"); int systemCategoryId = ctx.PostInt("SystemCategoryId"); if (albumId <= 0) { errors.Add(alang("exAlbumSelect")); run(NewPost, albumId); return; } if (systemCategoryId <= 0) { errors.Add(alang("exSysCategoryRequire")); run(NewPost, albumId); return; } if (ctx.GetFiles().Count <= 0) { errors.Add(alang("exUploadImg")); run(NewPost, albumId); return; } List <PhotoPost> imgs = new List <PhotoPost>(); for (int i = 0; i < ctx.GetFiles().Count; i++) { HttpFile file = ctx.GetFiles()[i]; if (file.ContentLength < 10) { continue; } // 发生任何错误,则返回 Result result = Uploader.SaveImg(file); if (result.HasErrors) { echo(result.ErrorsHtml); return; } PhotoPost post = newPost(ctx.Post("Text" + (i + 1)), result.Info.ToString(), albumId, systemCategoryId); PhotoApp app = ctx.app.obj as PhotoApp; postService.CreatePost(post, app); imgs.Add(post); } // 如果没有上传的图片 if (imgs.Count == 0) { errors.Add(alang("exUploadImg")); run(NewPost, albumId); return; } // 统计 User user = ctx.owner.obj as User; user.Pins = PhotoPost.count("OwnerId=" + user.Id); user.update("Pins"); // feed消息 addFeedInfo(imgs, albumId); echoRedirectPart(lang("opok"), to(new MyController().My), 1); }