예제 #1
0
        // 删除
        int Delete(
            out string strError)
        {
            strError = "";
            long nRet = 0;

            OpacApplication app         = (OpacApplication)this.Page.Application["app"];
            SessionInfo     sessioninfo = (SessionInfo)this.Page.Session["sessioninfo"];

            MessageData[] messages        = new MessageData[1];
            MessageData[] output_messages = null;

            messages[0]             = new MessageData();
            messages[0].strRecordID = this.RecordID;
            messages[0].TimeStamp   = this.TimeStamp;

            LibraryChannel channel = sessioninfo.GetChannel(true);

            try
            {
                if (String.IsNullOrEmpty(this.RecordID) == false)
                {
                    // 如果是废件箱内的消息, 彻底删除
                    if (BoxesInfo.IsRecycleBin(this.BoxName) == true)
                    {
                        nRet = // sessioninfo.Channel.
                               channel.SetMessage(
                            "delete",
                            "",
                            messages,
                            out output_messages,
                            out strError);
                    }
                    else
                    {
                        // 否则移动到废件箱
                        nRet = // sessioninfo.Channel.
                               channel.SetMessage(
                            "delete",
                            "movetorecyclebin",
                            messages,
                            out output_messages,
                            out strError);
                    }
                    if (nRet == -1)
                    {
                        return(-1);
                    }
                    this.BoxName = null;    // 现在不属于任何信箱
                }

                return(0);
            }
            finally
            {
                sessioninfo.ReturnChannel(channel);
            }
        }
예제 #2
0
        // 删除
        void deletebutton_Click(object sender, EventArgs e)
        {
            string strError = "";

            bool bDelete = false;

            // 如果是废件箱内的消息, 彻底删除
            if (BoxesInfo.IsRecycleBin(this.BoxName) == true)
            {
                bDelete = true;
            }

            int nRet = Delete(out strError);

            if (nRet == -1)
            {
                // text-level: 内部错误
                this.SetDebugInfo("删除消息失败: " + strError);
            }
            else
            {
                // text-level: 用户提示
                this.SetDebugInfo(this.GetString("消息删除成功"));  // "消息删除成功"
                if (bDelete == true)
                {
                    // 返回到当前所在信箱
                    this.SetEndInfo(this.GetString("消息删除成功"), null);
                }
                else
                {
                    // 返回到废件箱
                    this.SetEndInfo(this.GetString("消息已被移到废件箱"), // "消息已被移到废件箱。"
                                    BoxesInfo.TEMP
                                    );
                }
            }
        }
예제 #3
0
파일: Message.aspx.cs 프로젝트: gvhung/dp2
    protected void Page_Load(object sender, EventArgs e)
    {
        if (WebUtil.PrepareEnvironment(this,
                                       ref app,
                                       ref sessioninfo) == false)
        {
            return;
        }

        // 是否登录?
        if (sessioninfo.UserID == "")
        {
            sessioninfo.LoginCallStack.Push(Request.RawUrl);
            Response.Redirect("login.aspx", true);
            return;
        }

        string strSenderName = "";

        if (sessioninfo.ReaderInfo != null &&
            sessioninfo.IsReader == true)
        {
            string strDisplayName = "";
            string strBarcode     = "";

            strDisplayName = sessioninfo.ReaderInfo.DisplayName;
            strBarcode     = sessioninfo.ReaderInfo.Barcode;

            strSenderName = BoxesInfo.BuildOneAddress(strDisplayName, strBarcode);
        }
        else
        {
            strSenderName = sessioninfo.UserID;
        }

        this.MessageControl1.UserID = strSenderName;

        string strMessageID  = this.Request["id"];
        string strMessageIDs = this.Request["ids"];

        if (this.IsPostBack == false)
        {
            // ids参数不为空
            if (String.IsNullOrEmpty(strMessageIDs) == false)
            {
                string[]      ids    = strMessageIDs.Split(new char[] { ',' });
                List <string> idlist = new List <string>();
                for (int i = 0; i < ids.Length; i++)
                {
                    idlist.Add(ids[i]);
                }

                this.MessageControl1.MessageData    = null;
                this.MessageControl1.RecordID       = null;
                this.MessageControl1.TimeStamp      = null;
                this.MessageControl1.RecordIDs      = idlist;
                this.MessageControl1.RecordIDsIndex = 0;
                return;
            }

            // id参数不为空
            if (String.IsNullOrEmpty(strMessageID) == false)
            {
                LibraryChannel channel = sessioninfo.GetChannel(true);
                try
                {
                    string        strError = "";
                    MessageData[] messages = null;
                    string[]      ids      = new string[1];
                    ids[0] = strMessageID;
                    // 根据消息记录id获得消息详细内容
                    // 本函数还将检查消息是否属于strUserID指明的用户
                    // parameters:
                    //      strUserID   如果==null,表示不检查消息属于何用户
                    long nRet = // sessioninfo.Channel.
                                channel.GetMessage(
                        ids,
                        MessageLevel.Full,
                        out messages,
                        out strError);
                    if (nRet == -1)
                    {
                        this.Response.Write(strError);
                        this.Response.End();
                    }
                    if (messages == null || messages.Length < 1)
                    {
                        strError = "messages error";
                        this.Response.Write(strError);
                        this.Response.End();
                    }
                    this.MessageControl1.MessageData = messages[0];
                }
                finally
                {
                    sessioninfo.ReturnChannel(channel);
                }
            }
            else
            {
                string strRecipient = this.Request.QueryString["recipient"];
                if (String.IsNullOrEmpty(strRecipient) == false)
                {
                    this.MessageControl1.Recipient = strRecipient;
                }

                // 新创建的消息
                this.MessageControl1.MessageData = null;
                this.MessageControl1.RecordID    = null;
                this.MessageControl1.TimeStamp   = null;
            }
        }
    }
예제 #4
0
        // 删除选择的消息
        void deletebutton_Click(object sender, EventArgs e)
        {
            OpacApplication app         = (OpacApplication)this.Page.Application["app"];
            SessionInfo     sessioninfo = (SessionInfo)this.Page.Session["sessioninfo"];

            List <string> ids = new List <string>();

            for (int i = 0; i < this.LineCount; i++)
            {
                CheckBox checkbox = (CheckBox)this.FindControl("line" + Convert.ToString(i) + "_checkbox");
                if (checkbox.Checked == true)
                {
                    if (this.ItemIDs.Count <= i)
                    {
                        // text-level: 内部错误
                        this.SetDebugInfo("errorinfo", "ItemIDs失效...");
                        return;
                    }
                    ids.Add(this.ItemIDs[i]);
                    checkbox.Checked = false;
                }
            }

            if (ids.Count == 0)
            {
                // text-level: 用户提示
                this.SetDebugInfo(this.GetString("尚未选择任何消息"));
                return;
            }

            bool bMoveToRecycleBin = true;

            if (BoxesInfo.IsRecycleBin(this.CurrentBoxType) == true)
            {
                bMoveToRecycleBin = false;
            }
            else
            {
                bMoveToRecycleBin = true;
            }

            MessageData[] messages = new MessageData[ids.Count];
            for (int i = 0; i < ids.Count; i++)
            {
                messages[i]             = new MessageData();
                messages[i].strRecordID = ids[i];
            }

            LibraryChannel channel = sessioninfo.GetChannel(true);

            try
            {
                MessageData[] output_messages = null;
                string        strError        = "";
                long          nRet            = // sessioninfo.Channel.
                                                channel.SetMessage("delete",
                                                                   bMoveToRecycleBin == true ? "movetorecyclebin" : "",
                                                                   messages,
                                                                   out output_messages,
                                                                   out strError);
                if (nRet == -1)
                {
                    this.SetDebugInfo("errorinfo", strError);
                }
                else
                {
                    if (bMoveToRecycleBin == true)
                    {
                        // text-level: 用户提示
                        this.SetDebugInfo(
                            string.Format(this.GetString("已将s个消息移动到废件箱"),                        // "已将 {0} 个消息移动到废件箱。"
                                          ids.Count.ToString()));

                        // "已将 " + ids.Count + " 个消息移动到废件箱。");
                    }
                    else
                    {
                        // text-level: 用户提示
                        this.SetDebugInfo(
                            string.Format(this.GetString("已将s个消息永久删除"),                        // "已将 {0} 个消息永久删除。"
                                          ids.Count.ToString()));

                        // "已将 " + ids.Count + " 个消息永久删除。");
                    }

                    this.RefreshList(); // 刷新当前结果集显示
                }
            }
            finally
            {
                sessioninfo.ReturnChannel(channel);
            }
        }
예제 #5
0
        // 删除全部的消息
        void deleteallbutton_Click(object sender, EventArgs e)
        {
            string strError = "";
            long   nRet     = 0;

            bool bMoveToRecycleBin = true;

            OpacApplication app         = (OpacApplication)this.Page.Application["app"];
            SessionInfo     sessioninfo = (SessionInfo)this.Page.Session["sessioninfo"];

            if (BoxesInfo.IsRecycleBin(this.CurrentBoxType) == true)
            {
                bMoveToRecycleBin = false;
            }
            else
            {
                bMoveToRecycleBin = true;
            }

            string strStyle = this.CurrentBoxType;

            if (bMoveToRecycleBin == true)
            {
                strStyle += ",movetorecyclebin";
            }

            LibraryChannel channel = sessioninfo.GetChannel(true);

            try
            {
                MessageData[] output_messages = null;
                nRet = // sessioninfo.Channel.
                       channel.SetMessage("deleteall",
                                          strStyle,
                                          null,
                                          out output_messages,
                                          out strError);
                if (nRet == -1)
                {
                    this.SetDebugInfo("errorinfo", strError);
                    return;
                }
            }
            finally
            {
                sessioninfo.ReturnChannel(channel);
            }

            if (bMoveToRecycleBin == true)
            {
                // text-level: 用户提示
                this.SetDebugInfo(
                    string.Format(this.GetString("已将s个消息移动到废件箱"),    // "已将 {0} 个消息移动到废件箱。"
                                  nRet.ToString()));
                // "已将 " + nStart.ToString() + " 个消息移动到废件箱。"
            }
            else
            {
                // text-level: 用户提示
                this.SetDebugInfo(
                    string.Format(this.GetString("已将s个消息永久删除"),    // "已将 {0} 个消息永久删除。"
                                  nRet.ToString()));

                // "已将 " + nStart.ToString() + " 个消息永久删除。"
            }

            this.RefreshList(); // 刷新当前结果集显示
        }
예제 #6
0
        protected override void Render(HtmlTextWriter writer)
        {
            OpacApplication app         = (OpacApplication)this.Page.Application["app"];
            SessionInfo     sessioninfo = (SessionInfo)this.Page.Session["sessioninfo"];

            long nRet = 0;

            int nPageNo = this.StartIndex / this.PageMaxLines;

            if (nPageNo >= this.PageCount)  // 如果超过最后一页
            {
                lastpage_Click(null, null);
            }

            SetResultInfo();

            string strError = "";

            List <string> tempids = new List <string>();

            if (this.ResultCount != 0)
            {
                MessageData[]  messages = null;
                LibraryChannel channel  = sessioninfo.GetChannel(true);
                try
                {
                    int nTotalCount = 0;
                    nRet =  // sessioninfo.Channel.
                           channel.ListMessage(
                        "", // false,
                        this.ResultSetName,
                        this.CurrentBoxType,
                        MessageLevel.Summary,
                        this.StartIndex,
                        this.PageMaxLines,
                        out nTotalCount,
                        out messages,
                        out strError);
                    if (nRet == -1)
                    {
                        throw new Exception(strError);
                    }
                }
                finally
                {
                    sessioninfo.ReturnChannel(channel);
                }

                // 显示本页中的浏览行
                for (int i = 0; i < this.PageMaxLines; i++)
                {
                    MessageData data = null;
                    if (i < messages.Length)
                    {
                        data = messages[i];
                    }

                    PlaceHolder line = (PlaceHolder)this.FindControl("line" + Convert.ToString(i));
                    if (line == null)
                    {
                        PlaceHolder insertpoint = (PlaceHolder)this.FindControl("insertpoint");
                        PlaceHolder content     = (PlaceHolder)this.FindControl("content");

                        line = this.NewContentLine(content, i, insertpoint);
                    }

                    LiteralControl no        = (LiteralControl)this.FindControl("line" + Convert.ToString(i) + "_no");
                    CheckBox       checkbox  = (CheckBox)this.FindControl("line" + Convert.ToString(i) + "_checkbox");
                    LiteralControl sender    = (LiteralControl)this.FindControl("line" + Convert.ToString(i) + "_sender");
                    LiteralControl recipient = (LiteralControl)this.FindControl("line" + Convert.ToString(i) + "_recipient");
                    LiteralControl subject   = (LiteralControl)this.FindControl("line" + Convert.ToString(i) + "_subject");
                    LiteralControl date      = (LiteralControl)this.FindControl("line" + Convert.ToString(i) + "_date");
                    LiteralControl size      = (LiteralControl)this.FindControl("line" + Convert.ToString(i) + "_size");
                    LiteralControl classname = (LiteralControl)this.FindControl("line" + Convert.ToString(i) + "_classname");

                    if (data == null)
                    {
                        checkbox.Visible = false;
                        subject.Text     = "&nbsp;";
                        continue;
                    }

                    checkbox.Visible = true;

                    tempids.Add(data.strRecordID);

                    // 序号
                    string strNo = "&nbsp;";
                    strNo = Convert.ToString(i + this.StartIndex + 1);

                    no.Text = strNo;

                    string strDetailUrl = "./message.aspx?id=" + data.strRecordID;
                    if (data.strSubject == "")
                    {
                        data.strSubject = this.GetString("无");   // "(无)"
                    }
                    sender.Text    = data.strSender;
                    recipient.Text = data.strRecipient;
                    subject.Text   = "<a href='" + strDetailUrl + "'>" + data.strSubject + "</a>";
                    date.Text      = DateTimeUtil.LocalTime(data.strCreateTime);
                    size.Text      = data.strSize;

                    if (data.Touched == true)
                    {
                        classname.Text = "content";
                    }
                    else
                    {
                        classname.Text = "content new";
                    }
                } // end of for

                this.LineCount = Math.Max(this.LineCount, this.PageMaxLines);
            }
            else
            {
                // 显示空行
                for (int i = 0; i < this.PageMaxLines; i++)
                {
                    PlaceHolder line = (PlaceHolder)this.FindControl("line" + Convert.ToString(i));
                    if (line == null)
                    {
                        PlaceHolder insertpoint = (PlaceHolder)this.FindControl("insertpoint");
                        PlaceHolder content     = (PlaceHolder)this.FindControl("content");

                        line = this.NewContentLine(content, i, insertpoint);
                    }

                    line.Visible = true;

                    CheckBox checkbox = (CheckBox)this.FindControl("line" + Convert.ToString(i) + "_checkbox");
                    checkbox.Visible = false;

                    LiteralControl subject = (LiteralControl)this.FindControl("line" + Convert.ToString(i) + "_subject");
                    subject.Text = "&nbsp;";
                }
            }

            this.ItemIDs = tempids;

            // 设置删除按钮文字
            Button deletebutton = (Button)this.FindControl("delete");

            if (BoxesInfo.IsRecycleBin(this.CurrentBoxType) == true)
            {
                deletebutton.Text = this.GetString("永久删除选定的消息");
            }
            else
            {
                deletebutton.Text = this.GetString("将选定的消息移至废件箱");
            }

            // 设置删除全部按钮文字
            Button deleteallbutton = (Button)this.FindControl("deleteall");

            if (BoxesInfo.IsRecycleBin(this.CurrentBoxType) == true)
            {
                deleteallbutton.Text = this.GetString("永久删除全部消息");
            }
            else
            {
                deleteallbutton.Text = this.GetString("将全部消息移至废件箱");
            }

            base.Render(writer);
        }
예제 #7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (WebUtil.PrepareEnvironment(this,
                                       ref app,
                                       ref sessioninfo) == false)
        {
            return;
        }

        // 是否登录?
        if (sessioninfo.UserID == "")
        {
            sessioninfo.UserID   = "public";
            sessioninfo.IsReader = false;
        }

        string strError = "";
        int    nRet     = 0;

#if NO
        SessionInfo temp_sessioninfo = new SessionInfo(app);
        temp_sessioninfo.UserID   = app.ManagerUserName;
        temp_sessioninfo.Password = app.ManagerPassword;
        temp_sessioninfo.IsReader = false;
#endif
        LibraryChannel channel = app.GetChannel();

        try
        {
            bool   bHintDisplayName = false; // []暗示为显示名
            string strDisplayName   = this.Request["displayName"];
            string strBarcode       = this.Request["barcode"];
            string strEncyptBarcode = Request.QueryString["encrypt_barcode"];

            string strText = "";

            // 如果为加密的条码形态
            if (String.IsNullOrEmpty(strEncyptBarcode) == false)
            {
                strBarcode = OpacApplication.DecryptPassword(strEncyptBarcode);
                if (strBarcode == null)
                {
                    strError = "encrypt_barcode参数值格式错误";
                    goto ERROR1;
                }
                bHintDisplayName = true;
                goto SEARCH_COMMENT;
            }

            {
                if (String.IsNullOrEmpty(strDisplayName) == false)
                {
                    if (strDisplayName.IndexOfAny(new char[] { '[', ']' }) != -1)
                    {
                        bHintDisplayName = true;
                    }
                    strDisplayName = strDisplayName.Replace("[", "").Trim();
                    strDisplayName = strDisplayName.Replace("]", "").Trim();
                }

                nRet = 0;
                string strReaderXml        = "";
                string strOutputReaderPath = "";

                if (String.IsNullOrEmpty(strDisplayName) == false)
                {
                    byte[] timestamp = null;

                    string[] results = null;
                    long     lRet    = // temp_sessioninfo.Channel.
                                       channel.GetReaderInfo(
                        null,
                        "@displayName:" + strDisplayName,
                        "xml",
                        out results,
                        out strOutputReaderPath,
                        out timestamp,
                        out strError);
                    if (lRet == -1)
                    {
                        goto ERROR1;
                    }
                    if (lRet == 0 && bHintDisplayName == true)
                    {
                        strBarcode = "";
                        goto SEARCH_COMMENT;
                    }
                    strReaderXml = results[0];

                    // CONTINUE1:
                    if (nRet == 0)
                    {
                        strBarcode = strDisplayName;
                    }
                }

                // SEARCH_BARCODE:
                if (nRet == 0 && String.IsNullOrEmpty(strBarcode) == false)
                {
                    strReaderXml = "";
                    byte[] timestamp = null;

                    string[] results = null;
                    long     lRet    = // temp_sessioninfo.Channel.
                                       channel.GetReaderInfo(
                        null,
                        strBarcode,
                        "xml",
                        out results,
                        out strOutputReaderPath,
                        out timestamp,
                        out strError);
                    if (lRet == -1)
                    {
                        goto ERROR1;
                    }
                    if (lRet == 0)
                    {
                        goto SEARCH_COMMENT;
                    }
                    strReaderXml = results[0];
                }

                if (nRet == 0)
                {
                    /*
                     * strError = "读者显示名或者证条码号 '" + strDisplayName + "' 不存在";
                     * goto ERROR1;
                     * */
                    if (String.IsNullOrEmpty(strBarcode) == true)
                    {
                        strBarcode = strDisplayName;
                    }
                    goto SEARCH_COMMENT;
                }

                XmlDocument readerdom = null;
                nRet = OpacApplication.LoadToDom(strReaderXml,
                                                 out readerdom,
                                                 out strError);
                if (nRet == -1)
                {
                    strError = "装载读者记录 '" + strOutputReaderPath + "' 进入XML DOM时发生错误: " + strError;
                    goto ERROR1;
                }

                strDisplayName = DomUtil.GetElementText(readerdom.DocumentElement,
                                                        "displayName");

                strBarcode = DomUtil.GetElementInnerXml(readerdom.DocumentElement,
                                                        "barcode");
            }
SEARCH_COMMENT:
            strText = strDisplayName;
            if (String.IsNullOrEmpty(strText) == true)
            {
                strText = strBarcode;
            }

            this.Label_name.Text = strText;

            string strRecipient = "";

            /*
             * if (String.IsNullOrEmpty(strDisplayName) == false)
             * {
             *  if (strDisplayName.IndexOf("[") == -1)
             *      strRecipient = "[" + strDisplayName + "]";
             *  else
             *      strRecipient = strDisplayName;
             *  if (String.IsNullOrEmpty(strEncyptBarcode) == false)
             *      strRecipient += " encrypt_barcode:" + strEncyptBarcode;
             * }
             * else
             *  strRecipient = strBarcode;
             * */
            strRecipient = BoxesInfo.BuildOneAddress(strDisplayName, strBarcode);

            string strSendMessageUrl = "./message.aspx?recipient=" + HttpUtility.UrlEncode(strRecipient);
            this.Button_sendMessage.OnClientClick = "window.open('" + strSendMessageUrl + "','_blank'); return cancelClick();";

            LoginState loginstate = GlobalUtil.GetLoginState(this.Page);
            if (loginstate == LoginState.NotLogin || loginstate == LoginState.Public)
            {
                this.Button_sendMessage.Enabled = false;
            }

            this.BrowseSearchResultControl1.Title = strText + " 所发表的书评";

            if (String.IsNullOrEmpty(strEncyptBarcode) == false)
            {
                this.Image_photo.ImageUrl = "./getphoto.aspx?encrypt_barcode=" + HttpUtility.UrlEncode(strEncyptBarcode) + "&displayName=" + HttpUtility.UrlEncode(strDisplayName);
            }
            else
            {
                this.Image_photo.ImageUrl = "./getphoto.aspx?barcode=" + HttpUtility.UrlEncode(strBarcode);
            }

            this.Image_photo.Width  = 128;
            this.Image_photo.Height = 128;

            if (this.IsPostBack == false)
            {
                string strXml = "";
                if (String.IsNullOrEmpty(strDisplayName) == false &&
                    String.IsNullOrEmpty(strBarcode) == false)
                {
                    // 创建评注记录XML检索式
                    // 用作者和作者显示名共同限定检索
                    nRet = ItemSearchControl.BuildCommentQueryXml(
                        app,
                        strDisplayName,
                        strBarcode,
                        "<全部>",
                        15000,   // app.SearchMaxResultCount
                        true,
                        out strXml,
                        out strError);
                    if (nRet == -1)
                    {
                        goto ERROR1;
                    }
                }
                else if (String.IsNullOrEmpty(strBarcode) == false)
                {
                    // 创建XML检索式
                    nRet = ItemSearchControl.BuildQueryXml(
                        this.app,
                        "comment",
                        strBarcode,
                        "<全部>",
                        "作者",
                        "exact",
                        15000,   // app.SearchMaxResultCount
                        true,
                        out strXml,
                        out strError);
                    if (nRet == -1)
                    {
                        goto ERROR1;
                    }
                }
                else if (String.IsNullOrEmpty(strDisplayName) == false)
                {
                    // 创建XML检索式
                    nRet = ItemSearchControl.BuildQueryXml(
                        this.app,
                        "comment",
                        strDisplayName,
                        "<全部>",
                        "作者显示名",
                        "exact",
                        15000,   // app.SearchMaxResultCount
                        true,
                        out strXml,
                        out strError);
                    if (nRet == -1)
                    {
                        goto ERROR1;
                    }
                }
                else
                {
                    strError = "strBarcode和strDisplayName均为空,无法进行检索";
                    goto ERROR1;
                }

                string strResultSetName = "opac_userinfo";

                // sessioninfo.Channel.
                channel.Idle += new IdleEventHandler(channel_Idle);
                try
                {
                    long lRet = //sessioninfo.Channel.
                                channel.Search(
                        null,
                        strXml,
                        strResultSetName,
                        "", // strOutputStyle
                        out strError);
                    if (lRet == -1)
                    {
                        goto ERROR1;
                    }

                    // not found
                    if (lRet == 0)
                    {
                        this.BrowseSearchResultControl1.Title = strText + " 没有发表过任何书评";
                    }
                    else
                    {
                        this.BrowseSearchResultControl1.ResultSetName = strResultSetName;
                        this.BrowseSearchResultControl1.ResultCount   = (int)lRet;
                        this.BrowseSearchResultControl1.StartIndex    = 0;
                    }
                    return;
                }
                finally
                {
                    //sessioninfo.Channel.
                    channel.Idle -= new IdleEventHandler(channel_Idle);
                }
            }
            return;

ERROR1:
            Response.Write(HttpUtility.HtmlEncode(strError));
            Response.End();
        }
        finally
        {
#if NO
            temp_sessioninfo.CloseSession();
#endif
            app.ReturnChannel(channel);
        }
    }
예제 #8
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);
            }
        }
예제 #9
0
        // 保存到草稿箱
        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);
        }
예제 #10
0
        // 设置按钮和编辑域状态
        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("移至废件箱");
            }
        }