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; }
/// <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 }
public MachineIdentity(MachineIdentity mid) : this(mid.Name, mid.Description) { //nothing needed here }
public bool DelDirectory(Credentials c, MachineIdentity mid, DirectoryIdentity did) { throw new NotImplementedException(); }
public bool DelMachine(Credentials c, MachineIdentity mid) { throw new NotImplementedException(); }
public MachineContents GetMachineWithDirs(Credentials c, MachineIdentity mid) { throw new NotImplementedException(); }
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; } }
public bool DelMachine(Credentials c, MachineIdentity m) { throw new NotImplementedException(); }
public bool DelFile(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 FileContents DownloadFile(IFileSyncModel connection, Credentials c, MachineIdentity m, DirectoryIdentity d, FileIdentity f) { throw new NotImplementedException(); }
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; }
/// <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 }
public bool DelDirectory(Credentials c, MachineIdentity mid, DirectoryIdentity did) { var cl = new Ref.FileSyncModelClient(); cl.Abort(); throw new NotImplementedException(); }
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); } }
public MachineIdentity(MachineIdentity mid) : this(mid.Name, mid.Description) { //nothing needed here }