예제 #1
0
 private void BindList()
 {
     ddIssBox.DataSource     = IncidentBox.List();
     ddIssBox.DataTextField  = "Name";
     ddIssBox.DataValueField = "IncidentBoxId";
     ddIssBox.DataBind();
 }
예제 #2
0
        private void BindValues()
        {
            IncidentBox issb = IncidentBox.Load(IssBoxId);

            Util.CommonHelper.SafeSelect(ddIssBox, issb.IncidentBoxId.ToString());

            IncidentBoxRule[] ibList = IncidentBoxRule.List(IssBoxId);

            dgRules.Columns[2].HeaderText = LocRM.GetString("tIssRuleInfo");

            dgRules.DataSource = ibList;
            dgRules.DataBind();

            foreach (DataGridItem dgi in dgRules.Items)
            {
                ImageButton ib = (ImageButton)dgi.FindControl("ibDelete");
                if (ib != null)
                {
                    ib.Attributes.Add("onclick", "return confirm('" + LocRM.GetString("tWarning3") + "')");
                    ib.Attributes.Add("title", LocRM.GetString("tDelete"));
                }

                ImageButton ib1 = (ImageButton)dgi.FindControl("ibNew");
                if (ib1 != null)
                {
                    ib1.Attributes.Add("onclick", "javascript:{OpenWindow(\"EMailIssueRuleEdit.aspx?New=1&IssRuleId=" + ib1.CommandArgument + "&IssBoxId=" + IssBoxId + "\", 400, 300, false);return false;}");
                    ib1.Attributes.Add("title", LocRM.GetString("tAddRule"));
                }
            }
        }
예제 #3
0
        private void BindValues()
        {
            string strSubject;
            string strBody;

            AlertTemplate.GetTemplate(AlertTemplateTypes.Special, Language,
                                      Template,
                                      bCustom,
                                      out strSubject,
                                      out strBody);

            IncidentBoxDocument ibd = IncidentBoxDocument.Load(IncidentBoxId);

            if (ibd != null)
            {
                tbSubject.Text = ibd.GeneralBlock.OutgoingEmailFormatSubject;
                tbBody.Text    = ibd.GeneralBlock.OutgoingEmailFormatBody;
            }
            IncidentBox ib     = IncidentBox.Load(IncidentBoxId);
            string      ibName = "";

            if (ib != null)
            {
                ibName = ib.Name;
            }
            title = LocRM.GetString("TemplateEdit") + " " + ibName;


            DataTable dt = AlertTemplate.GetVariablesForTemplateEditor(AlertTemplateTypes.Special, Template);
            DataView  dv = dt.DefaultView;

            dv.Sort             = "Name";
            dlSysVar.DataSource = dv;
            dlSysVar.DataBind();
        }
예제 #4
0
 private void dg_Edit(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
 {
     dgRules.EditItemIndex = e.Item.ItemIndex;
     dgRules.DataKeyField  = "IncidentBoxId";
     BindDG();
     foreach (DataGridItem dgi in dgRules.Items)
     {
         if (dgi.ItemType == ListItemType.EditItem)
         {
             DropDownList ddl;
             ddl = (DropDownList)dgi.FindControl("ddl");
             ddl.ClearSelection();
             IncidentBox[] ibList = IncidentBox.ListWithRules();
             for (int i = 0; i < ibList.Length; i++)
             {
                 ddl.Items.Add(new ListItem(i.ToString(), i.ToString()));
             }
             try
             {
                 ddl.SelectedValue = e.Item.Cells[1].Text;
             }
             catch { }
         }
     }
 }
예제 #5
0
		private void BindValues()
		{
			IncidentBox ib = IncidentBox.Load(IssBoxId);
			lblIssBoxName.Text = ib.Name;

			IncidentBoxDocument ibd = IncidentBoxDocument.Load(IssBoxId);
//
//			//EMailRouterBlock
//			EMailRouterIncidentBoxBlock eribb = ibd.EMailRouterBlock;
//
//			cbAllowEMail.Checked = eribb.AllowEMailRouting;
//
//			Util.CommonHelper.SafeSelect(ddExtActionType, ((int)eribb.IncomingEMailAction).ToString());
//			Util.CommonHelper.SafeSelect(ddIntActionType, ((int)eribb.OutgoingEMailAction).ToString());
//			
//			BindReipients(eribb);
//
			//GeneralBlock
			GeneralIncidentBoxBlock gibb = ibd.GeneralBlock;
						
			lblManager.Text = Util.CommonHelper.GetUserStatusUL((int)gibb.Manager);

			trControl.Visible = gibb.AllowControl;
			if(gibb.AllowControl)
			{
				if(gibb.ControllerAssignType == ControllerAssignType.CustomUser)
					lblController.Text = Util.CommonHelper.GetUserStatusUL((int)gibb.Controller);
				else
				{
					if(gibb.ControllerAssignType == ControllerAssignType.Manager)
						lblController.Text = Util.CommonHelper.GetUserStatusUL((int)gibb.Manager);
					else if(gibb.ControllerAssignType == ControllerAssignType.Creator)
						using(IDataReader reader = Incident.GetIncident(IncidentId))
						{
							if(reader.Read())
								lblController.Text = Util.CommonHelper.GetUserStatusUL((int)reader["CreatorId"]);
						}
				}
			}

			lblExpDuration.Text = Util.CommonHelper.GetHours(gibb.ExpectedDuration);
			lblExpRespTime.Text = Util.CommonHelper.GetHours(gibb.ExpectedResponseTime);
			
			if(gibb.ResponsibleAssignType == ResponsibleAssignType.CustomUser)
				lblResponsible.Text = Util.CommonHelper.GetUserStatusUL((int)gibb.Responsible);
			else
			{
				trResponsible.Visible = false;
				using(IDataReader reader = Incident.GetIncidentTrackingState(IncidentId))
				{
					if(reader.Read() && reader["ResponsibleId"]!=DBNull.Value && (int)reader["ResponsibleId"]>0)
					{
						trResponsible.Visible = true;
						lblResponsible.Text = Util.CommonHelper.GetUserStatusUL((int)reader["ResponsibleId"]);
					}
				}
			}
		}
예제 #6
0
 private void BindData()
 {
     if (IssBoxId > 0)
     {
         IncidentBox ib = IncidentBox.Load(IssBoxId);
         if (ib != null)
         {
             cbIsDefault.Checked = ib.IsDefault;
             tbName.Text         = ib.Name;
             tbMask.Text         = ib.IdentifierMask;
         }
     }
 }
예제 #7
0
        private void BindIssBoxes()
        {
            IncidentBox[] ibList = IncidentBox.List();
            DataTable     dt     = new DataTable();

            dt.Columns.Add(new DataColumn("IncidentBoxId", typeof(int)));
            dt.Columns.Add(new DataColumn("IsDefault", typeof(bool)));
            dt.Columns.Add(new DataColumn("Name", typeof(string)));
            dt.Columns.Add(new DataColumn("IdentifierMask", typeof(string)));
            dt.Columns.Add(new DataColumn("Routing", typeof(string)));
            dt.Columns.Add(new DataColumn("Rules", typeof(string)));
            DataRow dr;

            foreach (IncidentBox ib in ibList)
            {
                dr = dt.NewRow();
                dr["IncidentBoxId"]  = ib.IncidentBoxId;
                dr["Name"]           = ib.Name;
                dr["IsDefault"]      = ib.IsDefault;
                dr["IdentifierMask"] = ib.IdentifierMask;
                dr["Routing"]        = "&nbsp;";
                dr["Rules"]          = "&nbsp;";
                IncidentBoxDocument ibd = IncidentBoxDocument.Load(ib.IncidentBoxId);
                if (ibd != null)
                {
                    if (ibd.EMailRouterBlock.AllowEMailRouting)
                    {
                        dr["Routing"] = "<img border='0' align='top' src='" + ResolveUrl("~/layouts/images/incidentbox_routing.gif") + "' title='" + LocRM.GetString("tEmailRoutingEnabled") + "'/>";
                    }
                }
                IncidentBoxRule[] ibr = IncidentBoxRule.List(ib.IncidentBoxId);
                if (ibr != null && ibr.Length > 0)
                {
                    dr["Rules"] = "<img border='0' align='top' src='" + ResolveUrl("~/layouts/images/incidentbox_rules.gif") + "' title='" + LocRM.GetString("tRulesExist") + "'/>";
                }
                dt.Rows.Add(dr);
            }

            rpIssBoxes.DataSource = dt;
            rpIssBoxes.DataBind();
            foreach (RepeaterItem ri in rpIssBoxes.Items)
            {
                LinkButton lb = (LinkButton)ri.FindControl("ibDelete");
                if (lb != null)
                {
                    lb.Attributes.Add("onclick", "javascript:return confirm('" + LocRM.GetString("tDelete") + "'+'?')");
                }
            }
        }
예제 #8
0
        private void dg_Update(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
        {
            DropDownList ddl      = (DropDownList)e.Item.FindControl("ddl");
            int          issId    = int.Parse(dgRules.DataKeys[e.Item.ItemIndex].ToString());
            int          newIndex = int.Parse(ddl.SelectedItem.Value);

            //			IncidentBox ib = IncidentBox.Load(issId);
            //			ib.Index = newIndex;
            //			IncidentBox.Update(ib);
            IncidentBox.ChangeAutodetectionIndex(issId, newIndex);

            //			dgRules.EditItemIndex = -1;
            //			BindDG();
            Response.Redirect("~/Admin/EMailRules.aspx");
        }
예제 #9
0
        private void dgBoxes_DeleteCommand(object source, DataGridCommandEventArgs e)
        {
            int sid = int.Parse(e.Item.Cells[0].Text);

            try
            {
                IncidentBox.Delete(sid);
                Response.Redirect(this.Page.ResolveUrl("~/Admin/EMailIssueBoxes.aspx"));
            }
            catch
            {
                lblCantDelete.Text = LocRM.GetString("tIssboxCantDeleted");
                divMessage.Visible = true;
            }
        }
예제 #10
0
        private void BindLists()
        {
            ddTitle.Items.Clear();
            ddTitle.Items.Add(new ListItem(LocRM.GetString("tSubject"), "Subject"));

            ddCreator.Items.Clear();
            ddCreator.DataSource     = User.GetListActive();
            ddCreator.DataValueField = "PrincipalId";
            ddCreator.DataTextField  = "DisplayName";
            ddCreator.DataBind();

            ddType.DataSource     = Incident.GetListIncidentTypes();
            ddType.DataTextField  = "TypeName";
            ddType.DataValueField = "TypeId";
            ddType.DataBind();

            ddPriority.DataSource     = Incident.GetListPriorities();
            ddPriority.DataTextField  = "PriorityName";
            ddPriority.DataValueField = "PriorityId";
            ddPriority.DataBind();
            ddPriority.Items.Insert(0, new ListItem(LocRM.GetString("tFromEMail"), "-1"));

            ddSeverity.DataSource     = Incident.GetListIncidentSeverity();
            ddSeverity.DataTextField  = "SeverityName";
            ddSeverity.DataValueField = "SeverityId";
            ddSeverity.DataBind();

            lbGenCats.DataSource     = Incident.GetListCategoriesAll();
            lbGenCats.DataTextField  = "CategoryName";
            lbGenCats.DataValueField = "CategoryId";
            lbGenCats.DataBind();

            lbIssCats.DataSource     = Incident.GetListIncidentCategories();
            lbIssCats.DataTextField  = "CategoryName";
            lbIssCats.DataValueField = "CategoryId";
            lbIssCats.DataBind();

            ddIssBox.Items.Clear();
            ddIssBox.Items.Add(new ListItem(LocRM.GetString("tIssBoxAutoSelect"), "-1"));
            foreach (IncidentBox folder in IncidentBox.List())
            {
                ddIssBox.Items.Add(new ListItem(folder.Name, folder.IncidentBoxId.ToString()));
            }

            ddDescription.Items.Clear();
            ddDescription.Items.Add(new ListItem(LocRM.GetString("tNothing"), "-1"));
            ddDescription.Items.Add(new ListItem(LocRM.GetString("tDescriptionAsBody"), "0"));
        }
예제 #11
0
        void rpIssBoxes_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            int bid = -1;

            bid = int.Parse(e.CommandArgument.ToString());
            if (e.CommandName == "Delete")
            {
                try
                {
                    IncidentBox.Delete(bid);
                }
                catch
                { }
                Response.Redirect("~/Admin/HDMSettings.aspx");
            }
        }
예제 #12
0
        private void imbSave_ServerClick(object sender, EventArgs e)
        {
            int iIssBoxId = -1;

            try
            {
                if (IssBoxId > 0)
                {
                    IncidentBox ib = IncidentBox.Load(IssBoxId);
                    if (ib != null)
                    {
                        ib.IsDefault      = cbIsDefault.Checked;
                        ib.Name           = tbName.Text.Trim();
                        ib.IdentifierMask = tbMask.Text.Trim();
                        IncidentBox.Update(ib);
                    }
                }
                else
                {
                    iIssBoxId = IncidentBox.Create(tbName.Text.Trim(), tbMask.Text.Trim(), cbIsDefault.Checked);
                }
                if (iIssBoxId > 0)
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(),
                                                            "try {window.opener.location.href='" + ResolveUrl("~/Admin/EMailIssueBoxView.aspx") + "?IssBoxId=" + iIssBoxId + "';}" +
                                                            "catch (e){} window.close();", true);
                }
                else
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(),
                                                            "try {window.opener.location.href=window.opener.location.href;}" +
                                                            "catch (e){} window.close();", true);
                }
            }
            catch (IncidentBoxDuplicateNameException)
            {
                lblDuplicate.Text    = LocRM.GetString("tDuplicateName");
                lblDuplicate.Visible = true;
            }
            catch (IncidentBoxDuplicateIdentifierMaskException)
            {
                lblDuplicate.Text    = LocRM.GetString("tDuplicateMask");
                lblDuplicate.Visible = true;
            }
        }
예제 #13
0
 protected string GetIssBoxDeleteButton(int Id)
 {
     if (Id > 0)
     {
         if (IncidentBox.CanDelete(Id))
         {
             return(String.Format("<img border='0' align='absmiddle' src='{0}' />&nbsp;{1}", ResolveUrl("~/layouts/images/delete.gif"), LocRM.GetString("tDelete")));
         }
         else
         {
             return(string.Empty);
         }
     }
     else
     {
         return(string.Empty);
     }
 }
예제 #14
0
        private void BindDG()
        {
            IncidentBox[] ibList = IncidentBox.List();
            DataTable     dt     = new DataTable();

            dt.Columns.Add(new DataColumn("IncidentBoxId", typeof(int)));
            dt.Columns.Add(new DataColumn("IsDefault", typeof(bool)));
            dt.Columns.Add(new DataColumn("Name", typeof(string)));
            dt.Columns.Add(new DataColumn("IdentifierMask", typeof(string)));
            DataRow dr;

            foreach (IncidentBox ib in ibList)
            {
                dr = dt.NewRow();
                dr["IncidentBoxId"]  = ib.IncidentBoxId;
                dr["Name"]           = ib.Name;
                dr["IsDefault"]      = ib.IsDefault;
                dr["IdentifierMask"] = ib.IdentifierMask;
                dt.Rows.Add(dr);
            }
            DataView dv = dt.DefaultView;

            dv.Sort = "Name";

            int i = 1;

            dgBoxes.Columns[i++].HeaderText = LocRM.GetString("tDefaultBox");
            dgBoxes.Columns[i++].HeaderText = LocRM.GetString("tName");
            dgBoxes.Columns[i++].HeaderText = LocRM.GetString("tIdentMask");

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

            foreach (DataGridItem dgi in dgBoxes.Items)
            {
                ImageButton ib = (ImageButton)dgi.FindControl("ibDelete");
                if (ib != null)
                {
                    ib.Attributes.Add("onclick", "return confirm('" + LocRM.GetString("tWarningIncBox") + "')");
                    ib.Attributes.Add("title", LocRM.GetString("tDelete"));
                }
            }
        }
예제 #15
0
        private void BindDG()
        {
            IncidentBox[] ibList = IncidentBox.ListWithRules();

            DataTable dt = new DataTable();

            dt.Columns.Add(new DataColumn("IncidentBoxId", typeof(int)));
            dt.Columns.Add(new DataColumn("Index", typeof(int)));
            dt.Columns.Add(new DataColumn("Name", typeof(string)));
            dt.Columns.Add(new DataColumn("Rules", typeof(string)));
            DataRow dr;
            int     i = 0;

            foreach (IncidentBox ib in ibList)
            {
                dr = dt.NewRow();
                dr["IncidentBoxId"] = ib.IncidentBoxId;
                dr["Index"]         = i++;
                dr["Name"]          = ib.Name;
                dr["Rules"]         = GetRules(ib.IncidentBoxId);
                dt.Rows.Add(dr);
            }
            DataView dv = dt.DefaultView;

            dv.Sort = "Index";

            dgRules.Columns[1].HeaderText = "#";
            dgRules.Columns[2].HeaderText = LocRM.GetString("tIssBoxRules");
            dgRules.Columns[3].HeaderText = LocRM.GetString("tIssBox");

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

            foreach (DataGridItem dgi in dgRules.Items)
            {
                ImageButton ib = (ImageButton)dgi.FindControl("ibDelete");
                if (ib != null)
                {
                    ib.Attributes.Add("onclick", "return confirm('" + LocRM.GetString("tWarning3") + "')");
                }
            }
        }
예제 #16
0
 private void BindToolBar()
 {
     secHeader.Title = LocRM.GetString("tIssRules");
     IncidentBox[] ibList = IncidentBox.ListWithoutRules();
     if (ibList.Length > 0)
     {
         int iId = ibList[0].IncidentBoxId;
         secHeader.AddLink("<img alt='' src='" + this.Page.ResolveUrl("~/Layouts/Images/rulesnew.gif") + "'/> " + LocRM.GetString("tAddRules"), this.Page.ResolveUrl("~/Admin/EMailIssueBoxRules.aspx") + "?IssBoxId=" + iId);
     }
     else
     {
         ibList = IncidentBox.List();
         if (ibList.Length > 0)
         {
             int iId = ibList[0].IncidentBoxId;
             secHeader.AddLink("<img alt='' src='" + this.Page.ResolveUrl("~/Layouts/Images/rulesnew.gif") + "'/> " + LocRM.GetString("tAddRules"), this.Page.ResolveUrl("~/Admin/EMailIssueBoxRules.aspx") + "?IssBoxId=" + iId);
         }
     }
     secHeader.AddLink("<img alt='' src='" + this.Page.ResolveUrl("~/Layouts/Images/cancel.gif") + "'/> " + LocRM.GetString("tHDM"), ResolveUrl("~/Apps/Administration/Pages/default.aspx?NodeId=MAdmin5"));
 }
        private void BindValues()
        {
            IncidentBoxDocument ibd = IncidentBoxDocument.Load(IncidentBoxId);

            if (ibd != null)
            {
                if (Template.IndexOf("Issue_Created") >= 0)
                {
                    tbSubject.Text = ibd.GeneralBlock.AutoReplyEMailSubjectTemplate;
                    tbBody.Text    = ibd.GeneralBlock.AutoReplyEMailBodyTemplate;
                }
                else if (Template.IndexOf("Issue_Closed") >= 0)
                {
                    tbSubject.Text = ibd.GeneralBlock.OnCloseAutoReplyEMailSubjectTemplate;
                    tbBody.Text    = ibd.GeneralBlock.OnCloseAutoReplyEMailBodyTemplate;
                }
            }
            IncidentBox ib     = IncidentBox.Load(IncidentBoxId);
            string      ibName = "";

            if (ib != null)
            {
                ibName = ib.Name;
            }
            if (Template.IndexOf("Issue_Created") >= 0)
            {
                title = LocRM.GetString("NewIssueMessage") + "&nbsp;" + ibName;
            }
            else if (Template.IndexOf("Issue_Closed") >= 0)
            {
                title = LocRM.GetString("CloseIssueMessage") + "&nbsp;" + ibName;
            }

            DataTable dt = AlertTemplate.GetVariablesForTemplateEditor(AlertTemplateTypes.Notification, Template);
            DataView  dv = dt.DefaultView;

            dv.Sort             = "Name";
            dlSysVar.DataSource = dv;
            dlSysVar.DataBind();
        }
예제 #18
0
        private void BindValues()
        {
            lblRules.Text = "&nbsp;";
            IncidentBox issb = IncidentBox.Load(IssBoxId);

            lblIssBoxName.Text = issb.Name;
            IncidentBoxRule[] ibList = IncidentBoxRule.List(IssBoxId);
            string            retVal = "";

            for (int i = 0; i < ibList.Length; i++)
            {
                retVal += "<tr><td width='30px'>";

                IncidentBoxRule ibr = ibList[i];

                if (ibr.RuleType == IncidentBoxRuleType.OrBlock || ibr.RuleType == IncidentBoxRuleType.AndBlock)
                {
                    string thisLevel = ibr.OutlineLevel + ibr.IncidentBoxRuleId + ".";
                    retVal += GetLabel(ibr, true) + "</td><td><b>(</b>";
                    string ss = "";
                    i       = Reccurence(ibList, out ss, thisLevel, i);
                    retVal += ss + "<b>)</b>";
                }
                else
                {
                    retVal += GetLabel(ibr, true);
                    retVal += "</td><td><b>(</b>&nbsp;" + GetInnerText(ibr) + "<b>)</b>";
                }

                retVal += "</td></tr>";
            }
            if (retVal != "")
            {
                lblRules.Text = String.Format("<table cellspacing='0' cellpadding='5' border='0' class='text'>{0}</table>", retVal);
            }
            else
            {
                lblRules.Text = "<font color='red' class='text'>" + LocRM.GetString("tIssueBoxRules") + "</font>";
            }
        }
예제 #19
0
        protected void ddlFolder_SelectedIndexChanged(object sender, EventArgs e)
        {
            int incidentBoxId = int.Parse(ddlFolder.SelectedValue, CultureInfo.InvariantCulture);

            if (incidentBoxId > 0)
            {
                IncidentBox box = IncidentBox.Load(incidentBoxId);
                if (box != null)
                {
                    ucExpectedResponseTime.Value = DateTime.MinValue.AddMinutes(box.Document.GeneralBlock.ExpectedResponseTime);
                    ucExpectedDuration.Value     = DateTime.MinValue.AddMinutes(box.Document.GeneralBlock.ExpectedDuration);
                    ucExpectedAssignTime.Value   = DateTime.MinValue.AddMinutes(box.Document.GeneralBlock.ExpectedAssignTime);
                    ucTaskTime.Value             = DateTime.MinValue.AddMinutes(box.Document.GeneralBlock.TaskTime);
                }
            }
            else
            {
                ucExpectedDuration.Value     = DateTime.MinValue.AddDays(7);
                ucExpectedResponseTime.Value = DateTime.MinValue.AddDays(1);
                ucExpectedAssignTime.Value   = DateTime.MinValue.AddHours(8);
                ucTaskTime.Value             = DateTime.MinValue.AddHours(3);
            }
        }
예제 #20
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);
                    }
                }
            }
        }
예제 #21
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;
            }
        }
예제 #22
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;
            }
        }
예제 #23
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
        }
예제 #24
0
        /// <summary>
        /// Default data bind.
        /// </summary>
        private void DefaultDataBind()
        {
            //FieldSet
            ddFieldSets.Items.Clear();
            ddFieldSets.Items.Add(new ListItem(GetGlobalResourceObject("IbnFramework.Incident", "StandardFieldSet").ToString(), Incident.IssueFieldSet.IncidentsDefault.ToString()));
            ddFieldSets.Items.Add(new ListItem(GetGlobalResourceObject("IbnFramework.Incident", "TimelineFieldSet").ToString(), Incident.IssueFieldSet.IncidentsLight.ToString()));
            ddFieldSets.Items.Add(new ListItem(GetGlobalResourceObject("IbnFramework.Incident", "TrackingFieldSet").ToString(), Incident.IssueFieldSet.IncidentsTracking.ToString()));

            //Grouping
            ddGroupField.Items.Clear();
            ddGroupField.Items.Add(new ListItem(GetGlobalResourceObject("IbnFramework.Incident", "NoGroupBy").ToString(), Incident.AvailableGroupField.NotSet.ToString()));
            ddGroupField.Items.Add(new ListItem(GetGlobalResourceObject("IbnFramework.Incident", "GroupByPrj").ToString(), Incident.AvailableGroupField.Project.ToString()));
            if (PortalConfig.GeneralAllowClientField)
            {
                ddGroupField.Items.Add(new ListItem(GetGlobalResourceObject("IbnFramework.Incident", "GroupByContacts").ToString(), Incident.AvailableGroupField.Client.ToString()));
            }
            ddGroupField.Items.Add(new ListItem(GetGlobalResourceObject("IbnFramework.Incident", "GroupByIssBoxes").ToString(), Incident.AvailableGroupField.IssueBox.ToString()));
            ddGroupField.Items.Add(new ListItem(GetGlobalResourceObject("IbnFramework.Incident", "GroupByResp").ToString(), Incident.AvailableGroupField.Responsible.ToString()));

            //Filters
            //Managers
            ddManager.DataSource     = Incident.GetListIncidentManagers();
            ddManager.DataValueField = "UserId";
            ddManager.DataTextField  = "UserName";
            ddManager.DataBind();

            ListItem lItem = new ListItem(LocRM.GetString("All"), "0");

            ddManager.Items.Insert(0, lItem);

            lItem = new ListItem(GetGlobalResourceObject("IbnFramework.Incident", "CurrentUser").ToString(), "-5");
            ddManager.Items.Insert(1, lItem);

            //Priorities
            ddPriority.DataSource     = Incident.GetListPriorities();
            ddPriority.DataTextField  = "PriorityName";
            ddPriority.DataValueField = "PriorityId";
            ddPriority.DataBind();
            lItem = new ListItem(LocRM.GetString("All"), "-1");
            ddPriority.Items.Insert(0, lItem);

            //IssueBox
            ddIssBox.DataSource     = IncidentBox.List();
            ddIssBox.DataTextField  = "Name";
            ddIssBox.DataValueField = "IncidentBoxId";
            ddIssBox.DataBind();
            lItem = new ListItem(LocRM.GetString("All"), "0");
            ddIssBox.Items.Insert(0, lItem);

            //Types
            ddType.DataSource     = Incident.GetListIncidentTypes();
            ddType.DataTextField  = "TypeName";
            ddType.DataValueField = "TypeId";
            ddType.DataBind();

            lItem = new ListItem(LocRM.GetString("All"), "0");
            ddType.Items.Insert(0, lItem);

            //Creators
            ddCreatedBy.DataSource     = Incident.GetListIncidentCreators();
            ddCreatedBy.DataTextField  = "UserName";
            ddCreatedBy.DataValueField = "UserId";
            ddCreatedBy.DataBind();

            lItem = new ListItem(LocRM.GetString("All"), "0");
            ddCreatedBy.Items.Insert(0, lItem);

            lItem = new ListItem(GetGlobalResourceObject("IbnFramework.Incident", "CurrentUser").ToString(), "-5");
            ddCreatedBy.Items.Insert(1, lItem);

            //Responsibles
            ddResponsible.DataSource     = Incident.GetListIncidentResponsibles();
            ddResponsible.DataValueField = "UserId";
            ddResponsible.DataTextField  = "UserName";
            ddResponsible.DataBind();

            lItem = new ListItem(LocRM.GetString("All"), "0");
            ddResponsible.Items.Insert(0, lItem);

            lItem = new ListItem(GetGlobalResourceObject("IbnFramework.Incident", "OutOfPersonalResponsibilityFilter").ToString(), "-1");
            ddResponsible.Items.Insert(1, lItem);

            lItem = new ListItem(GetGlobalResourceObject("IbnFramework.Incident", "ResponsibleNotAssigned").ToString(), "-2");
            ddResponsible.Items.Insert(2, lItem);

            lItem = new ListItem(GetGlobalResourceObject("IbnFramework.Incident", "GroupResp").ToString(), "-3");
            ddResponsible.Items.Insert(3, lItem);

            lItem = new ListItem(GetGlobalResourceObject("IbnFramework.Incident", "AllDenied").ToString(), "-4");
            ddResponsible.Items.Insert(4, lItem);

            lItem = new ListItem(GetGlobalResourceObject("IbnFramework.Incident", "CurrentUser").ToString(), "-5");
            ddResponsible.Items.Insert(5, lItem);

            //Client
            ClientControl.ObjectType = String.Empty;
            ClientControl.ObjectId   = PrimaryKeyId.Empty;

            //States
            ddState.Items.Clear();
            using (IDataReader reader = Incident.GetListIncidentStates())
            {
                while (reader.Read())
                {
                    if ((int)reader["StateId"] != (int)ObjectStates.Overdue)
                    {
                        ddState.Items.Add(new ListItem(reader["StateName"].ToString(), reader["StateId"].ToString()));
                    }
                }
            }

            lItem = new ListItem(LocRM.GetString("Inactive"), "-2");
            ddState.Items.Insert(0, lItem);
            lItem = new ListItem(LocRM.GetString("Active"), "-1");
            ddState.Items.Insert(0, lItem);
            lItem = new ListItem(LocRM.GetString("All"), "0");
            ddState.Items.Insert(0, lItem);

            //Severities
            ddSeverity.DataSource     = Incident.GetListIncidentSeverity();
            ddSeverity.DataTextField  = "SeverityName";
            ddSeverity.DataValueField = "SeverityId";
            ddSeverity.DataBind();
            lItem = new ListItem(LocRM.GetString("All"), "0");
            ddSeverity.Items.Insert(0, lItem);

            //Projects
            if (!Mediachase.IBN.Business.Configuration.ProjectManagementEnabled)
            {
                tdProject.Visible = false;
                _pc[Incident.ProjectFilterKey] = "0";
            }
            else
            {
                ddlProject.DataSource     = Project.GetListProjects();
                ddlProject.DataTextField  = "Title";
                ddlProject.DataValueField = "ProjectId";
                ddlProject.DataBind();
            }
            lItem = new ListItem(LocRM.GetString("All"), "0");
            ddlProject.Items.Insert(0, lItem);
            lItem = new ListItem(LocRM.GetString("NoneProject"), "-1");
            ddlProject.Items.Insert(1, lItem);
            ddlProject.DataSource = null;
            ddlProject.DataBind();

            //General Categories
            ddGenCatType.Items.Clear();
            ddGenCatType.Items.Add(new ListItem(LocRM.GetString("Any2"), "0"));
            ddGenCatType.Items.Add(new ListItem(LocRM.GetString("SelectedOnly"), "1"));
            ddGenCatType.Items.Add(new ListItem(LocRM.GetString("ExcludeSelected"), "2"));

            lbGenCats.Items.Clear();
            lbGenCats.DataSource     = Project.GetListCategoriesAll();
            lbGenCats.DataTextField  = "CategoryName";
            lbGenCats.DataValueField = "CategoryId";
            lbGenCats.DataBind();

            //Issue Categories
            ddIssCatType.Items.Clear();
            ddIssCatType.Items.Add(new ListItem(LocRM.GetString("Any2"), "0"));
            ddIssCatType.Items.Add(new ListItem(LocRM.GetString("SelectedOnly"), "1"));
            ddIssCatType.Items.Add(new ListItem(LocRM.GetString("ExcludeSelected"), "2"));

            lbIssCats.Items.Clear();
            lbIssCats.DataSource     = Incident.GetListIncidentCategories();
            lbIssCats.DataTextField  = "CategoryName";
            lbIssCats.DataValueField = "CategoryId";
            lbIssCats.DataBind();

            cbOnlyNewMess.Checked = false;

            cbIsPublic.Visible = Mediachase.IBN.Business.Security.IsUserInGroup(InternalSecureGroups.Administrator);

            trClient.Visible     = PortalConfig.GeneralAllowClientField;
            trCategories.Visible = PortalConfig.GeneralAllowGeneralCategoriesField;
            tblPriority.Visible  = PortalConfig.GeneralAllowPriorityField;
        }
예제 #25
0
        public string GetIncidentInfo(string UID)
        {
            XmlDocument xmlIncident = new XmlDocument();

            try
            {
                IncidentUserTicket ticket = IncidentUserTicket.Load(new Guid(UID));
                if (ticket == null)
                {
                    System.Xml.XmlDocument doc      = new System.Xml.XmlDocument();
                    System.Xml.XmlNode     node     = doc.CreateNode(XmlNodeType.Element, SoapException.DetailElementName.Name, SoapException.DetailElementName.Namespace);
                    System.Xml.XmlNode     resource = doc.CreateNode(XmlNodeType.Element, "resource", string.Empty);
                    resource.InnerText = "strNotfound";
                    node.AppendChild(resource);
                    throw new SoapException(String.Format("The ticket '{0}' not found", UID), new XmlQualifiedName(typeof(ArgumentException).FullName), System.Web.HttpContext.Current.Request.Url.AbsoluteUri, node);
                }

                Security.UserLoginByTicket(ticket);

                xmlIncident.LoadXml("<Incident></Incident>");

                XmlNode xmlRootNode = xmlIncident.SelectSingleNode("Incident");

                XmlElement NameNode        = xmlIncident.CreateElement("Name");
                XmlElement TypeNode        = xmlIncident.CreateElement("Type");
                XmlElement DescriptionNode = xmlIncident.CreateElement("Description");
                //XmlElement ManagerNode = xmlIncident.CreateElement("Manager");
                XmlElement ClientNode  = xmlIncident.CreateElement("Client");
                XmlElement CreatedNode = xmlIncident.CreateElement("Created");
                XmlElement StateNode   = xmlIncident.CreateElement("State");
                XmlElement StateIdNode = xmlIncident.CreateElement("StateId");
                XmlElement ColorNode   = xmlIncident.CreateElement("StateColor");

                int controllerId = -1;
                int IssBoxId     = -1;

                using (IDataReader reader = Incident.GetIncident(ticket.IncidentId))
                {
                    if (reader.Read())
                    {
                        if (reader["ControllerId"] != DBNull.Value)
                        {
                            controllerId = (int)reader["ControllerId"];
                        }
                        IssBoxId = (int)reader["IncidentBoxId"];

                        NameNode.InnerText        = (string)reader["Title"];
                        TypeNode.InnerText        = (string)reader["TypeName"];
                        DescriptionNode.InnerText = (string)reader["Description"];
                        //ManagerNode.InnerText = reader["Title"];
                        ClientNode.InnerText  = (string)reader["ClientName"];
                        CreatedNode.InnerText = ((DateTime)reader["CreationDate"]).ToString("s");
                        StateNode.InnerText   = (string)reader["StateName"];
                        StateIdNode.InnerText = reader["StateId"].ToString();
                        ColorNode.InnerText   = (Util.CommonHelper.GetStateColor((int)reader["StateId"])).ToArgb().ToString();

                        xmlRootNode.AppendChild(NameNode);
                        xmlRootNode.AppendChild(TypeNode);
                        xmlRootNode.AppendChild(DescriptionNode);
                        xmlRootNode.AppendChild(ClientNode);
                        xmlRootNode.AppendChild(CreatedNode);
                        xmlRootNode.AppendChild(StateNode);
                        xmlRootNode.AppendChild(StateIdNode);
                        xmlRootNode.AppendChild(ColorNode);
                    }
                }

                int  stateId = 0;
                int  userId  = -1;
                bool isGroup = false;

                using (IDataReader reader = Incident.GetIncidentTrackingState(ticket.IncidentId))
                {
                    if (reader.Read())
                    {
                        stateId = (int)reader["StateId"];
                        userId  = (int)reader["ResponsibleId"];
                        if (reader["IsResponsibleGroup"] != DBNull.Value && (bool)reader["IsResponsibleGroup"])
                        {
                            isGroup = true;
                        }
                    }
                }


                if (stateId == 7)
                {
                    isGroup = false;
                    userId  = controllerId;
                }

                if (isGroup)
                {
                    XmlElement responsibleNode   = xmlIncident.CreateElement("GroupResponsible");
                    XmlElement responsibleIdNode = xmlIncident.CreateElement("ResponsibleId");

                    responsibleNode.InnerText   = "1";
                    responsibleIdNode.InnerText = IncidentInfo.GroupResponsibleId.ToString();

                    xmlRootNode.AppendChild(responsibleNode);
                    xmlRootNode.AppendChild(responsibleIdNode);
                }
                else if (userId != -1)
                {
                    XmlElement responsibleNode   = xmlIncident.CreateElement("Responsible");
                    XmlElement responsibleIdNode = xmlIncident.CreateElement("ResponsibleId");

                    string UserName = Mediachase.IBN.Business.User.GetUserName(userId);

                    responsibleNode.InnerText   = UserName;
                    responsibleIdNode.InnerText = userId.ToString();

                    xmlRootNode.AppendChild(responsibleNode);
                    xmlRootNode.AppendChild(responsibleIdNode);
                }
                else if (stateId != 1 && stateId != 4 && stateId != 5)
                {
                    XmlElement responsibleNode   = xmlIncident.CreateElement("Responsible");
                    XmlElement responsibleIdNode = xmlIncident.CreateElement("ResponsibleId");

                    responsibleNode.InnerText   = NotSetResponsibleName;
                    responsibleIdNode.InnerText = IncidentInfo.NotSetResponsibleId.ToString();

                    xmlRootNode.AppendChild(responsibleNode);
                    xmlRootNode.AppendChild(responsibleIdNode);
                }

                if (IssBoxId != -1)
                {
                    IncidentBox ib = IncidentBox.Load(IssBoxId);

                    XmlElement BoxNode = xmlIncident.CreateElement("IncidentBox");
                    BoxNode.InnerText = ib.Name;

                    xmlRootNode.AppendChild(BoxNode);
                }

                DataTable tbl = Incident.GetListIncidentStates(ticket.IncidentId);
                foreach (DataRow row in tbl.Rows)
                {
                    if ((int)row["StateId"] != 1 && (int)row["StateId"] != 2)
                    {
                        XmlElement newStateNode = xmlIncident.CreateElement("NewState");

                        XmlElement idNode   = xmlIncident.CreateElement("Id");
                        XmlElement nameNode = xmlIncident.CreateElement("Name");

                        idNode.InnerText   = row["StateId"].ToString();
                        nameNode.InnerText = (string)row["StateName"];

                        newStateNode.AppendChild(idNode);
                        newStateNode.AppendChild(nameNode);

                        xmlRootNode.AppendChild(newStateNode);
                    }
                }

                // OZ: Add Available Responsible (...)
                Incident.Tracking trk = Incident.GetTrackingInfo(ticket.IncidentId);

                // Add No User Element (Custom ID)
                if (trk.CanSetNoUser)
                {
                    AppendNewResponsible(xmlRootNode, NotSetResponsibleName, NotSetResponsibleId);
                }

                // Add Group Element (Custom ID)
                if (trk.CanSetGroup)
                {
                    AppendNewResponsible(xmlRootNode, GroupResponsibleName, GroupResponsibleId);
                }

                // Add Users
                if (trk.CanSetUser)
                {
                    ArrayList alUsers = Incident.GetResponsibleList(ticket.IncidentId);
                    foreach (int iUserId in alUsers)
                    {
                        string userName = Mediachase.IBN.Business.User.GetUserName(iUserId);
                        AppendNewResponsible(xmlRootNode, userName, iUserId);
                    }
                }

                // Custom User  select ...
                // TODO:

                //
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);

                throw;
            }
            return(xmlIncident.InnerXml);
        }
예제 #26
0
        private void BindValues()
        {
            IncidentBox ib = IncidentBox.Load(IssBoxId);

            lblIssBoxName.Text  = ib.Name;
            tbMask.Text         = ib.IdentifierMask;
            cbIsDefault.Checked = ib.IsDefault;

            IncidentBoxDocument ibd = null;

            if (ViewState["IncidentBoxDocument"] != null)
            {
                ibd = IncidentBoxDocument.Load(IssBoxId, (string)ViewState["IncidentBoxDocument"]);
            }
            else
            {
                ibd = IncidentBoxDocument.Load(IssBoxId);
            }

            //EMailRouterBlock
            EMailRouterIncidentBoxBlock eribb = ibd.EMailRouterBlock;

            cbAllowEMail.Checked          = eribb.AllowEMailRouting;
            cbAllowAutoReply.Checked      = eribb.SendAutoReply;
            cbAllowAutoReplyClose.Checked = eribb.SendAutoIncidentClosed;

            if (ibd != null)
            {
                cbAllowAutoSigning.Checked = ibd.GeneralBlock.AllowOutgoingEmailFormat;
            }

            Util.CommonHelper.SafeSelect(ddExtActionType, ((int)eribb.IncomingEMailAction).ToString());
            Util.CommonHelper.SafeSelect(ddIntActionType, ((int)eribb.OutgoingEMailAction).ToString());

            BindReipients(eribb);

            //GeneralBlock
            GeneralIncidentBoxBlock gibb = ibd.GeneralBlock;

            //Util.CommonHelper.SafeSelect(ddCreator, gibb.DefaultCreator.ToString());
            Util.CommonHelper.SafeSelect(ddManager, gibb.Manager.ToString());
            Util.CommonHelper.SafeSelect(ddCalendar, gibb.CalendarId.ToString());

            Util.CommonHelper.SafeSelect(ddContType, ((int)gibb.ControllerAssignType).ToString());
            if (gibb.ControllerAssignType == ControllerAssignType.CustomUser)
            {
                trController.Visible = true;
                Util.CommonHelper.SafeSelect(ddController, gibb.Controller.ToString());
            }
            else
            {
                trController.Visible = false;
            }

            Util.CommonHelper.SafeSelect(ddRespType, ((int)gibb.ResponsibleAssignType).ToString());
            if (gibb.ResponsibleAssignType == ResponsibleAssignType.CustomUser)
            {
                //				lblForResp.Text = LocRM.GetString("tResponsible") + ":";
                //				ddResponsible.Visible = true;
                //				lblResponsible.Visible = false;
                //				lblChangeButton.Visible = false;
                trCustomUser.Visible = true;
                Util.CommonHelper.SafeSelect(ddResponsible, gibb.Responsible.ToString());

                // [2008-09-09] O.R.: Sometimes we can have inactive or deleted user
                if (ddResponsible.SelectedValue != gibb.Responsible.ToString())
                {
                    ddResponsible.Items.Insert(0, new ListItem("[ " + LocRM.GetString("tNotSet") + " ]", "-1"));
                    Util.CommonHelper.SafeSelect(ddResponsible, "-1");
                }
            }
            else
            {
                trCustomUser.Visible = false;
            }

            BindResponsible(gibb);

            cbAllowAddRes.Checked         = gibb.AllowAddResources;
            cbAllowAddToDo.Checked        = gibb.AllowAddToDo;
            cbAllowControl.Checked        = gibb.AllowControl;
            cbAllowToDeclineResp.Checked  = gibb.AllowToDeclineResponsibility;
            cbAllowToReassignResp.Checked = gibb.AllowToReassignResponsibility;
            cbAllowToComeResp.Checked     = gibb.AllowUserToComeResponsible;
            cbReassignResp.Checked        = gibb.ReassignResponsibileOnReOpen;

            ucDuration.Value     = DateTime.MinValue.AddMinutes(gibb.ExpectedDuration);
            ucResponseTime.Value = DateTime.MinValue.AddMinutes(gibb.ExpectedResponseTime);
            ucAssignTime.Value   = DateTime.MinValue.AddMinutes(gibb.ExpectedAssignTime);
            ucTaskTime.Value     = DateTime.MinValue.AddMinutes(gibb.TaskTime);
        }
예제 #27
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;
            }
        }
예제 #28
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();
            }
        }
예제 #29
0
        void NodeActions_Validate(object Sender, ValidateArgs e)
        {
            if (e.Node == null)
            {
                return;
            }

            UserLightPropertyCollection pc = Security.CurrentUser.Properties;

            int iObjTypeId = -1;
            int iObjId     = -1;

            if (HttpContext.Current.Items["ObjectTypeId"] != null)
            {
                iObjTypeId = (int)HttpContext.Current.Items["ObjectTypeId"];
            }
            if (HttpContext.Current.Items["ObjectId"] != null)
            {
                iObjId = (int)HttpContext.Current.Items["ObjectId"];
            }

            switch (e.CommandUid)
            {
                #region Reply
            case "Reply":
                if (e.Node.Type == "email" && e.Node.Attributes.ContainsKey("Incoming") && pc["IncForum_ReplyOutlook"] != "1" && pc["IncForum_ReplyEML"] != "1")
                {
                    e.IsEnabled = true;
                    e.IsVisible = true;
                }
                break;

                #endregion
                #region ReplyOutlook
            case "ReplyOutlook":
                if (e.Node.Type == "email" && e.Node.Attributes.ContainsKey("Incoming") && pc["IncForum_ReplyOutlook"] == "1")
                {
                    e.IsEnabled = true;
                    e.IsVisible = true;
                }
                break;

                #endregion
                #region ReplyEML
            case "ReplyEML":
                if (e.Node.Type == "email" && e.Node.Attributes.ContainsKey("Incoming") && pc["IncForum_ReplyEML"] != "1")
                {
                    e.IsEnabled = true;
                    e.IsVisible = true;
                }
                break;

                #endregion
                #region ReSend
            case "ReSend":
                if (iObjTypeId == (int)ObjectTypes.Issue)
                {
                    if (e.Node.Type == "email")
                    {
                        if (e.Node.Attributes.ContainsKey("Incoming"))
                        {
                            IncidentBox incidentBox = IncidentBox.Load(Incident.GetIncidentBox(iObjId));
                            EMailRouterIncidentBoxBlock settings = IncidentBoxDocument.Load(incidentBox.IncidentBoxId).EMailRouterBlock;
                            if (settings.AllowEMailRouting)
                            {
                                e.IsEnabled = true;
                                e.IsVisible = true;
                            }
                        }
                    }
                }
                break;

                #endregion
                #region ReSendOut
            case "ReSendOut":
                if (iObjTypeId == (int)ObjectTypes.Issue)
                {
                    if (e.Node.Type == "email")
                    {
                        if (e.Node.Attributes.ContainsKey("Outgoing"))
                        {
                            e.IsEnabled = true;
                            e.IsVisible = true;
                        }
                    }
                }
                break;

                #endregion
                #region Resolution
            case "Resolution":
                if (iObjTypeId == (int)ObjectTypes.Issue)
                {
                    if (!e.Node.Attributes.ContainsKey("Resolution") &&
                        !e.Node.Attributes.ContainsKey("Question"))
                    {
                        e.IsEnabled = true;
                        e.IsVisible = true;
                    }
                }
                break;

                #endregion
                #region UnResolution
            case "UnResolution":
                if (iObjTypeId == (int)ObjectTypes.Issue)
                {
                    if (e.Node.Attributes.ContainsKey("Resolution"))
                    {
                        e.IsEnabled = true;
                        e.IsVisible = true;
                    }
                }
                break;

                #endregion
                #region Workaround
            case "Workaround":
                if (iObjTypeId == (int)ObjectTypes.Issue)
                {
                    if (!e.Node.Attributes.ContainsKey("Workaround") &&
                        !e.Node.Attributes.ContainsKey("Question"))
                    {
                        e.IsEnabled = true;
                        e.IsVisible = true;
                    }
                }
                break;

                #endregion
                #region UnWorkaround
            case "UnWorkaround":
                if (iObjTypeId == (int)ObjectTypes.Issue)
                {
                    if (e.Node.Attributes.ContainsKey("Workaround"))
                    {
                        e.IsEnabled = true;
                        e.IsVisible = true;
                    }
                }
                break;

                #endregion
                #region OnTop
            case "OnTop":
                if (!e.Node.Attributes.ContainsKey(Node.ONTOP_ATTRIBUTE))
                {
                    e.IsEnabled = true;
                    e.IsVisible = true;
                }
                break;

                #endregion
                #region UnOnTop
            case "UnOnTop":
                if (e.Node.Attributes.ContainsKey(Node.ONTOP_ATTRIBUTE))
                {
                    e.IsEnabled = true;
                    e.IsVisible = true;
                }
                break;

                #endregion
                #region Delete
            case "Delete":
                if (iObjTypeId == (int)ObjectTypes.Issue)
                {
                    bool CanUpdate = Incident.CanUpdate(iObjId);
                    e.IsEnabled = CanUpdate;
                    e.IsVisible = CanUpdate;
                    e.IsBreak   = true;
                }
                break;

                #endregion
            default:
                break;
            }
        }
예제 #30
0
        private void imbSave_ServerClick(object sender, EventArgs e)
        {
            Page.Validate();
            if (!Page.IsValid)
            {
                return;
            }

            TimeSpan ts;

            if (ViewState["IncidentBoxDocument"] != null)
            {
                try
                {
                    IncidentBox ib = IncidentBox.Load(IssBoxId);
                    if (ib != null)
                    {
                        ib.Name           = lblIssBoxName.Text.Trim();
                        ib.IdentifierMask = tbMask.Text.Trim();
                        ib.IsDefault      = cbIsDefault.Checked;
                    }

                    IncidentBoxDocument ibd = IncidentBoxDocument.Load(IssBoxId, (string)ViewState["IncidentBoxDocument"]);

                    //GeneralBlock
                    GeneralIncidentBoxBlock gibb = ibd.GeneralBlock;

                    //gibb.DefaultCreator = int.Parse(ddCreator.SelectedValue);
                    gibb.Manager              = int.Parse(ddManager.SelectedValue);
                    gibb.CalendarId           = int.Parse(ddCalendar.SelectedValue);
                    gibb.ControllerAssignType = (ControllerAssignType)(int.Parse(ddContType.SelectedValue));
                    if (gibb.ControllerAssignType == ControllerAssignType.CustomUser)
                    {
                        gibb.Controller = int.Parse(ddController.SelectedValue);
                    }
                    gibb.ResponsibleAssignType = (ResponsibleAssignType)(int.Parse(ddRespType.SelectedValue));
                    if (gibb.ResponsibleAssignType == ResponsibleAssignType.CustomUser)
                    {
                        gibb.Responsible = int.Parse(ddResponsible.SelectedValue);
                    }

                    gibb.AllowAddResources             = cbAllowAddRes.Checked;
                    gibb.AllowAddToDo                  = cbAllowAddToDo.Checked;
                    gibb.AllowControl                  = cbAllowControl.Checked;
                    gibb.AllowToDeclineResponsibility  = cbAllowToDeclineResp.Checked;
                    gibb.AllowToReassignResponsibility = cbAllowToReassignResp.Checked;
                    gibb.AllowUserToComeResponsible    = cbAllowToComeResp.Checked;
                    gibb.ReassignResponsibileOnReOpen  = cbReassignResp.Checked;
                    gibb.AllowOutgoingEmailFormat      = cbAllowAutoSigning.Checked;

                    ts = new TimeSpan(ucDuration.Value.Ticks);
                    gibb.ExpectedDuration = (int)ts.TotalMinutes;

                    ts = new TimeSpan(ucResponseTime.Value.Ticks);
                    gibb.ExpectedResponseTime = (int)ts.TotalMinutes;

                    ts = new TimeSpan(ucAssignTime.Value.Ticks);
                    gibb.ExpectedAssignTime = (int)ts.TotalMinutes;

                    ts            = new TimeSpan(ucTaskTime.Value.Ticks);
                    gibb.TaskTime = (int)ts.TotalMinutes;

                    //EMailRouterBlock
                    EMailRouterIncidentBoxBlock eribb = ibd.EMailRouterBlock;

                    eribb.AllowEMailRouting      = cbAllowEMail.Checked;
                    eribb.IncomingEMailAction    = (ExternalEMailActionType)(int.Parse(ddExtActionType.SelectedValue));
                    eribb.OutgoingEMailAction    = (InternalEMailActionType)(int.Parse(ddIntActionType.SelectedValue));
                    eribb.SendAutoReply          = cbAllowAutoReply.Checked;
                    eribb.SendAutoIncidentClosed = cbAllowAutoReplyClose.Checked;

                    //IncidentBoxDocument.Save(ibd);
                    IncidentBox.Update(ib, ibd);
                    Response.Redirect("~/Admin/HDMSettings.aspx");
                }
                catch (IncidentBoxDuplicateNameException)
                {
                    lblDuplicate.Text    = LocRM.GetString("tDuplicateName");
                    lblDuplicate.Visible = true;
                }
                catch (IncidentBoxDuplicateIdentifierMaskException)
                {
                    lblDuplicate.Text    = LocRM.GetString("tDuplicateMask");
                    lblDuplicate.Visible = true;
                }
            }
        }