Ejemplo n.º 1
0
        private void OpenProjectFileForZipping()
        {
            SerializableTreeNode serializedTreeNode;

            if (applicationArgumentModel.IsFileOpenCase)
            {
                serializedTreeNode = projectSession.GetSerializableTreeNodeBaseOnProjectFile(applicationArgumentModel.FilePath);
            }
            else
            {
                serializedTreeNode = projectSession.GetSerializableTreeNodeBaseOnZipModel();
            }
            this.zipModel = projectSession.ZipFileModel;
            if (IsDirectoryValidAndAccessible(this.zipModel.MainTargetLocationDirectory))
            {
                String newArchiveName = zipModel.GetFullPathFileAndNameOfNewZipArchive;
                this.Text = this.Text + " => " + Path.GetFileName(newArchiveName);
                zipArchiving.NewArchiveName            = newArchiveName;
                zipArchiving.SerializableTreeNode      = serializedTreeNode;
                zipArchiving.ZipFileModelSource        = zipModel;
                zipArchiving.CompressionLevelArchiving = CompressionLevel.BestCompression;
                zipArchiving.StartArchiving();
            }
            else
            {
                MessageBox.Show(String.Format("The target location for archiving '{0}' is not accessible!",
                                              this.zipModel.MainTargetLocationDirectory),
                                "Access Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                isWindowCanBeClose = true;
                btnStop.Enabled    = false;
            }
        }
Ejemplo n.º 2
0
 public ZipArchiving(String newArchiveName, ZipFileModel zipFileModel, SerializableTreeNode serializableTreeNode)
 {
     this.NewArchiveName       = newArchiveName;
     this.ZipFileModelSource   = zipFileModel;
     this.SerializableTreeNode = serializableTreeNode;
     PrepareEventsVariablesArgs();
 }
Ejemplo n.º 3
0
        public async Task <IActionResult> Upload([FromBody] ZipFileModel model)
        {
            try
            {
                var key = _configuration["Key"];
                var IV  = _configuration["IV"];
                if (model.EncryptText.Length == 0)
                {
                    throw new ArgumentNullException("Encrypted Source file size is zero.");
                }
                if (key == null || key.Length == 0)
                {
                    throw new ArgumentNullException("Symmetric key is null.");
                }
                if (IV == null || IV.Length == 0)
                {
                    throw new ArgumentNullException("Initilization Vector is null.");
                }

                byte[] encryptedByte         = Convert.FromBase64String(model.EncryptText);
                AesCryptoServiceProvider aes = new AesCryptoServiceProvider();
                aes.BlockSize = 128;
                aes.KeySize   = 256;
                aes.Key       = System.Text.ASCIIEncoding.ASCII.GetBytes(key);
                aes.IV        = System.Text.ASCIIEncoding.ASCII.GetBytes(IV);
                aes.Padding   = PaddingMode.PKCS7;
                aes.Mode      = CipherMode.CBC;
                ICryptoTransform crypto    = aes.CreateDecryptor(aes.Key, aes.IV);
                byte[]           decrypted = crypto.TransformFinalBlock(encryptedByte, 0, encryptedByte.Length);
                var filepaths = System.Text.ASCIIEncoding.ASCII.GetString(decrypted);
                await _fileService.SaveFile(filepaths);

                return(Ok());
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
Ejemplo n.º 4
0
 public void SaveProject(String fullFilePath, ZipFileModel customZipModel)
 {
     FileSerialization.SaveObjectToFile(Serialization.BinarySerialization, fullFilePath, customZipModel);
 }
Ejemplo n.º 5
0
        public SerializableTreeNode GetSerializableTreeNodeBaseOnProjectFile(String fileFullPath)
        {
            ZipFileModel zipFileModel = OpenProjectSession(fileFullPath);

            return(zipFileModel.GetTreeViewZipFileSerializedStructure);
        }
Ejemplo n.º 6
0
        public TreeNodeExtended GetTreeNodeZipDesignOnProjectFile(String fileFullPath)
        {
            ZipFileModel zipFileModel = OpenProjectSession(fileFullPath);

            return(zipFileModel.GetTreeViewZipFileStructure());
        }
Ejemplo n.º 7
0
 public ZipFileModel OpenProjectSession(String fileFullPath)
 {
     ZipFileModel          = FileSerialization.LoadObjectToFile <ZipFileModel>(Serialization.BinarySerialization, fileFullPath);
     ZipFileModel.FilePath = fileFullPath;
     return(ZipFileModel);
 }
Ejemplo n.º 8
0
 public void ClearProjectSession()
 {
     ZipFileModel             = new ZipFileModel();
     ApplicationArgumentModel = new ApplicationArgumentModel(new string[] { });
 }