Пример #1
0
        public AttachmentBE GetAttachment()
        {
            if (myAttachment == null)
            {
                myAttachment = new AttachmentBE(this);
            }

            return(myAttachment);
        }
Пример #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);
            }
        }