示例#1
0
 private void bindMergeData()
 {
     // restore current settings data
     if (AppOptions.mergeOrigFile.Length > 0 || AppOptions.mergeInPath.Length > 0)
     {
         tbMergeInfoFile.Text   = AppOptions.mergeInfoFile;
         tbMergeSplitFiles.Text = AppOptions.mergeInPath;
         tbMergeOrigFile.Text   = AppOptions.mergeOrigFile;
     }
     // get settings from file
     else
     {
         List <string> setts = AppSettingsFile.LoadSettings();
         if (setts.Count > 1)
         {
             if (Directory.Exists(Path.GetDirectoryName(setts[0])) && Directory.Exists(setts[1]))
             {
                 tbMergeOrigFile.Text   = setts[0];
                 tbMergeSplitFiles.Text = setts[1];
                 findSplitInfoFile(setts[1]);
             }
         }
     }
 }
示例#2
0
        private void SplitFiles()
        {
            SplitStatus status = SplitStatus.Success;
            FileParser  _splitter;
            int         filesCnt = AppOptions.splitInFiles.Count;

            try
            {
                for (int f = 0; f < filesCnt; f++)
                {
                    updateLog(string.Format(Properties.Resources.msgSplitting, AppOptions.splitInFiles.ElementAt(f).Key));
                    updateProgressFiles((f * 100) / filesCnt);
                    updateProgressStatus(string.Format(Properties.Resources.msgSplittingFiles, f + 1, filesCnt));

                    _splitter = new FileParser(AppOptions.splitInFiles.ElementAt(f).Key,
                                               AppOptions.splitInFiles.ElementAt(f).Value,
                                               AppOptions.splitOutPath);
                    _splitter.OnProgress += new FileParser.OnProgressDelegate(updateProgress);

                    _splitter.Split(AppOptions.splitOpts);

                    if (_splitter.FilesCount.HasValue && _splitter.FilesCount.Value > 0)
                    {
                        updateLog(string.Format(Properties.Resources.msgSplitScc, _splitter.FilesCount.Value));

                        #region write warnings
                        if (AppOptions.splitOpts.Criterion == SplitOptions.SplitType.EqualParts &&
                            _splitter.FilesCount.Value < AppOptions.splitOpts.PartsCount)
                        {
                            updateLog(Properties.Resources.msgSplitWarning);
                        }
                        if (AppOptions.splitOpts.Criterion == SplitOptions.SplitType.SegmentNumbers &&
                            _splitter.Warnings.Count > 0)
                        {
                            foreach (Warning wrn in _splitter.Warnings)
                            {
                                updateLog(wrn.GetMessage());
                            }
                        }
                        #endregion

                        // save last split settings
                        List <string> settsList = new List <string>(2);
                        settsList.Add(_splitter.FilePath);
                        settsList.Add(_splitter.OutPath);
                        AppSettingsFile.SaveSettings(settsList);
                    }
                    else if (_splitter.FilesCount.HasValue && _splitter.FilesCount.Value == -1)
                    {
                        updateLog(Properties.Resources.msgSplitCorruptFile);
                        status = SplitStatus.SuccessWithErrors;
                    }
                    else
                    {
                        updateLog(Properties.Resources.errSplitNoFiles);
                    }
                }
            }
            catch (Exception ex)
            {
                updateLog(string.Format(Properties.Resources.errSplitUnexp, ex.Message));
                status = SplitStatus.Fail;
            }

            updateProgress(100);
            updateProgressFiles(100);
            updateProgressStatus(string.Format(Properties.Resources.msgSplitFinished, filesCnt));

            switch (status)
            {
            case SplitStatus.Success:
                MessageBox.Show(Properties.Resources.msbSplitFinished,
                                Properties.Resources.SplitTitle,
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
                break;

            case SplitStatus.SuccessWithErrors:
                MessageBox.Show(Properties.Resources.msbSplitFinishedWithErr,
                                Properties.Resources.SplitTitle,
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
                break;

            case SplitStatus.Fail:
                MessageBox.Show(Properties.Resources.errSplit,
                                Properties.Resources.SplitTitle,
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                break;
            }

            changeButtonsView(true);
        }