示例#1
0
        // 保存
        void savebutton_Click(object sender, EventArgs e)
        {
            OpacApplication app = (OpacApplication)this.Page.Application["app"];

            string strError = "";
            int    nRet     = SaveToTemp(out strError);

            if (nRet == -1)
            {
                // text-level: 用户提示
                this.SetDebugInfo(
                    string.Format(this.GetString("保存消息到s失败,原因s"),   // "保存消息到 {0} 失败,原因: {1}"
                                  app.BoxesInfo.GetString("草稿"),
                                  strError)

                    /*
                     * "保存消息到 "
                     + this.BoxesInfo.GetString("草稿")
                     + " 失败: " + strError*/
                    );
            }
            else
            {
                // text-level: 用户提示
                this.SetDebugInfo(this.GetString("消息保存成功"));  // "消息保存成功"
                this.SetEndInfo(this.GetString("消息保存成功"),
                                BoxesInfo.TEMP
                                );
            }
        }
示例#2
0
        void FillTabControl(TabControl tabcontrol)
        {
            OpacApplication app = (OpacApplication)this.Page.Application["app"];

            string strDefaultFormatName = this.DefaultFormatName;

            List <string> format_ids = new List <string> {
                "simple",
                "simplest",
                "logic"
            };
            List <string> format_names = new List <string> {
                this.GetString("simple"),
                this.GetString("simplest"),
                this.GetString("logic")
            };

            tabcontrol.Columns.Clear();
            for (int i = 0; i < format_ids.Count; i++)
            {
                TabColumn column = new TabColumn();
                column.Name = format_names[i];
                column.ID   = format_ids[i];
                tabcontrol.Columns.Add(column);

                if (this.DefaultFormatName == format_ids[i])
                {
                    tabcontrol.ActiveTab = format_names[i];
                }
            }
        }
示例#3
0
        protected override void Render(HtmlTextWriter output)
        {
            int    nRet     = 0;
            string strError = "";

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

            if (m_bLoaded == false)
            {
                string strParentID = "";
                nRet = LoadRecord(this.ItemRecPath,
                                  out strParentID,
                                  out strError);
                if (nRet == -1)
                {
                    goto ERROR1;
                }
            }

            base.Render(output);
            return;

ERROR1:
            this.SetDebugInfo("errorinfo", strError);
        }
示例#4
0
        protected override void CreateChildControls()
        {
#if NO
            Label label = new Label();
            label.ID       = "label";
            label.CssClass = "librarycodelabel";
            label.Text     = "分馆代码: ";
            this.Controls.Add(label);

            DropDownList list = new DropDownList();
            list.ID = "librarycode";
            // list.Width = new Unit("100%");
            list.CssClass     = "librarycode";
            list.AutoPostBack = true;
            list.TextChanged -= new EventHandler(list_TextChanged);
            list.TextChanged += new EventHandler(list_TextChanged);
            this.Controls.Add(list);

            OpacApplication app   = (OpacApplication)this.Page.Application["app"];
            List <string>   codes = app.GetAllLibraryCodes();
            if (codes.Count > 0)
            {
                FillList(list, codes);
            }
            else
            {
                label.Visible = false;
                list.Visible  = false;
            }
#endif

            LiteralControl table = new LiteralControl();
            table.ID = "table";  // id用于render()时定位
            this.Controls.Add(table);
        }
示例#5
0
文件: WebUtil.cs 项目: zszqwe/dp2
        public static bool PrepareEnvironment(Page page,
                                              ref OpacApplication app)
        {
            // 检查系统错误字符串
            string strErrorInfo = (string)page.Application["errorinfo"];

            if (String.IsNullOrEmpty(strErrorInfo) == false)
            {
                page.Response.Write(strErrorInfo);
                page.Response.End();
                return(false);   // error
            }

            // 获得app对象
            app = (OpacApplication)page.Application["app"];
            if (app == null)
            {
                strErrorInfo = "app == null";
                page.Response.Write(strErrorInfo);
                page.Response.End();
                return(false);
            }

            return(true);
        }
示例#6
0
        protected void Application_End(Object sender, EventArgs e)
        {
            OpacApplication app = null;

            try
            {
                /*
                 * // 调试用
                 * OpacApplication.WriteErrorLog("成功进入Application_End", EventLogEntryType.Information);
                 * */

                // 错误信息采用两级存放策略。
                // 如果LibraryAppliation对象已经存在,则采用其ErrorInfo成员的值;
                // 否则,采用Application["errorinfo"]值
                string strErrorInfo = "";
                app = (OpacApplication)Application["app"];
                if (app != null)
                {
                    strErrorInfo = app.GlobalErrorInfo;
                }
                else
                {
                    strErrorInfo = (string)Application["errorinfo"];
                }

                // 系统错误字符串为空时才保存.xml配置文件
                if (String.IsNullOrEmpty(strErrorInfo) == true)
                {
                    /*
                     * // 调试用
                     * OpacApplication.WriteWindowsLog("进行了 opac.xml 保存", EventLogEntryType.Information);
                     * */

                    app.Save(null, false);

                    app.Close();
                }
                else
                {
                    /*
                     * // 调试用
                     * OpacApplication.WriteWindowsLog("没有进行 opac.xml 保存,因为错误字符串 '" + ErrorInfo + "'", EventLogEntryType.Information);
                     * */
                }
            }
            catch (Exception ex)
            {
                string strErrorText = "Application_End阶段出现异常: " + ExceptionUtil.GetDebugText(ex);
                OpacApplication.WriteWindowsLog(strErrorText);

                if (app != null)
                {
                    app.GlobalErrorInfo = strErrorText;
                }
                else
                {
                    Application["errorinfo"] = strErrorText;
                }
            }
        }
示例#7
0
文件: WebUtil.cs 项目: zszqwe/dp2
 // 构造一个 style 目录中文件的路径
 public static string GetStylePath(OpacApplication app, string strFilename)
 {
     if (app != null && app.IsNewStyle == true)
     {
         return("./stylenew/" + strFilename);
     }
     return("./style/" + strFilename);
 }
示例#8
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);
            }
        }
示例#9
0
        // 选定一个风格
        void imagebutton_Click(object sender, ImageClickEventArgs e)
        {
            string          strError = "";
            OpacApplication app      = (OpacApplication)this.Page.Application["app"];

            if (app == null)
            {
                strError = "app == null";
                goto ERROR1;
            }
            SessionInfo sessioninfo = (SessionInfo)this.Page.Session["sessioninfo"];

            if (sessioninfo == null)
            {
                strError = "sessioninfo == null";
                goto ERROR1;
            }

            ImageButton imagebutton = (ImageButton)sender;
            string      strDirName  = imagebutton.ID;

            int nRedoCount = 0;

REDO:
            int nRet = SelectStyle(strDirName, out strError);

            if (nRet == -1)
            {
                goto ERROR1;
            }

            // return:
            //      -2  时间戳冲突
            //      -1  error
            //      0   没有必要保存(changed标志为false)
            //      1   成功保存
            nRet = sessioninfo.SaveLoginReaderDom(
                out strError);
            if (nRet == -1)
            {
                goto ERROR1;
            }
            if (nRet == -2)
            {
                if (nRedoCount < 5)
                {
                    nRedoCount++;
                    sessioninfo.ReaderInfo.ReaderDom = null;   // 强迫重新读入
                    goto REDO;
                }
                goto ERROR1;
            }
            return;

ERROR1:
            this.SetDebugInfo("errorinfo", strError);
        }
示例#10
0
        // TODO: 检查boxtype
        // 装入一个信箱的信息
        public int LoadBox(
            string strUserID,
            string strBoxType,
            out string strError)
        {
            strError = "";

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

            // 首先默认控件的当前信箱
            if (String.IsNullOrEmpty(strBoxType) == true)
            {
                strBoxType = this.CurrentBoxType;
            }

            // 若还是空, 则默认INBOX
            if (String.IsNullOrEmpty(strBoxType) == true)
            {
                strBoxType = BoxesInfo.INBOX;
            }

            string strResultSetName = "messagelist_" + strBoxType;

            LibraryChannel channel = sessioninfo.GetChannel(true);

            try
            {
                int           nTotalCount = 0;
                MessageData[] messages    = null;
                long          nRet        = // sessioninfo.Channel.
                                            channel.ListMessage(
                    "search",               // true,
                    strResultSetName,
                    strBoxType,
                    MessageLevel.Summary,
                    0,
                    0,
                    out nTotalCount,
                    out messages,
                    out strError);
                if (nRet == -1)
                {
                    return(-1);
                }

                this.ResultSetName  = strResultSetName;
                this.ResultCount    = nTotalCount;
                this.CurrentBoxType = strBoxType;
                return(0);
            }
            finally
            {
                sessioninfo.ReturnChannel(channel);
            }
        }
示例#11
0
        // 获得历史信息
        // parameters:
        //      nStart  开始位置。如果为 -1,表示仅获得事项总数
        // return:
        //      -2  尚未登录
        //      -1  出错
        //      其它  符合条件的事项总数
        int GetChargingHistory(int nPageNo,
                               int nItemsPerPage,
                               out List <ChargingItemWrapper> results,
                               out string strError)
        {
            strError = "";
            results  = null;

            // 获得读者证条码号
            string strReaderBarcode = "";
            {
                // return:
                //      -1  出错
                //      0   成功
                //      1   尚未登录
                int nRet = this.LoadReaderXml(out strError);
                if (nRet == -1)
                {
                    return(0);
                }
                if (nRet == 1)
                {
                    return(-2);
                }
                strReaderBarcode = DomUtil.GetElementText(ReaderDom.DocumentElement, "barcode");
            }

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

            LibraryChannel channel = sessioninfo.GetChannel(true);

            try
            {
                // 获得借阅历史
                // parameters:
                //      nPageNo 页号
                //      nItemsPerPage    每页的事项个数。如果为 -1,表示希望从头获取全部内容
                // return:
                //      -1  出错
                //      其它  符合条件的事项总数
                return((int)//sessioninfo.Channel.
                       channel.LoadChargingHistory(
                           null,
                           strReaderBarcode,
                           "return,lost,read",
                           nPageNo,
                           nItemsPerPage,
                           out results,
                           out strError));
            }
            finally
            {
                sessioninfo.ReturnChannel(channel);
            }
        }
示例#12
0
        // 选定风格
        // return:
        //      -1  error
        //      0   succeed
        int SelectStyle(string strDirName,
                        out string strError)
        {
            strError = "";

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

            if (app == null)
            {
                strError = "app == null";
                goto ERROR1;
            }
            SessionInfo sessioninfo = (SessionInfo)this.Page.Session["sessioninfo"];

            if (sessioninfo == null)
            {
                strError = "sessioninfo == null";
                goto ERROR1;
            }

            XmlDocument readerdom = null;
            // 获得当前session中已经登录的读者记录DOM
            // return:
            //      -2  当前登录的用户不是reader类型
            //      -1  出错
            //      0   尚未登录
            //      1   成功
            int nRet = sessioninfo.GetLoginReaderDom(
                out readerdom,
                out strError);

            if (nRet == -1 || nRet == -2)
            {
                goto ERROR1;
            }

            if (nRet == 0)
            {
                return(-1);
            }

            SetReaderSelectedStyleDir(ref readerdom,
                                      strDirName);
            sessioninfo.SetLoginReaderDomChanged();

            return(0);

ERROR1:
            return(-1);
        }
示例#13
0
        protected override void Render(HtmlTextWriter writer)
        {
            OpacApplication app         = (OpacApplication)this.Page.Application["app"];
            SessionInfo     sessioninfo = (SessionInfo)this.Page.Session["sessioninfo"];

            string strMode;

            if (String.IsNullOrEmpty(this.Mode) == true)
            {
                strMode = this.Mode;
            }
            else
            {
                strMode = this.Mode;
            }

            PlaceHolder endinfoline = (PlaceHolder)this.FindControl("endinfoline");
            PlaceHolder edit        = (PlaceHolder)this.FindControl("edit");

            if (strMode == "end")
            {
                endinfoline.Visible = true;
                edit.Visible        = false;
            }
            else
            {
                endinfoline.Visible = false;
                edit.Visible        = true;
            }

            LiteralControl infotext = (LiteralControl)this.FindControl("infotext");

            if (String.IsNullOrEmpty(this.BoxName) == true)
            {
                // text-level: 界面提示
                infotext.Text = this.GetString("新消息");
            }
            else
            {
                // text-level: 界面提示
                infotext.Text =
                    string.Format(this.GetString("来自s"),                // "来自 {0}"
                                  app.BoxesInfo.GetString(this.BoxName) // 将信箱名类型转换为当前语言的信箱名字符串
                                  );
                // "来自 " + this.BoxName;
            }

            base.Render(writer);
        }
示例#14
0
        // return:
        //      null    xml文件不存在,或者<borrowInfoControl>元素不存在
        static string GetColumnStyle(OpacApplication app)
        {
            if (app == null || app.WebUiDom == null)
            {
                return(null);
            }

            XmlNode node = app.WebUiDom.DocumentElement.SelectSingleNode("borrowInfoControl");

            if (node == null)
            {
                return(null);
            }

            return(DomUtil.GetAttr(node, "columnStyle"));
        }
示例#15
0
        // TODO: 以后白名单里面可以配置更大的数量

        protected void Session_Start(Object sender, EventArgs e)
        {
            OpacApplication app = null;

            try
            {
                app = (OpacApplication)Application["app"];

                if (app == null)
                {
                    throw new Exception("app == null while Session_Start(). global error info : " + (string)Application["errorinfo"]);
                }

                string strClientIP = HttpContext.Current.Request.UserHostAddress;
                // 增量计数
                if (app != null)
                {
                    long v = app.IpTable.IncIpCount(strClientIP, 1);
                    if (v >= app.IpTable.MAX_SESSIONS_PER_IP)
                    {
                        app.IpTable.IncIpCount(strClientIP, -1);
                        Session.Abandon();
                        return;
                    }
                }

                SessionInfo sessioninfo = new SessionInfo(app);
                sessioninfo.ClientIP   = strClientIP;
                Session["sessioninfo"] = sessioninfo;
                // throw new Exception("test exception");

                app.IncSesstionCounter(Request.UserHostAddress);
            }
            catch (Exception ex)
            {
                string strErrorText = "Session_Start阶段出现异常: " + ExceptionUtil.GetDebugText(ex);
                OpacApplication.WriteWindowsLog(strErrorText);
                if (app != null)
                {
                    app.GlobalErrorInfo = strErrorText;
                }
                else
                {
                    Application["errorinfo"] = strErrorText;
                }
            }
        }
示例#16
0
        // 重新检索结果集
        public void RefreshList()
        {
            OpacApplication app         = (OpacApplication)this.Page.Application["app"];
            SessionInfo     sessioninfo = (SessionInfo)this.Page.Session["sessioninfo"];

            string strError    = "";
            int    nTotalCount = 0;

            MessageData[] messages = null;
            if (String.IsNullOrEmpty(this.UserID) == true)
            {
                // text-level: 内部错误
                throw new Exception("UserID为空");
            }

            LibraryChannel channel = sessioninfo.GetChannel(true);

            try
            {
                // 重新发起检索,但暂不获取
                long nRet =   // sessioninfo.Channel.
                            channel.ListMessage(
                    "search", // true,
                    this.ResultSetName,
                    this.CurrentBoxType,
                    MessageLevel.Summary,
                    0,
                    0,
                    out nTotalCount,
                    out messages,
                    out strError);
                if (nRet == -1)
                {
                    // text-level: 内部错误
                    this.SetDebugInfo("errorinfo", "刷新时检索失败: " + strError);
                }
                else
                {
                    this.ResultCount = nTotalCount;
                }
            }
            finally
            {
                sessioninfo.ReturnChannel(channel);
            }
        }
示例#17
0
        protected void Session_End(Object sender, EventArgs e)
        {
            SessionInfo sessioninfo = (SessionInfo)Session["sessioninfo"];

            Session["sessioninfo"] = null;

            if (sessioninfo != null)
            {
                sessioninfo.CloseSession();

                // 减去计数
                // string strClientIP = HttpContext.Current.Request.UserHostAddress.ToString();
                OpacApplication app = (OpacApplication)Application["app"];
                if (app != null)
                {
                    app.IpTable.IncIpCount(sessioninfo.ClientIP, -1);
                }
            }
        }
示例#18
0
        protected override void Render(HtmlTextWriter output)
        {
            //int nRet = 0;
            //string strError = "";

            LoginState loginstate = GlobalUtil.GetLoginState(this.Page);

            if (loginstate == LoginState.NotLogin)
            {
                SetInfo("尚未登录, 不能创建荐购书目记录。<a href='login.aspx?redirect=newrecommend.aspx'>登录</a>");
            }
            if (loginstate == LoginState.Public)
            {
                SetInfo("访客身份, 不能创建荐购书目记录。<a href='login.aspx?redirect=newrecommend.aspx'>登录</a>");
            }

            PlaceHolder edit_holder = (PlaceHolder)this.FindControl("edit_holder");

            if (loginstate == LoginState.Public || loginstate == LoginState.NotLogin)
            {
                edit_holder.Visible = false;
                base.Render(output);
                return;
            }
            else
            {
                edit_holder.Visible = true;
            }
#if NO
            OpacApplication app         = (OpacApplication)this.Page.Application["app"];
            SessionInfo     sessioninfo = (SessionInfo)this.Page.Session["sessioninfo"];

            if (sessioninfo.Account != null)
            {
                TextBox edit_creator = (TextBox)this.FindControl("edit_creator");
                edit_creator.Text = sessioninfo.Account.UserID;
            }
#endif

            base.Render(output);
        }
示例#19
0
        void linkbutton_Click(object sender, EventArgs e)
        {
            OpacApplication app = (OpacApplication)this.Page.Application["app"];

            LinkButton button     = (LinkButton)sender;
            string     strBoxName = button.ID;

            // TODO: 需要将按钮上的文字名替换为boxtype值
            string strBoxType = app.BoxesInfo.GetBoxType(strBoxName);

            if (String.IsNullOrEmpty(strBoxType) == false)
            {
                this.Page.Response.Redirect("./mymessage.aspx?box=" + HttpUtility.UrlEncode(strBoxType));
                this.Page.Response.End();
            }
            else
            {
                this.Page.Response.Write("信箱名 '" + strBoxName + "' 无法转换为信箱类型字符串");
                this.Page.Response.End();
            }
        }
示例#20
0
        protected override void CreateChildControls()
        {
            OpacApplication app         = (OpacApplication)this.Page.Application["app"];
            SessionInfo     sessioninfo = (SessionInfo)this.Page.Session["sessioninfo"];

            HiddenField resultsetname = new HiddenField();

            resultsetname.ID = "resultsetname";
            this.Controls.Add(resultsetname);

            Panel title = new Panel();

            title.ID = "title";
            this.Controls.Add(title);

            LiteralControl titletext = new LiteralControl();

            titletext.Text = this.GetString("分面导航");
            title.Controls.Add(titletext);

            Panel progressbar = new Panel();

            progressbar.ID = "progressbar";
            this.Controls.Add(progressbar);

            HiddenField selected_node = new HiddenField();

            selected_node.ID = "selected-data";
            this.Controls.Add(selected_node);

            Button button = new Button();

            button.ID       = "button";
            button.CssClass = "treebutton hidden";
            button.Click   += new EventHandler(button_Click);
            this.Controls.Add(button);
        }
示例#21
0
        // return:
        //      -1  出错
        //      0   成功
        //      1   尚未登录
        public int LoadReaderXml(out string strError)
        {
            strError = "";

            app = (OpacApplication)this.Page.Application["app"];
            if (app == null)
            {
                strError = "app == null";
                goto ERROR1;
            }
            sessioninfo = (SessionInfo)this.Page.Session["sessioninfo"];
            if (sessioninfo == null)
            {
                strError = "sessioninfo == null";
                goto ERROR1;
            }

            if (String.IsNullOrEmpty(sessioninfo.UserID) == true)
            {
                return(1);
            }

            XmlDocument readerdom = null;
            // 获得当前session中已经登录的读者记录DOM
            // return:
            //      -2  当前登录的用户不是reader类型
            //      -1  出错
            //      0   尚未登录
            //      1   成功
            int nRet = sessioninfo.GetLoginReaderDom(
                out readerdom,
                out strError);

            if (nRet == -1)
            {
                goto ERROR1;
            }

            if (nRet == 0)
            {
                return(1);
            }

            if (nRet == -2)
            {
                if (String.IsNullOrEmpty(this.ReaderBarcode) == true)
                {
                    strError = "当前登录的用户不是reader类型,并且ReaderInfoBase.ReaderBarcode也为空";
                    goto ERROR1;
                }

                // TODO: 是否进一步判断Type
                // if (sessioninfo.Account.Type != "worreader")

                // 管理员获得特定证条码号的读者记录DOM
                // return:
                //      -2  当前登录的用户不是librarian类型
                //      -1  出错
                //      0   尚未登录
                //      1   成功
                nRet = sessioninfo.GetOtherReaderDom(
                    this.ReaderBarcode,
                    out readerdom,
                    out strError);
                if (nRet == -1 || nRet == -2)
                {
                    goto ERROR1;
                }

                if (nRet == 0)
                {
                    return(1);
                }
            }

            this.ReaderDom = readerdom;

            return(0);

ERROR1:
            return(-1);
        }
示例#22
0
        protected override void Render(HtmlTextWriter output)
        {
            int    nRet     = 0;
            string strError = "";

            // return:
            //      -1  出错
            //      0   成功
            //      1   尚未登录
            nRet = this.LoadReaderXml(out strError);
            if (nRet == -1)
            {
                goto ERROR1;
            }

            if (nRet == 1)
            {
                sessioninfo.LoginCallStack.Push(this.Page.Request.RawUrl);
                this.Page.Response.Redirect("login.aspx", true);
                return;
            }

            LiteralControl text       = null;
            string         strBarcode = DomUtil.GetElementText(ReaderDom.DocumentElement,
                                                               "barcode");

            // 显示名
            string strDisplayName = DomUtil.GetElementText(ReaderDom.DocumentElement,
                                                           "displayName");
            TextBox edit = (TextBox)this.FindControl("displayName");

            edit.Text = strDisplayName;

#if NO
            OpacApplication app = (OpacApplication)this.Page.Application["app"];

            if (string.IsNullOrEmpty(strBarcode) == false)
            {
                // 读者证号二维码
                string strCode = "";
                // 获得读者证号二维码字符串
                nRet = app.GetPatronTempId(
                    strBarcode,
                    out strCode,
                    out strError);
                if (nRet == -1)
                {
                    strCode = strError;
                }
                text      = (LiteralControl)this.FindControl("qrcode");
                text.Text = strCode;
            }
#endif
            text = (LiteralControl)this.FindControl("qrcode");
            if (text != null)
            {
                text.Text = "<img src='./getphoto.aspx?action=pqri&barcode=" + HttpUtility.UrlEncode(strBarcode) + "' alt='QRCode image'></img>";
            }

            // 姓名
            string strName = DomUtil.GetElementText(ReaderDom.DocumentElement,
                                                    "name");
            text      = (LiteralControl)this.FindControl("name");
            text.Text = strName;

            // 性别
            string strGender = DomUtil.GetElementText(ReaderDom.DocumentElement,
                                                      "gender");
            text      = (LiteralControl)this.FindControl("gender");
            text.Text = strGender;

            // 出生日期
            string strDateOfBirth = DomUtil.GetElementText(ReaderDom.DocumentElement,
                                                           "dateOfBirth");
            if (string.IsNullOrEmpty(strDateOfBirth) == true)
            {
                strDateOfBirth = DomUtil.GetElementText(ReaderDom.DocumentElement,
                                                        "birthday");
            }

            strDateOfBirth = DateTimeUtil.LocalDate(strDateOfBirth);
            text           = (LiteralControl)this.FindControl("dateOfBirth");
            text.Text      = strDateOfBirth;

            // 证号 2008/11/11
            string strCardNumber = DomUtil.GetElementText(ReaderDom.DocumentElement,
                                                          "cardNumber");
            if (String.IsNullOrEmpty(strCardNumber) == true)
            {
                PlaceHolder holder = (PlaceHolder)this.FindControl("cardNumber_holder");
                holder.Visible = false;
            }
            else
            {
                text      = (LiteralControl)this.FindControl("cardNumber");
                text.Text = strCardNumber;
            }

            // 身份证号
            string strIdCardNumber = DomUtil.GetElementText(ReaderDom.DocumentElement,
                                                            "idCardNumber");
            text      = (LiteralControl)this.FindControl("idCardNumber");
            text.Text = strIdCardNumber;

            // 单位
            string strDepartment = DomUtil.GetElementText(ReaderDom.DocumentElement,
                                                          "department");
            text      = (LiteralControl)this.FindControl("department");
            text.Text = strDepartment;

            // 职务
            string strPost = DomUtil.GetElementText(ReaderDom.DocumentElement,
                                                    "post");
            text      = (LiteralControl)this.FindControl("post");
            text.Text = strPost;

            // 地址
            string strAddress = DomUtil.GetElementText(ReaderDom.DocumentElement,
                                                       "address");
            text      = (LiteralControl)this.FindControl("address");
            text.Text = strAddress;

            // 电话
            string strTel = DomUtil.GetElementText(ReaderDom.DocumentElement,
                                                   "tel");
            text      = (LiteralControl)this.FindControl("tel");
            text.Text = strTel;

            // email
            string strEmail = DomUtil.GetElementText(ReaderDom.DocumentElement,
                                                     "email");
            text      = (LiteralControl)this.FindControl("email");
            text.Text = strEmail;

            // 证条码号

            text      = (LiteralControl)this.FindControl("barcode");
            text.Text = strBarcode;

            // 读者类型
            string strReaderType = DomUtil.GetElementText(ReaderDom.DocumentElement,
                                                          "readerType");
            text      = (LiteralControl)this.FindControl("readerType");
            text.Text = strReaderType;

            // 证状态
            string strState = DomUtil.GetElementText(ReaderDom.DocumentElement,
                                                     "state");
            text      = (LiteralControl)this.FindControl("state");
            text.Text = strState;

            // 发证日期
            string strCreateDate = DomUtil.GetElementText(ReaderDom.DocumentElement,
                                                          "createDate");
            strCreateDate = DateTimeUtil.LocalDate(strCreateDate);
            text          = (LiteralControl)this.FindControl("createDate");
            text.Text     = strCreateDate;

            // 证失效期
            string strExpireDate = DomUtil.GetElementText(ReaderDom.DocumentElement,
                                                          "expireDate");
            strExpireDate = DateTimeUtil.LocalDate(strExpireDate);
            text          = (LiteralControl)this.FindControl("expireDate");
            text.Text     = strExpireDate;

            // 租金 2008/11/11
            string  strHireExpireDate = "";
            string  strHirePeriod     = "";
            XmlNode nodeHire          = ReaderDom.DocumentElement.SelectSingleNode("hire");
            if (nodeHire != null)
            {
                strHireExpireDate = DomUtil.GetAttr(nodeHire, "expireDate");
                strHirePeriod     = DomUtil.GetAttr(nodeHire, "period");

                strHireExpireDate = DateTimeUtil.LocalDate(strHireExpireDate);
                strHirePeriod     = app.GetDisplayTimePeriodStringEx(strHirePeriod);


                text      = (LiteralControl)this.FindControl("hire");
                text.Text = this.GetString("周期")
                            + ": " + strHirePeriod + "; "
                            + this.GetString("失效期")
                            + ": " + strHireExpireDate;
            }
            else
            {
                PlaceHolder holder = (PlaceHolder)this.FindControl("hire_holder");
                holder.Visible = false;
            }

            // 押金 2008/11/11
            string strForegift = DomUtil.GetElementText(ReaderDom.DocumentElement,
                                                        "foregift");
            if (String.IsNullOrEmpty(strForegift) == false)
            {
                text      = (LiteralControl)this.FindControl("foregift");
                text.Text = strForegift;
            }
            else
            {
                PlaceHolder holder = (PlaceHolder)this.FindControl("foregift_holder");
                holder.Visible = false;
            }

            Image photo = (Image)this.FindControl("photo");
            photo.ImageUrl = "./getphoto.aspx?barcode=" + strBarcode;

            LoginState loginstate = GlobalUtil.GetLoginState(this.Page);

            Button      submit_button       = (Button)this.FindControl("submit");
            PlaceHolder upload_photo_holder = (PlaceHolder)this.FindControl("upload_photo_holder");


            if (loginstate == LoginState.Reader &&
                sessioninfo.ReaderInfo.Barcode == strBarcode)
            {
                submit_button.Visible       = true;
                upload_photo_holder.Visible = true;
            }
            else
            {
                submit_button.Visible       = false;
                upload_photo_holder.Visible = false;
            }

            base.Render(output);
            return;

ERROR1:
            this.SetDebugInfo("errorinfo", strError);
        }
示例#23
0
    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;
         * }
         * */
        if (sessioninfo.UserID == "")
        {
            sessioninfo.UserID   = "public";
            sessioninfo.IsReader = false;
        }

        string strError = "";
        int    nRet     = 0;
        // string strAction = Request.QueryString["action"];
        string strURI           = Request.QueryString["uri"];
        string strStyle         = Request.QueryString["style"];
        string strBiblioRecPath = Request.QueryString["biblioRecPath"];

        LibraryChannel channel = null;

#if CHANNEL_POOL
        channel = sessioninfo.GetChannel(true /*, sessioninfo.Parameters*/);
#else
        channel = sessioninfo.GetChannel(false);
#endif
        try
        {
            Uri uri = GetUri(strURI);
            if (uri != null &&
                (uri.Scheme == "http" || uri.Scheme == "https"))
            {
                // 以下是处理 dp2 系统外部的 URL
                if (StringUtil.IsInList("hitcount", strStyle) == true)
                {
#if NO
                    if (app.SearchLog != null)
                    {
                        long lHitCount = app.SearchLog.GetHitCount(strURI);
                        OpacApplication.OutputImage(this,
                                                    Color.FromArgb(200, Color.Blue),
                                                    lHitCount.ToString());
                        this.Response.End();
                        return;
                    }
                    OpacApplication.OutputImage(this,
                                                Color.FromArgb(200, Color.Blue),
                                                "*"); // 星号表示尚未启用外部链接计数功能
                    this.Response.End();
#endif
                    int    nFontSize   = 8;
                    string strFontSize = Request.QueryString["fontSize"];
                    if (string.IsNullOrEmpty(strFontSize) == false)
                    {
                        Int32.TryParse(strFontSize, out nFontSize);
                    }

                    if (StringUtil.IsInList("hitcount", app.SearchLogEnable) == false)
                    {
                        OpacApplication.OutputImage(this,
                                                    Color.FromArgb(200, Color.Blue),
                                                    "*",
                                                    nFontSize); // 星号表示尚未启用外部链接计数功能
                        this.Response.End();
                        return;
                    }
                    // TODO: 这里可以优化一下,当 lValue == -1 的时候,可以为 App 设置一个标志,以后就不再为外部 URL 请求 dp2library 的 HitCounver() API 了
                    string strText = "";
                    long   lValue  = 0;
                    long   lRet    = app.GetHitCount(channel,
                                                     strBiblioRecPath + "|" + strURI,
                                                     out lValue,
                                                     out strError);
                    if (lRet == -1)
                    {
                        strText = strError;
                    }
                    else
                    {
                        strText = (lValue == -1 ? "*" : lValue.ToString());    // * 表示 dp2library 中 mongodb 没有启用
                    }
                    OpacApplication.OutputImage(this,
                                                Color.FromArgb(200, Color.Blue),
                                                strText,
                                                nFontSize);

                    // 不但返回图像,而且滞后增量一次
                    if (StringUtil.IsInList("inc", strStyle) == true)
                    {
                        lRet = app.IncHitCount(channel,
                                               strBiblioRecPath + "|" + strURI,
                                               this.Request.UserHostAddress,
                                               false, // 是否要创建日志
                                               out strError);
                        if (lRet == -1)
                        {
                            Response.Write("IncHitCount 出错: " + strError);
                            this.Response.End();
                            return;
                        }
                    }

                    this.Response.End();
                    return;
                }


                else
                {
#if NO
                    if (app.SearchLog != null)
                    {
                        app.SearchLog.IncHitCount(strURI);
                    }
#endif
                    if (StringUtil.IsInList("hitcount", app.SearchLogEnable) == false)
                    {
                        this.Response.Redirect(strURI, true);
                        return;
                    }
                    long lRet = app.IncHitCount(channel,
                                                strBiblioRecPath + "|" + strURI,
                                                this.Request.UserHostAddress,
                                                StringUtil.IsInList("log", app.SearchLogEnable), // 是否要创建日志
                                                out strError);
                    if (lRet == -1)
                    {
                        Response.Write("IncHitCount 出错: " + strError);
                        this.Response.End();
                    }
                    else
                    {
                        this.Response.Redirect(strURI, true);
                    }
                    return;
                }
            }

            // *** 以下是处理 dp2 系统内部对象
            // TODO: dp2 系统内部对象总是有访问计数功能的,是否需要设计为 SearchLogEnable 中的 hitcount 具备与否对它无影响?

            string strSaveAs = Request.QueryString["saveas"];
            bool   bSaveAs   = false;
            if (strSaveAs == "true")
            {
                bSaveAs = true;
            }

            // FlushOutput flushdelegate = new FlushOutput(MyFlushOutput);

            // this.Response.BufferOutput = false;
            this.Server.ScriptTimeout = 10 * 60 * 60;    // 10 个小时

            nRet = app.DownloadObject(
                this,
                // flushdelegate,
                // sessioninfo.Channels,
                channel,
                strURI,
                bSaveAs,
                strStyle,
                out strError);
            if (nRet == -1)
            {
                // Response.Write(strError);
                OpacApplication.OutputImage(Page,
                                            Color.FromArgb(200, Color.DarkRed),
                                            strError);
            }

            Response.End();
            return;
        }
        finally
        {
#if CHANNEL_POOL
            sessioninfo.ReturnChannel(channel);
#endif
        }
    }
示例#24
0
    protected void Page_Load(object sender, EventArgs e)
    {
        this.BiblioSearchControl1.Location = this.TitleBarControl1.SelectedLibraryCode;

        if (WebUtil.PrepareEnvironment(this,
                                       ref app,
                                       ref sessioninfo) == false)
        {
            return;
        }

        string strSideBarFile = Server.MapPath("./search_sidebar.xml");

        if (File.Exists(strSideBarFile) == true)
        {
            this.SideBarControl1.CfgFile = strSideBarFile;
        }
        else
        {
            this.SideBarControl1.Visible = false;
        }

        SetSideBarVisible();

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

        if (this.BrowseSearchResultControl1.ResultCount > 0)
        {
            this.BrowseSearchResultControl1.Visible = true;
#if FILTER
            VisibleFilter(true);
#endif
        }

        // 是否登录?
        if (sessioninfo.UserID == "")
        {
            if (this.Page.Request["forcelogin"] == "on")
            {
                sessioninfo.LoginCallStack.Push(Request.RawUrl);
                Response.Redirect("login.aspx", true);
                return;
            }
            if (this.Page.Request["forcelogin"] == "userid")
            {
                sessioninfo.LoginCallStack.Push(Request.RawUrl);
                Response.Redirect("login.aspx?loginstyle=librarian", true);
                return;
            }
            sessioninfo.UserID   = "public";
            sessioninfo.IsReader = false;

            /*
             * sessioninfo.LoginCallStack.Push(Request.RawUrl);
             * Response.Redirect("login.aspx", true);
             * return;
             * */
        }

        string strError = "";
        int    nRet     = 0;

#if NO
        string strAction = this.Request["action"];
        if (strAction == "getdblist")
        {
            DoGetDbNameList();
            return;
        }
#endif

        // 如果有参数
        string strWord = this.Request["word"];
        if (String.IsNullOrEmpty(strWord) == false &&
            this.IsPostBack == false)
        {
            string strXml = "";

            // string strWord = "";
            string strDbName     = "";
            string strFrom       = "";
            string strMatchStyle = "";

            GetSearchParams(out strWord,
                            out strDbName,
                            out strFrom,
                            out strMatchStyle);

            // 根据检索参数创建XML检索式
            nRet = OpacApplication.BuildQueryXml(
                this.app,
                strDbName,     // this.Request["dbname"],
                strWord,
                strFrom,       // this.Request["from"],
                strMatchStyle, // this.Request["matchstyle"],
                null,
                null,
                app.SearchMaxResultCount,
                this.BiblioSearchControl1.SearchStyle, // strSearchStyle
                out strXml,
                out strError);
            if (nRet == -1)
            {
                goto ERROR1;
            }

            string strResultSetNamePrefix = "";

            strResultSetNamePrefix = this.Request["resultsetname"];
            if (String.IsNullOrEmpty(strResultSetNamePrefix) == true)
            {
                strResultSetNamePrefix = Session.SessionID + "_opac_1";
            }
            else
            {
                strResultSetNamePrefix = Session.SessionID + "_" + strResultSetNamePrefix;
            }

            string strResultSetName = GetResultSetName(strResultSetNamePrefix);

            LibraryChannel channel = sessioninfo.GetChannel(true);
            //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;
                }
#if FILTER
                app.SetFilterTask(strResultSetName, null);
#endif

                if (app.SearchLog != null)
                {
                    SearchLogItem log = new SearchLogItem();
                    log.IP    = this.Request.UserHostAddress.ToString();
                    log.Query = SearchLog.BuildLogQueryString(
                        this.Request["dbname"],
                        strWord,
                        this.Request["from"],
                        this.Request["matchstyle"]);
                    log.Time     = DateTime.UtcNow;
                    log.HitCount = nRet;
                    log.Format   = "searchcount";
                    app.SearchLog.AddLogItem(log);
                }

                // not found
                if (lRet == 0)
                {
                    this.BrowseSearchResultControl1.Visible = false;
#if FILTER
                    this.filter.Visible = false;
#endif
                    strError = "没有找到";
                    goto ERROR1;
                }

                this.BrowseSearchResultControl1.Clear();
                this.BrowseSearchResultControl1.Visible = true;
#if FILTER
                VisibleFilter(true);
#endif

                this.BrowseSearchResultControl1.ResultSetName = strResultSetName;
                this.BrowseSearchResultControl1.ResultCount   = (int)lRet;
                this.BrowseSearchResultControl1.StartIndex    = 0; // 2008/12/15

#if FILTER
                this.filter.ResultSetName = strResultSetName;
#endif

                string strFormat = this.Request["format"];
                if (String.IsNullOrEmpty(strFormat) == false)
                {
                    this.BrowseSearchResultControl1.FormatName = strFormat;
                }
                return;
            }
            finally
            {
                // sessioninfo.Channel.
                channel.Idle -= new IdleEventHandler(channel_Idle);
                sessioninfo.ReturnChannel(channel);
            }
        }

        // 观察特定的结果集
        if (this.IsPostBack == false)
        {
            string strResultSet     = this.Request["resultset"];
            string strBaseResultSet = this.Request["base"];
            string strTitle         = this.Request["title"];
            if (string.IsNullOrEmpty(strResultSet) == false)
            {
                string strResultsetFilename = PathUtil.MergePath(app.TempDir,   // sessioninfo.GetTempDir(), // ??
                                                                 strResultSet);
                if (File.Exists(strResultsetFilename) == true)
                {
                    long lHitCount = CacheBuilder.GetCount(app, strResultsetFilename, true);

                    this.BrowseSearchResultControl1.ResultsetFilename = strResultsetFilename;

                    this.BrowseSearchResultControl1.Visible = true;
#if FILTER
                    VisibleFilter(true);

                    this.filter.ResultSetName = strBaseResultSet;
#endif

                    string strOffset = this.Request["offset"];
                    this.BrowseSearchResultControl1.ResultsetOffset = strOffset;

#if FILTER
                    this.filter.SelectedNodePath = MakeSelectedPath(strResultSet, strOffset);
#endif
                    if (string.IsNullOrEmpty(strOffset) == false)
                    {
                        int nStart  = 0;
                        int nLength = -1;
                        BrowseSearchResultControl.ParseOffsetString(strOffset,
                                                                    out nStart,
                                                                    out nLength);
                        if (nLength == -1)
                        {
                            nLength = (int)lHitCount - nStart;
                        }
                        this.BrowseSearchResultControl1.ResultCount = nLength;
                    }
                    else
                    {
                        this.BrowseSearchResultControl1.ResultCount = (int)lHitCount;
                    }

                    if (string.IsNullOrEmpty(strTitle) == false)
                    {
                        this.BrowseSearchResultControl1.Title = strTitle;
                    }
                }
                else
                {
                    strError = "结果集文件 '" + strResultSet + "' 不存在";
                    goto ERROR1;
                }
            }
            else if (string.IsNullOrEmpty(strBaseResultSet) == false)
            {
                // 只用了base参数
                this.BrowseSearchResultControl1.Clear();
                this.BrowseSearchResultControl1.Visible = true;
#if FILTER
                VisibleFilter(true);
#endif

                this.BrowseSearchResultControl1.ResultSetName = strBaseResultSet;
                this.BrowseSearchResultControl1.ResultCount   = (int)MyWebPage.GetServerResultCount(sessioninfo, strBaseResultSet);
                this.BrowseSearchResultControl1.StartIndex    = 0;

#if FILTER
                this.filter.ResultSetName = strBaseResultSet;
#endif
            }
        }

        //this.AdvanceSearchControl1.Channels = sessioninfo.Channels;
        //this.AdvanceSearchControl1.ServerUrl = app.WsUrl;

        // this.HeadBarControl1.CurrentColumn = HeaderColumn.Search;
        return;

ERROR1:
        Response.Write(HttpUtility.HtmlEncode(strError));
        Response.End();
    }
示例#25
0
        void submit_button_Click(object sender, EventArgs e)
        {
            string strError = "";

            TextBox         textbox = (TextBox)this.FindControl("displayName");
            OpacApplication app     = (OpacApplication)this.Page.Application["app"];

            if (app == null)
            {
                strError = "app == null";
                goto ERROR1;
            }
            SessionInfo sessioninfo = (SessionInfo)this.Page.Session["sessioninfo"];

            if (sessioninfo == null)
            {
                strError = "sessioninfo == null";
                goto ERROR1;
            }

            int  nRedoCount   = 0;
            bool bUploadSaved = false;

REDO:
            XmlDocument readerdom = null;
            // 获得当前session中已经登录的读者记录DOM
            // return:
            //      -2  当前登录的用户不是reader类型
            //      -1  出错
            //      0   尚未登录
            //      1   成功
            int nRet = sessioninfo.GetLoginReaderDom(
                out readerdom,
                out strError);

            if (nRet == -1 || nRet == -2)
            {
                goto ERROR1;
            }

            if (nRet == 0)
            {
                goto ERROR1;
            }

            bool       bXmlRecordChanged = false;
            FileUpload upload            = (FileUpload)this.FindControl("upload");

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

            if (textbox.Text == strOldDisplayName &&
                upload.HasFile == false)
            {
                strError = "显示名没有发生修改并且也没有新上传头像,放弃保存";
                goto ERROR1;
            }

            if (strOldDisplayName != textbox.Text)
            {
                DomUtil.SetElementText(readerdom.DocumentElement,
                                       "displayName",
                                       textbox.Text);
                bXmlRecordChanged = true;
            }


            // 如果有上传头像
            if (upload.HasFile == true &&
                bUploadSaved == false)
            {
                XmlNamespaceManager nsmgr = new XmlNamespaceManager(new NameTable());
                nsmgr.AddNamespace("dprms", DpNs.dprms);

                // 全部<dprms:file>元素
                XmlNodeList nodes = sessioninfo.ReaderInfo.ReaderDom
                                    .DocumentElement.SelectNodes("//dprms:file[@usage='photo']", nsmgr);
                string strResTimeStamp = "";
                string strFileID       = "0";
                if (nodes.Count > 0)
                {
                    strFileID = DomUtil.GetAttr(nodes[0], "id");
                    if (String.IsNullOrEmpty(strFileID) == true)
                    {
                        strFileID = FindNewFileID(sessioninfo.ReaderInfo.ReaderDom);
                    }
                    strResTimeStamp = DomUtil.GetAttr(nodes[0], "__timestamp");
                }
                else
                {
                    strFileID = FindNewFileID(sessioninfo.ReaderInfo.ReaderDom);

                    XmlNode node = sessioninfo.ReaderInfo.ReaderDom.CreateElement(
                        "dprms:file", DpNs.dprms);
                    sessioninfo.ReaderInfo.ReaderDom.DocumentElement.AppendChild(node);

                    DomUtil.SetAttr(node, "id", strFileID);
                    DomUtil.SetAttr(node, "usage", "photo");
                    bXmlRecordChanged = true;
                }

                if (bXmlRecordChanged == true)
                {
                    sessioninfo.SetLoginReaderDomChanged();
                    // 先要保存一次XML记录,这样才有<dprms:file>元素,为上载资源作好准备
                    // return:
                    //      -2  时间戳冲突
                    //      -1  error
                    //      0   没有必要保存(changed标志为false)
                    //      1   成功保存
                    nRet = sessioninfo.SaveLoginReaderDom(
                        out strError);
                    if (nRet == -1)
                    {
                        goto ERROR1;
                    }
                    if (nRet == -2)
                    {
                        if (nRedoCount < 10)
                        {
                            nRedoCount++;
                            sessioninfo.ReaderInfo.ReaderDom = null;   // 强迫重新读入
                            goto REDO;
                        }
                        goto ERROR1;
                    }

                    bXmlRecordChanged = false;
                }


                // Stream stream = upload.FileContent;


                // 保存资源
                // 采用了代理帐户
                // return:
                //		-1	error
                //		0	发现上载的文件其实为空,不必保存了
                //		1	已经保存
                nRet = app.SaveUploadFile(
                    this.Page,
                    sessioninfo.ReaderInfo.ReaderDomPath,
                    strFileID,
                    strResTimeStamp,
                    upload.PostedFile,
                    64,
                    64,
                    out strError);
                if (nRet == -1)
                {
                    goto ERROR1;
                }

                bUploadSaved = true;

                sessioninfo.ReaderInfo.ReaderDom = null;    // 迫使重新装载
                // 因为上载后时间戳改变,需要重新获取
                nRet = sessioninfo.GetLoginReaderDom(
                    out readerdom,
                    out strError);
                if (nRet == -1 || nRet == -2)
                {
                    goto ERROR1;
                }
            }

            // 为显示名的修改而保存
            if (bXmlRecordChanged == true)
            {
                sessioninfo.SetLoginReaderDomChanged();


                // return:
                //      -2  时间戳冲突
                //      -1  error
                //      0   没有必要保存(changed标志为false)
                //      1   成功保存
                nRet = sessioninfo.SaveLoginReaderDom(
                    out strError);
                if (nRet == -1)
                {
                    goto ERROR1;
                }
                if (nRet == -2)
                {
                    if (nRedoCount < 10)
                    {
                        nRedoCount++;
                        sessioninfo.ReaderInfo.ReaderDom = null;   // 强迫重新读入
                        goto REDO;
                    }
                    goto ERROR1;
                }

                bXmlRecordChanged = false;
            }

            // 刷新显示
            return;

ERROR1:
            this.SetDebugInfo("errorinfo", strError);
        }
示例#26
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);
        }
示例#27
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);
            }
        }
示例#28
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(); // 刷新当前结果集显示
        }
示例#29
0
        // 设置结果集有关数量参数
        public void SetResultInfo()
        {
            OpacApplication app         = (OpacApplication)this.Page.Application["app"];
            SessionInfo     sessioninfo = (SessionInfo)this.Page.Session["sessioninfo"];

            LiteralControl messagelist_titletext = (LiteralControl)this.FindControl("messagelist_titletext");

            messagelist_titletext.Text = app.BoxesInfo.GetString(this.CurrentBoxType);

            int nPageNo = this.StartIndex / this.PageMaxLines;

            LiteralControl resultinfo = (LiteralControl)this.FindControl("info");

            if (this.ResultCount != 0)
            {
                // text-level: 界面提示
                resultinfo.Text =
                    string.Format(this.GetString("s内共有消息s条, 分s页显示, 当前为第s页"),
                                  // "{0} 内共有消息 {1} 条, 分 {2} 页显示, 当前为第 {3} 页。"
                                  app.BoxesInfo.GetString(this.CurrentBoxType),
                                  Convert.ToString(this.ResultCount),
                                  Convert.ToString(this.PageCount),
                                  Convert.ToString(nPageNo + 1));

                // this.BoxesInfo.GetString(this.CurrentBoxType) + " 内共有消息 " + Convert.ToString(this.ResultCount) + " 条, 分 " + Convert.ToString(this.PageCount) + " 页显示, 当前为第 " + Convert.ToString(nPageNo + 1) + "页。";
            }
            else
            {
                // text-level: 界面提示
                resultinfo.Text =
                    string.Format(this.GetString("s为空"),  // "('{0}' 为空)"
                                  app.BoxesInfo.GetString(this.CurrentBoxType));

                /*
                 * "('"
                 + this.BoxesInfo.GetString(this.CurrentBoxType)
                 + "' 为空)";
                 * */
            }

            LiteralControl maxpagecount = (LiteralControl)this.FindControl("maxpagecount");

            maxpagecount.Text =
                string.Format(this.GetString("maxpagecount"),   // (共 {0} 页)
                              Convert.ToString(this.PageCount));
            // " (共 " + Convert.ToString(this.PageCount) + " 页)";

            LiteralControl currentpageno = (LiteralControl)this.FindControl("currentpageno");

            currentpageno.Text = Convert.ToString(nPageNo + 1);

            PlaceHolder pageswitcher = (PlaceHolder)this.FindControl("pageswitcher");

            if (this.PageCount <= 1)
            {
                pageswitcher.Visible = false;
            }
            else
            {
                pageswitcher.Visible = true;
            }
        }
示例#30
0
        void CreateBoxListControls(PlaceHolder boxlist)
        {
            OpacApplication app         = (OpacApplication)this.Page.Application["app"];
            SessionInfo     sessioninfo = (SessionInfo)this.Page.Session["sessioninfo"];

            bool bDetectFullCount = true;   // 是否首次就探测所有信箱的未读数字

            LiteralControl literal = new LiteralControl();

            literal.Text = this.GetPrefixString(
                this.GetString("信箱"),
                "boxes_wrapper");
            literal.Text += "<table class='boxes'>"; //  width='100%' cellspacing='1' cellpadding='4'
            boxlist.Controls.Add(literal);

            LinkButton linkbutton = null;

            int nInboxUntouchedCount = 0;   // 收件箱中的未读信件数目

            LibraryChannel channel = sessioninfo.GetChannel(true);

            try
            {
                for (int i = 0; i < app.BoxesInfo.Boxes.Count; i++)
                {
                    Box box = app.BoxesInfo.Boxes[i];

                    string strClass = "box";

                    if (/*box.Name == this.CurrentBoxType*/
                        box.Type == this.CurrentBoxType)
                    {
                        strClass = "box active";
                    }

                    literal      = new LiteralControl();
                    literal.Text = "<tr class='" + strClass + "'><td class='" + strClass + "' nowrap>";
                    boxlist.Controls.Add(literal);

                    int nCount = 0;

                    if (bDetectFullCount == true)
                    {
                        nCount = // sessioninfo.Channel.
                                 channel.GetUntouchedMessageCount(
                            box.Name);
                        if (nCount != -1)
                        {
                            // untouchedcountlist[box.Name] = (object)nCount;
                        }

                        if (box.Type == BoxesInfo.INBOX)
                        {
                            nInboxUntouchedCount = nCount;
                        }
                    }


                    linkbutton    = new LinkButton();
                    linkbutton.ID = box.Name;
                    string strCaption = app.BoxesInfo.GetString(box.Type);   // 获得信箱对于当前语言的名字 2009/7/14 changed
                    if (nCount != 0)
                    {
                        linkbutton.Text = strCaption + "(" + Convert.ToString(nCount) + ")";
                    }
                    else
                    {
                        linkbutton.Text = strCaption;
                    }

                    linkbutton.Click += new EventHandler(linkbutton_Click);
                    boxlist.Controls.Add(linkbutton);

                    literal      = new LiteralControl();
                    literal.Text = "</td></tr>";
                    boxlist.Controls.Add(literal);
                }
            }
            finally
            {
                sessioninfo.ReturnChannel(channel);
            }

            // this.UntouchedCountList = untouchedcountlist;   // 更新内容

            literal      = new LiteralControl();
            literal.Text = "<tr class='cmd'><td class='newmessage'>";
            boxlist.Controls.Add(literal);

            Button newmessagebutton = new Button();

            newmessagebutton.ID       = "newmessage";
            newmessagebutton.Text     = this.GetString("撰写消息");
            newmessagebutton.CssClass = "newmessage";
            newmessagebutton.Click   += new EventHandler(newmessage_Click);
            boxlist.Controls.Add(newmessagebutton);

            literal      = new LiteralControl();
            literal.Text = "</td></tr>";
            boxlist.Controls.Add(literal);

            literal      = new LiteralControl();
            literal.Text = "</table>" + this.GetPostfixString();
            boxlist.Controls.Add(literal);
        }