コード例 #1
0
        private void SaveCert()
        {
            IsBusy = true;
            WorkInBackground((s, e) =>
            {
                try
                {
                    DisCert cert = new DisCert
                    {
                        Subject = this.SelectedCert.Subject,
                        ThumbPrint = this.SelectedCert.ThumbPrint
                    };
                    if (KmtConstants.IsOemCorp)
                        proxy.UpdateCertificateSubject(cert);
                    else if (KmtConstants.IsTpiCorp)
                    {

                        if (KmtConstants.CurrentHeadQuarter == null)
                        {
                            KmtConstants.CurrentHeadQuarter = new HeadQuarter()
                            {
                                CertSubject = cert.Subject,
                                CertThumbPrint = cert.ThumbPrint,
                                IsCentralizedMode = true,
                                IsCarbonCopy = false
                            };
                            hqProxy.InsertHeadQuarter(KmtConstants.CurrentHeadQuarter);
                        }
                        KmtConstants.CurrentHeadQuarter.CertSubject = cert.Subject;
                        KmtConstants.CurrentHeadQuarter.CertThumbPrint = cert.ThumbPrint;
                        hqProxy.UpdateHeadQuarter(KmtConstants.CurrentHeadQuarter);
                    }

                    MessageLogger.LogOperation(KmtConstants.LoginUser.LoginId,
                        string.Format("Microsoft Certificate Subject was changed to {0}", cert.Subject));
                    proxy.UpdateMsServiceEnabledSwitch(true);

                    DiagnosticResult result = proxy.TestMsConnection(KmtConstants.HeadQuarterId);
                    if (result.DiagnosticResultType == DiagnosticResultType.Ok)
                        proxy.UpdateMsServiceEnabledSwitch(true);
                    else
                        proxy.UpdateMsServiceEnabledSwitch(false);
                    IsBusy = false;
                    Dispatch(() =>
                    {

                        this.View.Close();
                    });
                }
                catch (Exception ex)
                {
                    IsBusy = false;
                    ex.ShowDialog();
                    ExceptionHandler.HandleException(ex);
                }
            });
        }
コード例 #2
0
        /// <summary>
        ///show certificate picker
        /// </summary>
        private void ShowCertificatePicker()
        {
            Window parent = GetCurrentWindow();
            IntPtr windowHandle = new WindowInteropHelper(parent).Handle;

            X509Certificate2Collection selectedCerts =
                X509Certificate2UI.SelectFromCollection(EncryptionHelper.GetMSCertificates(),
                ResourcesOfR6.CertVM_CertPickerTitle,
                "",
                X509SelectionFlag.SingleSelection,
                windowHandle);
            if (selectedCerts.Count > 0)
            {
                X509Certificate2 sc = selectedCerts[0];
                selectedCert = new DisCert
                {
                    Subject = sc.Subject,
                    ThumbPrint = sc.Thumbprint
                };
                this.CertificateSubject = selectedCert.Subject;
            }
        }