コード例 #1
0
        //Invoked by "BatchExtract".
        public void BatchExtract(string indexString, string folderPath, NamingInfo namingInfo)
        {
            progressBar.Visibility = Visibility.Visible;
            progressBar.Value      = 0;
            PBSetValue(5);

            XmlDocument smryXml     = GetRightSummaryXml();
            XmlNodeList summaryList = smryXml.GetElementsByTagName("Summary");

            PBSetValue(20);

            //Create file name ArrayList by users selected naming method.
            ArrayList fileNames = new ArrayList();

            switch (namingInfo.namingMethod)
            {
            case NamingMethod.Enumerate:
                for (int i = 1; i <= summaryList.Count; i++)
                {
                    fileNames.Add(i.ToString());
                }
                break;

            case NamingMethod.Origin:
                for (int i = 0; i < summaryList.Count; i++)
                {
                    fileNames.Add(System.IO.Path.GetFileNameWithoutExtension(((XmlElement)summaryList[i]).GetAttribute("path")));
                }
                break;

            case NamingMethod.Att:
                foreach (WrapPanel tempWrap in listBox.Items)
                {
                    string contentString = (tempWrap.Children[1] as TextBlock).Text;

                    fileNames.Add(System.IO.Path.GetFileNameWithoutExtension(contentString.Substring("Content= \"".Count(), contentString.Count() - "Content= \"".Count()).TrimEnd('\"')));
                }
                break;

            case NamingMethod.Index:
                fileNames.Add(new string[1] {
                    namingInfo.indexString
                });
                break;
            }
            PBSetValue(40);

            extractInfo eInfo = new extractInfo(ref smryXml, indexString, fileNames, folderPath);

            AttachmentExtractor.Extract(eInfo);

            PBSetValue(100);

            progressBar.Visibility = Visibility.Hidden;
        }