当前位置: 首页>>代码示例>>C#>>正文


C# Lib.ShouldShowQuestion方法代码示例

本文整理汇总了C#中Lib.ShouldShowQuestion方法的典型用法代码示例。如果您正苦于以下问题:C# Lib.ShouldShowQuestion方法的具体用法?C# Lib.ShouldShowQuestion怎么用?C# Lib.ShouldShowQuestion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Lib的用法示例。


在下文中一共展示了Lib.ShouldShowQuestion方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RenderQuestion

        protected void RenderQuestion(HtmlTextWriter writer, Lib.Data.DSQ.Question q)
        {
            if (q==null || !q.ID.HasValue)
                return;

            IMarkdownService markdownSvc = new MarkdownService(enableSyntaxHighlighting: true);
            IComplianceRepository complianceRepo = ObjectFactory.GetInstance<IComplianceRepository>();
            IDsqRepository dsqRepo = ObjectFactory.GetInstance<IDsqRepository>();

            string a = null;
            if (DrugID != null)
            {
                var answer = Lib.Data.DSQ.Answer.FindByDrug(DrugID.Value, q.ID.Value);
                if (answer != null && answer.ID.HasValue)
                    a = answer.Value;
            }

            if (!q.ShouldShowQuestion(false, a))
                return;

            var children = Lib.Data.DSQ.Question.FindByParent(q);
            bool has_children = false;

            if (children != null && children.Count > 0)
                has_children = true;

            if(q.HideFromView)
            {
                // if the answere was no, we don't care if it has any
                // children
                if(q.FieldType == "Yes/No" && a == "No")
                    return;

                if( has_children )
                {
                    foreach( var cq in children )
                        RenderQuestion( writer, cq );
                }

                return;
            }

            Eoc eocForQ = complianceRepo.GetEoc(DrugID.Value, q.ID.Value);
            bool for_eoc = false;

            if(eocForQ != null)
            {
                if(eocForQ.AppliesTo.Any(r => Framework.Security.Manager.HasRole(r)))
                {
                    for_eoc = true;
                }
            }

            string cssClass = "clearfix form-row";
            if (has_children)
                cssClass += " has-children";

            if (q.ParentID.HasValue)
            {
                writer.AddAttribute("data-parent-id", q.ParentID.Value.ToString());
                writer.AddAttribute("data-parent-checks", q.ParentChecks);
                cssClass += " has-parent";
            }

            writer.AddAttribute("data-id", q.ID.Value.ToString());
            writer.AddAttribute("class", cssClass);
            writer.RenderBeginTag("div");

            writer.AddAttribute("class", "form-label");
            writer.AddAttribute("for", "form-q-"+q.ID.Value.ToString());
            writer.RenderBeginTag("label");

            if( for_eoc )
            {
                writer.AddAttribute( "class", "form-label-text" );
                writer.RenderBeginTag( "span" );
            }

            writer.WriteEncodedText(q.ViewText);

            if( for_eoc )
            {
                writer.RenderEndTag();

                writer.AddAttribute( "class", "form-label-required" );
                writer.RenderBeginTag( "span" );

                if( !string.IsNullOrEmpty( a ) )
                    writer.WriteEncodedText( a );

                writer.RenderEndTag();
            }

            writer.RenderEndTag();

            writer.AddAttribute("class", "form-input");
            writer.RenderBeginTag("div");

            writer.AddAttribute("class", "form-info");
            writer.AddAttribute("name", "q-" + q.ID.Value.ToString());
//.........这里部分代码省略.........
开发者ID:REMSLogic,项目名称:REMSLogic,代码行数:101,代码来源:DSQView.cs

示例2: RenderQuestion

        protected void RenderQuestion(HtmlTextWriter writer, Lib.Data.DSQ.Question q)
        {
            if (q==null || !q.ID.HasValue)
                return;

            string a = null;
            bool pending_changes = false;
            if (DrugID != null)
            {
                var answer = Lib.Data.DSQ.Answer.FindByDrug(DrugID.Value, q.ID.Value);
                if (answer != null && answer.ID.HasValue)
                {
                    a = answer.Value;
                    if( version.HasValue )
                    {
                        var av = Lib.Data.DSQ.AnswerVersion.FindByDrugVersion(DrugID.Value, version.Value, answer.ID.Value);
                        if( av != null && av.ID.HasValue )
                        {
                            a = av.Value;
                            pending_changes = true;
                        }
                    }
                }
            }

            if( !q.ShouldShowQuestion( true, a ) )
                return;

            if( q.FieldType == "Link List" )
            {
                RenderQuestion_LinkList(writer, q, a, pending_changes);
                return;
            }
            else if( q.FieldType == "EOC" )
            {
                RenderQuestion_EOC( writer, q, a, pending_changes );
                return;
            }

            var children = Lib.Data.DSQ.Question.FindByParent(q);
            bool has_children = false;

            if (children.Count > 0)
                has_children = true;

            string cssClass = "clearfix form-row";
            if( has_children )
                cssClass += " has-children";
            if( pending_changes )
                cssClass += " pending-changes";

            if( q.ParentID.HasValue )
            {
                writer.AddAttribute( "data-parent-id", q.ParentID.Value.ToString() );
                writer.AddAttribute( "data-parent-checks", q.ParentChecks );
            }

            writer.AddAttribute( "data-id", q.ID.Value.ToString() );
            writer.AddAttribute( "class", cssClass );
            writer.RenderBeginTag( "div" );

            writer.AddAttribute( "class", "form-label" );
            writer.AddAttribute( "for", "form-q-" + q.ID.Value.ToString() );
            writer.RenderBeginTag( "label" );

            writer.AddAttribute("class", "edit-question-button");
            writer.AddAttribute("data-id", q.ID.Value.ToString());
            writer.RenderBeginTag("span");
            writer.WriteEncodedText("Edit");
            writer.RenderEndTag();

            if(q.HideFromView)
                writer.AddAttribute("class", "form-label-hidden-question");

            writer.RenderBeginTag("span");
            writer.WriteEncodedText( q.Text );
            writer.RenderEndTag();

            if( q.Required )
            {
                writer.WriteEncodedText( " " );
                writer.RenderBeginTag( "em" );
                writer.WriteEncodedText( "*" );
                writer.RenderEndTag();
            }

            writer.RenderEndTag();

            switch( q.FieldType )
            {
            case "TextBox":
                RenderQuestion_TextBox( writer, q, a );
                break;
            case "TextArea":
                RenderQuestion_TextArea( writer, q, a );
                break;
            case "Yes/No":
                RenderQuestion_YesNo( writer, q, a );
                break;
            case "Checkbox":
//.........这里部分代码省略.........
开发者ID:REMSLogic,项目名称:REMSLogic,代码行数:101,代码来源:DSQ.cs


注:本文中的Lib.ShouldShowQuestion方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。