private void CloseCommentColumn() { if (this.CommentColumn != null) { string strTemp1; string strTemp2; this.CommentColumn.Detach(out strTemp1, out strTemp2); this.CommentColumn = null; } }
// 装载栏目存储 private int LoadCommentColumn( string strStorageFileName, out string strError) { strError = ""; this.StorageFileName = strStorageFileName; try { if (this.CommentColumn == null) { this.CommentColumn = new ColumnStorage(); } else { // 2006/7/6 string strTemp1; string strTemp2; this.CommentColumn.Detach(out strTemp1, out strTemp2); this.CommentColumn = null; this.CommentColumn = new ColumnStorage(); } try { this.CommentColumn.Attach(strStorageFileName, strStorageFileName + ".index"); } catch (Exception ex) { strError = "Attach 文件 " + strStorageFileName + " 和索引失败 :" + ex.Message; return(-1); } return(0); } catch /*(System.ApplicationException ex)*/ { strError = "栏目暂时被锁定。请稍后再试。"; return(-1); } }
// 装载栏目存储 private int LoadCommentColumn( string strStorageFileName, out string strError) { strError = ""; this.StorageFileName = strStorageFileName; try { if (this.CommentColumn == null) this.CommentColumn = new ColumnStorage(); else { // 2006/7/6 string strTemp1; string strTemp2; this.CommentColumn.Detach(out strTemp1, out strTemp2); this.CommentColumn = null; this.CommentColumn = new ColumnStorage(); } try { this.CommentColumn.Attach(strStorageFileName, strStorageFileName + ".index"); } catch (Exception ex) { strError = "Attach 文件 " + strStorageFileName + " 和索引失败 :" + ex.Message; return -1; } return 0; } catch /*(System.ApplicationException ex)*/ { strError = "栏目暂时被锁定。请稍后再试。"; return -1; } }
// [外部调用] // 创建内存和物理存储对象 public int CreateCommentColumn( SessionInfo sessioninfo, System.Web.UI.Page page, out string strError) { this.m_lockCommentColumn.AcquireWriterLock(m_nCommentColumnLockTimeout); try { strError = ""; int nRet = 0; if (sessioninfo.Account == null || StringUtil.IsInList("managecache", sessioninfo.RightsOrigin) == false) { strError = "当前帐户不具备 managecache 权限,不能创建栏目缓存"; return -1; } this.CloseCommentColumn(); if (page != null && page.Response.IsClientConnected == false) // 灵敏中断 { strError = "中断"; return -1; } if (this.CommentColumn == null) this.CommentColumn = new ColumnStorage(); this.CommentColumn.ReadOnly = false; this.CommentColumn.m_strBigFileName = this.StorageFileName; this.CommentColumn.m_strSmallFileName = this.StorageFileName + ".index"; this.CommentColumn.Open(true); this.CommentColumn.Clear(); // 检索 nRet = SearchTopLevelArticles( sessioninfo, page, out strError); if (nRet == -1) return -1; // 排序 if (page != null) { page.Response.Write("--- begin sort ...<br/>"); page.Response.Flush(); } DateTime time = DateTime.Now; this.CommentColumn.Sort(); if (page != null) { TimeSpan delta = DateTime.Now - time; page.Response.Write("sort end. time=" + delta.ToString() + "<br/>"); page.Response.Flush(); } // 保存物理文件 string strTemp1; string strTemp2; this.CommentColumn.Detach(out strTemp1, out strTemp2); this.CommentColumn.ReadOnly = true; this.CloseCommentColumn(); // 重新装载 nRet = LoadCommentColumn( this.StorageFileName, out strError); if (nRet == -1) return -1; return 0; } finally { this.m_lockCommentColumn.ReleaseWriterLock(); } }
// [外部调用] // 创建内存和物理存储对象 public int CreateCommentColumn( SessionInfo sessioninfo, System.Web.UI.Page page, out string strError) { this.m_lockCommentColumn.AcquireWriterLock(m_nCommentColumnLockTimeout); try { strError = ""; int nRet = 0; if (sessioninfo.Account == null || StringUtil.IsInList("managecache", sessioninfo.RightsOrigin) == false) { strError = "当前帐户不具备 managecache 权限,不能创建栏目缓存"; return(-1); } this.CloseCommentColumn(); if (page != null && page.Response.IsClientConnected == false) // 灵敏中断 { strError = "中断"; return(-1); } if (this.CommentColumn == null) { this.CommentColumn = new ColumnStorage(); } this.CommentColumn.ReadOnly = false; this.CommentColumn.m_strBigFileName = this.StorageFileName; this.CommentColumn.m_strSmallFileName = this.StorageFileName + ".index"; this.CommentColumn.Open(true); this.CommentColumn.Clear(); // 检索 nRet = SearchTopLevelArticles( sessioninfo, page, out strError); if (nRet == -1) { return(-1); } // 排序 if (page != null) { page.Response.Write("--- begin sort ...<br/>"); page.Response.Flush(); } DateTime time = DateTime.Now; this.CommentColumn.Sort(); if (page != null) { TimeSpan delta = DateTime.Now - time; page.Response.Write("sort end. time=" + delta.ToString() + "<br/>"); page.Response.Flush(); } // 保存物理文件 string strTemp1; string strTemp2; this.CommentColumn.Detach(out strTemp1, out strTemp2); this.CommentColumn.ReadOnly = true; this.CloseCommentColumn(); // 重新装载 nRet = LoadCommentColumn( this.StorageFileName, out strError); if (nRet == -1) { return(-1); } return(0); } finally { this.m_lockCommentColumn.ReleaseWriterLock(); } }