コード例 #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {
                AppDomain.CurrentDomain.AssemblyResolve += onResolve;
                AppDomain.CurrentDomain.AssemblyLoad    += onLoad;
                trySetIcon();
                String dir = Assembly.GetExecutingAssembly().Location;

                StringDict dirs = new StringDict();
                dir = IOUtils.FindDirectoryToRoot(Path.GetDirectoryName(dir), "ImportDirs");
                if (dir != null)
                {
                    dirs.Add(dir, null);
                }

                StringDict files = new StringDict();
                foreach (var f in History.LoadHistory(HISTORY_KEY))
                {
                    files[f] = null;
                    dir      = Path.GetDirectoryName(Path.GetDirectoryName(f));
                    if (!String.IsNullOrEmpty(dir))
                    {
                        dirs[dir] = null;
                    }
                }

                foreach (var kvp in dirs)
                {
                    FileTree tree = new FileTree();
                    tree.AddFileFilter(@"\\import\.xml$", true);
                    tree.ReadFiles(kvp.Key);
                    if (tree.Files.Count != 0)
                    {
                        tree.Files.Sort();
                        foreach (var relfile in tree.Files)
                        {
                            files[tree.GetFullName(relfile)] = null;
                        }
                    }
                }

                ac = new DirectoryAutocompleter(comboBox1, files.Select(kvp => kvp.Key).ToList());
                if (comboBox1.Items.Count > 0)
                {
                    comboBox1.SelectedIndex = 0;
                }
            }
            catch (Exception ex)
            {
                Logs.ErrorLog.Log(ex);
                throw;
            }
        }
コード例 #2
0
        private static void addFilters(FileTree tree, XmlNodeList nodes, bool isDir)
        {
            foreach (XmlNode node in nodes)
            {
                String incl = XmlUtils.ReadStr(node, "@incl", null);
                String excl = XmlUtils.ReadStr(node, "@excl", null);
                if (incl == null && excl == null)
                {
                    throw new BMNodeException(node, "At least 1 of the attributes incl or excl must be present.");
                }

                if (incl != null)
                {
                    if (isDir)
                    {
                        tree.AddDirFilter(incl, true);
                    }
                    else
                    {
                        tree.AddFileFilter(incl, true);
                    }
                }

                if (excl != null)
                {
                    if (isDir)
                    {
                        tree.AddDirFilter(excl, false);
                    }
                    else
                    {
                        tree.AddFileFilter(excl, false);
                    }
                }
            }
        }
コード例 #3
0
        public FileStreamDirectory(PipelineContext ctx, XmlElement node, XmlElement parentNode)
            : base(ctx, node)
        {
            VirtualRoot = XmlUtils.ReadStr(node, "@virtualroot", null);
            if ("<dir>".Equals(VirtualRoot, StringComparison.OrdinalIgnoreCase))
            {
                VirtualRoot         = null;
                VirtualRootFromFile = true;
            }
            Sort        = node.ReadEnum("@filesort", SortMode.FileName | SortMode.Desc);
            ExportDirs  = node.ReadBool("@exportdirs", false);
            IgnoreDates = node.ReadBool("@ignoredates", false);
            if ((ctx.ImportFlags & _ImportFlags.FullImport) != 0)
            {
                IgnoreDates = true;
            }

            String file = node.ReadStr("@file", null);
            String root = node.ReadStr("@root", null);

            if (file == null && root == null)
            {
                throw new BMNodeException(node, "Missing file/root attribute.");
            }

            if (root != null && file != null)
            {
                file = Path.Combine(root, file);
                root = null;
            }

            if (file != null)
            {
                recursive = XmlUtils.ReadBool(node, "@recursive", false);
                File      = ctx.ImportEngine.Xml.CombinePath(file);
                RootLen   = 1 + IOUtils.DelSlash(Path.GetDirectoryName(File)).Length;
                //ctx.ImportLog.Log("File={0}, root={1}, len={2}", File, IOUtils.DelSlash(Path.GetDirectoryName(File)), RootLen);
            }
            else
            {
                tree    = new FileTree();
                Root    = root = ctx.ImportEngine.Xml.CombinePath(root);
                RootLen = root.Length;
                if (root[root.Length - 1] != '\\')
                {
                    RootLen++;
                }

                recursive = XmlUtils.ReadBool(node, "@recursive", true);
                String filter = XmlUtils.ReadStr(node, "@filter", null);

                tree.OnFile      += tree_OnFile;
                tree.OnFileError += fileTree_OnFileError;

                if (filter != null)
                {
                    tree.AddFileFilter(filter, true);
                }

                addFilters(tree, node.SelectNodes("dir"), true);
                addFilters(tree, node.SelectNodes("file"), false);
            }
        }