/// <summary> /// Adds the internal E mail2 incident. /// </summary> /// <param name="IncidentId">The incident id.</param> /// <param name="EMailMessageId">The E mail message id.</param> /// <param name="SenderName">Name of the sender.</param> /// <param name="SenderEmail">The sender email.</param> /// <returns></returns> private static int AddInternalEMail2Incident(int IncidentId, int EMailMessageId, string SenderName, string SenderEmail) { ForumThreadNodeInfo info = null; using (DbTransaction tran = DbTransaction.Begin()) { BaseIbnContainer FOcontainer = BaseIbnContainer.Create("FileLibrary", string.Format("IncidentId_{0}", IncidentId)); ForumStorage forumStorage = (ForumStorage)FOcontainer.LoadControl("ForumStorage"); int SenderUserID = Security.UserID; EMailMessageInfo mi = EMailMessageInfo.Load(EMailMessageId); info = forumStorage.CreateForumThreadNode(EMailMessageInfo.ExtractTextFromHtml(mi.HtmlBody), DateTime.UtcNow, Security.UserID, EMailMessageId, (int)ForumStorage.NodeContentType.EMail); ForumThreadNodeSettingCollection settings = new ForumThreadNodeSettingCollection(info.Id); settings.Add(ForumThreadNodeSetting.Outgoing, "1"); if (HttpContext.Current != null && HttpContext.Current.Items.Contains(ForumThreadNodeSetting.AllRecipients)) { settings.Add(ForumThreadNodeSetting.AllRecipients, HttpContext.Current.Items[ForumThreadNodeSetting.AllRecipients].ToString()); } tran.Commit(); } return(info.Id); }
public static AttachmentData Create(MimeEntry entry) { AttachmentData retVal = new AttachmentData(); retVal.ContentType = entry.ContentType; retVal.FileName = EMailMessageInfo.GetFileName(entry); retVal.Data = entry.Body; return(retVal); }
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))); }
/// <summary> /// Loads the specified E mail message id. /// </summary> /// <param name="EMailMessageId">The E mail message id.</param> /// <returns></returns> public static EMailMessageInfo Load(int EMailMessageId) { string category = "HelpDesk"; string key = string.Format(CultureInfo.InvariantCulture, "EMailMessage::{0}", EMailMessageId); EMailMessageInfo retVal; if (DataCache.TryGetValue <EMailMessageInfo>(category, DataCache.EmptyUser, key, out retVal)) { return(retVal); } retVal = new EMailMessageInfo(EMailMessageId); DataCache.Add(category, DataCache.EmptyUser, key, retVal); return(retVal); }
/// <summary> /// Adds the external E mail to incident. /// </summary> /// <param name="IncidentId">The incident id.</param> /// <param name="EMailMessageId">The E mail message id.</param> /// <param name="message">The message.</param> private static int AddExternalEMail2Incident(int IncidentId, int EMailMessageId, string SenderName, string SenderEmail) { ForumThreadNodeInfo info = null; using (DbTransaction tran = DbTransaction.Begin()) { BaseIbnContainer FOcontainer = BaseIbnContainer.Create("FileLibrary", string.Format("IncidentId_{0}", IncidentId)); ForumStorage forumStorage = (ForumStorage)FOcontainer.LoadControl("ForumStorage"); EMailMessageInfo mi = EMailMessageInfo.Load(EMailMessageId); info = forumStorage.CreateForumThreadNode(EMailMessageInfo.ExtractTextFromHtml(mi.HtmlBody), DateTime.UtcNow, Security.UserID, EMailMessageId, (int)ForumStorage.NodeContentType.EMail); // 2006-12-12 OZ: Register EMail External Recepient if (!EMailIssueExternalRecipient.Contains(IncidentId, SenderEmail)) { EMailIssueExternalRecipient.Create(IncidentId, SenderEmail); } ForumThreadNodeSettingCollection settings = new ForumThreadNodeSettingCollection(info.Id); settings.Add(ForumThreadNodeSetting.Incoming, "1"); if (HttpContext.Current != null && HttpContext.Current.Items.Contains(ForumThreadNodeSetting.AllRecipients)) { settings.Add(ForumThreadNodeSetting.AllRecipients, HttpContext.Current.Items[ForumThreadNodeSetting.AllRecipients].ToString()); } // O.R. [2008-09-19]: Recalculate Expected Dates DBIncident.RecalculateExpectedResponseDate(IncidentId); DBIncident.RecalculateExpectedAssignDate(IncidentId); tran.Commit(); } return(info.Id); }
/// <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 IncidentInfo Create(EMailRouterPop3Box box, Mediachase.Net.Mail.Pop3Message msg) { IncidentInfo retVal = new IncidentInfo(); retVal.CreatorId = box.Settings.DefaultEMailIncidentMappingBlock.DefaultCreator; retVal.EMailBox = box.EMailRouterPop3BoxId; retVal.Title = msg.Subject == null?string.Empty:msg.Subject; if (retVal.Title == string.Empty) { // Set Default Inicdent Title if subject is empty string SenderID = EMailMessage.GetSenderName(msg); if (SenderID == string.Empty) { SenderID = EMailMessage.GetSenderEmail(msg); } retVal.Title = string.Format("{0} ({1})", SenderID, DateTime.Now.ToString("d")); } // OZ: 2008-07-30 Added description defenition rules if (box.Settings.DefaultEMailIncidentMappingBlock.DescriptionId == -1) { retVal.Description = string.Empty; retVal.EMailBody = EMailMessageInfo.ExtractTextFromHtml(msg); } else { retVal.Description = EMailMessageInfo.ExtractTextFromHtml(msg); retVal.EMailBody = retVal.Description; } // int priorityId = GetPriorityId(box, msg); if (priorityId < 0) // <0 From Email { retVal.PriorityId = 500; string importance = msg.Importance; if (importance != null) { switch (importance.ToLower()) { case "low": retVal.PriorityId = 0; break; case "normal": retVal.PriorityId = 500; break; case "high": retVal.PriorityId = 750; break; } } } else { retVal.PriorityId = priorityId; } retVal.MailSenderEmail = EMailMessage.GetSenderEmail(msg); retVal.SeverityId = GetSeverityId(box, msg); retVal.TypeId = GetTypeId(box, msg); retVal.GeneralCategories.AddRange(GetGeneralCategories(box, msg)); retVal.IncidentCategories.AddRange(GetIncidentCategories(box, msg)); // OZ: 2007-01-11 retVal.ProjectId = box.Settings.DefaultEMailIncidentMappingBlock.ProjectId; retVal.IncidentBoxId = box.Settings.DefaultEMailIncidentMappingBlock.IncidentBoxId; // OZ: 2007-01-22 retVal.OrgUid = box.Settings.DefaultEMailIncidentMappingBlock.OrgUid; retVal.ContactUid = box.Settings.DefaultEMailIncidentMappingBlock.ContactUid; return(retVal); }