Ejemplo 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;
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Creates new contents of the machine.
 /// </summary>
 /// <param name="mid">ientity of the machine</param>
 /// <param name="directories">list of directories of the machine</param>
 public MachineContents(MachineIdentity mid, List<DirectoryContents> directories = null)
     : this(mid.Name, mid.Description, directories)
 {
     //nothing needed here
 }
Ejemplo n.º 3
0
 public MachineIdentity(MachineIdentity mid)
     : this(mid.Name, mid.Description)
 {
     //nothing needed here
 }
Ejemplo n.º 4
0
 public bool DelDirectory(Credentials c, MachineIdentity mid, DirectoryIdentity did)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 5
0
 public bool DelMachine(Credentials c, MachineIdentity mid)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 6
0
 public MachineContents GetMachineWithDirs(Credentials c, MachineIdentity mid)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 7
0
        public MachineContents GetMachineWithDirs(Credentials c, MachineIdentity m)
        {
            MachineContents mc = new MachineContents(m);

            using (filesyncEntitiesNew context = new filesyncEntitiesNew())
            {
                int mach_id = MachineNameToId(context, m.Name);
                if (mach_id == -1)
                    return null;
                mc.Id = mach_id;
                List<DirectoryContents> dirlist = new List<DirectoryContents>();

                foreach (var x in (from md in context.MachineDirs
                                   join d in context.Dirs on md.dir_id equals d.dir_id
                                   where md.machine_id == mach_id
                                   select new { md.dir_realpath, d }))
                {
                    var dir = new DirectoryContents(x.d.dir_name, x.d.dir_description, x.dir_realpath);
                    dir.Id = x.d.dir_id;
                    dir.Owner = x.d.user_ownerid;
                    dirlist.Add(dir);
                }
                mc.Directories = dirlist;
                return mc;
            }
        }
Ejemplo n.º 8
0
 public bool DelMachine(Credentials c, MachineIdentity m)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 9
0
 public bool DelFile(Credentials c, MachineIdentity m, DirectoryIdentity d,
         FileIdentity f)
 {
     throw new NotImplementedException();
 }
Ejemplo 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);
        }
Ejemplo n.º 11
0
        public FileContents DownloadFile(IFileSyncModel connection, Credentials c,
				MachineIdentity m, DirectoryIdentity d, FileIdentity f)
        {
            throw new NotImplementedException();
        }
Ejemplo n.º 12
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;
        }
Ejemplo n.º 13
0
 /// <summary>
 /// Creates new contents of the machine.
 /// </summary>
 /// <param name="mid">ientity of the machine</param>
 /// <param name="directories">list of directories of the machine</param>
 public MachineContents(MachineIdentity mid, List <DirectoryContents> directories = null)
     : this(mid.Name, mid.Description, directories)
 {
     //nothing needed here
 }
Ejemplo n.º 14
0
 public bool DelDirectory(Credentials c, MachineIdentity mid, DirectoryIdentity did)
 {
     var cl = new Ref.FileSyncModelClient();
     cl.Abort();
     throw new NotImplementedException();
 }
Ejemplo n.º 15
0
        public MachineContents GetMachineWithDirs(Credentials c, MachineIdentity mid)
        {
            var cl = new Ref.FileSyncModelClient();
            try {
                if (c == null)
                    throw new ArgumentNullException("c", "user credentials must be provided");
                if (mid == null)
                    throw new ArgumentNullException("mid", "machine identity was null");

                MachineContents newM = new MachineContents(mid);
                newM.Directories = cl.GetDirList(c, newM);
                cl.Close();
                if (newM == null)
                    throw new ActionException("Received a null object.", ActionType.User);
                return newM;

                //MachineContents m = null;
                //m = cl.GetMachineWithDirs(c, mid);
                //cl.Close();
                //return m;
            } catch (Exception ex) {
                cl.Abort();
                throw new ActionException("Unable to get list of directories belonging "
                    + "to the machine.", ActionType.Machine, ex);
            }
        }
Ejemplo n.º 16
0
 public MachineIdentity(MachineIdentity mid)
     : this(mid.Name, mid.Description)
 {
     //nothing needed here
 }