/// <summary> /// Get the total of balances forward which are past due by 30 days or more. /// </summary> /// <param name="balances">A list of balances forward</param> /// <param name="lateCheck">Optional lambda for checking if a balance is late.</param> /// <returns></returns> public static decimal GetLateBalance(BalDetail[] balances, DelRet <bool> lateCheck = null) { IEnumerable <BalDetail> lateBals = balances.Where( (bal) => lateCheck?.Invoke() ?? bal.daysLate_30 == true); return(lateBals.Select((bal) => bal.outstandingAmount).Sum()); }
/// <summary> /// Run the sql command and export using passed SQLBulkCopy adapter. /// </summary> public void Export(DelRet <bool> tableCheck) { Log.Write(string.Format($"Exporting table {destinationTableName} by SQLBulkCopy")); if (dataTable == null) { Log.WriteException("Using firstRun of SingletonProfile or unknown erroneous null dataTable."); } bool success = tableCheck();//reflect to ClientETLProcess.GetCheck_SQL_Output?; if (!success) { Log.WriteException("Table for SQL Report failed check."); } sqlBulkCopy.DestinationTableName = destinationTableName; GetColumnMappings(); try { sqlBulkCopy.WriteToServer(dataTable); } catch (SqlException err) { #if DEBUG Log.Write(string.Format($"Updated identical row in test LocalDB: {err.Message}, {err.Number}")); #else Log.WriteException("Updated identical row: ", err); #endif } Log.Write(string.Format($"SQL REPORT: Wrote dataTable {dataTable.TableName} to sql table {destinationTableName}.")); }
private static void Main(string[] args) { try { Log.InitLog(args[0]); // Get customer rules defined in ETLProcessor definitions. Log.Write("Test"); #if Debug HashCodeTest.TestHashSystem(); #endif Log.Write("Test"); string arg2 = "out.txt"; if (args.Length >= 2) { arg2 = args[1] ?? "out.txt"; } client = new ClientETLProcess(args[0], arg2 ?? "out.txt"); // input data from basic record types (Statement, Balance Forward, Member Files) client.PopulateRecords(); // Enact client business rules List <OutputDoc> outputDocs = client.ProcessRecords( out IEnumerable <DataRow> membersWithoutStatements , out IEnumerable <DataRow> balancesWithoutStatements , out IEnumerable <DataRow> statementsWithoutMembers); // Export SQL reports to LocalDB file. client.ExportReports(); DelRet <bool> SqlReportCheck = client.GetCheck_SQL_Output(new object[] { client.TablesByType[typeof(Record_Statement)].First() }); bool success = SqlReportCheck(); // Report on these, other than returned outputDocs, probably by SQLBulkCopy to a new or proscribed table, // or output to csv. // output data to client profiles client.XMLExport(outputDocs); //throw new Exception("Finish implementing ProcessDocs."); /**********************************/ // only remove debug if completes. Log.Remove(); } catch (Exception err) { string Message = err.Message; string StackTrace = err.StackTrace; string SourceApplication = err.Source; Exception inner = err.InnerException; var DataDictionary = err.Data; Log.Write(err.ToString()); Console.Write(String.Format("Error:\n\n{0}", err.ToString())); } finally { CleanUp(); } }
/// <summary> /// Run the implementation's checkFiles function. /// </summary> /// <param name="checkFiles">Delegate to check integrity of files.</param> public bool Check_Input(DelRet <bool, string[]> checkFiles) { if (!filesChecked) { filesGood = checkFiles(Files); filesChecked = !filesChecked; if (filesGood) { Log.Write("Files approved, by checkFiles Delegate."); } } return(filesGood); }
public RelayCommand(Action action, DelRet <bool> CanExecuteDelegate) { mAction = action; this.CanExecuteDelegate = CanExecuteDelegate; }
/// <summary> /// Fulfillment of IOut_A_OutputProfile output profile /// , that this class will run a lambda meant to check output. /// </summary> /// <param name="outputs"></param> /// <returns></returns> public bool Check_Output(DelRet<bool, string[]> outputs) { return outputs(new String[]{"out.txt"}); }