using CnasSynchronousCommon; using CnasSynchronusDAL; using CnasSynchronusIDAL; using CnasSynchrousModel; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; namespace CnasSynchronusClient { public class ExcelInstrumentData : InstrumentData { public string StrLocalPath { get; set; } public string strTableName { get; set; } public string strDateColumn { get; set; } public string strDate { get; set; } public IExcelService dataBaseService { get { return new ExcelDBService(); } } public ExcelFormatConfig ExcelFormat { get; set; } public ExcelInstrumentData(InstrumentDataSourceInfo dataSourceInfo, object[] vs) { if (dataSourceInfo.Path == null) return; ExcelFormat= FileOperation.GetFormatConfigData("ExcelFormatConfig.xml"); if (ExcelFormat.ReadExcelFileMode == "0") { RemoteFileCopy remoteFileCopy = new RemoteFileCopy(dataSourceInfo); remoteFileCopy.CopyFileFromRemote(".xls"); this.StrLocalPath = FileHelper.getBasePath() + "\\Cache\\" + System.Text.RegularExpressions.Regex.Replace(dataSourceInfo.Path, "[ \\[ \\] \\^ \\-_*×――(^)|'$%~!@#$…&%¥—+=<>《》!!???::•`·、。,;,.;\"‘’“”-]", "").Replace(@"\", "") + ".xls"; this.strTableName = vs[0].ToString(); this.strDateColumn = vs[1].ToString(); this.strDate = vs[2].ToString(); } else { string strFileName = DateTime.Now.ToString(ExcelFormat.ExcelFileNameFormat); if (strFileName != "") { RemoteFileCopy remoteFileCopy = new RemoteFileCopy(dataSourceInfo); remoteFileCopy.CopyFileFromRemote(".xls", strFileName + ".xls"); this.StrLocalPath = FileHelper.getBasePath() + "\\Cache\\" + System.Text.RegularExpressions.Regex.Replace(dataSourceInfo.Path, "[ \\[ \\] \\^ \\-_*×――(^)|'$%~!@#$…&%¥—+=<>《》!!???::•`·、。,;,.;\"‘’“”-]", "").Replace(@"\", "") + ".xls"; this.strTableName = $"'{strFileName}$'"; this.strDateColumn = vs[1].ToString(); this.strDate = vs[2].ToString(); } } } public override Dictionary GetInstrumentData() { return dataBaseService.GetInstrumentData( new ExcelOpenParams { StrPath = StrLocalPath, ExcelFileVersion = ExcelFormat.ExcelFileVersion, autoSql = ExcelFormat.AutoSql }); } public override DataTable GetInstrumentDataByDate() { return dataBaseService.GetInstrumentDataByDate( new ExcelOpenParams { StrPath = StrLocalPath, ExcelFileVersion = ExcelFormat.ExcelFileVersion, autoSql = ExcelFormat.AutoSql }, new ConditionParams { TableName = strTableName, DateColumn = strDateColumn, DateValue = strDate }); } public override DataTable GetInstrumentDataStruct() { return dataBaseService.GetInstrumentDataStruct( new ExcelOpenParams { StrPath = StrLocalPath, ExcelFileVersion = ExcelFormat.ExcelFileVersion, autoSql = ExcelFormat.AutoSql }, new ConditionParams { TableName = strTableName }); } } }