Esempio n. 1
0
		///<summary></summary>
		public static long Insert(SecurityLog log){
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				log.SecurityLogNum=Meth.GetLong(MethodBase.GetCurrentMethod(),log);
				return log.SecurityLogNum;
			}
			return Crud.SecurityLogCrud.Insert(log);
		}
Esempio n. 2
0
 ///<summary>PatNum can be 0.</summary>
 public static void MakeLogEntry(Permissions permType,long patNum,string logText)
 {
     //No need to check RemotingRole; no call to db.
     SecurityLog securityLog=new SecurityLog();
     securityLog.PermType=permType;
     securityLog.UserNum=Security.CurUser.UserNum;
     securityLog.LogText=logText;//"From: "+Environment.MachineName+" - "+logText;
     securityLog.CompName=Environment.MachineName;
     securityLog.PatNum=patNum;
     SecurityLogs.Insert(securityLog);
 }
Esempio n. 3
0
        ///<summary>PatNum can be 0.</summary>
        public static void MakeLogEntry(Permissions permType, long patNum, string logText)
        {
            //No need to check RemotingRole; no call to db.
            SecurityLog securityLog = new SecurityLog();

            securityLog.PermType = permType;
            securityLog.UserNum  = Security.CurUser.UserNum;
            securityLog.LogText  = logText;         //"From: "+Environment.MachineName+" - "+logText;
            securityLog.CompName = Environment.MachineName;
            securityLog.PatNum   = patNum;
            SecurityLogs.Insert(securityLog);
        }
Esempio n. 4
0
        ///<summary>Used for inserting without using the cache.  Usually used when multithreading connections.</summary>
        public static long InsertSecurityLogHashNoCache(long securityLogNum)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetLong(MethodBase.GetCurrentMethod(), securityLogNum));
            }
            SecurityLog     securityLog     = Crud.SecurityLogCrud.SelectOne(securityLogNum);
            SecurityLogHash securityLogHash = new SecurityLogHash();

            securityLogHash.SecurityLogNum = securityLog.SecurityLogNum;
            securityLogHash.LogHash        = GetHashString(securityLog);
            return(InsertNoCache(securityLogHash));
        }
Esempio n. 5
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);
        }
Esempio n. 6
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));
     }
 }
Esempio n. 7
0
        ///<summary>Creates a new SecurityLogHash entry in the Db.</summary>
        public static void InsertSecurityLogHash(long securityLogNum)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), securityLogNum);
                return;
            }
            SecurityLog     securityLog     = SecurityLogs.GetOne(securityLogNum);   //need a fresh copy because of time stamps, etc.
            SecurityLogHash securityLogHash = new SecurityLogHash();

            //Set the FK
            securityLogHash.SecurityLogNum = securityLog.SecurityLogNum;
            //Hash the securityLog
            securityLogHash.LogHash = GetHashString(securityLog);
            Insert(securityLogHash);
        }
Esempio n. 8
0
		///<summary>Does not make a call to the db.  Returns a SHA-256 hash of the entire security log.  Length of 32 bytes.  Only called from CreateSecurityLogHash() and FormAudit.FillGrid()</summary>
		public static string GetHashString(SecurityLog securityLog) {
			//No need to check RemotingRole; no call to db.
			HashAlgorithm algorithm=SHA256.Create();
			//Build string to hash
			string logString="";
			//logString+=securityLog.SecurityLogNum;
			logString+=((int)securityLog.PermType).ToString();
			logString+=securityLog.UserNum;
			logString+=POut.DateT(securityLog.LogDateTime,false);
			logString+=securityLog.LogText;
			//logString+=securityLog.CompName;
			logString+=securityLog.PatNum;
			//logString+=securityLog.FKey.ToString();
			byte[] unicodeBytes=Encoding.Unicode.GetBytes(logString);
			byte[] hashbytes=algorithm.ComputeHash(unicodeBytes);
			return Convert.ToBase64String(hashbytes);
		}
Esempio n. 9
0
        ///<summary>Takes a foreign key to a table associated with that PermType.  PatNum can be 0.  Returns the created SecurityLog object.  Does not perform an insert.</summary>
        public static SecurityLog MakeLogEntryNoInsert(Permissions permType, long patNum, string logText, long fKey, LogSources logSource = LogSources.None
                                                       , long defNum = 0, long defNumError = 0, DateTime DateTPrevious = default(DateTime))
        {
            //No need to check RemotingRole; no call to db.
            SecurityLog securityLog = new SecurityLog();

            securityLog.PermType      = permType;
            securityLog.UserNum       = Security.CurUser.UserNum;
            securityLog.LogText       = logText;    //"From: "+Environment.MachineName+" - "+logText;
            securityLog.CompName      = Environment.MachineName;
            securityLog.PatNum        = patNum;
            securityLog.FKey          = fKey;
            securityLog.LogSource     = logSource;
            securityLog.DefNum        = defNum;
            securityLog.DefNumError   = defNumError;
            securityLog.DateTPrevious = DateTPrevious;
            return(securityLog);
        }
Esempio n. 10
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
        }
Esempio n. 11
0
        ///<summary>Does not make a call to the db.  Returns a SHA-256 hash of the entire security log.  Length of 32 bytes.  Only called from CreateSecurityLogHash() and FormAudit.FillGrid()</summary>
        public static string GetHashString(SecurityLog securityLog)
        {
            //No need to check RemotingRole; no call to db.
            HashAlgorithm algorithm = SHA256.Create();
            //Build string to hash
            string logString = "";

            //logString+=securityLog.SecurityLogNum;
            logString += ((int)securityLog.PermType).ToString();
            logString += securityLog.UserNum;
            logString += POut.DateT(securityLog.LogDateTime, false);
            logString += securityLog.LogText;
            //logString+=securityLog.CompName;
            logString += securityLog.PatNum;
            //logString+=securityLog.FKey.ToString();
            byte[] unicodeBytes = Encoding.Unicode.GetBytes(logString);
            byte[] hashbytes    = algorithm.ComputeHash(unicodeBytes);
            return(Convert.ToBase64String(hashbytes));
        }
Esempio n. 12
0
 //there are no methods for deleting or changing log entries because that will never be allowed.
 ///<summary>Used when viewing various audit trails of specific types.</summary>
 public static SecurityLog[] Refresh(long patNum,List<Permissions> permTypes)
 {
     if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
         return Meth.GetObject<SecurityLog[]>(MethodBase.GetCurrentMethod(),patNum,permTypes);
     }
     string types="";
     for(int i=0;i<permTypes.Count;i++){
         if(i>0){
             types+=" OR";
         }
         types+=" PermType="+POut.Long((int)permTypes[i]);
     }
     string command="SELECT * FROM securitylog "
         +"WHERE PatNum= '"+POut.Long(patNum)+"' "
         +"AND ("+types+") "
         +"ORDER BY LogDateTime";
     DataTable table=Db.GetTable(command);
     SecurityLog[] List=new SecurityLog[table.Rows.Count];
     for(int i=0;i<List.Length;i++){
         List[i]=new SecurityLog();
         List[i].SecurityLogNum= PIn.Long   (table.Rows[i][0].ToString());
         List[i].PermType      = (Permissions)PIn.Long(table.Rows[i][1].ToString());
         List[i].UserNum       = PIn.Long   (table.Rows[i][2].ToString());
         List[i].LogDateTime   = PIn.DateT (table.Rows[i][3].ToString());
         List[i].LogText       = PIn.String(table.Rows[i][4].ToString());
         List[i].PatNum        = PIn.Long   (table.Rows[i][5].ToString());
     }
     return List;
 }
Esempio n. 13
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,LogSources logSource) {
			//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.LogSource=logSource;
			securityLog.SecurityLogNum=SecurityLogs.Insert(securityLog);
			//Create a hash of the security log.
			SecurityLogHashes.InsertSecurityLogHash(securityLog.SecurityLogNum);//uses db date/time
		}
Esempio n. 14
0
		///<summary>Used for ortho chart audit trail.  Attempts to parse the DateOfService from the security log text. If it is unable to parse the date, it will return MinDate.
		///<para>Returning MinDate from this function results in the audit trail entries for multiple dates of service displaying intermingled on the date "0001-01-01", harmless.</para></summary>
		public static DateTime GetOrthoDateFromLog(SecurityLog securityLog) {
			//There are 3 cases to try, in order of ascending complexity. If a simple case succeeds at parsing a date, that date is returned.
			//1) Using the new log text, there should be an 8 digit number at the end of each log entry. This is in the format "YYYYMMDD" and should be culture invariant.
			//2) Using the old log text, the Date of service appeared as a string in the middle of the text block.
			//3) Using the old log text, the Date of service appeared as a string in the middle of the text block in a culture dependant format.
			DateTime retVal=DateTime.MinValue;
			#region Ideal Case, Culture invariant
			try {
				string dateString=securityLog.LogText.Substring(securityLog.LogText.Length-8,8);
				retVal=new DateTime(int.Parse(dateString.Substring(0,4)),int.Parse(dateString.Substring(4,2)),int.Parse(dateString.Substring(6,2)));
				if(retVal!=DateTime.MinValue) {
					return retVal;
				}
			}
			catch(Exception ex) { }
			#endregion
			#region Depricated, log written in english
			try {
				if(securityLog.LogText.StartsWith("Ortho chart field edited.  Field date: ")) {
					retVal=DateTime.Parse(securityLog.LogText.Substring("Ortho chart field edited.  Field date: ".Length,10));//Date usually in the format MM/DD/YYYY, unless using en-UK for example
					if(retVal!=DateTime.MinValue) {
						return retVal;
					}
				}
			}
			catch(Exception ex) { }
			#endregion
			#region Depricated, log written in current culture
			try {
				if(securityLog.LogText.StartsWith(Lans.g("FormOrthoChart","Ortho chart field edited.  Field date"))) {
					string[] tokens=securityLog.LogText.Split(new string[] { ": " },StringSplitOptions.None);
					retVal=DateTime.Parse(tokens[1].Replace(Lans.g("FormOrthoChart","Field name"),""));
					if(retVal!=DateTime.MinValue) {
						return retVal;
					}
				}
			}
			catch(Exception ex) { }
			#endregion
			#region Depricated, log written in non-english non-current culture
				//not particularly common or useful.
			#endregion
			return retVal;//Should be DateTime.MinVal if we are returning here.
		}