public static void SetPrivateStatus(int ThreadNodeId) { ForumThreadNodeSettingCollection settings = new ForumThreadNodeSettingCollection(ThreadNodeId); if(settings.Contains(ForumThreadNodeSetting.Outgoing)) settings.Remove(ForumThreadNodeSetting.Outgoing); if(settings.Contains(ForumThreadNodeSetting.Incoming)) settings.Remove(ForumThreadNodeSetting.Incoming); settings.Add(ForumThreadNodeSetting.Internal, "1"); }
private void dgForum_ItemCommand(object source, DataGridCommandEventArgs e) { if (e.CommandName == "Resolution") { int nodeId = int.Parse(e.CommandArgument.ToString()); ForumThreadNodeSettingCollection coll = new ForumThreadNodeSettingCollection(nodeId); coll.Add(ForumThreadNodeSetting.Resolution, "1"); if (coll[ForumThreadNodeSetting.Internal] == null && coll[ForumThreadNodeSetting.Incoming] == null && coll[ForumThreadNodeSetting.Outgoing] == null) coll.Add(ForumThreadNodeSetting.Internal, "1"); } else if (e.CommandName == "Workaround") { int nodeId = int.Parse(e.CommandArgument.ToString()); ForumThreadNodeSettingCollection coll = new ForumThreadNodeSettingCollection(nodeId); coll.Add(ForumThreadNodeSetting.Workaround, "1"); if (coll[ForumThreadNodeSetting.Internal] == null && coll[ForumThreadNodeSetting.Incoming] == null && coll[ForumThreadNodeSetting.Outgoing] == null) coll.Add(ForumThreadNodeSetting.Internal, "1"); } else if (e.CommandName == "UnResolution") { int nodeId = int.Parse(e.CommandArgument.ToString()); ForumThreadNodeSettingCollection coll = new ForumThreadNodeSettingCollection(nodeId); if (coll[ForumThreadNodeSetting.Resolution] != null) coll.Remove(ForumThreadNodeSetting.Resolution); if (coll[ForumThreadNodeSetting.Internal] == null && coll[ForumThreadNodeSetting.Incoming] == null && coll[ForumThreadNodeSetting.Outgoing] == null) coll.Add(ForumThreadNodeSetting.Internal, "1"); } else if (e.CommandName == "UnWorkaround") { int nodeId = int.Parse(e.CommandArgument.ToString()); ForumThreadNodeSettingCollection coll = new ForumThreadNodeSettingCollection(nodeId); if (coll[ForumThreadNodeSetting.Workaround] != null) coll.Remove(ForumThreadNodeSetting.Workaround); if (coll[ForumThreadNodeSetting.Internal] == null && coll[ForumThreadNodeSetting.Incoming] == null && coll[ForumThreadNodeSetting.Outgoing] == null) coll.Add(ForumThreadNodeSetting.Internal, "1"); } else if (e.CommandName == "ReSend") { int emailMessageId = int.Parse(e.CommandArgument.ToString()); try { EMailRouterOutputMessage.Send(IncidentId, emailMessageId); WasFarwarded = 1; ForwardedEMail = emailMessageId; } catch { WasFarwarded = -1; ForwardedEMail = emailMessageId; } } else if (e.CommandName == "ReSendOut") { int emailMessageId = int.Parse(e.CommandArgument.ToString()); try { EMailRouterOutputMessage.Send(IncidentId, emailMessageId); WasFarwarded = 1; ForwardedEMail = emailMessageId; } catch { WasFarwarded = -1; ForwardedEMail = emailMessageId; } } else if (e.CommandName == "Reply") { try { int emailMessageId = int.Parse(e.CommandArgument.ToString()); if (pc["IncForum_ReplyOutlook"] == "1") { Response.AddHeader("content-disposition", String.Format("attachment; filename=\"{0}\"", "mail.msg")); HttpContext.Current.Response.ContentType = "application/msoutlook"; MsgMessage.Open(IncidentId, emailMessageId, HttpContext.Current.Response.OutputStream); } else if (pc["IncForum_ReplyEML"] == "1") { Response.AddHeader("content-disposition", String.Format("attachment; filename=\"{0}\"", "mail.eml")); HttpContext.Current.Response.ContentType = "message/rfc822"; MsgMessage.OpenEml(IncidentId, emailMessageId, HttpContext.Current.Response.OutputStream); } Response.End(); } catch (Exception ex) { HttpContext.Current.Trace.Write(ex.Message); } } }
private void BindDataGrid() { DataTable dtTop = new DataTable(); DataRow dr; dtTop.Columns.Add(new DataColumn("Id", typeof(int))); dtTop.Columns.Add(new DataColumn("Index", typeof(string))); dtTop.Columns.Add(new DataColumn("EMailMessageId", typeof(int))); dtTop.Columns.Add(new DataColumn("Weight", typeof(int))); dtTop.Columns.Add(new DataColumn("Sender", typeof(string))); dtTop.Columns.Add(new DataColumn("Message", typeof(string))); dtTop.Columns.Add(new DataColumn("SystemMessage", typeof(string))); dtTop.Columns.Add(new DataColumn("Created", typeof(string))); dtTop.Columns.Add(new DataColumn("CreationDate", typeof(DateTime))); dtTop.Columns.Add(new DataColumn("Attachments", typeof(string))); dtTop.Columns.Add(new DataColumn("NodeType", typeof(string))); dtTop.Columns.Add(new DataColumn("CanMakeResolution", typeof(bool))); dtTop.Columns.Add(new DataColumn("CanMakeWorkaround", typeof(bool))); dtTop.Columns.Add(new DataColumn("CanUnMakeResolution", typeof(bool))); dtTop.Columns.Add(new DataColumn("CanUnMakeWorkaround", typeof(bool))); dtTop.Columns.Add(new DataColumn("CanReSend", typeof(bool))); dtTop.Columns.Add(new DataColumn("CanReSendOut", typeof(bool))); dtTop.Columns.Add(new DataColumn("CanReply", typeof(bool))); DataTable dt = dtTop.Clone(); IncidentBox incidentBox = IncidentBox.Load(Incident.GetIncidentBox(IncidentId)); EMailRouterIncidentBoxBlock settings = IncidentBoxDocument.Load(incidentBox.IncidentBoxId).EMailRouterBlock; bool allowEMailRouting = settings.AllowEMailRouting; bool CanUpdate = Incident.CanUpdate(IncidentId); int _index = 0; foreach (ForumThreadNodeInfo node in Incident.GetForumThreadNodes(IncidentId)) { bool fl_IsTop = false; int iWeight = 3; string typeName = "internal"; ForumThreadNodeSettingCollection coll = new ForumThreadNodeSettingCollection(node.Id); if (coll[ForumThreadNodeSetting.Question] != null) { if (pc["IncForum_Quests458"] == "1") { fl_IsTop = true; iWeight = 0; } if (coll[ForumThreadNodeSetting.Incoming] != null) typeName = "Mail_incoming_quest"; else if (coll[ForumThreadNodeSetting.Outgoing] != null) typeName = "Mail_outgoing_quest"; else typeName = "internal_quest"; } else if (coll[ForumThreadNodeSetting.Resolution] != null) { if (pc["IncForum_Resol458"] == "1") { fl_IsTop = true; iWeight = 1; } if (coll[ForumThreadNodeSetting.Incoming] != null) typeName = "Mail_incoming_resol"; else if (coll[ForumThreadNodeSetting.Outgoing] != null) typeName = "Mail_outgoing_resol"; else typeName = "internal_resol"; } else if (coll[ForumThreadNodeSetting.Workaround] != null) { if (pc["IncForum_Work458"] == "1") { fl_IsTop = true; iWeight = 2; } if (coll[ForumThreadNodeSetting.Incoming] != null) typeName = "Mail_incoming_wa"; else if (coll[ForumThreadNodeSetting.Outgoing] != null) typeName = "Mail_outgoing_wa"; else typeName = "internal_wa"; } else if (coll[ForumThreadNodeSetting.Incoming] != null) typeName = "Mail_incoming"; else if (coll[ForumThreadNodeSetting.Outgoing] != null) typeName = "Mail_outgoing"; if (fl_IsTop) dr = dtTop.NewRow(); else dr = dt.NewRow(); dr["Weight"] = iWeight; dr["Id"] = node.Id; dr["EMailMessageId"] = node.EMailMessageId; dr["CanMakeResolution"] = false; dr["CanMakeWorkaround"] = false; dr["CanUnMakeResolution"] = false; dr["CanUnMakeWorkaround"] = false; dr["CanReply"] = false; dr["CanReSend"] = false; dr["CanReSendOut"] = false; switch (typeName) { case "internal_resol": case "Mail_incoming_resol": case "Mail_outgoing_resol": dr["CanUnMakeResolution"] = true; break; case "internal_wa": case "Mail_incoming_wa": case "Mail_outgoing_wa": dr["CanMakeResolution"] = true; dr["CanUnMakeWorkaround"] = true; break; case "internal": case "Mail_incoming": case "Mail_outgoing": dr["CanMakeResolution"] = true; dr["CanMakeWorkaround"] = true; break; default: break; } if (coll[ForumThreadNodeSetting.Outgoing] != null && !Security.CurrentUser.IsExternal) { dr["CanReSendOut"] = true; ///AK test //dr["CanReply"] = true; /// } if (coll[ForumThreadNodeSetting.Incoming] != null && !Security.CurrentUser.IsExternal) { dr["CanReply"] = true; dr["CanReSend"] = allowEMailRouting; } if (node.EMailMessageId <= 0) dr["Sender"] = CommonHelper.GetUserStatus(node.CreatorId); dr["Created"] = node.Created.ToShortDateString() + " " + node.Created.ToShortTimeString(); dr["CreationDate"] = node.Created; string sNodeType = typeName; try { sNodeType = LocRM.GetString(String.Format("NodeType_{0}", typeName)); } catch { } dr["NodeType"] = String.Format("<img alt='{1}' src='../Layouts/Images/icons/{0}.gif'/>", typeName, sNodeType); dr["SystemMessage"] = " "; string sMessage = ""; if (coll[IncidentForum.IssueEvent.Declining.ToString()] != null) { sMessage = String.Format("<font color='red'><b>{0}</b></font>", LocRM.GetString("tUserDeclined")); } if (coll[IncidentForum.IssueEvent.State.ToString()] != null) { int stateId = int.Parse(coll[IncidentForum.IssueEvent.State.ToString()].ToString()); if (sMessage == "") sMessage = String.Format("{2}: <font color='{0}'><b>{1}</b></font>", Util.CommonHelper.GetStateColorString(stateId), GetStatusName(stateId), LocRM.GetString("Status")); else sMessage += String.Format("{2}: <font color='{0}'><b>{1}</b></font>", Util.CommonHelper.GetStateColorString(stateId), GetStatusName(stateId), LocRM.GetString("Status")); } if (coll[IncidentForum.IssueEvent.Responsibility.ToString()] != null) { string sResp = ""; int iResp = int.Parse(coll[IncidentForum.IssueEvent.Responsibility.ToString()].ToString()); if (iResp == -2) sResp = String.Format("<img alt='' src='{0}'/> <span style='color:#808080;font-weight:bold'>{1}</span>", ResolveUrl("~/Layouts/Images/not_set.png"), LocRM.GetString("tRespNotSet")); else if (iResp == -1) sResp = String.Format("<img alt='' src='{0}'/> <span style='color:green;font-weight:bold'>{1}</span>", ResolveUrl("~/Layouts/Images/waiting.gif"), LocRM.GetString("tRespGroup")); else sResp = Util.CommonHelper.GetUserStatus(iResp); sResp = "<span class='IconAndText'><span>" + LocRM.GetString("tResponsible") + ":</span> " + sResp + "</span>"; if (sMessage == "") sMessage = sResp; else sMessage += "<br/>" + sResp; } if (WasFarwarded == 1 && node.EMailMessageId == ForwardedEMail) sMessage = "<font color='green'><b>" + LocRM.GetString("tWasResended") + "</b></font><br/>" + sMessage; if (WasFarwarded == -1 && node.EMailMessageId == ForwardedEMail) sMessage = "<font color='red'><b>" + LocRM.GetString("tWasNotResended") + "</b></font><br/>" + sMessage; dr["SystemMessage"] = (sMessage.Length == 0) ? " " : sMessage; string sAttach = ""; // EmailMessage if (node.EMailMessageId > 0) { EMailMessageInfo mi = null; try { mi = EMailMessageInfo.Load(node.EMailMessageId); int iUserId = User.GetUserByEmail(mi.SenderEmail); if (EMailClient.IsAlertSenderEmail(mi.SenderEmail)) iUserId = node.CreatorId; //User.GetUserByEmail(mi.SenderEmail); if (iUserId > 0) dr["Sender"] = Util.CommonHelper.GetUserStatus(iUserId); else { Client client = Mediachase.IBN.Business.Common.GetClient(mi.SenderEmail); if (client != null) { if (client.IsContact) dr["Sender"] = CommonHelper.GetContactLink(this.Page, client.Id, client.Name); else dr["Sender"] = CommonHelper.GetOrganizationLink(this.Page, client.Id, client.Name); } else if (mi.SenderName != "") dr["Sender"] = CommonHelper.GetEmailLink(mi.SenderEmail, mi.SenderName); else dr["Sender"] = CommonHelper.GetEmailLink(mi.SenderEmail, mi.SenderEmail); } string sBody = ""; if (mi.HtmlBody != null) { int iMaxLen = 256; sBody = mi.HtmlBody; if (!Security.CurrentUser.IsExternal && pc["IncForum_FullMess"] != "1") sBody = EMailMessageInfo.CutHtmlBody(mi.HtmlBody, iMaxLen, "..."); } if (pc["IncForum_FullMess"] != "1") dr["Message"] = String.Format("{0}<div class='text' style='text-align:right; font-weight:bold'><a href='javascript:OpenMessage({2},{3},false)'>{1}</a></div>", sBody, LocRM.GetString("More"), node.Id, node.EMailMessageId); else dr["Message"] = sBody; // Attachments for (int i = 0; i < mi.Attachments.Length; i++) { AttachmentInfo ai = mi.Attachments[i]; int id = DSFile.GetContentTypeByFileName(ai.FileName); string sIcon = ""; if (id > 0) { sIcon = String.Format("<img alt='' src='{0}'/>", ResolveUrl("~/Common/ContentIcon.aspx?IconID=" + id)); } //sAttach += String.Format("<nobr><a href='{0}'{2}>{1}</a></nobr> ", // ResolveUrl("~/Incidents/EmailAttachDownload.aspx") + "?EMailId=" + node.EMailMessageId.ToString() + "&AttachmentIndex=" + i.ToString(), // sIcon + " " + ai.FileName, // Mediachase.IBN.Business.Common.OpenInNewWindow(ai.ContentType) ? " target='_blank'" : ""); sAttach += String.Format("<a href='{0}'{2} style='white-space:nowrap'>{1}</a> ", WebDavUrlBuilder.GetEmailAtachWebDavUrl(node.EMailMessageId, i, true), sIcon + " " + ai.FileName, Mediachase.IBN.Business.Common.OpenInNewWindow(ai.ContentType) ? " target='_blank'" : ""); } } catch { dr["Sender"] = Util.CommonHelper.GetUserStatus(-1); dr["Message"] = String.Format("<font color='red'><b>{0}</b> (#{1})</font>", LocRM.GetString("tNotFound"), node.EMailMessageId); } } else { string sBody = CommonHelper.parsetext_br(node.Text, false); dr["Message"] = sBody; if (!Security.CurrentUser.IsExternal && pc["IncForum_FullMess"] != "1") { int iMaxLen = 300; string sBody1 = sBody; sBody = EMailMessageInfo.CutHtmlBody(sBody, iMaxLen, "..."); if (!sBody.Equals(sBody1)) dr["Message"] = String.Format("{0}<div class='text' style='text-align:right; font-weight:bold'><a href=\"javascript:OpenMessage({2},-1,true)\">{1}</a></div>", sBody, LocRM.GetString("More"), node.Id); } // Files if (node.ContentType == ForumStorage.NodeContentType.TextWithFiles) { FileInfo[] files = Incident.GetForumNodeFiles(node.Id); if (files.Length > 0) { foreach (FileInfo fl in files) { if (sAttach != "") sAttach += " "; string sTarget = Mediachase.IBN.Business.Common.OpenInNewWindow(fl.FileBinaryContentType) ? " target='_blank'" : ""; //string sLink = Util.CommonHelper.GetAbsolutePath(WebDavFileUserTicket.GetDownloadPath(fl.Id, fl.Name)); string sLink = Util.CommonHelper.GetAbsoluteDownloadFilePath(fl.Id, fl.Name, "FileLibrary", "ForumNodeId_" + node.Id); string sNameLocked = CommonHelper.GetLockerText(sLink); sAttach += String.Format("<span style='white-space:nowrap'><a href=\"{1}\"{3}><img alt='' src='../Common/ContentIcon.aspx?IconID={2}'/> {0}</a> {4}</span>", fl.Name, sLink, fl.FileBinaryContentTypeId, sTarget, sNameLocked); } } } } dr["Attachments"] = sAttach; if (sMessage.Length > 0 && dr["Message"].ToString() == "" && sAttach.Length == 0) { if (pc["IncForum_Info"] == "0") continue; dr["NodeType"] = String.Format("<img src='../Layouts/Images/icons/info_message.gif' alt='{1}'/>", typeName, LocRM.GetString("NodeType_InfoMessage")); dr["CanMakeResolution"] = false; dr["CanMakeWorkaround"] = false; dr["CanUnMakeResolution"] = false; dr["CanUnMakeWorkaround"] = false; } if (dr["Message"].ToString().Trim() == "") dr["Message"] = " "; if (pc["IncForum_ShowNums"] == "1") dr["Index"] = "<table cellspacing='0' cellpadding='4' border='0' width='100%'><tr><td class='text' align='center' style='background-position: center center; background-image: url(../Layouts/Images/atrisk1.gif); background-repeat: no-repeat'><b>" + (++_index).ToString() + "</b></td></tr></table>"; else dr["Index"] = " "; if (fl_IsTop) dtTop.Rows.Add(dr); else dt.Rows.Add(dr); } DataRow[] drtop = dtTop.Select("", "Weight, CreationDate"); DataRow[] drother = dt.Select("", pc["IncForum_Sort458"]); DataTable result = dt.Clone(); foreach (DataRow dr1 in drtop) { DataRow _dr = result.NewRow(); _dr.ItemArray = (Object[])dr1.ItemArray.Clone(); result.Rows.Add(_dr); } foreach (DataRow dr2 in drother) { DataRow _dr = result.NewRow(); _dr.ItemArray = (Object[])dr2.ItemArray.Clone(); result.Rows.Add(_dr); } DataView dv = result.DefaultView; dgForum.DataSource = dv; if (pc["IncidentForum_PageSize"] != null) dgForum.PageSize = int.Parse(pc["IncidentForum_PageSize"]); if (pc["IncidentForum_Page"] != null) { int iPageIndex = int.Parse(pc["IncidentForum_Page"]); int ppi = dv.Count / dgForum.PageSize; if (dv.Count % dgForum.PageSize == 0) ppi = ppi - 1; if (iPageIndex <= ppi) dgForum.CurrentPageIndex = iPageIndex; else dgForum.CurrentPageIndex = 0; pc["IncidentForum_Page"] = dgForum.CurrentPageIndex.ToString(); } dgForum.DataBind(); foreach (DataGridItem dgi in dgForum.Items) { ImageButton ib = (ImageButton)dgi.FindControl("ibDelete"); if (ib != null) { ib.ToolTip = LocRM.GetString("Delete"); ib.Attributes.Add("onclick", "return confirm('" + LocRM.GetString("WarningForumNode") + "')"); ib.Visible = CanUpdate; } ImageButton ib1 = (ImageButton)dgi.FindControl("ibResolution"); if (ib1 != null) { ib1.ToolTip = LocRM.GetString("tMarkAsResolution"); ib1.Attributes.Add("onclick", "return confirm('" + LocRM.GetString("tMarkAsResolutionWarning") + "')"); } ImageButton ib2 = (ImageButton)dgi.FindControl("ibWA"); if (ib2 != null) { ib2.ToolTip = LocRM.GetString("tMarkAsWA"); ib2.Attributes.Add("onclick", "return confirm('" + LocRM.GetString("tMarkAsWAWarning") + "')"); } ImageButton ib3 = (ImageButton)dgi.FindControl("ibUnResolution"); if (ib3 != null) { ib3.ToolTip = LocRM.GetString("tUnMarkAsResolution"); ib3.Attributes.Add("onclick", "return confirm('" + LocRM.GetString("tUnMarkAsResolutionWarning") + "')"); } ImageButton ib4 = (ImageButton)dgi.FindControl("ibUnWA"); if (ib4 != null) { ib4.ToolTip = LocRM.GetString("tUnMarkAsWA"); ib4.Attributes.Add("onclick", "return confirm('" + LocRM.GetString("tUnMarkAsWAWarning") + "')"); } ImageButton ib5 = (ImageButton)dgi.FindControl("ibReSend"); if (ib5 != null) { ib5.ToolTip = LocRM.GetString("tReSend"); ib5.Attributes.Add("onclick", "return confirm('" + LocRM.GetString("tReSendWarning") + "')"); } ImageButton ib6 = (ImageButton)dgi.FindControl("ibReSendOut"); if (ib6 != null) { ib6.ToolTip = LocRM.GetString("tReSend"); ib6.Attributes.Add("onclick", "return confirm('" + LocRM.GetString("tReSendOutWarning") + "')"); } ImageButton ib7 = (ImageButton)dgi.FindControl("ibReply"); if (ib7 != null) { ib7.ToolTip = LocRM.GetString("tReply"); if (!allowEMailRouting || (pc["IncForum_ReplyOutlook"] == "0" && pc["IncForum_ReplyEML"] == "0")) { string command = string.Format(CultureInfo.InvariantCulture, "{{ShowResizableWizard('{0}?IncidentId={1}&NodeId={2}&send=1',800,600);return false;}}", Page.ResolveUrl("~/Incidents/AddEMailMessage.aspx"), IncidentId, ib7.CommandArgument); ib7.Attributes.Add("onclick", command); } } } if (dgForum.Items.Count == 0) { dgForum.Visible = false; divNoMess.Visible = true; divNoMess.InnerHtml = "<span style='color:red'>" + LocRM.GetString("NoMessages") + "</span>"; } else { dgForum.Visible = true; divNoMess.Visible = false; } }
public static int CreateFromEmail( string title, string description, int project_id, int type_id, int priority, int severity_id, int task_time, int expected_duration, int expected_response_time, int expected_assign_time, ArrayList categories, ArrayList incident_categories, int IncidentBoxId, int EMailMessageId, PrimaryKeyId orgUid, PrimaryKeyId contactUid, int mustResponsibleId, bool useDuration, DateTime expResolveDate ) { if (!Company.CheckDiskSpace()) throw new MaxDiskSpaceException(); // OZ 2009-03-11 Fixed AccessDeniedException if user is inactive //if (!CanCreate(project_id)) // throw new AccessDeniedException(); title = title.Replace("<", "<").Replace(">", ">"); DateTime now = DateTime.UtcNow; object oProjectId = null; if (project_id > 0) oProjectId = project_id; EMailMessageInfo mi = EMailMessageInfo.Load(EMailMessageId); // int SenderUserID = -1; // TODO: Find User By Email // int UserId = Security.CurrentUser.UserID; // if (SenderUserID > 0) // UserId = SenderUserID; if (orgUid == PrimaryKeyId.Empty && contactUid == PrimaryKeyId.Empty) { Client client = Common.GetClient(mi.SenderEmail); if (client != null) { if (client.IsContact) { contactUid = client.Id; } else { orgUid = client.Id; } } } int stateId, managerId, responsibleId; bool isResposibleGroup; ArrayList users = new ArrayList(); Issue2.GetIssueBoxSettings(IncidentBoxId, out stateId, out managerId, out responsibleId, out isResposibleGroup, users); // 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); } // //ak [2009-06-10] responsible from creation page (IncidentEdit1) if (mustResponsibleId > 0) { responsibleId = mustResponsibleId; // O.R. [2009-12-17] upcoming state with responsible fix if (stateId == (int)ObjectStates.Upcoming) stateId = (int)ObjectStates.Active; isResposibleGroup = false; } IncidentBox box = IncidentBox.Load(IncidentBoxId); if (useDuration) expResolveDate = DBCalendar.GetFinishDateByDuration(box.Document.GeneralBlock.CalendarId, now, expected_duration); else { expResolveDate = User.GetUTCDate(expResolveDate); expected_duration = DBCalendar.GetDurationByFinishDate(box.Document.GeneralBlock.CalendarId, now, expResolveDate); } int IncidentId; using(DbTransaction tran = DbTransaction.Begin()) { // Remove from Pending PendingEMailMessageRow.DeleteByEMailMessageId(EMailMessageId); // Add to white list if (PortalConfig.UseAntiSpamFilter && PortalConfig.AutoFillWhiteList) WhiteListItem.Create(mi.SenderEmail); IncidentId = DBIncident.Create(oProjectId, Security.UserID, title, description, now, type_id, priority, stateId, severity_id, true, task_time, IncidentBoxId, responsibleId, isResposibleGroup ? 1 : 0, contactUid, orgUid, expected_duration, expected_response_time, expected_assign_time, expResolveDate, useDuration); string Identifier = TicketUidUtil.Create(box.IdentifierMask, IncidentId); DBIncident.UpdateIdentifier(IncidentId, Identifier); // Categories foreach(int CategoryId in categories) { DBCommon.AssignCategoryToObject((int)INCIDENT_TYPE, IncidentId, CategoryId); } // Incident Categories foreach(int CategoryId in incident_categories) { DBIncident.AssignIncidentCategory(IncidentId, CategoryId); } foreach(int UserId in activeUsers) { DbIssue2.ResponsibleGroupAddUser(IncidentId, UserId); } // Update Incident Identifier //string Ticket = TicketUidUtil.Create(box.IdentifierMask,IncidentId); //DBIncident.UpdateIdentifier(IncidentId, Ticket); // Forum // Upload Forum Message BaseIbnContainer FOcontainer = BaseIbnContainer.Create("FileLibrary",string.Format("IncidentId_{0}",IncidentId)); ForumStorage forumStorage = (ForumStorage)FOcontainer.LoadControl("ForumStorage"); ForumThreadNodeInfo 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.Incoming, "1"); settings.Add(ForumThreadNodeSetting.Question, "1"); // O.R: Recalculating project TaskTime if (project_id > 0 && task_time > 0) TimeTracking.RecalculateProjectTaskTime(project_id); // 2006-12-12 OZ: Register EMail External Recepient EMailIssueExternalRecipient.Create(IncidentId, mi.SenderEmail); string emailFrom = EMail.EMailRouterOutputMessage.FindEMailRouterPublicEmail(IncidentId); ArrayList excludeUsers = EMailRouterOutputMessage.Send(IncidentId, EMailMessageId); //SystemEvents.AddSystemEvents(SystemEventTypes.Issue_Created, IncidentId, -1, sendAutoReply ? mi.SenderEmail : null, emailFrom, excludeUsers); // 2007-02-12 OZ: Auto reply per Issue Box EMailRouterOutputMessage.SendAutoReply(IncidentId, emailFrom, mi.SenderEmail); // O.R.[2008-12-16]: Recalculate Current Responsible DBIncident.RecalculateCurrentResponsible(IncidentId); // O.R. [2009-06-15]: Recalculate project dates if (project_id > 0 && PortalConfig.UseIncidentDatesForProject && !useDuration) Project.RecalculateDates(project_id); if(project_id > 0) SystemEvents.AddSystemEvents(SystemEventTypes.Project_Updated_IssueList_IssueAdded, project_id, IncidentId, excludeUsers); Issue2.SendAlertsForNewIssue(IncidentId, managerId, responsibleId, activeUsers, excludeUsers); // 2007-02-15: OZ: New Message Addon Issue2.SetNewMessage(IncidentId, true); // // O.R. [2008-09-22]: Gate for sender Issue2.UpdateMailSenderEmail(IncidentId, mi.SenderEmail); tran.Commit(); } return IncidentId; }
public static int Create( string title, string description, int project_id, int type_id, int priority, int severity_id, int task_time, int expected_duration, int expected_response_time, int expected_assign_time, int creator_id, ArrayList categories, ArrayList incident_categories, string FileName, System.IO.Stream _inputStream, bool IsEmail, DateTime creation_date, int IncidentBoxId, PrimaryKeyId contactUid, PrimaryKeyId orgUid, int mustResponsibleId, bool useDuration, DateTime expResolveDate ) { if (!Company.CheckDiskSpace()) throw new MaxDiskSpaceException(); if (!CanCreate(project_id)) throw new AccessDeniedException(); // DateTime creation_date = DateTime.UtcNow; title = title.Replace("<", "<").Replace(">", ">"); object oProjectId = null; if (project_id > 0) oProjectId = project_id; IncidentBox box = null; if(IncidentBoxId <= 0) { IncidentInfo info = new IncidentInfo(); info.Description = description; info.GeneralCategories = categories; info.IncidentCategories = incident_categories; info.PriorityId = priority; info.SeverityId = severity_id; info.Title = title; info.TypeId = type_id; info.ContactUid = contactUid; info.OrgUid = orgUid; if (project_id > 0) info.ProjectId = project_id; if(creator_id < 0) info.CreatorId = Security.CurrentUser.UserID; else info.CreatorId = creator_id; box = IncidentBoxRule.Evaluate(info); if (box == null) throw new ArgumentNullException("box"); IncidentBoxId = box.IncidentBoxId; } else box = IncidentBox.Load(IncidentBoxId); // OZ: Fixed expected_duration and expected_response_time if (expected_duration <= 0) expected_duration = box.Document.GeneralBlock.ExpectedDuration; if (expected_response_time <= 0) expected_response_time = box.Document.GeneralBlock.ExpectedResponseTime; if (expected_assign_time <= 0) expected_assign_time = box.Document.GeneralBlock.ExpectedAssignTime; // if (task_time <= 0) task_time = box.Document.GeneralBlock.TaskTime; int stateId, managerId, responsibleId; bool isResposibleGroup; ArrayList users = new ArrayList(); Issue2.GetIssueBoxSettings(IncidentBoxId, out stateId, out managerId, out responsibleId, out isResposibleGroup, users); // 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); } // //ak [2009-06-10] responsible from creation page (IncidentEdit1) if (mustResponsibleId > 0) { responsibleId = mustResponsibleId; isResposibleGroup = false; } if (useDuration) expResolveDate = DBCalendar.GetFinishDateByDuration(box.Document.GeneralBlock.CalendarId, creation_date, expected_duration); else { expResolveDate = User.GetUTCDate(expResolveDate); expected_duration = DBCalendar.GetDurationByFinishDate(box.Document.GeneralBlock.CalendarId, creation_date, expResolveDate); } int issueId; using(DbTransaction tran = DbTransaction.Begin()) { issueId = DBIncident.Create(oProjectId, creator_id, title, description, creation_date, type_id, priority, stateId, severity_id, IsEmail, task_time, IncidentBoxId, responsibleId, isResposibleGroup?1:0, contactUid, orgUid, expected_duration, expected_response_time, expected_assign_time, expResolveDate, useDuration); string Identifier = TicketUidUtil.Create(box.IdentifierMask,issueId); DBIncident.UpdateIdentifier(issueId, Identifier); // Categories foreach(int CategoryId in categories) { DBCommon.AssignCategoryToObject((int)INCIDENT_TYPE, issueId, CategoryId); } // Incident Categories foreach(int CategoryId in incident_categories) { DBIncident.AssignIncidentCategory(issueId, CategoryId); } foreach(int UserId in activeUsers) { DbIssue2.ResponsibleGroupAddUser(issueId, UserId); } ForumStorage.NodeContentType _type = (FileName != String.Empty && _inputStream != null) ? ForumStorage.NodeContentType.TextWithFiles : ForumStorage.NodeContentType.Text; // Forum BaseIbnContainer destContainer = BaseIbnContainer.Create("FileLibrary", string.Format("IncidentId_{0}", issueId)); ForumStorage forumStorage = (ForumStorage)destContainer.LoadControl("ForumStorage"); if(description != String.Empty || (FileName != String.Empty && _inputStream != null)) { ForumThreadNodeInfo info = forumStorage.CreateForumThreadNode(description, creator_id, (int)_type); if(FileName != String.Empty && _inputStream != null) { BaseIbnContainer forumContainer = BaseIbnContainer.Create("FileLibrary", string.Format("ForumNodeId_{0}", info.Id)); FileStorage fs = (FileStorage)forumContainer.LoadControl("FileStorage"); fs.SaveFile(FileName, _inputStream); } ForumThreadNodeSettingCollection settings1 = new ForumThreadNodeSettingCollection(info.Id); settings1.Add(ForumThreadNodeSetting.Internal, "1"); settings1.Add(ForumThreadNodeSetting.Question, "1"); } // O.R: Recalculating project TaskTime if (project_id > 0 && task_time > 0) TimeTracking.RecalculateProjectTaskTime(project_id); // O.R.[2008-12-16]: Recalculate Current Responsible DBIncident.RecalculateCurrentResponsible(issueId); // O.R. [2009-06-15]: Recalculate project dates if (project_id > 0 && PortalConfig.UseIncidentDatesForProject && !useDuration) Project.RecalculateDates(project_id); SystemEvents.AddSystemEvents(SystemEventTypes.Issue_Created, issueId); if(project_id > 0) SystemEvents.AddSystemEvents(SystemEventTypes.Project_Updated_IssueList_IssueAdded, project_id, issueId); Issue2.SendAlertsForNewIssue(issueId, managerId, responsibleId, activeUsers, null); tran.Commit(); } return issueId; }
protected void btnSubmit_Click(object sender, System.EventArgs e) { bool withResponse = false; if (this.IsPostBack) { try { string sUserLight = "userlight"; // check user's name and password here UserLight currentUser = Security.GetUser(Login.Value, Password.Value); if (currentUser == null) throw new HttpException(405, "Your login or password is invalid."); // Security Addon [3/2/2004] UserLight retUser = null; if (HttpContext.Current.Items.Contains(sUserLight)) { retUser = (UserLight)HttpContext.Current.Items[sUserLight]; HttpContext.Current.Items.Remove(sUserLight); } HttpContext.Current.Items.Add(sUserLight, currentUser); // End Security Addon [3/2/2004] // New Folder System Addon [12/27/2005] string ContainerName = "FileLibrary"; string ContainerKey = String.Empty; int objectId = Int32.Parse(ObjectId.Value); int objectTypeId = Int32.Parse(ObjectTypeId.Value); int folderId = 0; switch ((ObjectTypes)objectTypeId) { case ObjectTypes.Project: ContainerKey = "ProjectId_" + objectId.ToString(); break; case ObjectTypes.Issue: ContainerKey = string.Empty; break; case ObjectTypes.Task: ContainerKey = "TaskId_" + objectId.ToString(); break; case ObjectTypes.CalendarEntry: ContainerKey = "EventId_" + objectId.ToString(); break; case ObjectTypes.Folder: ContainerKey = "Workspace"; if (objectId != 0) { folderId = objectId; ContainerKey = Mediachase.IBN.Business.ControlSystem.DirectoryInfo.GetContainerKey(folderId); } break; case ObjectTypes.Document: ContainerKey = "DocumentId_" + objectId.ToString(); break; case ObjectTypes.ToDo: ContainerKey = "ToDoId_" + objectId.ToString(); break; } if (ContainerKey != String.Empty) { Mediachase.IBN.Business.ControlSystem.BaseIbnContainer bic = Mediachase.IBN.Business.ControlSystem.BaseIbnContainer.Create(ContainerName, ContainerKey); Mediachase.IBN.Business.ControlSystem.FileStorage fs = (Mediachase.IBN.Business.ControlSystem.FileStorage)bic.LoadControl("FileStorage"); if (folderId == 0) folderId = fs.Root.Id; string fileName = Path.GetFileName(PublishedFile.PostedFile.FileName); if (FileName.Value != string.Empty) { fileName = FileName.Value; } /*int index = 0; while (fs.FileExist(fileName, folderId)) { fileName = Path.GetFileNameWithoutExtension(PublishedFile.PostedFile.FileName) + (index++).ToString(); fileName += Path.GetExtension(PublishedFile.PostedFile.FileName); }*/ fs.SaveFile(folderId, fileName, PublishedFile.PostedFile.InputStream); } else if ((ObjectTypes)objectTypeId == ObjectTypes.List) { string xml = SaveNParseExcel(PublishedFile.PostedFile.FileName, PublishedFile.PostedFile.InputStream); Response.BinaryWrite(System.Text.Encoding.UTF8.GetBytes(xml)); withResponse = true; } else if ((ObjectTypes)objectTypeId == ObjectTypes.Issue) { string fileName = Path.GetFileName(PublishedFile.PostedFile.FileName); if (FileName.Value != string.Empty) { fileName = FileName.Value; } // OZ: 2008-08-19 Add Process Eml Attachments if (Path.GetExtension(fileName).ToLower() == ".eml") { // Calculate email box int emailBoxId = EMailRouterOutputMessage.FindEMailRouterPublicId(objectId); // Save Email to email storage int eMailMessageId = EMailMessage.CreateFromStream(emailBoxId, PublishedFile.PostedFile.InputStream); EMailMessage.AddToIncidentMessage(false, objectId, eMailMessageId); try { ArrayList excludeUsers = EMailRouterOutputMessage.Send(objectId, eMailMessageId); SystemEvents.AddSystemEvents(SystemEventTypes.Issue_Updated_Forum_MessageAdded, objectId, -1, excludeUsers); } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex); //Log.WriteError(ex.ToString()); } } // Process Default files else { BaseIbnContainer destContainer = BaseIbnContainer.Create("FileLibrary", string.Format("IncidentId_{0}", objectId)); ForumStorage forumStorage = (ForumStorage)destContainer.LoadControl("ForumStorage"); ForumThreadNodeInfo info = forumStorage.CreateForumThreadNode(string.Empty, Security.CurrentUser.UserID, (int)ForumStorage.NodeContentType.TextWithFiles); BaseIbnContainer forumContainer = BaseIbnContainer.Create("FileLibrary", string.Format("ForumNodeId_{0}", info.Id)); FileStorage fs = (FileStorage)forumContainer.LoadControl("FileStorage"); fs.SaveFile(fileName, PublishedFile.PostedFile.InputStream); ForumThreadNodeSettingCollection settings1 = new ForumThreadNodeSettingCollection(info.Id); settings1.Add(ForumThreadNodeSetting.Internal, "1"); } } // End New Folder System Addon [12/27/2005] // Security Addon [3/2/2004] HttpContext.Current.Items.Remove(sUserLight); HttpContext.Current.Items.Add(sUserLight, retUser); // End Security Addon [3/2/2004] } catch (Exception ex) { throw new HttpException(405, "Internal Exception", ex); } if (!withResponse) { this.Response.Write("Published Completed"); } this.Response.End(); } }
public static void SetWorkaroundStatus(int ThreadNodeId) { ForumThreadNodeSettingCollection settings = new ForumThreadNodeSettingCollection(ThreadNodeId); settings.Add(ForumThreadNodeSetting.Workaround, "1"); }
public static void SetResolutionStatus(int ThreadNodeId) { ForumThreadNodeSettingCollection settings = new ForumThreadNodeSettingCollection(ThreadNodeId); settings.Add(ForumThreadNodeSetting.Resolution, "1"); }
private void BindEmail() { EMailMessageInfo mi = EMailMessageInfo.Load(EMailId); lblFrom.Text = mi.From; lblSubj.Text = mi.Subject; lblBody.Text = mi.HtmlBody; string sAttach = ""; for (int i = 0; i < mi.Attachments.Length; i++) { AttachmentInfo ai = mi.Attachments[i]; int id = DSFile.GetContentTypeByFileName(ai.FileName); string sIcon = ""; if (id > 0) { sIcon = String.Format("<img align='absmiddle' border='0' src='{0}' />", ResolveUrl("~/Common/ContentIcon.aspx?IconID=" + id)); } //sAttach += String.Format("<nobr><a href='{0}'{2}>{1}</a></nobr> ", // ResolveUrl("~/Incidents/EmailAttachDownload.aspx")+"?EMailId="+EMailId.ToString()+"&AttachmentIndex="+i.ToString(), // sIcon + " " + ai.FileName, // Mediachase.IBN.Business.Common.OpenInNewWindow(ai.ContentType) ? " target='_blank'" : ""); sAttach += String.Format("<nobr><a href='{0}'{2}>{1}</a></nobr> ", WebDavUrlBuilder.GetEmailAtachWebDavUrl(EMailId, i, true), sIcon + " " + ai.FileName, Mediachase.IBN.Business.Common.OpenInNewWindow(ai.ContentType) ? " target='_blank'" : ""); } lblAttach.Text = sAttach; lblBody.Text += " "; if (NodeId > 0) { ForumThreadNodeSettingCollection coll = new ForumThreadNodeSettingCollection(NodeId); if (!String.IsNullOrEmpty(coll[ForumThreadNodeSetting.AllRecipients])) lblTo.Text = coll[ForumThreadNodeSetting.AllRecipients]; } }
/// <summary> /// Updates the quick tracking. /// </summary> /// <param name="issueId">The issue id.</param> /// <param name="message">The message.</param> /// <param name="stateId">The state id.</param> /// <param name="priorityId">The priority id.</param> /// <param name="issueBoxId">The issue box id.</param> /// <param name="projectId">The project id.</param> /// <param name="responsibleId">The responsible id.</param> /// <param name="isResponsibleGroup">if set to <c>true</c> [is responsible group].</param> /// <param name="responsibleGroup">The responsible group.</param> /// <param name="decline">if set to <c>true</c> [decline].</param> /// <param name="useNewResponsible">if set to <c>true</c> [use new responsible from Issue Box].</param> public static void UpdateQuickTracking(int issueId, string message, int stateId, int priorityId, int? issueBoxId, int? projectId, int responsibleId, bool isResponsibleGroup, DataTable responsibleGroup, bool decline, bool useNewResponsible) { using (DbTransaction tran = DbTransaction.Begin()) { int nodeId = -1; if (message != null && message.Trim().Length > 0) { BaseIbnContainer destContainer = BaseIbnContainer.Create("FileLibrary", string.Format("IncidentId_{0}", issueId)); ForumStorage forumStorage = (ForumStorage)destContainer.LoadControl("ForumStorage"); ForumThreadNodeInfo info = forumStorage.CreateForumThreadNode(message, Security.UserID, 1); ForumThreadNodeSettingCollection settings1 = new ForumThreadNodeSettingCollection(info.Id); settings1.Add(ForumThreadNodeSetting.Internal, "1"); nodeId = info.Id; SystemEvents.AddSystemEvents(SystemEventTypes.Issue_Updated_Forum_MessageAdded, issueId); } if (issueBoxId.HasValue && projectId.HasValue && Incident.CanChangeProject(issueId)) { UpdateProject(issueId, projectId.Value, false); UpdateIncidentBox(issueId, issueBoxId.Value, false); if (useNewResponsible) { decline = false; responsibleGroup.Rows.Clear(); IncidentBox box = IncidentBox.Load(issueBoxId.Value); ResponsibleAssignType responsibleAssignType = box.Document.GeneralBlock.ResponsibleAssignType; if (responsibleAssignType == ResponsibleAssignType.Manual) { responsibleId = -1; isResponsibleGroup = false; } else if (responsibleAssignType == ResponsibleAssignType.CustomUser) { responsibleId = box.Document.GeneralBlock.Responsible; isResponsibleGroup = false; } else // Pool { responsibleId = -1; isResponsibleGroup = true; List<int> responsibleUsers = new List<int>(); foreach (int principalId in box.Document.GeneralBlock.ResponsiblePool) { if (User.IsGroup(principalId)) { using (IDataReader reader = DBGroup.GetListUsersInGroup(principalId)) { while (reader.Read()) { if (!responsibleUsers.Contains((int)reader["UserId"]) && (int)reader["Activity"] == 3) responsibleUsers.Add((int)reader["UserId"]); } } } else { if (!responsibleUsers.Contains(principalId) && User.GetUserActivity(principalId) == User.UserActivity.Active) responsibleUsers.Add(principalId); } } // responsibleGroup foreach (int principalId in responsibleUsers) { DataRow row = responsibleGroup.NewRow(); row["PrincipalId"] = principalId; row["IsNew"] = true; row["ResponsePending"] = true; responsibleGroup.Rows.Add(row); } } } } UpdateTrackingState(issueId, nodeId, stateId, priorityId, responsibleId, isResponsibleGroup, responsibleGroup, decline); tran.Commit(); } }
public static void UpdateQuickTracking(int IssueId, string Message, int ResponsibleId, bool IsResponsibleGroup, DataTable ResponsibleGroup) { using (DbTransaction tran = DbTransaction.Begin()) { int NodeId = -1; if (Message != null && Message.Trim().Length > 0) { BaseIbnContainer destContainer = BaseIbnContainer.Create("FileLibrary", string.Format("IncidentId_{0}", IssueId)); ForumStorage forumStorage = (ForumStorage)destContainer.LoadControl("ForumStorage"); ForumThreadNodeInfo info = forumStorage.CreateForumThreadNode(Message, Security.UserID, 1); ForumThreadNodeSettingCollection settings1 = new ForumThreadNodeSettingCollection(info.Id); settings1.Add(ForumThreadNodeSetting.Internal, "1"); NodeId = info.Id; SystemEvents.AddSystemEvents(SystemEventTypes.Issue_Updated_Forum_MessageAdded, IssueId); } UpdateTrackingState(IssueId, NodeId, ResponsibleId, IsResponsibleGroup, ResponsibleGroup); tran.Commit(); } }
public static void AddForumMessage2(int issueId, string messText, int nodeType, ArrayList nodeAttribute, bool toSend, int stateId, string FileName1, System.IO.Stream inputStream1, string FileName2, System.IO.Stream inputStream2, string FileName3, System.IO.Stream inputStream3) { int oldState; using(IDataReader reader = Incident.GetIncident(issueId, false)) { reader.Read(); oldState = (int)reader["StateId"]; } using(DbTransaction tran = DbTransaction.Begin()) { ForumThreadNodeInfo info = null; if (messText.Trim() != String.Empty || FileName1 != String.Empty || FileName2 != String.Empty || FileName3 != String.Empty) { BaseIbnContainer destContainer = BaseIbnContainer.Create("FileLibrary", string.Format("IncidentId_{0}", issueId)); ForumStorage forumStorage = (ForumStorage)destContainer.LoadControl("ForumStorage"); info = forumStorage.CreateForumThreadNode(messText, Security.CurrentUser.UserID, nodeType); if (FileName1 != String.Empty && inputStream1 != null) { BaseIbnContainer forumContainer = BaseIbnContainer.Create("FileLibrary", string.Format("ForumNodeId_{0}", info.Id)); FileStorage fs = (FileStorage)forumContainer.LoadControl("FileStorage"); fs.SaveFile(FileName1, inputStream1); } if (FileName2 != String.Empty && inputStream2 != null) { BaseIbnContainer forumContainer = BaseIbnContainer.Create("FileLibrary", string.Format("ForumNodeId_{0}", info.Id)); FileStorage fs = (FileStorage)forumContainer.LoadControl("FileStorage"); fs.SaveFile(FileName2, inputStream2); } if (FileName3 != String.Empty && inputStream3 != null) { BaseIbnContainer forumContainer = BaseIbnContainer.Create("FileLibrary", string.Format("ForumNodeId_{0}", info.Id)); FileStorage fs = (FileStorage)forumContainer.LoadControl("FileStorage"); fs.SaveFile(FileName3, inputStream3); } ForumThreadNodeSettingCollection settings = new ForumThreadNodeSettingCollection(info.Id); //if(toSend) //{ // settings.Add(ForumThreadNodeSetting.Outgoing, "1"); // //EMailRouterOutputMessage.SendOutgoing(issueId, info.Id); //} //else settings.Add(ForumThreadNodeSetting.Internal, "1"); foreach(string sAttr in nodeAttribute) settings.Add(sAttr, "1"); SystemEvents.AddSystemEvents(SystemEventTypes.Issue_Updated_Forum_MessageAdded, issueId); } if(stateId > 0 && stateId != oldState) UpdateStateAndNotifyController(issueId, stateId, info.Id); tran.Commit(); } }
private void BindDataGrid() { DataTable dt = new DataTable(); DataRow dr; #region DataTable dt.Columns.Add(new DataColumn("Id", typeof(int))); dt.Columns.Add(new DataColumn("Index", typeof(string))); dt.Columns.Add(new DataColumn("EMailMessageId", typeof(int))); dt.Columns.Add(new DataColumn("Sender", typeof(string))); dt.Columns.Add(new DataColumn("Message", typeof(string))); dt.Columns.Add(new DataColumn("SystemMessage", typeof(string))); dt.Columns.Add(new DataColumn("Created", typeof(string))); dt.Columns.Add(new DataColumn("CreationDate", typeof(DateTime))); dt.Columns.Add(new DataColumn("Attachments", typeof(string))); dt.Columns.Add(new DataColumn("NodeType", typeof(string))); dt.Columns.Add(new DataColumn("CanMakeResolution", typeof(bool))); dt.Columns.Add(new DataColumn("CanMakeWorkaround", typeof(bool))); dt.Columns.Add(new DataColumn("CanUnMakeResolution", typeof(bool))); dt.Columns.Add(new DataColumn("CanUnMakeWorkaround", typeof(bool))); dt.Columns.Add(new DataColumn("CanReSend", typeof(bool))); dt.Columns.Add(new DataColumn("CanReSendOut", typeof(bool))); dt.Columns.Add(new DataColumn("CanReply", typeof(bool))); #endregion IncidentBox incidentBox = IncidentBox.Load(Incident.GetIncidentBox(IncidentId)); EMailRouterIncidentBoxBlock settings = IncidentBoxDocument.Load(incidentBox.IncidentBoxId).EMailRouterBlock; bool allowEMailRouting = settings.AllowEMailRouting; bool CanUpdate = Incident.CanUpdate(IncidentId); int _index = 0; foreach (ForumThreadNodeInfo node in Incident.GetForumThreadNodes(IncidentId)) { #region Define Node Type string typeName = "internal"; ForumThreadNodeSettingCollection coll = new ForumThreadNodeSettingCollection(node.Id); if (coll[ForumThreadNodeSetting.Question] != null) { if (coll[ForumThreadNodeSetting.Incoming] != null) typeName = "Mail_incoming_quest"; else if (coll[ForumThreadNodeSetting.Outgoing] != null) typeName = "Mail_outgoing_quest"; else typeName = "internal_quest"; } else if (coll[ForumThreadNodeSetting.Resolution] != null) { if (coll[ForumThreadNodeSetting.Incoming] != null) typeName = "Mail_incoming_resol"; else if (coll[ForumThreadNodeSetting.Outgoing] != null) typeName = "Mail_outgoing_resol"; else typeName = "internal_resol"; } else if (coll[ForumThreadNodeSetting.Workaround] != null) { if (coll[ForumThreadNodeSetting.Incoming] != null) typeName = "Mail_incoming_wa"; else if (coll[ForumThreadNodeSetting.Outgoing] != null) typeName = "Mail_outgoing_wa"; else typeName = "internal_wa"; } else if (coll[ForumThreadNodeSetting.Incoming] != null) typeName = "Mail_incoming"; else if (coll[ForumThreadNodeSetting.Outgoing] != null) typeName = "Mail_outgoing"; #endregion dr = dt.NewRow(); dr["Id"] = node.Id; dr["EMailMessageId"] = node.EMailMessageId; dr["CanMakeResolution"] = false; dr["CanMakeWorkaround"] = false; dr["CanUnMakeResolution"] = false; dr["CanUnMakeWorkaround"] = false; dr["CanReply"] = false; dr["CanReSend"] = false; dr["CanReSendOut"] = false; switch (typeName) { case "internal_resol": case "Mail_incoming_resol": case "Mail_outgoing_resol": dr["CanUnMakeResolution"] = true; break; case "internal_wa": case "Mail_incoming_wa": case "Mail_outgoing_wa": dr["CanMakeResolution"] = true; dr["CanUnMakeWorkaround"] = true; break; case "internal": case "Mail_incoming": case "Mail_outgoing": dr["CanMakeResolution"] = true; dr["CanMakeWorkaround"] = true; break; default: break; } if (coll[ForumThreadNodeSetting.Outgoing] != null && !Mediachase.IBN.Business.Security.CurrentUser.IsExternal) dr["CanReSendOut"] = true; if (coll[ForumThreadNodeSetting.Incoming] != null && !Mediachase.IBN.Business.Security.CurrentUser.IsExternal) { dr["CanReply"] = true; dr["CanReSend"] = allowEMailRouting; } if (node.EMailMessageId <= 0) dr["Sender"] = Mediachase.UI.Web.Util.CommonHelper.GetUserStatus(node.CreatorId); dr["Created"] = node.Created.ToShortDateString() + " " + node.Created.ToShortTimeString(); dr["CreationDate"] = node.Created; string sNodeType = typeName; try { sNodeType = LocRM.GetString(String.Format("NodeType_{0}", typeName)); } catch { } dr["NodeType"] = String.Format("<img src='{2}/{0}.gif' width=24 height=16 align=absmiddle alt='{1}'>", typeName, sNodeType, ResolveClientUrl("~/layouts/images/icons")); dr["SystemMessage"] = String.Empty; string sMessage = ""; if (coll[IncidentForum.IssueEvent.Declining.ToString()] != null) { sMessage = String.Format("<font color='red'><b>{0}</b></font>", LocRM.GetString("tUserDeclined")); } if (coll[IncidentForum.IssueEvent.State.ToString()] != null) { int stateId = int.Parse(coll[IncidentForum.IssueEvent.State.ToString()].ToString()); if (sMessage == "") sMessage = String.Format("{2}: <font color='{0}'><b>{1}</b></font>", Mediachase.UI.Web.Util.CommonHelper.GetStateColorString(stateId), GetStatusName(stateId), LocRM.GetString("Status")); else sMessage += String.Format("{2}: <font color='{0}'><b>{1}</b></font>", Mediachase.UI.Web.Util.CommonHelper.GetStateColorString(stateId), GetStatusName(stateId), LocRM.GetString("Status")); } if (coll[IncidentForum.IssueEvent.Responsibility.ToString()] != null) { int iResp = int.Parse(coll[IncidentForum.IssueEvent.Responsibility.ToString()].ToString()); string sResp = ""; if (iResp == -2) sResp = String.Format("<img align='absmiddle' border='0' src='{0}' /> <font color='#808080'><b>{1}</b></font>", ResolveClientUrl("~/layouts/images/not_set.png"), LocRM.GetString("tRespNotSet")); else if (iResp == -1) sResp = String.Format("<img align='absmiddle' border='0' src='{0}' /> <font color='green'><b>{1}</b></font>", ResolveClientUrl("~/layouts/images/waiting.gif"), LocRM.GetString("tRespGroup")); else sResp = Mediachase.UI.Web.Util.CommonHelper.GetUserStatus(iResp); if (sMessage == "") sMessage = LocRM.GetString("tResponsible") + ": " + sResp; else sMessage += "<br />" + LocRM.GetString("tResponsible") + ": " + sResp; } if (WasFarwarded == 1 && node.EMailMessageId == ForwardedEMail) sMessage = "<font color='green'><b>" + LocRM.GetString("tWasResended") + "</b></font><br/>" + sMessage; if (WasFarwarded == -1 && node.EMailMessageId == ForwardedEMail) sMessage = "<font color='red'><b>" + LocRM.GetString("tWasNotResended") + "</b></font><br/>" + sMessage; dr["SystemMessage"] = (sMessage.Length == 0) ? String.Empty : sMessage; string sAttach = ""; #region EmailMessage - Attachments if (node.EMailMessageId > 0) { EMailMessageInfo mi = null; try { mi = EMailMessageInfo.Load(node.EMailMessageId); int iUserId = User.GetUserByEmail(mi.SenderEmail); if (EMailClient.IsAlertSenderEmail(mi.SenderEmail)) iUserId = node.CreatorId; if (iUserId > 0) dr["Sender"] = Mediachase.UI.Web.Util.CommonHelper.GetUserStatus(iUserId); else { Client client = Mediachase.IBN.Business.Common.GetClient(mi.SenderEmail); if (client != null) { if (client.IsContact) dr["Sender"] = Mediachase.UI.Web.Util.CommonHelper.GetContactLink(this.Page, client.Id, client.Name); else dr["Sender"] = Mediachase.UI.Web.Util.CommonHelper.GetOrganizationLink(this.Page, client.Id, client.Name); } else if (mi.SenderName != "") dr["Sender"] = Mediachase.UI.Web.Util.CommonHelper.GetEmailLink(mi.SenderEmail, mi.SenderName); else dr["Sender"] = Mediachase.UI.Web.Util.CommonHelper.GetEmailLink(mi.SenderEmail, mi.SenderEmail); } string sBody = String.Empty; if (mi.HtmlBody != null) sBody = mi.HtmlBody; dr["Message"] = sBody; // Attachments for (int i = 0; i < mi.Attachments.Length; i++) { AttachmentInfo ai = mi.Attachments[i]; int id = DSFile.GetContentTypeByFileName(ai.FileName); string sIcon = ""; if (id > 0) { sIcon = String.Format("<img align='absmiddle' border='0' src='{0}' />", ResolveClientUrl("~/Common/ContentIcon.aspx?IconID=" + id)); } //sAttach += String.Format("<nobr><a href='{0}'{2}>{1}</a></nobr> ", // ResolveClientUrl("~/Incidents/EmailAttachDownload.aspx") + "?EMailId=" + node.EMailMessageId.ToString() + "&AttachmentIndex=" + i.ToString(), // sIcon + " " + ai.FileName, // Mediachase.IBN.Business.Common.OpenInNewWindow(ai.ContentType) ? " target='_blank'" : ""); sAttach += String.Format("<nobr><a href='{0}'{2}>{1}</a></nobr> ", WebDavUrlBuilder.GetEmailAtachWebDavUrl(node.EMailMessageId, i, true), sIcon + " " + ai.FileName, Mediachase.IBN.Business.Common.OpenInNewWindow(ai.ContentType) ? " target='_blank'" : ""); } } catch { dr["Sender"] = Mediachase.UI.Web.Util.CommonHelper.GetUserStatus(-1); dr["Message"] = String.Format("<font color='red'><b>{0}</b> (#{1})</font>", LocRM.GetString("tNotFound"), node.EMailMessageId); } } else { string sBody = Mediachase.UI.Web.Util.CommonHelper.parsetext_br(node.Text, false); dr["Message"] = sBody; // Files if (node.ContentType == ForumStorage.NodeContentType.TextWithFiles) { FileInfo[] files = Incident.GetForumNodeFiles(node.Id); if (files.Length > 0) { foreach (FileInfo fl in files) { if (sAttach != "") sAttach += " "; string sTarget = Mediachase.IBN.Business.Common.OpenInNewWindow(fl.FileBinaryContentType) ? " target='_blank'" : ""; string sLink = Mediachase.UI.Web.Util.CommonHelper.GetAbsoluteDownloadFilePath(fl.Id, fl.Name, "FileLibrary", "ForumNodeId_" + node.Id); string sNameLocked = Mediachase.UI.Web.Util.CommonHelper.GetLockerText(sLink); sAttach += String.Format("<nobr><a href=\"{1}\"{3}><img src='{4}?IconID={2}' width='16' height='16' border=0 align=absmiddle> {0}</a> {5}</nobr>", fl.Name, sLink, fl.FileBinaryContentTypeId, sTarget, ResolveClientUrl("~/Common/ContentIcon.aspx"), sNameLocked ); } } } } dr["Attachments"] = sAttach; #endregion if (sMessage.Length > 0 && dr["Message"].ToString() == "" && sAttach.Length == 0) { dr["NodeType"] = String.Format("<img src='{0}' width='16' height='16' align=absmiddle alt='{1}'>", ResolveClientUrl("~/layouts/images/icons/info_message.gif"), LocRM.GetString("NodeType_InfoMessage")); dr["CanMakeResolution"] = false; dr["CanMakeWorkaround"] = false; dr["CanUnMakeResolution"] = false; dr["CanUnMakeWorkaround"] = false; } if (dr["Message"].ToString().Trim() == "") dr["Message"] = " "; dr["Index"] = "<table cellspacing='0' border='0' width='100%'><tr><td class='text' align='center' style='BACKGROUND-POSITION: center center; BACKGROUND-IMAGE: url(../../../layouts/images/atrisk1.gif); BACKGROUND-REPEAT: no-repeat;padding:4px;'><b>" + (++_index).ToString() + "</b></td></tr></table>"; dt.Rows.Add(dr); } DataView dv = dt.DefaultView; dv.Sort = "CreationDate"; dgForum.DataSource = dv; if (dv.Count == 0) { dgForum.Visible = false; dgForum.CurrentPageIndex = 0; divNoMess.Visible = true; divNoMess.InnerHtml = "<font color='red'>" + LocRM.GetString("NoMessages") + "</font>"; } else { dgForum.Visible = true; divNoMess.Visible = false; int ppi = dv.Count / dgForum.PageSize; if (dv.Count % dgForum.PageSize == 0) ppi = ppi - 1; if (ViewState["IncidentForum_Page"] != null) { int iPageIndex = int.Parse(ViewState["IncidentForum_Page"].ToString()); if (iPageIndex <= ppi) dgForum.CurrentPageIndex = iPageIndex; else dgForum.CurrentPageIndex = ppi; ViewState["IncidentForum_Page"] = dgForum.CurrentPageIndex.ToString(); } else dgForum.CurrentPageIndex = ppi; } dgForum.DataBind(); foreach (DataGridItem dgi in dgForum.Items) { ImageButton ib = (ImageButton)dgi.FindControl("ibDelete"); if (ib != null) { ib.ToolTip = LocRM.GetString("Delete"); ib.Attributes.Add("onclick", "return confirm('" + LocRM.GetString("WarningForumNode") + "')"); ib.Visible = CanUpdate; } ImageButton ib1 = (ImageButton)dgi.FindControl("ibResolution"); if (ib1 != null) { ib1.ToolTip = LocRM.GetString("tMarkAsResolution"); ib1.Attributes.Add("onclick", "return confirm('" + LocRM.GetString("tMarkAsResolutionWarning") + "')"); } ImageButton ib2 = (ImageButton)dgi.FindControl("ibWA"); if (ib2 != null) { ib2.ToolTip = LocRM.GetString("tMarkAsWA"); ib2.Attributes.Add("onclick", "return confirm('" + LocRM.GetString("tMarkAsWAWarning") + "')"); } ImageButton ib3 = (ImageButton)dgi.FindControl("ibUnResolution"); if (ib3 != null) { ib3.ToolTip = LocRM.GetString("tUnMarkAsResolution"); ib3.Attributes.Add("onclick", "return confirm('" + LocRM.GetString("tUnMarkAsResolutionWarning") + "')"); } ImageButton ib4 = (ImageButton)dgi.FindControl("ibUnWA"); if (ib4 != null) { ib4.ToolTip = LocRM.GetString("tUnMarkAsWA"); ib4.Attributes.Add("onclick", "return confirm('" + LocRM.GetString("tUnMarkAsWAWarning") + "')"); } ImageButton ib5 = (ImageButton)dgi.FindControl("ibReSend"); if (ib5 != null) { ib5.ToolTip = LocRM.GetString("tReSend"); ib5.Attributes.Add("onclick", "return confirm('" + LocRM.GetString("tReSendWarning") + "')"); } ImageButton ib6 = (ImageButton)dgi.FindControl("ibReSendOut"); if (ib6 != null) { ib6.ToolTip = LocRM.GetString("tReSend"); ib6.Attributes.Add("onclick", "return confirm('" + LocRM.GetString("tReSendOutWarning") + "')"); } ImageButton ib7 = (ImageButton)dgi.FindControl("ibReply"); if (ib7 != null) { ib7.ToolTip = LocRM.GetString("tReply"); if (!allowEMailRouting || (pc["IncForum_ReplyOutlook"] == "0" && pc["IncForum_ReplyEML"] == "0")) { string scommand = String.Format("{{ShowResizableWizard('{0}?IncidentId={1}&NodeId={2}&send=1&back={3}', 800, 600);return false;}}", ResolveClientUrl("~/Incidents/AddEMailMessage.aspx"), IncidentId, ib7.CommandArgument, HttpUtility.UrlEncode(this.Page.Request.RawUrl)); ib7.Attributes.Add("onclick", scommand); } } } }
/// <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; }
/// <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> /// Processes the X ibn headers. /// </summary> /// <param name="IncidentId">The incident id.</param> /// <param name="ThreadNodeId">The thread node id.</param> /// <param name="Msg">The MSG.</param> /// <returns></returns> public static bool ProcessXIbnHeaders(int IncidentId, int ThreadNodeId, Pop3Message Msg) { bool bRetVal = true; ForumStorage.NodeType nodeType = ForumStorage.NodeType.Internal; ForumThreadNodeSettingCollection settings = new ForumThreadNodeSettingCollection(ThreadNodeId); if (settings.Contains(ForumThreadNodeSetting.Incoming)) nodeType = ForumStorage.NodeType.Incoming; else if (settings.Contains(ForumThreadNodeSetting.Outgoing)) nodeType = ForumStorage.NodeType.Outgoing; bool bSetIncidentState = false; ObjectStates cmdObjectStates = ObjectStates.Active; int newResponsibleId = 0; foreach (string HeaderName in Msg.Headers.AllKeys) { string UpHeaderName = HeaderName.ToUpper(); if (UpHeaderName.StartsWith("X-IBN-")) { switch (UpHeaderName) { case "X-IBN-STATE": if (Msg.Headers[HeaderName].Trim() != "0") { cmdObjectStates = (ObjectStates)Enum.Parse(typeof(ObjectStates), Msg.Headers[HeaderName]); if (cmdObjectStates >= ObjectStates.Upcoming && cmdObjectStates <= ObjectStates.OnCheck) { bSetIncidentState = true; } else { // OZ: Wrong Object State cmdObjectStates = ObjectStates.Active; } } break; case "X-IBN-PRIVATEMSG": if (Msg.Headers[HeaderName].Trim() != "0") { XIbnHeaderCommand.SetPrivateStatus(ThreadNodeId); nodeType = ForumStorage.NodeType.Internal; bRetVal = false; } break; case "X-IBN-RESOLUTION": if (Msg.Headers[HeaderName].Trim() != "0") { XIbnHeaderCommand.SetResolutionStatus(ThreadNodeId); } break; case "X-IBN-WORKAROUND": if (Msg.Headers[HeaderName].Trim() != "0") { XIbnHeaderCommand.SetWorkaroundStatus(ThreadNodeId); } break; case "X-IBN-RESPONSIBLE": if (Msg.Headers[HeaderName].Trim() != "0") { newResponsibleId = int.Parse(Msg.Headers[HeaderName]); } break; default: XIbnHeaderCommand.Unknown(IncidentId, Msg.Headers[HeaderName]); break; } } } // Set Default IBN Object State if (!bSetIncidentState) { if (nodeType == ForumStorage.NodeType.Incoming) { IncidentBoxDocument document = IncidentBoxDocument.Load(Incident.GetIncidentBox(IncidentId)); switch (document.EMailRouterBlock.IncomingEMailAction) { case ExternalEMailActionType.None: break; case ExternalEMailActionType.SetReOpenState: XIbnHeaderCommand.SetIncidentState(nodeType, document, IncidentId, ThreadNodeId, ObjectStates.ReOpen); break; } } else if (nodeType == ForumStorage.NodeType.Outgoing) { IncidentBoxDocument document = IncidentBoxDocument.Load(Incident.GetIncidentBox(IncidentId)); switch (document.EMailRouterBlock.OutgoingEMailAction) { case InternalEMailActionType.None: break; case InternalEMailActionType.SendToCheck: XIbnHeaderCommand.SetIncidentState(nodeType, document, IncidentId, ThreadNodeId, ObjectStates.OnCheck); break; case InternalEMailActionType.SetCompletedState: XIbnHeaderCommand.SetIncidentState(nodeType, document, IncidentId, ThreadNodeId, ObjectStates.Completed); break; case InternalEMailActionType.SetSuspendState: XIbnHeaderCommand.SetIncidentState(nodeType, document, IncidentId, ThreadNodeId, ObjectStates.Suspended); break; } } } else { IncidentBoxDocument document = IncidentBoxDocument.Load(Incident.GetIncidentBox(IncidentId)); XIbnHeaderCommand.SetIncidentState(nodeType, document, IncidentId, ThreadNodeId, cmdObjectStates); } // OZ: 2008-11-24 ChangeResponsible, -1 = NotSet, -2 = Group if (newResponsibleId != 0) { XIbnHeaderCommand.ChangeResponsible(IncidentId, newResponsibleId); } return bRetVal; }