Beispiel #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            recid = RequestData.Get <string>("recid");
            title = RequestData.Get <string>("title", String.Empty);
            op    = RequestData.Get <string>("op");

            SysMessage msg = null;

            switch (this.RequestAction)
            {
            case RequestActionEnum.Update:
                msg = this.GetMergedData <SysMessage>();
                msg.SaveAndFlush();
                this.SetMessage("修改成功!");
                break;

            case RequestActionEnum.Create:
                msg = this.GetPostedData <SysMessage>();

                msg.SenderId   = this.UserInfo.UserID;
                msg.SenderName = this.UserInfo.Name;
                msg.SendTime   = DateTime.Now;

                msg.CreateAndFlush();
                this.SetMessage("新建成功!");
                break;

            case RequestActionEnum.Delete:
                msg = this.GetTargetData <SysMessage>();
                msg.DeleteAndFlush();
                this.SetMessage("删除成功!");
                return;
            }

            if (this.Request["Id"] != null)
            {
                msg = SysMessage.Find(this.Request["Id"]);
            }
            else if (op == "c")
            {
                if (!String.IsNullOrEmpty(recid))
                {
                    SysUser tusr = SysUser.Find(recid);

                    PageState.Add("ReceiverInfo", tusr);
                    PageState.Add("Title", title);
                }
            }

            this.SetFormData(msg);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            recid = RequestData.Get <string>("recid");
            title = RequestData.Get <string>("title", String.Empty);
            op    = RequestData.Get <string>("op");

            SysMessage msg = null;

            switch (this.RequestAction)
            {
            case RequestActionEnum.Update:
                msg = this.GetMergedData <SysMessage>();
                if (this.RequestData.Get("issend") != null && this.RequestData.Get <string>("issend") == "T")
                {
                    msg.State = "1";
                    GenerateReceivers(msg);
                }
                msg.SaveAndFlush();
                this.SetMessage("修改成功!");
                break;

            case RequestActionEnum.Create:
                msg = this.GetPostedData <SysMessage>();

                msg.SenderId   = this.UserInfo.UserID;
                msg.SenderName = this.UserInfo.Name;
                msg.SendTime   = DateTime.Now;

                if (this.RequestData.Get("issend") != null && this.RequestData.Get <string>("issend") == "T")
                {
                    msg.State = "1";
                    GenerateReceivers(msg);
                }
                msg.CreateAndFlush();
                this.SetMessage("新建成功!");
                break;

            case RequestActionEnum.Delete:
                msg = this.GetTargetData <SysMessage>();
                msg.DeleteAndFlush();
                this.SetMessage("删除成功!");
                return;
            }

            if (this.Request["Id"] != null)
            {
                msg = SysMessage.Find(this.Request["Id"]);
                try
                {
                    SysMessageReceive receive = SysMessageReceive.FindAllByProperties("MsgId", msg.Id, "ReceiverId", this.UserInfo.UserID)[0];
                    receive.IsFirstView   = "1";
                    receive.FirstViewTime = DateTime.Now;
                    receive.Save();
                    if (this.RequestData.Get("isdelete") != null && this.RequestData.Get <string>("isdelete") == "T")
                    {
                        receive.IsDelete = "1";
                        receive.Save();
                    }
                    string       template = @"<tr>
                                                <td align='center'>
                                                    <table width='96%' border='1' style='border-collapse: collapse; background-color:Gray;' cellspacing='0' cellpadding='0'>
                                                        <tr>
                                                            <td>
                                                                <font size='2'>回复人:&nbsp; {0}</font>
                                                            </td>
                                                            <td>
                                                                <font size='2'>回复时间:&nbsp; {1}</font>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                        </tr>
                                                        <tr>
                                                            <td colspan='2' style='word-wrap: break-word;'>
                                                                <font size='2'>回复内容:&nbsp; {2}</font>
                                                            </td>
                                                        </tr>
                                                    </table>
                                                </td>
                                            </tr>";
                    SysMessage[] msgs     = SysMessage.FindAll(Expression.Sql("Id in (select ReplyMsgId from SysMessageReceive where MsgId='" + msg.Id + "')"));
                    foreach (SysMessage mg in msgs)
                    {
                        ReplyHTML += string.Format(template, mg.SenderName, mg.SendTime, mg.MessageContent);
                    }
                }
                catch { }
            }
            else if (op == "c")
            {
                if (!String.IsNullOrEmpty(recid))
                {
                    SysUser tusr = SysUser.Find(recid);

                    PageState.Add("ReceiverInfo", tusr);
                    PageState.Add("Title", title);
                }
            }

            this.SetFormData(msg);
        }
Beispiel #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            recid = RequestData.Get <string>("recid");
            title = RequestData.Get <string>("title", String.Empty);
            op    = RequestData.Get <string>("op");

            SysMessage msg = null;

            switch (this.RequestAction)
            {
            case RequestActionEnum.Update:
                msg = this.GetMergedData <SysMessage>();
                if (this.RequestData.Get("issend") != null && this.RequestData.Get <string>("issend") == "T")
                {
                    msg.State = "1";
                    GenerateReceivers(msg);
                }
                msg.SaveAndFlush();
                this.SetMessage("修改成功!");
                break;

            case RequestActionEnum.Create:
                msg = this.GetPostedData <SysMessage>();

                msg.SenderId   = this.UserInfo.UserID;
                msg.SenderName = this.UserInfo.Name;
                msg.SendTime   = DateTime.Now;

                if (this.RequestData.Get("issend") != null && this.RequestData.Get <string>("issend") == "T")
                {
                    msg.State = "1";
                }
                msg.CreateAndFlush();
                if (this.RequestData.Get("issend") != null && this.RequestData.Get <string>("issend") == "T")
                {
                    GenerateReceivers(msg);
                }
                if (recid != null && recid != "")
                {
                    SysMessageReceive receive = SysMessageReceive.FindAllByProperties("MsgId", recid, "ReceiverId", this.UserInfo.UserID)[0];
                    receive.IsReply     = "1";
                    receive.ReplyMsgId  = msg.Id;
                    receive.ReplyTime   = DateTime.Now;
                    receive.ReplyResult = msg.MessageContent;
                    receive.Save();
                }
                this.SetMessage("新建成功!");
                break;

            case RequestActionEnum.Delete:
                msg = this.GetTargetData <SysMessage>();
                msg.DeleteAndFlush();
                this.SetMessage("删除成功!");
                return;
            }

            if (this.Request["Id"] != null)
            {
                msg = SysMessage.Find(this.Request["Id"]);
            }
            else if (op == "c")
            {
                if (!String.IsNullOrEmpty(recid))
                {
                    SysMessage tusr = SysMessage.Find(recid);

                    PageState.Add("ReceiverInfo", "{UserID:'" + tusr.SenderId + "',Name:'" + tusr.SenderName + "'}");
                    PageState.Add("Title", tusr.Title + "[回复]");
                }
            }

            this.SetFormData(msg);
        }