Exemple #1
0
        private void AsyncLoadSessionIds(object state)
        {
            var args = (UserSessionQueryParameters)state;

            try
            {
                using (var db = FindByUserDatabase.GetDatabase(_context))
                {
                    var sessionIds = db.FindSessions(args.User, args.Date);
                    lock (_lock)
                    {
                        _sessionIds = sessionIds;
                    }
                }
            }
            catch (Exception ex)
            {
                _context.Log.ReportException(ex, ExtentionDefinition.LogCategory, true, false);
                lock (_lock)
                {
                    _sessionIds = new HashSet <Guid>();
                }
            }

            var del = new MethodInvoker(UpdateSelectedSessions);

            Invoke(del);
        }
 public void Dispose()
 {
     if (_db != null)
     {
         _db.Dispose();
         _db = null;
     }
 }
 public void Dispose()
 {
     if (_db != null)
     {
         _db.Dispose();
         _db = null;
     }
 }
Exemple #4
0
 private void AsyncLoadUserList(object state)
 {
     try
     {
         using (var db = FindByUserDatabase.GetDatabase(_context))
         {
             ThreadSafeRefreshUsers(db.LoadUsernames(DataRetentionDays));
         }
     }
     catch (Exception ex)
     {
         _context.Log.RecordException(ex, ExtentionDefinition.LogCategory, true);
         ThreadSafeRefreshUsers(new List <string>());
         Enabled = true;
     }
 }
Exemple #5
0
        public static FindByUserDatabase GetDatabase(IRepositoryContext context)
        {
            var config = context.Configuration.Common as FindByUserConfiguration;

            if (config == null)
            {
                return(null);
            }

            FindByUserDatabase db = null;

            try
            {
                DbProviderFactory factory;
                switch (config.DatabaseProvider)
                {
                case "VistaDB":
                    factory = CreateVistaDbProviderFactory();
                    break;

                default:
                    factory = DbProviderFactories.GetFactory("System.Data.SqlClient");
                    break;
                }
                db = new FindByUserDatabase(context, factory, config.ConnectionString);
                DatabaseUnavailable = false;
            }
            catch (Exception ex)
            {
                // Only log the first time we fail until the user edits config
                if (!DatabaseUnavailable)
                {
                    DatabaseUnavailable = true;
                    context.Log.Error(ex, ExtentionDefinition.LogCategory, "Could not open database",
                                      config.ConnectionString);
                }
            }

            return(db);
        }
        public static FindByUserDatabase GetDatabase(IRepositoryContext context)
        {
            var config = context.Configuration.Common as FindByUserConfiguration;
            if (config == null)
                return null;

            FindByUserDatabase db = null;
            try
            {
                DbProviderFactory factory;
                switch (config.DatabaseProvider)
                {
                    case "VistaDB":
                        factory = CreateVistaDbProviderFactory();
                        break;

                    default:
                        factory = DbProviderFactories.GetFactory("System.Data.SqlClient");
                        break;
                }
                db = new FindByUserDatabase(context, factory, config.ConnectionString);
                DatabaseUnavailable = false;
            }
            catch (Exception ex)
            {
                // Only log the first time we fail until the user edits config
                if (!DatabaseUnavailable)
                {
                    DatabaseUnavailable = true;
                    context.Log.Error(ex, ExtentionDefinition.LogCategory, "Could not open database",
                        config.ConnectionString);
                }
            }

            return db;
        }
Exemple #7
0
        private void RefreshUserList()
        {
            if (!Enabled || _context == null)
            {
                return;
            }

            Enabled           = false;
            _selectedUsername = cboUser.SelectedIndex >= 0 ? cboUser.Items[cboUser.SelectedIndex].ToString() : null;
            cboUser.Items.Clear();
            cboUser.Items.Add("<All Users>");

            // Check if the database is available
            using (var db = FindByUserDatabase.GetDatabase(_context))
            {
                if (db == null || FindByUserDatabase.DatabaseUnavailable)
                {
                    ShowError = true;
                    return;
                }
            }

            ThreadPool.QueueUserWorkItem(AsyncLoadUserList, null);
        }
 public SessionScanner(ISession session, IRepositoryContext context)
 {
     _session = session;
     _db = FindByUserDatabase.GetDatabase(context);
 }
 public SessionScanner(ISession session, IRepositoryContext context)
 {
     _session = session;
     _db      = FindByUserDatabase.GetDatabase(context);
 }