Ejemplo n.º 1
0
        public static SWBaseTag GetTag(string type)
        {
            if (String.IsNullOrWhiteSpace(type))
            {
                return(null);
            }
            type = type.ToLower();

            SWBaseTag tag = null;

            switch (type)
            {
            case SWInputTextTag.Type:
                tag = new SWInputTextTag();
                break;

            case SWDateTag.Type:
                tag = new SWDateTag();
                break;

            case SWVarTag.Type:
                tag = new SWVarTag();
                break;

            case SWQueryTag.Type:
                tag = new SWQueryTag();
                break;

            case SWSelectTag.Type:
                tag = new SWSelectTag();
                break;

            case SWInputDateTag.Type:
                tag = new SWInputDateTag();
                break;

            case SWInputTimeTag.Type:
                tag = new SWInputTimeTag();
                break;
            }
            return(tag);
        }
Ejemplo n.º 2
0
        public static SWBaseTag GetTag(string type)
        {
            if (String.IsNullOrWhiteSpace(type)) return null;
            type = type.ToLower();

            SWBaseTag tag = null;
            switch (type)
            {
                case SWInputTextTag.Type:
                    tag = new SWInputTextTag();
                    break;
                case SWDateTag.Type:
                    tag = new SWDateTag();
                    break;
                case SWVarTag.Type:
                    tag = new SWVarTag();
                    break;
                case SWQueryTag.Type:
                    tag = new SWQueryTag();
                    break;
                case SWSelectTag.Type:
                    tag = new SWSelectTag();
                    break;
                case SWInputDateTag.Type:
                    tag = new SWInputDateTag();
                    break;
                case SWInputTimeTag.Type:
                    tag = new SWInputTimeTag();
                    break;
            }
            return tag;
        }
        private string ProcessQueryTag(SWQueryTag tag, out string errormessage)
        {
            errormessage = "";
            if (tag == null) return "";

            tag = (from t in this.ReportItem.TemplateTags
                   where tag.Name.ToLower().Equals(t.Name.ToLower()) &&
                   tag.TagType.Equals(t.TagType)
                   select t as SWQueryTag).FirstOrDefault();
            if (tag == null) return "";

            string result = "<table class=\"table table-striped table-bordered table-hover dataTable no-footer\">";
            DbDataReader reader = null;
            DbConnection conn = null;
            try
            {
                reader = ConnectionItem.GetReader(this.ReportItem.ConnectionItem, tag.Value, out errormessage, out conn, this.SetupQueryParameters(tag));

                if (reader != null)
                {
                    result += "<thead>";
                    result += "<tr role=\"row\">";
                    for (int i = 0; i < reader.FieldCount; i++)
                    {
                        result += String.Format("<th class=\"sorting_asc\" tabindex=\"0\" rowspan=\"1\" colspan=\"1\">{0}</th>", reader.GetName(i));
                    }
                    result += "</tr>";
                    result += "</thead>";

                    string isSame = "";
                    while (reader.Read())
                    {
                        result += "<tr>";
                        for (int i = 0; i < reader.FieldCount; ++i)
                        {
                            string value = reader[i].ToString();
                            if (!(value.StartsWith("<") && value.EndsWith("/>")))
                            {
                                value = WebUtility.HtmlEncode(value);
                                if (i == 0)
                                {
                                    if (String.Equals(isSame, value))
                                    {
                                        value = "";
                                    }
                                    else
                                    {
                                        isSame = value;
                                    }
                                }
                            }
                            result += String.Format("<td>{0}</td>", value);
                        }
                        result += "</tr>";
                    }
                }
            }
            catch (Exception ex)
            {
                errormessage = ex.Message;
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                    reader.Dispose();
                    reader = null;
                }

                if (conn != null)
                {
                    conn.Close();
                    conn = null;
                }
            }
            result += "</table>";
            return result;
        }