Exemple #1
0
 /// <summary>
 /// Returns a copy of the given file, also keeps the version number
 /// </summary>
 /// <param name="file">File to copy</param>
 public File(File file)
 {
     this.Name = file.Name;
     this.Content = file.Content;
     this.Created = file.Created;
     this.LastEdited = file.LastEdited;
     this.Version = file.Version;
 }
Exemple #2
0
 /// <summary>
 /// Returns a copy of a file and makes a log entry
 /// </summary>
 /// <param name="file"></param>
 /// <returns>The downloaded file</returns>
 public File DownloadFile(File file, Client client)
 {
     ConsoleHelper.WriteLine("Copying " + file.Name, Controller.DefaultColor);
     File ret = new File(file);
     this.Log.Add(DateTime.Now + " - " + client.ID + " initiated a download for " + file.Name);
     ConsoleHelper.WriteLine("Succesfully copied " + file.Name, Controller.DefaultSuccesColor);
     return ret;
 }
Exemple #3
0
 public void Update(File file)
 {
     this.Content = file.Content;
     this.LastEdited = DateTime.Now;
     this.Version++;
 }
Exemple #4
0
        /// <summary>
        /// Upload a file to the storage
        /// </summary>
        /// <param name="file"></param>
        /// <param name="client"></param>
        public void UploadFile(File file, Client client)
        {
            foreach (File f in this.Files)
            {
                if (f.Name == file.Name)
                {
                    ConsoleHelper.WriteLine("Uploading file", Controller.DefaultColor);
                    f.Update(file);
                    ConsoleHelper.WriteLine("Upload succesfull", Controller.DefaultSuccesColor);

                    Log.Add(DateTime.Now + " - " + client.ID + " uploaded " + file.Name + " version " + file.Version);
                    return;
                }
            }
            ConsoleHelper.WriteLine("Could not find file. Creating new file", Controller.DefaultColor);
            file.VersionReset();
            Files.Add(file);
            ConsoleHelper.WriteLine("Upload succesfull", Controller.DefaultSuccesColor);
            Log.Add(DateTime.Now + " - " + client.ID + " uploaded " + file.Name + " version " + file.Version);
        }