/// <summary>
        /// 获取文件名信息 1一般文件 2压缩文件  3 T8一般文件 4 T8压缩文件
        /// </summary>
        /// <param name="type">1一般文件 2压缩文件</param>
        /// <returns></returns>
        public virtual AFileName GetGenerateFileNameStragety(int type)
        {
            AFileName aFileName = null;

            switch (type)
            {
            case 1:
                aFileName = AutoFacContainer.ResolveNamed <AFileName>(typeof(GeneralFileName).Name);
                break;

            case 2:
                aFileName = AutoFacContainer.ResolveNamed <AFileName>(typeof(CompressFileName).Name);
                break;

            case 3:
                aFileName = AutoFacContainer.ResolveNamed <AFileName>(typeof(T8GeneralFileName).Name);
                break;

            case 4:
                aFileName = AutoFacContainer.ResolveNamed <AFileName>(typeof(T8CompressFileName).Name);
                break;

            default:
                throw new ArgumentNullException("GetSqlQueryTimeStragety()方法,参数type值错误");
            }
            return(aFileName);
        }
Example #2
0
        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);
        }