Beispiel #1
0
        public void SendEmailWithPdf(string lang)
        {
            var fileName = $"Audit_ID{this.Id}_{DateTime.Now.ToString("yyyyMMdd")}.pdf";
            var subject  = $"Printout {this.TypeName} | {this.Target}";
            var body     = "";
            var email    = AppUser.GetUserMail(this.AuditorLogin);

            if (email == null)
            {
                throw new Exception("You can not send an e-mail with the report - no e-mail in the system / wrong format!");
            }
            var report = AuditTypes.GetXtraReport(this, lang);

            using (MemoryStream stream = new MemoryStream())
            {
                report.ExportToPdf(stream);
                stream.Position = 0;
                var attach = new Attachment(stream, fileName, "application/pdf");
                MailUtils.SendEmail(subject, body, new List <string> {
                    email
                }, new List <Attachment> {
                    attach
                });
            }
            throw new Exception("An email with a PDF printout has been sent! Check your inbox!");
        }
Beispiel #2
0
        protected void SetupGridview(Audit activeAudit)
        {
            sdsAudit.SelectParameters["audit_id"].DefaultValue = Utils.ConvertToTrimmedString(activeAudit.Id);
            string activeLang    = (Session["lang"] == null) ? Languages.Default : Utils.ConvertToTrimmedString(Session["lang"]);
            int    activePage    = (Session["page"] == null) ? 0 : int.Parse(Session["page"].ToString());
            var    groups        = activeAudit.AuditQuestionGroups;
            string groupPosition = groups.Rows[activePage]["group_position"].ToString();

            gvAudit.AutoFilterByColumn(gvAudit.Columns["group_position"], groupPosition);
            string groupName = "";

            switch (activeLang)
            {
            case Languages.English:
                gvAudit.Columns["question"].Visible     = false;
                gvAudit.Columns["question_ENG"].Visible = true;
                groupName = groups.Rows[activePage]["group_name_ENG"].ToString();
                break;

            case Languages.Polish:
                gvAudit.Columns["question"].Visible     = true;
                gvAudit.Columns["question_ENG"].Visible = false;
                groupName = groups.Rows[activePage]["group_name"].ToString();
                break;
            }
            gvAudit.Caption            = AuditTypes.GetAuditGridCaption(groupPosition, groupName);
            gvAudit.SettingsText.Title = AuditTypes.GetAuditGridTitle(activeAudit);
        }
Beispiel #3
0
        protected void btnStartAudit_Click(object sender, EventArgs e)
        {
            var activeUser = new ActiveUser();
            var auditType  = cbAuditType.SelectedItem != null?Utils.ConvertToTrimmedString(cbAuditType.SelectedItem.Value) : null;

            var auditTarget = cbAuditTarget.SelectedItem != null?Utils.ConvertToTrimmedString(cbAuditTarget.SelectedItem.Value) : null;

            var auditShiftName = cbAuditShiftName.SelectedItem != null?Utils.ConvertToTrimmedString(cbAuditShiftName.SelectedItem.Value) : null;

            var auditorLogin    = activeUser.UserName;
            var auditorFullName = activeUser.FullName;

            if (auditTarget != null && auditType != null)
            {
                if (!(AuditTypes.ShiftNameObligatory(auditType) && auditShiftName == null))
                {
                    auditShiftName = AuditTypes.ShiftNameObligatory(auditType) ? auditShiftName : null;
                    if (auditorLogin != null && auditorFullName != null)
                    {
                        if (AuditTypes.UserInAuditorList(auditorLogin, auditType, auditTarget))
                        {
                            var newAudit = Audit.CreateNew(auditType, auditTarget, auditorLogin, auditorFullName, auditShiftName);
                            if (newAudit != null)
                            {
                                Session["lang"]            = null;
                                Session["page"]            = null;
                                Session["audit_id"]        = null;
                                Session["audit_detail_id"] = null;
                                Response.Redirect(Pages.PerformAudit);
                            }
                            else
                            {
                                Session["message"] = "Error when generating the audit template!!";
                            }
                        }
                        else
                        {
                            Session["message"] = "You are not assigned as an auditor for this type / target of audit!";
                        }
                    }
                    else
                    {
                        Session["message"] = "You are logged out!";
                    }
                }
                else
                {
                    Session["message"] = "Choose shift!";
                }
            }
            else
            {
                Session["message"] = "Choose type and target of audit!";
            }
            Response.Redirect(Request.RawUrl);
        }
Beispiel #4
0
        protected void gvAuditTargets_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
        {
            var    newAuditType       = Utils.ConvertToTrimmedString(e.NewValues["audit_type"]);
            var    newAuditTarget     = Utils.ConvertToTrimmedString(e.NewValues["audit_target"]);
            var    newArea            = Utils.ConvertToTrimmedString(e.NewValues["area"]);
            var    newSubarea         = Utils.ConvertToTrimmedString(e.NewValues["subarea"]);
            var    newSection         = Utils.ConvertToTrimmedString(e.NewValues["section"]);
            var    newSupervisorLogin = Utils.ConvertToTrimmedString(e.NewValues["supervisor_login"]);
            string newSupervisor      = null;

            if (newAuditType == null ||
                newAuditTarget == null)
            {
                e.Cancel = true;
                throw new Exception("Complete TYPE and TARGET fields!");
            }

            string message = SettsUtils.AuditTargetInsertVerify(newAuditType, newAuditTarget);

            if (message != null)
            {
                e.Cancel = true;
                throw new Exception(message);
            }

            message = AuditTypes.VerifyAuditTargetEntry(newAuditType, newArea, newSubarea, newSection, newSupervisorLogin);
            if (message != null)
            {
                e.Cancel = true;
                throw new Exception(message);
            }

            if (newSupervisorLogin != null)
            {
                var user = new AppUser(newSupervisorLogin);
                if (user.Exist)
                {
                    newSupervisor = user.FullName;
                }
                else
                {
                    e.Cancel = true;
                    throw new Exception("User does not exist (SUPERVISOR)!");
                }
            }

            e.NewValues["audit_type"]       = newAuditType;
            e.NewValues["audit_target"]     = newAuditTarget;
            e.NewValues["area"]             = newAuditType;
            e.NewValues["subarea"]          = newSubarea;
            e.NewValues["section"]          = newSection;
            e.NewValues["supervisor_login"] = newSupervisorLogin;
            e.NewValues["supervisor"]       = newSupervisor;
        }
Beispiel #5
0
        public void End()
        {
            string query      = @"UPDATE [audits]
                                SET [score] = @score,
                                    [end_date] = GETDATE()
                                WHERE [id] = @audit_id;";
            var    parameters = new Dictionary <string, object>()
            {
                { "audit_id", this.Id },
                { "score", this.AuditScoreCalculated }
            };

            DatabaseUtils.ExecuteNonQuery(query, parameters);
            AuditTypes.GenerateAuditActions(this);
            AuditTypes.NotifySupervisor(this);
            PhotoFiles.EndAuditRemove(this);
        }
Beispiel #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var id = Utils.ConvertToNullableInt(Request.QueryString["id"]);

            lblInfo.Text = string.Empty;
            if (id != null)
            {
                if (Audit.AuditExist((int)id))
                {
                    var report         = AuditTypes.GetXtraReport(new Audit((int)id), Languages.Polish);
                    var reportFileName = $"Audit_{id}";
                    Utils.PrintPDF(report, reportFileName);
                }
                else
                {
                    lblInfo.Text = $"Printing of the document failed!{Environment.NewLine}Audit does not exist!";
                }
            }
            else
            {
                lblInfo.Text = $"Printing of the document failed!{Environment.NewLine}Wrong parameter!";
            }
        }
Beispiel #7
0
        protected void cbPanelAudit_Callback(object sender, CallbackEventArgsBase e)
        {
            var auditType = Utils.ConvertToTrimmedString(e.Parameter);

            AuditTypes.AdjustTemplateToAuditType(auditType, cbAuditTarget, cbAuditShiftName);
        }