private string ProcessInputTextTag(SWInputTextTag tag, DBContent.TagValueItemTypes htmlType, out string errormessage) { errormessage = ""; if (tag == null) { return(""); } switch (htmlType) { case DBContent.TagValueItemTypes.Form: string html = String.Format("<input type=\"text\" class=\"form-control\" id = \"i{0}\" name=\"{0}\" />", tag.Name); if (this.PhysicalFormValues.ContainsKey(tag.Name)) { html += "<script>$(document).ready(function (){"; html += String.Format("$('#i{0}').val('{1}');", tag.Name, this.PhysicalFormValues[tag.Name]); html += "});</script>"; } return(html); case DBContent.TagValueItemTypes.Template: if (this.PhysicalFormValues.ContainsKey(tag.Name)) { object value = this.PhysicalFormValues[tag.Name]; if (value != null) { return(WebUtility.HtmlEncode(value.ToString())); } } break; } return(""); }
private string ProcessVarTag(SWVarTag tag, DBContent.TagValueItemTypes htmlType, out string errormessage) { errormessage = ""; if (tag == null) { return(""); } ReadOnlyCollection <SWBaseTag> lst = null; switch (htmlType) { case DBContent.TagValueItemTypes.Form: lst = this.ReportItem.FormTags; break; case DBContent.TagValueItemTypes.Template: lst = this.ReportItem.TemplateTags; break; } tag = (from t in lst where tag.Name.ToLower().Equals(t.Name.ToLower()) && tag.TagType.Equals(t.TagType) select t as SWVarTag).FirstOrDefault(); if (tag == null) { return(""); } return(tag.Value); }
private string ProcessSelectTag(SWSelectTag tag, DBContent.TagValueItemTypes htmlType, out string errormessage) { errormessage = ""; switch (htmlType) { case DBContent.TagValueItemTypes.Template: return(ProcessSelectTag_Template(tag, out errormessage)); case DBContent.TagValueItemTypes.Form: return(ProcessSelectTag_Form(tag, out errormessage)); } return(""); }
private string ProcessTag(SWBaseTag tag, DBContent.TagValueItemTypes htmlType, out string errormessage) { errormessage = ""; if (tag == null) { return(""); } switch (tag.TagType) { case SWInputTextTag.Type: return(this.ProcessInputTextTag(tag as SWInputTextTag, htmlType, out errormessage)); case SWInputDateTag.Type: case SWInputTimeTag.Type: return(this.ProcessInputDateTimeTag(tag as SWBaseInputDateTimeTag, htmlType, out errormessage)); case SWDateTag.Type: return(DateTime.Now.ToString()); case SWVarTag.Type: return(this.ProcessVarTag(tag as SWVarTag, htmlType, out errormessage)); case SWQueryTag.Type: return(this.ProcessQueryTag(tag as SWQueryTag, out errormessage)); case SWSelectTag.Type: return(this.ProcessSelectTag(tag as SWSelectTag, htmlType, out errormessage)); /* case SWInputDateTag.Type: * switch (htmlType) * { * case DBContent.TagValueItemTypes.Form: * return this.ProcessInputDateTag(foundTag as SWInputDateTag, out errormessage); * case DBContent.TagValueItemTypes.Template: * return foundTag.Value; * } * break;*/ } return(""); }
private void CreateHTML(out string errormessage, ref string html, DBContent.TagValueItemTypes htmlType) { errormessage = ""; if (String.IsNullOrWhiteSpace(html)) { return; } int startIndex = -1; int endIndex = -1; while ((startIndex = html.IndexOf(SWBaseTag.TagStart.ToLower(), endIndex + 1, StringComparison.CurrentCultureIgnoreCase)) >= 0) { endIndex = html.IndexOf(SWBaseTag.TagEnd.ToLower(), startIndex); int tempStart = html.IndexOf(SWBaseTag.TagStart.ToLower()); if (tempStart > endIndex) { continue; } string xmlTag = html.Substring(startIndex, endIndex - startIndex + 1); XmlDocument doc = new XmlDocument(); doc.LoadXml(xmlTag.ToLower()); XmlNode newNode = doc.DocumentElement; SWBaseTag tag = null; XmlAttribute typeAttr = newNode.Attributes[SWBaseTag.TypeAttribute]; if (typeAttr != null) { tag = SWBaseTag.GetTag(typeAttr.Value); } if (tag == null) { continue; } XmlAttribute nameAttr = newNode.Attributes[SWBaseTag.NameAttribute]; if (nameAttr != null) { tag.Name = nameAttr.Value; } string newHTML = this.ProcessTag(tag, htmlType, out errormessage); if (newHTML == null) { newHTML = ""; } int s = newHTML.Length; if (!String.IsNullOrWhiteSpace(errormessage)) { html = null; return; } html = html.Substring(0, startIndex) + newHTML + html.Substring(endIndex + 1, html.Length - endIndex - 1); int takeaway = endIndex - startIndex + 1; startIndex += newHTML.Length - takeaway; endIndex += newHTML.Length - takeaway; } }
private string ProcessInputDateTimeTag(SWBaseInputDateTimeTag tag, DBContent.TagValueItemTypes htmlType, out string errormessage) { errormessage = ""; if (tag == null) { return(""); } switch (htmlType) { case DBContent.TagValueItemTypes.Form: string html = ""; string typealias = ""; switch (tag.TagType) { case SWInputDateTag.Type: typealias = "date"; break; case SWInputTimeTag.Type: typealias = "time"; break; } html += String.Format("<input type=\"{0}\" class=\"form-control\" id = \"i{1}\" name=\"{1}\" />", typealias, tag.Name); if (this.PhysicalFormValues.ContainsKey(tag.Name)) { html += "<script>$(document).ready(function (){"; html += String.Format("$('#i{0}').val('{1}');", tag.Name, this.PhysicalFormValues[tag.Name]); html += "});</script>"; } else { html += @"<script>$(document).ready(function () { var now = new Date(); var day = ('0' + now.getDate()).slice(-2); var month = ('0' + (now.getMonth() + 1)).slice(-2); var today = now.getFullYear()+'-'+(month)+'-'+(day); var todaytime = now.getHours() + ':' + now.getMinutes() + ':' + now.getSeconds(); "; switch (tag.TagType) { case SWInputDateTag.Type: html += String.Format("$('#i{0}').val(today);", tag.Name); break; case SWInputTimeTag.Type: html += String.Format("$('#i{0}').val(todaytime);", tag.Name); break; } html += "});</script>"; } return(html); case DBContent.TagValueItemTypes.Template: if (this.PhysicalFormValues.ContainsKey(tag.Name)) { object value = this.PhysicalFormValues[tag.Name]; if (value != null) { return(WebUtility.HtmlEncode(value.ToString())); } } break; } return(""); }