Beispiel #1
0
        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);
        }
Beispiel #2
0
 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);
     }
 }
Beispiel #3
0
        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;
        }
Beispiel #4
0
        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);
        }
Beispiel #5
0
 public FileContents DownloadFile(IFileSyncModel connection, Credentials c,
                                  MachineIdentity m, DirectoryIdentity d, FileIdentity f)
 {
     throw new NotImplementedException();
 }
Beispiel #6
0
 public bool UploadFile(IFileSyncModel connection, Credentials c, MachineIdentity m,
                        DirectoryIdentity d, FileContents f)
 {
     return(connection.AddFile(c, new MachineContents(m), new DirectoryContents(d), f));
 }
Beispiel #7
0
 public bool UpdateMachine(IFileSyncModel connection, Credentials c, MachineContents newM,
                           MachineContents oldM)
 {
     throw new NotImplementedException();
 }
Beispiel #8
0
        public FileContents DownloadFile(IFileSyncModel connection, Credentials c,
				MachineIdentity m, DirectoryIdentity d, FileIdentity f)
        {
            throw new NotImplementedException();
        }
Beispiel #9
0
 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);
     }
 }
Beispiel #10
0
        public bool UploadFile(IFileSyncModel connection, Credentials c, MachineIdentity m,
				DirectoryIdentity d, FileContents f)
        {
            return connection.AddFile(c, new MachineContents(m), new DirectoryContents(d), f);
        }
Beispiel #11
0
        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;
        }
Beispiel #12
0
        public bool UpdateMachine(IFileSyncModel connection, Credentials c, MachineContents newM,
				MachineContents oldM)
        {
            throw new NotImplementedException();
        }