/// <summary> /// Expects the directory to contain an infopath manifest.xsf & template.xml files. The contents are then persisted & /// indexed by DocTypeName & DocTypeRev (aka solutionVersion) for OpenStream & OpenText operations. As of this writing, /// this application must have write access to the parent folder of the given directory for cab compression operations. /// </summary> /// <param name="importFolderPath"></param> /// <param name="workingFolderPath">default is parent of importFolderPath</param> public static List <ImporterLightDoc> ImportContentFolder(string sourceFolderPath, string workingFolderPath = null) { List <ImporterLightDoc> List_ImporterLightDoc = new List <ImporterLightDoc>(); DirectoryInfo _DirectoryInfo = new DirectoryInfo(sourceFolderPath); if (workingFolderPath == null) { workingFolderPath = RequestPaths.GetPhysicalApplicationPath(Resources.import_DirectoryPath); } //// ensure the import folder actually exists new DirectoryInfo(workingFolderPath) .mkdir() .Attributes = FileAttributes.NotContentIndexed | FileAttributes.Hidden; string DocMD5, DocTypeVer; string DocTypeName = FilesystemTemplateController.ScanContentFolder(_DirectoryInfo, out DocTypeVer, out DocMD5); if (!DocExchange.LuceneController.List(new List <string> { EmbededInterpreter.MY_ONLY_DOC_NAME }, null, null, DocMD5).Any()) { IList <string> relativeFilePathsInDirectoryTree = GetRelativeFilePathsInDirectoryTree(_DirectoryInfo.FullName, true); IDictionary <string, string> files = CreateStringDictionary(relativeFilePathsInDirectoryTree, relativeFilePathsInDirectoryTree); IDocRev DocRevBaseDoc = (IDocRev)DocInterpreter.Instance.Create(EmbededInterpreter.MY_ONLY_DOC_NAME); DocRevBaseDoc.Target.DocTypeName = DocTypeName; DocRevBaseDoc.Target.solutionVersion = DocTypeVer; DocRevBaseDoc.DocChecksum = int.MinValue; DocRevBaseDoc.DocStatus = true; DocRevBaseDoc.DocTitle = String.Format("{0} {1}", DocTypeName, DocTypeVer); DocRevBaseDoc.DocTypeName = EmbededInterpreter.MY_ONLY_DOC_NAME; DocRevBaseDoc.MD5 = DocMD5; DocRevBaseDoc.DocKeys = new Dictionary <string, string> { { Properties.Resources.TargetDocTypeNameKey, DocTypeName }, { Properties.Resources.TargetDocTypeVerKey, DocTypeVer } }; foreach (KeyValuePair <string, string> file in files) { FileInfo AddFileInfo = new FileInfo(_DirectoryInfo.FullName + "\\" + file.Value); DocRevBaseDoc.FileList.Add( new DocRevEntry() { Bytes = AddFileInfo.OpenRead().AsBytes(), Name = file.Key }); } List_ImporterLightDoc.Add( new ImporterLightDoc { LightDoc = DocExchange.Instance.Import( DocInterpreter.Instance.WriteStream((BaseDoc)DocRevBaseDoc)) }); } return(List_ImporterLightDoc); }