/// <summary> /// Загрузка файла /// </summary> /// <param name="fileName">Путь к файлу</param> /// <param name="db">БД</param> public string ImportDxlFile(string fileName, NotesDatabase db) { NotesStream = db.Parent.CreateStream(); NotesDxlImporter = db.Parent.CreateDXLImporter(); if (!NotesStream.Open(fileName)) { Loggers.Log4NetLogger.Error(new Exception("Невозможно открыть файл " + fileName)); return(null); } //notesDXLImporter.InputValidationOption = VALIDATIONOPTION.VALIDATE_NEVER; NotesDxlImporter.ACLImportOption = DXLIMPORTOPTION.DXLIMPORTOPTION_UPDATE_ELSE_IGNORE; NotesDxlImporter.DesignImportOption = DXLIMPORTOPTION.DXLIMPORTOPTION_REPLACE_ELSE_CREATE; NotesDxlImporter.ReplicaRequiredForReplaceOrUpdate = false; NotesDxlImporter.DocumentImportOption = DXLIMPORTOPTION.DXLIMPORTOPTION_UPDATE_ELSE_CREATE; NotesDxlImporter.ExitOnFirstFatalError = true; try { NotesDxlImporter.Import(NotesStream, db); string text = NotesDxlImporter.GetFirstImportedNoteId(); NotesStream.Truncate(); NotesStream.Close(); return(text); } catch (Exception e) { Loggers.Log4NetLogger.Error(new Exception(NotesDxlImporter.Log)); Loggers.Log4NetLogger.Error(new Exception(NotesDxlImporter.LogComment)); Loggers.Log4NetLogger.Error(e); } finally { Dispose(); } return(null); }
/// <summary> /// Рассылка писем если пришло Html В случае если зашло Html /// </summary> /// <param name="mailOutlook">Письма заступившие</param> /// <param name="arrayUsers">Рассылка пользователям</param> public void SendMailMimeHtml(MailLotusOutlookIn mailOutlook, List <string> arrayUsers) { Db.LotusConnectedDataBaseServer(Config.LotusServer, Config.LotusMailSend); NotesStream = Db.Db.Parent.CreateStream(); Document = Db.Db.CreateDocument(); try { if (Db.Db == null) { throw new InvalidOperationException("Фатальная ошибка нет соединения с сервером!"); } Db.DeleteDataBaseAllMailSizeWarning(); Document.AppendItemValue("Subject", "От кого: " + mailOutlook.MailAdress + " Тема: " + mailOutlook.SubjectMail); Document.AppendItemValue("Recipients", Db.Session.UserName); Document.AppendItemValue("OriginalTo", Db.Session.UserName); Document.AppendItemValue("From", Db.Session.UserName); Document.AppendItemValue("OriginalFrom", Db.Session.UserName); Document.AppendItemValue("SendTo", arrayUsers.ToArray()); var mimeEntity = Document.CreateMIMEEntity(); var mimeHeader = mimeEntity.CreateHeader("MIME-Version"); mimeHeader.SetHeaderVal("1.0"); mimeHeader = mimeEntity.CreateHeader("Content-Type"); mimeHeader.SetHeaderValAndParams("multipart/mixed"); var mimeChild = mimeEntity.CreateChildEntity(); NotesStream.WriteText(mailOutlook.Body); mimeChild.SetContentFromText(NotesStream, "text/html;charset=\"utf-8\"", MIME_ENCODING.ENC_NONE); mimeChild = mimeEntity.CreateChildEntity(); if (File.Exists(mailOutlook.FullPathFile)) { NotesStream.Truncate(); NotesStream.Open(mailOutlook.FullPathFile); mimeHeader = mimeChild.CreateHeader("Content-Disposition"); mimeHeader.SetHeaderVal($"attachment; filename=\"{mailOutlook.NameFile}\""); mimeChild.SetContentFromBytes(NotesStream, $"application/zip; name=\"{mailOutlook.NameFile}\"", MIME_ENCODING.ENC_IDENTITY_BINARY); } Document.CloseMIMEEntities(true); Db.Db.Parent.ConvertMime = true; if (Document.ComputeWithForm(true, false)) { Document.Save(true, true); Document.Send(false); NotesStream.Truncate(); NotesStream.Close(); } } catch (Exception e) { Loggers.Log4NetLogger.Error(new Exception("В рассылке Html письма возникла ошибка!")); Loggers.Log4NetLogger.Error(e); } finally { if (Document != null) { Marshal.ReleaseComObject(Document); } Document = null; if (NotesStream != null) { Marshal.ReleaseComObject(NotesStream); } NotesStream = null; } }