コード例 #1
0
        private void AnalyzeDatabase()
        {
            Task.Factory.StartNew(() =>
            {
                try
                {
                    if (!File.Exists(dataSource))
                    {
                        throw new InvalidOperationException("Unable to find " + dataSource);
                    }

                    Text = "SQL Compact Query Analyzer" + " - " + dataSource;

                    var fileInfo         = new FileInfo(dataSource);
                    fileInfo.Attributes &= ~FileAttributes.ReadOnly;

                    database = SqlCeDatabaseFactory.Create(GetConnectionString());
                    while (!database.VerifyConnectionStringPassword())
                    {
                        bool?result           = null;
                        PasswordWindow window = null;
                        Application.Current.Dispatcher.Invoke((Action) delegate
                        {
                            window = new PasswordWindow();
                            result = window.ShowDialog();
                        });
                        if (result != true)
                        {
                            return;
                        }
                        password = window.Password;
                        database.ConnectionString = GetConnectionString(4091);
                    }

                    AnalyzingTablesIsBusy = true;

                    var stopwatch = Stopwatch.StartNew();

                    database.AnalyzeDatabase();

                    ResultSetMessages = "Analyzed database in " + stopwatch.Elapsed;
                    stopwatch.Stop();

                    Application.Current.Dispatcher.Invoke((Action)PopulateTables);

                    AddRecentFile(dataSource);
                }
                catch (Exception e)
                {
                    ResultSetErrors        = e.ToString();
                    CurrentResultsTabIndex = 3;
                }
                finally
                {
                    AnalyzingTablesIsBusy = false;
                }
            });
        }
コード例 #2
0
        private async void ModeSelector_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var selected = this.ViewModel.SelectedMode;

            if (selected != null)
            {
                if (selected.Source == JryVideoDataSourceProviderManagerMode.Public)
                {
                    JryVideoCore.Current.Switch(JryVideoDataSourceProviderManagerMode.Public);
                    await this.ViewModel.VideosViewModel.RefreshAsync();
                }
                else
                {
                    var pw = await JryVideoCore.Current.SecureDataCenter.ProviderManager.GetSettingSet()
                             .FindAsync("password_sha1");

                    if (pw == null)
                    {
                        var dlg = new PasswordEditorWindow();
                        dlg.MessageTextBlock.Text       = "first time you must set a password.";
                        dlg.MessageTextBlock.Visibility = Visibility.Visible;
                        dlg.Owner = this.TryFindParent <Window>();
                        if (dlg.ShowDialog() != true)
                        {
                            this.ViewModel.SelectedMode = this.ViewModel.ModeCollection.First(
                                z => z.Source == JryVideoDataSourceProviderManagerMode.Public);
                            return;
                        }
                        var hash = JasilyHash.Create(HashType.SHA1).ComputeHashString(dlg.PasswordResult);
                        pw = new JrySettingItem("password_sha1", hash);
                        await JryVideoCore.Current.SecureDataCenter.ProviderManager.GetSettingSet().InsertAsync(pw);
                    }

                    var pwDlg = new PasswordWindow();
                    pwDlg.Owner = this.TryFindParent <Window>();
                    if (pwDlg.ShowDialog() == true)
                    {
                        if (pwDlg.PasswordBox.Password.IsNullOrWhiteSpace() ||
                            JasilyHash.Create(HashType.SHA1).ComputeHashString(pwDlg.PasswordBox.Password) != pw.Value)
                        {
                            this.ShowJryVideoMessage("error", "password error.");
                        }
                        else
                        {
                            JryVideoCore.Current.Switch(JryVideoDataSourceProviderManagerMode.Private);
                            await this.ViewModel.VideosViewModel.RefreshAsync();

                            return;
                        }
                    }

                    this.ViewModel.SelectedMode = this.ViewModel.ModeCollection.First(
                        z => z.Source == JryVideoDataSourceProviderManagerMode.Public);
                }
            }
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: jajp777/pass-winmenu
        /// <summary>
        /// Adds a new password to the password store.
        /// </summary>
        private void AddPassword()
        {
            if (InvokeRequired)
            {
                Invoke((MethodInvoker)AddPassword);
                return;
            }
            var passwordFileName = ShowFileSelectionWindow();

            // passwordFileName will be null if no file was selected
            if (passwordFileName == null)
            {
                return;
            }

            // Display the password generation window.
            string password;
            string extraContent;

            using (var passwordWindow = new PasswordWindow(Path.GetFileName(passwordFileName)))
            {
                passwordWindow.ShowDialog();
                if (!passwordWindow.DialogResult.GetValueOrDefault())
                {
                    return;
                }
                password     = passwordWindow.Password.Text;
                extraContent = passwordWindow.ExtraContent.Text.Replace(Environment.NewLine, "\n");
            }

            try
            {
                passwordManager.EncryptPassword(new PasswordFileContent(password, extraContent), passwordFileName + passwordManager.EncryptedFileExtension);
            }
            catch (GpgException e)
            {
                ShowErrorWindow("Unable to encrypt your password: "******"Unable to encrypt your password: "******"The new password has been copied to your clipboard.\nIt will be cleared in {ConfigManager.Config.ClipboardTimeout:0.##} seconds.", ToolTipIcon.Info);
            }
            // Add the password to Git
            git?.AddPassword(passwordFileName + passwordManager.EncryptedFileExtension);
        }
コード例 #4
0
        private void GetPassword()
        {
            var passwordWindow = new PasswordWindow();

            passwordWindow.ShowDialog();
            if (passwordWindow.Password == null || passwordWindow.Config == null)
            {
                Close();
            }

            _password = passwordWindow.Password;
            _config   = passwordWindow.Config;
        }
コード例 #5
0
        /// <summary>
        /// 修改密码
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tsbChangePassword_Click(object sender, EventArgs e)
        {
            PasswordWindow password = new PasswordWindow();

            password.StartLoad += (obj, ev) =>
            {
                StartLoad(obj);
            };
            password.StopLoad += (obj, ev) =>
            {
                StopLoad(obj);
            };
            SetSelect(tsbChangePassword, tsmiChangePassword);
            password.ShowDialog(this);
            SetSelect(checkedBtn, null, false);
        }
コード例 #6
0
        }         // DeleteUser()

        /// <summary>
        /// Change selected user password.
        /// </summary>
        public void ChangePassword(object x)
        {
            PasswordWindow passwordWindow;

            if (CurrentUser.Id == 0)
            {
                passwordWindow = new PasswordWindow("Set Password", CurrentUser.Id);
            }

            else
            {
                passwordWindow = new PasswordWindow("Change Password", CurrentUser.Id);
            }

            passwordWindow.Show();
        }         //ChangePassword()
コード例 #7
0
ファイル: MainWindow.xaml.cs プロジェクト: RoSkry/WPF
        private void Login_Click(object sender, RoutedEventArgs e)
        {
            PasswordWindow passwordWindow = new PasswordWindow();

            if (passwordWindow.ShowDialog() == true)
            {
                if (passwordWindow.Password == "12345678")
                {
                    MessageBox.Show("Авторизация пройдена");
                }
                else
                {
                    MessageBox.Show("Неверный пароль");
                }
            }
            else
            {
                MessageBox.Show("Авторизация не пройдена");
            }
        }
コード例 #8
0
        private async void DecryptCommandHandling()
        {
            var result = new PasswordWindow().ShowDialog();

            if (result == null || !(bool)result)
            {
                return;
            }

            this.IsBusy = true;

            var hsmPin = SimpleIoc.Default.GetInstance <PasswordViewModel>().Password;

            await Task.Run(() =>
            {
                DecryptInfo info;
                var targetPath = $"{this.FilePath}.dec";

                using (var input = File.OpenRead(this.FilePath))
                    using (var output = File.Create(targetPath))
                    {
                        info = HybridEncryption.Decrypt(input, output, new HybridEncryption.DecryptionParameter()
                        {
                            Progress   = this.ReportProgress,
                            IsCanceled = () => this.IsCanceled,
                            Password   = hsmPin,
                        });
                    }

                var decryptedFileName = Path.Combine(Path.GetDirectoryName(this.FilePath), info.FileName);
                if (File.Exists(decryptedFileName))
                {
                    var dto            = new DateTimeOffset(DateTime.Now);
                    decryptedFileName += $".{dto.ToUnixTimeMilliseconds()}{Path.GetExtension(info.FileName)}";
                }

                File.Move(targetPath, decryptedFileName);
            });

            this.IsBusy = false;
        }
コード例 #9
0
        private async void ModeSelector_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var selected = this.ViewModel.SelectedMode;

            if (selected.Value == JryVideoDataSourceProviderManagerMode.Public)
            {
                JryVideoCore.Current.DataAgent.Switch(JryVideoDataSourceProviderManagerMode.Public);
                await this.ViewModel.ReloadIfInitializedAsync();
            }
            else
            {
                var secure = JryVideoCore.Current.DataAgent.SecureDataCenter;

                if (!secure.IsWork)
                {
                    this.ShowJryVideoMessage("info", "current database not support private mode.");
                    this.SwitchPublic();
                    return;
                }

                string password = null;

                if (!await secure.ProviderManager.HasPasswordAsync())
                {
                    var dlg = new PasswordEditorWindow();
                    dlg.MessageTextBlock.Text       = "first time you must set a password.";
                    dlg.MessageTextBlock.Visibility = Visibility.Visible;
                    dlg.Owner = this.TryFindParent <Window>();
                    if (dlg.ShowDialog() != true)
                    {
                        this.SwitchPublic();
                        return;
                    }
                    password = dlg.PasswordResult;
                }
                else
                {
                    var pwDlg = new PasswordWindow();
                    pwDlg.Owner = this.TryFindParent <Window>();
                    if (pwDlg.ShowDialog() == true && !pwDlg.PasswordBox.Password.IsNullOrWhiteSpace())
                    {
                        password = pwDlg.PasswordBox.Password;
                    }
                }

                if (!password.IsNullOrWhiteSpace())
                {
                    var hash = JasilyHash.Create(HashType.SHA1).ComputeHashString(password);
                    if (await secure.ProviderManager.PasswordAsync(hash))
                    {
                        JryVideoCore.Current.DataAgent.Switch(JryVideoDataSourceProviderManagerMode.Private);
                        await this.ViewModel.ReloadIfInitializedAsync();

                        return;
                    }
                }

                this.ShowJryVideoMessage("error", "password error.");
                this.SwitchPublic();
            }
        }
コード例 #10
0
 public LoginFormViewModel(PasswordWindow passwordWindow)
 {
     _passwordWindow = passwordWindow;
     InitializeCommands();
 }
コード例 #11
0
        public string OpenPasswordDialog(PasswordViewModel passwordViewModel)
        {
            PasswordWindow passwordWindow = new PasswordWindow(passwordViewModel);

            return(passwordWindow.ShowDialog() == true ? passwordViewModel.EnteredPassword : null);
        }
コード例 #12
0
 /// <summary>
 /// Sing out
 /// </summary>
 private void OnSingOut(object param)
 {
     Window window = new PasswordWindow();
     window.Show();
     Logger.Log.InfoFormat("User {0} quitted the system", Settings.Default.Login);
     View.Close();
 }
コード例 #13
0
 public static void ProcessMessage(object viewModel)
 {
     if (viewModel is CollateralWindowViewModel)
     {
         CollateralWindow wnd = new CollateralWindow();
         wnd.DataContext = viewModel;
         wnd.ShowDialog();
     }
     else if (viewModel is AddFirmDialogViewModel)
     {
         AddFirmDialog wnd = new AddFirmDialog();
         (viewModel as AddFirmDialogViewModel).CloseWnd += (s, e) => wnd.Close();
         wnd.DataContext = viewModel;
         wnd.ShowDialog();
     }
     else if (viewModel is AddPersonDialogViewModel)
     {
         AddPersonDialog wnd = new AddPersonDialog();
         (viewModel as AddPersonDialogViewModel).CloseWnd += (s, e) => wnd.Close();
         wnd.DataContext = viewModel;
         wnd.ShowDialog();
     }
     else if (viewModel is CalculationInterestDialogViewModel)
     {
         CalculationInterestDialog wnd = new CalculationInterestDialog();
         (viewModel as CalculationInterestDialogViewModel).CloseWnd += (s, e) => wnd.Close();
         wnd.DataContext = viewModel;
         wnd.ShowDialog();
     }
     else if (viewModel is UpdateCreditDialogViewModel)
     {
         UpdateCreditDialog wnd = new UpdateCreditDialog();
         (viewModel as UpdateCreditDialogViewModel).CloseWnd += (s, e) => wnd.Close();
         wnd.DataContext = viewModel;
         wnd.ShowDialog();
     }
     else if (viewModel is AddCreditDialogViewModel)
     {
         AddCreditDialog wnd = new AddCreditDialog();
         (viewModel as AddCreditDialogViewModel).CloseWnd += (s, e) => wnd.Close();
         wnd.DataContext = viewModel;
         wnd.ShowDialog();
     }
     else if (viewModel is CollateralDialogViewModel)
     {
         CollateralDialog wnd = new CollateralDialog();
         (viewModel as CollateralDialogViewModel).CloseWnd += (s, e) => wnd.Close();
         wnd.DataContext = viewModel;
         wnd.ShowDialog();
     }
     else if (viewModel is MonitoringWindowViewModel)
     {
         MonitoringWindow wnd = new MonitoringWindow();
         wnd.DataContext = viewModel;
         wnd.ShowDialog();
     }
     else if (viewModel is UpdateMonitoringDialogViewModel)
     {
         UpdateMonitoringDialog wnd = new UpdateMonitoringDialog();
         (viewModel as UpdateMonitoringDialogViewModel).CloseWnd += (s, e) => wnd.Close();
         wnd.DataContext = viewModel;
         wnd.ShowDialog();
     }
     else if (viewModel is PasswordWindowViewModel)
     {
         PasswordWindow wnd = new PasswordWindow();
         (viewModel as PasswordWindowViewModel).CloseWnd += (s, e) => wnd.Close();
         wnd.DataContext = viewModel;
         wnd.ShowDialog();
     }
     else if (viewModel is MainWindowViewModelcs)
     {
         MainWindow wnd = new MainWindow();
         wnd.DataContext = viewModel;
         wnd.Closed     += (s, e) => App.Current.Shutdown();
         wnd.ShowDialog();
     }
     else if (viewModel is AddPropertyDialogViewModel)
     {
         AddPropertyDialog wnd = new AddPropertyDialog();
         (viewModel as AddPropertyDialogViewModel).CloseWnd += (s, e) => wnd.Close();
         wnd.DataContext = viewModel;
         wnd.ShowDialog();
     }
 }
コード例 #14
0
ファイル: myCommands.cs プロジェクト: hulu1528/MyBlogs
        public static void PublishViews2MultiSheet()
        {
            pwdWindow = new PasswordWindow();
            pwdWindow.ShowDialog();
            Document doc = Autodesk.AutoCAD.ApplicationServices.Core.Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;
            StringCollection viewsToPlot = new StringCollection();
            viewsToPlot.Add("Test1");
            viewsToPlot.Add("Test2");
            using (Transaction Tx = db.TransactionManager.StartTransaction())
            {
                ObjectId layoutId = LayoutManager.Current.GetLayoutId(LayoutManager.Current.CurrentLayout);
                Layout layout = Tx.GetObject(layoutId, OpenMode.ForWrite) as Layout;
                foreach (String viewName in viewsToPlot)
                {
                    PlotSettings plotSettings = new PlotSettings(layout.ModelType);
                    plotSettings.CopyFrom(layout);
                    PlotSettingsValidator psv = PlotSettingsValidator.Current;
                    psv.SetPlotConfigurationName(plotSettings, "DWF6 ePlot.pc3", "ANSI_A_(8.50_x_11.00_Inches)");
                    psv.RefreshLists(plotSettings);
                    psv.SetPlotViewName(plotSettings, viewName);
                    psv.SetPlotType(plotSettings, Autodesk.AutoCAD.DatabaseServices.PlotType.View);
                    psv.SetUseStandardScale(plotSettings, true);
                    psv.SetStdScaleType(plotSettings, StdScaleType.ScaleToFit);
                    psv.SetPlotCentered(plotSettings, true);
                    psv.SetPlotRotation(plotSettings, PlotRotation.Degrees000);
                    psv.SetPlotPaperUnits(plotSettings, PlotPaperUnit.Inches);
                    plotSettings.PlotSettingsName = String.Format("{0}{1}", viewName, "PS");
                    plotSettings.PrintLineweights = true;
                    plotSettings.AddToPlotSettingsDictionary(db);
                    Tx.AddNewlyCreatedDBObject(plotSettings, true);
                    psv.RefreshLists(plotSettings);
                    layout.CopyFrom(plotSettings);
                }
                Tx.Commit();
            }
            short bgPlot = (short)Autodesk.AutoCAD.ApplicationServices.Core.Application.GetSystemVariable("BACKGROUNDPLOT");
            Autodesk.AutoCAD.ApplicationServices.Core.Application.SetSystemVariable("BACKGROUNDPLOT", 0);
            string dwgFileName = Autodesk.AutoCAD.ApplicationServices.Core.Application.GetSystemVariable("DWGNAME") as string;
            string dwgPath = Autodesk.AutoCAD.ApplicationServices.Core.Application.GetSystemVariable("DWGPREFIX") as string;
            using (Transaction Tx = db.TransactionManager.StartTransaction())
            {
                DsdEntryCollection collection = new DsdEntryCollection();
                ObjectId activeLayoutId = LayoutManager.Current.GetLayoutId(LayoutManager.Current.CurrentLayout);
                foreach (String viewName in viewsToPlot)
                {
                    Layout layout = Tx.GetObject(activeLayoutId, OpenMode.ForRead) as Layout;
                    DsdEntry entry = new DsdEntry();
                    entry.DwgName = dwgPath + dwgFileName;
                    entry.Layout = layout.LayoutName;
                    entry.Title = viewName;
                    entry.NpsSourceDwg = entry.DwgName;
                    entry.Nps = String.Format("{0}{1}", viewName, "PS");
                    collection.Add(entry);
                }
                dwgFileName = dwgFileName.Substring(0, dwgFileName.Length - 4);
                DsdData dsdData = new DsdData();
                dsdData.SheetType = SheetType.MultiDwf;
                dsdData.ProjectPath = dwgPath;
                dsdData.DestinationName = dsdData.ProjectPath + dwgFileName + ".dwf";
                /*Get password from user*/
                dsdData.Password = pwdWindow.passwordBox.Password;
                if (System.IO.File.Exists(dsdData.DestinationName)) System.IO.File.Delete(dsdData.DestinationName);
                dsdData.SetDsdEntryCollection(collection);

                /*DsdFile */
                string dsdFile = dsdData.ProjectPath + dwgFileName + ".dsd";
                dsdData.WriteDsd(dsdFile);
                System.IO.StreamReader sr = new System.IO.StreamReader(dsdFile);
                string str = sr.ReadToEnd();
                sr.Close();
                str = str.Replace("PromptForDwfName=TRUE",
                                   "PromptForDwfName=FALSE");
                /*Prompts User to Enter Password and Reconfirms*/
                //str = str.Replace("PromptForPwd=FALSE",
                //                   "PromptForPwd=TRUE");
                //str = str.Replace("PwdProtectPublishedDWF=FALSE",
                //                   "PwdProtectPublishedDWF=TRUE");
                int occ = 0;
                int index = str.IndexOf("Setup=");
                int startIndex = 0;
                StringBuilder dsdText = new StringBuilder();
                while (index != -1)
                {
                    String str1 = str.Substring(startIndex, index + 6 - startIndex);
                    dsdText.Append(str1);
                    dsdText.Append(String.Format("{0}{1}", viewsToPlot[occ], "PS"));
                    startIndex = index + 6;
                    index = str.IndexOf("Setup=", index + 6);
                    if (index == -1)
                    {
                        dsdText.Append(str.Substring(startIndex, str.Length - startIndex));
                    }
                    occ++;
                }
                System.IO.StreamWriter sw = new System.IO.StreamWriter(dsdFile);
                sw.Write(dsdText.ToString());
                sw.Close();
                dsdData.ReadDsd(dsdFile);
                System.IO.File.Delete(dsdFile);
                PlotConfig plotConfig = PlotConfigManager.SetCurrentConfig("DWF6 ePlot.pc3");
                Publisher publisher = Autodesk.AutoCAD.ApplicationServices.Core.Application.Publisher;
                publisher.PublishExecute(dsdData, plotConfig);
                Tx.Commit();
            }
            Autodesk.AutoCAD.ApplicationServices.Core.Application.SetSystemVariable("BACKGROUNDPLOT", bgPlot);
        }