예제 #1
0
        public static bool Compare(SplitMergeCmdFile m1, SplitMergeCmdFile m2)
        {
            if (MergeListInfoDefn.Compare(m1.MergeListInfo, m2.MergeListInfo) == false)
            {
                return(false);
            }

            if (m1.MergeListFileArray.Count != m2.MergeListFileArray.Count)
            {
                return(false);
            }

            for (int iFile = 0; iFile < m1.MergeListFileArray.Count; ++iFile)
            {
                if (MergeListFiles.Compare(m1.MergeListFileArray[iFile], m2.MergeListFileArray[iFile]) == false)
                {
                    return(false);
                }
            }

            return(true);
        }
예제 #2
0
        private int ReadXmlCommandFile(string filename)
        {
            string planFilePath = Path.GetDirectoryName(filename);

            this.MergeListFileArray = new List <MergeListFiles>();
            this.MergeListInfo      = new MergeListInfoDefn();

            MergeListFiles mergeElement = null;

            System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(filename);

            int fileNotFoundCount = 0;

            while (reader.Read())
            {
                if (reader.IsStartElement())
                {
                    switch (reader.Name.ToLower())
                    {
                    case "file":
                        if (mergeElement != null)
                        {
                            this.MergeListFileArray.Add(mergeElement);
                        }

                        mergeElement = new MergeListFiles();
                        object exclude = reader.GetAttribute("exclude");
                        if (exclude != null)
                        {
                            if (exclude.ToString() == "1")
                            {
                                mergeElement.Include = false;
                            }
                        }

                        break;

                    case "path":
                        mergeElement.Path = reader.ReadElementContentAsString();

                        // resolve paths, if files were moved
                        if (File.Exists(mergeElement.Path) == false)
                        {
                            ++fileNotFoundCount;
                        }

                        break;

                    case "pages":
                        mergeElement.Pages = reader.ReadElementContentAsString();
                        break;

                    case "bookmark":
                        mergeElement.Bookmark = reader.ReadElementContentAsString();
                        break;

                    case "level":
                        mergeElement.Level = reader.ReadElementContentAsInt();
                        break;

                    case "info":
                        this.MergeListInfo.HasInfo = true;
                        break;

                    case "author":
                        this.MergeListInfo.HasInfo    = true;
                        this.MergeListInfo.InfoAuthor = reader.ReadElementContentAsString();
                        break;

                    case "title":
                        this.MergeListInfo.HasInfo   = true;
                        this.MergeListInfo.InfoTitle = reader.ReadElementContentAsString();
                        break;

                    case "subject":
                        this.MergeListInfo.HasInfo     = true;
                        this.MergeListInfo.InfoSubject = reader.ReadElementContentAsString();
                        break;

                    case "annotation":
                        this.MergeListInfo.Annotation = reader.ReadElementContentAsString();
                        break;

                    case "outfile":
                        this.MergeListInfo.OutFilename = reader.ReadElementContentAsString();
                        break;

                    case "startpage":
                        this.MergeListInfo.StartPage   = int.Parse(reader.ReadElementContentAsString());
                        this.MergeListInfo.NumberPages = true;
                        break;

                    case "paginationformat":
                        try
                        {
                            this.MergeListInfo.PaginationFormat = (PaginationFormatting.PaginationFormats) int.Parse(reader.ReadElementContentAsString());
                        }
                        catch
                        {
                            throw new Exception("Invalid value for pagination format in command file");
                        }

                        break;
                    }
                }
            }

            if (mergeElement != null)
            {
                this.MergeListFileArray.Add(mergeElement);
            }

            reader.Close();

            return(fileNotFoundCount);
        }
예제 #3
0
        private int ReadAsciiCommandFile(string filename)
        {
            int fileMissingCount = 0;

            this.MergeListFileArray = new List <MergeListFiles>();
            this.MergeListInfo      = new MergeListInfoDefn();

            string line = string.Empty;

            try
            {
                using (StreamReader sr = new StreamReader(filename))
                {
                    while ((line = sr.ReadLine()) != null)
                    {
                        string[] args = line.Split(new char[] { ';', '\r', '\n' });
                        if (args[0].ToLower() == "[info]")
                        {
                            this.MergeListInfo.HasInfo = true;
                            if (args.Length > 1)
                            {
                                this.MergeListInfo.InfoTitle = args[1];
                            }

                            if (args.Length > 2)
                            {
                                this.MergeListInfo.InfoSubject = args[2];
                            }

                            if (args.Length > 3)
                            {
                                this.MergeListInfo.InfoAuthor = args[3];
                            }
                        }
                        else
                        {
                            MergeListFiles mergeElement = new MergeListFiles();
                            mergeElement.Path  = args[0];
                            mergeElement.Pages = args[1];
                            if (args.Length > 2)
                            {
                                if (args[2].ToUpper() == "EXCLUDE")
                                {
                                    mergeElement.Include = false;
                                }
                            }

                            if (args.Length > 3)
                            {
                                mergeElement.Bookmark = args[3];
                            }

                            if (args.Length > 4)
                            {
                                mergeElement.Level = int.Parse(args[4]);
                            }

                            this.MergeListFileArray.Add(mergeElement);
                            if (File.Exists(mergeElement.Path) == false)
                            {
                                ++fileMissingCount;
                            }
                        }
                    }
                }
            }
            catch (Exception err)
            {
                if (line != null)
                {
                    if (line.Length > 0)
                    {
                        throw new Exception(err.Message + "\nOn Line:\n" + line);
                    }
                }

                throw err;
            }

            return(fileMissingCount);
        }