public MachineContents DownloadMachine(IFileSyncModel connection, Credentials c, MachineIdentity mid) { var m = connection.GetMachineWithDirs(c, mid); if (m == null) { return(null); } List <DirectoryContents> directories = new List <DirectoryContents>(); foreach (DirectoryIdentity did in m.Directories) { var d = connection.GetDirectoryWithFiles(c, m, did); List <FileContents> files = new List <FileContents>(); foreach (FileIdentity fid in d.Files) { var f = connection.GetFileWithContent(c, m, d, fid); files.Add(f); } d.Files = files; directories.Add(d); } m.Directories = directories; return(m); }
public bool UploadMachine(IFileSyncModel connection, Credentials c, MachineContents m) { try { foreach (DirectoryContents d in m.Directories) { if (!UploadDirectory(connection, c, m, d)) { return(false); } } return(true); } catch (ActionException ex) { throw new ActionException("Couldn't upload the machine contents." , ActionType.Machine, ex); } catch (Exception ex) { throw new ActionException("Error while uploading a whole machine.", ActionType.Machine, ex); } }
public MachineContents DownloadMachine(IFileSyncModel connection, Credentials c, MachineIdentity mid) { var m = connection.GetMachineWithDirs(c, mid); if (m == null) return null; List<DirectoryContents> directories = new List<DirectoryContents>(); foreach (DirectoryIdentity did in m.Directories) { var d = connection.GetDirectoryWithFiles(c, m, did); List<FileContents> files = new List<FileContents>(); foreach (FileIdentity fid in d.Files) { var f = connection.GetFileWithContent(c, m, d, fid); files.Add(f); } d.Files = files; directories.Add(d); } m.Directories = directories; return m; }
public bool UploadDirectory(IFileSyncModel connection, Credentials c, MachineIdentity m, DirectoryContents d) { //add dir if it does not exist if (!connection.AddDirectory(c, new MachineContents(m), d)) { return(false); } foreach (FileContents f in d.Files) { try { FileContents fUp = null; if (f.Size == 0) { fUp = ReadFileContents(f, d); } else { fUp = f; } if (!UploadFile(connection, c, m, d, f)) { return(false); } } catch (ActionException ex) { throw new ActionException("Couldn't upload the directory contents.", ActionType.Directory, ex); } catch (Exception ex) { throw new ActionException("Error while uploading a directory.", ActionType.Directory, ex); } } return(true); }
public FileContents DownloadFile(IFileSyncModel connection, Credentials c, MachineIdentity m, DirectoryIdentity d, FileIdentity f) { throw new NotImplementedException(); }
public bool UploadFile(IFileSyncModel connection, Credentials c, MachineIdentity m, DirectoryIdentity d, FileContents f) { return(connection.AddFile(c, new MachineContents(m), new DirectoryContents(d), f)); }
public bool UpdateMachine(IFileSyncModel connection, Credentials c, MachineContents newM, MachineContents oldM) { throw new NotImplementedException(); }
public bool UploadMachine(IFileSyncModel connection, Credentials c, MachineContents m) { try { foreach (DirectoryContents d in m.Directories) { if (!UploadDirectory(connection, c, m, d)) return false; } return true; } catch (ActionException ex) { throw new ActionException("Couldn't upload the machine contents." , ActionType.Machine, ex); } catch (Exception ex) { throw new ActionException("Error while uploading a whole machine.", ActionType.Machine, ex); } }
public bool UploadFile(IFileSyncModel connection, Credentials c, MachineIdentity m, DirectoryIdentity d, FileContents f) { return connection.AddFile(c, new MachineContents(m), new DirectoryContents(d), f); }
public bool UploadDirectory(IFileSyncModel connection, Credentials c, MachineIdentity m, DirectoryContents d) { //add dir if it does not exist if (!connection.AddDirectory(c, new MachineContents(m), d)) return false; foreach (FileContents f in d.Files) { try { FileContents fUp = null; if (f.Size == 0) fUp = ReadFileContents(f, d); else fUp = f; if (!UploadFile(connection, c, m, d, f)) return false; } catch (ActionException ex) { throw new ActionException("Couldn't upload the directory contents.", ActionType.Directory, ex); } catch (Exception ex) { throw new ActionException("Error while uploading a directory.", ActionType.Directory, ex); } } return true; }