本文整理汇总了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());
//.........这里部分代码省略.........
示例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":
//.........这里部分代码省略.........