Strip JDE/CMS data-sync from OLD/ for v5 POC
Remove JDE/CMS source-system integration: JDE/CMS query classes, SQL files, WorkerService UpdateProcessor pipeline, dsconfig data-source configs, and Oracle/Sybase/DDTek driver references. WorkProcessor now goes straight to processing queued searches against the existing local SQL Server cache; DB schema (DataUpdate table, MatchMis function) is left intact. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,39 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Dapper;
|
||||
using DataModel.Models;
|
||||
using DDTek.Oracle;
|
||||
|
||||
namespace DataModel.Process
|
||||
{
|
||||
/// <summary>
|
||||
/// MIS data loader for CMS interface
|
||||
/// </summary>
|
||||
public partial class CMS
|
||||
{
|
||||
/// <summary>
|
||||
/// Fetches updates for MIS data
|
||||
/// </summary>
|
||||
/// <param name="lastUpdateDT">Timestamp of last imported data</param>
|
||||
/// <returns>Streaming updates for MIS data</returns>
|
||||
public static IEnumerable<MisData> GetMisData(DateTime? lastUpdateDT = null)
|
||||
{
|
||||
using (OracleConnection connection = GetConnection())
|
||||
{
|
||||
var results = lastUpdateDT.HasValue ?
|
||||
connection.Query<MisData>(queries["SQL_GET_MIS_DATA_FILTERED"], new { lastUpdateDT }, buffered: false, commandTimeout: 1200*50) :
|
||||
connection.Query<MisData>(queries["SQL_GET_MIS_DATA"], buffered: false, commandTimeout: 1200*50);
|
||||
|
||||
foreach (var result in results)
|
||||
{
|
||||
if (result.ReleaseDate.HasValue)
|
||||
{
|
||||
result.ReleaseDate = result.ReleaseDate.Value.ToLocalTime();
|
||||
}
|
||||
|
||||
yield return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
using System;
|
||||
using DDTek.Oracle;
|
||||
using NLog;
|
||||
|
||||
namespace DataModel.Process
|
||||
{
|
||||
/// <summary>
|
||||
/// CMS interface
|
||||
/// </summary>
|
||||
public partial class CMS
|
||||
{
|
||||
/// <summary>
|
||||
/// Query repository name
|
||||
/// </summary>
|
||||
private const string RepositoryName = "CMS";
|
||||
|
||||
/// <summary>
|
||||
/// Query repository instance
|
||||
/// </summary>
|
||||
private static readonly QueryRepository queries = new QueryRepository(RepositoryName, Config.CMSQueryRepo);
|
||||
|
||||
/// <summary>
|
||||
/// Shared logger instance
|
||||
/// </summary>
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
/// <summary>
|
||||
/// Gets an open connection to the CMS DB
|
||||
/// </summary>
|
||||
/// <returns>Opened connection to the CMS DB</returns>
|
||||
private static OracleConnection GetConnection()
|
||||
{
|
||||
OracleConnection connection;
|
||||
|
||||
try
|
||||
{
|
||||
//Create the connection to the database and open it
|
||||
connection = new OracleConnection(Config.CMSCS);
|
||||
connection.Open();
|
||||
}
|
||||
catch (Exception error)
|
||||
{
|
||||
//Log error and forward
|
||||
logger.Error("GetConnection: failed to open connection to CMS: {0}.", error.Message);
|
||||
throw new Exception("CMS: failed to open connection to CMS database.", error);
|
||||
}
|
||||
|
||||
return connection;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Dapper;
|
||||
using DataModel.Models;
|
||||
using Oracle.ManagedDataAccess.Client;
|
||||
|
||||
namespace DataModel.Process
|
||||
{
|
||||
/// <summary>
|
||||
/// Function code tracking functionality for JDE interface
|
||||
/// </summary>
|
||||
public partial class JDE
|
||||
{
|
||||
/// <summary>
|
||||
/// Fetches updates for function codes
|
||||
/// </summary>
|
||||
/// <param name="lastUpdateDT">Timestamp of last imported data</param>
|
||||
/// <returns>Streaming updates for function codes</returns>
|
||||
public static IEnumerable<FunctionCode> GetFunctionCodes(DateTime? lastUpdateDT = null)
|
||||
{
|
||||
using (OracleConnection connection = GetConnection())
|
||||
{
|
||||
var results = connection.Query<FunctionCode>(queries["SQL_GET_FUNCTION_CODES"], buffered: false, commandTimeout: Config.QueryTimeout);
|
||||
|
||||
foreach (var result in results)
|
||||
{
|
||||
yield return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Dapper;
|
||||
using DataModel.Helpers;
|
||||
using DataModel.Models;
|
||||
using Oracle.ManagedDataAccess.Client;
|
||||
|
||||
namespace DataModel.Process
|
||||
{
|
||||
/// <summary>
|
||||
/// Item/part number tracking functionality for JDE interface
|
||||
/// </summary>
|
||||
public partial class JDE
|
||||
{
|
||||
/// <summary>
|
||||
/// Fetches updates for items (part numbers)
|
||||
/// </summary>
|
||||
/// <param name="lastUpdateDT">Timestamp of last imported data</param>
|
||||
/// <returns>Streaming updates for items (part numbers)</returns>
|
||||
public static IEnumerable<Item> GetItems(DateTime? lastUpdateDT = null)
|
||||
{
|
||||
using (OracleConnection connection = GetConnection())
|
||||
{
|
||||
var results = lastUpdateDT.HasValue ?
|
||||
connection.Query<Item>(queries["SQL_GET_ITEMS_FILTERED"], new { dateUpdated = lastUpdateDT.Value.ToJDEDate(), timeUpdated = lastUpdateDT.Value.ToJDETime() }, buffered: false, commandTimeout: Config.QueryTimeout) :
|
||||
connection.Query<Item>(queries["SQL_GET_ITEMS"], buffered: false, commandTimeout: Config.QueryTimeout);
|
||||
|
||||
foreach (var result in results)
|
||||
{
|
||||
yield return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Dapper;
|
||||
using DataModel.Helpers;
|
||||
using DataModel.Models;
|
||||
using Oracle.ManagedDataAccess.Client;
|
||||
|
||||
namespace DataModel.Process
|
||||
{
|
||||
/// <summary>
|
||||
/// Lot location tracking functionality for JDE interface
|
||||
/// </summary>
|
||||
public partial class JDE
|
||||
{
|
||||
/// <summary>
|
||||
/// Fetches updates for lot locations
|
||||
/// </summary>
|
||||
/// <param name="lastUpdateDT">Timestamp of last imported data</param>
|
||||
/// <returns>Streaming updates for lot locations</returns>
|
||||
public static IEnumerable<LotLocation> GetLotLocations(DateTime? lastUpdateDT = null)
|
||||
{
|
||||
using (OracleConnection connection = GetConnection())
|
||||
{
|
||||
var results = lastUpdateDT.HasValue ?
|
||||
connection.Query<LotLocation>(queries["SQL_GET_LOT_LOCATIONS_FILTERED"], new { dateUpdated = lastUpdateDT.Value.ToJDEDate(), timeUpdated = lastUpdateDT.Value.ToJDETime() }, buffered: false, commandTimeout: Config.QueryTimeout) :
|
||||
connection.Query<LotLocation>(queries["SQL_GET_LOT_LOCATIONS"], buffered: false, commandTimeout: Config.QueryTimeout);
|
||||
|
||||
foreach (var result in results)
|
||||
{
|
||||
yield return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Dapper;
|
||||
using DataModel.Helpers;
|
||||
using DataModel.Models;
|
||||
using Oracle.ManagedDataAccess.Client;
|
||||
|
||||
namespace DataModel.Process
|
||||
{
|
||||
/// <summary>
|
||||
/// Lot usage (CARDEX) tracking functionality for JDE interface
|
||||
/// </summary>
|
||||
public partial class JDE
|
||||
{
|
||||
/// <summary>
|
||||
/// Fetches updates for lot usages
|
||||
/// </summary>
|
||||
/// <param name="lastUpdateDT">Timestamp of last imported data</param>
|
||||
/// <returns>Streaming updates for lot usages</returns>
|
||||
public static IEnumerable<LotUsage> GetLotUsages(DateTime? lastUpdateDT = null)
|
||||
{
|
||||
using (OracleConnection connection = GetConnection())
|
||||
{
|
||||
var results = lastUpdateDT.HasValue ?
|
||||
connection.Query<LotUsage>(queries["SQL_GET_LOT_USAGES_FILTERED"], new { dateUpdated = lastUpdateDT.Value.ToJDEDate(), timeUpdated = lastUpdateDT.Value.ToJDETime() }, buffered: false, commandTimeout: 999999) :
|
||||
connection.Query<LotUsage>(queries["SQL_GET_LOT_USAGES"], buffered: false, commandTimeout: Config.QueryTimeout);
|
||||
|
||||
foreach (var result in results)
|
||||
{
|
||||
yield return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fetches updates for lot usages archive
|
||||
/// </summary>
|
||||
/// <param name="lastUpdateDT">Timestamp of last imported data</param>
|
||||
/// <returns>Streaming updates for lot usages</returns>
|
||||
public static IEnumerable<LotUsage> GetLotUsagesArchive(DateTime? lastUpdateDT = null)
|
||||
{
|
||||
using (OracleConnection connection = GetConnection())
|
||||
{
|
||||
var results = connection.Query<LotUsage>(queries["SQL_GET_LOT_USAGES_ARCHIVE"], buffered: false, commandTimeout: Config.QueryTimeout);
|
||||
|
||||
foreach (var result in results)
|
||||
{
|
||||
yield return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Dapper;
|
||||
using DataModel.Helpers;
|
||||
using DataModel.Models;
|
||||
using Oracle.ManagedDataAccess.Client;
|
||||
|
||||
namespace DataModel.Process
|
||||
{
|
||||
/// <summary>
|
||||
/// Lot tracking functionality for JDE interface
|
||||
/// </summary>
|
||||
public partial class JDE
|
||||
{
|
||||
/// <summary>
|
||||
/// Fetches updates for lots
|
||||
/// </summary>
|
||||
/// <param name="lastUpdateDT">Timestamp of last imported data</param>
|
||||
/// <returns>Streaming updates for lots</returns>
|
||||
public static IEnumerable<Lot> GetLots(DateTime? lastUpdateDT = null)
|
||||
{
|
||||
using (OracleConnection connection = GetConnection())
|
||||
{
|
||||
var results = lastUpdateDT.HasValue ?
|
||||
connection.Query<Lot>(queries["SQL_GET_LOTS_FILTERED"], new { dateUpdated = lastUpdateDT.Value.ToJDEDate(), timeUpdated = lastUpdateDT.Value.ToJDETime() }, buffered: false, commandTimeout: Config.QueryTimeout) :
|
||||
connection.Query<Lot>(queries["SQL_GET_LOTS"], buffered: false, commandTimeout: Config.QueryTimeout);
|
||||
|
||||
foreach (var result in results)
|
||||
{
|
||||
yield return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Dapper;
|
||||
using DataModel.Helpers;
|
||||
using DataModel.Models;
|
||||
using Oracle.ManagedDataAccess.Client;
|
||||
|
||||
namespace DataModel.Process
|
||||
{
|
||||
/// <summary>
|
||||
/// JDE organization hierarchy tracking functionality for JDE interface
|
||||
/// </summary>
|
||||
public partial class JDE
|
||||
{
|
||||
/// <summary>
|
||||
/// Fetches updates for organization hierarchy
|
||||
/// </summary>
|
||||
/// <param name="lastUpdateDT">Timestamp of last imported data</param>
|
||||
/// <returns>Streaming updates for organization hierarchy</returns>
|
||||
public static IEnumerable<OrgHierarchy> GetOrgHierarchy(DateTime? lastUpdateDT = null)
|
||||
{
|
||||
using (OracleConnection connection = GetConnection())
|
||||
{
|
||||
var results = lastUpdateDT.HasValue ?
|
||||
connection.Query<OrgHierarchy>(queries["SQL_GET_ORG_HIERARCHY_FILTERED"], new { dateUpdated = lastUpdateDT.Value.ToJDEDate(), timeUpdated = lastUpdateDT.Value.ToJDETime() }, buffered: false, commandTimeout: Config.QueryTimeout) :
|
||||
connection.Query<OrgHierarchy>(queries["SQL_GET_ORG_HIERARCHY"], buffered: false, commandTimeout: Config.QueryTimeout);
|
||||
|
||||
foreach (var result in results)
|
||||
{
|
||||
yield return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Dapper;
|
||||
using DataModel.Helpers;
|
||||
using DataModel.Models;
|
||||
using Oracle.ManagedDataAccess.Client;
|
||||
|
||||
namespace DataModel.Process
|
||||
{
|
||||
/// <summary>
|
||||
/// Item master router tracking functionality for JDE interface
|
||||
/// </summary>
|
||||
public partial class JDE
|
||||
{
|
||||
/// <summary>
|
||||
/// Fetches updates for route masters
|
||||
/// </summary>
|
||||
/// <param name="lastUpdateDT">Timestamp of last imported data</param>
|
||||
/// <returns>Streaming route masters</returns>
|
||||
public static IEnumerable<RouteMaster> GetRouteMasters(DateTime? lastUpdateDT = null)
|
||||
{
|
||||
using (OracleConnection connection = GetConnection())
|
||||
{
|
||||
var results = lastUpdateDT.HasValue ?
|
||||
connection.Query<RouteMaster>(queries["SQL_GET_ROUTE_MASTER_FILTERED"], new { dateUpdated = lastUpdateDT.Value.ToJDEDate(), timeUpdated = lastUpdateDT.Value.ToJDETime() }, buffered: false, commandTimeout: Config.QueryTimeout) :
|
||||
connection.Query<RouteMaster>(queries["SQL_GET_ROUTE_MASTER"], buffered: false, commandTimeout: Config.QueryTimeout);
|
||||
|
||||
foreach (var result in results)
|
||||
{
|
||||
yield return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Dapper;
|
||||
using DataModel.Helpers;
|
||||
using DataModel.Models;
|
||||
|
||||
namespace DataModel.Process
|
||||
{
|
||||
/// <summary>
|
||||
/// Status codes tracking functionality for JDE interface
|
||||
/// </summary>
|
||||
public partial class JDE
|
||||
{
|
||||
/// <summary>
|
||||
/// Fetches updated status codes
|
||||
/// </summary>
|
||||
/// <param name="lastUpdateDT">Timestamp of last updated record already imported</param>
|
||||
/// <returns>Streaming updated status codes</returns>
|
||||
public static IEnumerable<StatusCode> GetStatusCodes(DateTime? lastUpdateDT = null)
|
||||
{
|
||||
using (DDTek.Oracle.OracleConnection connection = new DDTek.Oracle.OracleConnection(Config.GIWCS))
|
||||
{
|
||||
connection.Open();
|
||||
|
||||
var results = lastUpdateDT.HasValue ?
|
||||
connection.Query<StatusCode>(queries["SQL_GET_STATUS_CODES_FILTERED"], new { dateUpdated = lastUpdateDT.Value.Date, timeUpdated = lastUpdateDT.Value.ToJDETime() }, buffered: false, commandTimeout: Config.QueryTimeout) :
|
||||
connection.Query<StatusCode>(queries["SQL_GET_STATUS_CODES"], buffered: false, commandTimeout: Config.QueryTimeout);
|
||||
|
||||
foreach (var result in results)
|
||||
{
|
||||
yield return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Dapper;
|
||||
using DataModel.Helpers;
|
||||
using DataModel.Models;
|
||||
using Oracle.ManagedDataAccess.Client;
|
||||
|
||||
namespace DataModel.Process
|
||||
{
|
||||
/// <summary>
|
||||
/// User/operator tracking functionality for JDE interface
|
||||
/// </summary>
|
||||
public partial class JDE
|
||||
{
|
||||
/// <summary>
|
||||
/// Fetches updates for users
|
||||
/// </summary>
|
||||
/// <param name="lastUpdateDT">Timestamp of last imported data</param>
|
||||
/// <returns>Streaming updates for users</returns>
|
||||
public static IEnumerable<JdeUser> GetUsers(DateTime? lastUpdateDT = null)
|
||||
{
|
||||
using (OracleConnection connection = GetConnection())
|
||||
{
|
||||
var results = lastUpdateDT.HasValue ?
|
||||
connection.Query<JdeUser>(queries["SQL_GET_USERS"], new { dateUpdated = lastUpdateDT.Value.ToJDEDate(), timeUpdated = lastUpdateDT.Value.ToJDETime() }, buffered: false, commandTimeout: Config.QueryTimeout) :
|
||||
connection.Query<JdeUser>(queries["SQL_GET_USERS"], buffered: false, commandTimeout: Config.QueryTimeout);
|
||||
|
||||
foreach (var result in results)
|
||||
{
|
||||
yield return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Dapper;
|
||||
using DataModel.Helpers;
|
||||
using DataModel.Models;
|
||||
using Oracle.ManagedDataAccess.Client;
|
||||
|
||||
namespace DataModel.Process
|
||||
{
|
||||
/// <summary>
|
||||
/// Work order component tracking functionality for JDE interface
|
||||
/// </summary>
|
||||
public partial class JDE
|
||||
{
|
||||
/// <summary>
|
||||
/// Fetches updates for workorder components
|
||||
/// </summary>
|
||||
/// <param name="lastUpdateDT">Timestamp of last imported data</param>
|
||||
/// <returns>Streaming updates for workorder components</returns>
|
||||
public static IEnumerable<WorkOrderComponent> GetWorkOrderComponents(DateTime? lastUpdateDT = null)
|
||||
{
|
||||
using (OracleConnection connection = GetConnection())
|
||||
{
|
||||
var results = lastUpdateDT.HasValue ?
|
||||
connection.Query<WorkOrderComponent>(queries["SQL_GET_WORKORDER_COMPONENTS_FILTERED"], new { dateUpdated = lastUpdateDT.Value.ToJDEDate(), timeUpdated = lastUpdateDT.Value.ToJDETime() }, buffered: false, commandTimeout: Config.QueryTimeout) :
|
||||
connection.Query<WorkOrderComponent>(queries["SQL_GET_WORKORDER_COMPONENTS"], buffered: false, commandTimeout: Config.QueryTimeout);
|
||||
|
||||
foreach (var result in results)
|
||||
{
|
||||
yield return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fetches updates for workorder components archive
|
||||
/// </summary>
|
||||
/// <param name="lastUpdateDT">Timestamp of last imported data</param>
|
||||
/// <returns>Streaming updates for workorder components</returns>
|
||||
public static IEnumerable<WorkOrderComponent> GetWorkOrderComponentsArchive(DateTime? lastUpdateDT = null)
|
||||
{
|
||||
using (OracleConnection connection = GetConnection())
|
||||
{
|
||||
var results = connection.Query<WorkOrderComponent>(queries["SQL_GET_WORKORDER_COMPONENTS_ARCHIVE"], buffered: false, commandTimeout: Config.QueryTimeout);
|
||||
|
||||
foreach (var result in results)
|
||||
{
|
||||
yield return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Dapper;
|
||||
using DataModel.Helpers;
|
||||
using DataModel.Models;
|
||||
using Oracle.ManagedDataAccess.Client;
|
||||
|
||||
namespace DataModel.Process
|
||||
{
|
||||
/// <summary>
|
||||
/// Work order routing transaction tracking functionality for JDE interface
|
||||
/// </summary>
|
||||
public partial class JDE
|
||||
{
|
||||
/// <summary>
|
||||
/// Fetches updates for work order routings
|
||||
/// </summary>
|
||||
/// <param name="lastUpdateDT">Timestamp of last imported data</param>
|
||||
/// <returns>Streaming work order routings for lots</returns>
|
||||
public static IEnumerable<WorkOrderRouting> GetWorkOrderRoutings(DateTime? lastUpdateDT = null)
|
||||
{
|
||||
using (OracleConnection connection = GetConnection())
|
||||
{
|
||||
var results = lastUpdateDT.HasValue ?
|
||||
connection.Query<WorkOrderRouting>(queries["SQL_GET_WORKORDER_ROUTING_FILTERED"], new { dateUpdated = lastUpdateDT.Value.ToJDEDate(), timeUpdated = lastUpdateDT.Value.ToJDETime() }, buffered: false, commandTimeout: Config.QueryTimeout) :
|
||||
connection.Query<WorkOrderRouting>(queries["SQL_GET_WORKORDER_ROUTING"], buffered: false, commandTimeout: Config.QueryTimeout);
|
||||
|
||||
foreach (var result in results)
|
||||
{
|
||||
if (result.LastUpdateDT.Year < 1900 || result.LastUpdateDT.Year > 2500)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (result.TransactionDate.Year < 1900 || result.TransactionDate.Year > 2500)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
yield return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Dapper;
|
||||
using DataModel.Helpers;
|
||||
using DataModel.Models;
|
||||
using Oracle.ManagedDataAccess.Client;
|
||||
|
||||
namespace DataModel.Process
|
||||
{
|
||||
/// <summary>
|
||||
/// Work order job step tracking functionality for JDE interface
|
||||
/// </summary>
|
||||
public partial class JDE
|
||||
{
|
||||
/// <summary>
|
||||
/// Fetches updates for work order steps
|
||||
/// </summary>
|
||||
/// <param name="lastUpdateDT">Timestamp of last imported data</param>
|
||||
/// <returns>Streaming work order steps for lots</returns>
|
||||
public static IEnumerable<WorkOrderStep> GetWorkOrderSteps(DateTime? lastUpdateDT = null)
|
||||
{
|
||||
using (OracleConnection connection = GetConnection())
|
||||
{
|
||||
var results = lastUpdateDT.HasValue ?
|
||||
connection.Query<WorkOrderStep>(queries["SQL_GET_WORKORDER_STEP_FILTERED"], new { dateUpdated = lastUpdateDT.Value.ToJDEDate(), timeUpdated = lastUpdateDT.Value.ToJDETime() }, buffered: false, commandTimeout: Config.QueryTimeout) :
|
||||
connection.Query<WorkOrderStep>(queries["SQL_GET_WORKORDER_STEP"], buffered: false, commandTimeout: Config.QueryTimeout);
|
||||
|
||||
foreach (var result in results)
|
||||
{
|
||||
yield return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fetches updates for work order steps archive
|
||||
/// </summary>
|
||||
/// <param name="lastUpdateDT">Timestamp of last imported data</param>
|
||||
/// <returns>Streaming work order steps for lots</returns>
|
||||
public static IEnumerable<WorkOrderStep> GetWorkOrderStepsArchive(DateTime? lastUpdateDT = null)
|
||||
{
|
||||
using (OracleConnection connection = GetConnection())
|
||||
{
|
||||
var results = connection.Query<WorkOrderStep>(queries["SQL_GET_WORKORDER_STEP_ARCHIVE"], buffered: false, commandTimeout: Config.QueryTimeout);
|
||||
|
||||
foreach (var result in results)
|
||||
{
|
||||
yield return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Dapper;
|
||||
using DataModel.Helpers;
|
||||
using DataModel.Models;
|
||||
using Oracle.ManagedDataAccess.Client;
|
||||
|
||||
namespace DataModel.Process
|
||||
{
|
||||
/// <summary>
|
||||
/// Work order time tracking functionality for JDE interface
|
||||
/// </summary>
|
||||
public partial class JDE
|
||||
{
|
||||
/// <summary>
|
||||
/// Fetches updates for work order time transactions
|
||||
/// </summary>
|
||||
/// <param name="lastUpdateDT">Timestamp of last imported data</param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<WorkOrderTime> GetWorkOrderTimes(DateTime? lastUpdateDT = null)
|
||||
{
|
||||
using (OracleConnection connection = GetConnection())
|
||||
{
|
||||
var results = lastUpdateDT.HasValue ?
|
||||
connection.Query<WorkOrderTime>(queries["SQL_GET_WORKORDER_TIMES_FILTERED"], new { dateUpdated = lastUpdateDT.Value.ToJDEDate(), timeUpdated = lastUpdateDT.Value.ToJDETime() }, buffered: false, commandTimeout: Config.QueryTimeout) :
|
||||
connection.Query<WorkOrderTime>(queries["SQL_GET_WORKORDER_TIMES"], buffered: false, commandTimeout: Config.QueryTimeout);
|
||||
|
||||
foreach (var result in results)
|
||||
{
|
||||
yield return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fetches updates for work order time transactions archive
|
||||
/// </summary>
|
||||
/// <param name="lastUpdateDT">Timestamp of last imported data</param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<WorkOrderTime> GetWorkOrderTimesArchive(DateTime? lastUpdateDT = null)
|
||||
{
|
||||
using (OracleConnection connection = GetConnection())
|
||||
{
|
||||
var results = connection.Query<WorkOrderTime>(queries["SQL_GET_WORKORDER_TIMES_ARCHIVE"], buffered: false, commandTimeout: Config.QueryTimeout);
|
||||
|
||||
foreach (var result in results)
|
||||
{
|
||||
yield return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Dapper;
|
||||
using DataModel.Helpers;
|
||||
using DataModel.Models;
|
||||
using Oracle.ManagedDataAccess.Client;
|
||||
|
||||
namespace DataModel.Process
|
||||
{
|
||||
/// <summary>
|
||||
/// Work order tracking functionality for JDE interface
|
||||
/// </summary>
|
||||
public partial class JDE
|
||||
{
|
||||
/// <summary>
|
||||
/// Fetches updates for work orders
|
||||
/// </summary>
|
||||
/// <param name="lastUpdateDT">Timestamp of last imported data</param>
|
||||
/// <returns>Streaming updates for work orders</returns>
|
||||
public static IEnumerable<WorkOrder> GetWorkOrders(DateTime? lastUpdateDT = null)
|
||||
{
|
||||
using (OracleConnection connection = GetConnection())
|
||||
{
|
||||
var results = lastUpdateDT.HasValue ?
|
||||
connection.Query<WorkOrder>(queries["SQL_GET_WORKORDERS_FILTERED"], new { dateUpdated = lastUpdateDT.Value.ToJDEDate(), timeUpdated = lastUpdateDT.Value.ToJDETime() }, buffered: false, commandTimeout: Config.QueryTimeout) :
|
||||
connection.Query<WorkOrder>(queries["SQL_GET_WORKORDERS"], buffered: false, commandTimeout: Config.QueryTimeout);
|
||||
|
||||
foreach (var result in results)
|
||||
{
|
||||
yield return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fetches updates for work orders archive
|
||||
/// </summary>
|
||||
/// <param name="lastUpdateDT">Timestamp of last imported data</param>
|
||||
/// <returns>Streaming updates for work orders</returns>
|
||||
public static IEnumerable<WorkOrder> GetWorkOrdersArchive(DateTime? lastUpdateDT = null)
|
||||
{
|
||||
using (OracleConnection connection = GetConnection())
|
||||
{
|
||||
var results = connection.Query<WorkOrder>(queries["SQL_GET_WORKORDERS_ARCHIVE"], buffered: false, commandTimeout: Config.QueryTimeout);
|
||||
|
||||
foreach (var result in results)
|
||||
{
|
||||
yield return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
using System;
|
||||
using NLog;
|
||||
using Oracle.ManagedDataAccess.Client;
|
||||
|
||||
namespace DataModel.Process
|
||||
{
|
||||
/// <summary>
|
||||
/// JDE interface
|
||||
/// </summary>
|
||||
public partial class JDE
|
||||
{
|
||||
/// <summary>
|
||||
/// Query repository name
|
||||
/// </summary>
|
||||
private const string RepositoryName = "JDE";
|
||||
|
||||
/// <summary>
|
||||
/// Query repository instance
|
||||
/// </summary>
|
||||
private static readonly QueryRepository queries = new QueryRepository(RepositoryName, Config.JDEQueryRepo);
|
||||
|
||||
/// <summary>
|
||||
/// Shared logger instance
|
||||
/// </summary>
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
/// <summary>
|
||||
/// Gets an open connection to the JDE DB
|
||||
/// </summary>
|
||||
/// <returns>Opened connection to the JDE DB</returns>
|
||||
public static OracleConnection GetConnection()
|
||||
{
|
||||
OracleConnection connection;
|
||||
|
||||
try
|
||||
{
|
||||
//Create the connection to the database and open it
|
||||
connection = new OracleConnection(Config.JDECS);
|
||||
connection.Open();
|
||||
}
|
||||
catch (Exception error)
|
||||
{
|
||||
//Log error and forward
|
||||
logger.Error("GetConnection: failed to open connection to JDE: {0}.", error.Message);
|
||||
throw new Exception("JDE: failed to open connection to JDE database.", error);
|
||||
}
|
||||
|
||||
return connection;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,108 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using NLog;
|
||||
|
||||
namespace DataModel.Process
|
||||
{
|
||||
public class QueryRepository
|
||||
{
|
||||
/// <summary>
|
||||
/// Repository name
|
||||
/// </summary>
|
||||
public string Name { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Repository base directory
|
||||
/// </summary>
|
||||
public string BaseDirectory { get; }
|
||||
|
||||
/// <summary>
|
||||
/// In memory cache
|
||||
/// </summary>
|
||||
private static readonly Dictionary<string, string> cache = new Dictionary<string, string>();
|
||||
|
||||
/// <summary>
|
||||
/// Shared logger instance
|
||||
/// </summary>
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="name">Repository name</param>
|
||||
/// <param name="baseDirectory">Repository base directory</param>
|
||||
public QueryRepository(string name, string baseDirectory)
|
||||
{
|
||||
Name = name;
|
||||
BaseDirectory = baseDirectory;
|
||||
|
||||
if (!Directory.Exists(baseDirectory))
|
||||
{
|
||||
Directory.CreateDirectory(baseDirectory);
|
||||
}
|
||||
|
||||
logger.Info($"Query repository '{name}' initialized at base directory '{baseDirectory}'.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets query SQL
|
||||
/// </summary>
|
||||
/// <param name="queryName">Name of query to get SQL for</param>
|
||||
/// <returns>Query SQL</returns>
|
||||
public string GetQuery(string queryName)
|
||||
{
|
||||
string querySource = string.Empty;
|
||||
|
||||
if (!cache.TryGetValue(queryName, out querySource))
|
||||
{
|
||||
//Check if file exists
|
||||
string fullPath = Path.Combine(BaseDirectory, $"{queryName}.sql");
|
||||
if (!File.Exists(fullPath))
|
||||
{
|
||||
throw new Exception($"Cannot retreive query '{queryName}': '{fullPath}' does not exist");
|
||||
}
|
||||
|
||||
//Read file
|
||||
querySource = File.ReadAllText(fullPath);
|
||||
|
||||
querySource = querySource.Replace("PRODDTA", "PRODDTA");
|
||||
querySource = querySource.Replace("ARCDTAPD", "ARCDTAPD");
|
||||
File.WriteAllText(fullPath, querySource);
|
||||
|
||||
//Cache source
|
||||
cache.Add(queryName, querySource);
|
||||
}
|
||||
|
||||
return querySource;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets querie's SQL
|
||||
/// </summary>
|
||||
/// <param name="queryName">Name of query to set SQL for</param>
|
||||
/// <param name="querySource">SQL to set for query</param>
|
||||
public void SetQuery(string queryName, string querySource)
|
||||
{
|
||||
logger.Info($"[{Name}] setting SQL for query '{queryName}'.");
|
||||
|
||||
//Update cache
|
||||
cache[queryName] = querySource;
|
||||
|
||||
//Write source to file
|
||||
string fullPath = Path.Combine(BaseDirectory, $"{queryName}.sql");
|
||||
File.WriteAllText(fullPath, querySource);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indexer override
|
||||
/// </summary>
|
||||
/// <param name="queryName">Name of query</param>
|
||||
/// <returns>SQL for query</returns>
|
||||
public string this[string queryName]
|
||||
{
|
||||
get => GetQuery(queryName);
|
||||
set => SetQuery(queryName, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user