private void MakeLotusFile(string localpath, FileManager fmRoot) { if (!isOkToContinue) { //check path to see if it matches starting point //if not, skip to next //if so, start import, and set isoktocontinue to true if (localpath == StartPath) { //start here isOkToContinue = true; //fmRoot = AtMng.GetFile(Convert.ToInt32(ebParentFileID.Text)); } } FileManager fm; fm = fmRoot; if (!isOkToContinue) { counter++; //continue to next in loop; don't create file/docs foreach (string subfile in System.IO.Directory.GetDirectories(localpath)) { MakeLotusFile(subfile, fm); } } else { if (chkNewFile.Checked) { iFiles++; fm = AtMng.CreateFile(fmRoot); // // NEED to set FileOpened date ... do we have that date? // string foldername = Path.GetFileName(localpath); string sectionXmlFilename = "__SectionMetadata.xml"; string fileXmlFilename = "__FileMetadata.xml"; string sectionXmlPath = Path.Combine(localpath, sectionXmlFilename); string fileXmlPath = Path.Combine(localpath, fileXmlFilename); if (counter == 0) { if (foldername == "Human Resources") { fm.CurrentFile.FileNumber = "HR"; } else { fm.CurrentFile.FileNumber = NormalizeLength(foldername, 16); } fm.CurrentFile.NameE = foldername; fm.CurrentFile.NameF = foldername; fm.CurrentFile.MetaType = "FN"; fm.CurrentFile.FileType = "F"; } else { if (System.IO.File.Exists(sectionXmlPath)) { //We are on a File Container XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(sectionXmlPath); string FileNumber = getNodeValue(xmlDoc, "FileClassDisp"); string FullFileNameNumber = getNodeValue(xmlDoc, "FileClass"); string FileClassGCDOC = getNodeValue(xmlDoc, "FileClassGCDOC"); string FileName;// = FullFileNameNumber.Substring(FileNumber.Length + 1); if (FileClassGCDOC != "") { fm.CurrentFile.MetaType = "SN"; fm.CurrentFile.FileType = "F"; FileName = FileClassGCDOC; fm.CurrentFile.FileNumber = fm.CurrentFileId.ToString(); } else { FileName = FullFileNameNumber.Substring(FileNumber.Length + 1); fm.CurrentFile.MetaType = "SN"; fm.CurrentFile.FileType = "F"; fm.CurrentFile.FileNumber = NormalizeLength(FileNumber, 16); } fm.CurrentFile.NameE = FileName; fm.CurrentFile.NameF = FileName; } else if (System.IO.File.Exists(fileXmlPath)) { //Volume fm.CurrentFile.MetaType = "FD"; if (localpath.Contains("DocRejects")) { //if localpath contains text DocRejects, it's a reject } foldername = foldername.Replace("Volume", "v."); foldername = foldername.Replace("_", "/"); fm.CurrentFile.FileNumber = fm.CurrentFileId.ToString();// NormalizeLength(foldername, 16); fm.CurrentFile.NameE = foldername; fm.CurrentFile.NameF = foldername; fm.CurrentFile.FileType = "F"; //set parent properties XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(fileXmlPath); setFilePropertiesFromXML(fm, xmlDoc, "FL", foldername); } else { //check to see if name set already; if not set defaults that should get replaced by volume child file on first pass if (fm.CurrentFile.IsNameENull()) { if (localpath.Contains("DocRejects")) { foldername = foldername.Replace("Volume", "v."); foldername = foldername.Replace("_", "/"); fm.CurrentFile.FileNumber = NormalizeLength(foldername, 16); fm.CurrentFile.NameE = foldername; fm.CurrentFile.NameF = foldername; fm.CurrentFile.MetaType = "FL"; fm.CurrentFile.FileType = "F"; } else { fm.CurrentFile.FileNumber = NormalizeLength(foldername, 16); fm.CurrentFile.NameE = "[NameNotSet]"; fm.CurrentFile.NameF = "[NameNotSet]"; fm.CurrentFile.MetaType = "FL"; fm.CurrentFile.FileType = "F"; } } } } ImportDocs(fm, localpath); atLogic.BusinessProcess bp = fm.GetBP(); bp.AddForUpdate(fm.EFile); bp.AddForUpdate(fm.GetFileXRef()); bp.AddForUpdate(fm.GetFileOffice()); bp.Update(); AddListItem("Created file " + localpath); counter++; } GC.Collect(); } if (chkInclude.Checked) { chkNewFile.Checked = true; foreach (string subfile in System.IO.Directory.GetDirectories(localpath)) { MakeLotusFile(subfile, fm); } } }
private void MakeFile(string file, FileManager fmRoot) { FileManager fm; fm = fmRoot; if (chkNewFile.Checked) { iFiles++; fm = AtMng.CreateFile(fmRoot); if (!fmRoot.CurrentFile.FileMetaTypeRow.SubFileAutoNumber) { fm.CurrentFile.FileNumber = "999"; } fm.CurrentFile.NameE = System.IO.Path.GetFileName(file); fm.CurrentFile.NameF = System.IO.Path.GetFileName(file); fm.CurrentFile.FileType = ucMultiDropDown2.SelectedValue.ToString(); atLogic.BusinessProcess bp = fm.GetBP(); bp.AddForUpdate(fm.EFile); bp.AddForUpdate(fm.GetFileXRef()); bp.AddForUpdate(fm.GetFileOffice()); bp.Update(); AddListItem("Created file " + file); } ActivityBP abp = fm.InitActivityProcess(); foreach (string doc in System.IO.Directory.GetFiles(file)) { string ext = System.IO.Path.GetExtension(doc); docDB.FileFormatRow fmt = fm.GetDocMng().DB.FileFormat.FindByFileFormat(ext); if (fmt != null && fmt.AllowUpload) { iCount++; ACEngine ace = abp.Add(DateTime.Today, acsr, null, false, null); atriumDB.ActivityRow newAc = ace.NewActivity; ace.DocumentDefaults(true); //ace.DoStep(0); //get the document from related fields docDB.DocumentRow dr = (docDB.DocumentRow)ace.relTables["Document0"][0].Row; DocumentBE.LoadFileX(dr, doc); AddListItem("Added document: " + System.IO.Path.GetFileName(doc)); ace.Save(true, false); abp.CurrentACE = null; } else { AddListItem("ILLEGAL EXTENSION: " + System.IO.Path.GetFileName(doc)); } } if (chkInclude.Checked) { chkNewFile.Checked = true; foreach (string subfile in System.IO.Directory.GetDirectories(file)) { MakeFile(subfile, fm); } } }