Example #1
0
        private void DgList_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
        {
            _Dvo = DgList.SelectedItem as FileDvo;
            if (_Dvo == null)
            {
                return;
            }

            LbRule.ItemsSource = _Dvo.OptionalList;
            LcSrc.Text         = _Dvo.SrcFile;
            LcDst.Text         = _Dvo.DstPath;
        }
Example #2
0
        public virtual bool Test(RuleDto rule, FileDvo file)
        {
            var fileMatch = !string.IsNullOrWhiteSpace(rule.src_file) ? IsMatch(file.SrcFile, rule.src_file, true) : true;
            var srcFile   = Path.Combine(file.SrcPath, file.SrcFile);
            var pathMatch = !string.IsNullOrWhiteSpace(rule.src_path) ? IsMatch(file.SrcPath + Path.DirectorySeparatorChar, rule.src_path, false) : true;

            if (fileMatch && pathMatch)
            {
                file.DstPath = rule.dst_path;
                file.DstFile = GenFileName(srcFile, rule.dst_file);
                file.DstName = System.IO.Path.Combine(file.DstPath, file.DstFile);
                return(true);
            }

            return(false);
        }
Example #3
0
        public void Init(IEnumerable <RuleDto> rules, params string[] args)
        {
            _Files = new ObservableCollection <FileDvo>();
            if (args != null)
            {
                foreach (var arg in args)
                {
                    var dto = new FileDvo {
                        SrcPath = System.IO.Path.GetDirectoryName(arg), SrcFile = System.IO.Path.GetFileName(arg)
                    };
                    MatchRule(rules, dto);
                    _Files.Add(dto);
                }
            }

            DgList.ItemsSource = _Files;
        }
Example #4
0
        private void MatchRule(IEnumerable <RuleDto> rules, FileDvo dto)
        {
            var list = new List <RuleDto>();
            var opt  = new AFileOpt();

            foreach (var rule in rules)
            {
                if (opt.Test(rule, dto))
                {
                    list.Add(rule);
                }
            }
            dto.OptionalList = list;
            if (list.Count == 1)
            {
                dto.CurrentRule = list[0];
            }
        }
Example #5
0
        public override void Deal(RuleDto rule, FileDvo file)
        {
            var src = System.IO.Path.Combine(file.SrcPath, file.SrcFile);

            if (!Directory.Exists(file.DstPath))
            {
                Directory.CreateDirectory(file.DstPath);
            }

            if (Directory.Exists(src))
            {
                CopyTo(new DirectoryInfo(src), file.DstPath);
                return;
            }

            if (File.Exists(src))
            {
                CopyTo(new FileInfo(src), Path.Combine(file.DstPath, file.DstFile));
                return;
            }
        }
Example #6
0
 public virtual void Deal(RuleDto rule, FileDvo file)
 {
 }
Example #7
0
 public override void Deal(RuleDto rule, FileDvo file)
 {
 }