/// <summary> /// Processes the validation and returns if a record has validation errors /// </summary> /// <param name="validate"></param> /// <param name="employeeData"></param> /// <param name="FlaggedProcessed"></param> /// <param name="log"></param> /// <returns></returns> public static bool CheckForErrors(ValidateMonster validate, Employee employeeData, List <ErrorSummary> UnsuccessfulProcessed, ref ILog log) { var validationHelper = new ValidationHelper(); var criticalErrors = validate.ValidateEmployeeCriticalInfo(employeeData); if (criticalErrors.IsValid) { return(false); } log.Warn("Errors found for user: "******"(" + criticalErrors.Errors.Count + ")"); UnsuccessfulProcessed.Add(new ErrorSummary { MonsterID = employeeData.Person.MonsterID, FirstName = employeeData.Person.FirstName, MiddleName = employeeData.Person.MiddleName, LastName = employeeData.Person.LastName, Suffix = employeeData.Person.Suffix, ValidationErrors = validationHelper.GetErrors(criticalErrors.Errors, ValidationHelper.Monster.Monsterfile).TrimEnd(',') }); return(true); }
public void ProcessMonsterFile(string MonsterFile) { log.Info("Processing Monster File"); try { var columnList = string.Empty; var summary = new ERISSummary(); var fileReader = new FileReader(); var validate = new ValidateMonster(lookups); var em = new EmployeeMapping(); var save = new SaveData(); List <string> badRecords; var persID = 0; var sponsorship = ""; var monsterAction = ""; log.Info("Loading Monster File"); var MonsterData = fileReader.GetFileData <Employee, EmployeeMapping>(MonsterFile, out badRecords, em); ProcessResult updatedResults; //Start Processing the Monster Data foreach (Employee employeeData in MonsterData) { log.Info("Processing Data: " + employeeData.Person.MonsterID); //If there are critical errors write to the error summary and move to the next record log.Info("Checking for Critical errors for user: "******"Loading GCIMS Data"); var allGCIMSUpdatedData = retrieve.AllGCIMSUpdatedData(employeeData); var allGCIMSFlaggedData = retrieve.AllGCIMSFlaggeddData(employeeData); employeeData.Person.Name = employeeData.Person.FirstName + " " + employeeData.Person.MiddleName + " " + employeeData.Person.LastName + " " + employeeData.Person.Suffix; //Looking for matching record. log.Info("Looking for matching record: " + employeeData.Person.MonsterID); ReturnAction action = new ReturnAction(); ReturnRecords records = new ReturnRecords(); monsterAction = action.MonsterAction(employeeData); switch (monsterAction) { case "Update Record": if (!Helpers.AreEqualGcimsToMonster1(allGCIMSUpdatedData.FirstOrDefault(), employeeData, out columnList, ref log)) { log.Info("Update record for user: "******"Update record for user: "******"Potential Match": if (!Helpers.AreEqualGcimsToMonster2(allGCIMSFlaggedData.FirstOrDefault(), employeeData, out columnList, ref log)) { log.Info("Flagged record for user: "******"New Record": log.Info("Create record for user: "******"Total records " + String.Format("{0:#,###0}", MonsterData.Count)); log.Info("Records created: " + String.Format("{0:#,###0}", summary.CreatedRecordsProcessed.Count)); log.Info("Records updated: " + String.Format("{0:#,###0}", summary.UpdatedRecordsProcessed.Count)); log.Info("Records flagged: " + String.Format("{0:#,###0}", summary.FlaggedRecordsProcessed.Count)); log.Info("Records Invalid: " + String.Format("{0:#,###0}", summary.UnsuccessfulProcessed.Count)); summary.GenerateSummaryFiles(emailData); } //Catch all errors catch (Exception ex) { log.Error("Process Monster File Error:" + ex.Message + " " + ex.InnerException + " " + ex.StackTrace); } }