예제 #1
0
        private void BtTest_Click(object sender, EventArgs e)
        {
            VSSUtils vss = new VSSUtils(Properties.Settings.Default.BaseLocation, Environment.UserName);

            LogForm lf = new LogForm();

            VSSUtils.sender = lf.AddToLog;
            lf.Show();

            FolderBrowserDialog fbd = new FolderBrowserDialog();

            fbd.Description  = "Необходимо выбрать папку для хранения патчей";
            fbd.SelectedPath = Properties.Settings.Default.PatchesLocalDir;

            DirectoryInfo localDir;

            if (fbd.ShowDialog() == DialogResult.OK)
            {
                localDir = new DirectoryInfo(fbd.SelectedPath);
                Properties.Settings.Default.PatchesLocalDir = fbd.SelectedPath;
                Properties.Settings.Default.Save();

                Thread th = new Thread(() =>
                {
                    BtTest.Invoke(new Action(() => BtTest.Enabled = false));
                    foreach (string item in TbPatchList.Text.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries))
                    {
                        string dir             = item.Split('/').Last();
                        DirectoryInfo patchDir = Directory.CreateDirectory(Path.Combine(localDir.FullName, dir));
                        vss.Pull(item, patchDir);

                        vss.TestPatchDir(item, out string errDesc, patchDir);
                        TbErrors.Invoke(new Action(() => TbErrors.AppendText(errDesc)));
                        lf.AddToLog("Проверка завершена!");
                    }

                    BtTest.Invoke(new Action(() => BtTest.Enabled = true));
                });
                th.Start();
            }
        }
예제 #2
0
        private void BtTest_Click(object sender, EventArgs e)
        {
            VSSUtils vss = new VSSUtils(Properties.Settings.Default.BaseLocation, Environment.UserName);

            LogForm lf = new LogForm();

            VSSUtils.sender = lf.AddToLog;
            lf.Show();

            FolderBrowserDialog fbd = new FolderBrowserDialog();

            fbd.Description  = "Необходимо выбрать папку для хранения патчей";
            fbd.SelectedPath = Properties.Settings.Default.PatchesLocalDir;

            DirectoryInfo localDir;

            if (fbd.ShowDialog() == DialogResult.OK)
            {
                localDir = new DirectoryInfo(fbd.SelectedPath);
                Properties.Settings.Default.PatchesLocalDir = fbd.SelectedPath;
                Properties.Settings.Default.Save();

                TbErrors.Clear();

                th = new Thread(() =>
                {
                    BtStop.Invoke(new Action(() => BtStop.Enabled = true));
                    BtTest.Invoke(new Action(() => BtTest.Enabled = false));

                    foreach (string item in TbPatchList.Text.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries))
                    {
                        string dir = item.Split('/').Last();

                        DirectoryInfo patchDir = new DirectoryInfo(Path.Combine(localDir.FullName, dir));

                        if (Directory.Exists(patchDir.FullName))
                        {
                            OSUtils.SetAttributesNormal(patchDir);
                            Directory.Delete(patchDir.FullName, true);
                        }
                        else
                        {
                            Directory.CreateDirectory(patchDir.FullName);
                        }

                        vss.Pull(item, patchDir);
                        OSUtils.SetAttributesNormal(patchDir);

                        vss.TestPatchDir(item, out string errDesc, patchDir);
                        TbErrors.Invoke(new Action(() => TbErrors.AppendText(errDesc)));

                        using (var sw = File.AppendText("err_log.txt"))
                        {
                            sw.WriteLine(errDesc);
                        }

                        lf.AddToLog("Проверка завершена!");
                    }

                    BtStop.Invoke(new Action(() => BtStop.Enabled = false));
                    BtTest.Invoke(new Action(() => BtTest.Enabled = true));
                    MessageBox.Show("Проверка завершена", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
                });
                th.Start();


                Properties.Settings.Default.PatchesToTest = TbPatchList.Text;
                Properties.Settings.Default.Save();
            }
        }