private void CreateDocument(FileManager fm, ActivityBP abp, string lotusDocId, string documentPath, string docSubject, DateTime docDate, List <string> listOfDocAttachments) { string ext = System.IO.Path.GetExtension(documentPath); docDB.FileFormatRow fmt = fm.GetDocMng().DB.FileFormat.FindByFileFormat(ext); if (fmt != null && fmt.AllowUpload) { iCount++; ACEngine ace = abp.Add(docDate, acsr, null, false, null); atriumDB.ActivityRow newAc = ace.NewActivity; ace.DocumentDefaults(true); docDB.DocumentRow dr = (docDB.DocumentRow)ace.relTables["Document0"][0].Row; DocumentBE.LoadFileX(dr, documentPath); dr.efSubject = docSubject; dr.efDate = docDate; dr.Source = "Lotus: " + lotusDocId; dr.IsDraft = false; AddListItem("Document added: " + System.IO.Path.GetFileName(documentPath)); if (listOfDocAttachments.Count > 0) { DocManager myDM = fm.GetDocMng(); atriumBE.AttachmentBE d = myDM.GetAttachment(); foreach (string attachment in listOfDocAttachments) { string localAttach = attachment; string attExt = Path.GetExtension(localAttach); if (attExt.Length > 10) { attExt = attExt.Substring(0, 10); //modify extension on disk File.Move(attachment, Path.ChangeExtension(attachment, attExt)); localAttach = Path.Combine(Path.GetDirectoryName(attachment), Path.GetFileNameWithoutExtension(attachment) + attExt); } //if extension is empty, modify doc extension //.LONOEXT if (string.IsNullOrEmpty(attExt)) { AddExtensionToDocWithoutExt(attachment); attExt = ".LONOEXT"; localAttach = localAttach + attExt; } docDB.FileFormatRow attFmt = fm.GetDocMng().DB.FileFormat.FindByFileFormat(attExt); //if extension not allowed, add it if (attFmt == null) { AddExtensionToFileFormatTable(attExt, fm.GetDocMng().DB.FileFormat); attFmt = fm.GetDocMng().DB.FileFormat.FindByFileFormat(attExt); } if (attFmt != null && attFmt.AllowUpload) { docDB.DocumentRow newDoc = (docDB.DocumentRow)myDM.GetDocument().Add(myDM.FM.CurrentFile, localAttach); int indexOfSpaceInAttachment = localAttach.IndexOf(' ') - 1; newDoc.efSubject = Path.GetFileNameWithoutExtension(localAttach).Substring(indexOfSpaceInAttachment).TrimStart(' '); //atts start with 6 digit lotus docNumber + space; let's remove that before import newDoc.efType = "ATT"; newDoc.IsDraft = false; newDoc.efDate = newDoc.DocContentRow.ModDate; newDoc.Source = "Lotus: " + lotusDocId; lmDatasets.docDB.AttachmentRow att = (lmDatasets.docDB.AttachmentRow)d.Add(dr); att.AttachmentId = newDoc.DocId; att.Version = newDoc.CurrentVersion; AddListItem("Attachment added: " + System.IO.Path.GetFileName(localAttach)); } else { AddListItem("Attachment - Extension not permitted: " + System.IO.Path.GetFileName(localAttach)); ExtTW.WriteLine(attExt + ", " + localAttach); } } } ace.Save(true, false); abp.CurrentACE = null; } else { AddListItem("Extension not permitted: " + System.IO.Path.GetFileName(documentPath)); ExtTW.WriteLine(ext + ", " + documentPath); } }
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); } } }
internal void DoACAllSteps(atriumDB.ActivityRow prevAC, ActivityConfig.ACSeriesRow asr, int revId, ACEngine.RevType revType, DateTime acDate, out ACEngine ace, out atriumDB.ActivityRow newAC, Stack <ParentChildStep> _flowQ, string conversationIndex) { atriumDB.ProcessRow pr = null; if (prevAC != null) { pr = prevAC.ProcessRow; } ace = Add(acDate, asr, pr, false, prevAC, ConnectorType.NextStep, _flowQ, revId, revType, conversationIndex, null); ace.ctx = ctx; newAC = ace.NewActivity; if (ace.HasRel0) { ace.DoStep(ACEngine.Step.RelatedFields0, true); } if (ace.HasRel1) { ace.DoStep(ACEngine.Step.RelatedFields1, true); } if (ace.HasRel2) { ace.DoStep(ACEngine.Step.RelatedFields2, true); } if (ace.HasRel3) { ace.DoStep(ACEngine.Step.RelatedFields3, true); } if (ace.HasRel4) { ace.DoStep(ACEngine.Step.RelatedFields4, true); } if (ace.HasRel5) { ace.DoStep(ACEngine.Step.RelatedFields5, true); } if (ace.HasRel6) { ace.DoStep(ACEngine.Step.RelatedFields6, true); } if (ace.HasRel7) { ace.DoStep(ACEngine.Step.RelatedFields7, true); } if (ace.HasRel8) { ace.DoStep(ACEngine.Step.RelatedFields8, true); } if (ace.HasRel9) { ace.DoStep(ACEngine.Step.RelatedFields9, true); } if (ace.HasTimeline) { ace.DoStep(ACEngine.Step.Timeline, true); } if (ace.HasDoc & !SkipDoc) { docDB.DocumentRow dr = (docDB.DocumentRow)ace.relTables["Document0"][0].Row; //if (TemplateCode != null) //only set the template if it is provided // dr.templateCode = TemplateCode; ace.DocumentDefaults(revId != 0); // if (dr.DocContentRow == null) //FM.GetDocMng().GetDocContent().Load(dr.DocRefId, dr.CurrentVersion); Doc0 = dr.DocContentRow.ContentsAsText; } else { ace.FM.GetDocMng().DB.RejectChanges(); ace.relTables.Remove("Document0"); ace.NewActivity.SetDocIdNull(); } if (ace.HasBilling) { ace.DoStep(ACEngine.Step.Billing, true); } }