示例#1
0
        public DateTime?GetsQueryCacheUserRequestDate(long queryId)
        {
            try
            {
                TraceMethodCall(queryId, AvrDbHelper.GetQueryNameForLog(queryId));

                return(AvrDbHelper.GetsQueryCacheUserRequestDate(queryId));
            }
            catch (Exception ex)
            {
                m_Trace.TraceMethodException(ex, Utils.GetCurrentMethodName(), m_TraceTitle);
                string format = EidssMessages.Get("msgCouldNotGetQueryCacheUserRequestDate",
                                                  "Could not get date when user requestet query cashe for Query ID={0}");
                throw new AvrDataException(String.Format(format, queryId), ex);
            }
        }
示例#2
0
        public void InvalidateQueryCacheForLanguage(long queryId, string lang)
        {
            try
            {
                TraceMethodCall(queryId, AvrDbHelper.GetQueryNameForLog(queryId), lang);

                AvrDbHelper.InvalidateQueryCache(queryId, lang);
            }
            catch (Exception ex)
            {
                m_Trace.TraceMethodException(ex, Utils.GetCurrentMethodName(), m_TraceTitle, queryId, lang);
                string format = EidssMessages.Get("msgCouldNotInvalidateQueryCache",
                                                  "Could not make query cashe table out of date. Query ID={0}, Language={1}");
                throw new AvrDataException(String.Format(format, queryId, lang), ex);
            }
        }
示例#3
0
 public bool DoesCachedQueryExists(long queryId, string lang, bool isArchive)
 {
     try
     {
         TraceMethodCall(queryId, AvrDbHelper.GetQueryNameForLog(queryId), lang);
         var  cacheKey = new QueryCacheKey(queryId, lang, isArchive);
         long?id       = AvrDbHelper.GetQueryCacheId(cacheKey, RefreshedCacheOnUserCallAfterDays);
         return(id.HasValue);
     }
     catch (Exception ex)
     {
         m_Trace.TraceMethodException(ex, Utils.GetCurrentMethodName(), m_TraceTitle);
         string format = EidssMessages.Get("msgCouldNotGetQueryCacheExistance",
                                           "Could not define does query cache exists for Query ID={0}.");
         throw new AvrDataException(String.Format(format, queryId), ex);
     }
 }
示例#4
0
        public DateTime GetQueryRefreshDateTime(long queryId, string lang)
        {
            try
            {
                if (queryId < 0)
                {
                    return(DateTime.Now);
                }
                TraceMethodCall(queryId, AvrDbHelper.GetQueryNameForLog(queryId), lang);

                return(AvrDbHelper.GetQueryRefreshDateTime(queryId, lang));
            }
            catch (Exception ex)
            {
                m_Trace.TraceMethodException(ex, Utils.GetCurrentMethodName(), m_TraceTitle);
                string format = EidssMessages.Get("msgCouldNotGetQueryCache",
                                                  "Could not get query cashe refresh date and time for Query ID={0}");
                throw new AvrDataException(String.Format(format, queryId), ex);
            }
        }
示例#5
0
        public void DeleteQueryCacheForLanguage(long queryId, string lang, bool leaveLastRecord)
        {
            try
            {
                TraceMethodCall(queryId, AvrDbHelper.GetQueryNameForLog(queryId), lang);

                int numberDeleted = AvrDbHelper.DeleteQueryCache(queryId, lang, leaveLastRecord);
                if (numberDeleted != 0)
                {
                    string msg = String.Format("Deleted '{0}' old cache records for Query '{1}' for language '{2}'",
                                               numberDeleted, queryId, lang);
                    m_Trace.Trace(m_TraceTitle, msg);
                }
            }
            catch (Exception ex)
            {
                m_Trace.TraceMethodException(ex, Utils.GetCurrentMethodName(), m_TraceTitle, queryId, lang);
                string format = EidssMessages.Get("msgCouldNotDeleteQueryCache",
                                                  "Could not delete query cashe. Query ID={0}, Language={1}");
                throw new AvrDataException(String.Format(format, queryId, lang), ex);
            }
        }
示例#6
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);
            }
        }