// 选定风格 // 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); }
// 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); }
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); }
protected override void Render(HtmlTextWriter output) { 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; } 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) { sessioninfo.LoginCallStack.Push(this.Page.Request.RawUrl); this.Page.Response.Redirect("login.aspx", true); return; } string strReaderStyleDir = GetReaderSelectedStyleDir(readerdom); if (String.IsNullOrEmpty(strReaderStyleDir) == true) { strReaderStyleDir = "0"; } ImageButton imagebutton = (ImageButton)this.FindControl(strReaderStyleDir); if (imagebutton != null) { imagebutton.CssClass = "selected"; } base.Render(output); return; ERROR1: output.Write(strError); }
void submitTitleText_Click(object sender, EventArgs e) { string strError = ""; TextBox textbox = (TextBox)this.FindControl("titletext"); string strTitleText = textbox.Text; 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; 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; } this.SetReaderTitleText(ref readerdom, strTitleText); 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; } // this.SetDebugInfo("保存成功。"); // 刷新显示 return; ERROR1: this.SetDebugInfo("errorinfo", strError); }
void CreateTitleText() { 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; } 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) { sessioninfo.LoginCallStack.Push(this.Page.Request.RawUrl); this.Page.Response.Redirect("login.aspx", true); return; } string strTitleText = GetReaderTitleText(readerdom); /* * // 左侧文字 * LiteralControl literal = new LiteralControl(); * literal.Text = "<tr><td>"; * this.Controls.Add(literal); */ // 编辑控件 TextBox textbox = new TextBox(); textbox.ID = "titletext"; textbox.Text = strTitleText; this.Controls.Add(textbox); /* * // 右侧文字 * literal = new LiteralControl(); * literal.Text = "</td></tr>"; * this.Controls.Add(literal); * */ return; ERROR1: return; }
protected override void Render(HtmlTextWriter output) { 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; } 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) { sessioninfo.LoginCallStack.Push(this.Page.Request.RawUrl); this.Page.Response.Redirect("login.aspx", true); return; } if (nRet == -2) { if (String.IsNullOrEmpty(this.ReaderBarcode) == true) { // text-level: 内部错误 strError = "当前登录的用户不是reader类型,并且BorrowInfoControl.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) { sessioninfo.LoginCallStack.Push(this.Page.Request.RawUrl); this.Page.Response.Redirect("login.aspx?loginstyle=librarian", true); return; } } // 兑现 借阅信息 RenderBorrow(app, sessioninfo, readerdom); base.Render(output); return; ERROR1: output.Write(strError); }
string GetStyleDirName() { 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; } string strLibraryCodeList = ""; // 当前用户管辖的馆代码列表 #if NO if (sessioninfo.Channel != null) { strLibraryCodeList = sessioninfo.Channel.LibraryCodeList; } #endif strLibraryCodeList = sessioninfo.LibraryCodeList; // 面板上选择的馆代码 string strSelectedLibraryCode = (string)this.Page.Session["librarycode"]; string strLibraryStyleDir = ""; // 分馆的风格目录 if (string.IsNullOrEmpty(strSelectedLibraryCode) == false) { XmlNode nodeLibrary = app.WebUiDom.DocumentElement.SelectSingleNode("libraries/library[@code='" + strSelectedLibraryCode + "']"); if (nodeLibrary != null) { strLibraryStyleDir = DomUtil.GetAttr(nodeLibrary, "style"); if (string.IsNullOrEmpty(strLibraryStyleDir) == true) { strLibraryStyleDir = DomUtil.GetAttr(nodeLibrary, "code"); } } } // 2007/7/11 LoginState loginstate = GlobalUtil.GetLoginState(this.Page); XmlNode nodeUserType = null; if (loginstate == LoginState.NotLogin) { nodeUserType = app.WebUiDom.DocumentElement.SelectSingleNode( "titleBarControl/userType[@type='notlogin']"); } else if (loginstate == LoginState.Public) { nodeUserType = app.WebUiDom.DocumentElement.SelectSingleNode( "titleBarControl/userType[@type='public']"); } else if (loginstate == LoginState.Librarian) { nodeUserType = app.WebUiDom.DocumentElement.SelectSingleNode( "titleBarControl/userType[@type='librarian']"); } if (nodeUserType != null) { string strStyleDirName = DomUtil.GetAttr(nodeUserType, "style"); return(MakeDir(strLibraryStyleDir, strStyleDirName)); #if NO if (String.IsNullOrEmpty(strStyleDirName) == true) { return("0"); // 缺省值 } return(strStyleDirName); #endif } 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; } // return PreferenceControl.GetReaderSelectedStyleDir(readerdom); return(MakeDir(strLibraryStyleDir, PreferenceControl.GetReaderSelectedStyleDir(readerdom))); ERROR1: return("0"); }