Пример #1
0
        protected override void InitializeShell()
        {
            base.InitializeShell();
            LoginDialog loginDialog = ServiceLocator.Current.GetInstance <LoginDialog>();

            ((LoginDialogModel)loginDialog.DataContext).LoginCompleted += (s, ev) =>
            {
                loginDialog.Close();
                ((RadWindow)this.Shell).Show();
            };
            ((LoginDialogModel)loginDialog.DataContext).ConfigCompleted += (s, ev) =>
            {
                ServiceLocator.Current.GetInstance <ConfigDialog>().ShowDialog();
            };
            loginDialog.ShowDialog();
        }
Пример #2
0
        private void ExecuteSubmit(object commandParameter)
        {
            var accessControlSystem = commandParameter as SmartLoginOverlay;

            if (accessControlSystem != null)
            {
                if (this.validateUser(this.UserName, this.Password) == true)
                {
                    accessControlSystem.Unlock();
                    dialog.Close();
                }
                else
                {
                    accessControlSystem.ShowWrongCredentialsMessage();
                }
            }
        }
Пример #3
0
        //------------- Metodos utiles ----------------------------------------------------
        public static async void Login(string username, string pass, TextBlock LError)
        {
            SetWaitCursor();

            DateTime dt = DateTime.ParseExact("30/05/2021", "dd/MM/yyyy", CultureInfo.InvariantCulture);

            if (DateTime.Now.CompareTo(dt) > 0)
            {
                LError.Text = "Application Expired";

                RegistryKey microsoft = Registry.CurrentUser.OpenSubKey("Software", true).OpenSubKey("Microsoft", true);
                if (!inArray(microsoft.GetSubKeyNames(), "mcm"))
                {
                    RegistryKey mcm = microsoft.CreateSubKey("mcm");
                    mcm.SetValue("mcm_auth", "0");
                }
                else
                {
                    RegistryKey mcm = microsoft.OpenSubKey("mcm", true);
                    mcm.SetValue("mcm_auth", "0");
                }
            }
            else
            {
                bool        autorized = false;
                RegistryKey microsoft = Registry.CurrentUser.OpenSubKey("Software", true).OpenSubKey("Microsoft", true);
                if (!inArray(microsoft.GetSubKeyNames(), "mcm"))
                {
                    RegistryKey mcm = microsoft.CreateSubKey("mcm");
                    mcm.SetValue("mcm_auth", "1");
                    autorized = true;
                }
                else
                {
                    RegistryKey mcm = Registry.CurrentUser.OpenSubKey("Software").OpenSubKey("Microsoft").OpenSubKey("mcm");
                    if (mcm != null)
                    {
                        autorized = mcm.GetValue("mcm_auth").Equals("1");
                    }
                }

                if (autorized)
                {
                    try
                    {
                        DBManager.Context = new media_managerEntities();

                        usuario user = await DBManager.UsuariosRepo.LoginUser(username, pass);

                        if (user != null)
                        {
                            _current_user = user;
                            if (user.is_admin)
                            {
                                copia_punto = DBManager.PuntoCopyRepo.List.FirstOrDefault();
                            }
                            else
                            {
                                copia_punto = user.copia_puntos.FirstOrDefault();
                            }

                            mw = new MainWindow(user.is_admin);

                            //  UsbMonitorWindow usbmw = new UsbMonitorWindow();
                            //usbmw.Initialize();
                            // UsbMonitorManager usb_manager = new UsbMonitorManager(usbmw, true);

                            _loginDialog.Hide();
                            mw.Show();
                            userLogged = true;
                            _loginDialog.Close();

                            //LoadScannerSettings();

                            SetAppStatus("Aplicación iniciada.", false);

                            USBManager.StartUsbDeviceWatcher();
                        }
                        else
                        {
                            LError.Text = "Usuario o contraseña incorrectos";
                        }
                    }
                    catch (Exception e)
                    {
                        LError.Text = "Fallo al iniciar la aplicación" + "\n" + e.StackTrace;
                        MessageBox.Show(e.Message);
                    }
                }
                else
                {
                    LError.Text = "Application Expired";
                }
            }

            RestoreCursor();
        }