| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429 | 
							- using DevExpress.XtraReports.UI;
 
- using iBemsDataService.Controllers;
 
- using System;
 
- using System.Collections.Generic;
 
- using System.Diagnostics;
 
- using System.Drawing;
 
- using System.Linq;
 
- using System.Net;
 
- using System.Reflection;
 
- using System.Web;
 
- namespace iBemsDataService.Util
 
- {
 
-     public class ReportTableHandler
 
-     {
 
-         public static XRTable CreateTableFromEnergyWithWidth<T>(List<T> list, float[] columnWidth)
 
-         {
 
-             XRTable table = CreateTableFromEnergy(list);
 
-             AdjustTextSizeEnergy(table, columnWidth);
 
-             return table;
 
-         }
 
-         public static XRTable CreateTableFromEnergy<T>(List<T> list)
 
-         {
 
-             XRTable table = new XRTable();
 
-             table.LocationF = new PointF(0, 0);
 
-             table.Font = new System.Drawing.Font("맑은 고딕", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
 
-             table.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleRight;
 
-             List<XRTableRow> rowListtop = ConvertEnergyToTableRowstop(list);
 
-             for (var i = 0; i < rowListtop.Count; i++)
 
-             {
 
-                 table.Rows.Add(rowListtop[i]);
 
-             }
 
-             table.AdjustSize();
 
-             table.EndInit();
 
-             table.WidthF = 839f;
 
-             return table;
 
-         }
 
-         private static List<XRTableRow> ConvertEnergyToTableRowstop<T>(List<T> list)
 
-         {
 
-             List<XRTableRow> rowList = new List<XRTableRow>();
 
-             String[] Text = { "TextResultDate", "TextResult" };
 
-             Type type = typeof(T);
 
-             foreach (T item in list)
 
-             {
 
-                 XRTableRow newRow = MakeXrTableRowTemplate();
 
-                 foreach (PropertyInfo propertyInfo in type.GetProperties())
 
-                 {
 
-                     var obj = propertyInfo.GetValue(item);
 
-                     String cellText = "";
 
-                     bool colorchekck = false;
 
-                     if (propertyInfo.Name.ToString() == "Name")
 
-                     {
 
-                         if (obj != null)
 
-                         {
 
-                             cellText = (String)obj;
 
-                             if (cellText.IndexOf("합계") != -1)
 
-                             {
 
-                                 colorchekck = true;
 
-                             }
 
-                         }
 
-                     }
 
-                     else if (propertyInfo.Name.ToString() == "Today")
 
-                     {
 
-                         if (obj != null)
 
-                         {
 
-                             cellText = obj.ToString();
 
-                         }
 
-                     }
 
-                     else if (propertyInfo.Name.ToString() == "Daybefore")
 
-                     {
 
-                         if (obj != null)
 
-                         {
 
-                             cellText = obj.ToString();
 
-                         }
 
-                     }
 
-                     else if (propertyInfo.Name.ToString() == "Dailyusage")
 
-                     {
 
-                         if (obj != null)
 
-                         {
 
-                             cellText = obj.ToString();
 
-                         }
 
-                     }
 
-                     else
 
-                     {
 
-                         if (obj != null)
 
-                         {
 
-                             cellText = obj.ToString();
 
-                         }
 
-                     }
 
-                     XRTableCell newcell = new XRTableCell();
 
-                     newcell.Text = cellText;
 
-                     if (propertyInfo.Name.ToString() == "Name")
 
-                     {
 
-                         newcell.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
 
-                     }
 
-                     newRow.Cells.Add(newcell);
 
-                     if (colorchekck)
 
-                     {
 
-                         newRow.BackColor = Color.FromArgb(255, 255, 204);
 
-                         colorchekck = false;
 
-                     }
 
-                 }
 
-                 rowList.Add(newRow);
 
-             }
 
-             return rowList;
 
-         }
 
-         public static XRTable CreateTableFromListWithColumnWidth<T>(List<T> list, float[] columnWidth, String[] exceptions = null)
 
-         {
 
-             XRTable table = CreateTableFromList(list, exceptions);
 
-             AdjustTextSize(table, columnWidth);
 
-             return table;
 
-         }
 
-         public static XRTable CreateTableFromListWithColumnWidthPatrol<T>(List<T> list, float[] columnWidth, String[] exceptions = null)
 
-         {
 
-             XRTable table = CreateTableFromListPatrol(list, exceptions);
 
-             AdjustTextSizePatrol(table, columnWidth);
 
-             return table;
 
-         }
 
-         public static XRTable CreateTableFromList<T>(List<T> list, String[] exceptions = null)
 
-         {
 
-             XRTable table = new XRTable();
 
-             table.LocationF = new PointF(0, 0);
 
-             table.Font = new System.Drawing.Font("맑은 고딕", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
 
-             table.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
 
-             table.BeginInit();
 
-             List<XRTableRow> rowListtop = ConvertListToTableRowstop(list, exceptions);
 
-             List<XRTableRow> rowListbottom = ConvertListToTableRowsbottom(list, exceptions);
 
-             for (var i = 0; i < rowListtop.Count; i++)
 
-             {
 
-                 table.Rows.Add(rowListtop[i]);
 
-                 table.Rows.Add(rowListbottom[i]);
 
-             }
 
-             for (var i = 1; i < rowListtop.Count * 2; i += 2)
 
-             {
 
-                 table.Rows[i].TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleLeft;
 
-             }
 
-             table.AdjustSize();
 
-             table.EndInit();
 
-             table.WidthF = 839f;
 
-             return table;
 
-         }
 
-         public static XRTable CreateTableFromListPatrol<T>(List<T> list, String[] exceptions = null)
 
-         {
 
-             XRTable table = new XRTable();
 
-             table.LocationF = new PointF(0, 0);
 
-             table.Font = new System.Drawing.Font("맑은 고딕", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
 
-             table.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
 
-             table.BeginInit();
 
-             List<XRTableRow> rowListtop = ConvertListToTableRowstop(list, exceptions);
 
-             List<XRTableRow> rowListbottom = ConvertListToTableRowsbottom(list, exceptions);
 
-             for (var i = 0; i < rowListtop.Count; i++)
 
-             {
 
-                 table.Rows.Add(rowListtop[i]);
 
-                 //table.Rows.Add(rowListbottom[i]);
 
-             }
 
-             //for (var i = 1; i < rowListtop.Count; i += 2)
 
-             //{
 
-             //    table.Rows[i].TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleLeft;
 
-             //}
 
-             table.AdjustSize();
 
-             table.EndInit();
 
-             table.WidthF = 800f;
 
-             return table;
 
-         }
 
-         public static XRTable CreateTableFromListWithColumnWidthMaterial<T>(List<T> list, float[] columnWidth, String[] exceptions = null)
 
-         {
 
-             XRTable table = CreateTableFromListMaterial(list, exceptions);
 
-             AdjustTextSize(table, columnWidth);
 
-             return table;
 
-         }
 
-         public static XRTable CreateTableFromListMaterial<T>(List<T> list, String[] exceptions = null)
 
-         {
 
-             XRTable table = new XRTable();
 
-             table.LocationF = new PointF(0, 0);
 
-             table.Font = new System.Drawing.Font("맑은 고딕", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
 
-             table.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
 
-             table.BeginInit();
 
-             List<XRTableRow> rowListtop = ConvertListToTableRowstop(list, exceptions);
 
-             for (var i = 0; i < rowListtop.Count; i++)
 
-             {
 
-                 table.Rows.Add(rowListtop[i]);
 
-             }
 
-             table.AdjustSize();
 
-             table.EndInit();
 
-             table.WidthF = 839f;
 
-             return table;
 
-         }
 
-         private static void AdjustTextSize(XRTable table, float[] columnWidth)
 
-         {
 
-             float[] columnWidthbottom = { 230f, 609f, 839f };
 
-             foreach (XRTableRow row in table.Rows)
 
-             {
 
-                 for (int i = 0; i < row.Cells.Count; i++)
 
-                 {
 
-                     if (row.Cells.Count > 2)
 
-                     {
 
-                         XRTableCell cell = row.Cells[i];
 
-                         if (columnWidth != null)
 
-                         {
 
-                             cell.SizeF = new SizeF(columnWidth[i], cell.SizeF.Height);
 
-                         }
 
-                     }
 
-                     else
 
-                     {
 
-                         XRTableCell cell = row.Cells[i];
 
-                         if (columnWidth != null)
 
-                         {
 
-                             cell.SizeF = new SizeF(columnWidthbottom[2], cell.SizeF.Height);
 
-                         }
 
-                     }
 
-                 }
 
-             }
 
-         }
 
-         private static void AdjustTextSizePatrol(XRTable table, float[] columnWidth)
 
-         {
 
-             float[] columnWidthbottom = { 230f, 609f, 800f };
 
-             foreach (XRTableRow row in table.Rows)
 
-             {
 
-                 for (int i = 0; i < row.Cells.Count; i++)
 
-                 {
 
-                     if (row.Cells.Count > 2)
 
-                     {
 
-                         XRTableCell cell = row.Cells[i];
 
-                         if (columnWidth != null)
 
-                         {
 
-                             cell.SizeF = new SizeF(columnWidth[i], cell.SizeF.Height);
 
-                         }
 
-                     }
 
-                     else
 
-                     {
 
-                         XRTableCell cell = row.Cells[i];
 
-                         if (columnWidth != null)
 
-                         {
 
-                             cell.SizeF = new SizeF(columnWidthbottom[2], cell.SizeF.Height);
 
-                         }
 
-                     }
 
-                 }
 
-             }
 
-         }
 
-         private static void AdjustTextSizeEnergy(XRTable table, float[] columnWidth)
 
-         {
 
-             foreach (XRTableRow row in table.Rows)
 
-             {
 
-                 for (int i = 0; i < row.Cells.Count; i++)
 
-                 {
 
-                     XRTableCell cell = row.Cells[i];
 
-                     if (columnWidth != null)
 
-                     {
 
-                         cell.SizeF = new SizeF(columnWidth[i], cell.SizeF.Height);
 
-                     }
 
-                 }
 
-             }
 
-         }
 
-         private static List<XRTableRow> ConvertListToTableRowstop<T>(List<T> list, String[] exceptions)
 
-         {
 
-             List<XRTableRow> rowList = new List<XRTableRow>();
 
-             Type type = typeof(T);
 
-             String[] Text = { "TextResultDate", "TextResult" };
 
-             foreach (T item in list)
 
-             {
 
-                 XRTableRow newRow = MakeXrTableRowTemplate();
 
-                 foreach (PropertyInfo propertyInfo in type.GetProperties())
 
-                 {
 
-                     if (exceptions != null && exceptions.Contains(propertyInfo.Name)) continue;
 
-                     if (Text.Contains(propertyInfo.Name)) continue;
 
-                     var obj = propertyInfo.GetValue(item);
 
-                     String cellText = null;
 
-                     if (obj != null)
 
-                     {
 
-                         cellText = obj.ToString();
 
-                     }
 
-                     XRTableCell newCell = new XRTableCell();
 
-                     newCell.Text = cellText;
 
-                     newRow.Cells.Add(newCell);
 
-                 }
 
-                 rowList.Add(newRow);
 
-             }
 
-             return rowList;
 
-         }
 
-         private static List<XRTableRow> ConvertListToTableRowsbottom<T>(List<T> list, String[] exceptions)
 
-         {
 
-             List<XRTableRow> rowList = new List<XRTableRow>();
 
-             Type type = typeof(T);
 
-             String[] Text = { "TextResultDate", "TextResult" };
 
-             foreach (T item in list)
 
-             {
 
-                 XRTableRow newRow = MakeXrTableRowTemplate();
 
-                 //String cellText = null;
 
-                 String[] temptext = new string[1];
 
-                 foreach (PropertyInfo propertyInfo in type.GetProperties())
 
-                 {
 
-                     if (exceptions != null && exceptions.Contains(propertyInfo.Name)) continue;
 
-                     if (!Text.Contains(propertyInfo.Name)) continue;
 
-                     var obj = propertyInfo.GetValue(item);
 
-                     if (propertyInfo.Name.ToString() == "TextResultDate")
 
-                     {
 
-                         if (obj != null)
 
-                         {
 
-                             DateTime[] TextResultDate = (DateTime[])obj;
 
-                             temptext = new string[TextResultDate.Count()];
 
-                         }
 
-                         else
 
-                         {
 
-                             temptext = null;
 
-                         }
 
-                     }
 
-                     if (propertyInfo.Name.ToString() == "TextResultDate")
 
-                     {
 
-                         DateTime[] TextResultDate = (DateTime[])obj;
 
-                         if (TextResultDate != null)
 
-                         {
 
-                             for (var i = 0; i < TextResultDate.Count(); i++)
 
-                             {
 
-                                 temptext[i] = "   " + TextResultDate[i].ToString("yyyy-MM-dd");
 
-                             }
 
-                         }
 
-                         else
 
-                         {
 
-                             //for (var i = 0; i < TextResultDate.Count(); i++)
 
-                             //{
 
-                             //    temptext[i] = "";
 
-                             //}
 
-                         }
 
-                     }
 
-                     else if (propertyInfo.Name.ToString() == "TextResult")
 
-                     {
 
-                         String[] TextResult = (String[])obj;
 
-                         //var seven = 50;
 
-                         if (TextResult != null)
 
-                         {
 
-                             for (var i = 0; i < TextResult.Count(); i++)
 
-                             {
 
-                                 //var result = TextResult[i].Replace("\n", " ");       //.replace(/\n/gi, '</p><p>      ');
 
-                                 //temptext[i] += " - " + result + "\r\n";
 
-                                 var result = TextResult[i].Replace("\n", "\n                  ");
 
-                                 result = result.Replace("?-", " -");
 
-                                 temptext[i] += " - " + result + "\r\n";
 
-                                 //if (temptext[i].Length > seven)
 
-                                 //{
 
-                                 //    temptext[i] = factorial(temptext[i]);
 
-                                 //}
 
-                             }
 
-                         }
 
-                         else
 
-                         {
 
-                             //for (var i = 0; i < TextResult.Count(); i++)
 
-                             //{
 
-                             //    temptext[i] += "";
 
-                             //}
 
-                         }
 
-                     }
 
-                 }
 
-                 XRTableCell newCell = new XRTableCell();
 
-                 string finaltempstring = "";
 
-                 if (temptext != null)
 
-                 {
 
-                     for (var i = 0; i < temptext.Length; i++)
 
-                     {
 
-                         finaltempstring += temptext[i];
 
-                     }
 
-                 }
 
-                 else
 
-                 {
 
-                     finaltempstring = "";
 
-                 }
 
-                 newCell.Text = finaltempstring;
 
-                 newCell.Multiline = true;
 
-                 newRow.Cells.Add(newCell);
 
-                 rowList.Add(newRow);
 
-             }
 
-             return rowList;
 
-         }
 
-         public static string factorial(string temp)
 
-         {
 
-             var seven = 50;
 
-             var forcnt = temp.Length / seven; //몫
 
-             var forcnt1 = temp.Length % seven; //나머지
 
-             if (forcnt == 0)
 
-             {
 
-                 return temp;
 
-             }
 
-             else if (forcnt != 0 && forcnt1 != 0)
 
-             {
 
-                 return temp.Substring(0, seven) + "\r\n" + factorial(temp.Substring(seven));
 
-             }
 
-             else
 
-             {
 
-                 return temp.Substring(0, seven);
 
-             }
 
-         }
 
-         private static XRTableRow MakeXrTableRowTemplate()
 
-         {
 
-             XRTableRow newRow = new XRTableRow();
 
-             newRow.BorderColor = Color.Black;
 
-             newRow.BorderWidth = 1;
 
-             newRow.Borders = DevExpress.XtraPrinting.BorderSide.All;
 
-             newRow.HeightF = 30f;
 
-             return newRow;
 
-         }
 
-     }
 
- }
 
 
  |