private void initializeAuditLogger( AuditLogEnabledChangeHandler auditLogEnabledChangeHandler, AuditLogHandler auditLogHandler, bool isEnabled) { try { var aLogger = AuditLogger.Instance; if (aLogger == null) { throw new Exception("AuditLogger Instance is null"); } aLogger.SetAuditLogEnabledChangeHandler(auditLogEnabledChangeHandler); if (auditLogEnabledChangeHandler == null) { throw new Exception("AuditLogEnabledChangeHandler is null"); } aLogger.SetAuditLogHandler(auditLogHandler); if (auditLogHandler == null) { throw new Exception("AuditLogHandler is null"); } aLogger.SetEnabled(isEnabled); } catch (Exception eX) { throw new ApplicationException("Cannot initialize AuditLogger", eX); } }
public void SetAuditLogEnabledChangeHandler(AuditLogEnabledChangeHandler aEnHandler) { this.auditChangeHandler = aEnHandler; }
/// <summary> /// Initializes common secured machine names and ports from PAWNSEC as well as some common init tasks /// - Exception Handler /// - Oracle connection /// - Couch service /// - Database time /// - Shop date & time /// - Site Id /// - Main application logger /// - Cashlinx PDA URL /// </summary> /// <param name="dSession"> </param> /// <param name="confRef"></param> /// <param name="appName"> </param> /// <param name="auditLogEnabled"> </param> /// <param name="exceptionHandler"> </param> /// <param name="multiConnect"></param> /// <param name="keyedConnect"></param> /// <param name="key"></param> /// <param name="auditLogEnabledChangeHandler"> </param> /// <param name="auditLogHandler"> </param> public void Init( DesktopSession dSession, EncryptedConfigContainer confRef, string appName, AuditLogEnabledChangeHandler auditLogEnabledChangeHandler, AuditLogHandler auditLogHandler, bool auditLogEnabled, Func <bool> exceptionHandler = null, bool multiConnect = false, bool keyedConnect = false, string key = null) { //Get DesktopSession instance this.desktopSession = dSession; if (this.desktopSession == null) { throw new ApplicationException("DesktopSession is null! Exiting!"); } //Setup exception handler var exHandler = BasicExceptionHandler.Instance; exHandler.PrintStackTrace = true; if (exceptionHandler != null) { exHandler.setExceptionCallback(exceptionHandler); } else { exHandler.setExceptionCallback(exceptionCallbackMethod); } //Get client config for DB connection var clientConfigDB = confRef.GetOracleDBService(); this.OracleDA = new OracleDataAccessor( confRef.DecryptValue(clientConfigDB.DbUser), confRef.DecryptValue(clientConfigDB.DbUserPwd), confRef.DecryptValue(clientConfigDB.Server), confRef.DecryptValue(clientConfigDB.Port), confRef.DecryptValue(clientConfigDB.AuxInfo), confRef.DecryptValue(clientConfigDB.Schema), (uint)confRef.ClientConfig.StoreConfiguration.FetchSizeMultiplier, multiConnect, keyedConnect, key); if (!this.OracleDA.Initialized) { throw new ApplicationException("Oracle data accessor is not initialized. Cannot interact with the database. Exiting!"); } //Get client config for Couch connection var clientDocDb = confRef.GetCouchDBService(); if (clientDocDb != null) { this.CouchDBConnector = new SecuredCouchConnector( confRef.DecryptValue(clientDocDb.Server), confRef.DecryptValue(clientDocDb.Port), DesktopSession.SSL_PORT, confRef.DecryptValue(clientDocDb.Schema), confRef.DecryptValue(clientDocDb.DbUser), confRef.DecryptValue(clientDocDb.DbUserPwd), DesktopSession.SECURE_COUCH_CONN); } else { throw new ApplicationException("Cannot initialize secured document server connection! Exiting!"); } //Retrieve database time DateTime time; ShopProcedures.ExecuteGetDatabaseTime(this.OracleDA, out time); this.DatabaseTime = time; //Set shop date time var storeConf = confRef.ClientConfig.StoreConfiguration; ShopDateTime.Instance.setOffsets(0, 0, 0, 0, 0, 0, 0); ShopDateTime.Instance.SetDatabaseTime(this.DatabaseTime); ShopDateTime.Instance.SetPawnSecOffsetTime(storeConf); //Initialize the site this.currentSiteId = new SiteId(); this.currentSiteId.StoreNumber = confRef.ClientConfig.StoreSite.StoreNumber; //Load store information LoadStoreData(currentSiteId.StoreNumber); //Finalize site info population this.currentSiteId.TerminalId = confRef.ClientConfig.ClientConfiguration.WorkstationId; this.currentSiteId.Alias = confRef.ClientConfig.StoreSite.Alias; this.currentSiteId.Company = confRef.ClientConfig.StoreSite.CompanyNumber; this.currentSiteId.CompanyNumber = confRef.ClientConfig.StoreSite.CompanyNumber; this.currentSiteId.Date = ShopDateTime.Instance.ShopDate; this.currentSiteId.State = confRef.ClientConfig.StoreSite.State; this.currentSiteId.LoanAmount = 0.00M; try { //Initialize the logger this.initializeLogger(appName); //Initialize audit logger this.initializeAuditLogger(auditLogEnabledChangeHandler, auditLogHandler, auditLogEnabled); } catch (Exception eX) { throw new ApplicationException("One or both primary loggers failed to initialize!", eX); } //Retrieve URL var pdaUrlObj = confRef.GetURL(); if (pdaUrlObj != null) { this.CashlinxPDAURL = confRef.DecryptValue(pdaUrlObj.AuxInfo); } else { throw new ApplicationException("Cannot determine CashlinxPDA URL! Exiting!"); } }
/// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// </summary> /// <filterpriority>2</filterpriority> public void Dispose() { this.auditChangeHandler = null; this.auditHandler = null; }