public MainWindow()
        {
            try
            {
                //This part is used for initializing element so that popup is loaded first time
                using (WysiwysDialog inputDialog = new WysiwysDialog("")) { }
                //using (LoadingDialog loadingDialog = new LoadingDialog("Opening App for the first time")) { }

                //Add waight during download - https://github.com/lim0513/ModernMessageBoxLibForWPF/blob/master/DemoProj/MainWindow.xaml.cs
                //ActivateNotifyIcon();
            }
            catch (Exception ex)
            {
                Log.Print(LogLevel.Critical, ex.ToString());
            }
            InitializeComponent();
            this.Hide();

#pragma warning disable CS0612 // Type or member is obsolete
            StartServer();
#pragma warning restore CS0612 // Type or member is obsolete
        }
Пример #2
0
        private async Task <long?> SignFileAsync(long previouSigningFileId, string token, string downloadUrl, string uploadUrl, long procedureSerial = -1, string reason = "")
        {
            Tuple <XmlDocument, string> downloadedFile = await XmlSign.DownloadFileWithIdAsync(downloadUrl);

            //Open Dialog Popup
            if (downloadedFile == null)
            {
                return(null);
            }
            try {
                bool isRejected = false;
                await Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                {
                    using (WysiwysDialog inputDialog = new WysiwysDialog(downloadedFile.Item1.OuterXml))
                    {
                        if (inputDialog.ShowDialog() == false)
                        {
                            isRejected = true;
                        }
                    }
                }));

                if (isRejected)
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                Log.Print(LogLevel.Critical, ex.ToString());
            }

            XmlDocument signedXmldDoc = XmlSign.GetSignedXMLDocument(downloadedFile.Item1, XmlSign.GetX509Certificate2FromDongle(), procedureSerial, reason);

            Tuple <XmlDocument, string> uploadFile = new Tuple <XmlDocument, string>(signedXmldDoc, downloadedFile.Item2);
            long?uploadFileID = await XmlSign.UploadFileAsync(uploadFile, token, previouSigningFileId, uploadUrl);

            Log.Print(LogLevel._Low, "Uploaded File ID - " + uploadFileID);
            try
            {
                if (uploadFileID != null)
                {
                    await Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        App.ShowTaskbarNotificationAfterUpload("Signed XML File Uploaded Successfully");
                    }));
                }
            }
            catch (Exception ex)
            {
                Log.Print(LogLevel.Critical, ex.Message.ToString());
            }

            /*
             * //Verify - No Need
             * bool? ifSignVerified = XmlSign.VerifyAllSign(signedXmldDoc);
             * if (ifSignVerified == true)
             * {
             *  MessageBox.Show("Verified");
             * }
             * else if (ifSignVerified == false)
             * {
             *  MessageBox.Show("Failed Verification");
             * }
             * else
             * {
             *  MessageBox.Show("File Has No Sign");
             * }*/
            return(uploadFileID);
        }