/// <summary> /// processes the delegate /// </summary> private static void GenericProcessor(object ADelegateName, bool ARunManually) { if (!FProcessDelegates.ContainsKey((string)ADelegateName)) { return; } TDataBase db = EstablishDBConnection(); TPetraIdentity PetraIdentity = new TPetraIdentity( "SYSADMIN", "", "", "", "", DateTime.MinValue, DateTime.MinValue, DateTime.MinValue, 0, -1, -1, false, false); UserInfo.GUserInfo = new TPetraPrincipal(PetraIdentity, null); TProcessDelegate TypedDelegate = FProcessDelegates[(string)ADelegateName]; TypedDelegate(db, ARunManually); CloseDBConnection(db); if (TLogging.DebugLevel >= 9) { TLogging.Log("delegate " + ADelegateName + " has run."); } }
private static SUserRow LoadUser(String AUserID, out TPetraIdentity APetraIdentity, TDBTransaction ATransaction) { SUserRow ReturnValue; SUserTable UserDT = null; SUserRow UserDR; DateTime LastLoginDateTime; DateTime FailedLoginDateTime; // Check if user exists in s_user DB Table if (!SUserAccess.Exists(AUserID, ATransaction)) { throw new EUserNotExistantException(StrInvalidUserIDPassword); } // User exists, so load User record UserDT = SUserAccess.LoadByPrimaryKey(AUserID, ATransaction); UserDR = UserDT[0]; if (!UserDR.IsFailedLoginDateNull()) { FailedLoginDateTime = UserDR.FailedLoginDate.Value; FailedLoginDateTime = FailedLoginDateTime.AddSeconds(Convert.ToDouble(UserDR.FailedLoginTime)); } else { FailedLoginDateTime = DateTime.MinValue; } if (!UserDR.IsLastLoginDateNull()) { LastLoginDateTime = UserDR.LastLoginDate.Value; LastLoginDateTime = LastLoginDateTime.AddSeconds(Convert.ToDouble(UserDR.LastLoginTime)); } else { LastLoginDateTime = DateTime.MinValue; } Int64 PartnerKey; if (!UserDR.IsPartnerKeyNull()) { PartnerKey = UserDR.PartnerKey; } else { // to make it not match PartnerKey 0, which might be stored in the DB or in a variable PartnerKey = -1; } // Create PetraIdentity APetraIdentity = new Ict.Petra.Shared.Security.TPetraIdentity( AUserID.ToUpper(), UserDR.LastName, UserDR.FirstName, UserDR.LanguageCode, UserDR.AcquisitionCode, DateTime.MinValue, LastLoginDateTime, FailedLoginDateTime, UserDR.FailedLogins, PartnerKey, UserDR.DefaultLedgerNumber, UserDR.AccountLocked, UserDR.Retired, UserDR.CanModify); ReturnValue = UserDR; return(ReturnValue); }
void BtnPrintReportPDFClick(object sender, EventArgs e) { OpenFileDialog DialogOpen = new OpenFileDialog(); // see file in sub directory test data. // create file with method TResultList.WriteBinaryFile DialogOpen.Filter = "Binary Report File (*.bin)|*.bin"; DialogOpen.RestoreDirectory = true; DialogOpen.Title = "Open Binary Report File"; if (DialogOpen.ShowDialog() == DialogResult.OK) { TResultList Results = new TResultList(); TParameterList Parameters; Results.ReadBinaryFile(DialogOpen.FileName, out Parameters); TPetraIdentity PetraIdentity = new TPetraIdentity( "TESTUSER", "", "", "", "", DateTime.MinValue, DateTime.MinValue, DateTime.MinValue, 0, -1, -1, false, false, false); UserInfo.GUserInfo = new TPetraPrincipal(PetraIdentity, null); PrintDocument doc = new PrintDocument(); TPdfPrinter pdfPrinter = new TPdfPrinter(doc, TGfxPrinter.ePrinterBehaviour.eReport); TReportPrinterLayout layout = new TReportPrinterLayout(Results, Parameters, pdfPrinter, true); pdfPrinter.Init(eOrientation.ePortrait, layout, eMarginType.ePrintableArea); pdfPrinter.SavePDF("test.pdf"); System.Diagnostics.Process.Start(Path.GetFullPath("test.pdf")); } }
void TbbImportReportBinaryFileClick(object sender, EventArgs e) { OpenFileDialog DialogOpen = new OpenFileDialog(); // see file in sub directory test data. // create file with method TResultList.WriteBinaryFile DialogOpen.Filter = "Binary Report File (*.bin)|*.bin"; DialogOpen.RestoreDirectory = true; DialogOpen.Title = "Open Binary Report File"; if (DialogOpen.ShowDialog() == DialogResult.OK) { TResultList Results = new TResultList(); TParameterList Parameters; Results.ReadBinaryFile(DialogOpen.FileName, out Parameters); PrintDocument doc = new PrintDocument(); TPetraIdentity PetraIdentity = new TPetraIdentity( "TESTUSER", "", "", "", "", DateTime.MinValue, DateTime.MinValue, DateTime.MinValue, 0, -1, -1, false, false, false); UserInfo.GUserInfo = new TPetraPrincipal(PetraIdentity, null); FGfxPrinter = new TGfxPrinter(doc, TGfxPrinter.ePrinterBehaviour.eReport); new TReportPrinterLayout(Results, Parameters, FGfxPrinter, true); printPreviewControl1.Document = doc; doc.EndPrint += new PrintEventHandler(this.PrintDocument_EndPrint); printPreviewControl1.InvalidatePreview(); } }
/// <summary> /// AddUser /// </summary> public override bool AddUser(string AUserID, string APassword = "") { // we need a GUserInfo object for submitting the changes to the database later on TPetraIdentity PetraIdentity = new TPetraIdentity( "SYSADMIN", "", "", "", "", DateTime.MinValue, DateTime.MinValue, DateTime.MinValue, 0, -1, -1, false, false, false); UserInfo.GUserInfo = new TPetraPrincipal(PetraIdentity, null); return(FUserManager.AddUser(AUserID, APassword)); }
/// <summary> /// Gets called in regular intervals from a Timer in Class TTimedProcessing. /// </summary> /// <param name="ADBAccessObj">Already instatiated DB Access object with opened DB connection.</param> /// <param name="ARunManually">this is true if the process was called manually from the server admin console</param> public static void Process(TDataBase ADBAccessObj, bool ARunManually) { TDBTransaction ReadWriteTransaction; bool NewTransaction; bool LastReminderDateAcquired; DateTime LastReminderDate; DataSet ReminderResultsDS; SSystemDefaultsRow SystemDefaultsDR; PPartnerReminderTable PartnerReminderDT; int ReminderFreqency; TDataBase DBAccessObj; if (TLogging.DebugLevel >= 6) { TLogging.Log("Entering TProcessPartnerReminders.Process..."); } // TODO: it is quite ipossible at the moment to use ADBAccessObj instead of DBAccess.GDBAccessObj due to SubmitChanges etc //DBAccessObj = ADBAccessObj; DBAccessObj = DBAccess.GDBAccessObj; // SubmitChanges references a user TPetraIdentity PetraIdentity = new TPetraIdentity( "SYSADMIN", "", "", "", "", DateTime.MinValue, DateTime.MinValue, DateTime.MinValue, 0, -1, -1, false, false); UserInfo.GUserInfo = new TPetraPrincipal(PetraIdentity, null); ReadWriteTransaction = DBAccessObj.GetNewOrExistingTransaction(IsolationLevel.ReadCommitted, out NewTransaction); /* * This whole process must either succeed or fail, therefore the whole thing is in a try-catch. */ try { /* * Obtain date when PartnerReminders last ran. This is stored in a SystemDefault. If it doesn't exist already, * a new SystemDefault with an ancient date is created for us. */ LastReminderDateAcquired = GetLastReminderDate(out LastReminderDate, out SystemDefaultsDR, ReadWriteTransaction); if (!LastReminderDateAcquired) { TLogging.Log( TTimedProcessing.StrAutomaticProcessing + StrRemindersProcessing + ": Could not send Partner Reminders because Petra couldn't create the required SystemDefault setting for the Last Reminder Date!"); DBAccessObj.RollbackTransaction(); return; } // Retrieve all PartnerReminders we need to process. ReminderResultsDS = GetRemindersToProcess(LastReminderDate, out PartnerReminderDT, DBAccessObj, ReadWriteTransaction); /* * We now have a Typed DataTable with the PartnerReminders that we need to process. * Iterate through the PartnerReminders, update data, and send an email for each PartnerReminder. */ if (TLogging.DebugLevel >= 6) { TLogging.Log("_---------------------------------_"); TLogging.Log("PartnerReminders data before we start processing all PartnerReminders...."); TLogging.Log(ReminderResultsDS.GetXml().ToString()); } foreach (PPartnerReminderRow PartnerReminderDR in PartnerReminderDT.Rows) { if (TLogging.DebugLevel >= 4) { TLogging.Log(String.Format(TTimedProcessing.StrAutomaticProcessing + StrRemindersProcessing + ": Processing Reminder ID {0} for Partner {1}.", PartnerReminderDR.ReminderId, PartnerReminderDR.PartnerKey)); } ReminderFreqency = (PartnerReminderDR.IsReminderFrequencyNull()) ? 0 : PartnerReminderDR.ReminderFrequency; PartnerReminderDR.BeginEdit(); PartnerReminderDR.LastReminderSent = DateTime.Now.Date; PartnerReminderDR.NextReminderDate = DateTime.Now.Date.AddDays(ReminderFreqency); if (!PartnerReminderDR.IsEventDateNull()) // Reminder has an Event Date { if (PartnerReminderDR.NextReminderDate > PartnerReminderDR.EventDate) { if (TLogging.DebugLevel >= 5) { TLogging.Log(String.Format(TTimedProcessing.StrAutomaticProcessing + StrRemindersProcessing + ": Deactivating Reminder ID {0} for Partner {1} as its Event Date is in the past.", PartnerReminderDR.ReminderId, PartnerReminderDR.PartnerKey)); } PartnerReminderDR.ReminderActive = false; } } if (TLogging.DebugLevel >= 4) { TLogging.Log(String.Format(TTimedProcessing.StrAutomaticProcessing + StrRemindersProcessing + ": Sending email for Reminder ID {0} for Partner {1}.", PartnerReminderDR.ReminderId, PartnerReminderDR.PartnerKey)); } if (SendReminderEmail(PartnerReminderDR, ReadWriteTransaction)) { // Accept the edit if (TLogging.DebugLevel >= 4) { TLogging.Log(String.Format(TTimedProcessing.StrAutomaticProcessing + StrRemindersProcessing + ": Reminder ID {0} for Partner {1} accepted by SMTP server.", PartnerReminderDR.ReminderId, PartnerReminderDR.PartnerKey)); } PartnerReminderDR.EndEdit(); } else { // Cancel the edit TLogging.Log(String.Format(TTimedProcessing.StrAutomaticProcessing + StrRemindersProcessing + ": Reminder ID {0} for Partner {1} REJECTED by SMTP server.", PartnerReminderDR.ReminderId, PartnerReminderDR.PartnerKey)); PartnerReminderDR.CancelEdit(); } } if (TLogging.DebugLevel >= 6) { TLogging.Log("_---------------------------------_"); TLogging.Log("PartnerReminders data after processing all PartnerReminders, before writing it to DB...."); TLogging.Log(PartnerReminderDT.DataSet.GetXml().ToString()); } // Update all the changed PartnerReminder Rows PPartnerReminderAccess.SubmitChanges(PartnerReminderDT, ReadWriteTransaction); if (TLogging.DebugLevel >= 6) { TLogging.Log("_---------------------------------_"); } /* * Update the SystemDefault that keeps track of when Partner Reminders last ran. * (SystemDefaultsDR will point to the row we loaded earlier on, OR the row we added earlier on * if there wasn't already a SystemDefault row.) */ UpdateLastReminderDate(SystemDefaultsDR, ReadWriteTransaction); if (NewTransaction) { DBAccess.GDBAccessObj.CommitTransaction(); } TLogging.LogAtLevel(1, TTimedProcessing.StrAutomaticProcessing + StrRemindersProcessing + " ran succesfully."); } catch (Exception Exc) { TLogging.Log( TTimedProcessing.StrAutomaticProcessing + StrRemindersProcessing + " encountered an Exception:" + Environment.NewLine + Exc.ToString()); if (NewTransaction) { DBAccess.GDBAccessObj.RollbackTransaction(); } throw; } }
public static TPetraPrincipal PerformUserAuthentication(String AUserID, String APassword, string AClientComputerName, string AClientIPAddress, out Boolean ASystemEnabled, TDBTransaction ATransaction) { SUserRow UserDR; DateTime LoginDateTime; TPetraPrincipal PetraPrincipal = null; string UserAuthenticationMethod = TAppSettingsManager.GetValue("UserAuthenticationMethod", "OpenPetraDBSUser", false); IUserAuthentication AuthenticationAssembly; string AuthAssemblyErrorMessage; Int32 AProcessID = -1; ASystemEnabled = true; string EmailAddress = AUserID; if (EmailAddress.Contains("@")) { // try to find unique User for this e-mail address string sql = "SELECT s_user_id_c FROM PUB_s_user WHERE UPPER(s_email_address_c) = ?"; OdbcParameter[] parameters = new OdbcParameter[1]; parameters[0] = new OdbcParameter("EmailAddress", OdbcType.VarChar); parameters[0].Value = EmailAddress.ToUpper(); DataTable result = ATransaction.DataBaseObj.SelectDT(sql, "user", ATransaction, parameters); if (result.Rows.Count == 1) { AUserID = result.Rows[0][0].ToString(); } else { TLogging.Log("Login with E-Mail address failed for " + EmailAddress + ". " + "We found " + result.Rows.Count.ToString() + " matching rows for this address."); } } try { UserDR = LoadUser(AUserID, out PetraPrincipal, ATransaction); } catch (EUserNotExistantException) { TPetraIdentity PetraIdentity = new TPetraIdentity( "SYSADMIN", "", "", "", "", DateTime.MinValue, DateTime.MinValue, DateTime.MinValue, 0, -1, -1, false, false, false); UserInfo.GUserInfo = new TPetraPrincipal(PetraIdentity, null); // Logging TLoginLog.AddLoginLogEntry(AUserID, TLoginLog.LOGIN_STATUS_TYPE_LOGIN_ATTEMPT_FOR_NONEXISTING_USER, String.Format(Catalog.GetString( "User with User ID '{0}' attempted to log in, but there is no user account for this user! "), AUserID) + String.Format(ResourceTexts.StrRequestCallerInfo, AClientComputerName, AClientIPAddress), out AProcessID, ATransaction); // Only now throw the Exception! throw; } UserInfo.GUserInfo = PetraPrincipal; if ((AUserID == "SYSADMIN") && TSession.HasVariable("ServerAdminToken")) { // Login via server admin console authenticated by file token APassword = String.Empty; } // // (1) Check user-supplied password // else if (UserAuthenticationMethod == "OpenPetraDBSUser") { if (!TPasswordHelper.EqualsAntiTimingAttack( Convert.FromBase64String( CreateHashOfPassword(APassword, UserDR.PasswordSalt, UserDR.PwdSchemeVersion)), Convert.FromBase64String(UserDR.PasswordHash))) { // The password that the user supplied is wrong!!! --> Save failed user login attempt! // If the number of permitted failed logins in a row gets exceeded then also lock the user account! SaveFailedLogin(AUserID, UserDR, AClientComputerName, AClientIPAddress, ATransaction); if (UserDR.AccountLocked && (Convert.ToBoolean(UserDR[SUserTable.GetAccountLockedDBName(), DataRowVersion.Original]) != UserDR.AccountLocked)) { // User Account just got locked! throw new EUserAccountGotLockedException(StrInvalidUserIDPassword); } else { throw new EPasswordWrongException(StrInvalidUserIDPassword); } } } else { AuthenticationAssembly = LoadAuthAssembly(UserAuthenticationMethod); if (!AuthenticationAssembly.AuthenticateUser(EmailAddress, APassword, out AuthAssemblyErrorMessage)) { // The password that the user supplied is wrong!!! --> Save failed user login attempt! // If the number of permitted failed logins in a row gets exceeded then also lock the user account! SaveFailedLogin(AUserID, UserDR, AClientComputerName, AClientIPAddress, ATransaction); if (UserDR.AccountLocked && (Convert.ToBoolean(UserDR[SUserTable.GetAccountLockedDBName(), DataRowVersion.Original]) != UserDR.AccountLocked)) { // User Account just got locked! throw new EUserAccountGotLockedException(StrInvalidUserIDPassword); } else { throw new EPasswordWrongException(AuthAssemblyErrorMessage); } } } // // (2) Check if the User Account is Locked or if the user is 'Retired'. If either is true then deny the login!!! // // IMPORTANT: We perform these checks only AFTER the check for the correctness of the password so that every // log-in attempt that gets rejected on grounds of a wrong password takes the same amount of time (to help prevent // an attack vector called 'timing attack') if (PetraPrincipal.PetraIdentity.AccountLocked || PetraPrincipal.PetraIdentity.Retired) { if (PetraPrincipal.PetraIdentity.AccountLocked) { // Logging TLoginLog.AddLoginLogEntry(AUserID, TLoginLog.LOGIN_STATUS_TYPE_LOGIN_ATTEMPT_FOR_LOCKED_USER, Catalog.GetString("User attempted to log in, but the user account was locked! ") + String.Format(ResourceTexts.StrRequestCallerInfo, AClientComputerName, AClientIPAddress), out AProcessID, ATransaction); // Only now throw the Exception! throw new EUserAccountLockedException(StrInvalidUserIDPassword); } else { // Logging TLoginLog.AddLoginLogEntry(AUserID, TLoginLog.LOGIN_STATUS_TYPE_LOGIN_ATTEMPT_FOR_RETIRED_USER, Catalog.GetString("User attempted to log in, but the user is retired! ") + String.Format(ResourceTexts.StrRequestCallerInfo, AClientComputerName, AClientIPAddress), out AProcessID, ATransaction); // Only now throw the Exception! throw new EUserRetiredException(StrInvalidUserIDPassword); } } // // (3) Check SystemLoginStatus (whether the general use of the OpenPetra application is enabled/disabled) in the // SystemStatus table (this table always holds only a single record) // SSystemStatusTable SystemStatusDT; SystemStatusDT = SSystemStatusAccess.LoadAll(ATransaction); if (SystemStatusDT[0].SystemLoginStatus) { ASystemEnabled = true; } else { ASystemEnabled = false; // TODO: Check for Security Group membership might need reviewal when security model of OpenPetra might get reviewed... if (PetraPrincipal.IsInGroup("SYSADMIN")) { PetraPrincipal.LoginMessage = String.Format(StrSystemDisabled1, SystemStatusDT[0].SystemDisabledReason) + Environment.NewLine + Environment.NewLine + StrSystemDisabled2Admin; } else { TLoginLog.AddLoginLogEntry(AUserID, TLoginLog.LOGIN_STATUS_TYPE_LOGIN_ATTEMPT_WHEN_SYSTEM_WAS_DISABLED, Catalog.GetString("User wanted to log in, but the System was disabled. ") + String.Format(ResourceTexts.StrRequestCallerInfo, AClientComputerName, AClientIPAddress), out AProcessID, ATransaction); TLoginLog.RecordUserLogout(AUserID, AProcessID, ATransaction); throw new ESystemDisabledException(String.Format(StrSystemDisabled1, SystemStatusDT[0].SystemDisabledReason) + Environment.NewLine + Environment.NewLine + String.Format(StrSystemDisabled2, StringHelper.DateToLocalizedString(SystemStatusDT[0].SystemAvailableDate.Value), SystemStatusDT[0].SystemAvailableDate.Value.AddSeconds(SystemStatusDT[0].SystemAvailableTime).ToShortTimeString())); } } // // (4) Save successful login! // LoginDateTime = DateTime.Now; UserDR.LastLoginDate = LoginDateTime; UserDR.LastLoginTime = Conversions.DateTimeToInt32Time(LoginDateTime); UserDR.FailedLogins = 0; // this needs resetting! // Upgrade the user's password hashing scheme if it is older than the current password hashing scheme if (APassword != String.Empty && UserDR.PwdSchemeVersion < TPasswordHelper.CurrentPasswordSchemeNumber) { TMaintenanceWebConnector.SetNewPasswordHashAndSaltForUser(UserDR, APassword, AClientComputerName, AClientIPAddress, ATransaction); } SaveUser(AUserID, (SUserTable)UserDR.Table, ATransaction); PetraPrincipal.PetraIdentity.CurrentLogin = LoginDateTime; //PetraPrincipal.PetraIdentity.FailedLogins = 0; // TODO: Check for Security Group membership might need reviewal when security model of OpenPetra might get reviewed... if (PetraPrincipal.IsInGroup("SYSADMIN")) { TLoginLog.AddLoginLogEntry(AUserID, TLoginLog.LOGIN_STATUS_TYPE_LOGIN_SUCCESSFUL_SYSADMIN, Catalog.GetString("User login - SYSADMIN privileges. ") + String.Format(ResourceTexts.StrRequestCallerInfo, AClientComputerName, AClientIPAddress), out AProcessID, ATransaction); } else { TLoginLog.AddLoginLogEntry(AUserID, TLoginLog.LOGIN_STATUS_TYPE_LOGIN_SUCCESSFUL, Catalog.GetString("User login. ") + String.Format(ResourceTexts.StrRequestCallerInfo, AClientComputerName, AClientIPAddress), out AProcessID, ATransaction); } PetraPrincipal.ProcessID = AProcessID; AProcessID = 0; // // (5) Check if a password change is requested for this user // if (UserDR.PasswordNeedsChange) { // The user needs to change their password before they can use OpenPetra PetraPrincipal.LoginMessage = SharedConstants.LOGINMUSTCHANGEPASSWORD; } return(PetraPrincipal); }
/// <summary> /// Initialises Logging and parses Server settings from different sources. /// </summary> public TServerManager() : base() { // Create SystemDefaults Cache TSystemDefaultsCache.GSystemDefaultsCache = new TSystemDefaultsCache(); DomainManager.GetSiteKeyFromSystemDefaultsCacheDelegate = @TSystemDefaultsCache.GSystemDefaultsCache.GetSiteKeyDefault; TCacheableTablesManager.InitializeUnit(); TCacheableTablesManager.GCacheableTablesManager = new TCacheableTablesManager(new TDelegateSendClientTask(TClientManager.QueueClientTask)); Assembly SysManAssembly = Assembly.Load("Ict.Petra.Server.lib.MSysMan"); Type ImportExportType = SysManAssembly.GetType("Ict.Petra.Server.MSysMan.ImportExport.TImportExportManager"); FImportExportManager = (IImportExportManager)Activator.CreateInstance(ImportExportType, (BindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod), null, null, null); Assembly DBUpgradesAssembly = Assembly.Load("Ict.Petra.Server.lib.MSysMan.DBUpgrades"); Type DatabaseUpgradeType = DBUpgradesAssembly.GetType("Ict.Petra.Server.MSysMan.DBUpgrades.TDBUpgrades"); FDBUpgrades = (IDBUpgrades)Activator.CreateInstance(DatabaseUpgradeType, (BindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod), null, null, null); Type UserManagement = SysManAssembly.GetType("Ict.Petra.Server.MSysMan.Maintenance.UserManagement.TUserManager"); FUserManager = (IUserManager)Activator.CreateInstance(UserManagement, (BindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod), null, null, null); TClientManager.InitializeStaticVariables(TSystemDefaultsCache.GSystemDefaultsCache, FUserManager, new TErrorLog(), new TLoginLog(), new TMaintenanceLogonMessage(), ExceptionHandling_DBConnectionBrokenCallback); // Set up the SYSADMIN user (#5650). // (This is required for all SubmitChanges method calls in the server's main AppDomain because // that Method references UserInfo.GUserInfo) // When using this with the Web Services, this does not apply to the threads for each session. TPetraIdentity PetraIdentity = new TPetraIdentity( "SYSADMIN", "", "", "", "", DateTime.MinValue, DateTime.MinValue, DateTime.MinValue, 0, -1, -1, false, false, false); TPetraPrincipal Principal = new TPetraPrincipal(PetraIdentity, null); UserInfo.GUserInfo = Principal; // // Set up 'Timed Processing' // TTimedProcessing.DailyStartTime24Hrs = TAppSettingsManager.GetValue("Server.Processing.DailyStartTime24Hrs", "00:30"); if (TAppSettingsManager.GetBoolean("Server.Processing.PartnerReminders.Enabled", true)) { Assembly PartnerProcessingAssembly = Assembly.Load("Ict.Petra.Server.lib.MPartner.processing"); Type PartnerReminderClass = PartnerProcessingAssembly.GetType("Ict.Petra.Server.MPartner.Processing.TProcessPartnerReminders"); TTimedProcessing.AddProcessingJob( "TProcessPartnerReminders", (TTimedProcessing.TProcessDelegate)Delegate.CreateDelegate( typeof(TTimedProcessing.TProcessDelegate), PartnerReminderClass, "Process")); } if (TAppSettingsManager.GetBoolean("Server.Processing.AutomatedIntranetExport.Enabled", false)) { Assembly CommonProcessingAssembly = Assembly.Load("Ict.Petra.Server.lib.MCommon.processing"); Type IntranetExportClass = CommonProcessingAssembly.GetType("Ict.Petra.Server.MCommon.Processing.TProcessAutomatedIntranetExport"); TTimedProcessing.AddProcessingJob( "TProcessAutomatedIntranetExport", (TTimedProcessing.TProcessDelegate)Delegate.CreateDelegate( typeof(TTimedProcessing.TProcessDelegate), IntranetExportClass, "Process")); } if (TAppSettingsManager.GetBoolean("Server.Processing.DataChecks.Enabled", false)) { Assembly CommonProcessingAssembly = Assembly.Load("Ict.Petra.Server.lib.MCommon.processing"); Type ProcessDataChecksClass = CommonProcessingAssembly.GetType("Ict.Petra.Server.MCommon.Processing.TProcessDataChecks"); TTimedProcessing.AddProcessingJob( "TProcessDataChecks", (TTimedProcessing.TProcessDelegate)Delegate.CreateDelegate( typeof(TTimedProcessing.TProcessDelegate), ProcessDataChecksClass, "Process")); } }
public static SUserRow LoadUser(String AUserID, out TPetraIdentity APetraIdentity) { SUserRow ReturnValue; TDBTransaction ReadWriteTransaction; Boolean NewTransaction; SUserTable UserDT; SUserRow UserDR; Boolean UserExists; DateTime LastLoginDateTime; DateTime FailedLoginDateTime; ReadWriteTransaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction(IsolationLevel.Serializable, TEnforceIsolationLevel.eilMinimum, out NewTransaction); // Check if user exists in s_user DB Table try { UserExists = SUserAccess.Exists(AUserID, ReadWriteTransaction); } catch { if (NewTransaction) { DBAccess.GDBAccessObj.CommitTransaction(); TLogging.LogAtLevel(7, "TUserManager.LoadUser: committed own transaction."); } throw; } if (!UserExists) { throw new EUserNotExistantException(StrInvalidUserIDPassword); } else { try { // Load User record UserDT = SUserAccess.LoadByPrimaryKey(AUserID, ReadWriteTransaction); } catch (Exception Exp) { if (NewTransaction) { DBAccess.GDBAccessObj.CommitTransaction(); TLogging.LogAtLevel(7, "TUserManager.LoadUser: committed own transaction."); } TLogging.LogAtLevel(8, "Exception occured while loading a s_user record: " + Exp.ToString()); throw; } if (NewTransaction) { DBAccess.GDBAccessObj.CommitTransaction(); TLogging.LogAtLevel(7, "TUserManager.LoadUser: committed own transaction."); } UserDR = UserDT[0]; if (!UserDR.IsFailedLoginDateNull()) { FailedLoginDateTime = UserDR.FailedLoginDate.Value; FailedLoginDateTime = FailedLoginDateTime.AddSeconds(Convert.ToDouble(UserDR.FailedLoginTime)); } else { FailedLoginDateTime = DateTime.MinValue; } if (!UserDR.IsLastLoginDateNull()) { LastLoginDateTime = UserDR.LastLoginDate.Value; LastLoginDateTime = LastLoginDateTime.AddSeconds(Convert.ToDouble(UserDR.LastLoginTime)); } else { LastLoginDateTime = DateTime.MinValue; } Int64 PartnerKey; if (!UserDR.IsPartnerKeyNull()) { PartnerKey = UserDR.PartnerKey; } else { // to make it not match PartnerKey 0, which might be stored in the DB or in a variable PartnerKey = -1; } // Create PetraIdentity APetraIdentity = new Ict.Petra.Shared.Security.TPetraIdentity( AUserID.ToUpper(), UserDR.LastName, UserDR.FirstName, UserDR.LanguageCode, UserDR.AcquisitionCode, DateTime.MinValue, LastLoginDateTime, FailedLoginDateTime, UserDR.FailedLogins, PartnerKey, UserDR.DefaultLedgerNumber, UserDR.Retired, UserDR.CanModify); ReturnValue = UserDR; } return(ReturnValue); }