private static DirContents FromDatabase(Credentials cr, MachineIdentity mid, DirIdentity did, bool downloadFilesContents = false) { List <FileContents> files = new List <FileContents>(); var c = cr.ToLib(); var m = mid.ToLib(); DirModel d = did.ToLib(); try { FileManipulator.GetFileList(c, m, d); foreach (FileModel f in d.Files) { if (downloadFilesContents) { //adding contents to 'f' FileManipulator.GetFileContent(c, m, d, f); } //adding new gui object to list files.Add(new FileContents(f)); } } catch (ActionException ex) { throw new ActionException("Unable to download directory contents.\n\n" + ex.Message + ".", ActionType.Directory, MemeType.Fuuuuu, ex); } catch (Exception ex) { throw new ActionException("Error while downloading directory contents.", ActionType.Directory, MemeType.Fuuuuu, ex); } //does not add local files, because this is supposed to happen in the constructor that // launches this static private method return(new DirContents(did, files, false)); }
public ActionResult Upload(Credentials cr, MachineIdentity mid, DirIdentity did) { try { FileManipulator.AddFile(cr.ToLib(), mid.ToLib(), did.ToLib(), this.ToLib()); } catch (Exception ex) { throw new ActionException("Error occurred while file was uploaded.", ActionType.File, MemeType.Fuuuuu, ex); } return(new ActionResult("File uploaded.", "File was put into the database.", ActionType.File)); }
private static FileContents FromDatabase(Credentials cr, MachineIdentity mid, DirIdentity did, FileIdentity fid) { FileModel f = null; try { f = fid.ToLib(); FileManipulator.GetFileContent(cr.ToLib(), mid.ToLib(), did.ToLib(), f); } catch (Exception ex) { throw new ActionException("Error while downloading file contents from database.", ActionType.File, MemeType.Fuuuuu, ex); } return(new FileContents(f)); }