Ejemplo n.º 1
0
def addSubDataSource(taskId, name, sqlStatement, requestInfo):
    '''Add SubDataSource to task which taskId = taskId,you need apply name and sqlStatement,def will check exists'''
    #print(taskId)
    dictSubDataSource = dictQuerySubDataSourceList(taskId=taskId,
                                                   requestInfo=requestInfo)
    #print(dictSubDataSource)
    listSubDataSourceName = []
    for singleSubDataSource in dictSubDataSource:
        listSubDataSourceName.append(singleSubDataSource['name'])
    #print(listSubDataSourceName)
    if name not in listSubDataSourceName:
        needurl = requestInfo.rooturl + r'/mdc/Task/AddDataSource'
        needPostData = {}
        needPostData['id'] = ''
        needPostData['taskId'] = taskId
        needPostData['name'] = name
        needPostData[
            'databaseSourceId'] = 'cb1ecd13-2dab-4892-b517-34d79ccfcb6d'  #默认为ehr
        needPostData['nameLangid'] = ''
        needPostData['sqlStatement'] = sqlStatement
        response = requestNeedurl(needurl=needurl,
                                  postData=needPostData,
                                  headers=requestInfo.headers,
                                  CookieOpener=requestInfo.CookieOpener)
        print('%s Add Success' % (name))
        return response
    else:
        print('%s exist SubDataSource,skip Add' % (name))
Ejemplo n.º 2
0
def addNewTmpl(name, requestInfo):
    '''Add new tmpl in project which projectId = 2ae753f5-7402-4fa4-88de-2df90a0024ea,you need apply name'''
    print('11114555:%s' % ('11114555'))
    restest = queryTmpl(requestInfo=requestInfo)
    tmplId = [
        singleTmpl['id'] for singleTmpl in queryTmpl(requestInfo=requestInfo)
        if singleTmpl['name'] == name
    ]
    if len(tmplId) == 0:
        needurl = requestInfo.rooturl + r'/mdc/Tmpl/ADD'
        print('needurl:%s' % (needurl))
        needPostData = {}
        needPostData[
            'projectId'] = '2ae753f5-7402-4fa4-88de-2df90a0024ea'  #默认职位人事业务
        needPostData['messageTypeId'] = '059dda48-f066-4ffe-b47b-69655434d90a'
        needPostData['priority'] = '1'
        needPostData['name'] = name
        needPostData['id'] = ''
        response = requestNeedurl(needurl=needurl,
                                  postData=needPostData,
                                  headers=requestInfo.headers,
                                  CookieOpener=requestInfo.CookieOpener)
        return response
    else:
        print('%s exist tmpl,skip Add' % (name))
Ejemplo n.º 3
0
def addNewTask(name, tmplId, requestInfo):
    '''Add new task in tmpl,you need apply name and tmplId'''
    taskId = [
        singleTask['id']
        for singleTask in queryTaskbyTmpl(tmplId=tmplId,
                                          requestInfo=requestInfo)
        if singleTask['name'] == name
    ]
    if len(taskId) == 0:
        needurl = requestInfo.rooturl + r'/mdc/Task/ADD'
        needPostData = {}
        needPostData['templateId'] = tmplId  #默认职位人事业务
        needPostData['name'] = name
        needPostData['id'] = ''
        needPostData['nameLangid'] = ''
        needPostData['isMail'] = 'true'
        needPostData['isMsg'] = 'false'
        needPostData['isSMS'] = 'false'
        needPostData['agentId'] = ''
        needPostData['isWeixin'] = 'false'
        needPostData['description'] = name
        needPostData['descriptionLangid'] = ''
        response = requestNeedurl(needurl=needurl,
                                  postData=needPostData,
                                  headers=requestInfo.headers,
                                  CookieOpener=requestInfo.CookieOpener)
        return response
    else:
        print('Add filed,taskname exists')
Ejemplo n.º 4
0
def dictQueryTmplVars(tmplId, requestInfo):
    '''Query all TmplVars IN Tmpl which tmplId = tmplId and resquest the dict of tmplvar list'''
    needurl = requestInfo.rooturl + r'/mdc/Tmpl/QueryVariable'
    needPostData = {}
    needPostData['tmplId'] = tmplId
    response = requestNeedurl(needurl=needurl,
                              postData=needPostData,
                              headers=requestInfo.headers,
                              CookieOpener=requestInfo.CookieOpener)
    dictResponse = json.loads(response.read().decode())['data']
    return dictResponse
Ejemplo n.º 5
0
def dictQuerySubDataSourceList(taskId, requestInfo):
    '''Query SubDataSourceList IN task which taskId = taskId and resquest the dict of SubDataSource list'''
    needurl = requestInfo.rooturl + r'/mdc/Task/SubDataSourceList'
    needPostData = {}
    needPostData['taskId'] = taskId
    needPostData['pageIndex'] = 0
    needPostData['pageSize'] = 30
    response = requestNeedurl(needurl=needurl,
                              postData=needPostData,
                              headers=requestInfo.headers,
                              CookieOpener=requestInfo.CookieOpener)
    dictResponse = json.loads(response.read().decode())['records']
    return dictResponse
Ejemplo n.º 6
0
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
Ejemplo n.º 7
0
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
Ejemplo n.º 8
0
def queryTaskbyTmpl(tmplId, requestInfo):
    '''Query tmpl list in project which projectId = 2ae753f5-7402-4fa4-88de-2df90a0024ea '''
    needurl = requestInfo.rooturl + r'/mdc/Task/query'
    needPostData = {}
    needPostData['tmplId'] = tmplId
    needPostData['pageIndex'] = '0'
    needPostData['pageSize'] = '30'
    response = requestNeedurl(needurl=needurl,
                              postData=needPostData,
                              headers=requestInfo.headers,
                              CookieOpener=requestInfo.CookieOpener)
    resQueryTask = json.loads(response.read().decode())
    josonQueryTask = resQueryTask['records']
    return josonQueryTask
Ejemplo n.º 9
0
def addMainDataSource(taskId, name, sqlStatement, requestInfo):
    '''Add MainDataSource to task which taskid = taskId,you need apply name and sqlStatement'''
    if taskId == '':
        print('Need taskId')
    else:
        needurl = requestInfo.rooturl + r'/mdc/Task/dataSource'
        needPostData = {}
        needPostData['id'] = ''
        needPostData['taskId'] = taskId
        needPostData['name'] = name
        needPostData[
            'databaseSourceId'] = 'cb1ecd13-2dab-4892-b517-34d79ccfcb6d'  #默认为ehr
        needPostData['nameLangid'] = ''
        needPostData['sqlStatement'] = sqlStatement
        response = requestNeedurl(needurl=needurl,
                                  postData=needPostData,
                                  headers=requestInfo.headers,
                                  CookieOpener=requestInfo.CookieOpener)
        print('%s Add Success' % (name))
        return response
Ejemplo n.º 10
0
def addTmplVar(templateId, name, code, requestInfo):
    '''Add TmplVar to Tmpl which templateId = tmplId,you need apply name and code,def will check exists'''
    needurl = requestInfo.rooturl + r'/mdc/Tmpl/AddVariable'
    needPostData = {}
    needPostData['id'] = ''
    needPostData['templateId'] = templateId
    needPostData['name'] = name
    needPostData['code'] = code
    dictTmplVar = dictQueryTmplVars(tmplId=templateId, requestInfo=requestInfo)
    listTmpVarName = []
    for singleTmpVar in dictTmplVar:
        listTmpVarName.append(singleTmpVar['name'])
    #print(listTmpVarName)
    if name not in listTmpVarName:
        response = requestNeedurl(needurl=needurl,
                                  postData=needPostData,
                                  headers=requestInfo.headers,
                                  CookieOpener=requestInfo.CookieOpener)
        print('%s Add Success' % (name))
    else:
        print('%s exist vars,skip Add' % (name))