Exemplo n.º 1
0
        /// <summary>
        /// Gets the web dav URL by WebDavTicket.
        /// </summary>
        /// <param name="ticket">The ticket.</param>
        /// <returns></returns>
        public static string GetWebDavUrl(string ticket)
        {
            string       retVal       = string.Empty;
            WebDavTicket webDavTicket = WebDavTicket.Parse(ticket);

            //Попытаемся определить имя файла
            if (String.IsNullOrEmpty(webDavTicket.AbsolutePath.FileName))
            {
                if (webDavTicket.AbsolutePath.StorageType == ObjectTypes.File_FileStorage)
                {
                    FileStorageAbsolutePath fsAbsPath = webDavTicket.AbsolutePath as FileStorageAbsolutePath;
                    if (fsAbsPath != null)
                    {
                        FileStorage fs = new FileStorage();
                        Mediachase.IBN.Business.ControlSystem.FileInfo fileInfo = fs.GetFile(fsAbsPath.UniqueId);
                        if (fileInfo != null)
                        {
                            webDavTicket.AbsolutePath.FileName = fileInfo.Name;
                        }
                    }
                }
                else if (webDavTicket.AbsolutePath.StorageType == ObjectTypes.File_MetaData)
                {
                    MetaDataAbsolutePath mdAbsPath = webDavTicket.AbsolutePath as MetaDataAbsolutePath;
                    if (mdAbsPath != null)
                    {
                        Mediachase.Ibn.Data.Meta.FileInfo fileInfo = new Mediachase.Ibn.Data.Meta.FileInfo(mdAbsPath.FileUID);
                        webDavTicket.AbsolutePath.FileName = fileInfo.Name;
                    }
                }
                else if (webDavTicket.AbsolutePath.StorageType == ObjectTypes.File_MetaDataPlus)
                {
                    MetaDataPlusAbsolutePath mdpAbsPath = webDavTicket.AbsolutePath as MetaDataPlusAbsolutePath;
                    if (mdpAbsPath != null)
                    {
                        Mediachase.MetaDataPlus.MetaObject obj = MetaDataWrapper.LoadMetaObject(mdpAbsPath.MetaObjectId, mdpAbsPath.MetaObjectType);
                        MetaFile mf = obj[mdpAbsPath.MetaFieldName] as MetaFile;
                        if (mf != null)
                        {
                            webDavTicket.AbsolutePath.FileName = mf.Name;
                        }
                    }
                }
                else if (webDavTicket.AbsolutePath.StorageType == ObjectTypes.File_Incident)
                {
                    EmailStorageAbsolutePath emlAbsPath = webDavTicket.AbsolutePath as EmailStorageAbsolutePath;
                    if (emlAbsPath != null)
                    {
                        EMailMessageInfo emlInfo    = EMailMessageInfo.Load(emlAbsPath.EmailMsgId);
                        AttachmentInfo   attachInfo = emlInfo.Attachments[emlAbsPath.EmailAttachmentIndex];
                        webDavTicket.AbsolutePath.FileName = attachInfo.FileName;
                    }
                }
            }

            retVal = GetWebDavUrl(webDavTicket.AbsolutePath, true);


            return(retVal);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the web dav URL.
        /// </summary>
        /// <param name="emailId">The email id.</param>
        /// <param name="emailAttachIndex">Index of the email attach.</param>
        /// <param name="withAuthToken">if set to <c>true</c> [with auth token].</param>
        /// <returns></returns>
        public static string GetEmailAtachWebDavUrl(int emailId, int emailAttachIndex, bool withAuthToken)
        {
            EMailMessageInfo emlInfo = EMailMessageInfo.Load(emailId);

            if (emlInfo.Attachments.Length <= emailAttachIndex)
            {
                throw new ArgumentException("emailAttachIndex");
            }

            AttachmentInfo attachInfo = emlInfo.Attachments[emailAttachIndex];

            EmailStorageAbsolutePath absPath = (EmailStorageAbsolutePath)WebDavAbsolutePath.CreateInstance(ObjectTypes.File_Incident);

            absPath.EmailMsgId           = emailId;
            absPath.EmailAttachmentIndex = emailAttachIndex;
            absPath.FileName             = attachInfo.FileName;

            return(GetWebDavUrl(absPath, withAuthToken));
        }
Exemplo n.º 3
0
        private void BindDGMailIncidents()
        {
            DataTable dt = new DataTable();

            dt.Columns.Add(new DataColumn("PendingMessageId", typeof(int)));
//			dt.Columns.Add(new DataColumn("From", typeof(string)));
//			dt.Columns.Add(new DataColumn("To", typeof(string)));
            dt.Columns.Add(new DataColumn("Subject", typeof(string)));
            dt.Columns.Add(new DataColumn("Created", typeof(DateTime)));
            DataRow dr;

            int[] pendList = EMailMessage.ListPendigEMailMessageIds();
            foreach (int id in pendList)
            {
                dr = dt.NewRow();
                dr["PendingMessageId"] = id;
                EMailMessageInfo emi = EMailMessageInfo.Load(id);
//				dr["From"] = GetAddress(emi.From);
//				dr["To"] = GetAddress(emi.To);
                dr["Subject"] = emi.Subject;
                dr["Created"] = emi.Created;
                dt.Rows.Add(dr);
            }
            DataView dv = dt.DefaultView;

            dv.Sort = "Created DESC";

            dgMailIncidents.DataSource = dv;
            dgMailIncidents.DataBind();

            int RowCount = dgMailIncidents.Items.Count;

            if (RowCount == 0)
            {
                Sep3.Visible = false;
                Pan3.Visible = false;
            }
            else
            {
                Sep3.Title = String.Format("{0} ({1})", LocRM.GetString("MI"), RowCount);
            }
        }
Exemplo n.º 4
0
        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> &nbsp;&nbsp;",
                //    ResolveUrl("~/Incidents/EmailAttachDownload.aspx")+"?EMailId="+EMailId.ToString()+"&AttachmentIndex="+i.ToString(),
                //    sIcon + "&nbsp;" + ai.FileName,
                //    Mediachase.IBN.Business.Common.OpenInNewWindow(ai.ContentType) ? " target='_blank'" : "");
                sAttach += String.Format("<nobr><a href='{0}'{2}>{1}</a></nobr> &nbsp;&nbsp;", WebDavUrlBuilder.GetEmailAtachWebDavUrl(EMailId, i, true),
                                         sIcon + "&nbsp;" + ai.FileName, Mediachase.IBN.Business.Common.OpenInNewWindow(ai.ContentType) ? " target='_blank'" : "");
            }
            lblAttach.Text = sAttach;
            lblBody.Text  += "&nbsp;";

            if (NodeId > 0)
            {
                ForumThreadNodeSettingCollection coll = new ForumThreadNodeSettingCollection(NodeId);
                if (!String.IsNullOrEmpty(coll[ForumThreadNodeSetting.AllRecipients]))
                {
                    lblTo.Text = coll[ForumThreadNodeSetting.AllRecipients];
                }
            }
        }
Exemplo n.º 5
0
        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}' />&nbsp;<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}' />&nbsp;<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> &nbsp;&nbsp;",
                            //  ResolveClientUrl("~/Incidents/EmailAttachDownload.aspx") + "?EMailId=" + node.EMailMessageId.ToString() + "&AttachmentIndex=" + i.ToString(),
                            //  sIcon + "&nbsp;" + ai.FileName,
                            //  Mediachase.IBN.Business.Common.OpenInNewWindow(ai.ContentType) ? " target='_blank'" : "");
                            sAttach += String.Format("<nobr><a href='{0}'{2}>{1}</a></nobr> &nbsp;&nbsp;", WebDavUrlBuilder.GetEmailAtachWebDavUrl(node.EMailMessageId, i, true),
                                                     sIcon + "&nbsp;" + 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>&nbsp;(#{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 += "&nbsp;&nbsp;&nbsp;";
                                }

                                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"] = "&nbsp;";
                }
                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);
                    }
                }
            }
        }
Exemplo n.º 6
0
        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"] = "&nbsp;";

                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) ? "&nbsp;" : 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> &nbsp;&nbsp;",
                            //  ResolveUrl("~/Incidents/EmailAttachDownload.aspx") + "?EMailId=" + node.EMailMessageId.ToString() + "&AttachmentIndex=" + i.ToString(),
                            //  sIcon + "&nbsp;" + ai.FileName,
                            //  Mediachase.IBN.Business.Common.OpenInNewWindow(ai.ContentType) ? " target='_blank'" : "");
                            sAttach += String.Format("<a href='{0}'{2} style='white-space:nowrap'>{1}</a> &nbsp;&nbsp;", WebDavUrlBuilder.GetEmailAtachWebDavUrl(node.EMailMessageId, i, true),
                                                     sIcon + "&nbsp;" + 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>&nbsp;(#{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 += "&nbsp;&nbsp;&nbsp;";
                                }

                                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"] = "&nbsp;";
                }
                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"] = "&nbsp;";
                }

                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;
            }
        }
Exemplo n.º 7
0
        private void BindTable()
        {
            HtmlTableRow  tr  = new HtmlTableRow();
            HtmlTableCell tc1 = new HtmlTableCell();
            HtmlTableCell tc2 = new HtmlTableCell();

            #region Variables
            string title         = String.Empty;
            string description   = String.Empty;
            string code          = String.Empty;
            string issue_box     = String.Empty;
            string priority      = String.Empty;
            string state         = String.Empty;
            string responsible   = String.Empty;
            string manager       = String.Empty;
            string client        = String.Empty;
            string opendate      = String.Empty;
            string created       = String.Empty;
            string modified      = String.Empty;
            string expecteddate  = String.Empty;
            string resolvedate   = String.Empty;
            string categories    = String.Empty;
            string isscategories = String.Empty;
            #endregion

            #region BindValues
            using (IDataReader reader = Incident.GetIncident(int.Parse(Request["IncidentId"])))
            {
                if (reader.Read())
                {
                    title       = reader["Title"].ToString();
                    description = reader["Description"].ToString();

                    code = "#" + reader["IncidentId"].ToString() + "&nbsp;";
                    string sIdentifier = "";
                    if (reader["Identifier"] != DBNull.Value)
                    {
                        sIdentifier = reader["Identifier"].ToString();
                    }
                    int ManagerId = 0;
                    if (reader["IncidentBoxId"] != DBNull.Value)
                    {
                        IncidentBox box = IncidentBox.Load((int)reader["IncidentBoxId"]);
                        code     += ((sIdentifier == "") ? TicketUidUtil.Create(box.IdentifierMask, (int)reader["IncidentId"]) : sIdentifier);
                        issue_box = box.Name;
                        ManagerId = box.Document.GeneralBlock.Manager;
                        manager   = Mediachase.UI.Web.Util.CommonHelper.GetUserStatusPureName(ManagerId);
                    }
                    priority = reader["PriorityName"].ToString();
                    state    = reader["StateName"].ToString();

                    #region Responsible
                    int StateId = (int)reader["StateId"];
                    if (StateId == (int)ObjectStates.Upcoming ||
                        StateId == (int)ObjectStates.Suspended ||
                        StateId == (int)ObjectStates.Completed)
                    {
                        if (ManagerId > 0)
                        {
                            responsible = Mediachase.UI.Web.Util.CommonHelper.GetUserStatusPureName(ManagerId);
                        }
                    }
                    if (StateId == (int)ObjectStates.OnCheck)
                    {
                        if (reader["ControllerId"] != DBNull.Value)
                        {
                            responsible = Mediachase.UI.Web.Util.CommonHelper.GetUserStatusPureName((int)reader["ControllerId"]);
                        }
                    }
                    if (reader["ResponsibleId"] != DBNull.Value && (int)reader["ResponsibleId"] > 0)
                    {
                        responsible = Mediachase.UI.Web.Util.CommonHelper.GetUserStatusPureName((int)reader["ResponsibleId"]);
                    }
                    else if (reader["IsResponsibleGroup"] != DBNull.Value && (bool)reader["IsResponsibleGroup"])
                    {
                        responsible = CHelper.GetResFileString("{IbnFramework.Incident:tRespGroup}");
                    }
                    else
                    {
                        responsible = CHelper.GetResFileString("{IbnFramework.Incident:tRespNotSet}");
                    }
                    #endregion

                    client = reader["ClientName"].ToString();
                    if (reader["ActualOpenDate"] != DBNull.Value)
                    {
                        opendate = ((DateTime)reader["ActualOpenDate"]).ToShortDateString() + " " + ((DateTime)reader["ActualOpenDate"]).ToShortTimeString();
                    }
                    created = string.Format("{0} {1} {2}",
                                            Mediachase.UI.Web.Util.CommonHelper.GetUserStatusPureName((int)reader["CreatorId"]),
                                            ((DateTime)reader["CreationDate"]).ToShortDateString(),
                                            ((DateTime)reader["CreationDate"]).ToShortTimeString());
                    modified = string.Format("{0} {1}",
                                             ((DateTime)reader["ModifiedDate"]).ToShortDateString(),
                                             ((DateTime)reader["ModifiedDate"]).ToShortTimeString());
                    if (reader["ExpectedResponseDate"] != DBNull.Value)
                    {
                        expecteddate = ((DateTime)reader["ExpectedResponseDate"]).ToShortDateString() + " " + ((DateTime)reader["ExpectedResponseDate"]).ToShortTimeString();
                    }
                    if (reader["ExpectedResolveDate"] != DBNull.Value)
                    {
                        resolvedate = ((DateTime)reader["ExpectedResolveDate"]).ToShortDateString() + " " + ((DateTime)reader["ExpectedResolveDate"]).ToShortTimeString();
                    }
                }
            }

            #region categories
            using (IDataReader reader = Incident.GetListCategories(int.Parse(Request["IncidentId"])))
            {
                while (reader.Read())
                {
                    if (categories.Length > 0)
                    {
                        categories += ", ";
                    }
                    categories += reader["CategoryName"].ToString();
                }
            }
            #endregion

            #region isscategories
            using (IDataReader reader = Incident.GetListIncidentCategoriesByIncident(int.Parse(Request["IncidentId"])))
            {
                while (reader.Read())
                {
                    if (isscategories.Length > 0)
                    {
                        isscategories += ", ";
                    }
                    isscategories += reader["CategoryName"].ToString();
                }
            }
            #endregion
            #endregion


            #region showTitle
            if (_pc[prefix + "showTitle"] == null || (_pc[prefix + "showTitle"] != null && bool.Parse(_pc[prefix + "showTitle"])))
            {
                tr            = new HtmlTableRow();
                tc1           = new HtmlTableCell();
                tc1.VAlign    = "top";
                tc1.InnerHtml = GetGlobalResourceObject("IbnFramework.Incident", "showTitle").ToString() + ":";
                tc2           = new HtmlTableCell();
                tc2.VAlign    = "top";
                tc2.ColSpan   = 3;
                tc2.InnerHtml = String.Format("<b>{0}</b>", title);
                tr.Cells.Add(tc1);
                tr.Cells.Add(tc2);
                mainTable.Rows.Add(tr);
            }
            #endregion
            #region showDescription
            if (_pc[prefix + "showDescription"] != null && bool.Parse(_pc[prefix + "showDescription"]))
            {
                tr            = new HtmlTableRow();
                tc1           = new HtmlTableCell();
                tc1.VAlign    = "top";
                tc1.InnerHtml = GetGlobalResourceObject("IbnFramework.Incident", "showDescription").ToString() + ":";
                tc2           = new HtmlTableCell();
                tc2.VAlign    = "top";
                tc2.ColSpan   = 3;
                tc2.InnerHtml = String.Format("<i>{0}</i>", description);
                tr.Cells.Add(tc1);
                tr.Cells.Add(tc2);
                mainTable.Rows.Add(tr);
            }
            #endregion

            int countFields = 0;
            #region showCode
            if (_pc[prefix + "showCode"] != null && bool.Parse(_pc[prefix + "showCode"]))
            {
                if (countFields == 0)
                {
                    tr = new HtmlTableRow();
                }
                tc1           = new HtmlTableCell();
                tc1.InnerHtml = GetGlobalResourceObject("IbnFramework.Incident", "showCode").ToString() + ":";
                tc2           = new HtmlTableCell();
                tc2.InnerHtml = code;
                tr.Cells.Add(tc1);
                tr.Cells.Add(tc2);
                countFields++;
                if (countFields == 2)
                {
                    mainTable.Rows.Add(tr);
                    countFields = 0;
                }
            }
            #endregion
            #region showIssBox
            if (_pc[prefix + "showIssBox"] != null && bool.Parse(_pc[prefix + "showIssBox"]))
            {
                if (countFields == 0)
                {
                    tr = new HtmlTableRow();
                }
                tc1           = new HtmlTableCell();
                tc1.InnerHtml = GetGlobalResourceObject("IbnFramework.Incident", "showIssBox").ToString() + ":";
                tc2           = new HtmlTableCell();
                tc2.InnerHtml = issue_box;
                tr.Cells.Add(tc1);
                tr.Cells.Add(tc2);
                countFields++;
                if (countFields == 2)
                {
                    mainTable.Rows.Add(tr);
                    countFields = 0;
                }
            }
            #endregion
            #region showPriority
            if (_pc[prefix + "showPriority"] == null || (_pc[prefix + "showPriority"] != null && bool.Parse(_pc[prefix + "showPriority"])))
            {
                if (countFields == 0)
                {
                    tr = new HtmlTableRow();
                }
                tc1           = new HtmlTableCell();
                tc1.InnerHtml = GetGlobalResourceObject("IbnFramework.Incident", "showPriority").ToString() + ":";
                tc2           = new HtmlTableCell();
                tc2.InnerHtml = priority;
                tr.Cells.Add(tc1);
                tr.Cells.Add(tc2);
                countFields++;
                if (countFields == 2)
                {
                    mainTable.Rows.Add(tr);
                    countFields = 0;
                }
            }
            #endregion
            #region showStatus
            if (_pc[prefix + "showStatus"] == null || (_pc[prefix + "showStatus"] != null && bool.Parse(_pc[prefix + "showStatus"])))
            {
                if (countFields == 0)
                {
                    tr = new HtmlTableRow();
                }
                tc1           = new HtmlTableCell();
                tc1.InnerHtml = GetGlobalResourceObject("IbnFramework.Incident", "showStatus").ToString() + ":";
                tc2           = new HtmlTableCell();
                tc2.InnerHtml = state;
                tr.Cells.Add(tc1);
                tr.Cells.Add(tc2);
                countFields++;
                if (countFields == 2)
                {
                    mainTable.Rows.Add(tr);
                    countFields = 0;
                }
            }
            #endregion
            #region showResponsible
            if (_pc[prefix + "showResponsible"] == null || (_pc[prefix + "showResponsible"] != null && bool.Parse(_pc[prefix + "showResponsible"])))
            {
                if (countFields == 0)
                {
                    tr = new HtmlTableRow();
                }
                tc1           = new HtmlTableCell();
                tc1.InnerHtml = GetGlobalResourceObject("IbnFramework.Incident", "showResponsible").ToString() + ":";
                tc2           = new HtmlTableCell();
                tc2.InnerHtml = responsible;
                tr.Cells.Add(tc1);
                tr.Cells.Add(tc2);
                countFields++;
                if (countFields == 2)
                {
                    mainTable.Rows.Add(tr);
                    countFields = 0;
                }
            }
            #endregion
            #region showManager
            if (_pc[prefix + "showManager"] != null && bool.Parse(_pc[prefix + "showManager"]))
            {
                if (countFields == 0)
                {
                    tr = new HtmlTableRow();
                }
                tc1           = new HtmlTableCell();
                tc1.InnerHtml = GetGlobalResourceObject("IbnFramework.Incident", "showManager").ToString() + ":";
                tc2           = new HtmlTableCell();
                tc2.InnerHtml = manager;
                tr.Cells.Add(tc1);
                tr.Cells.Add(tc2);
                countFields++;
                if (countFields == 2)
                {
                    mainTable.Rows.Add(tr);
                    countFields = 0;
                }
            }
            #endregion
            #region showGenCats
            if (_pc[prefix + "showGenCats"] != null && bool.Parse(_pc[prefix + "showGenCats"]))
            {
                if (countFields == 0)
                {
                    tr = new HtmlTableRow();
                }
                tc1           = new HtmlTableCell();
                tc1.VAlign    = "top";
                tc1.InnerHtml = GetGlobalResourceObject("IbnFramework.Incident", "showGenCats").ToString() + ":";
                tc2           = new HtmlTableCell();
                tc2.VAlign    = "top";
                tc2.InnerHtml = categories;
                tr.Cells.Add(tc1);
                tr.Cells.Add(tc2);
                countFields++;
                if (countFields == 2)
                {
                    mainTable.Rows.Add(tr);
                    countFields = 0;
                }
            }
            #endregion
            #region showIssCats
            if (_pc[prefix + "showIssCats"] != null && bool.Parse(_pc[prefix + "showIssCats"]))
            {
                if (countFields == 0)
                {
                    tr = new HtmlTableRow();
                }
                tc1           = new HtmlTableCell();
                tc1.VAlign    = "top";
                tc1.InnerHtml = GetGlobalResourceObject("IbnFramework.Incident", "showIssCats").ToString() + ":";
                tc2           = new HtmlTableCell();
                tc2.VAlign    = "top";
                tc2.InnerHtml = isscategories;
                tr.Cells.Add(tc1);
                tr.Cells.Add(tc2);
                countFields++;
                if (countFields == 2)
                {
                    mainTable.Rows.Add(tr);
                    countFields = 0;
                }
            }
            #endregion
            #region showClient
            if (_pc[prefix + "showClient"] == null || (_pc[prefix + "showClient"] != null && bool.Parse(_pc[prefix + "showClient"])))
            {
                if (countFields == 0)
                {
                    tr = new HtmlTableRow();
                }
                tc1           = new HtmlTableCell();
                tc1.InnerHtml = GetGlobalResourceObject("IbnFramework.Incident", "showClient").ToString() + ":";
                tc2           = new HtmlTableCell();
                tc2.InnerHtml = client;
                tr.Cells.Add(tc1);
                tr.Cells.Add(tc2);
                countFields++;
                if (countFields == 2)
                {
                    mainTable.Rows.Add(tr);
                    countFields = 0;
                }
            }
            #endregion
            #region showOpenDate
            if (_pc[prefix + "showOpenDate"] != null && bool.Parse(_pc[prefix + "showOpenDate"]))
            {
                if (countFields == 0)
                {
                    tr = new HtmlTableRow();
                }
                tc1           = new HtmlTableCell();
                tc1.InnerHtml = GetGlobalResourceObject("IbnFramework.Incident", "showOpenDate").ToString() + ":";
                tc2           = new HtmlTableCell();
                tc2.InnerHtml = opendate;
                tr.Cells.Add(tc1);
                tr.Cells.Add(tc2);
                countFields++;
                if (countFields == 2)
                {
                    mainTable.Rows.Add(tr);
                    countFields = 0;
                }
            }
            #endregion
            #region showCreationInfo
            if (_pc[prefix + "showCreationInfo"] != null && bool.Parse(_pc[prefix + "showCreationInfo"]))
            {
                if (countFields == 0)
                {
                    tr = new HtmlTableRow();
                }
                tc1           = new HtmlTableCell();
                tc1.InnerHtml = GetGlobalResourceObject("IbnFramework.Incident", "showCreationInfo").ToString() + ":";
                tc2           = new HtmlTableCell();
                tc2.InnerHtml = created;
                tr.Cells.Add(tc1);
                tr.Cells.Add(tc2);
                countFields++;
                if (countFields == 2)
                {
                    mainTable.Rows.Add(tr);
                    countFields = 0;
                }
            }
            #endregion
            #region showLastModifiedInfo
            if (_pc[prefix + "showLastModifiedInfo"] != null && bool.Parse(_pc[prefix + "showLastModifiedInfo"]))
            {
                if (countFields == 0)
                {
                    tr = new HtmlTableRow();
                }
                tc1           = new HtmlTableCell();
                tc1.InnerHtml = GetGlobalResourceObject("IbnFramework.Incident", "showLastModifiedInfo").ToString() + ":";
                tc2           = new HtmlTableCell();
                tc2.InnerHtml = modified;
                tr.Cells.Add(tc1);
                tr.Cells.Add(tc2);
                countFields++;
                if (countFields == 2)
                {
                    mainTable.Rows.Add(tr);
                    countFields = 0;
                }
            }
            #endregion
            #region showExpectedDate
            if (_pc[prefix + "showExpectedDate"] == null || (_pc[prefix + "showExpectedDate"] != null && bool.Parse(_pc[prefix + "showExpectedDate"])))
            {
                if (countFields == 0)
                {
                    tr = new HtmlTableRow();
                }
                tc1           = new HtmlTableCell();
                tc1.InnerHtml = GetGlobalResourceObject("IbnFramework.Incident", "showExpectedDate").ToString() + ":";
                tc2           = new HtmlTableCell();
                tc2.InnerHtml = expecteddate;
                tr.Cells.Add(tc1);
                tr.Cells.Add(tc2);
                countFields++;
                if (countFields == 2)
                {
                    mainTable.Rows.Add(tr);
                    countFields = 0;
                }
            }
            #endregion
            #region showResolveDate
            if (_pc[prefix + "showResolveDate"] == null || (_pc[prefix + "showResolveDate"] != null && bool.Parse(_pc[prefix + "showResolveDate"])))
            {
                if (countFields == 0)
                {
                    tr = new HtmlTableRow();
                }
                tc1           = new HtmlTableCell();
                tc1.InnerHtml = GetGlobalResourceObject("IbnFramework.Incident", "showResolveDate").ToString() + ":";
                tc2           = new HtmlTableCell();
                tc2.InnerHtml = resolvedate;
                tr.Cells.Add(tc1);
                tr.Cells.Add(tc2);
                countFields++;
                if (countFields == 2)
                {
                    mainTable.Rows.Add(tr);
                    countFields = 0;
                }
            }
            #endregion

            #region showForum
            if (_pc[prefix + "showForum"] == null || (_pc[prefix + "showForum"] != null && _pc[prefix + "showForum"] != "-1"))
            {
                DataTable dt = new DataTable();
                DataRow   dr;
                dt.Columns.Add(new DataColumn("Index", typeof(string)));
                dt.Columns.Add(new DataColumn("Sender", typeof(string)));
                dt.Columns.Add(new DataColumn("Message", typeof(string)));
                dt.Columns.Add(new DataColumn("Created", typeof(string)));
                dt.Columns.Add(new DataColumn("CreationDate", typeof(DateTime)));
                int index_mess = 0;
                #region DataTable
                foreach (ForumThreadNodeInfo node in Incident.GetForumThreadNodes(int.Parse(Request["IncidentId"])))
                {
                    dr                 = dt.NewRow();
                    dr["Created"]      = node.Created.ToShortDateString() + " " + node.Created.ToShortTimeString();
                    dr["CreationDate"] = node.Created;

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

                            if (iUserId > 0)
                            {
                                dr["Sender"] = Mediachase.UI.Web.Util.CommonHelper.GetUserStatus(iUserId);
                            }
                            else
                            {
                                Client clientObj = Mediachase.IBN.Business.Common.GetClient(mi.SenderEmail);
                                if (clientObj != null)
                                {
                                    if (clientObj.IsContact)
                                    {
                                        dr["Sender"] = Mediachase.UI.Web.Util.CommonHelper.GetContactLink(this.Page, clientObj.Id, clientObj.Name);
                                    }
                                    else
                                    {
                                        dr["Sender"] = Mediachase.UI.Web.Util.CommonHelper.GetOrganizationLink(this.Page, clientObj.Id, clientObj.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 = "";
                            if (mi.HtmlBody != null)
                            {
                                sBody = mi.HtmlBody;
                            }

                            dr["Message"] = sBody;
                        }
                        catch
                        {
                            dr["Sender"]  = Mediachase.UI.Web.Util.CommonHelper.GetUserStatus(-1);
                            dr["Message"] = String.Format("<font color='red'><b>{0}</b>&nbsp;(#{1})</font>", "Not Found", node.EMailMessageId);
                        }
                    }
                    else
                    {
                        string sBody = Mediachase.UI.Web.Util.CommonHelper.parsetext_br(node.Text, false);
                        dr["Message"] = sBody;
                        dr["Sender"]  = Mediachase.UI.Web.Util.CommonHelper.GetUserStatusPureName(node.CreatorId);
                    }

                    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(" + ResolveClientUrl("~/layouts/images/atrisk1.gif") + "); BACKGROUND-REPEAT: no-repeat;padding:4px;'><b>" + (++index_mess).ToString() + "</b></td></tr></table>";

                    if (!String.IsNullOrEmpty(dr["Message"].ToString().Trim()))
                    {
                        dt.Rows.Add(dr);
                    }
                }
                #endregion
                int showForum = 1;
                if (_pc[prefix + "showForum"] != null)
                {
                    showForum = int.Parse(_pc[prefix + "showForum"]);
                }

                DataView  dv      = dt.DefaultView;
                DataTable dtClone = dt.Clone();
                if (showForum > 0)
                {
                    dv.Sort = "CreationDate DESC";
                }
                else
                {
                    dv.Sort = "CreationDate";
                }

                int index = 0;
                foreach (DataRowView drv in dv)
                {
                    dr           = dtClone.NewRow();
                    dr.ItemArray = drv.Row.ItemArray;
                    dtClone.Rows.Add(dr);
                    index++;
                    if (showForum > 0 && index >= showForum)
                    {
                        break;
                    }
                }
                dgForum.DataSource = dtClone.DefaultView;
                dgForum.DataBind();
            }
            #endregion
        }
Exemplo n.º 8
0
        private void BindDefaultValues()
        {
            string fromEmail = Security.CurrentUser.Email;

            if (IncidentId > 0)
            {
                fromEmail = EMailRouterOutputMessage.FindEMailRouterPublicEmail(IncidentId);
            }
            txtFrom.Text = String.Format(CultureInfo.InvariantCulture,
                                         "{1}&nbsp;&lt;{0}&gt;", fromEmail, Security.CurrentUser.DisplayName);
            lblCCTitle.Text = "";
            lblToTitle.Text = LocRM.GetString("tTo") + ":";
            if (IncidentId > 0)
            {
                NameValueCollection _params = new NameValueCollection();
                _params["IssueId"] = IncidentId.ToString();
                string[] erList = EMailClient.GetDefaultRecipientList(EMailClient.IssueMode, _params);
                for (int i = 0; i < erList.Length; i++)
                {
                    string sName = GetNameByEMail(erList[i]);
                    if (sName != "")
                    {
                        lblCC.Text += String.Format(CultureInfo.InvariantCulture, "{0} &lt;{1}&gt;; ", sName, erList[i]);
                    }
                    else
                    {
                        lblCC.Text += erList[i] + "; ";
                    }
                }

                string sValue = EMailMessage.GetOutgoingEmailFormatBodyPreview(IncidentId).Replace("[=Text=]", "");
                if (NodeId > 0)
                {
                    EMailMessageInfo mi = EMailMessageInfo.Load(NodeId);
                    sValue += "<br/>" + "<blockquote style='border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;' dir='ltr'>" + mi.HtmlBody + "</blockquote>";
                }
                fckEditor.Text = sValue;

                using (IDataReader reader = Incident.GetIncident(IncidentId))
                {
                    if (reader.Read())
                    {
                        txtSubject.Text = string.Format(CultureInfo.InvariantCulture
                                                        , "RE: [{0}] {1}"
                                                        , (reader["Identifier"] != DBNull.Value) ?
                                                        reader["Identifier"].ToString()
                                                                : TicketUidUtil.Create(IncidentBox.Load((int)reader["IncidentBoxId"]).IdentifierMask, IncidentId)
                                                        , HttpUtility.HtmlDecode(reader["Title"].ToString())
                                                        );
                    }
                }
            }
            if (FileIds != "")
            {
                string sFiles = FileIds.Trim();
                if (sFiles.EndsWith(","))
                {
                    sFiles = sFiles.Substring(0, sFiles.Length - 1);
                }
                string[] masFiles = sFiles.Split(',');
                if (masFiles.Length > 0)
                {
                    string _containerName   = "FileLibrary";
                    string _containerKey    = "EMailAttach";
                    CS.BaseIbnContainer bic = CS.BaseIbnContainer.Create(_containerName, _containerKey);
                    CS.FileStorage      fs  = (CS.FileStorage)bic.LoadControl("FileStorage");

                    CS.BaseIbnContainer bic2 = CS.BaseIbnContainer.Create(FilesContainerName, FilesContainerKey);
                    CS.FileStorage      fs2  = (CS.FileStorage)bic.LoadControl("FileStorage");

                    CS.DirectoryInfo di = fs.GetDirectory(fs.Root.Id, _guid, true);
                    for (int i = 0; i < masFiles.Length; i++)
                    {
                        fs2.CopyFile(int.Parse(masFiles[i]), di.Id);
                    }
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "_getFiles",
                                                            "window.setTimeout('updateAttachments()', 500);", true);
                }
            }
            if (ErrorId != "")
            {
                string support_email = GlobalResourceManager.Strings["SupportEmail"];
                //if (Security.CurrentUser != null && Security.CurrentUser.Culture.ToLower().IndexOf("ru") >= 0)
                //    support_email = "*****@*****.**";
                txtTo.Text = support_email + "; ";

                txtSubject.Text = String.Format("{0} {1} {2} Error Report", IbnConst.CompanyName, IbnConst.ProductFamilyShort, IbnConst.VersionMajorDotMinor);

                string prefix   = Request.Url.Host.Replace(".", "_");
                string FilePath = Server.MapPath("../Admin/Log/Error/" + prefix + "_" + ErrorId + ".html");
                string sTemp    = String.Empty;
                using (StreamReader sr = File.OpenText(FilePath))
                {
                    sTemp += sr.ReadToEnd();
                }

                Match match = Regex.Match(sTemp, @"<body[^>]*>(?<HtmlBody>[\s\S]*?)</body>", RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.Multiline);
                if (match.Success)
                {
                    string body       = match.Groups["HtmlBody"].Value;
                    Match  matchStyle = Regex.Match(sTemp, @"<style[^>]*>(?<HtmlStyle>[\s\S]*?)</style>", RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.Multiline);
                    if (matchStyle.Success)
                    {
                        body += matchStyle.Value;
                    }
                    sTemp = body;
                }
                fckEditor.Text = sTemp;
            }
            if (lblCC.Text != "")
            {
                lblCCTitle.Text = LocRM.GetString("tTo") + ":";
                lblToTitle.Text = LocRM.GetString("tCc") + ":";
            }
        }
Exemplo n.º 9
0
        private void BindEmailValues()
        {
            EMailMessageInfo mi = EMailMessageInfo.Load(EMailMessageId);

            IncidentInfo incidentInfo = EMailIncidentMappingHandler.CreateMapping(EMailMessageId);

            // Eval IncidentBox
            ddlFolder.SelectedValue = IncidentBoxRule.Evaluate(incidentInfo).IncidentBoxId.ToString();

            txtTitle.Text       = incidentInfo.Title;
            ftbDescription.Text = incidentInfo.Description;
            CommonHelper.SafeSelect(ddlPriority, incidentInfo.PriorityId.ToString());
            CommonHelper.SafeSelect(ddlSeverity, incidentInfo.SeverityId.ToString());
            CommonHelper.SafeSelect(ddlType, incidentInfo.TypeId.ToString());
            ddProject.ObjectTypeId = (int)ObjectTypes.Project;
            ddProject.ObjectId     = incidentInfo.ProjectId;

            if (incidentInfo.GeneralCategories != null)
            {
                foreach (int CatId in incidentInfo.GeneralCategories)
                {
                    CommonHelper.SafeMultipleSelect(lbCategory, CatId.ToString());
                }
            }
            if (incidentInfo.IncidentCategories != null)
            {
                foreach (int CatId in incidentInfo.IncidentCategories)
                {
                    CommonHelper.SafeMultipleSelect(lbIncidentCategory, CatId.ToString());
                }
            }

            //try from MailSenderEmail
            PrimaryKeyId contactUid = PrimaryKeyId.Empty;
            PrimaryKeyId orgUid     = PrimaryKeyId.Empty;
            Client       client     = Common.GetClient(incidentInfo.MailSenderEmail);

            if (client != null)
            {
                if (client.IsContact)
                {
                    contactUid = client.Id;

                    ClientControl.ObjectType = ContactEntity.GetAssignedMetaClassName();
                    ClientControl.ObjectId   = contactUid;
                }
                else
                {
                    orgUid = client.Id;

                    ClientControl.ObjectType = OrganizationEntity.GetAssignedMetaClassName();
                    ClientControl.ObjectId   = orgUid;
                }
            }


            //from incidentinfo

            if (orgUid == PrimaryKeyId.Empty && contactUid == PrimaryKeyId.Empty)
            {
                if (incidentInfo.OrgUid != PrimaryKeyId.Empty)
                {
                    ClientControl.ObjectType = OrganizationEntity.GetAssignedMetaClassName();
                    ClientControl.ObjectId   = incidentInfo.OrgUid;
                }
                else if (incidentInfo.ContactUid != PrimaryKeyId.Empty)
                {
                    ClientControl.ObjectType = ContactEntity.GetAssignedMetaClassName();
                    ClientControl.ObjectId   = incidentInfo.ContactUid;
                }
            }

            trHtmlAttach.Visible = false;
            trEmail.Visible      = true;

            string sBody = "";

            if (mi.HtmlBody != null)
            {
                sBody = EMailMessageInfo.CutHtmlBody(mi.HtmlBody, 256, "...");
            }

            if (sBody.Trim() != "")
            {
                lblEmail.Text = String.Format("{0}<p align=right class='text'><a href=\"javascript:OpenSizableWindow('EMailView.aspx?EMailId={2}', 750, 550)\"><b>{1}</b></a>", sBody, LocRM4.GetString("More"), EMailMessageId);
            }
            else
            {
                lblEmail.Text = sBody;
            }
        }