Esempio n. 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);
        }
Esempio n. 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);
     }
 }
Esempio n. 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;
        }
Esempio n. 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);
        }
Esempio n. 5
0
 public FileContents DownloadFile(IFileSyncModel connection, Credentials c,
                                  MachineIdentity m, DirectoryIdentity d, FileIdentity f)
 {
     throw new NotImplementedException();
 }
Esempio n. 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));
 }
Esempio n. 7
0
 public bool UpdateMachine(IFileSyncModel connection, Credentials c, MachineContents newM,
                           MachineContents oldM)
 {
     throw new NotImplementedException();
 }
Esempio n. 8
0
        public FileContents DownloadFile(IFileSyncModel connection, Credentials c,
				MachineIdentity m, DirectoryIdentity d, FileIdentity f)
        {
            throw new NotImplementedException();
        }
Esempio n. 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);
     }
 }
Esempio n. 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);
        }
Esempio n. 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;
        }
Esempio n. 12
0
        public bool UpdateMachine(IFileSyncModel connection, Credentials c, MachineContents newM,
				MachineContents oldM)
        {
            throw new NotImplementedException();
        }