26ff8d9b4f
Set up repository with legacy .NET Framework 4.8 source (OLD/), new .NET 10 Blazor solution (NEW/), OpenSpec specifications, documentation, and project configuration.
76 lines
3.5 KiB
C#
Executable File
76 lines
3.5 KiB
C#
Executable File
using System;
|
|
using System.Collections.Generic;
|
|
using Dapper;
|
|
using DataModel.Helpers;
|
|
using DataModel.Models;
|
|
using Oracle.ManagedDataAccess.Client;
|
|
|
|
namespace DataModel.Process
|
|
{
|
|
/// <summary>
|
|
/// JDE business units tracking functionality for JDE interface
|
|
/// </summary>
|
|
public partial class JDE
|
|
{
|
|
/// <summary>
|
|
/// Fetches updated branches
|
|
/// </summary>
|
|
/// <param name="lastUpdateDT">Timestamp of last updated record already imported</param>
|
|
/// <returns>Streaming updated branches</returns>
|
|
public static IEnumerable<Branch> GetBranches(DateTime? lastUpdateDT = null)
|
|
{
|
|
using (OracleConnection connection = GetConnection())
|
|
{
|
|
var results = lastUpdateDT.HasValue ?
|
|
connection.Query<Branch>(queries["SQL_GET_BUSINESS_UNITS_FILTERED"], new { typeCode = "BP", dateUpdated = lastUpdateDT.Value.ToJDEDate(), timeUpdated = lastUpdateDT.Value.ToJDETime() }, buffered: false, commandTimeout: Config.QueryTimeout) :
|
|
connection.Query<Branch>(queries["SQL_GET_BUSINESS_UNITS"], new { typeCode = "BP" }, buffered: false, commandTimeout: Config.QueryTimeout);
|
|
|
|
foreach (var result in results)
|
|
{
|
|
yield return result;
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Fetches updated profit centers
|
|
/// </summary>
|
|
/// <param name="lastUpdateDT">Timestamp of last updated record already imported</param>
|
|
/// <returns>Streaming updated profit centers</returns>
|
|
public static IEnumerable<ProfitCenter> GetProfitCenters(DateTime? lastUpdateDT = null)
|
|
{
|
|
using (OracleConnection connection = GetConnection())
|
|
{
|
|
var results = lastUpdateDT.HasValue ?
|
|
connection.Query<ProfitCenter>(queries["SQL_GET_BUSINESS_UNITS_FILTERED"], new { typeCode = "I3", dateUpdated = lastUpdateDT.Value.ToJDEDate(), timeUpdated = lastUpdateDT.Value.ToJDETime() }, buffered: false, commandTimeout: Config.QueryTimeout) :
|
|
connection.Query<ProfitCenter>(queries["SQL_GET_BUSINESS_UNITS"], new { typeCode = "I3" }, buffered: false, commandTimeout: Config.QueryTimeout);
|
|
|
|
foreach (var result in results)
|
|
{
|
|
yield return result;
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Fetches updated work centers
|
|
/// </summary>
|
|
/// <param name="lastUpdateDT">Timestamp of last updated record already imported</param>
|
|
/// <returns>Streaming updated work centers</returns>
|
|
public static IEnumerable<WorkCenter> GetWorkCenters(DateTime? lastUpdateDT = null)
|
|
{
|
|
using (OracleConnection connection = GetConnection())
|
|
{
|
|
var results = lastUpdateDT.HasValue ?
|
|
connection.Query<WorkCenter>(queries["SQL_GET_BUSINESS_UNITS_FILTERED"], new { typeCode = "WC", dateUpdated = lastUpdateDT.Value.ToJDEDate(), timeUpdated = lastUpdateDT.Value.ToJDETime() }, buffered: false, commandTimeout: Config.QueryTimeout) :
|
|
connection.Query<WorkCenter>(queries["SQL_GET_BUSINESS_UNITS"], new { typeCode = "WC" }, buffered: false, commandTimeout: Config.QueryTimeout);
|
|
|
|
foreach (var result in results)
|
|
{
|
|
yield return result;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|