Example #1
0
        protected void CreateNewDirectoryCommandHandler(object sender, ExecutedRoutedEventArgs args)
        {
            try
            {
                m_controller.CreateNewDirectory(NewDirectoryName);

                DrawerHost drawerHost = ((DrawerHost)Template.FindName(DrawerHostName, this));

                if (drawerHost.IsBottomDrawerOpen)
                {
                    drawerHost.IsBottomDrawerOpen = false;
                }
            }
            catch (Exception exc)
            {
                SnackbarMessageQueue.Enqueue(exc.Message);
            }
        }
Example #2
0
        /// <summary>
        /// Create a new plan
        /// </summary>
        private void ClearPlan()
        {
            _viewModel.ClearCanvas();
            listBoxHistory.Items.Clear();

            buttonAddArea.Style   = FindResource("MaterialDesignFloatingActionDarkButton") as Style;
            buttonAddCamera.Style = FindResource("MaterialDesignFloatingActionDarkButton") as Style;
            buttonAddDoor.Style   = FindResource("MaterialDesignFloatingActionDarkButton") as Style;
            buttonAddWindow.Style = FindResource("MaterialDesignFloatingActionDarkButton") as Style;
            buttonAddWall.Style   = FindResource("MaterialDesignFloatingActionDarkButton") as Style;

            _snackbarMessageQueue.Enqueue("New plan");
        }
        private void addOperator()
        {
            if (companyName.Text.Trim() == "")
            {
                myMessageQueue.Enqueue(rm.GetString("fillBlanks", cultureInfo), rm.GetString("ok", cultureInfo), () => HandleOKMethod());
                return;
            }

            using (MySqlConnection localDbConnection = new MySqlConnection(pathToDBFile))
            {
                localDbConnection.Open();

                try
                {
                    MySqlCommand cmd = new MySqlCommand("Select count(*) from Operators where Operator = @Operator", localDbConnection);
                    cmd.Parameters.AddWithValue("@Operator", companyName.Text.Trim());
                    int result = (int)cmd.ExecuteScalar();
                    if (result != 0)
                    {
                        MessageBox.Show(rm.GetString("operatorAlreadyExist"), rm.GetString("system"), MessageBoxButton.OK,
                                        MessageBoxImage.Warning);
                        return;
                    }
                }
                catch { }

                try
                {
                    MySqlCommand commandToAddDatabase = new MySqlCommand("INSERT INTO Operators(Operator) VALUES(@Operator)", localDbConnection);
                    commandToAddDatabase.Parameters.AddWithValue("@Operator", companyName.Text.Trim());
                    commandToAddDatabase.ExecuteNonQuery();
                    Variables.saved = true;
                    MessageBox.Show(rm.GetString("operatorSaved"), rm.GetString("system"),
                                    MessageBoxButton.OK, MessageBoxImage.Information);
                    this.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, rm.GetString("system"), MessageBoxButton.OK,
                                    MessageBoxImage.Error);
                }
            }
        }
Example #4
0
 private void writeSingleData()
 {
     try
     {
         int value = Convert.ToInt32(kp.Text.ToString());
         if (value > 247 || value < 0)
         {
             myMessageQueue.Enqueue("0 - 247 arası bir değer giriniz", "OK", () => HandleOKMethod());
             return;
         }
         modbusClient.WriteSingleRegister(18, value);
         Vars.client.UnitIdentifier = Convert.ToByte(value);
         Properties.Settings.Default.tensionSlave = value;
         Properties.Settings.Default.Save();
         MessageBox.Show("Yazıldı");
         this.Close();
     }
     catch (Exception ex) { MessageBox.Show(ex.Message); }
 }
Example #5
0
        private void save()
        {
            Properties.Settings.Default.diameterCheck           = (bool)diameterCheck.IsChecked;
            Properties.Settings.Default.diameterSetCheck        = (bool)diameterSetCheck.IsChecked;
            Properties.Settings.Default.diameterDifferenceCheck = (bool)diameterDifferenceCheck.IsChecked;
            Properties.Settings.Default.plusToleranceCheck      = (bool)plusToleranceCheck.IsChecked;
            Properties.Settings.Default.minusToleranceCheck     = (bool)minusToleranceCheck.IsChecked;
            Properties.Settings.Default.display3Check           = (bool)display3Check.IsChecked;
            Properties.Settings.Default.ncCheck         = (bool)ncCheck.IsChecked;
            Properties.Settings.Default.evenCheck       = (bool)evenCheck.IsChecked;
            Properties.Settings.Default.parpCheck       = (bool)parpCheck.IsChecked;
            Properties.Settings.Default.pariCheck       = (bool)pariCheck.IsChecked;
            Properties.Settings.Default.diameter2       = (bool)diameter2.IsChecked;
            Properties.Settings.Default.plusTolerance2  = (bool)plusTolerance2.IsChecked;
            Properties.Settings.Default.minusTolerance2 = (bool)minusTolerance2.IsChecked;
            Properties.Settings.Default.xAxis           = (bool)xAxis.IsChecked;
            Properties.Settings.Default.yAxis           = (bool)yAxis.IsChecked;

            if (turkish.IsChecked == true)
            {
                cultureInfo = new CultureInfo("tr-TR");
                Properties.Settings.Default.language = "tr-TR";
                Properties.Settings.Default.Save();
            }
            else if (english.IsChecked == true)
            {
                cultureInfo = new CultureInfo("en-EN");
                Properties.Settings.Default.language = "en-EN";
                Properties.Settings.Default.Save();
            }
            else if (arabic.IsChecked == true)
            {
                cultureInfo = new CultureInfo("ar-AR");
                Properties.Settings.Default.language = "ar-AR";
                Properties.Settings.Default.Save();
            }

            Properties.Settings.Default.deviceAmount   = (int)upDownDevice.Value;
            Properties.Settings.Default.operatorAmount = (int)upDownOperator.Value;

            myMessageQueue.Enqueue(rm.GetString("settingsSaved", cultureInfo), rm.GetString("ok"),
                                   () => HandleOKMethod());
        }
 protected virtual void CurrentDirectoryChangedHandler(string newCurrentDirectory)
 {
     try
     {
         m_controller.SelectDirectory(newCurrentDirectory);
         if (m_currentDirectoryTextBox != null)
         {
             m_currentDirectoryTextBox.Text = newCurrentDirectory;
         }
     }
     catch (PathTooLongException)
     {
         SnackbarMessageQueue.Enqueue(Localization.Strings.LongPathsAreNotSupported);
     }
     catch (Exception exc)
         when(exc is UnauthorizedAccessException || exc is FileNotFoundException)
         {
             SnackbarMessageQueue.Enqueue(exc.Message);
         }
 }
Example #7
0
        private void DeleteConnection(object o)
        {
            var connection = o as ExplicitConnection;

            if (connection == null)
            {
                return;
            }

            var optional = _explicitConnectionCache.Get(connection.Id);

            if (!optional.HasValue)
            {
                return;
            }

            _explicitConnectionCache.Delete(connection.Id);
            SnackbarMessageQueue.Enqueue($"Deleted {connection.Label}.", "UNDO", _explicitConnectionCache.AddOrUpdate,
                                         optional.Value, true);
        }
Example #8
0
        public void getStats()
        {
            GetMyStatisticsRequest getMyStatisticsRequest = new GetMyStatisticsRequest();


            app.communicator.SocketSendReceive(JsonSerializer.serializeRequest(getMyStatisticsRequest, Constants.GET_MY_STATISTICS_REQUEST)).ContinueWith(task =>
            {
                ResponseInfo response = task.Result;
                GetMyStatisticsResponse getMyStatisticsResponse = JsonDeserializer.deserializeResponse <GetMyStatisticsResponse>(response.buffer);
                switch (getMyStatisticsResponse.status)
                {
                case Constants.GET_MY_STATISTICS_SUCCESS:
                    MyMessageQueue.Enqueue("Load Stats Successfully!");
                    this.Dispatcher.Invoke(() =>
                    {
                        loadStatsToUI(getMyStatisticsResponse);
                    });
                    break;
                }
            });
        }
Example #9
0
        private void doWork()
        {
            if (confirmation.Password == "")
            {
                myMessageQueue.Enqueue(rm.GetString("confirmationIsEmpty"), rm.GetString("ok"), () => HandleOKMethod());
                return;
            }

            if (checkAdmin())
            {
                using (MySqlConnection localDbConnection = new MySqlConnection(pathToDBFile))
                {
                    localDbConnection.Open();

                    string       query   = "DELETE FROM Operators WHERE Operator = @Name";
                    MySqlCommand command = new MySqlCommand(query, localDbConnection);
                    command.Parameters.AddWithValue("@Name", nameReceived);

                    try
                    {
                        command.ExecuteNonQuery();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, rm.GetString("system"), MessageBoxButton.OK, MessageBoxImage.Information);
                        return;
                    }
                }
            }
            else
            {
                MessageBox.Show(rm.GetString("adminConfirmationNotValid", cultureInfo), rm.GetString("system"),
                                MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }
            Variables.saved = true;
            MessageBox.Show(rm.GetString("operatorDeleted"), rm.GetString("system"),
                            MessageBoxButton.OK, MessageBoxImage.Information);
            this.Close();
        }
Example #10
0
        private void send()
        {
            try
            {
                int.Parse(sendData.Text);
            }
            catch
            {
                myMessageQueue.Enqueue(rm.GetString("onlyInteger", cultureInfo), rm.GetString("ok", cultureInfo), () => HandleOKMethod());
                return;
            }

            try
            {
                master.WriteSingleRegister(slave, address, ushort.Parse(sendData.Text));
                MessageBox.Show(rm.GetString("writingSuccessful", cultureInfo), rm.GetString("system", cultureInfo),
                                MessageBoxButton.OK, MessageBoxImage.Information);
                this.Close();
            }
            catch (IOException) {
            }
        }
Example #11
0
        public void ExecuteAddFeadback()
        {
            FeedBack feedBack = FeedbackModel.getAsFeedBack();

            feedBack.IceCreamID = iceCream.IceCreamId;
            var status = feedBackLogic.addFeedBack(feedBack);

            switch (status)
            {
            case FeedBackLogic.Status.Success:
                SnackbarMessageQueue.Enqueue("Succesful added feedback, Thank you very match.");
                break;

            case FeedBackLogic.Status.ExistError:
                SnackbarMessageQueue.Enqueue("Oops, You just add feedback now...");
                break;

            default:
                SnackbarMessageQueue.Enqueue("Error, Can not add feedback now. Please try latter.");
                break;
            }
        }
Example #12
0
        private void updateDevice()
        {
            if (slaveId.Text.Trim() == "" || deviceName.Text.Trim() == "" || readingAdress1.Text.Trim() == "" || readingAdress2.Text.Trim() == "" ||
                readingAdress3.Text.Trim() == "")
            {
                myMessageQueue.Enqueue(rm.GetString("fillBlanks", cultureInfo), rm.GetString("ok", cultureInfo), () => HandleOKMethod());
                return;
            }

            using (MySqlConnection localDbConnection = new MySqlConnection(pathToDBFile))
            {
                localDbConnection.Open();

                try
                {
                    MySqlCommand command = new MySqlCommand("UPDATE Devices SET Device = @Device, SlaveID = @SlaveID, Address1 = @Address1," +
                                                            "Address2 = @Address2, Address3 = @Address3, Address4 = @Address4, Address5 = @Address5 " +
                                                            "WHERE ID = @ID", localDbConnection);
                    command.Parameters.AddWithValue("@ID", ID);
                    command.Parameters.AddWithValue("@Device", deviceName.Text.Trim());
                    command.Parameters.AddWithValue("@SlaveID", slaveId.Text.Trim());
                    command.Parameters.AddWithValue("@Address1", readingAdress1.Text.Trim());
                    command.Parameters.AddWithValue("@Address2", readingAdress2.Text.Trim());
                    command.Parameters.AddWithValue("@Address3", readingAdress3.Text.Trim());
                    command.Parameters.AddWithValue("@Address4", readingAdress4.Text.Trim());
                    command.Parameters.AddWithValue("@Address5", readingAdress5.Text.Trim());
                    command.ExecuteNonQuery();
                    MessageBox.Show(rm.GetString("deviceInformationUpdated"), rm.GetString("system"),
                                    MessageBoxButton.OK, MessageBoxImage.Information);
                    this.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, rm.GetString("system"),
                                    MessageBoxButton.OK, MessageBoxImage.Information);
                }
            }
        }
Example #13
0
        private void deleteProject()
        {
            if (confirmation.Password == "")
            {
                myMessageQueue.Enqueue(rm.GetString("confirmationIsEmpty"), rm.GetString("ok"), () => HandleOKMethod());
                return;
            }

            if (localDbConnectionUnity.State == ConnectionState.Closed)
            {
                localDbConnectionUnity.Open();
            }

            if (localDbConnectionProject1.State == ConnectionState.Closed)
            {
                localDbConnectionProject1.Open();
            }

            string        query   = "SELECT Password FROM Admins";
            SqlCommand    command = new SqlCommand(query, localDbConnectionUnity);
            SqlDataReader reader  = command.ExecuteReader();

            while (reader.Read())
            {
                if (reader[0].ToString().Trim() == confirmation.Password.Trim())
                {
                    SqlCommand commandToCreateProject = new SqlCommand("dbo.deleteProjectToDo", localDbConnectionProject1);
                    commandToCreateProject.CommandType = CommandType.StoredProcedure;
                    commandToCreateProject.Parameters.AddWithValue("@id", id);
                    commandToCreateProject.ExecuteNonQuery();

                    MessageBox.Show(rm.GetString("projectDeleted"), rm.GetString("system"),
                                    MessageBoxButton.OK, MessageBoxImage.Information);
                    localDbConnectionUnity.Close();
                    localDbConnectionProject1.Close();
                    this.Close();
                    return;
                }
            }

            localDbConnectionUnity.Close();
            localDbConnectionProject1.Close();
            myMessageQueue.Enqueue(rm.GetString("adminConfirmationNotValid", cultureInfo), "OK", () => HandleOKMethod());
        }
        private void BackBTN_Click(object sender, RoutedEventArgs e)
        {
            thr.Abort();
            LeaveGameRequest leaveGameRequest = new LeaveGameRequest();

            app.communicator.SocketSendReceive(JsonSerializer.serializeRequest(leaveGameRequest, Constants.LEAVE_GAME_REQUEST)).ContinueWith(task =>
            {
                ResponseInfo response = task.Result;
                LeaveGameResponse leaveGameResponse = JsonDeserializer.deserializeResponse <LeaveGameResponse>(response.buffer);
                switch (leaveGameResponse.status)
                {
                case Constants.LEAVE_GAME_SUCCESS:

                    MyMessageQueue.Enqueue("You left the game successfuly.");
                    this.Dispatcher.Invoke(() =>
                    {
                        NavigationService ns = NavigationService.GetNavigationService(this);
                        ns.Navigate(new Uri("Menu.xaml", UriKind.Relative));
                    });

                    break;
                }
            });
        }
Example #15
0
        private void updateRoom()
        {
            while (true)
            {
                GetRoomDetailsRequest getRoomDetailsRequest = new GetRoomDetailsRequest();
                getRoomDetailsRequest.roomId = 0;
                ResponseInfo           response = app.communicator.SocketSendReceive(JsonSerializer.serializeRequest(getRoomDetailsRequest, Constants.GET_ROOM_DETAILS_REQUEST)).Result;
                GetRoomDetailsResponse getRoomDetailsResponse = JsonDeserializer.deserializeResponse <GetRoomDetailsResponse>(response.buffer);

                switch (getRoomDetailsResponse.status)
                {
                case Constants.GET_ROOM_DETAILS_SUCCESS:
                    if (getRoomDetailsResponse.isActive == true)
                    {
                        MyMessageQueue.Enqueue("The admin started the game.");
                        this.Dispatcher.Invoke(() =>
                        {
                            NavigationService ns = NavigationService.GetNavigationService(this);
                            ns.Navigate(new Uri("QuestionScreen.xaml", UriKind.Relative));
                        });
                        thr.Abort();
                        break;
                    }
                    else if (!app.admin && getRoomDetailsResponse.admin == app.username)
                    {
                        MyMessageQueue.Enqueue("You are admin now.");
                        app.admin = true;
                        NewAdminRequest newAdminRequest = new NewAdminRequest();

                        ResponseInfo response1 = app.communicator.SocketSendReceive(JsonSerializer.serializeRequest(newAdminRequest, Constants.NEW_ADMIN_REQUEST)).Result;


                        NewAdminResponse newAdminResponse = JsonDeserializer.deserializeResponse <NewAdminResponse>(response.buffer);
                        switch (newAdminResponse.status)
                        {
                        case Constants.NEW_ADMIN_SUCCESS:
                            this.Dispatcher.Invoke(() =>
                            {
                                NavigationService ns = NavigationService.GetNavigationService(this);
                                ns.Refresh();
                            });
                            thr.Abort();
                            break;
                        }
                    }
                    else
                    {
                        updateRoomUI(getRoomDetailsResponse);
                    }

                    break;

                case Constants.GET_ROOM_DETAILS_NOT_EXIST:

                    MyMessageQueue.Enqueue("The admin closed the room.");
                    this.Dispatcher.Invoke(() =>
                    {
                        NavigationService ns = NavigationService.GetNavigationService(this);
                        ns.Navigate(new Uri("Menu.xaml", UriKind.Relative));
                    });
                    thr.Abort();
                    break;
                }
                System.Threading.Thread.Sleep(100);
            }
        }
Example #16
0
 private void CallSnackBarMessageQueue(string message)
 {
     RootMessageQueue = new SnackbarMessageQueue();
     Task.Factory.StartNew(() => RootMessageQueue.Enqueue(message));
 }
Example #17
0
 private void ExileEngineOnMessage(object sender, string message)
 {
     SnackbarMessageQueue.Enqueue(message, null, null, null, false, false);
 }
Example #18
0
        public LoginAndRegisterViewModel()
        {
            SelectedCountryCode  = 6;    //默认选中中国
            RSelectedCountryCode = 6;
            EnabledLogin         = true; //允许登录
            SnackBar             = new SnackbarMessageQueue();
            #region Initial Commands
            LoginCommand              = new RelayCommand <IHavePassword>(UserLogin);
            RegisterCommand           = new RelayCommand <IHavePassword>(UserRegisterAccount);
            UsernameTextChangeCommand = new RelayCommand <IHavePassword>(UsernameChanged);
            UploadAvatorCommand       = new RelayCommand(AvatorUpload);
            FemaleOrMaleCommand       = new RelayCommand <object>(FemaleOrMaleChoice);
            RememberPwdCommand        = new RelayCommand <bool>(RememberPassword);
            RegisterTxtLostFocus      = new RelayCommand(CheckPhoneNumber);
            PasswordChanged           = new RelayCommand <RoutedEventArgs>(PasswordChange);

            visiShowKey    = Visibility.Collapsed;
            IsVisitorLogin = false;
            #endregion

            #region Initial Location Lists
            GPSLocator = new GeoCoordinateWatcher();
            Location   = new GeoCoordinate();
            Task.Run(() =>
            {
                GPSLocator.TryStart(false, TimeSpan.FromMilliseconds(5000)); ////超过5S则返回False;
                Location = GPSLocator.Position.Location;                     //获取位置
            });
            CountryList  = GetLocationList(AreasType.Country).ToObservableCollection();
            ProvinceList = new ObservableCollection <Areas>();
            ProvinceList.AddRange(new Areas()
            {
                parent_id = 1, type = 2
            }.GetChildrenList().ToObservableCollection());
            CityList = new ObservableCollection <Areas>();
            AreaList = new ObservableCollection <Areas>();
            //GobalAreaList = new ObservableCollection<Country>();
            GobalAreaList = Country.GetCountries().ToObservableCollection();//国家和地区列表
            #endregion

            if (Debugger.IsAttached)
            {
                //UserId = "15625294668";
            }
            Messenger.Default.Register <bool>(this, LoginNotifications.InitialAccount, (para) => { InitialAccount(); });
            Messenger.Default.Register <string>(this, LoginAndRegisterViewModel.ErrorMessage, (texts) => { SnackBar.Enqueue(texts, "重试", () => { ShiKuManager.GetConfigAsync(); }); });
        }
Example #19
0
 private void sendMessage(string text)
 {
     Message = new SnackbarMessageQueue();
     Message.Enqueue(text);
 }
        private void update()
        {
            string name, userID, id, pass, passRepeat, mail, phone;

            name       = nameSurname.Text.Trim();
            userID     = userName.Text.Trim();
            id         = Properties.Settings.Default.userDbID;
            pass       = password.Password.Trim();
            passRepeat = passwordRepeat.Password.Trim();
            mail       = textMail.Text.Trim() + "@" + comboBoxMail.Text.Trim();
            phone      = phoneNumber.Text.Trim();

            if (name.Trim() == "" || id.Trim() == "" || pass.Trim() == "" || passRepeat.Trim() == "" || phone.Trim() == "")
            {
                myMessageQueue.Enqueue(rm.GetString("blanksCannotBeEmpty", cultureInfo), "OK", () => HandleUndoMethod());
                return;
            }
            if (pass.Length < 5 || pass.Length > 16)
            {
                myMessageQueue.Enqueue(rm.GetString("passwordMinAndMax", cultureInfo), "OK", () => HandleUndoMethod());
                return;
            }
            if (pass != passRepeat)
            {
                myMessageQueue.Enqueue(rm.GetString("passwordDoesntMatch", cultureInfo), "OK", () => HandleUndoMethod());
                return;
            }
            if (comboBoxMail.Text.Trim() == "" || textMail.Text.Trim() == "")
            {
                myMessageQueue.Enqueue(rm.GetString("mailEmpty", cultureInfo), "OK", () => HandleUndoMethod());
                return;
            }

            using (MySqlConnection localDbConnection = new MySqlConnection(pathToDBFile))
            {
                localDbConnection.Open();

                string       query   = "UPDATE Users SET NameSurname = @NameSurname, UserName = @UserName, Password = @Password, Mail = @Mail, Phone = @Phone WHERE ID = @ID";
                MySqlCommand command = new MySqlCommand(query, localDbConnection);

                command.Parameters.AddWithValue("@ID", id);
                command.Parameters.AddWithValue("@NameSurname", name);
                command.Parameters.AddWithValue("@UserName", userID);
                command.Parameters.AddWithValue("@Password", pass);
                command.Parameters.AddWithValue("@Mail", mail);
                command.Parameters.AddWithValue("@Phone", phone);

                try
                {
                    command.ExecuteNonQuery();
                    Properties.Settings.Default.username    = userID;
                    Properties.Settings.Default.password    = pass;
                    Properties.Settings.Default.nameSurname = name;
                    Properties.Settings.Default.userMail    = mail;
                    Properties.Settings.Default.phoneNumber = phone;
                    Properties.Settings.Default.Save();
                    MessageBox.Show(rm.GetString("updateSucceeded", cultureInfo), rm.GetString("system", cultureInfo),
                                    MessageBoxButton.OK, MessageBoxImage.Information);
                }
                catch (Exception ex) {
                    MessageBox.Show(ex.Message, rm.GetString("system", cultureInfo),
                                    MessageBoxButton.OK, MessageBoxImage.Information);
                }
            }
        }
Example #21
0
        private void btnStart_Click(object sender, RoutedEventArgs e)
        {
            SnackbarMessageQueue messageQueue = new SnackbarMessageQueue(TimeSpan.FromSeconds(2));

            sbErr.MessageQueue = messageQueue;

            sbErr.IsActive = true;
            messageQueue.Enqueue("Processing data! Please Wait!");
            // Form Validation
            if (!validate())
            {
                return;
            }

            //Get the path of Directory from Source path TextBox
            string path = txtSourcePath.Text.Trim().ToLower();

            //Check if the directory exists
            if (Directory.Exists(path))
            {
                filePathLength = path.Length;
                //process each filetype
                if (cbJpeg.IsChecked == true)
                {
                    Parallel.Invoke(() =>
                    {
                        ProcessFile("jpeg", path);
                    });
                }
                if (cbJpg.IsChecked == true)
                {
                    Parallel.Invoke(() =>
                    {
                        ProcessFile("jpg", path);
                    });
                }
                if (cbPng.IsChecked == true)
                {
                    Parallel.Invoke(() =>
                    {
                        ProcessFile("png", path);
                    });
                }
                if (cbMp4.IsChecked == true)
                {
                    Parallel.Invoke(() =>
                    {
                        ProcessFile("mp4", path);
                    });
                }
                if (cbMkv.IsChecked == true)
                {
                    Parallel.Invoke(() =>
                    {
                        ProcessFile("mkv", path);
                    });
                }
                if (cbMp3.IsChecked == true)
                {
                    Parallel.Invoke(() =>
                    {
                        ProcessFile("mp3", path);
                    });
                }
                if (cbDoc.IsChecked == true)
                {
                    Parallel.Invoke(() =>
                    {
                        ProcessFile("doc", path);
                    });
                }
                if (cbExcel.IsChecked == true)
                {
                    Parallel.Invoke(() =>
                    {
                        ProcessFile("xls", path);
                    });
                }
                if (cbPdf.IsChecked == true)
                {
                    Parallel.Invoke(() =>
                    {
                        ProcessFile("pdf", path);
                    });
                }
                if (cbZip.IsChecked == true)
                {
                    Parallel.Invoke(() =>
                    {
                        ProcessFile("zip", path);
                    });
                }
            }
            else
            {
                // If the directory does not exists, then print an error message
                bool?Result = new MaterialMessageBox("No Directory found!!!", MessageType.Error, MessageButtons.Ok).ShowDialog();
            }

            NavigationService.Navigate(new pgReport(metadataList, this));
        }
Example #22
0
 private void ShowSnackbar(string message)
 {
     messageQueue.Enqueue(message);
     LoginSnackbar.MessageQueue = messageQueue;
 }
Example #23
0
 private void sendBatchMessage(string message)
 {
     BatchMessage = new SnackbarMessageQueue();
     BatchMessage.Enqueue(message);
 }
Example #24
0
        private void buttonLoginEvent()
        {
            userId       = id.Text.Trim();
            userPassword = password.Password.Trim();

            if (userId.Trim() == "" || userPassword.Trim() == "")
            {
                myMessageQueue.Enqueue(rm.GetString("blanksCannotBeEmpty", cultureInfo), "OK", () => HandleOKMethod());
                return;
            }

            using (MySqlConnection localDbConnection = new MySqlConnection(pathToDBFile))
            {
                localDbConnection.Open();
                string       query   = "SELECT * FROM Admins WHERE UserName = '******' AND Password = '******' ";
                MySqlCommand command = new MySqlCommand(query, localDbConnection);

                MySqlDataReader reader = command.ExecuteReader();

                if (reader.Read())
                {
                    Variables.isAdmin = true;

                    reader.Close();

                    myMessageQueue.Enqueue(rm.GetString("welcome", cultureInfo), "OK", () => HandleOKMethod());
                    MainWindow mainWindow = new MainWindow();
                    mainWindow.Show();
                    welcomeScreen.Close();
                    return;
                }
            }

            using (MySqlConnection localDbConnection = new MySqlConnection(pathToDBFile))
            {
                localDbConnection.Open();
                string       query   = "SELECT * FROM Users WHERE UserName = '******' AND Password = '******' ";
                MySqlCommand command = new MySqlCommand(query, localDbConnection);

                MySqlDataReader reader = command.ExecuteReader();

                if (reader.Read())
                {
                    Variables.UserName = reader.GetString(1);
                    //string status = Convert.ToBoolean(checkBoxRemember.IsChecked) ? "+" : "-";

                    if ((bool)checkBoxRemember.IsChecked)
                    {
                        Properties.Settings.Default.username    = userId;
                        Properties.Settings.Default.password    = userPassword;
                        Properties.Settings.Default.nameSurname = Variables.UserName;
                        Properties.Settings.Default.userMail    = reader.GetString(4);
                        Properties.Settings.Default.signedIn    = true;
                        Properties.Settings.Default.phoneNumber = reader.GetString(5);
                        Properties.Settings.Default.userDbID    = reader.GetInt32(0).ToString();
                        Properties.Settings.Default.Save();
                    }

                    reader.Close();

                    MainWindow mainWindow = new MainWindow();
                    mainWindow.Show();
                    welcomeScreen.Close();
                    return;
                }
                else
                {
                    myMessageQueue.Enqueue(rm.GetString("incorrectIdOrPassword", cultureInfo), "OK", () => HandleOKMethod());
                }
            }
        }
Example #25
0
 private void sendTransactionMessage(string message)
 {
     TransactionMessage = new SnackbarMessageQueue();
     TransactionMessage.Enqueue(message);
 }
Example #26
0
 private void ShowSnackbar(Snackbar snackbar, string message)
 {
     messageQueue.Enqueue(message);
     snackbar.MessageQueue = messageQueue;
 }
Example #27
0
        private static void Dispatcher_UnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
        {
#if RELEASE
            switch (e.Exception)
            {
            case QueryNotRespondingException _:
                MessageQueue.Enqueue(AkaI18N.QueryNotResponding);
                break;

            case ApiException apiException:
                if (apiException.StatusCode == HttpStatusCode.BadRequest)
                {
                    MessageQueue.Enqueue(AkaI18N.QueryNotResponding);
                }
                break;

            case HttpRequestException _: break;

            default:
                ExceptionDumper.WriteException(e.Exception);
                break;
            }

            e.Handled = true;
#endif
        }
 public static void ShowMessegeQueue(SnackbarMessageQueue messageQueue, string message)
 {
     Task.Factory.StartNew(() => messageQueue.Enqueue(message));
 }
Example #29
0
        private void buttonLoginEvent()
        {
            card.Visibility = Visibility.Visible;
            userId          = id.Text.Trim();
            userPassword    = password.Password.Trim();

            if (userId.Trim() == "" || userPassword.Trim() == "")
            {
                myMessageQueue.Enqueue(rm.GetString("blanksCannotBeEmpty", cultureInfo), "OK", () => HandleOKMethod());
                card.Visibility = Visibility.Hidden;
                return;
            }
            string     query   = "SELECT NameSurname, Mail, Phone, Id FROM Users WHERE UserId = '" + userId + "' AND Password = '******' ";
            SqlCommand command = new SqlCommand(query, localDbConnection);

            string     queryForAdmin   = "SELECT NameSurname FROM Admins WHERE userID = '" + userId + "' AND Password = '******' ";
            SqlCommand commandForAdmin = new SqlCommand(queryForAdmin, localDbConnection);

            localDbConnection.Open();
            SqlDataReader reader = command.ExecuteReader();

            if (reader.Read())
            {
                Variables.UserName = reader[0].ToString();
                string status = Convert.ToBoolean(checkBoxRemember.IsChecked) ? "+" : "-";
                if (status == "+")
                {
                    Properties.Settings.Default.username    = userId;
                    Properties.Settings.Default.password    = userPassword;
                    Properties.Settings.Default.nameSurname = reader[0].ToString();
                    Properties.Settings.Default.userMail    = reader[1].ToString();
                    Properties.Settings.Default.signedIn    = true;
                    Properties.Settings.Default.phoneNumber = reader[2].ToString();
                    Properties.Settings.Default.userDbID    = reader[3].ToString();
                    Properties.Settings.Default.Save();
                }
                myMessageQueue.Enqueue(rm.GetString("welcome", cultureInfo), "OK", () => HandleOKMethod());
                localDbConnection.Close();
                if (!Properties.Settings.Default.userFirstTime)
                {
                    openSelectedProject();
                }
                else
                {
                    openSelectProject();
                }
                card.Visibility = Visibility.Hidden;
                return;
            }
            localDbConnection.Close();
            localDbConnection.Open();
            SqlDataReader readerForAdmin = commandForAdmin.ExecuteReader();

            if (readerForAdmin.Read())
            {
                Variables.UserName = readerForAdmin[0].ToString();
                Properties.Settings.Default.nameSurname = readerForAdmin[0].ToString();
                myMessageQueue.Enqueue(rm.GetString("welcome", cultureInfo), "OK", () => HandleOKMethod());
                localDbConnection.Close();
                Vars.IsAdmin = true;
                if (!Properties.Settings.Default.userFirstTime)
                {
                    openSelectedProject();
                }
                else
                {
                    openSelectProject();
                }
                localDbConnection.Close();
                card.Visibility = Visibility.Hidden;
                return;
            }
            else
            {
                myMessageQueue.Enqueue(rm.GetString("incorrectIdOrPassword", cultureInfo), "OK", () => HandleOKMethod());
            }

            localDbConnection.Close();
            card.Visibility = Visibility.Hidden;
        }
Example #30
0
        private void LoginBTN_Clicked(object sender, RoutedEventArgs e)
        {
            Button btn = sender as Button;

            MaterialDesignThemes.Wpf.ButtonProgressAssist.SetIsIndeterminate(btn, true);
            MaterialDesignThemes.Wpf.ButtonProgressAssist.SetValue(btn, -1);
            MaterialDesignThemes.Wpf.ButtonProgressAssist.SetIsIndicatorVisible(btn, true);
            btn.IsEnabled       = false;
            SignupBTN.IsEnabled = false;
            bool EverythingFine = true;

            if (String.IsNullOrEmpty(UsernameBox.Text))
            {
                UsernameBox.GetBindingExpression(TextBox.TextProperty);
                ValidationError validationError = new ValidationError(new NotEmptyValidationRule(), UsernameBox.GetBindingExpression(TextBox.TextProperty));
                validationError.ErrorContent = "Field is required.";

                Validation.MarkInvalid(
                    UsernameBox.GetBindingExpression(TextBox.TextProperty),
                    validationError);
                EverythingFine = false;
            }
            else
            {
                Validation.ClearInvalid(UsernameBox.GetBindingExpression(TextBox.TextProperty));
            }
            if (String.IsNullOrEmpty(PasswordBox.Password))
            {
                PasswordBox.GetBindingExpression(TextBox.TextProperty);
                ValidationError validationError = new ValidationError(new NotEmptyValidationRule(), PasswordBox.GetBindingExpression(PasswordBox.DataContextProperty));
                validationError.ErrorContent = "Field is required.";

                Validation.MarkInvalid(
                    PasswordBox.GetBindingExpression(PasswordBox.DataContextProperty),
                    validationError);
                EverythingFine = false;
            }
            else if (PasswordBox.Password.Length < 1)
            {
                PasswordBox.GetBindingExpression(TextBox.TextProperty);
                ValidationError validationError = new ValidationError(new NotEmptyValidationRule(), PasswordBox.GetBindingExpression(PasswordBox.DataContextProperty));
                validationError.ErrorContent = "At least 8 characters.";

                Validation.MarkInvalid(
                    PasswordBox.GetBindingExpression(PasswordBox.DataContextProperty),
                    validationError);
                EverythingFine = false;
            }
            else
            {
                Validation.ClearInvalid(PasswordBox.GetBindingExpression(PasswordBox.DataContextProperty));
            }
            if (EverythingFine)
            {
                LoginRequest loginRequest = new LoginRequest();
                loginRequest.username = UsernameBox.Text;
                loginRequest.password = PasswordBox.Password;

                app.communicator.SocketSendReceive(JsonSerializer.serializeRequest(loginRequest, Constants.LOGIN_REQUEST_CODE)).ContinueWith(task =>
                {
                    ResponseInfo response       = task.Result;
                    LoginResponse loginResponse = JsonDeserializer.deserializeResponse <LoginResponse>(response.buffer);
                    switch (loginResponse.status)
                    {
                    case Constants.LOGIN_SUCCESS:
                        MyMessageQueue.Enqueue("Sign in Successfully!");
                        this.Dispatcher.Invoke(() =>
                        {
                            app.username         = UsernameBox.Text;
                            NavigationService ns = NavigationService.GetNavigationService(this);
                            ns.Navigate(new Uri("Menu.xaml", UriKind.Relative));
                        });
                        break;

                    case Constants.LOGIN_INCORRECT_PASSWORD:
                        MyMessageQueue.Enqueue("Incorrect password.");
                        break;

                    case Constants.LOGIN_USERNAME_NOT_EXIST:
                        MyMessageQueue.Enqueue("Username not exist.");
                        break;

                    case Constants.LOGIN_UNEXPECTED_ERR:
                        MyMessageQueue.Enqueue("There was an unexpected error.");
                        break;

                    case Constants.LOGIN_ALREADY_ONLINE:
                        MyMessageQueue.Enqueue("This Username is already online.");
                        break;
                    }
                    this.Dispatcher.Invoke(() =>
                    {
                        ButtonProgressAssist.SetIsIndeterminate(btn, false);
                        ButtonProgressAssist.SetIsIndicatorVisible(btn, false);
                        btn.IsEnabled       = true;
                        SignupBTN.IsEnabled = true;
                    });
                });
            }
            else
            {
                MaterialDesignThemes.Wpf.ButtonProgressAssist.SetIsIndeterminate(btn, false);
                MaterialDesignThemes.Wpf.ButtonProgressAssist.SetIsIndicatorVisible(btn, false);
                btn.IsEnabled       = true;
                SignupBTN.IsEnabled = true;
            }
        }