You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
148 lines
4.7 KiB
148 lines
4.7 KiB
|
|
///-----------------------------------------------------------------------
|
|
/// <copyright file="DBService.cs" company="Origtek">
|
|
/// 程式代號: DBService
|
|
/// 程式名稱: DBService
|
|
/// 程式說明:
|
|
/// 起始作者: Nelson
|
|
/// 起始日期: 2016/09/03 17:03:37
|
|
/// 最新修改人: Hercules
|
|
/// 最新修日期: 2017/05/15 12:24:49
|
|
/// </copyright>
|
|
///-----------------------------------------------------------------------
|
|
|
|
namespace CounsellorBL.BLStructure
|
|
{
|
|
using OT.COM.ArsenalDB;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Globalization;
|
|
using CounsellorBL.Helper;
|
|
|
|
public class QueryResponse
|
|
{
|
|
/// <summary>
|
|
/// 類別成員、類別屬性說明:符合條件總數
|
|
/// </summary>
|
|
public long TotalCount
|
|
{
|
|
get; set;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 類別成員、類別屬性說明:本次回傳總數
|
|
/// </summary>
|
|
public long CurrentCount
|
|
{
|
|
get; set;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 類別成員、類別屬性說明:資料陣列
|
|
/// </summary>
|
|
public List<Dictionary<string, object>> Records
|
|
{
|
|
get;
|
|
} = new List<Dictionary<string, object>>();
|
|
|
|
/// <summary>
|
|
/// 函式名稱:queryResponse
|
|
/// 函式說明:建構式
|
|
/// 起始作者:
|
|
/// 起始日期:
|
|
/// 最新修改人:
|
|
/// 最新修改日:
|
|
/// </summary>
|
|
/// <param name="i_qdsOringinResult">查詢結果</param>
|
|
/// <returns>
|
|
/// 回傳
|
|
/// </returns>
|
|
/// <summary>
|
|
public QueryResponse(QueryDataSet i_qdsOringinResult, Dictionary<string, object> i_dicAdditionDataForEveryRow = null)
|
|
{
|
|
setup(i_qdsOringinResult, i_dicAdditionDataForEveryRow);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 函式名稱:
|
|
/// 函式說明:建構式
|
|
/// 起始作者:
|
|
/// 起始日期:
|
|
/// 最新修改人:
|
|
/// 最新修改日:
|
|
/// </summary>
|
|
/// <param name="參數名稱">
|
|
/// 參數說明
|
|
/// </param>
|
|
/// <returns>
|
|
/// 回傳
|
|
/// </returns>
|
|
/// <summary>
|
|
public QueryResponse()
|
|
{
|
|
}
|
|
|
|
protected void setup(QueryDataSet i_qdsOringinResult, Dictionary<string, object> i_dicAdditionDataForEveryRow = null)
|
|
{
|
|
|
|
if (i_qdsOringinResult != null && i_qdsOringinResult.DATA != null && i_qdsOringinResult.DATA.Tables.Count > 0)
|
|
{
|
|
DataTable dt = i_qdsOringinResult.DATA.Tables[0];
|
|
DataColumnCollection dcc = dt.Columns;
|
|
int nSNCount = 1;
|
|
|
|
this.TotalCount = i_qdsOringinResult.Total;
|
|
|
|
this.CurrentCount = dt.Rows.Count;
|
|
|
|
foreach (DataRow dr in dt.Rows)
|
|
{
|
|
Dictionary<string, object> dicData = new Dictionary<string, object>
|
|
{
|
|
{ "sn", nSNCount }
|
|
};
|
|
|
|
if (i_dicAdditionDataForEveryRow != null)
|
|
{
|
|
foreach (KeyValuePair<string, object> kvp in i_dicAdditionDataForEveryRow)
|
|
{
|
|
dicData.Add(kvp.Key, kvp.Value);
|
|
}
|
|
}
|
|
|
|
foreach (DataColumn dc in dcc)
|
|
{
|
|
object oData = dr[dc.ColumnName];
|
|
string sColumnName = dc.ColumnName.ToLower(CultureInfo.CurrentCulture);
|
|
|
|
if (oData is string)
|
|
{
|
|
string sData = oData.ToString();
|
|
dicData.Add(sColumnName, sData.TrimEnd());
|
|
}
|
|
else if (oData is DateTime)
|
|
{
|
|
dicData.Add(sColumnName, ((DateTime)(oData)).ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.CurrentCulture));
|
|
}
|
|
else if (TypeCheckerHelper.IsNumeric(oData))
|
|
{
|
|
dicData.Add(sColumnName, oData);
|
|
}
|
|
else
|
|
{
|
|
if (!(oData is DBNull))
|
|
{
|
|
dicData.Add(sColumnName, oData.ToString());
|
|
}
|
|
}
|
|
}
|
|
|
|
this.Records.Add(dicData);
|
|
nSNCount++;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|