public static void SyncSemiStaticData() { DatabaseInit._LogHandler.WriteLog("SyncSemiStaticData()", LogSeverity.Information, LogCategory.DataAccess); using (var httpHandler = new HttpClientHandler()) { httpHandler.UseDefaultCredentials = true; using (var httpClient = new HttpClient(httpHandler)) { httpClient.BaseAddress = new Uri(Properties.Settings.Default.ServicesHostUrl); httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/xml")); using (var consoleRepository = new ConsoleRepository()) { DatabaseInit.SyncBrokers(httpClient, consoleRepository); DatabaseInit.SyncNonLondonBrokers(httpClient, consoleRepository); DatabaseInit.SyncCOBs(httpClient, consoleRepository); DatabaseInit.SyncOffices(httpClient, consoleRepository); DatabaseInit.SyncUnderwriters(httpClient, consoleRepository); DatabaseInit.SyncRiskCodes(httpClient, consoleRepository); DatabaseInit.UpdateSipAddresses(consoleRepository); DatabaseInit.UpdateEmailAddresses(consoleRepository); DatabaseInit.UpdateUserPictures(consoleRepository); consoleRepository.SaveChanges(); } } } }
public IActionResult ConsoleStart(string consoleText) { var consx = ConsoleRepository.AddConsole(new VirtualConsole(DateTime.Now.Ticks.ToString(), 80, 40)); consx.WriteLine($"Starting command '{consoleText}'... "); GetBuilder().RunAsync(consx, cons => { SampleDocuments.MarkDownBasics(cons); SlowPlayback.LiveElements(cons); SampleDocuments.ColourPalette(cons); if (consoleText == "err") { throw new Exception("Sample Error"); } var a = new ProgressBar(cons, "Test Scrolling").Start(100); for (int i = 0; i < a.ItemsTotal; i++) { a.Increment(i.ToString()); Thread.Sleep(200); } a.Stop(); cons.SetProp("DoneUrl", "/Home/Privacy"); }); return(Console(consx)); }
public virtual IActionResult UpdateConsole(string id) { if (ConsoleRepository.TryGetConsole(id, out var cons)) { return(Json(GetBuilder().ToDto(cons))); } else { return(NotFound($"Id not found: {id}")); } }
public void Audit(string source, string reference, string title, string description) { //todo: need to work on dispose using (IConsoleRepository consoleRepository = new ConsoleRepository()) { consoleRepository.Add(new AuditTrail { Source = source, Reference = reference, Title = title, Description = description }); consoleRepository.SaveChanges(); } }
public virtual IActionResult Console(string id, string src) { if (ConsoleRepository.TryGetConsole(id, out var cons)) { return(View(ConsoleHostView, new ConsoleDataModel(cons, GetBuilder().ToDto(cons)))); } else { return(View(ConsoleHostView, new ConsoleDataModel( null, new ConsoleData() { Title = $"Not Found: {id}", BackUrl = src, IsActive = false, Version = 1, HtmlContent = $"Console Not Found: {id}" }))); } }
public string CreateQuoteSheet(CreateQuoteSheetDto dto, out Submission submission) { // TODO: use the correct quote sheet... var quoteSheetTemplateId = dto.QuoteSheetTemplateId; dto.QuoteSheetTemplateUrl = this.ConsoleRepository.Query <QuoteTemplate>() .FirstOrDefault(qt => qt.Id == dto.QuoteSheetTemplateId).RdlPath; dto.QuoteSheetTemplateName = this.ConsoleRepository.Query <QuoteTemplate>() .FirstOrDefault(qt => qt.Id == dto.QuoteSheetTemplateId).Name; submission = this.SubmissionModule.GetSubmissionById(dto.SubmissionId); //todo this is done to clear previous context. has to be fixed once softdelet is fixed. using (IConsoleRepository consoleRepository = new ConsoleRepository()) { if (submission == null) { throw new KeyNotFoundException(string.Format(this.NotFoundMessage, dto.SubmissionId)); } consoleRepository.Attach(submission); var currentUser = consoleRepository.Query <User>() .FirstOrDefault(u => u.DomainLogon == this.HttpContext.CurrentUser.Identity.Name); if (currentUser == null) { throw new ApplicationException("Current user could not be found"); } var versions = (from version in submission.Options.SelectMany(o => o.OptionVersions) from option in dto.OptionList where version.OptionId == option.OptionId from versionNumber in option.OptionVersionNumberList where version.VersionNumber == versionNumber select version).ToList(); var isDeclinature = false; var submSt = submission.Options.Select(s => s) .SelectMany(o => o.OptionVersions) .SelectMany(ov => ov.Quotes) .Where(q => q.IsSubscribeMaster).Select(s => s.SubmissionStatus).Distinct().ToList(); if ((submSt.Count == 1) && (submSt.FirstOrDefault().Equals(Settings.Default["DeclinatureSubmissionStatus"].ToString()))) { isDeclinature = true; } var quotesheet = new QuoteSheet {//Todo: S2Q Title = string.Format(this.QuoteSheetTitle, submission.Title, versions.SelectMany(ov => ov.Quotes).First().InsuredName, DateTime.Now), IssuedBy = currentUser, IssuedById = currentUser.Id, IssuedDate = DateTime.Now, ObjectStore = Settings.Default["DMSObjectStore"].ToString(), DocumentClass = Settings.Default["DMSDocumentClass"].ToString(), DocumentType = isDeclinature ? Settings.Default["DeclinatureDocType"].ToString() : Settings.Default["QuoteDocType"].ToString() }; var content = this.QuoteSheetData.CreateQuoteSheetPdf(dto, isDeclinature); quotesheet.Guid = this.QuoteSheetData.SaveQuoteSheetToDMS(quotesheet, content, submission, isDeclinature); quotesheet.OptionVersions = versions; if (!isDeclinature) { foreach (var quote in versions.SelectMany(ov => ov.Quotes)) { if (!quote.SubmissionStatus.Equals(Settings.Default["DeclinatureSubmissionStatus"].ToString())) { quote.OptionVersion.IsLocked = true; quote.SubmissionStatus = "QUOTED"; } } } consoleRepository.Add(quotesheet); consoleRepository.SaveChanges(); return(string.Format(this.QuoteSheetUrl, ConfigurationManager.AppSettings["UWDmsFileDownloadURL"], quotesheet.Guid)); } }