Ejemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Title")] RiskReport riskReport)
        {
            if (id != riskReport.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(riskReport);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!RiskReportExists(riskReport.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            return(View(riskReport));
        }
Ejemplo n.º 2
0
        public RiskReport ProcessChangeSet(ChangeSetInfo changeSet)
        {
            _changeSet = changeSet;
            _isRunning = true;
            _mainThread = new Thread(new ThreadStart(ScoreChangeSet));
            _mainThread.Start();
            MD5
            Stopwatch timer = new Stopwatch();
            timer.Start();
            bool timeout = false;
            while (_isRunning)
            {
                Thread.Sleep(100);
                if (timer.Elapsed.Seconds > this.ExecutionTimeOut)
                {
                    _isRunning = false;
                    timeout = true;
                    _mainThread.Join(2000);
                }
            }
            timer.Stop();
            MD5
            if (_report == null)
                _report = new RiskReport();

            _report.Timeout = timeout;
            _report.AggregationThreshold = _settings.AggregationThreshold;
            _report.Date = changeSet.Date;
            MD5
            return _report;
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Create([Bind("Id,Title")] RiskReport riskReport)
        {
            if (ModelState.IsValid)
            {
                _context.Add(riskReport);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(riskReport));
        }
Ejemplo n.º 4
0
        public static async Task InitializeDatabaseAsync(IServiceProvider serviceProvider)
        {
            using (var serviceScope = serviceProvider.GetRequiredService <IServiceScopeFactory>().CreateScope())
            {
                // grab our db context from the IOC container
                var db = serviceScope.ServiceProvider.GetService <ApplicationDbContext>();

                // create db if needed
                await db.Database.EnsureCreatedAsync();

                if (!db.Blog.Any())
                {
                    db.Blog.AddRange(_blogs);
                    db.SaveChangesAsync().Wait();
                }

                if (!db.RiskClass.Any())
                {
                    db.RiskClass.AddRange(_riskClasses);
                    db.SaveChangesAsync().Wait();
                }

                if (!db.RiskCategory.Any())
                {
                    db.RiskCategory.AddRange(_riskCategories);
                    db.SaveChangesAsync().Wait();
                }

                if (!db.RiskItem.Any())
                {
                    db.RiskItem.AddRange(_riskItems);
                    db.SaveChangesAsync().Wait();
                }

                if (!db.RiskReport.Any())
                {
                    RiskReport report = new RiskReport()
                    {
                        Title = "DZ Bank New York: Standard Risk Rating",
                    };
                    RiskReport report2 = new RiskReport()
                    {
                        Title = "DZ Bank New York: FI Risk Rating",
                    };

                    db.RiskReport.Add(report);
                    db.RiskReport.Add(report2);

                    var items = db.RiskItem.ToList();

                    foreach (var i in items)
                    {
                        if (i.Id < 7)
                        {
                            report.AddRiskItem(i);  // RRRIs.Add(new RRRI { RiskReportId = report.Id, RiskItemId = i.Id });
                        }
                        if (i.Id > 6)
                        {
                            report2.AddRiskItem(i); //.RRRIs.Add(new RRRI { RiskReportId = report2.Id, RiskItemId = i.Id });
                        }
                    }
                    db.SaveChangesAsync().Wait();
                }
            }
            await Task.FromResult(0);
        }