Exemple #1
0
 public long CopyLayout(long layoutId, string lang)
 {
     try
     {
         TraceMethodCall(layoutId, AvrDbHelper.GetLayoutNameForLog(layoutId), lang);
         EidssAvrServiceInitializer.CheckAndInitEidssCore();
         return(VirtualLayoutCopier.CreateLayoutCopyInAvrService(layoutId, lang, m_Container));
     }
     catch (Exception ex)
     {
         m_Trace.TraceMethodException(ex, Utils.GetCurrentMethodName(), m_TraceTitle);
         string format = EidssMessages.Get("msgCouldNotCreateLayoutCopy", "Could not create layout copy. Layout ID={0}, Language={1}");
         throw new AvrDataException(String.Format(format, layoutId, lang), ex);
     }
 }
Exemple #2
0
        public ChartExportDTO ExportChartToJpg(ChartTableDTO zippedData)
        {
            try
            {
                string    layoutName = AvrDbHelper.GetLayoutNameForLog(zippedData.ViewId);
                Stopwatch watch      = TraceMethodCall(layoutName, zippedData);
                EidssAvrServiceInitializer.CheckAndInitEidssCore();

                ChartExportDTO result;
                using (new CultureInfoTransaction(new CultureInfo(CustomCultureHelper.SupportedLanguages[zippedData.Lang])))
                {
                    VirtualChart virtualChart = null;
                    try
                    {
                        lock (m_ChartSyncLock)
                        {
                            virtualChart = new VirtualChart(m_Container);
                        }
                        result = virtualChart.ExportChartToJpg(zippedData, m_ChartSyncLock);
                    }
                    finally
                    {
                        if (virtualChart != null)
                        {
                            lock (m_ChartSyncLock)
                            {
                                virtualChart.Dispose();
                            }
                        }
                    }
                }
                TraceMethodCallFinished(watch, layoutName, zippedData);
                return(result);
            }
            catch (Exception ex)
            {
                m_Trace.TraceMethodException(ex, Utils.GetCurrentMethodName(), m_TraceTitle, zippedData);
                string format = EidssMessages.Get("msgCouldNotExportChart",
                                                  "Could not get Export chart from View. ViewID={0}, Lang={1}");
                string msg = String.Format(format, zippedData.ViewId, zippedData.Lang);
                throw new AvrDataException(msg, ex);
            }
        }
Exemple #3
0
        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();
            }
        }
Exemple #4
0
        private QueryTableHeaderDTO GetInternalCachedQueryTableHeader(long queryId, bool isSchedulerCall, string lang, bool isArchive)
        {
            try
            {
                string    queryName = AvrDbHelper.GetQueryNameForLog(queryId);
                Stopwatch watch     = TraceMethodCall(queryId, queryName, lang, isArchive);

                EidssAvrServiceInitializer.CheckAndInitEidssCore();

                var cacheKey = new QueryCacheKey(queryId, lang, isArchive);

                long?id = AvrDbHelper.GetQueryCacheId(cacheKey, RefreshedCacheOnUserCallAfterDays);

                if (!id.HasValue)
                {
                    bool needExecute;
                    lock (m_CacheSyncLock)
                    {
                        needExecute = !m_QueryCacheList.Contains(cacheKey);
                        if (needExecute)
                        {
                            m_QueryCacheList.Add(cacheKey);
                            if (!m_QueryCacheSyncLock.ContainsKey(cacheKey))
                            {
                                m_QueryCacheSyncLock.Add(cacheKey, new object());
                            }
                            if (!m_QueryCacheErrors.ContainsKey(cacheKey))
                            {
                                m_QueryCacheErrors.Add(cacheKey, false);
                            }
                        }
                    }
                    lock (m_QueryCacheSyncLock[cacheKey])
                    {
                        try
                        {
                            if (needExecute)
                            {
                                try
                                {
                                    id = AvrDbHelper.GetQueryCacheId(cacheKey, RefreshedCacheOnUserCallAfterDays);
                                    if (!id.HasValue)
                                    {
                                        QueryTableModel tableModel = AvrDbHelper.GetQueryResult(queryId, lang, isArchive);
                                        id = AvrDbHelper.SaveQueryCache(tableModel);
                                    }
                                }
                                finally
                                {
                                    lock (m_CacheSyncLock)
                                    {
                                        m_QueryCacheErrors[cacheKey] = !id.HasValue;
                                        m_QueryCacheList.Remove(cacheKey);
                                    }
                                }
                            }
                            else
                            {
                                while (true)
                                {
                                    lock (m_CacheSyncLock)
                                    {
                                        if (!m_QueryCacheList.Contains(cacheKey))
                                        {
                                            break;
                                        }
                                    }

                                    Monitor.Wait(m_QueryCacheSyncLock[cacheKey]);
                                }
                                lock (m_CacheSyncLock)
                                {
                                    if (m_QueryCacheErrors[cacheKey])
                                    {
                                        string message = EidssMessages.Get("msgCouldNotGetQueryCacheHeaderGeneral",
                                                                           "Could not get header of query cashe table. For detail see previous exception logged");
                                        throw new AvrDataException(message);
                                    }
                                }
                                id = AvrDbHelper.GetQueryCacheId(cacheKey, RefreshedCacheOnUserCallAfterDays, true);
                            }
                        }
                        finally
                        {
                            Monitor.PulseAll(m_QueryCacheSyncLock[cacheKey]);
                        }
                    }
                }
                if (!id.HasValue)
                {
                    string msg = EidssMessages.Get("msgCouldNotGetQueryCacheId", "Could not get query cashe ID. See log for more details.");
                    throw new AvrDataException(msg);
                }

                QueryTableHeaderDTO header = AvrDbHelper.GetQueryCacheHeader(id.Value, isSchedulerCall, isArchive);
                TraceMethodCallFinished(watch, queryId, queryName, lang, isArchive);
                return(header);
            }
            catch (Exception ex)
            {
                m_Trace.TraceMethodException(ex, Utils.GetCurrentMethodName(), m_TraceTitle, queryId, lang);
                string format = EidssMessages.Get("msgCouldNotGetQueryCacheHeader",
                                                  "Could not get header of query cashe table. Query ID={0}, Language={1}");
                throw new AvrDataException(String.Format(format, queryId, lang), ex);
            }
        }
Exemple #5
0
 protected override void InitEidssCore()
 {
     EidssAvrServiceInitializer.InitEidssCore();
 }