Ejemplo n.º 1
0
        void NodeActions_InvokeCommand(object Sender, InvokeCommandArgs e)
        {
            SqlForumProvider fp       = new Mediachase.Ibn.Forum.SqlForumProvider();
            HttpResponse     Response = ((Control)Sender).Page.Response;

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

            // TODO: (OR) У Олега Ж. пока не реализовано. Должно вытаскиваться из атрибутов.
            int emailMessageId = -1;

            switch (e.CommandUid)
            {
                #region Reply
            case "Reply":
//					((Control)Sender).Page.Response.Write("Test reply event (TestCommandManager.dll : class TestReplyHandler )<br>");
                break;

                #endregion
                #region ReplyOutlook
            case "ReplyOutlook":
                Response.ClearContent();
                Response.ClearHeaders();
                Response.AddHeader("content-disposition", String.Format("attachment; filename=\"{0}\"", "mail.msg"));
                Response.ContentType = "application/msoutlook";

                MsgMessage.Open(iObjId, emailMessageId, Response.OutputStream);
                Response.End();
                break;

                #endregion
                #region ReplyEML
            case "ReplyEML":
                Response.ClearContent();
                Response.ClearHeaders();
                Response.AddHeader("content-disposition", String.Format("attachment; filename=\"{0}\"", "mail.eml"));
                Response.ContentType = "message/rfc822";
                MsgMessage.OpenEml(iObjId, emailMessageId, Response.OutputStream);
                Response.End();
                break;

                #endregion
                #region ReSend
            case "ReSend":
                EMailRouterOutputMessage.Send(iObjId, emailMessageId);
                break;

                #endregion
                #region ReSendOut
            case "ReSendOut":
                EMailRouterOutputMessage.Send(iObjId, emailMessageId);
                break;

                #endregion
                #region Resolution
            case "Resolution":
                e.Node.SetAttribute("Resolution", "1");
                fp.SaveNode(e.Node);
                break;

                #endregion
                #region UnResolution
            case "UnResolution":
                if (e.Node.Attributes.ContainsKey("Resolution"))
                {
                    e.Node.Attributes.Remove("Resolution");
                    fp.SaveNode(e.Node);
                }
                break;

                #endregion
                #region Workaround
            case "Workaround":
                e.Node.SetAttribute("Workaround", "1");
                fp.SaveNode(e.Node);
                break;

                #endregion
                #region UnWorkaround
            case "UnWorkaround":
                if (e.Node.Attributes.ContainsKey("Workaround"))
                {
                    e.Node.Attributes.Remove("Workaround");
                    fp.SaveNode(e.Node);
                }
                break;

                #endregion
                #region OnTop
            case "OnTop":
                e.Node.SetAttribute(Node.ONTOP_ATTRIBUTE, "1");
                fp.SaveNode(e.Node);
                break;

                #endregion
                #region UnOnTop
            case "UnOnTop":
                if (e.Node.Attributes.ContainsKey(Node.ONTOP_ATTRIBUTE))
                {
                    e.Node.Attributes.Remove(Node.ONTOP_ATTRIBUTE);
                    fp.SaveNode(e.Node);
                }
                break;

                #endregion
                #region Delete
            case "Delete":
                fp.DeleteNode(e.Node.Uid);
                break;

                #endregion
            default:
                break;
            }
        }
Ejemplo n.º 2
0
        private void dgForum_ItemCommand(object source, DataGridCommandEventArgs e)
        {
            if (e.CommandName == "Resolution")
            {
                int nodeId = int.Parse(e.CommandArgument.ToString());
                ForumThreadNodeSettingCollection coll = new ForumThreadNodeSettingCollection(nodeId);
                coll.Add(ForumThreadNodeSetting.Resolution, "1");

                if (coll[ForumThreadNodeSetting.Internal] == null &&
                    coll[ForumThreadNodeSetting.Incoming] == null &&
                    coll[ForumThreadNodeSetting.Outgoing] == null)
                {
                    coll.Add(ForumThreadNodeSetting.Internal, "1");
                }
            }
            else if (e.CommandName == "Workaround")
            {
                int nodeId = int.Parse(e.CommandArgument.ToString());
                ForumThreadNodeSettingCollection coll = new ForumThreadNodeSettingCollection(nodeId);
                coll.Add(ForumThreadNodeSetting.Workaround, "1");

                if (coll[ForumThreadNodeSetting.Internal] == null &&
                    coll[ForumThreadNodeSetting.Incoming] == null &&
                    coll[ForumThreadNodeSetting.Outgoing] == null)
                {
                    coll.Add(ForumThreadNodeSetting.Internal, "1");
                }
            }
            else if (e.CommandName == "UnResolution")
            {
                int nodeId = int.Parse(e.CommandArgument.ToString());
                ForumThreadNodeSettingCollection coll = new ForumThreadNodeSettingCollection(nodeId);
                if (coll[ForumThreadNodeSetting.Resolution] != null)
                {
                    coll.Remove(ForumThreadNodeSetting.Resolution);
                }

                if (coll[ForumThreadNodeSetting.Internal] == null &&
                    coll[ForumThreadNodeSetting.Incoming] == null &&
                    coll[ForumThreadNodeSetting.Outgoing] == null)
                {
                    coll.Add(ForumThreadNodeSetting.Internal, "1");
                }
            }
            else if (e.CommandName == "UnWorkaround")
            {
                int nodeId = int.Parse(e.CommandArgument.ToString());
                ForumThreadNodeSettingCollection coll = new ForumThreadNodeSettingCollection(nodeId);
                if (coll[ForumThreadNodeSetting.Workaround] != null)
                {
                    coll.Remove(ForumThreadNodeSetting.Workaround);
                }

                if (coll[ForumThreadNodeSetting.Internal] == null &&
                    coll[ForumThreadNodeSetting.Incoming] == null &&
                    coll[ForumThreadNodeSetting.Outgoing] == null)
                {
                    coll.Add(ForumThreadNodeSetting.Internal, "1");
                }
            }
            else if (e.CommandName == "ReSend")
            {
                int emailMessageId = int.Parse(e.CommandArgument.ToString());
                try
                {
                    EMailRouterOutputMessage.Send(IncidentId, emailMessageId);
                    WasFarwarded   = 1;
                    ForwardedEMail = emailMessageId;
                }
                catch
                {
                    WasFarwarded   = -1;
                    ForwardedEMail = emailMessageId;
                }
            }
            else if (e.CommandName == "ReSendOut")
            {
                int emailMessageId = int.Parse(e.CommandArgument.ToString());
                try
                {
                    EMailRouterOutputMessage.Send(IncidentId, emailMessageId);
                    WasFarwarded   = 1;
                    ForwardedEMail = emailMessageId;
                }
                catch
                {
                    WasFarwarded   = -1;
                    ForwardedEMail = emailMessageId;
                }
            }
            else if (e.CommandName == "Reply")
            {
                try
                {
                    int emailMessageId = int.Parse(e.CommandArgument.ToString());

                    if (pc["IncForum_ReplyOutlook"] == "1")
                    {
                        Response.AddHeader("content-disposition", String.Format("attachment; filename=\"{0}\"", "mail.msg"));
                        HttpContext.Current.Response.ContentType = "application/msoutlook";

                        MsgMessage.Open(IncidentId, emailMessageId,
                                        HttpContext.Current.Response.OutputStream);
                    }
                    else if (pc["IncForum_ReplyEML"] == "1")
                    {
                        Response.AddHeader("content-disposition", String.Format("attachment; filename=\"{0}\"", "mail.eml"));
                        HttpContext.Current.Response.ContentType = "message/rfc822";
                        MsgMessage.OpenEml(IncidentId, emailMessageId,
                                           HttpContext.Current.Response.OutputStream);
                    }

                    Response.End();
                }
                catch (Exception ex)
                {
                    HttpContext.Current.Trace.Write(ex.Message);
                }
            }
        }