def requestAllCalData(self): payrollInfo['allcalpackageID'] = str( self.entry_allCalPackageID_var.get()) if payrollInfo['allcalpackageID'] == '': mb.showerror('读取错误', '未读取到指定薪资包ID') pass else: needurl = 'http://peter/zybxehr/ePayroll/payrollpackage/PackageCalculate.aspx?PACKAGEID=' + payrollInfo[ 'allcalpackageID'] needPostData = {'TxtPackageID': payrollInfo['allcalpackageID']} self.requestCalList(needPostData, needurl)
def requestCalDebug(self): payrollInfo['packageID'] = str(self.entry_singlePackageID_var.get()) payrollInfo['workNO'] = str(self.entry_singleWorkNo_var.get()) if payrollInfo['packageID'] == '': mb.showerror('读取错误', '未读取到指定薪资包ID') pass else: if payrollInfo['workNO'] == '': mb.showerror('读取错误', '未读取到指定工号') pass else: mb.showinfo( '请求开始', '请求基本参数:薪资包ID:%s;工号:%s' % (payrollInfo['packageID'], payrollInfo['workNO'])) needurl = 'http://peter/zybxehr/ePayroll/PayrollPackage/PackageCalculateDebug.aspx?PackageID=' + payrollInfo[ 'packageID'] viewState = self.get_ViewState(headers=self.headers, needurl=needurl) if viewState == '': mb.showinfo('读取错误', '未读取到入口页面的页面状态,请先点击登录进行模拟登录') else: needPostData = { '__VIEWSTATE': viewState, 'txtWorkNO': payrollInfo['workNO'], 'BtnDebug': '调试', 'TxtPackageID': payrollInfo['packageID'] } response = self.requestNeedurl(needurl=needurl, postData=needPostData, headers=self.headers) readResponse = response.read().decode() readSoup = bs.BeautifulSoup( readResponse, "html.parser").find(id="txtDebugInfo").string self.text_singleCalDebug.insert(tk.END, readSoup) self.entry_singleCalDebug_var.set(readSoup) writeFullPath = rootWorkSapce + '/CalDebug_' + payrollInfo[ 'workNO'] + '.txt' writeToTxt(writeFullPath, readSoup) mb.showinfo('请求结束', '请求结束,调试信息被回写到如下地址:%s' % (writeFullPath))
def run_completer(self, parser, command, point=None, completer=autocomplete, **kwargs): command = ensure_str(command) if point is None: point = str(len(command)) with TemporaryFile() as t: os.environ["COMP_LINE"] = ensure_bytes(command) if USING_PYTHON2 else command os.environ["COMP_POINT"] = point self.assertRaises(SystemExit, completer, parser, output_stream=t, exit_method=sys.exit, **kwargs) t.seek(0) return t.read().decode(sys_encoding).split(IFS)
def run_completer(self, parser, command, point=None, **kwargs): command = ensure_str(command) if point is None: # Adjust point for wide chars point = str(len(command.encode(sys_encoding))) with TemporaryFile() as t: os.environ["COMP_LINE"] = ensure_bytes(command) if USING_PYTHON2 else command os.environ["COMP_POINT"] = point os.environ["_ARGCOMPLETE_COMP_WORDBREAKS"] = '"\'@><=;|&(:' self.assertRaises(SystemExit, autocomplete, parser, output_stream=t, exit_method=sys.exit, **kwargs) t.seek(0) return t.read().decode(sys_encoding).split(IFS)
def run_completer(self, parser, command, point=None, **kwargs): command = ensure_str(command) if point is None: # Adjust point for wide chars point = str(len(command.encode(sys_encoding))) with TemporaryFile() as t: os.environ["COMP_LINE"] = ensure_bytes(command) if USING_PYTHON2 else command os.environ["COMP_POINT"] = point os.environ["_ARGCOMPLETE_COMP_WORDBREAKS"] = '"\'@><=;|&(:' self.assertRaises(SystemExit, autocomplete, parser, output_stream=t, exit_method=sys.exit, **kwargs) t.seek(0) return t.read().decode(sys_encoding).split(IFS)
def listRecipientVarsByTmpId(tmplId, requestInfo): needurl = requestInfo.rooturl + r'/mdc/Tmpl/Recipient?tmplId=' + tmplId needPostData = {} response = requestNeedurl(needurl=needurl, postData=needPostData, headers=requestInfo.headers, CookieOpener=requestInfo.CookieOpener) readQueryRecipientVars = response.read().decode() listRecipientVars = re.findall(r'variableList:\[(.*)\],', str(readQueryRecipientVars)) if len(listRecipientVars) > 0: listRecipientVars = '[' + listRecipientVars[0] + ']' listRecipientVars = json.loads(listRecipientVars) return listRecipientVars
def listVariableMappingByTaskId(taskId, requestInfo): needurl = requestInfo.rooturl + r'/mdc/Task/variableMapping?taskId=' + taskId needPostData = {} response = requestNeedurl(needurl=needurl, postData=needPostData, headers=requestInfo.headers, CookieOpener=requestInfo.CookieOpener) readVariableMappings = response.read().decode() listVariableMappings = re.findall(r"variableList':\[(.*)\],", str(readVariableMappings)) if len(listVariableMappings) > 0: listVariableMappings = '[' + listVariableMappings[0] + ']' listVariableMappings = json.loads(listVariableMappings) return listVariableMappings
def saveNewSource(self): connInfo['rooturl'] = str(self.entry_rooturl_var.get()) connInfo['host'] = str(self.entry_host_var.get()) connInfo['port'] = str(self.entry_port_var.get()) connInfo['webname'] = str(self.entry_webname_var.get()) connInfo['webpsw'] = str(self.entry_webpsw_var.get()) tempkey1 = randomString(16) pc1 = prpcrypt(tempkey1) encryptedKey1 = pc1.encrypt(connInfo['webpsw']) connInfo['webpsw'] = str(encryptedKey1.decode()) connInfo['websalt'] = str(tempkey1) with open('websource.json', 'w+') as file_object: json.dump(connInfo, file_object) mb.showinfo( '您已经成功更新站点源', '您所更新的站点信息如下:根地址:%s;主机地址:%s;端口:%s;登录账户:%s;' % (connInfo['rooturl'], connInfo['host'], connInfo['port'], connInfo['webname'])) global ehrsource ehrsource = dictReadSource()
def readShowALLSP(self, db_ShowALLSP): mb.showinfo('SP开始提取') checkMphelptextExist = mssql_checkUserObjectExist("mp_helptext") if checkMphelptextExist[0] == 0: truepath = rootfile + '\importproc_mp_helptext.txt' spcontent = readFromTxt(truepath).strip('\n') connWithDBWithnoresult(ehr, spcontent) mb.showinfo( "Tips", "We have import mp_helptext for reploace sys.sp_helptext") db_SPContentList = [] for item in db_ShowALLSP: if item[:4] != "gbpm": #print(item[:4]) item = "gbpm." + item strHead = """\n-------------------TIP """ + item db_SPContentList.append(strHead) strHead = """\nIF EXISTS (SELECT * FROM sys.objects WHERE name = substring('""" + item + """',6,99)) \n DROP PROCEDURE """ + item + """\n GO;\n""" db_SPContentList.append(strHead) selectHelptext = """mp_helptext '""" + item + """'""" #print(selectHelptext) db_helptext = connWithDB(ehr, selectHelptext) for itemtext in db_helptext: db_SPContentList.append(itemtext) strFoot = """\n GO;""" db_SPContentList.append(strFoot) filename_showALLSP = 'showALLSP.txt' filetruepath_showALLSP = str(self.entry_rootfile_var.get( )) + '/' + filename_showALLSP #print(filetruepath_showALLSP) writeToTxt(filetruepath_showALLSP, db_SPContentList) mb.showinfo('SP提取', 'SP已经成功提取完毕')
def saveNewConnecttion(self): connInfo['servername'] = str(self.entry_servername_var.get()) connInfo['dbusername'] = str(self.entry_dbusername_var.get()) connInfo['dbpsw'] = self.entry_dbpsw_var.get() connInfo['dbname'] = str(self.entry_dbname_var.get()) connInfo['sourcename'] = str(self.entry_sourcename_var.get()) tempkey = randomString(16) pc = prpcrypt(tempkey) encryptedKey = pc.encrypt(connInfo['dbpsw']) connInfo['dbpsw'] = str(encryptedKey.decode()) connInfo['dbsalt'] = str(tempkey) with open('sourcename.json', 'w+') as file_object: json.dump(connInfo, file_object) mb.showinfo( '您已经成功更新数据库链接', '您所更新的数据库链接信息如下:服务器名称:%s;数据库名称:%s;用户名:%s;' % (connInfo['servername'], connInfo['dbname'], connInfo['dbusername'])) global ehr ehr = readConn()
def requestCalList(self, needPostData, needurl): mb.showinfo('请求开始', '请求耗时较长,请稍后!!!') viewState = self.get_ViewState(headers=self.headers, needurl=needurl) #print(viewState) pageSize = '200' targetIndex = '1' needPostData['__VIEWSTATE'] = viewState needPostData['btnSearchStaff'] = '查询' needPostData['grdNavigator$ddlPageSize'] = pageSize needPostData['grdNavigator$txtPageIndex'] = targetIndex response = self.requestNeedurl(needurl=needurl, postData=needPostData, headers=self.headers) readResponse = response.read().decode() readSoup = bs.BeautifulSoup(readResponse, "html.parser") recordTotalNum = readSoup.find( id='grdNavigator_lblRecordsCount').string totalPagesNum = int(int(recordTotalNum) / int(pageSize)) + 1 lastPageNum = int(recordTotalNum) % int(pageSize) read_tr = readSoup.find('thead').find_all('th') for item in read_tr: read_tr = item.find('nobr').string self.tabledatainTh.append(read_tr) print(self.tabledatainTh) for targetIndex in range(totalPagesNum): print('targetIndex') print(targetIndex) print('totalPagesNum') print(totalPagesNum) if targetIndex == int(totalPagesNum) - 1: thisPageNum = lastPageNum else: thisPageNum = int(pageSize) print('thisPageNum') print(thisPageNum) viewState = self.get_ViewStateFromRes(readResponse) needPostData = { '__VIEWSTATE': viewState, 'grdNavigator$txtPageIndex': str(targetIndex + 1) } response = self.requestNeedurl(needurl=needurl, postData=needPostData, headers=self.headers) readResponse = response.read().decode() readSoup = bs.BeautifulSoup(readResponse, "html.parser") with open('E:/workspace/tmpfile/temptabledata.json', 'a') as file_object: for item in range(thisPageNum): #print(item) itemid = 'ulgridStaff_r_' + str(item) read_tr = readSoup.find(id=itemid) read_tr_nobr = read_tr.find_all('nobr') tabledatainTr = [] for item in read_tr_nobr: tabledatainTr.append( str(item.string).replace("\xa0", " ")) tabledatainDict = {} tabledatainDict = dict( zip(self.tabledatainTh, tabledatainTr)) print(tabledatainDict) json.dump(obj=tabledatainDict, fp=file_object, ensure_ascii=False, indent=2) writefiletxt = "E:\\workspace\\tmpfile\\Readcircle" + str( targetIndex + 1) + ".txt" writeToTxt(writefiletxt, readResponse) targetIndex += 1 mb.showinfo('请求结束', '系统已经写入完成数据!!!')
def writeMdcFileToWeb(self): truepath = str(self.entry_mdcFilePath_var.get()) listParagraphData = readDocument(truepath=truepath) print('listParagraphData:%s' % (listParagraphData)) loginInSystem(requestInfo=WebRequest) for singleParagraphData in listParagraphData: #print('singleParagraphData:%s'%(singleParagraphData)) tmpName = singleParagraphData.get('邮件提醒模板设定').get('模板名称') print('tmpName:%s' % (tmpName)) cookie = WebRequest.cookie for item in cookie: singlecookie = item.name + '=' + item.value + ';' print('singlecookie:%s' % (singlecookie)) #测试通过:功能1:新增模板到人事业务模块下,指定name即可 resAddNewTmpl = addNewTmpl(name=tmpName, requestInfo=WebRequest) #测试通过:功能2:查询指定名称的tmplid列表 tmplId = [ singleTmpl['id'] for singleTmpl in queryTmpl(requestInfo=WebRequest) if singleTmpl['name'] == tmpName ] #测试通过:功能4:添加变量到指定tmpid的模板下,add new var to new var list and add listAddNewVars = singleParagraphData.get('变量显示名称') for singleNewVar in listAddNewVars: if tmplId == []: pass else: resAddTmpl = addTmplVar(templateId=tmplId[0], name=singleNewVar['name'], code=singleNewVar['code'], requestInfo=WebRequest) #测试通过:功能3:查询指定tmpid的模板下的变量列表 dictTmplVar = dictQueryTmplVars(tmplId=tmplId[0], requestInfo=WebRequest) #测试通过:功能6:添加任务到指定的模板下 taskName = tmpName resAddNewTask = addNewTask(name=tmpName, tmplId=tmplId[0], requestInfo=WebRequest) tmpTaskId = [ singleTask['id'] for singleTask in queryTaskbyTmpl(tmplId=tmplId[0], requestInfo=WebRequest) if singleTask['name'] == taskName ] if len(tmpTaskId) == 0: print('Add filed,Please check tmplId exists') else: print('Add success,taskId is:' % (tmpTaskId)) #测试通过:功能5,查看指定tmpid对应的task列表 taskId = [ singleTask['id'] for singleTask in queryTaskbyTmpl(tmplId=tmplId[0], requestInfo=WebRequest) if singleTask['name'] == taskName ] #测试通过:功能6,向指定taskId添加主数据源 dataSourceName = singleParagraphData.get('主数据源设定').get( 'dataSourceName') sqlStatement = singleParagraphData.get('主数据源设定').get( 'sqlStatement') resAddMainDataSource = addMainDataSource(taskId=taskId[0], name=dataSourceName, sqlStatement=sqlStatement, requestInfo=WebRequest) #测试通过:功能7 向指定的taskId添加子数据源 listAddSubDataSource = singleParagraphData.get('子数据源设定') for singleSubDataSource in listAddSubDataSource: resAddSubDataSource = addSubDataSource( taskId=taskId[0], name=singleSubDataSource['subDataSourceName'], sqlStatement=singleSubDataSource[ 'subDataSourceSqlStatement'], requestInfo=WebRequest) #print('resAddSubDataSource:%s'%(resAddSubDataSource)) #测试通过:功能8 向指定的taskId更新变量数据源 resAddVarMapping = addVarMapping( taskId=taskId[0], cookie=cookie, requestInfo=WebRequest, singleParagraphData=singleParagraphData) #测试通过:功能9 设定接收人,不允许使用群组只能使用子数据源 listDocRecipientVars = singleParagraphData.get('接收人设定') resAddRecipient = addRecipient( tmplId=tmplId[0], cookie=cookie, listDocRecipientVars=listDocRecipientVars, requestInfo=WebRequest) designSubject = singleParagraphData.get('邮件提醒模板设定').get('主题') designContents = singleParagraphData.get('邮件提醒模板设定').get('模板内容') print('designSubject%s' % (designSubject)) print('designContents%s' % (designContents)) print('tmplId%s' % (tmplId[0])) resAddTmplContent = addTmplContent(tmplId=tmplId[0], cookie=cookie, designSubject=designSubject, designContents=designContents, requestInfo=WebRequest) pass
def create_training_files(): # 0.05 nb = [10, 20, 30, 40, 50] for i in nb: name = target_file + str(i) + '.csv' create_training_file_balance_good_bad(i / 100, name)