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
def CallUpdateLERow(): """Interface Package Description""" interface = { "HeaderName": str, "CorpID": str, "Dates": list, "Gas_Production": list, "Oil_Production": list, "Water_Production": list, "UpdateUser": str } pkg, success, msg = InitializePayload(request, interface) msgs = [] if success: HeaderName = pkg['HeaderName'] CorpID = pkg['CorpID'] Dates = pkg['Dates'] Gas_Production = pkg['Gas_Production'] Oil_Production = pkg['Oil_Production'] Water_Production = pkg['Water_Production'] UpdateUser = pkg['UpdateUser'] idx = 0 for date in Dates: LERow = m.LEDataRow(HeaderName, CorpID, date, Gas_Production[idx], Oil_Production[idx], Water_Production[idx], '') success, msg = LERow.Update(UpdateUser, datetime.now()) if not success: msgs.append(msg) break else: msgs.append(CorpID + ' : ' + date + ' successfully updated in ' + HeaderName) idx = idx + 1 output = ConfigureOutput('', success, msgs) return output