public BandEnhancer(ILogger <BandEnhancer> logger, IKnowledgeBaseFactory knowledgeBaseFactory, string knowledgeBaseFileName, IWiki wikiSearch, IPersonsNameFinder personsNameFinder) { this.logger = logger; this.knowledgeBase = knowledgeBaseFactory.GetKnowledgeBase(knowledgeBaseFileName); this.wikiSearch = wikiSearch; this.personsNameFinder = personsNameFinder; }
private void BindWikiContent() { if (string.IsNullOrEmpty(Request.QueryString["id"])) throw new InvalidOperationException("A valid identifier is requested."); wiki = Wiki.Load(new Guid(Request.QueryString["id"])); if (wiki == null) return; // Tracing on first request. if (!Page.IsPostBack) TraceWiki(wiki); Page.Title = string.Format("Wiki - {0}", wiki.Title); TitleLabel.Text = wiki.Title; EditorLabel.Text = string.Format("Autor: {0}{1}", !string.IsNullOrEmpty(wiki.Editor) ? wiki.Editor : "ND", !string.IsNullOrEmpty(wiki.DepartmentArea) ? string.Format(" - {0}", wiki.DepartmentArea) : string.Empty); ContentLabel.Text = wiki.Content; EditButton.Visible = wiki.Editable || User.IsInRole("Administrator"); relatedWiki = Wiki.GetRelatedWiki(wiki); if (relatedWiki != null) { int max = 3; while (max-- > 0 && (relatedWiki == null || relatedWiki.Equals(wiki))) relatedWiki = Wiki.GetRandomWiki(); TitleRelatedLabel.Text = relatedWiki.Title; ContentRelatedLabel.Text = relatedWiki.Description; RelatedWikiLink.NavigateUrl = TitleRelatedLabel.NavigateUrl = relatedWiki.RelativeLink; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (HttpContext.Current.Cache["contentOfDay"] == null && HttpContext.Current.Cache["Article1Cover"] == null) { content1 = Wiki.GetRandomWiki(); if (content1 == null) { UpdateView(); return; } contentOfDay = content1.Title; DateTime absoluteExpiration = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day); absoluteExpiration = absoluteExpiration.AddDays(1); HttpContext.Current.Cache.Add("contentOfDay", contentOfDay, null, absoluteExpiration, Cache.NoSlidingExpiration, CacheItemPriority.Normal, null); HttpContext.Current.Cache.Add("Article1Cover", content1.ID, null, absoluteExpiration, Cache.NoSlidingExpiration, CacheItemPriority.Normal, null); } else { contentOfDay = (string)HttpContext.Current.Cache["contentOfDay"]; content1 = Wiki.Load((Guid)HttpContext.Current.Cache["Article1Cover"]); } UpdateView(); } }
public B_Wiki() { if (CacheRedis.RedisHelper.Ping()) { dal = new C_Wiki(); } else { dal = new D_Wiki(); } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { randomWiki = Wiki.GetRandomWiki(); if (randomWiki != null) { TitleRelatedLabel.Text = randomWiki.Title; ContentRelatedLabel.Text = randomWiki.Description; RelatedWikiLink.NavigateUrl = randomWiki.RelativeLink; } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (HttpContext.Current.Cache["contentOfDay"] == null && HttpContext.Current.Cache["Article1Cover"] == null && HttpContext.Current.Cache["Article2Cover"] == null) { content1 = Wiki.GetRandomWiki(); if (content1 == null) { UpdateView(); return; } contentOfDay = content1.Title; content2 = Wiki.GetRandomWiki(); /// Mmm... aki puede haber problemas, cuando Wiki.GetRandomWiki() regrese siempre el mismo /// (solo haya un wiki) y también cuando regresa null. int max = 20; while (max-- > 0 && content1.Equals(content2)) content2 = Wiki.GetRandomWiki(); DateTime absoluteExpiration = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day); absoluteExpiration = absoluteExpiration.AddDays(1); HttpContext.Current.Cache.Add("contentOfDay", contentOfDay, null, absoluteExpiration, Cache.NoSlidingExpiration, CacheItemPriority.Normal, null); HttpContext.Current.Cache.Add("Article1Cover", content1.ID, null, absoluteExpiration, Cache.NoSlidingExpiration, CacheItemPriority.Normal, null); HttpContext.Current.Cache.Add("Article2Cover", content2.ID, null, absoluteExpiration, Cache.NoSlidingExpiration, CacheItemPriority.Normal, null); } else { contentOfDay = (string)HttpContext.Current.Cache["contentOfDay"]; content1 = Wiki.Load((Guid)HttpContext.Current.Cache["Article1Cover"]); content2 = Wiki.Load((Guid)HttpContext.Current.Cache["Article2Cover"]); } UpdateView(); } }
private void TraceWiki(IWiki wiki) { if (wiki == null) return; LogEntry entry = new LogEntry(); entry.Categories.Clear(); entry.Categories.Add("Bitacora de consultas"); entry.Priority = 5; entry.Severity = TraceEventType.Information; entry.Message = "Wiki consultado"; entry.ExtendedProperties.Add("id", wiki.ID); entry.ExtendedProperties.Add("title", wiki.Title); entry.ExtendedProperties.Add("urlRequested", HttpContext.Current != null ? HttpContext.Current.Request.Url.PathAndQuery : string.Empty); entry.ExtendedProperties.Add("username", HttpContext.Current != null ? HttpContext.Current.User.Identity.Name : string.Empty); entry.ExtendedProperties.Add("type", wiki.GetType().ToString()); Logger.Write(entry); }
private static async Task <bool> SaveSection(DbObjectsList list, IWiki wiki) { TemplateFiller tf = new TemplateFiller(); // table of contents var section = await wiki.GetWikiPage(list.WikiSection); string toc = tf.FillTocTemplate(File.ReadAllText($"Templates/toc_{list.TemplateName}"), list, (desc, line) => !section.content.Contains(line)); if (!string.IsNullOrEmpty(toc)) { await wiki.SetWikiPage(list.WikiSection, section.content + Environment.NewLine + toc, null); } // pages for each object string template = File.ReadAllText($"Templates/{list.TemplateName}"); foreach (var i in list) { var currentPage = await wiki.GetWikiPage(i.Name); if (string.IsNullOrEmpty(currentPage.content)) // create page { await wiki.SetWikiPage(i.Name, tf.FillTemplate(template, i), list.WikiSection); } else if (i.LastUpdated > currentPage.updated) // update page { await wiki.SetWikiPage(i.Name, tf.MergeTemplate(template, i, currentPage.content), list.WikiSection); } else { ;// nothing changed - skip page } } return(true); }
public static void InsertWiki(IWiki item) { _defaultProvider.InsertWiki(item); }
public abstract void DeletePublishedWiki(IWiki item);
public static void DeleteWiki(IWiki item) { _defaultProvider.DeleteWiki(item); }
public abstract void InsertPublishedWiki(IWiki item);
public abstract void DeleteWiki(IWiki item);
public override void InsertPublishedWiki(IWiki item) { if (item == null) throw new ArgumentNullException("item"); WikiDataContext db = new WikiDataContext( ConfigurationManager.ConnectionStrings[this.ConnectionStringName].ConnectionString); Table<LinqWiki> wikis = db.GetTable<LinqWiki>(); wikis.InsertOnSubmit(new LinqWiki() { ApplicationName = this.ApplicationName, Author = item.Author, Category = item.Category, Content = item.Content, DateCreated = item.DateCreated, DepartmentArea = item.DepartmentArea, Description = item.Description, Editable = item.Editable, Editor = item.Editor, ID = item.ID, IsVisible = item.IsVisible, Keywords = item.Keywords, LastUpdated = item.LastUpdated, LastUpdatedBy = item.LastUpdatedBy, ReachLevel = (int)item.ReachLevel, Slug = item.Slug, Title = item.Title }); try { db.SubmitChanges(ConflictMode.ContinueOnConflict); } catch (ChangeConflictException ex) { Trace.TraceWarning(ex.Message); // All database values overwrite current values. foreach (ObjectChangeConflict occ in db.ChangeConflicts) occ.Resolve(RefreshMode.OverwriteCurrentValues); } catch (DbException ex) { Trace.TraceError(ex.Message); return; } }
public override void InsertWiki(IWiki item) { WorkWikiItem workitem = new WorkWikiItem(item); workitem.Action = SaveAction.Insert; RequestAuthorization(workitem); }
public override void DeletePublishedWiki(IWiki item) { WikiDataContext db = new WikiDataContext( ConfigurationManager.ConnectionStrings[this.ConnectionStringName].ConnectionString); Table<LinqWiki> wikis = db.GetTable<LinqWiki>(); // BusinessBase inherited clases will have a downside effect with a ChangeConflictException // as it has changed LastUpdated row version in the call stack. LinqWiki w = new LinqWiki() { ApplicationName = this.ApplicationName, Author = item.Author, Category = item.Category, Content = item.Content, DateCreated = item.DateCreated, DepartmentArea = item.DepartmentArea, Description = item.Description, Editable = item.Editable, Editor = item.Editor, ID = item.ID, IsVisible = item.IsVisible, Keywords = item.Keywords, LastUpdated = item.LastUpdated, LastUpdatedBy = item.LastUpdatedBy, ReachLevel = (int)item.ReachLevel, Slug = item.Slug, Title = item.Title }; // Assume that "wiki" has been sent by client. // Attach with "true" to the change tracker to consider the entity modified // and it can be checked for optimistic concurrency because // it has a column that is marked with "RowVersion" attribute wikis.Attach(w); wikis.DeleteOnSubmit(w); try { db.SubmitChanges(ConflictMode.ContinueOnConflict); } catch (ChangeConflictException ex) { Trace.TraceError(ex.Message); // All database values overwrite current values. foreach (ObjectChangeConflict occ in db.ChangeConflicts) occ.Resolve(RefreshMode.OverwriteCurrentValues); } catch (DbException ex) { Trace.TraceError(ex.Message); } }
public override void DeleteWiki(IWiki item) { WorkWikiItem workitem = new WorkWikiItem(item); workitem.Action = SaveAction.Delete; RequestAuthorization(workitem); }
public FilesResult(IWiki content) { wiki = content; }
public static void UpdateWiki(IWiki item) { _defaultProvider.UpdateWiki(item); }
public abstract void InsertWiki(IWiki item);
public abstract void UpdateWiki(IWiki item);
public abstract void UpdatePublishedWiki(IWiki item);