using DeviceRepair.Utils; using NLog; using System; using System.Collections.Generic; using System.Data; using TsSFCDevice.Client.Biz.Base.Service; using TsSFCDevice.Client.Biz.Base.Utils; using TsSFCDevice.Client.Biz.DeviceSvc; namespace TsSFCDevice.Client.Biz.Impl { public class HisRepository where TParams : class, new() { private readonly Logger log; private static HisRepository manager; private IDictionary m_ApiParameters; /// /// API输入参数 /// public IDictionary ApiParameters { get { return m_ApiParameters; } set { m_ApiParameters = value; } } public HistoryType @HisType { get; set; } public static HisRepository Instance { get { if (manager == null) manager = new HisRepository(); return manager; } } public HisRepository() { log = LogManager.GetCurrentClassLogger(); m_ApiParameters = new Dictionary(); } internal string GetParameters(string cOperator = "", bool bFlag = true) { return ParametersObject.GetInstance(cOperator).GetJsonSerialized(m_ApiParameters); } public IList HistoryGet(IDictionary vParams) { DataSet dsResults = new DataSet(); try { byte[] btResults = null; var vRtn = Utility.SfcBizService.CurrentSvc.HistoryGet(HisType, GetParameters(), out btResults); if (vRtn.Code != 1) { throw new Exception(vRtn.Message); } dsResults = CompressionHelper.ExactDataSet(btResults); if (dsResults == null || dsResults.Tables.Count == 0 || dsResults.Tables[0].Rows.Count == 0) { return null; } return DTOHelper.DataTableToList(dsResults.Tables[0]); } catch (Exception ex) { throw ex; } } public IList HistoryGet() { return HistoryGet(ApiParameters); } } }