Beispiel #1
0
        ///<summary>Creates security log entries for all that PatNums passed in.</summary>
        public static void MakeLogEntry(Permissions permType, List <long> listPatNums, string logText)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), permType, listPatNums, logText);
                return;
            }
            List <SecurityLog> listSecLogs = new List <SecurityLog>();

            foreach (long patNum in listPatNums)
            {
                SecurityLog secLog = MakeLogEntryNoInsert(permType, patNum, logText, 0);
                SecurityLogs.Insert(secLog);
                listSecLogs.Add(secLog);
            }
            List <SecurityLogHash> listHash    = new List <SecurityLogHash>();
            List <EntryLog>        listEntries = new List <EntryLog>();

            listSecLogs = SecurityLogs.GetMany(SQLWhere.CreateIn(nameof(SecurityLog.SecurityLogNum),
                                                                 listSecLogs.Select(x => x.SecurityLogNum).ToList()));
            foreach (SecurityLog log in listSecLogs)
            {
                SecurityLogHash secLogHash = new SecurityLogHash();
                secLogHash.SecurityLogNum = log.SecurityLogNum;
                secLogHash.LogHash        = SecurityLogHashes.GetHashString(log);
                listHash.Add(secLogHash);
                if (log.PermType == Permissions.AppointmentCreate)
                {
                    listEntries.Add(new EntryLog(log.UserNum, EntryLogFKeyType.Appointment, log.FKey, log.LogSource));
                }
            }
            EntryLogs.InsertMany(listEntries);
            SecurityLogHashes.InsertMany(listHash);
        }
Beispiel #2
0
        public static void DeleteBeforeDateInclusive(DateTime date)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), date);
                return;
            }
            int         countDeleted = 0;
            List <long> listSecurityLogNums;

            do
            {
                //Delete the hashes
                MiscDataEvent.Fire(CodeBase.ODEventType.MiscData,
                                   Lans.g("FormBackup", "Removing old data from securityloghash table. Rows deleted so far:") + " " + countDeleted);
                //limiting to 500,000 to avoid out of memory exceptions
                string command = $"SELECT SecurityLogNum FROM securitylog WHERE DATE(LogDateTime) <= {POut.DateT(date.Date)} LIMIT 500000";
                listSecurityLogNums = Db.GetListLong(command);
                if (listSecurityLogNums.Count < 1)
                {
                    break;
                }
                SecurityLogHashes.DeleteForSecurityLogEntries(listSecurityLogNums);
                //Then delete the securitylog entries themselves
                MiscDataEvent.Fire(CodeBase.ODEventType.MiscData,
                                   Lans.g("FormBackup", "Removing old data from securitylog table. Rows deleted so far:") + " " + countDeleted);
                command = $"DELETE FROM securitylog WHERE SecurityLogNum IN ({string.Join(",",listSecurityLogNums)})";
                Db.NonQ(command);
                countDeleted += listSecurityLogNums.Count;
            }while(listSecurityLogNums.Count > 0);
        }
Beispiel #3
0
        ///<summary>Used when making a security log from a remote server, possibly with multithreaded connections.</summary>
        public static void MakeLogEntryNoCache(Permissions permType, long patnum, string logText, long userNum, LogSources source)
        {
            SecurityLog securityLog = new SecurityLog();

            securityLog.PermType       = permType;
            securityLog.UserNum        = userNum;
            securityLog.LogText        = logText;
            securityLog.CompName       = Environment.MachineName;
            securityLog.PatNum         = patnum;
            securityLog.FKey           = 0;
            securityLog.LogSource      = source;
            securityLog.SecurityLogNum = SecurityLogs.InsertNoCache(securityLog);
            SecurityLogHashes.InsertSecurityLogHashNoCache(securityLog.SecurityLogNum);
        }
Beispiel #4
0
 ///<summary>Take a SecurityLog object to save to the database. Creates a SecurityLogHash object as well.</summary>
 public static void MakeLogEntry(SecurityLog secLog)
 {
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         Meth.GetVoid(MethodBase.GetCurrentMethod(), secLog);
         return;
     }
     secLog.SecurityLogNum = SecurityLogs.Insert(secLog);
     SecurityLogHashes.InsertSecurityLogHash(secLog.SecurityLogNum);            //uses db date/time
     if (secLog.PermType == Permissions.AppointmentCreate)
     {
         EntryLogs.Insert(new EntryLog(secLog.UserNum, EntryLogFKeyType.Appointment, secLog.FKey, secLog.LogSource));
     }
 }
Beispiel #5
0
        ///<summary>Takes a foreign key to a table associated with that PermType.  PatNum can be 0.</summary>
        public static void MakeLogEntry(Permissions permType, long patNum, string logText, long fKey)
        {
            //No need to check RemotingRole; no call to db.
            SecurityLog securityLog = new SecurityLog();

            securityLog.PermType = permType;
            if (Security.CurUser != null)            //if this is generated by Patient Portal web service then we won't have a CurUser set
            {
                securityLog.UserNum = Security.CurUser.UserNum;
            }
            securityLog.LogText        = logText;   //"From: "+Environment.MachineName+" - "+logText;
            securityLog.CompName       = Environment.MachineName;
            securityLog.PatNum         = patNum;
            securityLog.FKey           = fKey;
            securityLog.SecurityLogNum = SecurityLogs.Insert(securityLog);
            //Create a hash of the security log.
            SecurityLogHashes.InsertSecurityLogHash(securityLog.SecurityLogNum);            //uses db date/time
        }