public void Post([FromBody] List <Models.ReportIncident> incidents)
        {
            var incidentTypes = this._db.IncidentTypes.Where(t => t.incidentReportTypeId == 1).ToList();


            foreach (Models.ReportIncident incident in incidents)
            {
                this._db.ReportIncidents.Add(incident);
                this._db.SaveChanges();

                var incidentType = incidentTypes.Where(t => t.incidentTypeId == incident.incidentTypeId).SingleOrDefault();

                if (incidentType != null)
                {
                    if (incidentType.incidentCategoryId == 1 || incidentType.incidentCategoryId == 2) // REPORTABLE TO JC
                    {
                        ReportsController reportsController         = new ReportsController();
                        Models.Presentation.ReportsViewModel report = reportsController.GetReportHeader(incident.incidentId);
                        reportsController.Dispose();


                        Controllers.MailController mailer = new MailController();

                        List <string> sendTos = new List <string>();
                        StringBuilder msg     = new StringBuilder();

                        sendTos.Add("*****@*****.**");

                        Models.Notification notification = new Models.Notification();

                        notification.incidentId        = incident.incidentId;
                        notification.notifyPartyId     = 37;
                        notification.notifyDateTime    = DateTime.Now;
                        notification.notifyContact     = "CFS Compliance";
                        notification.notifyMethod      = "E-Mail";
                        notification.notifyStaffId     = 0;
                        notification.notifyComments    = "Automatic E-Mail sent to compliance by incident report system.";
                        notification.isAcknowledged    = 1;
                        notification.acknowledgeUserId = 0;

                        this._db.Notifications.Add(notification);
                        this._db.SaveChanges();

                        msg.Append("<h1>Incident Report: Compliance Notification</h1>");
                        msg.Append("<p>A new incident report for client " + report.clientName + " by " + report.staffName + " has been created and is being forwarded to compliance.</p>");
                        msg.Append("<p><a href=\"http://cfs-incidents/Admin/Review/" + report.incidentId.ToString() + "\">Click here to view the report.</a></p>");


                        //sendTos.Add(notifier.emailAddress);
                        //sendTos.Add("*****@*****.**"); //MTS - commented out March '18
                        mailer.SendMail(sendTos, "*****@*****.**", "Incident Report Compliance Notification: " + report.clientName, System.Net.Mail.MailPriority.High, msg);
                    }
                }
            }
        }
        // POST api/<controller>
        public void Post([FromBody] Models.Notification notification)
        {
            if (notification.notificationId == 0)
            {
                this._db.Notifications.Add(notification);
            }
            else
            {
                this._db.Notifications.Attach(notification);
                this._db.Entry(notification).State = System.Data.Entity.EntityState.Modified;
            }

            this._db.SaveChanges();


            if (notification.notifyPartyId == 8)  // JUSTICE CENTER
            {
                ReportsController reportsController         = new ReportsController();
                Models.Presentation.ReportsViewModel report = reportsController.GetReportHeader(notification.incidentId);
                reportsController.Dispose();


                Controllers.MailController mailer = new MailController();

                List <string> sendTos = new List <string>();
                StringBuilder msg     = new StringBuilder();

                sendTos.Add("*****@*****.**");

                Models.Notification complianceNotification = new Models.Notification();

                complianceNotification.incidentId        = notification.incidentId;
                complianceNotification.notifyPartyId     = 37;
                complianceNotification.notifyDateTime    = DateTime.Now;
                complianceNotification.notifyContact     = "CFS Compliance";
                complianceNotification.notifyMethod      = "E-Mail";
                complianceNotification.notifyStaffId     = 0;
                complianceNotification.notifyComments    = "Automatic E-Mail sent to compliance by incident report system.";
                complianceNotification.isAcknowledged    = 1;
                complianceNotification.acknowledgeUserId = 0;

                this._db.Notifications.Add(complianceNotification);
                this._db.SaveChanges();

                msg.Append("<h1>Incident Report: Compliance Notification</h1>");
                msg.Append("<p>A new incident report for client " + report.clientName + " by " + report.staffName + " has been created and is being forwarded to compliance.</p>");
                msg.Append("<p><a href=\"http://cfs-incidents/admin/review/" + report.incidentId.ToString() + "\">Click here to view the report.</a></p>");


                //sendTos.Add(notifier.emailAddress);
                //sendTos.Add("*****@*****.**"); //MTS - commented out March '18
                mailer.SendMail(sendTos, "*****@*****.**", "Incident Report Compliance Notification: Justice Center Called", System.Net.Mail.MailPriority.High, msg);
            }
        }
Пример #3
0
        public FileStreamResult OpenIncidents()
        {
            Reports.OpenReports report = new Reports.OpenReports();
            report.Load();

            API.ReportsController reportsController = new API.ReportsController();

            report.SetDataSource(reportsController.GetUserReports(80).ToList());

            reportsController.Dispose();

            Stream reportStream = report.ExportToStream(ExportFormatType.PortableDocFormat);

            report.Close();
            report.Dispose();

            return(new FileStreamResult(reportStream, "application/pdf"));
        }
Пример #4
0
        private Content.Reports.ResidentialReport ResidentialReport(long id)
        {
            API.ReportsController       reportsController       = new API.ReportsController();
            API.ProgramsController      programsController      = new API.ProgramsController();
            API.TypesController         typesController         = new API.TypesController();
            API.RestraintsController    restraintsController    = new API.RestraintsController();
            API.DetailsController       detailsController       = new API.DetailsController();
            API.MedicalsController      medicalsController      = new API.MedicalsController();
            API.SignaturesController    signaturesController    = new API.SignaturesController();
            API.UsersController         usersContoller          = new API.UsersController();
            API.StaffController         staffController         = new API.StaffController();
            API.NotificationsController notificationsController = new API.NotificationsController();
            API.NotifyPartiesController notifyPartiesController = new API.NotifyPartiesController();
            API.CommentsController      commentsController      = new API.CommentsController();
            API.AttachmentsController   attachmentsController   = new API.AttachmentsController();

            var reportHeader     = Models.Converters.ListToDataSet.ToDataTable <Models.IncidentReport>(reportsController.Print_GetIncidentReport(id).ToList());
            var programs         = Models.Converters.ListToDataSet.ToDataTable <Models.IncidentProgram>(programsController.Get().ToList());
            var incidentTypes    = Models.Converters.ListToDataSet.ToDataTable <Models.IncidentType>(typesController.Get().ToList());
            var reportIncidents  = Models.Converters.ListToDataSet.ToDataTable <Models.ReportIncident>(typesController.Print_GetReportIncidents(id).ToList());
            var restraints       = Models.Converters.ListToDataSet.ToDataTable <Models.Restraint>(restraintsController.Get(id).ToList());
            var incidentDetails  = Models.Converters.ListToDataSet.ToDataTable <Models.IncidentDetail>(detailsController.Print(id).ToList());
            var medicals         = Models.Converters.ListToDataSet.ToDataTable <Models.Medical>(medicalsController.Print_GetMedicals(id).ToList());
            var reportSignatures = Models.Converters.ListToDataSet.ToDataTable <Models.Presentation.ReportSignsViewModel>(signaturesController.Print(id).ToList());
            var reportSigTypes   = Models.Converters.ListToDataSet.ToDataTable <Models.ReportSigType>(signaturesController.GetTypes().ToList());
            var users            = Models.Converters.ListToDataSet.ToDataTable <Models.User>(usersContoller.Get().ToList());
            var incidentStaff    = Models.Converters.ListToDataSet.ToDataTable <Models.IncidentStaff>(staffController.Get(id).ToList());
            var notifications    = Models.Converters.ListToDataSet.ToDataTable <Models.Notification>(notificationsController.Print(id).ToList());
            var notifyParties    = Models.Converters.ListToDataSet.ToDataTable <Models.NotifyParty>(notifyPartiesController.Print().ToList());
            var adminComments    = Models.Converters.ListToDataSet.ToDataTable <Models.AdminComment>(commentsController.Print(id).ToList());
            var attachments      = Models.Converters.ListToDataSet.ToDataTable <Models.IncidentAttachment>(attachmentsController.Print(id).ToList());



            reportsController.Dispose();
            programsController.Dispose();
            typesController.Dispose();
            restraintsController.Dispose();
            detailsController.Dispose();
            medicalsController.Dispose();
            signaturesController.Dispose();
            usersContoller.Dispose();
            staffController.Dispose();
            notificationsController.Dispose();
            notifyPartiesController.Dispose();
            commentsController.Dispose();
            attachmentsController.Dispose();


            Reports.ResidentialReport report = new Reports.ResidentialReport();
            report.Load();


            report.Database.Tables["IncidentReport"].SetDataSource(reportHeader);
            report.Database.Tables["IncidentPrograms"].SetDataSource(programs);

            var reportableIncidentsSubreport  = report.Subreports["ReportableIncidentsSubreport"];
            var significantIncidentsSubreport = report.Subreports["SignificantIncidentsSubreport"];
            var internalEventsSubreport       = report.Subreports["InternalEventsSubreport"];
            var restraintsSubreport           = report.Subreports["RestraintsSubreport"];
            var incidentDetailsSubreport      = report.Subreports["IncidentDetailsSubreport"];
            var notificationsSubreport        = report.Subreports["NotificationsSubreport"];
            var medicalsSubreport             = report.Subreports["MedicalsSubreport"];
            var staffSubreport         = report.Subreports["StaffSubreport"];
            var adminCommentsSubreport = report.Subreports["AdminCommentsSubreport"];
            var signaturesSubreport    = report.Subreports["SignaturesSubreport"];
            var attachmentsSubreport   = report.Subreports["AttachmentsSubreport"];

            reportableIncidentsSubreport.Database.Tables["IncidentTypes"].SetDataSource(incidentTypes);
            reportableIncidentsSubreport.Database.Tables["ReportIncidents"].SetDataSource(reportIncidents);

            significantIncidentsSubreport.Database.Tables["IncidentTypes"].SetDataSource(incidentTypes);
            significantIncidentsSubreport.Database.Tables["ReportIncidents"].SetDataSource(reportIncidents);

            internalEventsSubreport.Database.Tables["IncidentTypes"].SetDataSource(incidentTypes);
            internalEventsSubreport.Database.Tables["ReportIncidents"].SetDataSource(reportIncidents);

            restraintsSubreport.Database.Tables["Restraints"].SetDataSource(restraints);

            incidentDetailsSubreport.Database.Tables["IncidentDetails"].SetDataSource(incidentDetails);

            notificationsSubreport.Database.Tables["Notifications"].SetDataSource(notifications);
            notificationsSubreport.Database.Tables["NotifyParties"].SetDataSource(notifyParties);
            notificationsSubreport.Database.Tables["Users"].SetDataSource(users);

            medicalsSubreport.Database.Tables["Medicals"].SetDataSource(medicals);
            medicalsSubreport.Database.Tables["Users"].SetDataSource(users);
            medicalsSubreport.Database.Tables["ReportSigns"].SetDataSource(reportSignatures);

            staffSubreport.Database.Tables["IncidentStaff"].SetDataSource(incidentStaff);

            adminCommentsSubreport.Database.Tables["AdminComments"].SetDataSource(adminComments);
            adminCommentsSubreport.Database.Tables["Users"].SetDataSource(users);

            signaturesSubreport.Database.Tables["ReportSigns"].SetDataSource(reportSignatures);
            signaturesSubreport.Database.Tables["ReportSigTypes"].SetDataSource(reportSigTypes);

            attachmentsSubreport.Database.Tables["IncidentAttachments"].SetDataSource(attachments);

            report.SetParameterValue("incidentId", id);

            return(report);
        }
        public void PostAutoNotifiers([FromBody] Models.Presentation.ProgramNotifiersModel[] notifiers)
        {
            Controllers.MailController mailer = new MailController();

            long incidentId = 0;

            incidentId = notifiers.FirstOrDefault().incidentId;



            ReportsController reportsController = new ReportsController();

            Models.Presentation.ReportsViewModel report = reportsController.GetReportHeader(incidentId);
            reportsController.Dispose();


            List <string> sendTos = new List <string>();
            StringBuilder msg     = new StringBuilder();

            //sendTos.Add(notifier.emailAddress);
            sendTos.Add("*****@*****.**");

            msg.Append("<h1>New Incident Report</h1>");
            msg.Append("<p>A new incident report has been created for client " + report.clientName + " by " + report.staffName + ".</p>");
            msg.Append("<p><a href=\"http://cfs-incidents/report/residential/" + report.incidentId.ToString() + "\">Click here to view the report.</a></p>");
            msg.Append("<p><a href=\"http://cfs-incidents/Medicals\">Click here to create a medical review.</a></p>");

            // COMMENT OUT BEFORE LIVE
            //msg.Append("<p>To be included:<br />");


            foreach (var notifier in notifiers)
            {
                //msg.Append(notifier.emailAddress + "<br />");

                sendTos.Add(notifier.emailAddress.ToLower().Trim());

                Models.Notification notification = new Models.Notification();

                notification.incidentId        = incidentId;
                notification.notifyPartyId     = notifier.notifyPartyId;
                notification.notifyDateTime    = DateTime.Now;
                notification.notifyContact     = notifier.staffName;
                notification.notifyMethod      = "E-Mail";
                notification.notifyStaffId     = notifier.userId == null ? 0 : (long)notifier.userId;
                notification.notifyComments    = "Automatic E-Mail sent to " + notifier.emailAddress.ToLower().Trim() + " by incident report system.";
                notification.isAcknowledged    = 1;
                notification.acknowledgeUserId = notifier.userId == null ? 0 : (long)notifier.userId;

                this._db.Notifications.Add(notification);
            }


            this._db.SaveChanges();


            // COMMENT OUT BEFORE LIVE
            //msg.Append("</p>");


            // ADD REPORT DETAILS AND LINK TO REPORT


            // ACKNOWLEDGEMENT LINK
            msg.Append("<p><a href='/'></a></p>");


            mailer.SendMail(sendTos, "*****@*****.**", "New Incident Report: " + report.clientName, System.Net.Mail.MailPriority.High, msg);



            mailer.Dispose();
        }