Example #1
0
        public MainWindow()
        {
            XmlConfigurator.Configure();
            Version appVersion = new Version();//

            //Log.Info("Application is starting");
            if (!IsUserAdministrator())
            {
                SetActiveWindow(IntPtr.Zero);
                var result = MessageBox.Show("This program require higher privileges.");
                this.Close();
                return;
            }

            Task.Factory.StartNew(() =>
            {
                loadHtmlThread();
            });
            try
            {
                InitializeComponent();
                appVersion = Assembly.GetExecutingAssembly().GetName().Version;
                ApplicationVersion.Content = "V" + appVersion.Major.ToString() + "." + appVersion.Minor.ToString();
                Title += " (v" + appVersion.ToString() + ")";
                bool createdNew;
                m_Mutex = new Mutex(true, "IdentaZoneAdminMutex", out createdNew);
                if (!createdNew)
                {
                    SetActiveWindow(IntPtr.Zero);
                    MessageBox.Show("The application is already running.", "Warning", MessageBoxButton.OK);
                    this.Close();
                }
                this.userGrid.ItemsSource    = userRows;
                aboutIdentaZoneBtn.IsChecked = true;


                LicenseTabInit();
                // plugins init
                try {
                    pluginManager.LoadPlugins();
                }
                catch (Exception ex)
                {
                    Log.Error(ex);
                }
                if (pluginManager.Plugins.Count == 0)
                {
                    NoDevices = true;
                }
                // Load DB
                _db.Init("usrdb");

                var users = _db.GetAllUsers();
                foreach (var user in users)
                {
                    foreach (var credential in user.credentials_List)
                    {
                        if (credential is FingerCredential)
                        {
                            var fingerCredential = credential as FingerCredential;
                            foreach (var finger in fingerCredential.fingers)
                            {
                                finger.Template = pluginManager.GetTemplate(finger.Type, Convert.FromBase64String(finger.Bytes));
                            }
                        }
                    }
                }
                InitTestTab();
                SystemEvents.SessionSwitch += new SessionSwitchEventHandler(this.SystemEvents_SessionSwitch);
            }
            catch (Exception E)
            {
                Log.Error("Startup failed " + E);
            }
        }