Example #1
0
 public void Init(FileManager FM, fFile ffile)
 {
     fm   = FM;
     ffns = ffile;
     AcSeriesOKToAdd.Clear();
     ABP = fm.InitActivityProcess();
     try
     {
         Dictionary <int, atriumBE.CurrentFlow> activeProcesses = ABP.Workflow.NextSteps();
         foreach (CurrentFlow ap in activeProcesses.Values)
         {
             if (ap.NextSteps.Count > 0)
             {
                 LoadNextSteps(ap);
             }
         }
         LoadEnabledProcesses();
         LoadAvailableProcesses();
     }
     catch (Exception x)
     {
         throw new LMException(Properties.Resources.QuickACNoNextSteps, x);
     }
 }
Example #2
0
        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);
            }
        }
Example #3
0
        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);
                }
            }
        }
Example #4
0
        private void ImportDocs(FileManager fm, string folderpath)
        {
            ActivityBP    abp                  = fm.InitActivityProcess();
            List <string> listOfXmlDocs        = new List <string>();
            List <string> listOfDocAttachments = new List <string>();

            //retrieve list of docId'ed xml files
            foreach (string doc in System.IO.Directory.GetFiles(folderpath))
            {
                if (Path.GetFileName(doc) == fileXmlFilename || Path.GetFileName(doc) == leafXmlFilename)
                {
                    continue;
                }

                if (Path.GetExtension(doc) == ".xml")
                {
                    //how do we ensure the xml doc is ours and not meant for import?
                    //check filename length?  safe enough?
                    //check the filename can be parsed as int?
                    //both checks?
                    string filenameOfXMLFile = Path.GetFileNameWithoutExtension(doc);
                    bool   isNumeric         = int.TryParse(filenameOfXMLFile, out int filedocid);

                    if (filenameOfXMLFile.Length > 7 || !isNumeric)
                    {
                        continue;
                    }

                    listOfXmlDocs.Add(doc);
                }
            }

            //loop through doc metadata xml files
            foreach (string docXmlFile in listOfXmlDocs)
            {
                //load file into XmlDocument for metadata
                XmlDocument xmlDocMetadata = new XmlDocument();
                xmlDocMetadata.Load(docXmlFile);

                //check to see if there is an rtf file for it
                string folderPath = Path.GetDirectoryName(docXmlFile);
                string docId      = Path.GetFileNameWithoutExtension(docXmlFile);


                string docsubject = getNodeValue(xmlDocMetadata, "Subject");
                if (docsubject.Length > 255)
                {
                    docsubject = docsubject.Substring(0, 255);
                }
                DateTime docDate = getDocDateValue(xmlDocMetadata);

                string rtfFile = Path.Combine(folderpath, docId + ".docx");

                if (!File.Exists(rtfFile))
                {
                    if (pathToEmptyRtfDoc == "")
                    {
                        pathToEmptyRtfDoc = rtfTemplateName;
                    }
                    //create blank rtf file so a record of the doc exists
                    rtfFile = pathToEmptyRtfDoc;
                }
                //find any related embedded objects using startsWith doc id
                listOfDocAttachments.Clear();
                foreach (string doc in System.IO.Directory.GetFiles(folderpath))
                {
                    if (Path.GetFileName(doc).StartsWith(docId + " "))
                    {
                        listOfDocAttachments.Add(doc);
                    }
                }
                CreateDocument(fm, abp, docId, rtfFile, docsubject, docDate, listOfDocAttachments);
            }
        }