internal override CommandLine Parse(string[] args)
        {
            if (args.Length < 1)
            {
                throw new CommandLineException(Properties.Resources.InvalidNumberOfOptions);
            }

            int currentArg = ProcessOptions(args, optionParams);

            //we know that there is, at least, one more parameters: databasefile
            CheckDatabase(args[currentArg]);
            DatabaseFile = args[currentArg];
            containers   = AccessApp.ContainersFactory(DatabaseFile);

            if (++currentArg < args.Length)
            {
                if (args[currentArg][0] == '@')
                {
                    ProcessResponseFile(args[currentArg].Substring(1));
                }
                else
                {
                    ProcessFiles(args, currentArg);
                }
            }
            else
            {
                ProcessResponseFile(Console.In);
            }

            return(this);
        }
Example #2
0
        /// <summary>
        /// Gets an array of objects names for a specific object container
        /// </summary>
        /// <param name="objectType">object type to get its objects</param>
        public string[] ObjectNames(ObjectType objectType)
        {
            string[] result = new string[0];
            if (tree.Nodes.Count == 0)
            {
                return(result);
            }

            Containers          containers = AccessApp.ContainersFactory(tree.Nodes[0].Text);
            ObjectTypeExtension ote        = containers.Find(objectType);

            if (ote != null)
            {
                ContainerNames names      = ote.Container;
                TreeNode[]     matchNodes = tree.Nodes[0].Nodes.Find(names.DisplayPluralName, true);
                if (matchNodes.Length == 1)
                {
                    result = new string[matchNodes[0].Nodes.Count];
                    for (int i = 0; i < matchNodes[0].Nodes.Count; i++)
                    {
                        result[i] = matchNodes[0].Nodes[i].Text;
                    }
                }
            }
            return(result);
        }
Example #3
0
        /// <summary>
        /// Enumerate the allowed object types and, for each, the list of objects for that type
        /// </summary>
        /// <param name="app">Access application</param>
        /// <exception cref="ArgumentNullException"> if <paramref name="app"/> is null</exception>
        private void FillObjectTree(AccessIO.AccessApp app)
        {
            //TODO: Do the work in background
            if (app == null)
            {
                throw new ArgumentNullException("app");
            }

            const string key = "db";

            Images                = new TreeImages(AccessApp.ContainersFactory(fileName));
            tree.ImageList        = Images.ImageList;
            tree.ImageKey         = key;
            tree.SelectedImageKey = key;

            tree.Nodes.Clear();
            TreeNode root = tree.Nodes.Add(Path.GetFileName(app.FileName));

            root.ToolTipText = app.FileName;
            foreach (ContainerNames container in app.AllowedContainers)
            {
                TreeNode subItem = root.Nodes.Add(container.DisplayPluralName);
                subItem.ImageKey         = container.DefaultExtension.ToString();
                subItem.SelectedImageKey = container.DefaultExtension.ToString();
                foreach (IObjecOptions item in app.LoadObjectNames(container.InvariantName))
                {
                    TreeNode node = new TreeNode(item.Name);
                    node.Tag              = item;
                    node.ImageKey         = app.AllowedContainers.Find(item.ObjectType).FileExtension.ToString();
                    node.SelectedImageKey = node.ImageKey;
                    subItem.Nodes.Add(node);
                }
            }
        }
Example #4
0
        private void FillTree(string rootPath)
        {
            if (String.IsNullOrEmpty(rootPath))
            {
                return;
            }

            if (!Directory.Exists(rootPath))
            {
                throw new ArgumentException(Properties.Resources.RootPathNotValid);
            }

            tree.Nodes.Clear();

            TreeNode rootNode = new TreeNode(BuildRootNodeText(rootPath));

            tree.Nodes.Add(rootNode);

            //Get the list of containers depending on the 'database properties' file
            //If do not exists that file, containers will be null and we don't know what folders structure should to expect
            Containers containers = AccessApp.ContainersFactory(rootNode.Text);

            if (containers == null)
            {
                rootNode.Nodes.Add(Properties.Resources.EmptyFileStructure);
                tree.CheckBoxes = false;
                return;
            }
            else
            {
                tree.CheckBoxes = true;
            }

            const string key = "folder";

            Images                = new TreeImages(containers);
            tree.ImageList        = Images.ImageList;
            tree.ImageKey         = key;
            tree.SelectedImageKey = key;

            DirectoryInfo rootDirectory             = new DirectoryInfo(rootPath);
            IEnumerable <DirectoryInfo> directories = rootDirectory.EnumerateDirectories();

            foreach (ContainerNames names in containers)
            {
                TreeNode node = rootNode.Nodes.Add(names.InvariantName, names.InvariantName);
                node.ImageKey         = names.DefaultExtension.ToString();
                node.SelectedImageKey = node.ImageKey;

                DirectoryInfo di = directories.FirstOrDefault <DirectoryInfo>(d => d.Name == names.InvariantName);
                if (di != null)
                {
                    FillContainerFiles(di, node, names.ObjectTypes);
                }
            }
        }
        private void ProcessAccessObject(string accessObjectName)
        {
            Regex regex = new Regex(@"([a-z]{3})\.(.+)", RegexOptions.IgnoreCase);
            Match match = regex.Match(accessObjectName);

            if (!match.Success)
            {
                throw new CommandLineException(Properties.Resources.InvalidObjectName);
            }

            AccessIO.FileExtensions fileExtension;
            if (!Enum.TryParse <AccessIO.FileExtensions>(match.Groups[1].Value, out fileExtension))
            {
                throw new CommandLineException(Properties.Resources.InvalidObjectName);
            }

            Containers containers = AccessApp.ContainersFactory(DatabaseFile);

            Objects.Add(new AccessIO.ObjectOptions(match.Groups[2].Value, containers.Find(fileExtension).ObjectType));
        }