private void BtSetFolder_Click(object sender, EventArgs e) { using (var fbd = new FolderBrowserDialog()) { fbd.SelectedPath = IniUtils.GetConfig("Directories", "FixpackDir"); DialogResult result; try { result = fbd.ShowDialog(); } catch (Exception exc) { fbd.SelectedPath = ""; result = fbd.ShowDialog(); } if (result == DialogResult.OK && !string.IsNullOrWhiteSpace(fbd.SelectedPath)) { IniUtils.SetConfig("Directories", "FixpackDir", fbd.SelectedPath); folder = fbd.SelectedPath; LbSetFolder.Text = "Папка: " + fbd.SelectedPath; (new ToolTip()).SetToolTip(LbSetFolder, LbSetFolder.Text); subfolders = Directory.GetDirectories(folder); MessageBox.Show("Найдено: " + subfolders.Length.ToString() + " патчей", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); BtCreateFileScFromSc.Enabled = true; BtCreateFileScFromFiles.Enabled = true; BtRNCheck.Enabled = true; BtCheckFp.Enabled = true; } } }
public VSSForm() { InitializeComponent(); Application.Idle += OnIdle; Connect(); TbSourceFolder.Text = IniUtils.GetConfig("Folders", "Source"); TbDestFolder.Text = IniUtils.GetConfig("Folders", "Dest"); }
private void TsLoadOrder_Click(object sender, EventArgs e) { Microsoft.Office.Interop.Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application(); string folder; using (var ofd = new OpenFileDialog()) { ofd.DefaultExt = "xls"; ofd.Filter = "Файл Excel(*.XLS;*.XLSX)|*.XLS;*.XLSX|Все файлы (*.*)|*.*"; ofd.InitialDirectory = IniUtils.GetConfig("Directories", "ExcelDir"); DialogResult result; try { result = ofd.ShowDialog(); } catch (Exception exc) { ofd.InitialDirectory = ""; result = ofd.ShowDialog(); } if (result == DialogResult.OK && !string.IsNullOrWhiteSpace(ofd.FileName)) { TbFolders.Text = ""; IniUtils.SetConfig("Directories", "ExcelDir", Path.GetDirectoryName(ofd.FileName)); folder = ofd.FileName; Microsoft.Office.Interop.Excel.Workbook xlWorkbook = xlApp.Workbooks.Open(folder); Microsoft.Office.Interop.Excel._Worksheet xlWorksheet = xlWorkbook.Sheets[1]; Microsoft.Office.Interop.Excel.Range xlRange = xlWorksheet.UsedRange; int rowCount = xlRange.Rows.Count; int colCount = xlRange.Columns.Count; int patchColumn = 2; int firstPatchRow = 2; for (int i = firstPatchRow; i <= rowCount; i++) { //write the value to the console if (xlRange.Cells[i, patchColumn] != null && xlRange.Cells[i, patchColumn].Value2 != null) { TbFolders.Text += xlRange.Cells[i, patchColumn].Value2.ToString() + Environment.NewLine; } } ExcelCleanup(xlRange, xlWorksheet, xlWorkbook, xlApp); } } }
private void Connect() { try { basePath = IniUtils.GetConfig("Credentials", "Base"); string cvsType = IniUtils.GetConfig("CVS", "CVSType"); if (String.IsNullOrWhiteSpace(cvsType)) { throw new ArgumentException("В настройках задайте тип системы контроля версий"); } if (String.IsNullOrWhiteSpace(basePath)) { throw new ArgumentException("В настройках задайте правильный путь до " + cvsType); } cvs = Activator.CreateInstance("CVSLib", "CVSLib.CVSTypes." + IniUtils.GetConfig("CVS", "CVSType")).Unwrap() as CVS; cvs.location = basePath; cvs.login = Environment.UserName; cvs.Connect(); //cvs = new VSS(basePath, Environment.UserName); } catch (COMException exc) { string message = VSSErrors.GetMessageByCode(exc.ErrorCode); MessageBox.Show(message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (ArgumentException exc) { MessageBox.Show(exc.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Stop); } catch (Exception exc) { MessageBox.Show(exc.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void BtDownload_Click(object sender, EventArgs e) { string workingFolder = IniUtils.GetConfig("Directories", "WorkingFolder"); DownloadVSSDestFolder(); }