// 保存到草稿箱 int SaveToTemp(out string strError) { OpacApplication app = (OpacApplication)this.Page.Application["app"]; SessionInfo sessioninfo = (SessionInfo)this.Page.Session["sessioninfo"]; strError = ""; string strOldRecordID = ""; byte[] baOldTimeStamp = null; // 如果是来自草稿的记录 if (BoxesInfo.IsTemp(this.BoxName) == true) { strOldRecordID = this.RecordID; baOldTimeStamp = this.TimeStamp; } TextBox recipient = (TextBox)this.FindControl("recipient"); TextBox subject = (TextBox)this.FindControl("subject"); TextBox sender = (TextBox)this.FindControl("sender"); sender.Text = this.UserID; TextBox content = (TextBox)this.FindControl("content"); //byte[] baOutputTimeStamp = null; //string strOutputID = ""; MessageData[] messages = new MessageData[1]; MessageData[] output_messages = null; messages[0] = new MessageData(); messages[0].strRecipient = recipient.Text; messages[0].strSender = sender.Text; messages[0].strSubject = subject.Text; messages[0].strMime = "text"; messages[0].strBody = content.Text; messages[0].strRecordID = strOldRecordID; // string strOldRecordID, messages[0].TimeStamp = baOldTimeStamp; // byte [] baOldTimeStamp, LibraryChannel channel = sessioninfo.GetChannel(true); try { long nRet = // sessioninfo.Channel. channel.SetMessage( "save", "", messages, out output_messages, out strError); if (nRet == -1) { return(-1); } } finally { sessioninfo.ReturnChannel(channel); } if (output_messages == null || output_messages.Length < 1) { strError = "output_messages error"; return(-1); } // 为了便于再次修改后保存 this.RecordID = output_messages[0].strRecordID; this.TimeStamp = output_messages[0].TimeStamp; return(0); }
// 发送 int Send(out string strError) { OpacApplication app = (OpacApplication)this.Page.Application["app"]; SessionInfo sessioninfo = (SessionInfo)this.Page.Session["sessioninfo"]; strError = ""; TextBox recipient = (TextBox)this.FindControl("recipient"); if (String.IsNullOrEmpty(recipient.Text) == true) { // text-level: 用户提示 strError = this.GetString("尚未填写收件人"); // "尚未填写收件人" return(-1); } TextBox subject = (TextBox)this.FindControl("subject"); if (String.IsNullOrEmpty(subject.Text) == true) { // text-level: 用户提示 strError = this.GetString("尚未填写主题"); // "尚未填写主题" return(-1); } TextBox sender = (TextBox)this.FindControl("sender"); sender.Text = this.UserID; TextBox content = (TextBox)this.FindControl("content"); MessageData[] messages = new MessageData[1]; MessageData[] output_messages = null; messages[0] = new MessageData(); messages[0].strRecipient = recipient.Text; messages[0].strSender = sender.Text; messages[0].strSubject = subject.Text; messages[0].strMime = "text"; messages[0].strBody = content.Text; //messages[0].strRecordID = strOldRecordID; // string strOldRecordID, //messages[0].TimeStamp = baOldTimeStamp; // byte [] baOldTimeStamp, LibraryChannel channel = sessioninfo.GetChannel(true); try { long nRet = // sessioninfo.Channel. channel.SetMessage( "send", "", messages, out output_messages, out strError); if (nRet == -1) { return(-1); } // 如果来自草稿箱, 则需要从中永久删除 if (BoxesInfo.IsTemp(this.BoxName) == true) { messages = new MessageData[1]; output_messages = null; messages[0] = new MessageData(); messages[0].strRecordID = this.RecordID; // string strOldRecordID, messages[0].TimeStamp = this.TimeStamp; // byte [] baOldTimeStamp, nRet = // sessioninfo.Channel. channel.SetMessage( "delete", "", messages, out output_messages, out strError); if (nRet == -1) { return(-1); } this.BoxName = null; // 现在不属于任何信箱 } return(0); } finally { sessioninfo.ReturnChannel(channel); } }
// 设置按钮和编辑域状态 public void SetState(string strOriginBox) { TextBox recipient = (TextBox)this.FindControl("recipient"); TextBox sender = (TextBox)this.FindControl("sender"); TextBox subject = (TextBox)this.FindControl("subject"); TextBox content = (TextBox)this.FindControl("content"); TextBox date = (TextBox)this.FindControl("date"); Button savebutton = (Button)this.FindControl("save"); Button sendbutton = (Button)this.FindControl("send"); Button replybutton = (Button)this.FindControl("reply"); Button forwardbutton = (Button)this.FindControl("forward"); Button deletebutton = (Button)this.FindControl("delete"); // 如果是窗口内新记录 if (String.IsNullOrEmpty(strOriginBox) == true) { savebutton.Enabled = true; sendbutton.Enabled = true; replybutton.Enabled = false; forwardbutton.Enabled = false; deletebutton.Enabled = false; if (String.IsNullOrEmpty(sender.Text) == true) { // 2006/11/25 neew add sender.Text = this.UserID; } sender.ReadOnly = true; recipient.ReadOnly = false; subject.ReadOnly = false; content.ReadOnly = false; // 让修改 date.ReadOnly = true; } // 如果是来自收件箱的记录 else if (BoxesInfo.IsInBox(strOriginBox) == true) { savebutton.Enabled = false; sendbutton.Enabled = false; replybutton.Enabled = true; forwardbutton.Enabled = true; deletebutton.Enabled = true; sender.ReadOnly = true; recipient.ReadOnly = true; subject.ReadOnly = true; content.ReadOnly = true; // 不让修改 date.ReadOnly = true; } // 如果是来自草稿的记录 else if (BoxesInfo.IsTemp(strOriginBox) == true) { savebutton.Enabled = true; sendbutton.Enabled = true; replybutton.Enabled = false; forwardbutton.Enabled = false; deletebutton.Enabled = true; sender.Text = this.UserID; sender.ReadOnly = true; recipient.ReadOnly = false; subject.ReadOnly = false; content.ReadOnly = false; // 让修改 date.ReadOnly = true; } // 如果是来自 已发送 的记录 else if (BoxesInfo.IsOutbox(strOriginBox) == true) { savebutton.Enabled = false; sendbutton.Enabled = true; // 再次发送? replybutton.Enabled = false; forwardbutton.Enabled = true; deletebutton.Enabled = true; // 全部不让修改 sender.ReadOnly = true; recipient.ReadOnly = true; subject.ReadOnly = true; content.ReadOnly = true; // 不让修改 date.ReadOnly = true; } // 如果是来自 废件箱 的记录 else if (BoxesInfo.IsRecycleBin(strOriginBox) == true) { savebutton.Enabled = false; sendbutton.Enabled = false; replybutton.Enabled = true; forwardbutton.Enabled = true; deletebutton.Enabled = true; // 全部不让修改 sender.ReadOnly = true; recipient.ReadOnly = true; subject.ReadOnly = true; content.ReadOnly = true; // 不让修改 date.ReadOnly = true; } // 如果是废件箱内的消息, 彻底删除 if (BoxesInfo.IsRecycleBin(this.BoxName) == true) { deletebutton.Text = this.GetString("永久删除"); } else { deletebutton.Text = this.GetString("移至废件箱"); } }