コード例 #1
0
ファイル: PostPartHandler.cs プロジェクト: YSRE/SuperRocket
        private void UpdateThreadVersioningDates(PostPart postPart)
        {
            var utcNow = _clock.UtcNow;

            postPart.ThreadPart.As <ICommonPart>().ModifiedUtc        = utcNow;
            postPart.ThreadPart.As <ICommonPart>().VersionModifiedUtc = utcNow;
        }
コード例 #2
0
ファイル: CountersService.cs プロジェクト: jon123/NGM.Forum
        public void UpdateCounters(PostPart postPart)
        {
            if (postPart.IsParentThread())
                return;

            UpdateThreadPartAndForumPartCounters(postPart);
        }
コード例 #3
0
        private void UpdatePostCount(PostPart postPart)
        {
            if (postPart.IsParentThread())
                return;

            UpdateThreadPartCounters(postPart);
        }
コード例 #4
0
 public static string PostView(this UrlHelper urlHelper, PostPart postPart, Pager pager)
 {
     if (pager.Page >= 2)
         return string.Format("{0}#{1}", ThreadView(urlHelper, postPart.ThreadPart, pager), postPart.Id);
     else
         return PostView(urlHelper, postPart);
 }
コード例 #5
0
ファイル: PostPartHandler.cs プロジェクト: YSRE/SuperRocket
        private void UpdateCounters(PostPart postPart)
        {
            if (postPart.IsParentThread())
            {
                return;
            }

            UpdateThreadPartCounters(postPart);
        }
コード例 #6
0
 public void Consume(PostPartImageUpdatedAction message)
 {
     try
     {
         using (FsoContext db = new FsoContext())
         {
             PostPart     postPart = db.Set <PostPart>().FirstOrDefault(f => f.Id == message.PostPartId);
             AppMediaFile appFile  = db.Set <AppMediaFile>().FirstOrDefault(f => f.PostPartId == message.PostPartId);
             if (appFile == null)
             {
                 appFile = new AppMediaFile()
                 {
                     FileExtension   = message.FileExtension,
                     ImageDimension  = message.Dimension,
                     SmallPath       = message.SmallImageUrl,
                     ThumbPath       = message.ThumbImageUrl,
                     ResizedPath     = message.LargeImageUrl,
                     BlurLazyPath    = message.LazyImageUrl,
                     PostPart        = postPart,
                     DateUtcAdd      = DateTime.UtcNow,
                     DateUtcModified = DateTime.UtcNow
                 };
                 db.Set <AppMediaFile>().Add(appFile);
             }
             else
             {
                 appFile.FileExtension   = message.FileExtension;
                 appFile.BlurLazyPath    = message.LazyImageUrl;
                 appFile.ImageDimension  = message.Dimension;
                 appFile.SmallPath       = message.SmallImageUrl;
                 appFile.ThumbPath       = message.ThumbImageUrl;
                 appFile.ResizedPath     = message.LargeImageUrl;
                 appFile.PostPart        = postPart;
                 appFile.DateUtcModified = DateTime.UtcNow;
                 db.Set <AppMediaFile>().Update(appFile);
             }
             int z = db.SaveChanges();
             if (z > 0)
             {
                 Console.WriteLine("PostPart Update Image Activity Handled For PostPart {0} and Image {1}", message.PostPartId, message.ThumbImageUrl);
             }
             else
             {
                 Console.WriteLine("PostPart Update Image Activity CANNOT Handled For PostPart {0} and Image {1}", message.PostPartId, message.ThumbImageUrl);
             }
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("PostPart Update Image Activity CANNOT Handled For PostPart {0} and Image {1}", message.PostPartId, message.ThumbImageUrl);
         Console.WriteLine(ex.Message);
         if (ex.InnerException != null)
         {
             Console.WriteLine(ex.InnerException.Message);
         }
     }
 }
コード例 #7
0
 public static string PostView(this UrlHelper urlHelper, PostPart postPart, Pager pager)
 {
     if (pager.Page >= 2)
     {
         return(string.Format("{0}#{1}", ThreadView(urlHelper, postPart.ThreadPart, pager), postPart.Id));
     }
     else
     {
         return(PostView(urlHelper, postPart));
     }
 }
コード例 #8
0
ファイル: PostPartHandler.cs プロジェクト: six006/NGM.Forum
        private void UpdateThreadPartCounters(PostPart postPart) {
            var commonPart = postPart.As<CommonPart>();
            if (commonPart != null &&
                commonPart.Record.Container != null) {

                ThreadPart threadPart = postPart.ThreadPart ??
                                        _threadService.Get(commonPart.Record.Container.Id, VersionOptions.Published);

                threadPart.PostCount = _postService.Count(threadPart, VersionOptions.Published);

                UpdateForumPartCounters(threadPart);
            }
        }
コード例 #9
0
        public bool SendEmailNotificationToSubscribers(PostPart postPart)
        {
            var threadPart = postPart.ThreadPart;
            var subscriptionsToThread = _threadSubscriptionRepository.Table.Where(e => e.ThreadId == threadPart.Id && e.EmailUpdates == true).ToList();
            //if there are subscribed users
            if (subscriptionsToThread.Count > 0)
            {
                //it is possible that the subscribed user no longer exists (i.e. has been deleted from the system)
                var subscribedUserIds = subscriptionsToThread.Select( t=>t.UserId ).ToList();
                var userParts = _userRepository.Table.Where(user => subscribedUserIds.Contains(user.Id)).ToList();
                if (userParts.Count > 0)
                {
                    var usersCultures = _userPreferredCultureService.GetUsersCultures(userParts.Select( user=>user.Id).ToList());
                    foreach (var culture in usersCultures.Keys)
                    {
                        var userList = userParts.Where( user=> usersCultures[culture].Contains( user.Id)).ToList();

                        //it would be possible to use the BCC to send to all subscribed users provided that the list is 'reasonable' in length 
                        //i.e. 100 or less otherwise the mail server may truncate or refuse to send.
                        //that approach however won't work with the orchard email channel because it requires a MailMessage.To recipient and misses the 
                        //case that an email is sent BCC only.
                        foreach (var user in userList)
                        {
                            if (!String.IsNullOrWhiteSpace(user.Email))
                            {
                                var urlHelper = new UrlHelper(HttpContext.Current.Request.RequestContext);
                                string baseUrl = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority);


                                var postUrl = baseUrl + urlHelper.Action("ViewPostInThread", "Thread", new { postId=postPart.Id});
                               
                                
                                var translationEmail = _subscriptionEmailTemplateService.GetEmailTemplateTranslation(culture, postPart.ThreadPart.Title, postPart.Text, postPart.Format, postUrl, _orchardServices.WorkContext.CurrentSite.BaseUrl);
                                MessageContext messageContext = new MessageContext();
                                messageContext.MailMessage.Subject = translationEmail.Title;
                                messageContext.MailMessage.Body = translationEmail.BodyPlainText;
                                messageContext.MailMessage.To.Add(user.Email);
                                AlternateView altView = AlternateView.CreateAlternateViewFromString(translationEmail.BodyHtml, System.Text.Encoding.UTF8, "text/html");
                                messageContext.MailMessage.AlternateViews.Add(altView);
                                messageContext.MailMessage.BodyEncoding = System.Text.Encoding.UTF8;
                                messageContext.Service = EmailMessagingChannel.EmailService;
                                _emailMessageingChannel.SendMessage(messageContext);
                            }
                        }

                    }
                }
            }

            return true;
        }
コード例 #10
0
ファイル: PostPartHandler.cs プロジェクト: YSRE/SuperRocket
        private void UpdateThreadPartCounters(PostPart postPart)
        {
            var commonPart = postPart.As <CommonPart>();

            if (commonPart != null &&
                commonPart.Record.Container != null)
            {
                ThreadPart threadPart = postPart.ThreadPart ??
                                        _threadService.Get(commonPart.Record.Container.Id, VersionOptions.Published);

                threadPart.PostCount = _postService.Count(threadPart, VersionOptions.Published);

                UpdateForumPartCounters(threadPart);
            }
        }
コード例 #11
0
ファイル: CountersService.cs プロジェクト: jon123/NGM.Forum
        public void UpdateThreadPartAndForumPartCounters(PostPart postPart)
        {
            var commonPart = postPart.As<CommonPart>();
            if (commonPart != null &&
                commonPart.Record.Container != null)
            {

                ThreadPart threadPart = postPart.ThreadPart ??
                                        _threadService.Get(commonPart.Record.Container.Id, true, VersionOptions.Published);

                //threadPart.PostCount = _postService.Count(threadPart, VersionOptions.Published);
                threadPart.PostCount = _contentManager.Query<PostPart, PostPartRecord>(VersionOptions.Published)
                                .Where(p => p.IsInappropriate == false).Join<CommonPartRecord>().Where(c => c.Container.Id == threadPart.Id).List().Count();

                UpdateForumPartCounters(threadPart);
            }
        }
コード例 #12
0
ファイル: PostPartService.cs プロジェクト: DooMachine/fso
        public AddPostPartReturnModel AddPostPart(int postId, string title, string currUserId)
        {
            AddPostPartReturnModel ret = new AddPostPartReturnModel();
            Post post = _postSet.Include(p => p.PostParts).FirstOrDefault(p => p.Id == postId);

            if (post == null)
            {
                ret.IsActionSucceed = false;
                return(ret);
            }
            if (string.IsNullOrEmpty(currUserId) || post.UserInfoId != currUserId)
            {
                ret.IsActionSucceed = false;
                return(ret);
            }
            if (post.PostParts == null)
            {
                post.PostParts = new List <PostPart>();
            }
            if (post.PostParts.Count >= 4)
            {
                ret.IsActionSucceed = false;
                return(ret);
            }
            PostPart newPostPart = new PostPart()
            {
                Title = title,
                Post  = post
            };

            _postPartSet.Add(newPostPart);
            if (_entityContext.SaveChanges() != 0)
            {
                ret.IsActionSucceed = true;
                ret.PostPartId      = newPostPart.Id;
            }
            ;
            return(ret);
        }
コード例 #13
0
ファイル: PostPartService.cs プロジェクト: DooMachine/fso
        public RemovePostPartReturnModel RemovePostPart(int PostPartId, string currUserId)
        {
            RemovePostPartReturnModel ret = new RemovePostPartReturnModel()
            {
                IsActionSucceed = false
            };

            if (string.IsNullOrEmpty(currUserId))
            {
                return(ret);
            }

            PostPart ppart = _postPartSet.Include(p => p.Post).Include(p => p.Image).FirstOrDefault(p => p.Id == PostPartId);

            if (ppart.Post.UserInfoId != currUserId)
            {
                return(ret);
            }
            ppart.IsSoftDeleted = true;
            if (ppart.Image != null)
            {
                ret.SmallImageUrl = ppart.Image.SmallPath;
                ret.LargeImageUrl = ppart.Image.ResizedPath;
                ret.ThumbImageUrl = ppart.Image.ThumbPath;
            }

            _postPartSet.Update(ppart);
            int z = _entityContext.SaveChanges();

            if (z == 0)
            {
                ret.IsActionSucceed = false;
            }
            ret.IsActionSucceed = true;
            return(ret);
        }
コード例 #14
0
        /* Post */

        public static string PostReply(this UrlHelper urlHelper, PostPart postPart) {
            return PostCreateByContent(urlHelper, postPart);
        }
コード例 #15
0
 public static string UnMarkPostAsAnswer(this UrlHelper urlHelper, PostPart postPart)
 {
     return urlHelper.Action("UnMarkPostAsAnswer", "Post", new { contentId = postPart.Id, area = Constants.LocalArea });
 }
コード例 #16
0
ファイル: ThreadController.cs プロジェクト: YSRE/SuperRocket
 private bool IsAllowedToCreatePost(PostPart postPart)
 {
     return(_authorizationService.TryCheckAccess(Orchard.Core.Contents.Permissions.PublishContent, _authenticationService.GetAuthenticatedUser(), postPart));
 }
コード例 #17
0
ファイル: PostPartHandler.cs プロジェクト: jon123/NGM.Forum
 private void SetModelProperties(BuildShapeContext context, PostPart postPart) {
     context.Shape.Thread = postPart.ThreadPart;
     if (context.Shape.Metadata.DisplayType != null)
     {
         if (context.Shape.Metadata.DisplayType == "Editor")
         {
             context.Shape.EditorFlavor = GetFlavor(postPart);
             context.Shape.ReturnUrl = HttpContext.Current.Request.UrlReferrer.AbsoluteUri;
         }
     }
 }
コード例 #18
0
 public static string PostRemoveInappropriate(this UrlHelper urlHelper, PostPart postPart)
 {
     return urlHelper.Action("RemoveInappropriate", "ReportPostAdmin", new { contentId = postPart.Id, area = Constants.LocalArea, returnUrl = urlHelper.RequestContext.HttpContext.Request.ToUrlString() });
 }
コード例 #19
0
ファイル: PostPartHandler.cs プロジェクト: six006/NGM.Forum
 private void SetModelProperties(BuildShapeContext context, PostPart postPart) {
     context.Shape.Thread = postPart.ThreadPart;
 }
コード例 #20
0
 public static string ReplyPost(this UrlHelper urlHelper, PostPart postPart)
 {
     return ReplyContent(urlHelper, postPart);
 }
コード例 #21
0
        private object MyPostToSend(PostPart postPart)
        {
            var PostToSend = new
            {
                AddDate = postPart.AddDate,
                Content = postPart.Content,
                UserId = postPart.UserId,
                UserName = _Helpers.GetUsernameFromId(postPart.UserId)
            };

            return PostToSend;
        }
コード例 #22
0
 public static string ViewPost(this UrlHelper urlHelper, PostPart postPart)
 {
     return string.Format("{0}#{1}", ViewThread(urlHelper, postPart.ThreadPart), postPart.Id);
 }
コード例 #23
0
 public static string PostView(this UrlHelper urlHelper, PostPart postPart)
 {
     return(string.Format("{0}#{1}", ThreadView(urlHelper, postPart.ThreadPart), postPart.Id));
 }
コード例 #24
0
 public static string PostDelete(this UrlHelper urlHelper, PostPart postPart)
 {
     return(urlHelper.Action("Delete", "Post", new { contentId = postPart.Id, area = Constants.LocalArea, returnUrl = urlHelper.RequestContext.HttpContext.Request.ToUrlString() }));
 }
コード例 #25
0
        /* Post */

        public static string PostReply(this UrlHelper urlHelper, PostPart postPart)
        {
            return(PostCreateByContent(urlHelper, postPart));
        }
コード例 #26
0
ファイル: PostPartHandler.cs プロジェクト: YSRE/SuperRocket
 private void SetModelProperties(BuildShapeContext context, PostPart postPart)
 {
     context.Shape.Thread = postPart.ThreadPart;
 }
コード例 #27
0
 public static string PostView(this UrlHelper urlHelper, PostPart postPart) {
     return string.Format("{0}#{1}", ThreadView(urlHelper, postPart.ThreadPart), postPart.Id);
 }
コード例 #28
0
 public static string PostDelete(this UrlHelper urlHelper, PostPart postPart) {
     return urlHelper.Action("Delete", "Post", new { contentId = postPart.Id, area = Constants.LocalArea, returnUrl = urlHelper.RequestContext.HttpContext.Request.ToUrlString() });
 }
コード例 #29
0
ファイル: PostPartHandler.cs プロジェクト: jon123/NGM.Forum
 private static string GetFlavor(PostPart part)
 {
     var typePartSettings = part.Settings.GetModel<PostTypePartSettings>();
     return (typePartSettings != null && !string.IsNullOrWhiteSpace(typePartSettings.Flavor))
                ? typePartSettings.Flavor
                : part.PartDefinition.Settings.GetModel<PostPartSettings>().FlavorDefault;
 }
コード例 #30
0
ファイル: PostPartHandler.cs プロジェクト: six006/NGM.Forum
 private void UpdateThreadVersioningDates(PostPart postPart) {
     var utcNow = _clock.UtcNow;
     postPart.ThreadPart.As<ICommonPart>().ModifiedUtc = utcNow;
     postPart.ThreadPart.As<ICommonPart>().VersionModifiedUtc = utcNow;
 }
コード例 #31
0
ファイル: PostPartHandler.cs プロジェクト: jon123/NGM.Forum
        private void RemoveReports(PostPart postPart)
        {
            //If a post is deleted from the system remove its related 'inappropriate reports'
            //Once the post is gone from the system, the report can no longer be substantiated, so keeping it for historic purposes serves no purpose.
            var reportIds = _reportPostService.Get().Where( report=>report.PostId == postPart.Id ).Select( r=>r.Id).ToList();
            _reportPostService.DeleteReports(reportIds);

        }
コード例 #32
0
ファイル: PostPartHandler.cs プロジェクト: jon123/NGM.Forum
 private void SendNewPostNotification(PostPart postPart)
 {
     _subscriptionService.SendEmailNotificationToSubscribers(postPart);
 }
コード例 #33
0
 public static string PostViewEditHistory(this UrlHelper urlHelper, PostPart postPart)
 {
     return urlHelper.Action("ViewPostEditHistory", "Post", new { postId = postPart.Id, area = Constants.LocalArea, returnUrl = urlHelper.RequestContext.HttpContext.Request.ToUrlString() });
 }