public void Connect() { if (VSSDB == null) { try { VSSDB = new VSSDatabase(); VSSDB.Open(Location, Login, ""); } catch (System.Runtime.InteropServices.COMException exc) { if (exc.ErrorCode == -2147167977) { throw new ArgumentException("Wrong location or login"); } else { throw new ArgumentException(VSSErrors.GetMessageByCode(exc.ErrorCode)); } } catch { throw new Exception("Неопознанная ошибка"); } } }
public void Rename(string oldName, string newName) { try { VSSItem dir = VSSDB.get_VSSItem(oldName, false); dir.Name = newName; } catch (System.Runtime.InteropServices.COMException exc) { throw new ArgumentException(VSSErrors.GetMessageByCode(exc.ErrorCode)); } catch { throw new Exception("Неопознанная ошибка"); } }
public void Move(string source, string destination, IEnumerable <string> items) { try { VSSDB.get_VSSItem(source, false); } catch (System.Runtime.InteropServices.COMException exc) { throw new ArgumentException(VSSErrors.GetMessageByCode(exc.ErrorCode)); } catch { throw new Exception("Неопознанная ошибка"); } items = items.Select(x => string.Join("/", source, x)); Move(destination, items); }
public void Move(string destination, IEnumerable <string> items) { VSSItem destDir; try { destDir = VSSDB.get_VSSItem(destination, false); } catch (System.Runtime.InteropServices.COMException exc) { throw new ArgumentException(VSSErrors.GetMessageByCode(exc.ErrorCode)); } catch { throw new Exception("Неопознанная ошибка"); } foreach (string item in items) { Thread th = new Thread(() => { try { rwl.EnterReadLock(); VSSItem movingDir = VSSDB.get_VSSItem(item, false); rwl.ExitReadLock(); movingDir.Move(destDir); AfterMove(item, movingDir); } catch (System.Runtime.InteropServices.COMException exc) { throw new ArgumentException(VSSErrors.GetMessageByCode(exc.ErrorCode)); } catch { throw new Exception("Неопознанная ошибка"); } }); th.Start(); } }
public void Pull(string vssPath, DirectoryInfo localPath) { try { VSSItem dir = VSSDB.get_VSSItem(vssPath, false); sender($"Папка {vssPath} найдена"); if (!localPath.Exists) { localPath.Create(); sender($"Папка {vssPath} найдена"); } dir.Get(localPath.FullName, (int)(VSSFlags.VSSFLAG_RECURSYES | VSSFlags.VSSFLAG_REPREPLACE)); //DeleteLocalIfNotExistsInVSS(dir, localPath); sender("Папка загружена!"); } catch (System.Runtime.InteropServices.COMException exc) { throw new ArgumentException(VSSErrors.GetMessageByCode(exc.ErrorCode)); } }