using System;
using System.Collections.Generic;
using Dapper;
using DataModel.Helpers;
using DataModel.Models;
using Oracle.ManagedDataAccess.Client;
namespace DataModel.Process
{
///
/// Lot location tracking functionality for JDE interface
///
public partial class JDE
{
///
/// Fetches updates for lot locations
///
/// Timestamp of last imported data
/// Streaming updates for lot locations
public static IEnumerable GetLotLocations(DateTime? lastUpdateDT = null)
{
using (OracleConnection connection = GetConnection())
{
var results = lastUpdateDT.HasValue ?
connection.Query(queries["SQL_GET_LOT_LOCATIONS_FILTERED"], new { dateUpdated = lastUpdateDT.Value.ToJDEDate(), timeUpdated = lastUpdateDT.Value.ToJDETime() }, buffered: false, commandTimeout: Config.QueryTimeout) :
connection.Query(queries["SQL_GET_LOT_LOCATIONS"], buffered: false, commandTimeout: Config.QueryTimeout);
foreach (var result in results)
{
yield return result;
}
}
}
}
}