Example #1
0
        private void BtnUploadFile_OnClick(object sender, RoutedEventArgs e)
        {
            try
            {
                OpenFileDialog dialog = new OpenFileDialog { Multiselect = false };
                dialog.Filter = "Zip files (*.zip)|*.zip|Rar files (*.rar)|*.rar|All files (*.*)|*.*";

                if (dialog.ShowDialog() == true)
                {
                    String path = dialog.FileName;
                    byte[] data = GetByte(path, "original_file");
                    byte[] signed = GetByte(path, "signed_file");
                    bool verificationStatus = Utility.Verifier.Verify(data, signed);
                    if (verificationStatus == true)
                    {
                        imgCross.Visibility = Visibility.Collapsed;
                        imgTick.Visibility = Visibility.Visible;
                        lblMessage.Text = "اطلاعات مورد تایید می باشد.";
                        webBrowser.NavigateToString(Encoding.UTF8.GetString(data)); 
                        imgLogo.Visibility = Visibility.Collapsed;
                        webBrowser.Visibility = Visibility.Visible;
                    }
                    else
                    {
                        ShowError();
                    }
                }
            }
            catch (UserInterfaceException ex)
            {
                ShowError(ex);
            }
            catch (FormatException ex)
            {
                //Log.Error("Format Exception Error While Uploading File(BtnUploadFile_OnClick) in Hoopad Mode.", ex);
                UserInterfaceException exception = new UserInterfaceException(30002, ExceptionMessage.Format, ex);
                ShowError(exception);
            }
            catch (Exception ex)
            {
                //Log.Error("Unspecific Exception Error While Uploading File(BtnUploadFile_OnClick) in Hoopad Mode.", ex);
                UserInterfaceException exception = new UserInterfaceException(30001, ExceptionMessage.FileOpenError, ex);
                ShowError(exception);
            }
        }
Example #2
0
 public void ShowError(UserInterfaceException ex)
 {
     MessageBox.Show(ex.Message, "نقص اطلاعات", MessageBoxButton.OK, MessageBoxImage.Error,
             MessageBoxResult.OK, MessageBoxOptions.RightAlign | MessageBoxOptions.RtlReading);
     ShowError();
 }