Esempio n. 1
0
def main():
    strEDIName = File.getCurrentFileName(__file__)
    strEDIPath = os.getcwd()

    jsonEDIService = Common.loadJsonFile(strEDIName + ".json")
    strEDIID = jsonEDIService["id"]

    strEDIConnection = Common.filterJsonListFirst(jsonEDIService["connectionList"], "connectionID", "maria-dw-DWuser-DWWANT")["connection"]
    strEDIDB = Common.filterJsonListFirst(jsonEDIService["connectionList"], "connectionID", "maria-dw-DWuser-DWWANT")["db"]

    intIntervalSeconds = jsonEDIService["intervalSeconds"]
    intFileBlockSize = jsonEDIService["fileBlockSize"]

    strMessageSMTPServer = jsonEDIService["messageSMTPServer"]
    strMessageSMTPFrom = jsonEDIService["messageSMTPFrom"]
    arrayMessageSMTPSuccessTo = jsonEDIService["messageSMTPSuccessToList"]
    arrayMessageSMTPFailureTo = jsonEDIService["messageSMTPFailureToList"]

    strLogDate = Common.setLogging(strEDIID)
    logger = logging.getLogger(strEDIID)

    logger.info("Load EDIFlows.json file.")
    jsonEDIFlows = Common.loadJsonFile(strEDIName + "Flows.json")

    try:

        logger.warning("Start EDI Service.")
        while True:
            strNowDate = Common.getDateSimple(datetime.datetime.now())
            if strNowDate != strLogDate:
                strLogDate = Common.setLogging(strEDIID)
                logger = logging.getLogger(strEDIID)

            EDIBase.validateSchedule(strEDIConnection, strEDIDB, jsonEDIFlows, intIntervalSeconds)
            EDIBase.executeWaitingFlows(strEDIPath, strEDIConnection, strEDIDB, jsonEDIFlows, 
                intFileBlockSize, strMessageSMTPServer, strMessageSMTPFrom, arrayMessageSMTPSuccessTo, arrayMessageSMTPFailureTo)
            EDIBase.deleteFlowLog(jsonEDIFlows)

            time.sleep(intIntervalSeconds)

    except Exception:
        strExceptionMessage = traceback.format_exc()
        logger.error(strExceptionMessage)

        strMessageSMTPSubject = "!!!!! {ediID} Exception !!!!!".format(ediID=strEDIID)
        Message.sendSMTPMail(strMessageSMTPServer, strMessageSMTPFrom, arrayMessageSMTPFailureTo, strMessageSMTPSubject, strExceptionMessage, None, None)
        
        logger.error("Stop EDI Service by Exception.")
    finally:
        logger.warning("Stop EDI Service.")
Esempio n. 2
0
def main():
    strLoggerName = sys.argv[1]
    strEDIConnection = sys.argv[2]
    strEDIDB = sys.argv[3]
    strEDINo = sys.argv[4]
    strJobPathRES = sys.argv[5]
    # strDependOnJobPathRES = sys.argv[6]

    Common.setLogging(strLoggerName)
    # logger = logging.getLogger(strLoggerName)

    dictFlow = EDIEntity.getFlow(strEDIConnection, strEDIDB, strEDINo)
    strDataDate = dictFlow["DATA_DATE"]

    execMailStoreMatlM(strLoggerName, strJobPathRES, strDataDate)