public void VirtualPivotGetModelTest() { DataView layoutLookup = LookupCache.Get(LookupTables.Layout); if (layoutLookup.Count > 0) { var layoutId = (long)layoutLookup.Table.Rows[0]["idflLayout"]; for (int i = 0; i < 3; i++) { using (new StopwathTransaction("++ VirtualPivot with View++ " + i)) { AvrPivotViewModel model = VirtualPivot.CreateAvrPivotViewModel(layoutId, "en", StructureMapContainerInit()); Assert.IsNotNull(model); } } } }
public ViewDTO GetCachedView(string sessionId, long layoutId, string lang) { try { m_ViewSemaphore.Wait(); var layout = AvrDbHelper.GetLayoutDTO(layoutId); Stopwatch watch = TraceMethodCall(sessionId, layoutId, layout.DefaultLayoutName, lang); EidssAvrServiceInitializer.CheckAndInitEidssCore(); ViewDTO view = null; var cacheKey = new QueryCacheKey(layout.QueryId, lang, layout.UseArchivedData); long? queryCacheId = AvrDbHelper.GetQueryCacheId(cacheKey, RefreshedCacheOnUserCallAfterDays); if (queryCacheId.HasValue) { var viewCacheId = AvrDbHelper.GetViewCacheId(queryCacheId.Value, layoutId, RefreshedCacheOnUserCallAfterDays); if (viewCacheId.HasValue) { view = AvrDbHelper.GetViewCache(viewCacheId.Value, false); } } if (view == null) { AvrPivotViewModel model = VirtualPivot.CreateAvrPivotViewModel(layoutId, lang, m_Container); string xmlViewHeader = AvrViewSerializer.Serialize(model.ViewHeader); byte[] zippedViewHeader = BinaryCompressor.ZipString(xmlViewHeader); BaseTableDTO serializedDTO = BinarySerializer.SerializeFromTable(model.ViewData); BaseTableDTO zippedDTO = BinaryCompressor.Zip(serializedDTO); view = new ViewDTO(zippedDTO, zippedViewHeader); queryCacheId = AvrDbHelper.GetQueryCacheId(cacheKey, RefreshedCacheOnUserCallAfterDays); if (queryCacheId.HasValue) { AvrDbHelper.SaveViewCache(queryCacheId.Value, layoutId, view); } } TraceMethodCallFinished(watch, sessionId, layoutId, layout.DefaultLayoutName, lang); return(view); } catch (OutOfMemoryException ex) { m_Trace.TraceMethodException(ex, Utils.GetCurrentMethodName(), m_TraceTitle, sessionId, layoutId, lang); throw new AvrDataException(EidssMessages.Get("ErrAVROutOfMemory"), ex); } catch (Exception ex) { m_Trace.TraceMethodException(ex, Utils.GetCurrentMethodName(), m_TraceTitle, sessionId, layoutId, lang); string format = EidssMessages.Get("msgCouldNotGetViewData", "Could not get View Data from Layout. LayoutID={0}, Lang={1}, SessionId={2}"); string msg = String.Format(format, layoutId, lang, sessionId); throw new AvrDataException(msg, ex); } finally { m_ViewSemaphore.Release(); } }