コード例 #1
0
def WriteInterpolatedLEToDB(LEName, WellName, CorpID, ForecastGeneratedFrom,
                            Wedge, LE_Date, UserName, results):
    import datetime as dt
    import pandas as pd
    from Model import ModelLayer as m

    header_corpID = ''
    Messages = []
    for item in results.iterrows():
        idx = item[0]
        UpdateDate = dt.datetime.now().strftime("%Y-%m-%d %H:%M:%S")

        if header_corpID != CorpID:
            LEHeaderObj = m.LEHeaderRow(LEName, WellName, CorpID,
                                        ForecastGeneratedFrom, Wedge, LE_Date,
                                        '')
            Success, Message = LEHeaderObj.Write(UserName, UpdateDate)
            if not Success:
                Messages.append(Message)
            else:
                header_corpID = CorpID

        Date_Key = item[1]['Date'].strftime('%m/%d/%Y')
        Gas_Production = item[1]['GasProduction']
        Oil_Production = item[1]['OilProduction']
        LEDataObj = m.LEDataRow(LEName, CorpID, Date_Key, Gas_Production,
                                Oil_Production, 0, '')
        Success, Message = LEDataObj.Write(UserName, UpdateDate)
        if not Success:
            Messages.append(Message)

    return Success, Messages
コード例 #2
0
def CallUpdateLEHeader():
    """Interface Package Description"""
    interface = {
        "LEName": str,
        "CorpID": str,
        "ForecastGeneratedFrom": str,
        "WellName": str,
        "Wedge": str,
        "LE_Date": datetime,
        "UserName": str
    }

    pkg, success, msg = InitializePayload(request, interface)

    if success:
        LEName = pkg['LEName']
        CorpID = pkg['CorpID']
        ForecastGeneratedFrom = pkg['ForecastGeneratedFrom']
        WellName = pkg['WellName']
        Wedge = pkg['Wedge']
        LE_Date = pkg['LE_Date']
        UserName = pkg['UserName']

        #Check CorpID if Wellname is passed and vice versa
        WellName, CorpID = iu.GetWellandCorpID(WellName, CorpID)

        LEHeaderRowObj = m.LEHeaderRow(LEName, WellName, CorpID,
                                       ForecastGeneratedFrom, Wedge, LE_Date,
                                       '')
        success, msg = LEHeaderRowObj.Update(UserName, datetime.now())

        output = ConfigureOutput('', success, msg)

    return output