public MainWindow() { InitializeComponent(); DataHandlerFactory dataHandlerFactory = new DataHandlerFactory(); DataHandler = dataHandlerFactory.CreateDataHandler(ConfigurationManager.AppSettings["DataSourceType"]); }
public void Create_ReturnAnOracleHandler() { DataHandlerFactory factory = new DataHandlerFactory(); IDataHandler myHandler = factory.Create( "OracleHandler" ); Assert.AreEqual( "OracleHandler", myHandler.HandlerClassID() ); }
public void Initialize() { dataHandlerFactory = new DataHandlerFactory(); xMLDataHandler = new XMLDataHandler(); cSVDataHandler = new CSVDataHandler(); dBDataHandler = new DBDataHandler(new CarDBContext()); }
/// <summary> /// 获取数据列表 /// </summary> /// <param name="connStr"></param> /// <param name="dataHandlerTypeName"></param> /// <param name="sql"></param> /// <param name="op"></param> /// <param name="ed"></param> /// <returns></returns> public static DataTable GetDataList(string connStr, string dataHandlerTypeName, string sql, DateTime op, DateTime ed) { IDataHandler dataHandler = DataHandlerFactory.GetHandler(dataHandlerTypeName); dataHandler.DBConnectStr = connStr; return(dataHandler.GetDataList(sql, op, ed)); }
/// <summary> /// 连接数据库测试 /// </summary> /// <param name="connStr"></param> /// <param name="dataHandlerTypeName"></param> /// <returns></returns> public static bool DBConnectOpen(string connStr, string dataHandlerTypeName) { IDataHandler dataHandler = DataHandlerFactory.GetHandler(dataHandlerTypeName); dataHandler.DBConnectStr = connStr; return(dataHandler.DBConnectOpen()); }
public void Test() { IDataHandler handler = DataHandlerFactory.GetHandler("Transfer8Pro.DAO.DataHandlers.SqlServer_DataHandler"); //new SqlServer_DataHandler(); handler.DBConnectStr = "server=192.168.0.14;database=OX;uid=sa;pwd=sa."; string sql = "SELECT top 100 AuthorID,AuthorName FROM [OX].[dbo].[AT_AuthorInfo] WHERE CreateTime>@StartTime AND CreateTime<@EndTIme "; handler.OutputData(sql, new DateTime(2018, 3, 1), new DateTime(2018, 4, 1), @"R:\tmp.jl"); }
public void Test_Oracle() { var s = DataHandlerFactory.DBTypes; IDataHandler handler = DataHandlerFactory.GetHandler("Transfer8Pro.DAO.DataHandlers.Oracle_DataHandler"); //new SqlServer_DataHandler(); handler.DBConnectStr = "Data Source=(DESCRIPTION=(ADDRESS_LIST= (ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.60) (PORT=18991)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=ORCL12)));User Id=ox;Password=ox_pwd"; string sql = "select * from OX_KINDINFO where CreatedTime>:StartTime AND CreatedTime<:EndTIme "; handler.OutputData(sql, new DateTime(2018, 11, 1), new DateTime(2018, 12, 1), @"R:\tmp.jl"); }
public override void BuildDbFile() { Action <TaskEntity> action = t8Task => { try { BuildInstanceObject buildInstanceService = new BuildInstanceObject(); //1得到数据库文件路径 AFileName fileNameStragety = buildInstanceService.GetGenerateFileNameStragety(3); ISqlQueryTime SqlQueryTimeStragety = buildInstanceService.GetSqlQueryTimeStragety(t8Task.CycleType); FileInfoEntity fileInfoEntity = new FileInfoEntity(); fileInfoEntity.NormalFileName = fileNameStragety.FileName(t8Task); fileInfoEntity.NormalFilePath = fileNameStragety.FileFullName(t8Task); fileInfoEntity.SqlStartTime = SqlQueryTimeStragety.StartTime(DateTime.Now); fileInfoEntity.SqlEndTime = SqlQueryTimeStragety.EndTime(DateTime.Now); t8Task.FileInfo = fileInfoEntity; //2创建数据库文件并添加数据 IDataHandler handler = DataHandlerFactory.GetHandler(t8Task.DataHandler); handler.DBConnectStr = Common.DecryptData(t8Task.DBConnectString_Hashed); string sql = t8Task.SQL; bool isSuccess = handler.OutputDataToSQLite(sql, fileInfoEntity.SqlStartTime, fileInfoEntity.SqlEndTime, fileInfoEntity.NormalFilePath); Thread.Sleep(300); if (!isSuccess) { LogUtil.WriteLog($"从数据库向数据文件[{fileInfoEntity.NormalFilePath}]导入数据出现错误"); throw new Exception($"从数据库向数据文件[{fileInfoEntity.NormalFilePath}]导入数据出现错误"); } LogUtil.WriteLog($"数据文件[{fileInfoEntity.NormalFilePath}]创建并添加数据完成"); } catch (Exception ex) { LogUtil.WriteLog(ex); throw new Exception(ex.Message); } }; product.AddPart(action); }
public void InstantiateAFactory() { DataHandlerFactory factory = new DataHandlerFactory(); Assert.AreNotEqual( null, factory ); }