/// <summary> /// ThrowするExceptionを作成 /// </summary> /// <param name="_errorCode"></param> /// <param name="_innerEx"></param> /// <returns></returns> public static STEException ThrowException(Define.ErrorCode _errorCode, string _message = null, Exception _innerEx = null) { STEException steex = new STEException(_errorCode, _message, _innerEx); return steex; }
public STEException(Define.ErrorCode _errorCode, string _message, Exception _innerEx) : base(_message, _innerEx) { this.ErrorCode = _errorCode; }
public STEException(Define.ErrorCode _errorCode, Exception _ex) : this(_errorCode, null, new Exception()) { }
public DBModel(Define.DatabaseType _dbType, string _connectionString) { this.DbType =_dbType; this.ConnectionString = _connectionString; }
/// <summary> /// DBよりExcel・CSVに出力 /// </summary> /// <param name="_dbType"></param> /// <param name="_connectString"></param> /// <param name="_sql"></param> /// <param name="_outFileFullPath"></param> /// <returns></returns> public static Define.ErrorCode ExecuteDbToFile(Define.DatabaseType _dbType, string _connectString, string _sql, string _outFileFullPath) { Define.OutFileType outType = Define.OutFileType.Excel; DataTable dt = null; // Excel出力用のフォルダ作成 if (!Directory.Exists(Path.GetDirectoryName(_outFileFullPath))) { Directory.CreateDirectory(Path.GetDirectoryName(_outFileFullPath)); } ///// DBよりデータ取得 DBModel dbModel = new DBModel(_dbType, _connectString); try { dt = dbModel.GetDBTable(_sql); } catch (STEException steEx) { return steEx.ErrorCode; } catch (Exception) { return Define.ErrorCode.DBUnExpectedError; } DateTime executeDate = DateTime.UtcNow.AddHours(9); // 1件も一致しなかった場合は終了 if (dt.Rows.Count == 0) { return Define.ErrorCode.DBCountZeroError; } ///// ファイル作成 try { outType = Define.GetOutFileTypeByPath(_outFileFullPath); IOutput output = null; switch (outType) { case Define.OutFileType.Excel: output = new ExcelModel(_outFileFullPath); break; case Define.OutFileType.Csv: output = new CsvModel(_outFileFullPath); break; } // 出力成功時 if (output.Write(dt, executeDate, _sql)) { return Define.ErrorCode.Success; } else { return Define.ErrorCode.ExcelOutputDataError; } } catch (STEException stex) { return stex.ErrorCode; } catch { return Define.ErrorCode.ExcelUnExpectedError; } }
/// <summary> /// Windowを実行状態にする メッセージがあれば表示 /// </summary> /// <param name="_message"></param> private void windowEnabled(Define.ErrorCode _errorCode) { windowEnabled(Define.ErrorMessage(_errorCode)); }