예제 #1
0
        public virtual void UpdateCount(PhotoApp app)
        {
            int count = PhotoPost.count("AppId=" + app.Id);

            app.PhotoCount = count;
            app.update("PhotoCount");
        }
예제 #2
0
        // app count
        private void updateCountApp(PhotoApp app)
        {
            int count = db.count <PhotoPost>("AppId=" + app.Id);

            app.PhotoCount = count;
            db.update(app, "PhotoCount");
        }
예제 #3
0
        public virtual void UpdateCommentCount(PhotoApp app)
        {
            int count = PhotoPostComment.find("AppId=" + app.Id).count();

            app.CommentCount = count;
            app.update("CommentCount");
        }
예제 #4
0
        private long getAlbumAppId(long userId)
        {
            PhotoApp app = photoService.GetByUser(userId);

            if (app == null)
            {
                return(0);
            }
            return(app.Id);
        }
예제 #5
0
        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);
        }
예제 #6
0
        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));
        }
예제 #7
0
        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;
        }
예제 #8
0
        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;
        }
예제 #9
0
        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);
        }
예제 #10
0
        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);
        }
예제 #11
0
        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));
        }
예제 #12
0
        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);
        }
예제 #13
0
        // 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();
            }
        }
예제 #14
0
        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);
        }
예제 #15
0
        // 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);
            }
        }
예제 #16
0
 public List <PhotoApp> GetAppAll()
 {
     return(PhotoApp.findAll());
 }
예제 #17
0
 public PhotoApp GetByUser(int userId)
 {
     return(PhotoApp.find("OwnerId=" + userId).first());
 }
예제 #18
0
        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);
        }
예제 #19
0
 private void updatePostCount( PhotoApp app )
 {
     int count = db.count<PhotoPost>( "AppId=" + app.Id );
     app.PhotoCount = count;
     db.update( app, "PhotoCount" );
 }
예제 #20
0
        private PhotoApp getPhotoAppByUser(User creator)
        {
            PhotoApp app = PhotoApp.find("OwnerId=" + creator.Id).first();

            return(app);
        }
예제 #21
0
 public virtual PhotoApp GetByUser(long userId)
 {
     return(PhotoApp.find("OwnerId=" + userId).first());
 }
예제 #22
0
        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;
        }
예제 #23
0
 public virtual void UpdateCommentCount( PhotoApp app )
 {
     int count = PhotoPostComment.find( "AppId=" + app.Id ).count();
     app.CommentCount = count;
     app.update( "CommentCount" );
 }
예제 #24
0
 public virtual void UpdateCount( PhotoApp app )
 {
     int count = PhotoPost.count( "AppId=" + app.Id );
     app.PhotoCount = count;
     app.update( "PhotoCount" );
 }
예제 #25
0
        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);
        }