public static CollectionOcrData FromCollection(ITisCollectionData collection) #endif { try { if (collection != null) { CollectionOcrData res = new CollectionOcrData(); res.CollectionID = collection.Name; res.FlowType = collection.FlowType; List <PageOcrData> pgs = new List <PageOcrData>(); //-- Iterate collection pages and add them to the class Pages property. --\\ foreach (ITisPageData page in collection.Pages) { pgs.Add(PageOcrData.FromPRD(page)); } if (pgs != null && pgs.Count > 0) { res.pages = pgs.ToArray(); return(res); } } else { throw new Exception(String.Format("ITisCollectionData specified in: [{0}] is not valid", MethodBase.GetCurrentMethod().Name)); } } catch (Exception ex) { ILog.LogError(ex); } return(null); }
/// <summary> /// Show an open file dialog for source PRD and save File dialog for atrget XML, then convert source PRD to XML. /// when multiple are selected they will be inserted into one XML file representing a collection /// </summary>> public static bool PRDToXml(string targetXML, params string[] sourcePRDs) { try { if (File.Exists(targetXML)) { File.Delete(targetXML); } if (sourcePRDs != null && sourcePRDs.Length == 1) { if (PageOcrData.FromPRD(sourcePRDs[0]).ToXml(targetXML) && File.Exists(targetXML)) { ILog.LogDebug(string.Format("Done converting PRD file [{0}] to XML file [{1}]", sourcePRDs[0], targetXML)); return(true); } } else if (sourcePRDs != null && sourcePRDs.Length > 1) { CollectionOcrData collOcr = new CollectionOcrData(); List <PageOcrData> pages = new List <PageOcrData>(); foreach (string srcPrd in sourcePRDs) { if (File.Exists(srcPrd)) { pages.Add(PageOcrData.FromPRD(srcPrd)); } } collOcr.pages = pages.ToArray(); collOcr.CollectionID = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss fffff"); return(collOcr.ToXml(targetXML)); } } catch (Exception ex) { ILog.LogError(ex); } return(false); }