예제 #1
0
 public static void WriteNoValue(string keyPath, Reporter reporter)
 {
     reporter.Write(keyPath + " にはValueがありませんでした。");
 }
예제 #2
0
        /// <summary>
        /// background transaction
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            Arguments args = (Arguments)e.Argument;

            // 今回はやっつけ的な増築で対処 本気で1000台レベルをやることになったら考える
            var list = this.GetFileList(args.HiveFileName);

            if (list.Count == 0)
            {
                MessageBox.Show("指定のパスにレジストリファイルがありません。", "KaniReg",
                                MessageBoxButtons.OK, MessageBoxIcon.Asterisk);

                e.Cancel = true;
                return;
            }

            this._resultPathList = new List <string>();

            var errors = new StringBuilder();

            // 使い回し用
            FileInfo  info;
            string    hiveName;
            Arguments arguments;
            Analyzer  analyzer;

            foreach (var file in list)
            {
                _reporter = new Reporter();

                // hive指定の取得
                hiveName = string.Empty;
                info     = new FileInfo(file);

                if (0 == this._cmbIndex)
                {
                    if ("NTUSER.DAT".Equals(info.Name, StringComparison.OrdinalIgnoreCase))
                    {
                        hiveName = "NTUSER";
                    }
                    else if ("USRCLASS.DAT".Equals(info.Name, StringComparison.OrdinalIgnoreCase))
                    {
                        hiveName = "USRCLASS";
                    }
                    else
                    {
                        hiveName = info.Name.ToUpper();
                    }
                }
                else
                {
                    hiveName = this._cmbText;
                }

                // Refill hiveName Arguments
                arguments = new Arguments(file, hiveName, args.TimeZoneBias, args.OutputUtc);

                // Show processing file name on progress bar
                this.Invoke((MethodInvoker) delegate()
                {
                    this.lblProgress.Text = file;
                });

                analyzer = new Analyzer(arguments, _reporter, _logger, backgroundWorker);
                bool result = analyzer.Process(this._executedFileCount);

                if (!string.IsNullOrEmpty(analyzer.ErrorMessage))
                {
                    errors.AppendLine(analyzer.ErrorMessage);
                }

                if (backgroundWorker.CancellationPending)
                {
                    e.Cancel = true;
                    return;
                }

                this.SaveReport(file, analyzer.ErrorMessage, result);

                this._executedFileCount++;

                int progress = (int)(((double)this._executedFileCount /
                                      (double)this._registryFileCount) * 100);
                progress = (100 > progress) ? progress : 100;
                this.backgroundWorker.ReportProgress(progress, "Files");
            }

            e.Result = errors.ToString();
        }