コード例 #1
0
 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;
 }
コード例 #2
0
ファイル: Wiki.aspx.cs プロジェクト: kohku/codefactory
    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;
        }
    }
コード例 #3
0
ファイル: Default.aspx.cs プロジェクト: kohku/codefactory
    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();
        }
    }
コード例 #4
0
 public B_Wiki()
 {
     if (CacheRedis.RedisHelper.Ping())
     {
         dal = new C_Wiki();
     }
     else
     {
         dal = new D_Wiki();
     }
 }
コード例 #5
0
    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;
            }
        }
    }
コード例 #6
0
ファイル: Default_Old.aspx.cs プロジェクト: kohku/codefactory
    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();
        }
    }
コード例 #7
0
ファイル: Wiki.aspx.cs プロジェクト: kohku/codefactory
    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);
    }
コード例 #8
0
        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);
        }
コード例 #9
0
ファイル: WikiService.cs プロジェクト: kohku/codefactory
 public static void InsertWiki(IWiki item)
 {
     _defaultProvider.InsertWiki(item);
 }
コード例 #10
0
ファイル: WikiProvider.cs プロジェクト: kohku/codefactory
 public abstract void DeletePublishedWiki(IWiki item);
コード例 #11
0
ファイル: WikiService.cs プロジェクト: kohku/codefactory
 public static void DeleteWiki(IWiki item)
 {
     _defaultProvider.DeleteWiki(item);
 }
コード例 #12
0
ファイル: WikiProvider.cs プロジェクト: kohku/codefactory
 public abstract void InsertPublishedWiki(IWiki item);
コード例 #13
0
ファイル: WikiProvider.cs プロジェクト: kohku/codefactory
 public abstract void DeleteWiki(IWiki item);
コード例 #14
0
ファイル: LinqWikiProvider.cs プロジェクト: kohku/codefactory
        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;
            }
        }
コード例 #15
0
ファイル: LinqWikiProvider.cs プロジェクト: kohku/codefactory
        public override void InsertWiki(IWiki item)
        {
            WorkWikiItem workitem = new WorkWikiItem(item);
            workitem.Action = SaveAction.Insert;

            RequestAuthorization(workitem);
        }
コード例 #16
0
ファイル: LinqWikiProvider.cs プロジェクト: kohku/codefactory
        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);
            }
        }
コード例 #17
0
ファイル: LinqWikiProvider.cs プロジェクト: kohku/codefactory
        public override void DeleteWiki(IWiki item)
        {
            WorkWikiItem workitem = new WorkWikiItem(item);
            workitem.Action = SaveAction.Delete;

            RequestAuthorization(workitem);
        }
コード例 #18
0
ファイル: FilesResult.cs プロジェクト: kohku/codefactory
 public FilesResult(IWiki content)
 {
     wiki = content;
 }
コード例 #19
0
ファイル: WikiService.cs プロジェクト: kohku/codefactory
 public static void UpdateWiki(IWiki item)
 {
     _defaultProvider.UpdateWiki(item);
 }
コード例 #20
0
ファイル: WikiProvider.cs プロジェクト: kohku/codefactory
 public abstract void InsertWiki(IWiki item);
コード例 #21
0
ファイル: WikiProvider.cs プロジェクト: kohku/codefactory
 public abstract void UpdateWiki(IWiki item);
コード例 #22
0
ファイル: WikiProvider.cs プロジェクト: kohku/codefactory
 public abstract void UpdatePublishedWiki(IWiki item);