Esempio n. 1
0
        private void FillGrid()
        {
            long userNum = 0;

            if (comboUser.SelectedIndex > 0)
            {
                userNum = UserodC.Listt[comboUser.SelectedIndex - 1].UserNum;
            }
            SecurityLog[] logList = null;
            if (comboPermission.SelectedIndex == 0)
            {
                logList = SecurityLogs.Refresh(PIn.Date(textDateFrom.Text), PIn.Date(textDateTo.Text),
                                               Permissions.None, PatNum, userNum);
            }
            else
            {
                logList = SecurityLogs.Refresh(PIn.Date(textDateFrom.Text), PIn.Date(textDateTo.Text),
                                               (Permissions)Enum.Parse(typeof(Permissions), comboPermission.SelectedItem.ToString()), PatNum, userNum);
            }
            grid.BeginUpdate();
            grid.Columns.Clear();
            ODGridColumn col = new ODGridColumn(Lan.g("TableAudit", "Date"), 70);

            col.SortingStrategy = GridSortingStrategy.DateParse;
            grid.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableAudit", "Time"), 60);
            col.SortingStrategy = GridSortingStrategy.DateParse;
            grid.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableAudit", "Patient"), 100);
            grid.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableAudit", "User"), 70);
            grid.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableAudit", "Permission"), 110);
            grid.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableAudit", "Computer"), 70);
            grid.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableAudit", "Log Text"), 560);
            grid.Columns.Add(col);
            grid.Rows.Clear();
            ODGridRow row;
            Userod    user;

            for (int i = 0; i < logList.Length; i++)
            {
                row = new ODGridRow();
                row.Cells.Add(logList[i].LogDateTime.ToShortDateString());
                row.Cells.Add(logList[i].LogDateTime.ToShortTimeString());
                row.Cells.Add(logList[i].PatientName);
                user = Userods.GetUser(logList[i].UserNum);
                //user might be null due to old bugs.
                if (user == null)
                {
                    row.Cells.Add("unknown");
                }
                else
                {
                    row.Cells.Add(Userods.GetUser(logList[i].UserNum).UserName);
                }
                if (logList[i].PermType == Permissions.ChartModule)
                {
                    row.Cells.Add("ChartModuleViewed");
                }
                else if (logList[i].PermType == Permissions.FamilyModule)
                {
                    row.Cells.Add("FamilyModuleViewed");
                }
                else if (logList[i].PermType == Permissions.AccountModule)
                {
                    row.Cells.Add("AccountModuleViewed");
                }
                else if (logList[i].PermType == Permissions.ImagesModule)
                {
                    row.Cells.Add("ImagesModuleViewed");
                }
                else if (logList[i].PermType == Permissions.TPModule)
                {
                    row.Cells.Add("TreatmentPlanModuleViewed");
                }
                else
                {
                    row.Cells.Add(logList[i].PermType.ToString());
                }
                row.Cells.Add(logList[i].CompName);
                row.Cells.Add(logList[i].LogText);
                //Get the hash for the audit log entry from the database and rehash to compare
                string newHash = SecurityLogHashes.GetHashString(logList[i]);
                if (logList[i].LogHash != newHash)
                {
                    row.ColorText = Color.Red;                   //Bad hash or no hash entry at all.  This prevents users from deleting the entire hash table to make the audit trail look valid and encrypted.
                    //historical entries will show as red.
                }
                grid.Rows.Add(row);
            }
            grid.EndUpdate();
            grid.ScrollToEnd();
        }
Esempio n. 2
0
        private void FillGrid()
        {
            if (textRows.errorProvider1.GetError(textRows) != "")
            {
                MsgBox.Show(this, "Please fix data entry errors first.");
                return;
            }
            long userNum = 0;

            if (comboUser.SelectedIndex > 0)
            {
                userNum = _listUserods[comboUser.SelectedIndex - 1].UserNum;
            }
            SecurityLog[] logList          = null;
            DateTime      datePreviousFrom = PIn.Date(textDateEditedFrom.Text);
            DateTime      datePreviousTo   = DateTime.Today;

            if (textDateEditedTo.Text != "")
            {
                datePreviousTo = PIn.Date(textDateEditedTo.Text);
            }
            try {
                if (comboPermission.SelectedIndex == 0)
                {
                    logList = SecurityLogs.Refresh(PIn.Date(textDateFrom.Text), PIn.Date(textDateTo.Text),
                                                   Permissions.None, PatNum, userNum, datePreviousFrom, datePreviousTo, checkIncludeArchived.Checked, PIn.Int(textRows.Text));
                }
                else
                {
                    logList = SecurityLogs.Refresh(PIn.Date(textDateFrom.Text), PIn.Date(textDateTo.Text),
                                                   (Permissions)Enum.Parse(typeof(Permissions), comboPermission.SelectedItem.ToString()), PatNum, userNum,
                                                   datePreviousFrom, datePreviousTo, checkIncludeArchived.Checked, PIn.Int(textRows.Text));
                }
            }
            catch (Exception ex) {
                FriendlyException.Show(Lan.g(this, "There was a problem refreshing the Audit Trail with the current filters."), ex);
                logList = new SecurityLog[0];
            }
            grid.BeginUpdate();
            grid.Columns.Clear();
            grid.Columns.Add(new ODGridColumn(Lan.g("TableAudit", "Date"), 70, GridSortingStrategy.DateParse));
            grid.Columns.Add(new ODGridColumn(Lan.g("TableAudit", "Time"), 60, GridSortingStrategy.DateParse));
            grid.Columns.Add(new ODGridColumn(Lan.g("TableAudit", "Patient"), 100));
            grid.Columns.Add(new ODGridColumn(Lan.g("TableAudit", "User"), 70));
            grid.Columns.Add(new ODGridColumn(Lan.g("TableAudit", "Permission"), 190));
            grid.Columns.Add(new ODGridColumn(Lan.g("TableAudit", "Computer"), 70));
            grid.Columns.Add(new ODGridColumn(Lan.g("TableAudit", "Log Text"), 279));
            grid.Columns.Add(new ODGridColumn(Lan.g("TableAudit", "Last Edit"), 100));
            grid.Rows.Clear();
            ODGridRow row;

            foreach (SecurityLog logCur in logList)
            {
                row = new ODGridRow();
                row.Cells.Add(logCur.LogDateTime.ToShortDateString());
                row.Cells.Add(logCur.LogDateTime.ToShortTimeString());
                row.Cells.Add(logCur.PatientName);
                //user might be null due to old bugs.
                row.Cells.Add(Userods.GetUser(logCur.UserNum)?.UserName ?? "unknown");
                if (logCur.PermType == Permissions.ChartModule)
                {
                    row.Cells.Add("ChartModuleViewed");
                }
                else if (logCur.PermType == Permissions.FamilyModule)
                {
                    row.Cells.Add("FamilyModuleViewed");
                }
                else if (logCur.PermType == Permissions.AccountModule)
                {
                    row.Cells.Add("AccountModuleViewed");
                }
                else if (logCur.PermType == Permissions.ImagesModule)
                {
                    row.Cells.Add("ImagesModuleViewed");
                }
                else if (logCur.PermType == Permissions.TPModule)
                {
                    row.Cells.Add("TreatmentPlanModuleViewed");
                }
                else
                {
                    row.Cells.Add(logCur.PermType.ToString());
                }
                row.Cells.Add(logCur.CompName);
                if (logCur.PermType != Permissions.UserQuery)
                {
                    row.Cells.Add(logCur.LogText);
                }
                else
                {
                    //Only display the first snipet of very long queries. User can double click to view.
                    row.Cells.Add(logCur.LogText.Left(200, true));
                    row.Tag = (Action)(() => {
                        MsgBoxCopyPaste formText = new MsgBoxCopyPaste(logCur.LogText);
                        formText.NormalizeContent();
                        formText.Show();
                    });
                }
                if (logCur.DateTPrevious.Year < 1880)
                {
                    row.Cells.Add("");
                }
                else
                {
                    row.Cells.Add(logCur.DateTPrevious.ToString());
                }
                //Get the hash for the audit log entry from the database and rehash to compare
                if (logCur.LogHash != SecurityLogHashes.GetHashString(logCur))
                {
                    row.ColorText = Color.Red;                   //Bad hash or no hash entry at all.  This prevents users from deleting the entire hash table to make the audit trail look valid and encrypted.
                    //historical entries will show as red.
                }
                grid.Rows.Add(row);
            }
            grid.EndUpdate();
            grid.ScrollToEnd();
        }