private void SetCollectionValue(WebDevPage.IHTMLElement controlElement, PropertyInfo prop, Infolight.EasilyReportTools.DataSourceItemCollection collection) { if (controlElement != null) { string collectionxml = GetCollectionXml(prop, collection); if (collectionxml.Length > 0) { string html = controlElement.innerHTML; int index = IndexOfBeginTag(html, prop.Name); int length; if (index <= 0) { index = 0; } controlElement.innerHTML = html.Insert(index, collectionxml); } } }
private string GetCollectionXml(PropertyInfo prop, Infolight.EasilyReportTools.ReportItemCollection collection) { StringBuilder builder = new StringBuilder(); if (prop != null && collection != null && prop.PropertyType == collection.GetType()) { if (collection.Count > 0) { builder.AppendLine(string.Format("\t<{0}>", prop.Name)); for (int i = 0; i < collection.Count; i++) { builder.Append(string.Format("\t\t<{0}:{1} ", "cc1", collection[i].GetType().Name)); PropertyInfo[] infos = collection[i].GetType().GetProperties(); for (int j = 0; j < infos.Length; j++) { if (!IsVisibilityHidden(infos[j])) { if (infos[j].PropertyType == typeof(string) || infos[j].PropertyType == typeof(int) || infos[j].PropertyType == typeof(bool) || infos[j].PropertyType.BaseType == typeof(Enum)) { if (!infos[j].Name.Equals("Name")) { object value = infos[j].GetValue(collection[i], null); object defaultvalue = GetDefaultValue(infos[j]); if (infos[j].CanWrite && value != defaultvalue) { builder.Append(string.Format("{0}=\"{1}\" ", infos[j].Name, value)); } } } } } builder.AppendLine("/>"); } builder.AppendLine(string.Format("\t</{0}>", prop.Name)); } } return builder.ToString(); }
private string GetCollectionXml(PropertyInfo prop, Infolight.EasilyReportTools.DataSourceItemCollection collection) { StringBuilder builder = new StringBuilder(); if (prop != null && collection != null && prop.PropertyType == collection.GetType()) { if (collection.Count > 0) { builder.AppendLine(string.Format("\t<{0}>", prop.Name)); for (int i = 0; i < collection.Count; i++) { builder.Append(string.Format("\t\t<{0}:{1} ", "cc1", collection[i].GetType().Name)); PropertyInfo[] infos = collection[i].GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly); for (int j = 0; j < infos.Length; j++) { if (!IsVisibilityHidden(infos[j])) { if (infos[j].PropertyType == typeof(string) || infos[j].PropertyType == typeof(int) || infos[j].PropertyType == typeof(bool) || infos[j].PropertyType.BaseType == typeof(Enum)) { if (!infos[j].Name.Equals("Name")) { object value = infos[j].GetValue(collection[i], null); object defaultvalue = GetDefaultValue(infos[j]); if (infos[j].CanWrite && value != defaultvalue) { builder.Append(string.Format("{0}=\"{1}\" ", infos[j].Name, value)); } } } if (infos[j].PropertyType == typeof(Infolight.EasilyReportTools.FieldItemCollection)) { builder.AppendLine(">"); builder.AppendLine(string.Format("\t\t<{0}>", infos[j].Name)); Infolight.EasilyReportTools.FieldItemCollection fieldItemCollection = (Infolight.EasilyReportTools.FieldItemCollection)infos[j].GetValue(collection[i], null); foreach (Infolight.EasilyReportTools.FieldItem item in fieldItemCollection) { builder.Append(string.Format("\t\t\t<{0}:{1} ", "cc1", item.GetType().Name)); PropertyInfo[] itemProps = item.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly); for (int k = 0; k < itemProps.Length; k++) { if (!IsVisibilityHidden(itemProps[k])) { if (itemProps[k].PropertyType == typeof(string) || itemProps[k].PropertyType == typeof(int) || itemProps[k].PropertyType == typeof(bool) || itemProps[k].PropertyType.BaseType == typeof(Enum)) { if (!itemProps[k].Name.Equals("Name")) { object itemValue = itemProps[k].GetValue(item, null); object itemDefaultvalue = GetDefaultValue(itemProps[k]); if (itemProps[k].CanWrite && itemValue != itemDefaultvalue) { builder.Append(string.Format("{0}=\"{1}\" ", itemProps[k].Name, itemValue)); } } } } } builder.AppendLine("/>"); } builder.AppendLine(string.Format("\t\t</{0}>", infos[j].Name)); } } } builder.Append(string.Format("\t\t</{0}:{1}>", "cc1", collection[i].GetType().Name)); } builder.AppendLine(string.Format("\t</{0}>", prop.Name)); } } return builder.ToString(); }
/// <summary> /// ������� /// </summary> /// <param name="groupColumn">���ܵ���λ</param> /// <param name="sumType">���ܵ�����</param> /// <param name="table">DataTable</param> /// <param name="row">DataRow</param> /// <param name="columns">�������λ</param> /// <returns>���ܵĽ��</returns> private object GroupTotal(string groupColumn, Infolight.EasilyReportTools.FieldItem.SumType sumType, DataTable table, DataRow row, List<string> columns) { if (string.IsNullOrEmpty(groupFilter)) { StringBuilder filter = new StringBuilder(); if (row != null) { foreach (string col in columns) { if (table.Columns.Contains(col)) { DataColumn column = table.Columns[col]; if (filter.Length > 0) { filter.Append(" And "); } filter.Append(col); filter.Append("="); if (column.DataType == typeof(string) || column.DataType == typeof(Guid)) { filter.Append(string.Format("'{0}'", row[col])); } else if (column.DataType == typeof(DateTime)) { filter.Append(string.Format("'{0:yyyy/MM/dd HH:mm:ss.fff}'", row[col])); } else { filter.Append(string.Format("{0}", row[col])); } } else { throw new Exception(string.Format("column:{0} not in table", col)); } } } groupFilter = filter.ToString(); } return table.Compute(string.Format("{0}({1})", sumType, groupColumn), groupFilter); }