示例#1
0
        private void BindValues()
        {
            if (IncidentId != 0)
            {
                int    FolderId                = -1;
                string sIdentifier             = "";
                bool   canViewFinances         = Incident.CanViewFinances(IncidentId);
                bool   canViewTimeTrackingInfo = Incident.CanViewTimeTrackingInfo(IncidentId);

                using (IDataReader reader = Incident.GetIncident(IncidentId))
                {
                    if (reader.Read())
                    {
                        ///  IncidentId, ProjectId, ProjectTitle, CreatorId,
                        ///  Title, Description, Resolution, Workaround, CreationDate,
                        ///  TypeId, TypeName, PriorityId, PriorityName,
                        ///  SeverityId, SeverityName, IsEmail, MailSenderEmail, StateId, TaskTime,
                        ///  IncidentBoxId, OrgUid, ContactUid, ClientName, ControllerId,
                        ///  ResponsibleGroupState, TotalMinutes, TotalApproved

                        lblCreator.Text      = CommonHelper.GetUserStatus((int)reader["CreatorId"]);
                        lblCreationDate.Text = ((DateTime)reader["CreationDate"]).ToShortDateString() + " " + ((DateTime)reader["CreationDate"]).ToShortTimeString();

                        if (reader["Identifier"] != DBNull.Value)
                        {
                            sIdentifier = reader["Identifier"].ToString();
                        }
                        if (reader["IncidentBoxId"] != DBNull.Value)
                        {
                            FolderId = (int)reader["IncidentBoxId"];
                        }
                        lblClient.Text   = Util.CommonHelper.GetClientLink(this.Page, reader["OrgUid"], reader["ContactUid"], reader["ClientName"]);
                        lblTaskTime.Text = Util.CommonHelper.GetHours((int)reader["TaskTime"]);

                        if (canViewTimeTrackingInfo)
                        {
                            SpentTimeLabel.Text = String.Format(CultureInfo.InvariantCulture,
                                                                "{0} / {1}:",
                                                                LocRM3.GetString("spentTime"),
                                                                LocRM3.GetString("approvedTime"));

                            lblSpentTime.Text = String.Format(CultureInfo.InvariantCulture,
                                                              "{0} / {1}",
                                                              Util.CommonHelper.GetHours((int)reader["TotalMinutes"]),
                                                              Util.CommonHelper.GetHours((int)reader["TotalApproved"]));
                        }
                    }
                }

                List <string> sCategories = new List <string>();
                using (IDataReader reader = Incident.GetListCategories(IncidentId))
                {
                    while (reader.Read())
                    {
                        sCategories.Add(reader["CategoryName"].ToString());
                    }
                }
                string[] mas = sCategories.ToArray();
                if (mas.Length > 0)
                {
                    lblGenCats.Text   = String.Join(", ", mas);
                    trGenCats.Visible = true;
                }
                else
                {
                    trGenCats.Visible = false;
                }

                List <string> sIssCategories = new List <string>();
                using (IDataReader reader = Incident.GetListIncidentCategoriesByIncident(IncidentId))
                {
                    while (reader.Read())
                    {
                        sIssCategories.Add(reader["CategoryName"].ToString());
                    }
                }
                string[] mas1 = sIssCategories.ToArray();
                if (mas1.Length > 0)
                {
                    lblIssCats.Text   = String.Join(", ", mas1);
                    trIssCats.Visible = true;
                }
                else
                {
                    trIssCats.Visible = false;
                }

                if (FolderId > 0)
                {
                    IncidentBox         box      = IncidentBox.Load(FolderId);
                    IncidentBoxDocument settings = IncidentBoxDocument.Load(FolderId);
                    if (Security.CurrentUser.IsExternal)
                    {
                        lblFolder.Text = String.Format("{0}", box.Name);
                    }
                    else if (Security.IsUserInGroup(InternalSecureGroups.Administrator))
                    {
                        lblFolder.Text = String.Format("<a href='../Admin/EMailIssueBoxView.aspx?IssBoxId={1}'>{0}</a>", box.Name, box.IncidentBoxId);
                    }
                    else
                    {
                        lblFolder.Text = String.Format("<a href=\"javascript:OpenPopUpWindow(&quot;../Incidents/IncidentBoxView.aspx?IssBoxId={1}&IncidentId={2}&quot;,500,375)\">{0}</a>",
                                                       box.Name, box.IncidentBoxId, IncidentId.ToString());
                    }
                    lblManager.Text = CommonHelper.GetUserStatus(settings.GeneralBlock.Manager);
                    if (sIdentifier == "")
                    {
                        lblTicket.Text = TicketUidUtil.Create(box.IdentifierMask, IncidentId);
                    }
                    else
                    {
                        lblTicket.Text = sIdentifier;
                    }
                }

                trClient.Visible   = PortalConfig.CommonIncidentAllowViewClientField;
                trGenCats.Visible  = PortalConfig.CommonIncidentAllowViewGeneralCategoriesField;
                trIssCats.Visible  = PortalConfig.IncidentAllowViewIncidentCategoriesField;
                trTaskTime.Visible = PortalConfig.CommonIncidentAllowViewTaskTimeField;
            }
        }
示例#2
0
        public static void SendMessage(string[] To, string Subject, string Body, Mediachase.IBN.Business.ControlSystem.DirectoryInfo Attachments, string Mode, NameValueCollection Params)
        {
            // Cleanup Temporary files
            DbEMailTempFile.CleanUp();

            #region Validate Arguments
            if (To == null)
            {
                throw new ArgumentNullException("To");
            }

            if (Subject == null)
            {
                throw new ArgumentNullException("Subject");
            }

            if (Body == null)
            {
                throw new ArgumentNullException("Body");
            }

            //if (To.Length == 0)
            //    throw new ArgumentOutOfRangeException("To", "Email recipient list is empty.");

            if (Mode == null)
            {
                Mode = string.Empty;
            }

            if (Params == null)
            {
                Params = new NameValueCollection();
            }
            #endregion

            string FromEmail = string.Empty;

            switch (Mode)
            {
            case EMailClient.IssueMode:
            case EMailClient.SmtpTestMode:
                FromEmail = Alerts2.AlertSenderEmail;
                break;

            default:
                FromEmail = Security.CurrentUser.Email;
                break;
            }

            string FullFromEmail = string.Format("\"{0} {1}\" <{2}>",
                                                 Security.CurrentUser.LastName,
                                                 Security.CurrentUser.FirstName,
                                                 FromEmail);

            using (DbTransaction tran = DbTransaction.Begin())
            {
                EMailMessageLogSetting EmailLogSettings = EMailMessageLogSetting.Current;
                if (EmailLogSettings.IsActive)
                {
                    EMailMessageLog.CleanUp(EmailLogSettings.Period);
                }
                else
                {
                    EmailLogSettings = null;
                }

                Mode = Mode.ToLower();

                #region Pre-format incoming arguments
                switch (Mode)
                {
                case EMailClient.IssueMode:
                    if (Params["IssueId"] == null)
                    {
                        throw new ArgumentNullException("Params[\"IssueId\"]");
                    }

                    int IssueId = int.Parse(Params["IssueId"]);

                    // TODO: Validate Subject & Ticket
                    if (TicketUidUtil.LoadFromString(Subject) == string.Empty)
                    {
                        IncidentBox incidentBox = IncidentBox.Load(Incident.GetIncidentBox(IssueId));

                        string IncidentTicket = Incident.GetIdentifier(IssueId);

                        if (incidentBox.Document.GeneralBlock.AllowOutgoingEmailFormat)
                        {
                            StringBuilder sb = new StringBuilder(incidentBox.Document.GeneralBlock.OutgoingEmailFormatSubject, 4096);

                            sb.Replace("[=Title=]", Subject);
                            sb.Replace("[=Ticket=]", IncidentTicket);
                            //sb.Replace("[=Text=]", Body);
                            sb.Replace("[=FirstName=]", Security.CurrentUser.FirstName);
                            sb.Replace("[=LastName=]", Security.CurrentUser.LastName);

                            Subject = sb.ToString();
                        }
                        else
                        {
                            Subject = string.Format("RE: [{0}] {1}",
                                                    IncidentTicket,
                                                    Subject);
                        }
                    }
                    break;

                default:
                    break;
                }

                #endregion

                Pop3Message msg = Create(FullFromEmail, To, Subject, Body, Attachments);

                switch (Mode)
                {
                case EMailClient.IssueMode:
                    #region Issue
                    int IssueId = int.Parse(Params["IssueId"]);

                    IncidentBox incidentBox = IncidentBox.Load(Incident.GetIncidentBox(IssueId));

                    bool AllowEMailRouting = true;

                    EMailRouterIncidentBoxBlock settings = IncidentBoxDocument.Load(incidentBox.IncidentBoxId).EMailRouterBlock;
                    if (!settings.AllowEMailRouting)
                    {
                        AllowEMailRouting = false;
                    }

                    EMailRouterPop3Box internalPop3Box = EMailRouterPop3Box.ListInternal();
                    if (internalPop3Box == null)
                    {
                        AllowEMailRouting = false;
                    }

                    // Register Email Message
                    // OZ: [2007--05-25] Fix Problem Object reference not set to an instance of an object If (internalPop3Box == NULL)
                    int EMailMessageId = EMailMessage.Create(internalPop3Box != null?
                                                             internalPop3Box.EMailRouterPop3BoxId : EMailRouterOutputMessage.FindEMailRouterPublicId(IssueId),
                                                             msg);

                    // Register Forume Node
                    int ThreadNodeId = EMailMessage.AddToIncidentMessage(true, IssueId, EMailMessageId, msg);

                    // Send Message

                    if (AllowEMailRouting)
                    {
                        ArrayList excludedUsers = EMailRouterOutputMessage.Send(IssueId, internalPop3Box, msg, To);
                        SystemEvents.AddSystemEvents(SystemEventTypes.Issue_Updated_Forum_MessageAdded, IssueId, -1, excludedUsers);
                    }
                    else
                    {
                        FromEmail     = EMailRouterOutputMessage.FindEMailRouterPublicEmail(IssueId);
                        FullFromEmail = string.Format("\"{0} {1}\" <{2}>",
                                                      Security.CurrentUser.LastName,
                                                      Security.CurrentUser.FirstName,
                                                      FromEmail);

                        // Create OutputMessageCreator
                        OutputMessageCreator issueOutput = new OutputMessageCreator(msg,
                                                                                    -1,
                                                                                    FromEmail,
                                                                                    FullFromEmail);

                        // Fill Recipent
                        foreach (string ToItem in To)
                        {
                            issueOutput.AddRecipient(ToItem);
                        }

                        foreach (EMailIssueExternalRecipient exRecipient in EMailIssueExternalRecipient.List(IssueId))
                        {
                            issueOutput.AddRecipient(exRecipient.EMail);
                        }

                        int emailBoxId = EMail.EMailRouterOutputMessage.FindEMailRouterPublicId(IssueId);

                        //Send Smtp Message
                        foreach (OutputMessage outputMsg in issueOutput.Create())
                        {
                            SmtpClientUtility.SendMessage(OutgoingEmailServiceType.HelpDeskEmailBox, emailBoxId, outputMsg.MailFrom, outputMsg.RcptTo, outputMsg.Subject, outputMsg.Data);
                        }

                        ArrayList excludedUsers = new ArrayList();

                        foreach (string ToItem in To)
                        {
                            int emailUserId = DBUser.GetUserByEmail(ToItem, false);
                            if (emailUserId > 0)
                            {
                                excludedUsers.Add(emailUserId);
                            }
                        }

                        SystemEvents.AddSystemEvents(SystemEventTypes.Issue_Updated_Forum_MessageAdded, IssueId, -1, excludedUsers);
                    }
                    #endregion
                    break;

                case EMailClient.SmtpTestMode:
                    throw new NotImplementedException();
                //OutputMessageCreator smtpTestOutput = new OutputMessageCreator(msg,
                //    -1,
                //    FromEmail,
                //    FullFromEmail);

                //// Fill Recipent
                //foreach (string ToItem in To)
                //{
                //    smtpTestOutput.AddRecipient(ToItem);
                //}

                ////Send Smtp Message
                //foreach (OutputMessage outputMsg in smtpTestOutput.Create())
                //{
                //    //SmtpClientUtility.DirectSendMessage(outputMsg.MailFrom, outputMsg.RcptTo, outputMsg.Subject, outputMsg.Data);
                //    //SmtpBox.SendTestEmail(
                //}
                //break;
                default:
                    #region Default
                    // Create OutputMessageCreator
                    OutputMessageCreator defaultOutput = new OutputMessageCreator(msg,
                                                                                  -1,
                                                                                  FromEmail,
                                                                                  FullFromEmail);

                    // Fill Recipent
                    foreach (string ToItem in To)
                    {
                        defaultOutput.AddRecipient(ToItem);
                    }

                    //Send Smtp Message
                    foreach (OutputMessage outputMsg in defaultOutput.Create())
                    {
                        SmtpClientUtility.SendMessage(OutgoingEmailServiceType.SendFile, null, outputMsg.MailFrom, outputMsg.RcptTo, outputMsg.Subject, outputMsg.Data);
                    }

                    #endregion
                    break;
                }

                if (Attachments != null)
                {
                    FileStorage.InnerDeleteFolder(Attachments.Id);
                }

                tran.Commit();
            }
        }
示例#3
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
        }
示例#4
0
        private void BindValues()
        {
            if (IncidentId != 0)
            {
                try
                {
                    using (IDataReader reader = Incident.GetIncident(IncidentId))
                    {
                        if (reader.Read())
                        {
                            string sTitle = "";
                            if (Configuration.ProjectManagementEnabled && reader["ProjectId"] != DBNull.Value)
                            {
                                string projectPostfix = CHelper.GetProjectNumPostfix((int)reader["ProjectId"], (string)reader["ProjectCode"]);
                                if (Project.CanRead((int)reader["ProjectId"]))
                                {
                                    sTitle += String.Format(CultureInfo.InvariantCulture,
                                                            "<a href='../Projects/ProjectView.aspx?ProjectId={0}' title='{1}'>{2}{3}</a> \\ ",
                                                            reader["ProjectId"].ToString(),
                                                            LocRM.GetString("Project"),
                                                            reader["ProjectTitle"].ToString(),
                                                            projectPostfix
                                                            );
                                }
                                else
                                {
                                    sTitle += String.Format(CultureInfo.InvariantCulture,
                                                            "<span title='{0}'>{1}{2}</span> \\ ",
                                                            LocRM.GetString("Project"),
                                                            reader["ProjectTitle"].ToString(),
                                                            LocRM.GetString("Project"));
                                }
                            }
                            sTitle += reader["Title"].ToString() + "&nbsp;(#" + reader["IncidentId"].ToString() + ")&nbsp;";
                            string sIdentifier = "";
                            if (reader["Identifier"] != DBNull.Value)
                            {
                                sIdentifier = reader["Identifier"].ToString();
                            }
                            if (reader["IncidentBoxId"] != DBNull.Value)
                            {
                                IncidentBox box = IncidentBox.Load((int)reader["IncidentBoxId"]);
                                sTitle += "(" + ((sIdentifier == "") ? TicketUidUtil.Create(box.IdentifierMask, IncidentId) : sIdentifier) + ")";
                            }
                            lblTitle.Text    = sTitle;
                            lblType.Text     = reader["TypeName"].ToString();
                            lblSeverity.Text = reader["SeverityName"].ToString();

                            lblState.ForeColor = Util.CommonHelper.GetStateColor((int)reader["StateId"]);
                            lblState.Text      = reader["StateName"].ToString();
                            if ((bool)reader["IsOverdue"])
                            {
                                lblState.ForeColor = Util.CommonHelper.GetStateColor((int)ObjectStates.Overdue);
                                lblState.Text      = String.Format(CultureInfo.InvariantCulture,
                                                                   "{0}, {1}",
                                                                   reader["StateName"].ToString(),
                                                                   GetGlobalResourceObject("IbnFramework.Incident", "Overdue"));
                            }

                            lblPriority.Text      = reader["PriorityName"].ToString() + " " + LocRM.GetString("Priority").ToLower();
                            lblPriority.ForeColor = Util.CommonHelper.GetPriorityColor((int)reader["PriorityId"]);

                            if (reader["Description"] != DBNull.Value)
                            {
                                string txt = CommonHelper.parsetext(reader["Description"].ToString(), false);
                                if (PortalConfig.ShortInfoDescriptionLength > 0 && txt.Length > PortalConfig.ShortInfoDescriptionLength)
                                {
                                    txt = txt.Substring(0, PortalConfig.ShortInfoDescriptionLength) + "...";
                                }

                                lblDescription.Text = txt;
                            }

                            //						lblExpRespDate.Text = ((DateTime)reader["ExpectedResponseDate"]).ToString("g");
                            //						lblExpResDur.Text = ((DateTime)reader["ExpectedResolveDate"]).ToString("g");
                        }
                        else
                        {
                            Response.Redirect("../Common/NotExistingID.aspx?IncidentID=1");
                        }
                    }
                }
                catch (AccessDeniedException)
                {
                    Response.Redirect("~/Common/NotExistingID.aspx?AD=1");
                }
                divType.Visible     = lblType.Visible = PortalConfig.IncidentAllowViewTypeField;
                divSeverity.Visible = lblSeverity.Visible = PortalConfig.IncidentAllowViewSeverityField;
                lblPriority.Visible = PortalConfig.CommonIncidentAllowViewPriorityField;
                trAdd.Visible       = divType.Visible || divSeverity.Visible || lblPriority.Visible;
            }
        }
示例#5
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") + ":";
            }
        }