コード例 #1
0
        public ActionResult Create([Bind(Include = "Id,CallerName,CallerNumber,Location,Description,EmergencyId,AssistanceRequiredId,CategoryId")] Crisis crisis)
        {
            if (!loginHelper.isAuthorized(Convert.ToInt32(Session["userRole"]), roleRequired))
            {
                return(RedirectToAction("NotAuthorized", "Error"));
            }
            if (ModelState.IsValid)
            {
                crisis.TimeStamp = DateTime.Now;
                CrisisRepository.addCrisis(crisis);
                if (crisis.EmergencyId == 3)
                {
                    crisis.Category           = categoriesRepository.getCategoryById(crisis.CategoryId);
                    crisis.AssistanceRequired = assistanceRequiredRepository.getAssistanceRequiredById(crisis.AssistanceRequiredId);
                    crisis.Emergency          = emergencyRepository.getEmergencyById(crisis.EmergencyId);
                    Console.WriteLine("Level 3 Report detected!");
                    ReportJobs reportJobs = new ReportJobs();
                    //add back ground job to send crisis for approval
                    BackgroundJob.Enqueue(() => reportJobs.sendCrisis(crisis));
                }

                return(RedirectToAction("Index"));
            }

            //new code
            ViewBag.AssistanceRequiredId = new SelectList(assistanceRequiredRepository.getAssistanceRequired(), "Id", "Assistance", crisis.AssistanceRequiredId);
            ViewBag.CategoryId           = new SelectList(categoriesRepository.getCategories(), "Id", "Description", crisis.CategoryId);
            ViewBag.EmergencyId          = new SelectList(emergencyRepository.getEmergencies(), "Id", "Level", crisis.EmergencyId);

            return(View(crisis));
        }
コード例 #2
0
        public void Configuration(IAppBuilder app)
        {
            ReportJobs reportJobs = new ReportJobs();

            ConfigureAuth(app);
            GlobalConfiguration.Configuration.UseSqlServerStorage("CMS2Context");

            //for debugging with a UI on jobs
            //app.UseHangfireDashboard();

            //add recurring report generation every 30 minutes
            RecurringJob.AddOrUpdate(() => reportJobs.sendReport(reportJobs.generateReport()), Cron.MinuteInterval(30)); //set timer here
            app.UseHangfireServer();
        }
コード例 #3
0
 public ActionResult Edit([Bind(Include = "Id,ReportDetails,Approved")] SummaryReport summaryReport)
 {
     if (!loginHelper.isAuthorized(Convert.ToInt32(Session["userRole"]), roleRequired))
     {
         return(RedirectToAction("NotAuthorized", "Error"));
     }
     summaryReport.TimeStamp = DateTime.Now;
     if (ModelState.IsValid)
     {
         if (summaryReport.Approved == true)
         {
             ReportJobs reportJobs = new ReportJobs();
             BackgroundJob.Enqueue(() => reportJobs.sendReport(summaryReport));
         }
         db.Entry(summaryReport).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(summaryReport));
 }
コード例 #4
0
        public ActionResult Create([Bind(Include = "Id,CallerName,CallerNumber,Location,Description,EmergencyId,AssistanceRequiredId,CategoryId")] Crisis crisis)
        {
            if (ModelState.IsValid)
            {
                crisis.TimeStamp = DateTime.Now;
                CrisisRepository.addCrisis(crisis);
                if (crisis.EmergencyId == 3)
                {
                    Console.WriteLine("Level 3 Report detected!");
                    ReportJobs reportJobs = new ReportJobs();
                    BackgroundJob.Enqueue(() => reportJobs.sendCrisis(crisis));
                }

                return(RedirectToAction("Index"));
            }

            //new code
            ViewBag.AssistanceRequiredId = new SelectList(CrisisRepository.GetAssistanceRequired(), "Id", "Assistance", crisis.AssistanceRequiredId);
            ViewBag.CategoryId           = new SelectList(CrisisRepository.GetCategories(), "Id", "Description", crisis.CategoryId);
            ViewBag.EmergencyId          = new SelectList(CrisisRepository.GetEmergencies(), "Id", "Level", crisis.EmergencyId);

            return(View(crisis));
        }