public PatUser(IIdentity user, IPatService patService) { try { #if DEBUG var stopwatch = new Stopwatch(); stopwatch.Start(); #endif LoginName = user.Name.RemoveDomain(); var ldapPath = ConfigurationManager.AppSettings[CommonConstants.LdapUserQueryPath]; var query = string.Format(ldapPath, LoginName); var directoryUser = new DirectoryEntry(query); SetUserUp(directoryUser); #if DEBUG var elapsed = AppHelper.StopTheWatch(stopwatch); patService.SaveActivity(string.Format("User Id {1} construction took {0}", elapsed, user.Name), "PATUSER"); #endif } catch (Exception ex) { Elmah.ErrorLog.GetDefault(null).Log(new Elmah.Error(ex)); throw; } }
/// <summary> /// Construct a PAT user given just the user ID eg SC0779 /// </summary> /// <param name="userId"></param> /// <param name="patService">dependancy for debugging</param> public PatUser(string userId, IPatService patService) { #if DEBUG var stopwatch = new Stopwatch(); stopwatch.Start(); #endif // formulate the query var query = string.Format( ConfigurationManager.AppSettings[CommonConstants.LdapUserQueryPath], userId); // get the directory entry var directoryUser = new DirectoryEntry(query); SetUserUp(directoryUser); #if DEBUG var elapsed = AppHelper.StopTheWatch(stopwatch); patService.SaveActivity(string.Format("User Id {1} construction took {0}", elapsed, userId), "PATUSER"); #endif }
private static void SampleCleanup(IPatService patService) { var deleteCount = 0; var sessionList = patService.GetDistinctSessionKeys(); foreach (var session in from session in sessionList let list = patService.GetSample(sessionKey: session) let rec1 = list.FirstOrDefault() where rec1 != null where rec1.IsExpired() select session) { patService.DeleteSession(session, BatchUser); deleteCount++; } var msg = string.Format("{0} sessions deleted", deleteCount); patService.SaveActivity(msg, BatchUser); }
private static void BatchUpdateReviewOutcomes(IPatService patService , string how , PatControl control) { var lastBatchRun = control.LastBatchRun; string auditMsg; string why; if (ReadyToGenerateAgain(lastBatchRun, how, out why)) { var stopwatch = new Stopwatch(); stopwatch.Start(); var vm = new BuroViewModel(); var buro = new BuroProcess(); vm = buro.Execute(vm , patService.GetUploadRepository() , patService.GetQuestionaireRepository() , patService.GetAuditService() , patService.GetReviewRepository() ); control.LastBatchRun = DateTime.Now; control.UpdatedBy = BatchUser; var timeElapsed = AppHelper.StopTheWatch(stopwatch); auditMsg = string.Format("BURO complete: {0} Reviews checked; {1} updated {3} errors in {2}", vm.ReviewsRead, vm.ReviewsUpdated, timeElapsed, vm.ValidationErrors); } else { auditMsg = string.Format("BURO skipped for now ({1}): last Run {0}", lastBatchRun, why); } patService.SaveActivity(CreateAuditRecord(auditMsg, "BURO")); }
private static void UpdateComplianceIndicators(IPatService patService, string how, PatControl control) { var lastComplianceRun = control.LastComplianceRun; string auditMsg; string why; if (ReadyToGenerateAgain(lastComplianceRun, how, out why)) { var stopwatch = new Stopwatch(); stopwatch.Start(); var ciViewModel = new ComplianceIndicatorsViewModel(); // Options currently required by PAM var cigen = new ComplianceIndicators(); ciViewModel = cigen.Generate(ciViewModel); control.LastComplianceRun = DateTime.Now; control.UpdatedBy = BatchUser; control.ReviewCount = ciViewModel.ReviewsRead; control.ProjectCount = ciViewModel.ProjectsRead; control.ProjectCompletion = AppHelper.Percent(ciViewModel.CompletedProjects, ciViewModel.ProjectsRead); control.SampleCount = ciViewModel.SamplesRead; control.TotalComplianceIndicator = AppHelper.Average(ciViewModel.TotalCompliancePoints, ciViewModel.ReviewsRead); var timeElapsed = AppHelper.StopTheWatch(stopwatch); auditMsg = string.Format("CI Generation complete: {0} indicators generated in {1}", ciViewModel.IndicatorsGenerated, timeElapsed); } else { auditMsg = string.Format("CI Generation skipped ({1}) for now: last Run {0}", lastComplianceRun, why); } patService.SaveActivity(CreateAuditRecord(auditMsg, "CIGEN")); }