Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.IO;
- using EPiServer.Common;
- using System.Web.Configuration;
- using EPiServer.Common.Sorting;
- using EPiServer.Common.Reporting;
- using EPiServer.Community.Blog;
- using EPiServer.Common.Security;
- using EPiServer.Community;
- using EPiServer.Common.Cache;
- using EPiServer.Common.Categories;
- using EPiServer.Common.Data;
- namespace RelateBugTesting
- {
- class Program
- {
- private class FrameworkFactoryBaseWrapper : FrameworkFactoryBase
- {
- public static void DoStuff(IEntity e, int id)
- {
- // need to do it this way as FrameworkFactoryBase.UpdateEntity is protected.
- UpdateEntity(e, id);
- }
- }
- static void Main(string[] args)
- {
- // Initialize Community
- Initialize();
- // fetch the bug reports about the first blog
- Blog blog = BlogHandler.Instance.GetBlog(4);
- int totalItems;
- foreach (var reportCase in ReportHandler.Instance.GetReportCases(ReportCaseStatus.New, blog, EntityStatus.Approved, null, 1, 10, out totalItems, new ReportCaseSortOrder[] { new ReportCaseSortOrder(ReportCaseSortField.Created, SortingDirection.Ascending) }))
- {
- Console.WriteLine(reportCase.Comment);
- Console.WriteLine("hi");
- }
- // Create Report about the first blog
- UserAuthor user = (UserAuthor)AuthorHandler.Instance.GetAuthor(3);
- IReport r = new Report(blog, user, "testing" + DateTime.Now);
- // save the report
- r = ReportHandler.Instance.AddReport(r);
- // add a category
- ICategory category = new Category("Urban" + DateTime.Now.Minute);
- // Add it if it doesn't exist
- ICategory rootCategory = CategoryHandler.Instance.AddCategory(category);
- // Add the category to the report
- Report reportClone = (Report)r.Clone();
- reportClone.Categories.Add(rootCategory);
- // Haxx to update the categories and attributes
- FrameworkFactoryBaseWrapper.DoStuff(reportClone, r.ID);
- foreach (var reportCase in ReportHandler.Instance.GetReportCases(ReportCaseStatus.New, blog, EntityStatus.Approved, null, 1, 10, out totalItems, new ReportCaseSortOrder[] { new ReportCaseSortOrder(ReportCaseSortField.Created, SortingDirection.Ascending) }))
- {
- Console.WriteLine(reportCase.Comment);
- Console.WriteLine("hello");
- //ReportCase rCase = (ReportCase)reportCase.Clone();
- //rCase.Categories.Add(rootCategory);
- //ReportHandler.Instance.UpdateReportCase(rCase);
- }
- }
- private static void Initialize()
- {
- new EPiServer.Framework.Initialization.SiteMappingConfiguration().Initialize(null);
- EPiServer.Framework.Initialization.SiteMappingConfiguration.Instance.SiteId = "MyRelateSite";
- EPiServer.Data.Configuration.EPiServerDataStoreSection.ConfigurationInstance = GetConfigurationFromFile();
- EPiServer.Common.Configuration.EPiServerCommonSection.ConfigurationInstance = GetConfigurationFromFile();
- EPiServer.Community.Configuration.EPiServerCommunitySection.ConfigurationInstance = GetConfigurationFromFile();
- EPiServer.Common.Settings.LoadSettings();
- }
- private static System.Configuration.Configuration GetConfigurationFromFile()
- {
- if (System.Web.Hosting.HostingEnvironment.IsHosted)
- {
- return WebConfigurationManager.OpenWebConfiguration("~/");
- }
- else
- {
- WebConfigurationFileMap cfm = new WebConfigurationFileMap();
- cfm.VirtualDirectories.Add("/", new VirtualDirectoryMapping(Environment.CurrentDirectory, true));
- return WebConfigurationManager.OpenMappedWebConfiguration(cfm, "/");
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment