Ejemplo n.º 1
0
        public bool CheckLoginData(string id, string password, ref ProductsClient productsClient, ref CashierClient cashierClient, ref Cashier cashier, ref List <Product> products, ref string token)
        {
            token = TokenRequester.ReuqestToken(id, password);
            bool result = false;

            if (token != null)
            {
                cashierClient  = new CashierClient(token);
                productsClient = new ProductsClient(token);

                cashier  = cashierClient.Login(id);
                products = productsClient.GetProducts();
                result   = true;
            }
            else
            {
                result = false;
            }

            if (cashier != null && products.Count > 0 && result)
            {
                result = true;;
            }
            else
            {
                result = false;
            }
            return(result);
        }
Ejemplo n.º 2
0
        private void HandleBtnLoginClick()
        {
            string         id             = txtLogin.Text;
            string         password       = pswPassword.Password;
            ProductsClient productsClient = null;
            CashierClient  cashierClient  = null;
            Cashier        cashier        = null;
            List <Product> products       = new List <Product>();
            string         token          = "";

            btnLogin.IsEnabled = false;
            Task.Factory.StartNew((Action) delegate
            {
                foreach (FileInfo fi in _directoryInfo.GetFiles("PluginLogIn.dll"))
                {
                    Assembly pluginAssembly = Assembly.LoadFrom(fi.FullName);
                    foreach (Type pluginType in pluginAssembly.GetExportedTypes())
                    {
                        if (pluginType.GetInterface(typeof(ILogIn).Name) != null)
                        {
                            ILogIn typeLoadedFromPlugin = (ILogIn)Activator.CreateInstance(pluginType);
                            if (typeLoadedFromPlugin.CheckLoginData(id, password, ref productsClient, ref cashierClient,
                                                                    ref cashier, ref products, ref token))
                            {
                                InitAppData(cashier, products, token);
                                Dispatcher.BeginInvoke(new Action(delegate
                                {
                                    MainWindow mainWindow = new MainWindow();
                                    mainWindow.Show();
                                    Close();
                                }));
                            }
                            else
                            {
                                MessageBox.Show("Nieprawidłowy login lub hasło!", "Błąd logowania", MessageBoxButton.OK,
                                                MessageBoxImage.Exclamation);
                            }
                        }
                    }
                }
            });
        }