def deleteLastSessionData(self): #全て消してから新たに作成する dirPath = Config.getConf('CostManageAutoDLinfo', 'download_path') FileOperationLib.deleteDir(dirPath) FileOperationLib.makeDir(dirPath) #Zipファイル FileOperationLib.deleteFile(Config.getConf('CostManageAutoDLinfo', 'output_path') + 'cost_manage.zip')
def deleteLastSessionData(self): #全て消してから新たに作成する dirPath = Config.getConf('TimeRecordAutoDLinfo', 'download_path') FileOperationLib.deleteDir(dirPath) FileOperationLib.makeDir(dirPath) #Zipファイル FileOperationLib.deleteFile(Config.getConf('TimeRecordAutoDLinfo', 'output_path') + 'time_sheet.zip')
def sendCostManage(self, dt): ym = DateUtilLib.getYmFormatJapanese(dt) mail = SendMailLib() mail.setMailFrom(Config.getConf('MAILinfo', 'admin_mail_from')) mail.setMailTo(Config.getConf('CostManageAutoDLinfo', 'kanri_mail')) mail.setMailSubject('【自動送信】' + ym + '経費精算情報') mail.setMailText(ym + '分の経費精算一覧を送付します。') mail.setAttach(Config.getConf('CostManageAutoDLinfo', 'output_path') + 'cost_manage.zip') mail.send()
def sendTimeSheet(self, dt): dt = StringOperationLib.mid(dt, 1, 7) ym = DateUtilLib.getYmFormatJapanese(dt) mail = SendMailLib() mail.setMailFrom(Config.getConf('MAILinfo', 'admin_mail_from')) mail.setMailTo(Config.getConf('TimeRecordAutoDLinfo', 'kanri_mail')) mail.setMailSubject('【自動送信】' + ym + '勤怠表') mail.setMailText(ym + '分の勤怠表を送付します。') mail.setAttach(Config.getConf('TimeRecordAutoDLinfo', 'output_path') + 'time_sheet.zip') mail.send()
def makeExcel(self, dt, recordMapList, totalList, name): dt = StringOperationLib.mid(dt, 1, 7) ym = DateUtilLib.getYmFormatJapanese(dt) name = StringOperationLib.replace(name, " ", "") excel = PythonExcelLib() excel.setPageA4 excel.rename('月間作業実績報告書') #タイトル等共通部分 self.setCommon(excel, ym, name) #勤怠表の項目名 self.setTimeRecordTitle(excel) #勤怠表 lastRow = self.setTimeRecordValue(excel, recordMapList) #合計行 self.setTimeRecordTotalValue(excel, totalList, copy(lastRow)) #押印欄等 self.setOtherArea(excel, copy(lastRow)) #体裁 self.setFormat(excel, copy(lastRow)) excel.save(Config.getConf('TimeRecordAutoDLinfo', 'download_path') + '本社提出用_' + ym + '勤怠表_' + name + '.xlsx') #オブジェクト解放 del excel
def mainProc(self, args): try: ''' 実行引数を受け取る ''' for num in range(len(args)): if num > 0: if args[num][0] == '-': key = args[num] value = args[num + 1] self.form[key] = value ''' confファイルを読み込み ''' Config.confLoad('system') ''' ロガーオープン ''' self.logger = BaseLogger(self.procLogFileName) self.logger.fileOpen() self.logger.writeLog( "START_TIME=" + StringOperationLib.toString(DateUtilLib.getTime())) self.logger.writeLog("START_BATCH_NAME=" + self.appName) self.logger.writeLog("PARAM_INFO=" + self.appId + " param:" + " ".join(args)) ''' DB接続 ''' self.db = DbManager() self.db.connect() ''' ロジック実行 ''' logic = self.getLogic(self.db, self.logger, self.form) logic.run() except Exception as e: self.errProc(e) finally: self.db.disConnect() self.logger.writeLog( "END_TIME=" + StringOperationLib.toString(DateUtilLib.getTime()) + '\r\n') self.logger.fileClose()
def deleteReceiptFile(self, arr): #社員情報を取得 eDao = EmployeeDao(self.db) eDao.addWhereStr(EmployeeDao.COL_LOGIN_ID, Config.getConf('DBinfo', 'admin_user_id'), EmployeeDao.COMP_NOT_EQUAL) #管理者は除外 eList = eDao.doSelectCol(EmployeeDao.COL_LOGIN_ID) self.writeLog('ディレクトリ削除開始:' + StringOperationLib.toString(DateUtilLib.getToday())) for i in range(len(eList)): for j in range(len(arr)): ym = StringOperationLib.toString(StringOperationLib.left(arr[j], 4) + StringOperationLib.right(arr[j], 2)) user_id = StringOperationLib.toString(eList[i]) dirPath = Config.getConf('RECEIPTinfo', 'receipt_file_path') + user_id + '/' + ym if FileOperationLib.existDir(dirPath): FileOperationLib.deleteDir(dirPath) self.writeLog('ディレクトリ削除 ユーザーID: ' + user_id + ' 対象年月: ' + ym) self.writeLog('ディレクトリ削除完了:' + StringOperationLib.toString(DateUtilLib.getToday()))
def copyReceiptFile(self, targetYm, loginId, toPath): year, month = DateUtilLib.splitYm(targetYm) ym = StringOperationLib.toString(year) + StringOperationLib.toString(month) fromPath = FileOperationLib.getFileList(Config.getConf('RECEIPTinfo', 'receipt_file_path') + loginId + '/' + ym + '/') for file in fromPath: if not(StringOperationLib.match(FileOperationLib.getFileName(file), '*.xlsx')): fileName = FileOperationLib.getFileName(file).encode('utf-8', 'surrogateescape').decode('SJIS', 'surrogateescape') FileOperationLib.copyFile(file, toPath + fileName)
def errProc(self, e): try: self.errLogger = BaseLogger(self.errLogFileName) self.errLogger.fileOpen() self.errLogger.writeErrLog(e) self.errLogger.fileClose() #エラーメール送信 errMail = SendMailLib() errMail.setMailFrom(Config.getConf('MAILinfo', 'admin_mail_from')) errMail.setMailTo(Config.getConf('MAILinfo', 'admin_mail_to')) errMail.setErrMailSubject(self.appId) errMail.setErrMailText(self.appName, e) errMail.send() except Exception as e2: print(e2) finally: self.errLogger.fileClose()
def deleteReceiptFile(self, ids): #社員情報を取得 eDao = EmployeeDao(self.db) eDao.addWhereIn(EmployeeDao.COL_ID, ids) eList = eDao.doSelectCol(EmployeeDao.COL_LOGIN_ID) self.writeLog('ディレクトリ削除開始:' + StringOperationLib.toString(DateUtilLib.getToday())) for i in range(len(eList)): user_id = StringOperationLib.toString(eList[i]) dirPath = Config.getConf('RECEIPTinfo', 'receipt_file_path') + user_id #年月は関係なし(ユーザーIDのディレクトリごとまるっと削除する) if FileOperationLib.existDir(dirPath): FileOperationLib.deleteDir(dirPath) self.writeLog('ディレクトリ削除 ユーザーID: ' + user_id) self.writeLog('ディレクトリ削除完了:' + StringOperationLib.toString(DateUtilLib.getToday()))
def run(self): date = self.getForm('-date') interval = int(self.getForm('-interval', 60)) if date == '': self.writeLog('parameter:-date is not set') return targetDate = self.getTargetDate(date, interval) #パス取得 dirPath = Config.getConf('LOGinfo', 'log_file_path') count = 0 for logPath in FileOperationLib.getFileList(dirPath, '*' + targetDate + '*.log'): FileOperationLib.deleteFile(logPath) count += 1 self.writeLog('ログ削除件数:' + StringOperationLib.toString(count) + '件') return
def __init__(self, fileName): self.path = Config.getConf('LOGinfo', 'log_file_path') self.fileName = fileName
def makeZipFile(self): dirPath = Config.getConf('TimeRecordAutoDLinfo', 'download_path') outputPath = Config.getConf('TimeRecordAutoDLinfo', 'output_path') FileOperationLib.fileArchive('time_sheet', outputPath, dirPath)
def makeZipFile(self): dirPath = Config.getConf('CostManageAutoDLinfo', 'download_path') outputPath = Config.getConf('CostManageAutoDLinfo', 'output_path') FileOperationLib.fileArchive('cost_manage', outputPath, dirPath)
def __init__(self): self.dbHost = Config.getConf('DBinfo', 'db_server') self.dbUser = Config.getConf('DBinfo', 'db_user') self.dbPassword = Config.getConf('DBinfo', 'db_password') self.dbSchema = Config.getConf('DBinfo', 'db_schema') self.dbCharset = Config.getConf('DBinfo', 'db_char')
def makeEmployeeDir(self, employeeName): dirPath = Config.getConf('CostManageAutoDLinfo', 'download_path') + employeeName + '/' FileOperationLib.makeDir(dirPath) return dirPath
def __init__(self): self.reset() self.smtp = smtplib.SMTP(Config.getConf('MAILinfo', 'smtp_host'), Config.getConf('MAILinfo', 'smtp_port'), Config.getConf('MAILinfo', 'conn_timeout')) self.smtp.starttls()