|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- 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;
- try
- {
- ExcelFormat = FileOperation.GetFormatConfigData<ExcelFormatConfig>("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+ strFileName + ".xls", "[ \\[ \\] \\^ \\-_*×――(^)|'$%~!@#$…&%¥—+=<>《》!!???::•`·、。,;,.;\"‘’“”-]", "").Replace(@"\", "") + ".xls";
- this.strTableName = $"'{strFileName}$'";
- this.strDateColumn = vs[1].ToString();
- this.strDate = vs[2].ToString();
- }
- }
- }
- catch (Exception ex)
- {
- AppLog.Error(ex.Message);
- }
- }
-
- public override Dictionary<string, DataTable> GetInstrumentData()
- {
- if (StrLocalPath == null || ExcelFormat == null || ExcelFormat == null)
- return new Dictionary<string, DataTable>();
-
- 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
- });
- }
- }
- }
|