public static IncidentInfo CreateMapping(int EMailMessageId) { // Load Message Info EMailMessageInfo mi = EMailMessageInfo.Load(EMailMessageId); // Load Emal Box EMailRouterPop3Box emailBox = EMailRouterPop3Box.Load(mi.EMailRouterPop3BoxId); // Load Mapping Handler By EMail Box IEMailIncidentMapping mappingHandler = EMailIncidentMappingHandler.LoadHandler(emailBox.Settings.SelectedHandlerId); // Mapping return(mappingHandler.Create(emailBox, EMailMessage.GetPop3Message(EMailMessageId))); }
public static void OpenEml(int IncidentId, int EMailMessageId, Stream outputStream) { Pop3Message message = EMailMessage.GetPop3Message(EMailMessageId); IncidentBox incidentBox = IncidentBox.Load(Incident.GetIncidentBox(IncidentId)); EMailRouterPop3Box emailBox = EMailRouterPop3Box.ListInternal(); string SenderName = EMailMessage.GetSenderName(message); string FromEmail = SenderName == string.Empty?emailBox.EMailAddress: string.Format("\"{0}\" <{1}>", SenderName, emailBox.EMailAddress); OutputMessageCreator output = new OutputMessageCreator(message, IncidentId, emailBox.EMailAddress, FromEmail); output.AddRecipient(Security.CurrentUser.UserID); string Subject = (message.Subject == null?string.Empty:message.Subject); if (Subject == string.Empty) { // OZ: Maybe: Set Default Inicdent Title if subject is empty //Subject = Incident.GetIncidentTitle(IncidentId); } if (TicketUidUtil.LoadFromString(Subject) == string.Empty) { output.Subject = string.Format("[{0}] {1}", TicketUidUtil.Create(incidentBox.IdentifierMask, IncidentId), Subject); } OutputMessage outputMsg = (OutputMessage)output.Create()[0]; outputStream.Write(outputMsg.Data, 0, outputMsg.Data.Length); outputStream.Flush(); }
public static ArrayList Send(int IncidentId, int EMailMessageId) { EMailMessageRow row = new EMailMessageRow(EMailMessageId); return(Send(IncidentId, EMailRouterPop3Box.Load(row.EMailRouterPop3BoxId), EMailMessage.GetPop3Message(row.EmlMessage))); }
/// <summary> /// Adds to incident message. /// </summary> /// <param name="IsInternal">if set to <c>true</c> [is internal].</param> /// <param name="IncidentId">The incident id.</param> /// <param name="EMailMessageId">The E mail message id.</param> /// <returns></returns> public static int AddToIncidentMessage(bool IsInternal, int IncidentId, int EMailMessageId) { Pop3Message message = EMailMessage.GetPop3Message(EMailMessageId); return(AddToIncidentMessage(IsInternal, IncidentId, EMailMessageId, message)); }
/// <summary> /// Copies to incident. /// </summary> /// <param name="emailMessageId">The email message id.</param> /// <param name="incidentId">The incident id.</param> public static void CopyToIncident(int emailMessageId, int incidentId) { using (DbTransaction tran = DbTransaction.Begin()) { // Remove from pending PendingEMailMessageRow.DeleteByEMailMessageId(emailMessageId); // Load Pop3 Message EMailMessageInfo msgInfo = EMailMessageInfo.Load(emailMessageId); EMailRouterPop3Box emailBox = EMailRouterPop3Box.Load(msgInfo.EMailRouterPop3BoxId); Pop3Message msg = EMailMessage.GetPop3Message(emailMessageId); // Add User to White Lits string SenderEmail = EMailMessage.GetSenderEmail(msg); //if(!WhiteListItem.Contains(SenderEmail)) if (PortalConfig.UseAntiSpamFilter && PortalConfig.AutoFillWhiteList) { WhiteListItem.Create(SenderEmail); } int creatorId, issueBoxId; using (IDataReader reader = Incident.GetIncident(incidentId)) { reader.Read(); creatorId = (int)reader["CreatorId"]; issueBoxId = (int)reader["IncidentBoxId"]; } int stateId, managerId, responsibleId; bool isResposibleGroup; ArrayList users = new ArrayList(); Issue2.GetIssueBoxSettings(issueBoxId, out stateId, out managerId, out responsibleId, out isResposibleGroup, users); UserLight prevUser = LogOnCreator(creatorId, msg); int ThreadNodeId = AddToIncidentMessage(emailBox.IsInternal, incidentId, emailMessageId, msg); if (ProcessXIbnHeaders(incidentId, ThreadNodeId, msg)) { ArrayList excludeUsers = EMailRouterOutputMessage.Send(incidentId, emailBox, msg); // O.R. [2008-09-09]: Exclude inactive users if (responsibleId > 0 && User.GetUserActivity(responsibleId) != User.UserActivity.Active) { responsibleId = -1; } ArrayList activeUsers = new ArrayList(); foreach (int userId in users) { if (User.GetUserActivity(userId) == User.UserActivity.Active) { activeUsers.Add(userId); } } // Issue2.SendAlertsForNewIssue(incidentId, managerId, responsibleId, activeUsers, excludeUsers); } tran.Commit(); } }
/// <summary> /// Approves the pending. /// </summary> /// <param name="EMailMessageId">The E mail message id.</param> public static void ApprovePending(int EMailMessageId) { // Stop Double Approve if (!PendingEMailMessageRow.Contains(EMailMessageId)) { return; } using (DbTransaction tran = DbTransaction.Begin()) { // Remove from pending PendingEMailMessageRow.DeleteByEMailMessageId(EMailMessageId); // Load Pop3 Message EMailMessageInfo msgInfo = EMailMessageInfo.Load(EMailMessageId); EMailRouterPop3Box emailBox = EMailRouterPop3Box.Load(msgInfo.EMailRouterPop3BoxId); Pop3Message msg = EMailMessage.GetPop3Message(EMailMessageId); // Add User to White Lits string SenderEmail = EMailMessage.GetSenderEmail(msg); //if(!WhiteListItem.Contains(SenderEmail)) if (PortalConfig.UseAntiSpamFilter && PortalConfig.AutoFillWhiteList) { WhiteListItem.Create(SenderEmail); } string TicketUID = TicketUidUtil.LoadFromString(msg.Subject == null ? string.Empty : msg.Subject); if (TicketUID == string.Empty) { int IncidentId = CreateNewIncident(EMailMessageId, emailBox, msg); // Automaticaly by Incident.CreateFromEmail //EMailRouterOutputMessage.Send(IncidentId, emailBox, msg); } else { // Assign By Ticket int IncidentId = FindIncidentByTicket(TicketUID); if (IncidentId != -1) { int creatorId, issueBoxId; using (IDataReader reader = Incident.GetIncident(IncidentId)) { reader.Read(); creatorId = (int)reader["CreatorId"]; issueBoxId = (int)reader["IncidentBoxId"]; } int stateId, managerId, responsibleId; bool isResposibleGroup; ArrayList users = new ArrayList(); Issue2.GetIssueBoxSettings(issueBoxId, out stateId, out managerId, out responsibleId, out isResposibleGroup, users); UserLight prevUser = LogOnCreator(creatorId, msg); int ThreadNodeId = AddToIncidentMessage(emailBox.IsInternal, IncidentId, EMailMessageId, msg); if (ProcessXIbnHeaders(IncidentId, ThreadNodeId, msg)) { ArrayList excludeUsers = EMailRouterOutputMessage.Send(IncidentId, emailBox, msg); // O.R. [2008-09-09]: Exclude inactive users if (responsibleId > 0 && User.GetUserActivity(responsibleId) != User.UserActivity.Active) { responsibleId = -1; } ArrayList activeUsers = new ArrayList(); foreach (int userId in users) { if (User.GetUserActivity(userId) == User.UserActivity.Active) { activeUsers.Add(userId); } } // Issue2.SendAlertsForNewIssue(IncidentId, managerId, responsibleId, activeUsers, excludeUsers); } } else { IncidentId = CreateNewIncident(EMailMessageId, emailBox, msg); // Automaticaly by Incident.CreateFromEmail //EMailRouterOutputMessage.Send(IncidentId, emailBox, msg); } } tran.Commit(); } }
public static void Open(int IncidentId, int EMailMessageId, Stream outputStream) { System.Reflection.Assembly asm = typeof(MsgMessage).Assembly; Pop3Message message = EMailMessage.GetPop3Message(EMailMessageId); IncidentBox incidentBox = IncidentBox.Load(Incident.GetIncidentBox(IncidentId)); EMailRouterPop3Box box = EMailRouterPop3Box.ListInternal(); string receiver = Security.CurrentUser.Email; //EMailMessage.GetSenderEmail(message); string sender = box.EMailAddress; using (Stream stream = asm.GetManifestResourceStream("Mediachase.IBN.Business.Resources.template.msg")) { using (MemoryStream memStream = new MemoryStream()) { using (MsgHelper helper = new MsgHelper(stream)) { helper.SetSenderEmail(sender); //string SenderName = EMailMessage.GetSenderName(message); //helper.SetSenderName(SenderName==string.Empty?sender:SenderName); helper.SetSenderName(sender); string IncidentTitle = Incident.GetIncidentTitle(IncidentId); string IncidentTicket = TicketUidUtil.Create(incidentBox.IdentifierMask, IncidentId); string Subject = (message.Subject == null?string.Empty:message.Subject); if (Subject == string.Empty) { // OZ: Maybe: Set Default Inicdent Title if subject is empty //Subject = Incident.GetIncidentTitle(IncidentId); } if (TicketUidUtil.LoadFromString(Subject) == string.Empty) { Subject = string.Format("[{0}] {1}", TicketUidUtil.Create(incidentBox.IdentifierMask, IncidentId), Subject); } helper.SetReceiverName(Security.CurrentUser.DisplayName); helper.SetDisplayTo(receiver); helper.SetReceiverEmail(receiver); helper.SetCreationTimes(DateTime.UtcNow); helper.SetSubject(Subject); helper.SetBody(message.BodyText); if (message.BodyHtml == null || message.BodyHtml.Trim() == String.Empty) { helper.SetHtmlBody(message.BodyText); } else { helper.SetHtmlBody(message.BodyHtml); } helper.Commit(); helper.createMSG(memStream); memStream.Flush(); memStream.Seek(0, SeekOrigin.Begin); const int bufLen = 1024; byte[] buffer = new byte[bufLen]; int bytesRead; while ((bytesRead = memStream.Read(buffer, 0, bufLen)) > 0) { outputStream.Write(buffer, 0, bytesRead); } outputStream.Flush(); } } } }