コード例 #1
0
		/// <summary>
		/// Read report group summary info.
		/// </summary>
		/// <param name="reader">The data reader.</param>
		/// <returns>The group summary.</returns>
		public virtual APRptJsonGroupSummary ReadGroupSummary(IDataReader reader)
		{
			// Group root, none text
			APRptJsonGroupSummary rootSummary = new APRptJsonGroupSummary("");

			while (reader.Read())
			{
				APRptJsonGroupSummary summary = rootSummary;
				int count = (int)reader[COUNT_ALIAS];
				summary.count += count;

				foreach (APRptGroupDef groupDef in _def.Groups)
				{
					APRptColumn column = _source.AllColumns[groupDef.ColumnId];

					object value = column.Json(reader);
					object key;
					string text;

					if (value == null || value == DBNull.Value)
					{
						key = text = "";
					}
					else if (column is DateTimeAPRptColumn)
					{
						key = text = GetDateGroupText((DateTime)value, groupDef.DateGroupMode);
					}
					else if (column is LookupAPRptColumn)
					{
						key = reader[column.DataName];
						text = Convert.ToString((column as LookupAPRptColumn).RelationShowColumn.Json(reader));
					}
					else
					{
						key = value;
						text = Convert.ToString(value);
					}


					if (summary.subgroups != null && summary.subgroups.ContainsKey(key))
					{
						summary = summary.subgroups[key];
					}
					else
					{
						APRptJsonGroupSummary subSummary = new APRptJsonGroupSummary(text) { value = value };
						if (summary.subgroups == null)
							summary.subgroups = new Dictionary<object, APRptJsonGroupSummary>();
						summary.subgroups[key] = subSummary;
						summary = subSummary;
					}

					summary.count += count;
				}
			}

			return rootSummary;
		}
コード例 #2
0
        /// <summary>
        /// Read report group summary info.
        /// </summary>
        /// <param name="reader">The data reader.</param>
        /// <returns>The group summary.</returns>
        public virtual APRptJsonGroupSummary ReadGroupSummary(IDataReader reader)
        {
            // Group root, none text
            APRptJsonGroupSummary rootSummary = new APRptJsonGroupSummary("");

            while (reader.Read())
            {
                APRptJsonGroupSummary summary = rootSummary;
                int count = (int)reader[COUNT_ALIAS];
                summary.count += count;

                foreach (APRptGroupDef groupDef in _def.Groups)
                {
                    APRptColumn column = _source.AllColumns[groupDef.ColumnId];

                    object value = column.Json(reader);
                    object key;
                    string text;

                    if (value == null || value == DBNull.Value)
                    {
                        key = text = "";
                    }
                    else if (column is DateTimeAPRptColumn)
                    {
                        key = text = GetDateGroupText((DateTime)value, groupDef.DateGroupMode);
                    }
                    else if (column is LookupAPRptColumn)
                    {
                        key  = reader[column.DataName];
                        text = Convert.ToString((column as LookupAPRptColumn).RelationShowColumn.Json(reader));
                    }
                    else
                    {
                        key  = value;
                        text = Convert.ToString(value);
                    }


                    if (summary.subgroups != null && summary.subgroups.ContainsKey(key))
                    {
                        summary = summary.subgroups[key];
                    }
                    else
                    {
                        APRptJsonGroupSummary subSummary = new APRptJsonGroupSummary(text)
                        {
                            value = value
                        };
                        if (summary.subgroups == null)
                        {
                            summary.subgroups = new Dictionary <object, APRptJsonGroupSummary>();
                        }
                        summary.subgroups[key] = subSummary;
                        summary = subSummary;
                    }

                    summary.count += count;
                }
            }

            return(rootSummary);
        }