Exemplo n.º 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);
            }
        }
Exemplo n.º 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
                                    );
                }
            }
        }
Exemplo n.º 3
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);
            }
        }
Exemplo n.º 4
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(); // 刷新当前结果集显示
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
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("移至废件箱");
            }
        }