Exemplo n.º 1
0
 private static void SaveToDBFiles(EFile fileObject)
 {
     if (!DBController.ContainsPreviousRecord(fileObject.FileLocation))
     {
         DBController.WriteToDB("files", fileObject);
     }
 }
Exemplo n.º 2
0
        private static void SaveFile(string filename)
        {
            var fileDetails = new FileInfo(filename);
            var fileObject  = new EFile(fileDetails);
            var temp        = DBController.ReadFileDetails(fileObject.FileLocation).FileName;

            if (fileObject.FileLocation != temp)
            {
                SaveToDBFiles(fileObject);
                var encryptFile = new FileEncryptor(fileObject);
                try
                {
                    encryptFile.FileEncrypt();
                    fileObject.EncryptedHash  = encryptFile.EncryptedHash;
                    fileObject.StoredDateTime = DateTime.Now;
                    DBController.WriteToDB("storedfiles", fileObject);
                    DBController.UpdateDBState(fileObject.FileHash, "true");
                    StatusMessage.PostToRecentsBox(fileObject);
                }
                catch (Exception ex)
                {
                    StatusMessage.PostToActivityBox("Attempting Encryption: " + ex.ToString(), MessageType.ERROR);
                    StatusMessage logger = new StatusMessage();
                    logger.Log("Save button: " + ex);
                }
            }
            else
            {
                MessageBox.Show("Error, file was already saved.", "Error encrypting file", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }