/// <summary>
        /// Add a file to transfer to the transfer Queue
        /// Files will be transferred one at a time
        /// </summary>
        public void AddFileToTransferAsync(ZipEntity zipEntity, ZipWatcherPreferences zipWatcherPreferences)
        {
            zipEntity.RemoteOutputPath     = CalculateRemotePath(zipEntity, zipWatcherPreferences);
            zipEntity.RemoteOutputFileName = CalculateRemoteFileName(zipEntity, zipWatcherPreferences);
            AllLogWriter.Instance.LogMessage($"\nAdding file to Queue for transferring from: {zipEntity.ZipFileName} to  {zipEntity.RemoteOutputPath}");
            // zipEntity.RemoteOutputFolder=



            if (!(_isZipFileTaskRunning))
            {
                _zipFileTask = TransferringFiles();
            }

            _zipTranferQueue.Add(zipEntity);
        }
Example #2
0
        private void Call7zip(ZipWatcherPreferences zipWatcherPreferences, ZipEntity zipEntity)
        {
            Process sevenZip = new Process();

            if (!(string.IsNullOrEmpty(zipWatcherPreferences.PathTo7Zip)))
            {
                sevenZip.StartInfo.WorkingDirectory = zipWatcherPreferences.PathTo7Zip;
            }

            sevenZip.StartInfo.UseShellExecute        = false;
            sevenZip.StartInfo.RedirectStandardOutput = true;

            sevenZip.StartInfo.Arguments = $"/c {Path.Combine(zipWatcherPreferences.PathTo7Zip, "7z.exe")} a -m0=lzma2 -r -y \"{zipEntity.ZipFileName}\" \"{zipEntity.BackupFileName}\" ";
            sevenZip.StartInfo.FileName  = "cmd.exe";
            try
            {
                FileLogWriter.Instance.LogMessage("Starting 7zip");
                FileLogWriter.Instance.LogMessage($"7zip Commandline {Path.Combine(sevenZip.StartInfo.WorkingDirectory, "cmd.exe")} {sevenZip.StartInfo.Arguments} ");

                sevenZip.Start();
                _isSevenZipRunning = true;

                while (!(sevenZip.StandardOutput.EndOfStream) && _isSevenZipRunning)
                {
                    FileLogWriter.Instance.LogMessage($"\t{sevenZip.StandardOutput.ReadLine()}");
                }

                if (_isSevenZipRunning == true)
                {
                    sevenZip.WaitForExit();
                }

                FileLogWriter.Instance.LogMessage($"Finished Compressing {zipEntity.ZipFileName}");
                _isSevenZipRunning = false;
            }
            catch (Exception e)
            {
                AllLogWriter.Instance.LogErrorMessage(e.ToString());
            }
        }
Example #3
0
 public void CompressFIle(ZipEntity zipEntity)
 {
 }
Example #4
0
        private void UpdateZipFileNameAndPath(ZipEntity zEntity)
        {
            var filename = Path.GetFileNameWithoutExtension(zEntity.BackupFileName);

            zEntity.ZipFileName = $"{Path.Combine(_zipWatcherPreferences.OutPutFolderFor7zip, filename)}.7z";
        }
        /// <summary>
        /// Determines the name of the remote folder and filename to transfer
        /// </summary>
        /// <param name="zipEntity"></param>
        /// <param name=""></param>
        /// <returns></returns>
        private string CalculateRemoteFileName(ZipEntity zipEntity, ZipWatcherPreferences zipWatcherPreferences)
        {
            string fileName = Path.GetFileName(zipEntity.ZipFileName);

            return(Path.Combine(zipWatcherPreferences.EndResultPath, DateTime.Now.GetYearMonthDay(), fileName ?? throw new InvalidOperationException()));
        }
 /// <summary>
 /// Determines the name of the remote folder to transfer the zip file
 /// </summary>
 /// <param name="zipEntity"></param>
 /// <param name=""></param>
 /// <returns></returns>
 private string CalculateRemotePath(ZipEntity zipEntity, ZipWatcherPreferences zipWatcherPreferences)
 {
     return(Path.Combine(zipWatcherPreferences.EndResultPath, DateTime.Now.GetYearMonthDay()));
 }