private void CreateInfaRepositoryDirToolStripMenuItem_Click(object sender, EventArgs e) { EnterValueForm evf = new EnterValueForm("Добавление папки информатики в репозиторий"); if (evf.ShowDialog() == DialogResult.OK) { LogForm lf = new LogForm(); VSSUtils.sender = lf.AddToLog; lf.Show(); Thread th = new Thread(() => { DisableVSSButtons(); patchUtils.CreateStructure( evf.Value, Properties.Settings.Default.InfaSubdir, Properties.Settings.Default.RepStructureInfa.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).ToList()); if (MessageBox.Show("Папка создана!", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information) == DialogResult.OK) { if (!lf.IsDisposed) { lf.Close(); } } EnableVSSButtons(); }); th.Start(); } }
private void TestLocal() { LogForm lf = new LogForm(); VSSUtils.sender = lf.AddToLog; lf.Show(); FolderBrowserDialog fbd = new FolderBrowserDialog(); fbd.Description = "Необходимо выбрать патч для проверки"; DirectoryInfo localDir; bool retry = false; if (fbd.ShowDialog() == DialogResult.OK) { localDir = new DirectoryInfo(fbd.SelectedPath); Thread th = new Thread(() => { string errDesc = ""; if (!VSSUtils.CheckPatchErrors(localDir, ref errDesc)) { ErrorForm ef = new ErrorForm($"Ошибки в патче {localDir.Name}", errDesc); if (ef.ShowDialog() == DialogResult.Retry) { retry = true; } } lf.AddToLog("Проверка завершена!"); }); th.Start(); } }
private void PushPatch(DirectoryInfo patchCopyDir, List <FileInfoWithPatchOptions> patchFiles, bool isDMFR) { LogForm lf = new LogForm(); VSSUtils.sender = lf.AddToLog; lf.Show(); Thread th = new Thread(() => { DisableVSSButtons(); lf.AddToLog("Выкладывание патча"); if (patchUtils.PushPatch(patchCopyDir, patchFiles, isDMFR)) { lf.AddToLog(Environment.NewLine + "Патч выложен!"); if (MessageBox.Show("Патч выложен!", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information) == DialogResult.OK) { if (!lf.IsDisposed) { lf.Invoke(new Action(() => lf.Close())); } } } OSUtils.SetAttributesNormal(patchCopyDir); Directory.Delete(patchCopyDir.FullName, true); EnableVSSButtons(); }); th.Start(); }
private void BtFindFirst_Click(object sender, EventArgs e) { TbResult.Clear(); List <string> roots = TbRoots.Text.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).ToList(); vss = new VSSUtils(Properties.Settings.Default.BaseLocation, Environment.UserName); lf = new LogForm(); VSSUtils.sender = lf.AddToLog; lf.Show(); Thread th = new Thread(() => { EnableStopButton(); DisableSearchButtons(); bool found = false; foreach (string root in roots) { if (vss.FirstInEntireBase(root, TbFileName.Text, (int)NudDepth.Value, true, out string match)) { TbResult.Invoke(new Action(() => TbResult.AppendText(match))); found = true; break; } } if (found) { MessageBox.Show("Поиск завершен", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { MessageBox.Show("Файл не найден", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Warning); } lf.Invoke(new Action(() => lf.Close())); EnableSearchButtons(); DisableStopButton(); }); th.Start(); }
private void PushPatch(DirectoryInfo patchCopyDir, List <FileInfoWithPatchOptions> patchFiles) { LogForm lf = new LogForm(); VSSUtils.sender = lf.AddToLog; lf.Show(); lf.AddToLog("Проверка патча"); Thread th = new Thread(() => { DisableVSSButtons(); if (CheckPatch(patchCopyDir, patchFiles)) { lf.AddToLog("Выкладывание патча"); if (patchUtils.PushPatch(patchCopyDir, patchFiles, out List <string> vssPathCheckedOutToAnotherUser)) { lf.AddToLog(Environment.NewLine + "Патч выложен!"); if (MessageBox.Show("Патч выложен!", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information) == DialogResult.OK) { if (!lf.IsDisposed) { lf.Invoke(new Action(() => lf.Close())); } } } else { EnterValueForm ef = new EnterValueForm("Файлы checked out другим пользователем. Невозможно добавить:", string.Join(Environment.NewLine, vssPathCheckedOutToAnotherUser)); ef.ShowDialog(); } } OSUtils.SetAttributesNormal(patchCopyDir); Directory.Delete(patchCopyDir.FullName, true); EnableVSSButtons(); }); th.Start(); }
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(); } }
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(); } }