public override IList<SearchDocument> GetModifiedSearchDocuments (ModuleInfo modInfo, DateTime beginDate) { var searchDocs = new List<SearchDocument> (); var settings = new EmployeeListSettings (modInfo); var employees = GetObjects<EmployeeInfo> (CommandType.StoredProcedure, (settings.IncludeSubdivisions) ? // which SP to use "University_GetRecursiveEmployeesByDivisionID" : "University_GetEmployeesByDivisionID", settings.DivisionID, settings.SortType, false ); foreach (var employee in employees) { if (employee.LastModifiedOnDate.ToUniversalTime () > beginDate.ToUniversalTime ()) { var aboutEmployee = employee.SearchDocumentText; var sd = new SearchDocument () { PortalId = modInfo.PortalID, AuthorUserId = employee.LastModifiedByUserID, Title = employee.FullName, // Description = HtmlUtils.Shorten (aboutEmployee, 255, "..."), Body = aboutEmployee, ModifiedTimeUtc = employee.LastModifiedOnDate.ToUniversalTime (), UniqueKey = string.Format ("University_Employee_{0}", employee.EmployeeID), Url = string.Format ("/Default.aspx?tabid={0}#{1}", modInfo.TabID, modInfo.ModuleID), IsActive = employee.IsPublished }; searchDocs.Add (sd); } } return searchDocs; }
protected override void Render (HtmlTextWriter writer) { if (!renderDisabled) { if (renderCacheContent == null) { // cache expired using (var stringWriter = new System.IO.StringWriter ()) using (var htmlWriter = new HtmlTextWriter (stringWriter)) { // render the current page content to our temp writer base.Render (htmlWriter); // htmlWriter.Flush(); htmlWriter.Close (); // get the content renderCacheContent = stringWriter.ToString (); } // NOTE: For testing purposes // renderCacheContent = string.Concat (renderCacheContent, "<p>" + DateTime.Now.ToShortTimeString () + "</p>"); // NOTE: Set render cache only in non-edit mode - this give editors // somethat increased performance and ensures that common users see only allowed content if (!IsEditable) { var settings = new EmployeeListSettings (this); CacheHelper.Set<string> (renderCacheContent, DataCacheKey, settings.DataCacheTime); } } // write the new html to the page writer.Write (renderCacheContent); } }
/// <summary> /// Stores container control visibility to data cache /// </summary> /// <param name="visible">Set to <c>true</c>, if container control should be visible to common users.</param> private void Cache_SetContainerVisible (bool visible) { #if (RENDERCACHE) var settings = new EmployeeListSettings (this); CacheHelper.Set<bool> (visible, DataCacheKey + "_ContainerVisible", settings.DataCacheTime + 60); #endif }
/* protected void ClearDataCache_Action (object sender, ActionEventArgs e) { try { if (e.Action.CommandName == "ClearDataCache.Action") { DataCache.RemoveCache(DataCacheKey); // Disabling render as we don't have controls, filled with data. disableRender = true; // NOTE: Also, control binding could be done in LoadComplete, // so we should know that we need update view, and there // be no need to disable render Response.Redirect (Globals.NavigateURL (), true); } } catch (Exception ex) { Exceptions.ProcessModuleLoadException(this, ex); } }*/ #endif /// <summary> /// Apply necessary cache logic on load /// </summary> /// <returns><c>true</c>, if control must render from cache, <c>false</c> otherwise.</returns> private bool Cache_OnLoad () { var cacheExists = false; #if (RENDERCACHE) var settings = new EmployeeListSettings (this); if (settings.DataCacheTime > 0) { if (IsEditable) { // don't use cache in edit mode DataCache.RemoveCache (DataCacheKey); // DataCache.RemoveCache(dataCacheKey + "_ContainerVisible"); } else { // NOTE: read cache here, cause it may be too late on render renderCacheContent = CacheHelper.Get<string> (DataCacheKey); if (renderCacheContent != null) { // REVIEW: Maybe is would be better is set default container visibility to true? var visible = CacheHelper.TryGet<bool> (DataCacheKey + "_ContainerVisible", false); ContainerControl.Visible = visible; renderDisabled = !visible; // no need to do anything, just render from cache cacheExists = true; } } } #endif return cacheExists; }