コード例 #1
0
        public ActionResult Print(int IncidentReportID)
        {
            IncidentReport check   = db.IncidentReport.FirstOrDefault(x => x.IncidentReportID == IncidentReportID);
            var            student = db.Students.FirstOrDefault(x => x.UserID == check.StudentUserID);
            var            name    = student.StudentLastName + ", " + student.StudentFirstName + " ";


            if (check == null)
            {
                TempData["Error"] = "No record found!";
                return(RedirectToAction("Student", "IncidentReports"));
            }
            else if (check.CompletionDate == null)
            {
                TempData["Error"] = "No record found!";
                return(RedirectToAction("Student", "IncidentReports"));
            }


            return(new ActionAsPdf(
                       "Report",
                       new { IncidentReportID = IncidentReportID })
            {
                FileName = string.Format("Incident_Report_{0}.pdf", name + check.CompletionDate)
            });
        }
コード例 #2
0
        public ActionResult Details(StudentInterviewViewModel vm, int IncidentReportID)
        {
            GetCurrentUserInViewBag();

            IncidentReport report = db.IncidentReport.FirstOrDefault(x => x.IncidentReportID == IncidentReportID);

            if (report == null)
            {
                return(HttpNotFound());
            }

            report.CounsellorNotes = vm.CounselorNotes;

            int result = db.SaveChanges();

            if (result > 0)
            {
                TempData["Message"] = "Counselor notes successfully saved!";
            }
            else
            {
                var errors = ModelState.Values.SelectMany(v => v.Errors);
                TempData["Error"] = errors;
            }

            return(RedirectToAction("Index", "Home"));
        }
コード例 #3
0
        public IncidentReportVM AddReport(IncidentReportVM incidentReportVM, string userId)
        {
            var companyId = _context.CompanyUsers.FirstOrDefault(cu => cu.UserId == userId).CompanyId;

            if (_context.Jobs.Any(j => j.Id == incidentReportVM.JobId && j.CompanyId == companyId))
            {
                var report = new IncidentReport
                {
                    CreateDate      = DateTime.Now,
                    Date            = incidentReportVM.Date,
                    JobId           = incidentReportVM.JobId,
                    ReviewedByAdmin = false,
                    Summary         = incidentReportVM.Summary
                };
                _context.IncidentReports.Add(report);
                if (incidentReportVM.Labourers != null && incidentReportVM.Labourers.Count > 0)
                {
                    var labourerIncidentReports = incidentReportVM.Labourers.Select(l => new LabourerIncidentReport
                    {
                        IncidentReport = report,
                        LabourerId     = l.LabourerId
                    });
                    _context.LabourerIncidentReports.AddRange(labourerIncidentReports);
                }
                _context.SaveChanges();
                incidentReportVM.Id = report.Id;

                new EmailHelper(_emailSettings.Value).SendIncidenReportNotificationToAdmin(_context, report.Id);

                return(incidentReportVM);
            }
            return(null);
        }
コード例 #4
0
        public ActionResult Student(string UserID)
        {
            GetCurrentUserInViewBag();

            List <IncidentReport> StudentInventorylist = new List <IncidentReport>();
            var datalist = db.IncidentReport.Where(x => x.StudentUserID == UserID).ToList();
            var student  = db.Students.FirstOrDefault(x => x.UserID == UserID);

            if (datalist.Count() != 0)
            {
                foreach (var item in datalist)
                {
                    IncidentReport pvm = new IncidentReport();
                    pvm.IncidentReportID = item.IncidentReportID;
                    pvm.CompletionDate   = item.CompletionDate;

                    StudentInventorylist.Add(pvm);
                }
                return(View(StudentInventorylist.ToList()));
            }
            else
            {
                TempData["Error"] = "No Incident Reports under student: " + student.StudentLastName + ", " + student.StudentFirstName + "(" + student.StudentID + ")";
                return(RedirectToAction("Index"));
            }
        }
コード例 #5
0
        public void UpdateReport(IncidentReport report)
        {
            List <IncidentReport> list = new List <IncidentReport>();

            using (var ctx = new IncidentCloudContext())
            {
                foreach (IncidentReport ir in ctx.IncidentReports)
                {
                    list.Add(ir);
                }

                int i = 0;
                for (i = 0; i < list.Count; i++)
                {
                    if (DateTime.Compare(list[i].Time, report.Time) == 0)
                    {
                        i = list[i].Id;
                        break;
                    }
                }

                var res = ctx.IncidentReports.Where(r => r.Id == i).FirstOrDefault();
                res.Reason        = report.Reason;
                res.RepairTime    = report.RepairTime;
                res.CrewSent      = report.CrewSent;
                res.Crewtype      = report.Crewtype;
                res.IncidentState = report.IncidentState;
                res.LostPower     = report.LostPower;
                try { res.InvestigationCrew = ctx.Crews.Where(c => c.Id == report.InvestigationCrew.Id).FirstOrDefault(); } catch { }
                try { res.RepairCrew = ctx.Crews.Where(c => c.Id == report.RepairCrew.Id).FirstOrDefault(); } catch { }

                ctx.SaveChanges();
            }
        }
コード例 #6
0
 private void SetUpIncidentReport()
 {
     _incidentReport            = new IncidentReport(DataEntryUnitTestFixture.IdentityId, DataEntryUnitTestFixture.AgencyDetails.Id, Guid.NewGuid(), Guid.NewGuid(), false);
     _incidentReport.Number     = Number;
     _incidentReport.CaseNumber = "9999";
     _reportsUnitOfWork.Setup(mock => mock.Find <Report>(It.IsAny <Guid>(), It.IsAny <TrackingMode>(), It.IsAny <ThrowIf>())).Returns(_incidentReport);
 }
コード例 #7
0
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            ObservableCollection <Crew> res   = new ObservableCollection <Crew>();
            ObservableCollection <Crew> crews = new ObservableCollection <Crew>();
            IncidentReport report             = new IncidentReport();

            try
            {
                crews  = (ObservableCollection <Crew>)values[0];
                report = (IncidentReport)values[1];
            }
            catch { return(null); }

            //if (report.Crew != null)
            //{
            //    res.Add(report.Crew);
            //    return res;
            //}

            foreach (Crew crew in crews)
            {
                if (report.Crewtype == crew.Type)
                {
                    res.Add(crew);
                }
            }

            if (res.Count == 0)
            {
                report.IncidentState = IncidentState.NO_CREWS;
                return(res);
            }

            return(res);
        }
コード例 #8
0
        public async Task <IActionResult> Edit(int id, [Bind("IncidentIndex,LocationIndex,IncidentDateTime,Note")] IncidentReport incidentReport)
        {
            if (id != incidentReport.IncidentIndex)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(incidentReport);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!IncidentReportExists(incidentReport.IncidentIndex))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["LocationIndex"] = new SelectList(_context.LocationSetting, "locationIndex", "locationIndex", incidentReport.LocationIndex);
            return(View(incidentReport));
        }
コード例 #9
0
        public IncidentReport GetReport(DateTime id)
        {
            List <IncidentReport> retVal = new List <IncidentReport>();

            using (var ctxCloud = new IncidentCloudContext())
            {
                foreach (IncidentReport ir in ctxCloud.IncidentReports)
                {
                    retVal.Add(ir);
                }
            }

            IncidentReport res = null;

            foreach (IncidentReport report in retVal)
            {
                if (DateTime.Compare(report.Time, id) == 0)
                {
                    res = report;
                    break;
                }
            }

            using (var ctxCloud = new IncidentCloudContext())
            {
                res = ctxCloud.IncidentReports.Where(ir => ir.Id == res.Id).Include("InvestigationCrew").FirstOrDefault();
            }
            return(res);
        }
コード例 #10
0
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            ObservableCollection <Crew> res   = new ObservableCollection <Crew>();
            ObservableCollection <Crew> crews = new ObservableCollection <Crew>();
            IncidentReport report             = new IncidentReport();
            CrewType       type;

            try
            {
                crews  = (ObservableCollection <Crew>)values[0];
                report = (IncidentReport)values[1];
                type   = (CrewType)values[2];
            }
            catch { return(null); }

            foreach (Crew crew in crews)
            {
                if (type == crew.Type && !crew.Working)
                {
                    res.Add(crew);
                }
            }

            return(res);
        }
コード例 #11
0
        public IActionResult GetById(long id)
        {
            IncidentReport result = null;

            using (connection) {
                connection.Open();
                MySqlCommand cmd = new MySqlCommand("select * from reports where id=" + id, connection);

                using (var reader = cmd.ExecuteReader()) {
                    while (reader.Read())
                    {
                        result = new IncidentReport()
                        {
                            id             = Convert.ToInt32(reader["id"]),
                            title          = reader["title"].ToString(),
                            description    = reader["description"].ToString(),
                            reportedBy     = Convert.ToInt32(reader["reportedBy"]),
                            personAffected = Convert.ToInt32(reader["personAffected"]),
                            location       = Convert.ToInt32(reader["location"])
                        };
                    }
                }
            }

            if (result == null)
            {
                return(NotFound());
            }
            return(new ObjectResult(result));
        }
コード例 #12
0
        public IEnumerable <IncidentReport> GetIncidentsReport(Administrator admin, DateTime dateFrom, DateTime dateTo)
        {
            var company       = unitOfWork.CompanyRepository.Get(x => x.Id == admin.Company.Id, null, "Employees").FirstOrDefault();
            var incidentsList = new List <IncidentReport>();

            if (company != null)
            {
                foreach (Employee e in company.Employees)
                {
                    var employee = unitOfWork.EmployeeRepository.Get(x => x.Id == e.Id, null, "Trajects").FirstOrDefault();
                    if (employee != null)
                    {
                        var trajectsIds = employee.Trajects.Select(x => x.Id).ToList();

                        var incidents = unitOfWork.IncidentRepository.Get(x => trajectsIds.Contains(x.Traject.Id) && x.CreationTime >= dateFrom && x.CreationTime < dateTo.AddDays(1), null, "Location").ToList();

                        foreach (var incident in incidents)
                        {
                            var incidentReport = new IncidentReport()
                            {
                                Address     = incident.Location != null? incident.Location.Address:"",
                                Base64Image = incident.Base64Image,
                                Date        = incident.CreationTime.ToString(),
                                Description = incident.Description,
                                UserName    = e.UserName
                            };

                            incidentsList.Add(incidentReport);
                        }
                    }
                }
            }

            return(incidentsList);
        }
コード例 #13
0
        public ActionResult CreateIncidentReport(FormCollection GetReport, IncidentReport incidentReport, string FileName)
        {
            //= Request['files']
            incidentReport.IncidentDateTime = Convert.ToDateTime(GetReport["IncidentDate"] + " " + GetReport["IncidentTime"]);
            BaseEntitiesAutomation(incidentReport);
            db.IncidentReports.Add(incidentReport);
            db.SaveChanges();

            IncidentReportAttachment incidentReportAttachment = new IncidentReportAttachment();


            //IncidentReportType incidentReportType = new IncidentReportType();
            //string[] IncValues = GetReport.GetValues("Incident");

            //foreach (var item in IncValues)
            //{
            //    int id = Convert.ToInt32(item);
            //    incidentReportType.IncidentTypeID = id;
            //    incidentReportType.IncidentReportID = incidentReport.IncidentReportID;
            //    BaseEntitiesAutomation(incidentReportType);
            //    db.IncidentReportTypes.Add(incidentReportType);
            //    db.SaveChanges();
            //}
            return(RedirectToAction("Index", "Reports"));
        }
コード例 #14
0
        public void UpdateReport(IncidentReport report)
        {
            List <IncidentReport> list = new List <IncidentReport>();

            using (var ctx = new IncidentContext())
            {
                foreach (IncidentReport ir in ctx.IncidentReports)
                {
                    list.Add(ir);
                }

                int i = 0;
                for (i = 0; i < list.Count; i++)
                {
                    if (DateTime.Compare(list[i].Time, report.Time) == 0)
                    {
                        i = list[i].Id;
                        break;
                    }
                }

                var res = ctx.IncidentReports.Where(r => r.Id == i).FirstOrDefault();
                res.Reason        = report.Reason;
                res.RepairTime    = report.RepairTime;
                res.CrewSent      = report.CrewSent;
                res.IncidentState = report.IncidentState;
                res.LostPower     = report.LostPower;
                // res.Crew = ctx.Crews.Where(c => c.Id == report.Crew.Id).FirstOrDefault();

                ctx.SaveChanges();
            }
            //using (var ctxcloud = new IncidentCloudContext())
            //{
            //    foreach (IncidentReport ir in ctxcloud.IncidentReports)
            //    {
            //        list.Add(ir);
            //    }

            //    int i = 0;
            //    for (i = 0; i < list.Count; i++)
            //    {
            //        if (DateTime.Compare(list[i].Time, report.Time) == 0)
            //        {
            //            i = list[i].Id;
            //            break;
            //        }
            //    }

            //    var res = ctxcloud.IncidentReports.Where(r => r.Id == i).FirstOrDefault();
            //    res.Reason = report.Reason;
            //    res.RepairTime = report.RepairTime;
            //    res.CrewSent = report.CrewSent;
            //    res.IncidentState = report.IncidentState;
            //    res.LostPower = report.LostPower;
            //    res.Crew = ctxcloud.Crews.Where(c => c.Id == report.Crew.Id).FirstOrDefault();

            //    ctxcloud.SaveChanges();
            //}
        }
コード例 #15
0
        public async Task MakePredictionRequest(string imageFilePath, string locationStr, int locationIndex)
        {
            try
            {   // get the prediction proability threshold to send email or telegram from the database
                double predicationThreshold = decimal.ToDouble(_context.WebCamPredictSetting.Select(x => x.PredictionThreshold).FirstOrDefault());

                var client = new HttpClient();

                // Request headers - replace this example key with your valid Prediction-Key.
                client.DefaultRequestHeaders.Add("Prediction-Key", "************");

                // Prediction URL - replace this example URL with your valid Prediction URL.
                string url = "***************************";

                HttpResponseMessage response;
                double proValue;
                string strProValue;
                // Request body. Try this sample with a locally stored image.
                byte[] byteData = await GetImageAsByteArray(imageFilePath);

                var content = new ByteArrayContent(byteData);

                content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
                response = await client.PostAsync(url, content);

                string text = await response.Content.ReadAsStringAsync();

                dynamic predication = JsonConvert.DeserializeObject(text);
                foreach (var pred in predication.predictions)
                {
                    string tagname = pred.tagName;
                    if (tagname == "NoMask")
                    {
                        strProValue = pred.probability;
                        double.TryParse(strProValue, out proValue);

                        if (double.IsNaN(proValue) == false && double.IsInfinity(proValue) == false)
                        {
                            if (proValue > predicationThreshold)
                            {
                                IncidentReport incidentReport = new IncidentReport();
                                incidentReport.LocationIndex    = locationIndex;
                                incidentReport.IncidentDateTime = DateTime.Now;
                                _context.Add(incidentReport);
                                await _context.SaveChangesAsync();

                                //await sentEmail(imageFilePath, locationStr, locationIndex);
                                await sentEmailMailKit(imageFilePath, locationStr, locationIndex);
                                await sentTelegram(imageFilePath, locationStr, locationIndex);
                            }
                        }
                    }
                }
            } catch (Exception ex)
            {
                Debug.WriteLine("Made Prediction");
                Debug.WriteLine(ex.InnerException);
            }
        }
コード例 #16
0
        public ActionResult UpdateIncidentReport(FormCollection GetReport, IncidentReport incidentReport)
        {
            IncidentReport inc = db.IncidentReports.Find(incidentReport.IncidentReportID);

            TryUpdateModel(inc);
            db.SaveChanges();
            return(RedirectToAction("Index", "Reports"));
        }
コード例 #17
0
        public ActionResult UpdateIncidentReport(int id)
        {
            IncidentReport incReport = db.IncidentReports.Find(id);

            ViewBag.incidentReport = incReport;

            return(View());
        }
コード例 #18
0
        public void Receive_CheckNullReportNumber()
        {
            var report = new IncidentReport(DataEntryUnitTestFixture.IdentityId, DataEntryUnitTestFixture.AgencyDetails.Id, Guid.NewGuid(), Guid.NewGuid(), false);

            _reportsUnitOfWork.Setup(mock => mock.Find <Report>(It.IsAny <Guid>(), It.IsAny <TrackingMode>(), It.IsAny <ThrowIf>())).Returns(report);
            report.Number = null;
            // _pendingCompleteReportProcessor.MessageHandler(new ReportPendingCompleteMessage(report.Id));
        }
コード例 #19
0
        public void SendCrewToDms(IncidentReport report)
        {
            /*Logic dms*/
            Thread crewprocess = new Thread(() => ProcessCrew(report));

            crewprocess.Start();
            return;
        }
コード例 #20
0
ファイル: Publisher.cs プロジェクト: tomyqg/OMS
 public void PublishIncident(IncidentReport report)
 {
     try
     {
         proxy.PublishIncident(report);
     }
     catch { }
 }
コード例 #21
0
        public ActionResult DeleteConfirmed(int id)
        {
            IncidentReport incidentReport = db.IncidentReports.Find(id);

            db.IncidentReports.Remove(incidentReport);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #22
0
 public void AddReport(IncidentReport report)
 {
     using (var ctxCloud = new IncidentCloudContext())
     {
         ctxCloud.IncidentReports.Add(report);
         ctxCloud.SaveChanges();
     }
 }
コード例 #23
0
        private IncidentReport SetUpIncident()
        {
            var incidentReport = new IncidentReport(DataEntryUnitTestFixture.IdentityId, DataEntryUnitTestFixture.AgencyDetails.Id, Guid.NewGuid(), Guid.NewGuid(), false);

            incidentReport.Number     = Number;
            incidentReport.CaseNumber = "999";
            return(incidentReport);
        }
コード例 #24
0
        public IncidentReport Create(IncidentReport report)
        {
            report.Id = _incidentReportCommandService.CreateReportWithTemplate(
                report.TemplateId,
                report.IsSupplement,
                report);

            return(report);
        }
コード例 #25
0
 public void PublishIncident(IncidentReport report)
 {
     try
     {
         proxyToCloud.InvokeWithRetry(client => client.Channel.PublishIncident(report));
         // proxy.PublishIncident(report);
     }
     catch { }
 }
コード例 #26
0
 public IHttpActionResult GetIncidentReportWorkList()
 {
     try
     {
         List <IncidentReportWorkListAC> incidentReportWorkList = new List <IncidentReportWorkListAC>();
         if (HttpContext.Current.User.Identity.IsAuthenticated)
         {
             //Get Incident Report By Comapany Id.
             IncidentReport incidentReport = _incidentReportRepository.GetIncidentReportByCompanyId(companyId);
             if (incidentReport != null)
             {
                 //Get Cashier Incident Report BY Company Id.
                 List <CashierIncidentReport> listOfCashierIncidentReport = _incidentReportRepository.GetListOfCashierIncidentReportByCompanyId(companyId);
                 if (listOfCashierIncidentReport.Count > 0)
                 {
                     //Group By Cashier.
                     var cashierIncidentList = listOfCashierIncidentReport.GroupBy(x => x.UserId);
                     foreach (var cashierIncidentReport in cashierIncidentList)
                     {
                         var incidentReportDeatil = GetCashierIncidentReport(cashierIncidentReport.Key, false, listOfCashierIncidentReport);
                         if (incidentReportDeatil.Amount >= incidentReport.AmountLimit || incidentReportDeatil.OperationCount >= incidentReport.OperationCounter)
                         {
                             IncidentReportWorkListAC incidentReportWorkListAC = new IncidentReportWorkListAC();
                             incidentReportWorkListAC.Amount          = incidentReportDeatil.Amount;
                             incidentReportWorkListAC.OperationCount  = incidentReportDeatil.OperationCount;
                             incidentReportWorkListAC.ReachedDateTime = incidentReportDeatil.ReachedDateTime;
                             incidentReportWorkListAC.BranchName      = incidentReportDeatil.BranchName;
                             incidentReportWorkListAC.BranchId        = incidentReportDeatil.BranchId;
                             incidentReportWorkListAC.ModifiedDate    = incidentReportDeatil.ModifiedDate;
                             incidentReportWorkListAC.CashierId       = incidentReportDeatil.CashierId;
                             incidentReportWorkListAC.CashierName     = incidentReportDeatil.CashierName;
                             List <CashierIncidentReport> checkCashierIncidentReportListCount = listOfCashierIncidentReport.Where(x => x.UserId == cashierIncidentReport.Key && x.IsRefreshRequset == true).OrderByDescending(x => x.CreatedDateTime).ToList();
                             if (checkCashierIncidentReportListCount.Count > 0)
                             {
                                 incidentReportWorkListAC.HasChildItem = true;
                                 List <SubIncidentReportWorkListAC> listOfSubIncidentReportWorkListAC = GetSubIncidentReportWorkFlowListAC(checkCashierIncidentReportListCount);
                                 incidentReportWorkListAC.ListOfSubIncidentReportWorkListAC = listOfSubIncidentReportWorkListAC;
                             }
                             incidentReportWorkList.Add(incidentReportWorkListAC);
                         }
                     }
                 }
             }
             return(Ok(incidentReportWorkList));
         }
         else
         {
             return(BadRequest());
         }
     }
     catch (Exception ex)
     {
         _errorLog.LogException(ex);
         throw;
     }
 }
コード例 #27
0
ファイル: BizTalkHelper.cs プロジェクト: SanjayIntellve7/Test
 public void ProcessIncidentReport(IncidentReport dto)
 {
     try
     {
     }
     catch (Exception e)
     {
         _logger.LogException(LogLevel.Error, "Failed to transmit Incident Report to BizTalk", e);
     }
 }
コード例 #28
0
 public ActionResult Edit([Bind(Include = "id,incidentDate,programName,location,incidentType,reporterFirstName,reporterLastName,Description")] IncidentReport incidentReport)
 {
     if (ModelState.IsValid)
     {
         db.Entry(incidentReport).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(incidentReport));
 }