private static Application OnBaseConnect() { Application app = null; try { String url = System.Configuration.ConfigurationManager.AppSettings["OnBase.Url"]; String username = System.Configuration.ConfigurationManager.AppSettings["OnBase.Username"]; String pwd = System.Configuration.ConfigurationManager.AppSettings["OnBase.Password"]; String datasource = System.Configuration.ConfigurationManager.AppSettings["OnBase.Datasource"]; OnBaseAuthenticationProperties authProps = Application.CreateOnBaseAuthenticationProperties(url, username, pwd, datasource); //app = Application.Connect(OnBase.OnBaseProperties.Authentication); app = Application.Connect(authProps); } catch (MaxLicensesException e) { Log.Logger.Error("Error: All available licenses have been consumed."); throw e; } catch (SystemLockedOutException e) { Log.Logger.Error("Error: The system is currently in lockout mode."); throw e; } catch (InvalidLoginException e) { Log.Logger.Error("Error: Invalid Login Credentials."); throw e; } catch (AuthenticationFailedException e) { Log.Logger.Error("Error: NT Authentication Failed."); throw e; } catch (MaxConcurrentLicensesException e) { Log.Logger.Error("Error: All concurrent licenses for this user group have been consumed."); throw e; } catch (InvalidLicensingException e) { Log.Logger.Error("Error: Invalid Licensing."); throw e; } catch (Exception e) { Log.Logger.Error("Error! {0}", e.Message); throw e; } if (app != null) { Log.Logger.Information("Connection Successful. Connection ID: {0}", app.SessionID); } return(app); }
static Application ConnectToOnBase(string url, string user, string pwd, string dataSource) { Application Application = null; try { //Connect the Application Object OnBaseAuthenticationProperties props = Application.CreateOnBaseAuthenticationProperties(url, user, pwd, dataSource); Application = Application.Connect(props); } catch (InvalidLoginException ex) { throw new Exception("The credentials entered are invalid.", ex); } catch (AuthenticationFailedException ex) { throw new Exception("Authentication failed.", ex); } catch (MaxConcurrentLicensesException ex) { throw new Exception("All licenses are currently in use, please try again later.", ex); } catch (NamedLicenseNotAvailableException ex) { throw new Exception("Your license is not availble, please insure you are logged out of other OnBase clients.", ex); } catch (SystemLockedOutException ex) { throw new Exception("The system is currently locked, please try back later.", ex); } catch (UnityAPIException ex) { throw new Exception("There was an unhandled exception with the Unity API.", ex); } catch (Exception ex) { throw new Exception("There was an unhandled exception.", ex); } return(Application); }