/// <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(); } }