コード例 #1
0
 /// <summary>
 /// 详细页面地址
 /// </summary>
 /// <param name="itemId">推荐内容Id</param>
 /// <returns></returns>
 public string RecommendItemDetail(long itemId)
 {
     BlogThread blogThread = new BlogService().Get(itemId);
     if (blogThread == null)
         return string.Empty;
     string userName = UserIdToUserNameDictionary.GetUserName(blogThread.UserId);
     return SiteUrls.Instance().BlogDetail(userName, itemId);
 }
コード例 #2
0
ファイル: feed.ashx.cs プロジェクト: rowlek/Rock-ChMS
        public void ProcessRequest( HttpContext context )
        {
            // get feed format
            if (context.Request["format"] != null)
                format = context.Request["format"].ToString();
            else
                format = "rss";

            // get return count (default 20)
            if ( int.TryParse( context.Request["count"], out count ) == false )
            {
                count = 20;
            }

            // get object type
            if ( context.Request["type"] != null )
                type = context.Request["type"].ToString();

            // get object key
            int.TryParse( context.Request["key"], out key );

            context.Response.Clear();

            if ( type != string.Empty )
            {
                string errorMessage = string.Empty;
                string contentType = string.Empty;

                BlogService blogService = new BlogService();
                string feedXml = blogService.ReturnFeed(key, count, format, out errorMessage, out contentType);

                if ( errorMessage == string.Empty )
                {
                    context.Response.ContentType = contentType;
                    context.Response.Write( feedXml );
                }
                else
                {
                    context.Response.ContentType = "text/html";
                    context.Response.Write( errorMessage );
                }

                context.Response.End();
            }
            else
            {

                context.Response.ContentType = "text/html";

                context.Response.Write( "No Feed Type Provided." );

                context.Response.End();
            }
        }
コード例 #3
0
ファイル: BlogServiceTest.cs プロジェクト: sebnilsson/Blaven
        public void ctor_NullBlogSettings_ShouldNotThrow()
        {
            // Arrange
            var repository = new FakeRepository();

            // Act
            var service = new BlogService(repository, blogSettings: null);

            // Assert
            Assert.NotNull(service);
        }
コード例 #4
0
        public void BlogServiceShouldDeleteThrougthWriteRepository()
        {
            var readRepoMock = new Mock<IBlogRepository>();

            IBlogService service = new BlogService(null, readRepoMock.Object);

            service.DeletePost(new BlogPost());
            readRepoMock.Verify(x => x.DeletePost(It.IsAny<BlogPost>()), Times.Once());

            service.DeleteComment(new Comment());
            readRepoMock.Verify(x => x.DeleteComment(It.IsAny<Comment>()), Times.Once());
        }
コード例 #5
0
        public void CreateBlog_saves_a_blog_via_context()
        {
            var context = new TestContext();

            var service = new BlogService(context);
            service.AddBlog("ADO.NET Blog", "http://blogs.msdn.com/adonet");

            Assert.AreEqual(1, context.Blogs.Count());
            Assert.AreEqual("ADO.NET Blog", context.Blogs.Single().Name);
            Assert.AreEqual("http://blogs.msdn.com/adonet", context.Blogs.Single().Url);
            Assert.AreEqual(1, context.SaveChangesCount);
        }
コード例 #6
0
 /// <summary>
 /// 获取被评论对象名称
 /// </summary>
 /// <param name="commentedObjectId">被评论对象Id</param>
 /// <param name="tenantTypeId">租户类型Id</param>
 /// <returns></returns>
 public string GetCommentedObjectName(long commentedObjectId, string tenantTypeId)
 {
     if (tenantTypeId == TenantTypeIds.Instance().BlogThread())
     {
         BlogThread blog = new BlogService().Get(commentedObjectId);
         if (blog != null)
         {
             return blog.Subject;
         }
     }
     return string.Empty;
 }
コード例 #7
0
        public void Test_EntityContext_SavesAddress()
        {
            var mockSet = new Mock<DbSet<Blog>>();

            var mockContext = new Mock<BloggingContext>();
            mockContext.Setup(m => m.Blogs).Returns(mockSet.Object);

            var service = new BlogService(mockContext.Object);
            service.AddBlog("ADO.NET Blog", "http://blogs.msdn.com/adonet");

            mockSet.Verify(m => m.Add(It.IsAny<Blog>()), Times.Once());
            mockContext.Verify(m => m.SaveChanges(), Times.Once());
        }
コード例 #8
0
        public static BlogService Create(
            IEnumerable<BlogPost> blogPosts = null,
            IEnumerable<BlogMeta> blogMetas = null,
            params BlogSetting[] blogSettings)
        {
            var repository = new FakeRepository(blogPosts, blogMetas);

            blogSettings = (blogSettings != null && blogSettings.Any())
                               ? blogSettings
                               : BlogSettingTestData.CreateCollection().ToArray();

            var service = new BlogService(repository, blogSettings);
            return service;
        }
コード例 #9
0
 /// <summary>
 /// 获取被评论对象(部分)
 /// </summary>
 /// <param name="commentedObjectId"></param>
 /// <returns></returns>
 public CommentedObject GetCommentedObject(long commentedObjectId)
 {
     BlogThread blogThread = new BlogService().Get(commentedObjectId);
     if (blogThread != null)
     {
         CommentedObject commentedObject = new CommentedObject();
         commentedObject.DetailUrl = SiteUrls.Instance().BlogDetail(blogThread.User.UserName, commentedObjectId);
         commentedObject.Name = blogThread.Subject;
         commentedObject.Author = blogThread.Author;
         commentedObject.UserId = blogThread.UserId;
         return commentedObject;
     }
     return null;
 }
コード例 #10
0
        public AssociatedInfo GetAssociatedInfo(long associateId, string tenantTypeId = "")
        {
            BlogThread thread = new BlogService().Get(associateId);
            if (thread != null && thread.User != null)
            {
                return new AssociatedInfo()
                {
                    DetailUrl = SiteUrls.Instance().BlogDetail(thread.User.UserName, associateId),
                    Subject = thread.Subject
                };
            }

            return null;
        }
コード例 #11
0
        public async Task GetAllBlogsAsync_orders_by_name()
        {
            var context = new TestContext();
            context.Blogs.Add(new Blog { Name = "BBB" });
            context.Blogs.Add(new Blog { Name = "ZZZ" });
            context.Blogs.Add(new Blog { Name = "AAA" });

            var service = new BlogService(context);
            var blogs = await service.GetAllBlogsAsync();

            Assert.AreEqual(3, blogs.Count);
            Assert.AreEqual("AAA", blogs[0].Name);
            Assert.AreEqual("BBB", blogs[1].Name);
            Assert.AreEqual("ZZZ", blogs[2].Name);
        }
コード例 #12
0
        public void BlogServiceShouldReadThrougthReadRepository()
        {
            Guid guid = Guid.NewGuid();
            var readRepoMock = new Mock<IBlogRepository>();

            IBlogService service = new BlogService(readRepoMock.Object, null);

            service.GetPost(guid);
            readRepoMock.Verify(x => x.GetPost(It.IsAny<Guid>()), Times.Once());

            service.GetPosts();
            readRepoMock.Verify(x => x.GetPosts(), Times.Once());

            service.GetComments(guid);
            readRepoMock.Verify(x => x.GetComments(It.IsAny<Guid>()), Times.Once());
        }
コード例 #13
0
 /// <summary>
 /// 删除用户在应用中的数据
 /// </summary>
 /// <param name="userId">用户Id</param>
 /// <param name="takeOverUserName">用于接管删除用户时不能删除的内容(例如:用户创建的群组)</param>
 /// <param name="isTakeOver">是否接管被删除用户可被接管的内容</param>
 protected override void DeleteUser(long userId, string takeOverUserName, bool isTakeOver)
 {
     BlogService blogService = new BlogService();
     blogService.DeleteUser(userId, takeOverUserName, isTakeOver);
 }
コード例 #14
0
 public PlatformController(ILoggerFactory loggerFactory, PlatformConfigutationService platformConfigutationService, BlogService blogService)
 {
     Logger = loggerFactory.CreateLogger <PlatformController>();
     PlatformConfigutationService = platformConfigutationService;
     BlogService = blogService;
 }
コード例 #15
0
 public ActionResult Add(BlogLinkViewModel viewModel)
 {
     BlogService.AddBlogLink(User.Blogs.First().Id, viewModel.Link);
     return(Json(new { Id = viewModel.Link.Id }));
 }
コード例 #16
0
 /// <summary>
 /// Deletes the Page from the current BlogProvider.
 /// </summary>
 public void Purge()
 {
     BlogService.DeletePage(this);
     DeletedPages.Remove(this);
 }
コード例 #17
0
 protected override AuthorProfile DataSelect(string id)
 {
     return(BlogService.SelectProfile(id));
 }
コード例 #18
0
 public BlogController()
 {
     BlogService    = new BlogService(SignalRPushNotificationProvider.Instance);
     ContentService = new ContentService();
 }
コード例 #19
0
ファイル: BlogController.cs プロジェクト: apsingh7/blog
        //[Filter.Authorize]
        public IActionResult GetAll()
        {
            BlogService obj = new BlogService();

            return(Ok(obj.GetData()));
        }
コード例 #20
0
        public void onRefresh(PullToRefreshLayout pullToRefreshLayout)
        {
            int id = -1, markType = 1;

            try
            {
                //通过收藏URL判断书签类型
                if (bookMark.LinkUrl.Contains("https://news"))
                {
                    //新闻
                    int lastIndex = bookMark.LinkUrl.LastIndexOf("/");
                    if (lastIndex <= 27)
                    {
                        id = Convert.ToInt32(bookMark.LinkUrl.Substring(27, bookMark.LinkUrl.Length - 27));
                    }
                    else
                    {
                        id = Convert.ToInt32(bookMark.LinkUrl.Substring(27, bookMark.LinkUrl.Length - 28));
                    }
                    markType = 1;
                    CommonHelper.InitalShare(this, null, true, "博客园新闻分享", bookMark.Title, "", bookMark.LinkUrl);
                }
                else if (bookMark.LinkUrl.Contains("http://kb."))
                {
                    //知识库
                    int lastIndex = bookMark.LinkUrl.LastIndexOf("/");
                    if (lastIndex <= 27)
                    {
                        id = Convert.ToInt32(bookMark.LinkUrl.Substring(27, bookMark.LinkUrl.Length - 27));
                    }
                    else
                    {
                        id = Convert.ToInt32(bookMark.LinkUrl.Substring(27, bookMark.LinkUrl.Length - 28));
                    }
                    markType = 2;
                    Button btnViewComments = FindViewById <Button>(Resource.Id.footbar_comments);
                    btnViewComments.Visibility = ViewStates.Gone;
                    LinearLayout linearWriteComments = FindViewById <LinearLayout>(Resource.Id.footbar_write_comment);
                    linearWriteComments.Visibility = ViewStates.Gone;
                    CommonHelper.InitalShare(this, null, true, "知识库分享", bookMark.Title, "", bookMark.LinkUrl);
                }
                else
                {
                    //默认博客类型
                    markType = 3;
                    int startindex = bookMark.LinkUrl.LastIndexOf("/");
                    //bookMark.WzLinkId
                    id = Convert.ToInt32(bookMark.LinkUrl.Substring(startindex + 1, bookMark.LinkUrl.Length - startindex - 6));
                    CommonHelper.InitalShare(this, null, true, "博客园文章分享", bookMark.Title, "", bookMark.LinkUrl);
                }
            }
            catch (Exception)
            {
            }
            if (id == -1)
            {
                using (var stream = Assets.Open("articlecontent.html"))
                {
                    StreamReader sr   = new StreamReader(stream);
                    string       html = sr.ReadToEnd();
                    sr.Close();
                    sr.Dispose();
                    html = html.Replace("#title#", bookMark.Title)
                           .Replace("#author#", "")
                           .Replace("#time#", "收藏于 " + bookMark.DateAdded.ToString("yyyy/MM/dd hh:mm:ss"))
                           .Replace("#content#", "尴尬,这篇文章有点儿小问题,等会儿再看吧");
                    webView.LoadDataWithBaseURL("file:///android_asset/", html, "text/html", "utf-8", null);
                }
                pullToRefreshLayout.refreshFinish(0);
            }
            else
            {
                CommonHelper.InitalBookMark(this, bookMark.LinkUrl, bookMark.Title);
                BaseService.ExeRequest(async() =>
                {
                    switch (markType)
                    {
                    case 1:
                        content = await NewsService.GetNewInfo(CommonHelper.token, id);
                        break;

                    case 2:
                        content = await BlogService.GetKbArticleContent(CommonHelper.token, id);
                        break;

                    case 3:
                        content = await BlogService.GetArticleContent(CommonHelper.token, id);
                        break;
                    }
                    content = content.Replace("\\r\\n", "</br>").Replace("\\n", "</br>").Replace("\\t", "&nbsp;&nbsp;&nbsp;&nbsp;").Replace("\\", string.Empty);
                    content = content.Substring(1, content.Length - 2);
                    using (var stream = Assets.Open("articlecontent.html"))
                    {
                        StreamReader sr = new StreamReader(stream);
                        string html     = sr.ReadToEnd();
                        sr.Close();
                        sr.Dispose();
                        html = html.Replace("#title#", bookMark.Title)
                               .Replace("#author#", "")
                               .Replace("#time#", "收藏于 " + bookMark.DateAdded.ToString("yyyy/MM/dd hh:mm:ss"))
                               .Replace("#content#", content);
                        webView.LoadDataWithBaseURL("file:///android_asset/", html, "text/html", "utf-8", null);
                    }
                    pullToRefreshLayout.refreshFinish(0);
                }, this);
            }
        }
コード例 #21
0
        public async void UnSubscribe()
        {
            try
            {
                var checkNet    = true;
                int workingStep = 1;
                retry = 1;
                int loopcheck = 0;

                bool internetCheck = true;
                do
                {
                    switch (workingStep)
                    {
                    case 1:                            //check internet
                        checkNet = CheckingInternet();
                        if (checkNet == true)
                        {
                            workingStep = 10;
                        }
                        else
                        {
                            workingStep = 2;
                        }
                        break;

                    case 2:                            //delay
                        await Task.Delay(300);

                        workingStep = 3;
                        break;

                    case 3:                            //action result
                        bool istryAgain = await Application.Current.MainPage.DisplayAlert("", "No Internet", "Try Again", "Cancel");

                        if (istryAgain)
                        {
                            workingStep = 1;
                        }
                        else
                        {
                            internetCheck = false;
                        }
                        break;

                    case 10:                            //call api
                        loopcheck++;

                        resultUnsub = await BlogService.UnSubscribes(Profile.Id, App.UserId);

                        if (resultUnsub.StatusCode == Enums.StatusCode.Ok)
                        {
                            //ListSubscr = new ObservableCollection<ProfileDto>(resultUnsub.Success);
                            //await App.Current.MainPage.Navigation.RemovePage();
                            //await App.Current.MainPage.Navigation.PushAsync(new FollowPage(this));

                            workingStep = 100;
                        }
                        else
                        {
                            if (loopcheck <= maxRetry)
                            {
                                if (resultUnsub.StatusCode == Enums.StatusCode.Unauthorized)
                                {
                                    //await GetToken();
                                }
                                else
                                {
                                    workingStep++;
                                }
                            }
                            else
                            {
                                internetCheck = false;
                            }
                        }
                        break;

                    case 11:                            //
                        await Task.Delay(300);

                        workingStep++;
                        break;

                    case 12:                            //
                        if (resultUnsub.StatusCode == Enums.StatusCode.BadRequest)
                        {
                            //await App.Current.MainPage.Navigation.PopAsync();
                            //await PopupNavigation.Instance.PushAsync(new ErrorPopup("SOMETHING WRONG"));

                            //await App.Current.MainPage.DisplayAlert("WARNING", "SOMETHING WRONG", "OK");
                        }
                        else if (resultUnsub.StatusCode == Enums.StatusCode.NotFound)
                        {
                            //await PopupNavigation.Instance.PushAsync(new ErrorPopup(result.Error.ErrorMessage));

                            //await Application.Current.MainPage.DisplayAlert("", result.Error.ErrorMessage.ToString(), "OK");
                        }
                        else if (resultUnsub.StatusCode == Enums.StatusCode.InternalServerError)
                        {
                            //await PopupNavigation.Instance.PushAsync(new ErrorPopup(result.Error.ErrorMessage));

                            //await Application.Current.MainPage.DisplayAlert("", result.Error.ErrorMessage.ToString(), "OK");
                        }
                        else
                        {
                            ///await PopupNavigation.Instance.PushAsync(new ErrorPopup(result.Error.ErrorMessage));

                            //await Application.Current.MainPage.DisplayAlert("", result.Error.ErrorMessage.ToString(), "OK");
                        }
                        workingStep++;
                        break;

                    case 13:                            //
                        internetCheck = false;
                        break;

                    case 100:                            //
                        internetCheck = false;
                        break;

                    default:
                        internetCheck = false;
                        break;
                    }
                } while (internetCheck);
            }
            catch (OperationCanceledException)
            {
                //await PopupNavigation.Instance.PushAsync(new ErrorPopup("ปิดปรับปรุงServer"));

                //await Application.Current.MainPage.DisplayAlert("", "ปิดปรับปรุงServer", "OK");
                //Application.Current.MainPage = new NavigationPage(new LoginPage());
            }
            catch (TimeoutException)
            {
                //await PopupNavigation.Instance.PushAsync(new ErrorPopup("ปิดปรับปรุงServer"));

                //await Application.Current.MainPage.DisplayAlert("", "กรุณาลองใหม่อีกครั้ง", "OK");
                //Application.Current.MainPage = new NavigationPage(new LoginPage());
            }
        }
コード例 #22
0
        public async Task <IActionResult> Index(CancellationToken cancellationToken = default)
        {
            var blogModel = await BlogService.GetBlogAsync(1, cancellationToken).ConfigureAwait(true);

            return(View(blogModel));
        }
コード例 #23
0
        public async Task <ActionResult> GetAtomFeed()
        {
            var result = await BlogService.QueryAtomFeed(BaseAddress);

            return(Content(result.Result, "text/xml"));
        }
コード例 #24
0
 public void CreateBlogTransactional([FromBody] CreateBlogDto createBlogDto, [FromServices] BlogService blogService2)
 {
     blogService2.CreateBlogTransactional(createBlogDto);
 }
コード例 #25
0
 public ActionResult Delete(IEnumerable <int> ids)
 {
     BlogService.DeleteBlogLinks(User.Blogs.First().Id, ids);
     return(Json(true));
 }
コード例 #26
0
 public ActionResult Edit(BlogLinkPM blogFriend)
 {
     BlogService.EditBlogLink(User.Blogs.First().Id, blogFriend);
     return(Json(true));
 }
コード例 #27
0
 /// <summary>
 /// Retreaves extension object from database or file system
 /// </summary>
 /// <param name="exType">Extension Type</param>
 /// <param name="exId">Extension ID</param>
 /// <returns>Extension object as Stream</returns>
 public object GetSettings(ExtensionType exType, string exId)
 {
     return(BlogService.LoadFromDataStore(exType, exId));
 }
コード例 #28
0
        public async void GetBlog()
        {
            try
            {
                var checkNet    = true;
                int workingStep = 1;
                retry = 1;
                int loopcheck = 0;

                bool internetCheck = true;
                do
                {
                    switch (workingStep)
                    {
                    case 1:    //check internet
                        checkNet = CheckingInternet();
                        if (checkNet == true)
                        {
                            workingStep = 10;
                        }
                        else
                        {
                            workingStep = 2;
                        }
                        break;

                    case 2:    //delay
                        await Task.Delay(300);

                        workingStep = 3;
                        break;

                    case 3:    //action result
                        bool istryAgain = await Application.Current.MainPage.DisplayAlert("", "No Internet", "Try Again", "Cancel");

                        if (istryAgain)
                        {
                            workingStep = 1;
                        }
                        else
                        {
                            internetCheck = false;
                        }
                        break;

                    case 10:    //call api
                        loopcheck++;
                        result = await BlogService.GetTargetBlog(Profile.Id, App.UserId);

                        if (result.StatusCode == Enums.StatusCode.Ok)
                        {
                            List <BlogModel> blogModel = new List <BlogModel>();
                            MyBlogs          data      = result.Success;
                            blogModel = data.Blogs.Select(b => new BlogModel()
                            {
                                BookMarkVisible = b.BookMarkVisible,
                                IsLike          = b.IsLike,
                                Createtime      = b.Createtime,
                                Detail          = b.Detail,
                                Id        = b.Id,
                                ImageHead = b.ImageHead,
                                ImagePath = b.ImagePath,
                                Owner     = b.Owner,
                                OwnerId   = b.OwnerId,
                                Title     = b.Title,
                                Topic     = b.Topic,
                                TopicId   = b.TopicId,
                                IsOn      = b.IsOn,
                                IsOff     = b.IsOff
                            }).ToList();
                            ListBlog    = new ObservableCollection <BlogModel>(blogModel);
                            Posts       = data.Posts + " " + "Posts";
                            Followers   = data.Followers + " " + "Followers";
                            Followings  = data.Followings + " " + "Followings";
                            workingStep = 100;
                            loopcheck   = 0;
                        }
                        else
                        {
                            if (loopcheck <= maxRetry)
                            {
                                if (result.StatusCode == Enums.StatusCode.Unauthorized)
                                {
                                    //await GetToken();
                                }
                                else
                                {
                                    workingStep++;
                                }
                            }
                            else
                            {
                                internetCheck = false;
                            }
                        }
                        break;

                    case 11:    //
                        await Task.Delay(300);

                        workingStep++;
                        break;

                    case 12:    //
                        if (result.StatusCode == Enums.StatusCode.BadRequest)
                        {
                            //await App.Current.MainPage.Navigation.PopAsync();
                            //await PopupNavigation.Instance.PushAsync(new ErrorPopup("SOMETHING WRONG"));

                            //await App.Current.MainPage.DisplayAlert("WARNING", "SOMETHING WRONG", "OK");
                        }
                        else if (result.StatusCode == Enums.StatusCode.NotFound)
                        {
                            //await PopupNavigation.Instance.PushAsync(new ErrorPopup(result.Error.ErrorMessage));

                            //await Application.Current.MainPage.DisplayAlert("", result.Error.ErrorMessage.ToString(), "OK");
                        }
                        else if (result.StatusCode == Enums.StatusCode.InternalServerError)
                        {
                            //await PopupNavigation.Instance.PushAsync(new ErrorPopup(result.Error.ErrorMessage));

                            //await Application.Current.MainPage.DisplayAlert("", result.Error.ErrorMessage.ToString(), "OK");
                        }
                        else
                        {
                            ///await PopupNavigation.Instance.PushAsync(new ErrorPopup(result.Error.ErrorMessage));

                            //await Application.Current.MainPage.DisplayAlert("", result.Error.ErrorMessage.ToString(), "OK");
                        }
                        workingStep++;
                        break;

                    case 13:    //
                        internetCheck = false;
                        break;

                    case 100:    //
                        internetCheck = false;
                        break;

                    default:
                        internetCheck = false;
                        break;
                    }
                } while (internetCheck);
            }
            catch (OperationCanceledException)
            {
                //await PopupNavigation.Instance.PushAsync(new ErrorPopup("ปิดปรับปรุงServer"));

                //await Application.Current.MainPage.DisplayAlert("", "ปิดปรับปรุงServer", "OK");
                //Application.Current.MainPage = new NavigationPage(new LoginPage());
            }
            catch (TimeoutException)
            {
                //await PopupNavigation.Instance.PushAsync(new ErrorPopup("ปิดปรับปรุงServer"));

                //await Application.Current.MainPage.DisplayAlert("", "กรุณาลองใหม่อีกครั้ง", "OK");
                //Application.Current.MainPage = new NavigationPage(new LoginPage());
            }
        }
コード例 #29
0
 public AuthorService(BloggingContext context, BlogService blogService, GraphqlErrors errors)
 {
     _context     = context;
     _blogService = blogService;
     _errors      = errors;
 }
コード例 #30
0
 public AuthorsController(BlogService blogService)
 {
     this.blogService = blogService;
 }
コード例 #31
0
 public ActionResult ReadUserPosts(DataSourceRequest request)
 {
     return(Json(BlogService.ReadUserPosts(User, request), JsonRequestBehavior.AllowGet));
 }
コード例 #32
0
 public BlogsController(EcommerceContext context)
 {
     _blogService = new BlogService(context);
     _context     = context;
 }
コード例 #33
0
ファイル: GraphQlController.cs プロジェクト: navkar/GraphQL
 public GraphQlController(BlogService blogService)
 {
     this.blogService = blogService;
 }
コード例 #34
0
 /// <summary>
 /// Retrieves the object from the data store and populates it.
 /// </summary>
 /// <param name="id">
 /// The unique identifier of the object.
 /// </param>
 /// <returns>
 /// The object that was selected from the data store.
 /// </returns>
 protected override Blog DataSelect(Guid id)
 {
     return(BlogService.SelectBlog(id));
 }
コード例 #35
0
 /// <summary>
 /// Retrieves a page form the BlogProvider
 /// based on the specified id.
 /// </summary>
 /// <param name="id">The page id.</param>
 /// <returns>The Page requested.</returns>
 protected override Page DataSelect(Guid id)
 {
     return BlogService.SelectPage(id);
 }
コード例 #36
0
ファイル: BlogThreadEventModule.cs プロジェクト: hbulzy/SYS
        /// <summary>
        /// 评论日志动态处理程序
        /// </summary>
        /// <param name="comment"></param>
        /// <param name="eventArgs"></param>
        private void BlogCommentActivityEventModule_After(Comment comment, AuditEventArgs eventArgs)
        {
            NoticeService noticeService = new NoticeService();
            BlogThread blogThread = null;

            if (comment.TenantTypeId == TenantTypeIds.Instance().BlogThread())
            {
                //生成动态
                ActivityService activityService = new ActivityService();
                AuditService auditService = new AuditService();
                bool? auditDirection = auditService.ResolveAuditDirection(eventArgs.OldAuditStatus, eventArgs.NewAuditStatus);
                if (auditDirection == true)
                {
                    //创建评论的动态[关注评论者的粉丝可以看到该评论]
                    Activity activity = Activity.New();
                    activity.ActivityItemKey = ActivityItemKeys.Instance().CreateBlogComment();
                    activity.ApplicationId = BlogConfig.Instance().ApplicationId;

                    BlogService blogService = new BlogService();
                    blogThread = blogService.Get(comment.CommentedObjectId);
                    if (blogThread == null || blogThread.UserId == comment.UserId)
                    {
                        return;
                    }
                    activity.IsOriginalThread = true;
                    activity.IsPrivate = false;
                    activity.OwnerId = comment.UserId;
                    activity.OwnerName = comment.Author;
                    activity.OwnerType = ActivityOwnerTypes.Instance().User();
                    activity.ReferenceId = blogThread.ThreadId;
                    activity.ReferenceTenantTypeId = TenantTypeIds.Instance().BlogThread();
                    activity.SourceId = comment.Id;
                    activity.TenantTypeId = TenantTypeIds.Instance().Comment();
                    activity.UserId = comment.UserId;

                    //是否是公开的(用于是否推送站点动态)
                    bool isPublic = blogThread.PrivacyStatus == PrivacyStatus.Public ? true : false;
                    activityService.Generate(activity, false, isPublic);

                    //创建评论的动态[关注该日志的用户可以看到该评论]
                    Activity activityOfBlogComment = Activity.New();
                    activityOfBlogComment.ActivityItemKey = activity.ActivityItemKey;
                    activityOfBlogComment.ApplicationId = activity.ApplicationId;
                    activityOfBlogComment.IsOriginalThread = activity.IsOriginalThread;
                    activityOfBlogComment.IsPrivate = activity.IsPrivate;
                    activityOfBlogComment.ReferenceId = activity.ReferenceId;
                    activityOfBlogComment.ReferenceTenantTypeId = activity.ReferenceTenantTypeId;
                    activityOfBlogComment.SourceId = activity.SourceId;
                    activityOfBlogComment.TenantTypeId = activity.TenantTypeId;
                    activityOfBlogComment.UserId = activity.UserId;

                    activityOfBlogComment.OwnerId = blogThread.ThreadId;
                    activityOfBlogComment.OwnerName = blogThread.ResolvedSubject;
                    activityOfBlogComment.OwnerType = ActivityOwnerTypes.Instance().Blog();

                    activityService.Generate(activityOfBlogComment, false, isPublic);
                }
                else if (auditDirection == false)
                {
                    activityService.DeleteSource(TenantTypeIds.Instance().Comment(), comment.Id);
                }
            }
        }
コード例 #37
0
 protected override void DataUpdate()
 {
     BlogService.UpdateProfile(this);
 }
コード例 #38
0
 /// <summary>
 /// copys a file from one directory to another with a new name
 /// </summary>
 /// <param name="NewName">the new name</param>
 /// <param name="NewBaseDirectory">the new directory</param>
 /// <returns>the new file object</returns>
 /// <remarks>
 /// both object will be maintained after the copy.
 /// </remarks>
 public File CopyFile(string NewName, Directory NewBaseDirectory)
 {
     return(BlogService.UploadFile(this.FileContents, NewName, NewBaseDirectory, true));
 }
コード例 #39
0
 public BlogController()
 {
     this.service = new BlogService();
 }
コード例 #40
0
 public ActionResult ReadFriends(DataSourceRequest request)
 {
     return(Json(BlogService.ReadBlogLinks(User.Blogs.First().Id, request), JsonRequestBehavior.AllowGet));
 }
コード例 #41
0
		public BlogController(IConfiguration configuration, BlogService blogService) {
			_configuration = configuration;
			_blogService = blogService;
		}
コード例 #42
0
ファイル: BlogController.cs プロジェクト: Mike920/BlogSite
 public BlogController()
 {
     _service = new BlogService(ModelState);
 }
コード例 #43
0
 public HomeController(BlogService service)
 {
     this.service = service;
 }
コード例 #44
0
 /// <summary>
 /// Retrieves the object from the data store and populates it.
 /// </summary>
 /// <param name="id">
 /// The unique identifier of the object.
 /// </param>
 /// <returns>
 /// The object that was selected from the data store.
 /// </returns>
 protected override BlogRollItem DataSelect(Guid id)
 {
     return(BlogService.SelectBlogRoll(id));
 }
コード例 #45
0
ファイル: Category.cs プロジェクト: VijayMVC/CSharpBBQ
 /// <summary>
 /// Retrieves the object from the data store and populates it.
 /// </summary>
 /// <param name="id">
 /// The unique identifier of the object.
 /// </param>
 /// <returns>
 /// True if the object exists and is being populated successfully
 /// </returns>
 protected override Category DataSelect(Guid id)
 {
     return(BlogService.SelectCategory(id));
 }
コード例 #46
0
        /// <summary>
        /// 转换成BlogThread类型
        /// </summary>
        /// <returns>日志实体</returns>
        public BlogThread AsBlogThread()
        {
            BlogThread blogThread = null;

            //写日志
            if (this.ThreadId <= 0)
            {
                blogThread = BlogThread.New();
                blogThread.UserId = UserContext.CurrentUser.UserId;
                blogThread.Author = UserContext.CurrentUser.DisplayName;
                if (this.OwnerId.HasValue)
                {
                    blogThread.OwnerId = this.OwnerId.Value;
                    blogThread.TenantTypeId = TenantTypeIds.Instance().Group();
                }
                else
                {
                    blogThread.OwnerId = UserContext.CurrentUser.UserId;
                    blogThread.TenantTypeId = TenantTypeIds.Instance().User();
                }
                blogThread.OriginalAuthorId = UserContext.CurrentUser.UserId;
                blogThread.IsDraft = this.IsDraft;
            }
            //编辑日志
            else
            {
                BlogService blogService = new BlogService();
                blogThread = blogService.Get(this.ThreadId);
                blogThread.LastModified = DateTime.UtcNow;
            }

            blogThread.Subject = this.Subject;
            blogThread.Body = this.Body;
            blogThread.IsSticky = this.IsSticky;
            blogThread.IsLocked = this.IsLocked;
            blogThread.PrivacyStatus = this.PrivacyStatus;
            blogThread.Keywords = this.Keywords;
            if (string.IsNullOrEmpty(blogThread.Keywords))
            {
                string[] keywords = ClauseScrubber.TitleToKeywords(this.Subject);
                if (keywords.Length > 0)
                    blogThread.Keywords = string.Join(" ", keywords);
                else
                    blogThread.Keywords = string.Empty;
            }
            blogThread.Summary = this.Summary;
            if (string.IsNullOrEmpty(this.Summary))
            {
                blogThread.Summary = HtmlUtility.TrimHtml(this.Body, 100);
            }

            blogThread.FeaturedImageAttachmentId = this.FeaturedImageAttachmentId;
            if (blogThread.FeaturedImageAttachmentId > 0)
            {
                Attachment attachment = attachmentService.Get(blogThread.FeaturedImageAttachmentId);
                if (attachment != null)
                {
                    blogThread.FeaturedImage = attachment.GetRelativePath() + "\\" + attachment.FileName;
                }
                else
                {
                    blogThread.FeaturedImageAttachmentId = 0;
                }
            }
            else
            {
                blogThread.FeaturedImage = string.Empty;
            }

            return blogThread;
        }
コード例 #47
0
 /// <summary>
 /// Retrieves the object from the data store and populates it.
 /// </summary>
 /// <param name="id">
 /// The unique identifier of the object.
 /// </param>
 /// <returns>
 /// The object that was selected from the data store.
 /// </returns>
 protected override Referrer DataSelect(Guid id)
 {
     return(BlogService.SelectReferrer(id));
 }
コード例 #48
0
        public static string GetInstalledVersion(string pkgId)
        {
            var pkg = BlogService.InstalledFromGalleryPackages().Where(p => p.PackageId == pkgId).FirstOrDefault();

            return(pkg == null ? "" : pkg.Version);
        }