/// <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); }
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(); } }
public void ctor_NullBlogSettings_ShouldNotThrow() { // Arrange var repository = new FakeRepository(); // Act var service = new BlogService(repository, blogSettings: null); // Assert Assert.NotNull(service); }
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()); }
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); }
/// <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; }
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()); }
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; }
/// <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; }
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; }
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); }
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()); }
/// <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); }
public PlatformController(ILoggerFactory loggerFactory, PlatformConfigutationService platformConfigutationService, BlogService blogService) { Logger = loggerFactory.CreateLogger <PlatformController>(); PlatformConfigutationService = platformConfigutationService; BlogService = blogService; }
public ActionResult Add(BlogLinkViewModel viewModel) { BlogService.AddBlogLink(User.Blogs.First().Id, viewModel.Link); return(Json(new { Id = viewModel.Link.Id })); }
/// <summary> /// Deletes the Page from the current BlogProvider. /// </summary> public void Purge() { BlogService.DeletePage(this); DeletedPages.Remove(this); }
protected override AuthorProfile DataSelect(string id) { return(BlogService.SelectProfile(id)); }
public BlogController() { BlogService = new BlogService(SignalRPushNotificationProvider.Instance); ContentService = new ContentService(); }
//[Filter.Authorize] public IActionResult GetAll() { BlogService obj = new BlogService(); return(Ok(obj.GetData())); }
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", " ").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); } }
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()); } }
public async Task <IActionResult> Index(CancellationToken cancellationToken = default) { var blogModel = await BlogService.GetBlogAsync(1, cancellationToken).ConfigureAwait(true); return(View(blogModel)); }
public async Task <ActionResult> GetAtomFeed() { var result = await BlogService.QueryAtomFeed(BaseAddress); return(Content(result.Result, "text/xml")); }
public void CreateBlogTransactional([FromBody] CreateBlogDto createBlogDto, [FromServices] BlogService blogService2) { blogService2.CreateBlogTransactional(createBlogDto); }
public ActionResult Delete(IEnumerable <int> ids) { BlogService.DeleteBlogLinks(User.Blogs.First().Id, ids); return(Json(true)); }
public ActionResult Edit(BlogLinkPM blogFriend) { BlogService.EditBlogLink(User.Blogs.First().Id, blogFriend); return(Json(true)); }
/// <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)); }
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()); } }
public AuthorService(BloggingContext context, BlogService blogService, GraphqlErrors errors) { _context = context; _blogService = blogService; _errors = errors; }
public AuthorsController(BlogService blogService) { this.blogService = blogService; }
public ActionResult ReadUserPosts(DataSourceRequest request) { return(Json(BlogService.ReadUserPosts(User, request), JsonRequestBehavior.AllowGet)); }
public BlogsController(EcommerceContext context) { _blogService = new BlogService(context); _context = context; }
public GraphQlController(BlogService blogService) { this.blogService = blogService; }
/// <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)); }
/// <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); }
/// <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); } } }
protected override void DataUpdate() { BlogService.UpdateProfile(this); }
/// <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)); }
public BlogController() { this.service = new BlogService(); }
public ActionResult ReadFriends(DataSourceRequest request) { return(Json(BlogService.ReadBlogLinks(User.Blogs.First().Id, request), JsonRequestBehavior.AllowGet)); }
public BlogController(IConfiguration configuration, BlogService blogService) { _configuration = configuration; _blogService = blogService; }
public BlogController() { _service = new BlogService(ModelState); }
public HomeController(BlogService service) { this.service = service; }
/// <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)); }
/// <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)); }
/// <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; }
/// <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)); }
public static string GetInstalledVersion(string pkgId) { var pkg = BlogService.InstalledFromGalleryPackages().Where(p => p.PackageId == pkgId).FirstOrDefault(); return(pkg == null ? "" : pkg.Version); }