Ejemplo n.º 1
0
        public static QueryTableHeaderDTO GetQueryCacheHeader(long queryCacheId, bool isSchedulerCall, bool isArchive)
        {
            using (var avrTran = new AvrDbTransaction())
            {
                DbManagerProxy manager = avrTran.Manager;
                DbManager      command = manager.SetSpCommand("spAsQueryCacheGetHeader",
                                                              manager.Parameter("idfQueryCache", queryCacheId),
                                                              manager.Parameter("blnSchedulerCall", isSchedulerCall),
                                                              manager.Parameter("blnUseArchivedData", isArchive));

                QueryTablePacketDTO headerPacket = new QueryTablePacketDTO {
                    IsArchive = isArchive
                };
                int packetCount = 0;
                lock (m_DbSyncLock)
                {
                    using (IDataReader reader = command.ExecuteReader())
                    {
                        if (reader.Read())
                        {
                            packetCount           = (int)reader["intPacketCount"];
                            headerPacket.RowCount = (int)reader["intQueryColumnCount"];
                            var binaryBody = (byte[])reader["blbQuerySchema"];
                            headerPacket.BinaryBody = new ChunkByteArray(binaryBody);
                        }
                    }

                    avrTran.CommitTransaction();
                }
                return(new QueryTableHeaderDTO(headerPacket, queryCacheId, packetCount));
            }
        }
Ejemplo n.º 2
0
        public static ViewDTO GetViewCache(long viewCacheId, bool isSchedulerCall)
        {
            ViewDTO view;

            using (var avrTran = new AvrDbTransaction())
            {
                DbManagerProxy manager   = avrTran.Manager;
                DbManager      headerCmd = manager.SetSpCommand("spAsViewCacheGetHeader",
                                                                manager.Parameter("idfViewCache", viewCacheId),
                                                                manager.Parameter("blnSchedulerCall", isSchedulerCall));

                lock (m_DbSyncLock)
                {
                    int packetCount;
                    using (IDataReader reader = headerCmd.ExecuteReader())
                    {
                        if (!reader.Read())
                        {
                            return(null);
                        }

                        BaseTableDTO viewTableDTO = new BaseTableDTO
                        {
                            Header =
                            {
                                RowCount   = (int)reader["intViewColumnCount"],
                                BinaryBody = new ChunkByteArray((byte[])reader["blbViewSchema"])
                            }
                        };

                        var binaryHeader = (byte[])reader["blbViewHeader"];
                        view = new ViewDTO(viewTableDTO, binaryHeader);

                        packetCount = (int)reader["intPacketCount"];
                    }
                    for (int packetNumber = 0; packetNumber < packetCount; packetNumber++)
                    {
                        DbManager packetCmd = manager.SetSpCommand("spAsViewCacheGetPacket",
                                                                   manager.Parameter("idfViewCache", viewCacheId),
                                                                   manager.Parameter("intViewCachePacketNumber", packetNumber));

                        var packetDTO = new BaseTablePacketDTO();
                        using (IDataReader packetReader = packetCmd.ExecuteReader())
                        {
                            if (!packetReader.Read())
                            {
                                return(null);
                            }

                            packetDTO.RowCount   = (int)packetReader["intTableRowCount"];
                            packetDTO.BinaryBody = new ChunkByteArray((byte[])packetReader["blbViewCachePacket"]);
                        }
                        view.BodyPackets.Add(packetDTO);
                    }

                    avrTran.CommitTransaction();
                }
            }
            return(view);
        }
Ejemplo n.º 3
0
 public static long SaveViewCache(long queryCacheId, long layoutId, ViewDTO zippedTable)
 {
     using (var avrTran = new AvrDbTransaction())
     {
         long id = SaveViewCacheWithoutTransaction(queryCacheId, layoutId, zippedTable);
         avrTran.CommitTransaction();
         return(id);
     }
 }
Ejemplo n.º 4
0
 public static long SaveQueryCache(QueryTableModel zippedTable)
 {
     using (var avrTran = new AvrDbTransaction())
     {
         long id = SaveQueryCacheWithoutTransaction(zippedTable);
         avrTran.CommitTransaction();
         return(id);
     }
 }
Ejemplo n.º 5
0
 public static DateTime?GetsQueryCacheUserRequestDate(long queryId)
 {
     using (var avrTran = new AvrDbTransaction())
     {
         DbManagerProxy manager = avrTran.Manager;
         DbManager      command = manager.SetSpCommand("spAsQueryCacheUserRequestDate", manager.Parameter("idfQuery", queryId));
         object         result;
         lock (m_DbSyncLock)
         {
             result = command.ExecuteScalar();
             avrTran.CommitTransaction();
         }
         return((result == null || result == DBNull.Value) ? null : (DateTime?)result);
     }
 }
Ejemplo n.º 6
0
        public static void InvalidateViewCache(long layoutId)
        {
            using (var avrTran = new AvrDbTransaction())
            {
                DbManagerProxy manager = avrTran.Manager;

                DbManager command = manager.SetSpCommand("spAsViewCacheInvalidate",
                                                         manager.Parameter("idfLayout", layoutId));

                lock (m_DbSyncLock)
                {
                    command.ExecuteNonQuery();
                    avrTran.CommitTransaction();
                }
            }
        }
Ejemplo n.º 7
0
        public static void InvalidateQueryCache(long queryId, string lang = null)
        {
            using (var avrTran = new AvrDbTransaction())
            {
                DbManagerProxy manager = avrTran.Manager;

                DbManager command = string.IsNullOrEmpty(lang)
                    ? manager.SetSpCommand("spAsQueryCacheInvalidate",
                                           manager.Parameter("idfQuery", queryId))
                    : manager.SetSpCommand("spAsQueryCacheInvalidate",
                                           manager.Parameter("idfQuery", queryId),
                                           manager.Parameter("strLanguage", lang));

                lock (m_DbSyncLock)
                {
                    command.ExecuteNonQuery();
                    avrTran.CommitTransaction();
                }
            }
        }
Ejemplo n.º 8
0
        public static long?GetViewCacheId
            (long queryCacheId, long layoutId, int refresheAfterDays = DaysInAWeek, bool allowSelectInvalidated = false)
        {
            using (var avrTran = new AvrDbTransaction())
            {
                DbManagerProxy manager = avrTran.Manager;
                DbManager      command = manager.SetSpCommand("spAsViewCacheExist",
                                                              manager.Parameter("idfQueryCache", queryCacheId),
                                                              manager.Parameter("idfLayout", layoutId),
                                                              manager.Parameter("refreshedCacheOnUserCallAfterDays", refresheAfterDays),
                                                              manager.Parameter("allowSelectInvalidated", allowSelectInvalidated)
                                                              );
                object result;
                lock (m_DbSyncLock)
                {
                    result = command.ExecuteScalar();
                    avrTran.CommitTransaction();
                }

                return((result == null || result == DBNull.Value) ? null : (long?)result);
            }
        }
Ejemplo n.º 9
0
        public static QueryTablePacketDTO GetQueryCachePacket(long queryCasheId, int packetNumber)
        {
            using (var avrTran = new AvrDbTransaction())
            {
                DbManager command = avrTran.Manager.SetSpCommand("spAsQueryCacheGetPacket",
                                                                 avrTran.Manager.Parameter("idfQueryCache", queryCasheId),
                                                                 avrTran.Manager.Parameter("intQueryCachePacketNumber", packetNumber));

                var result = new QueryTablePacketDTO();
                using (IDataReader reader = command.ExecuteReader())
                {
                    if (reader.Read())
                    {
                        result.RowCount   = (int)reader["intTableRowCount"];
                        result.BinaryBody = new ChunkByteArray((byte[])reader["blbQueryCachePacket"]);
                        result.IsArchive  = (bool)reader["blnArchivedData"];
                    }
                }
                avrTran.CommitTransaction();
                return(result);
            }
        }
Ejemplo n.º 10
0
        public static long?GetQueryCacheId
            (QueryCacheKey queryCacheKey, int refresheAfterDays = DaysInAWeek, bool allowSelectInvalidated = false)
        {
            using (var avrTran = new AvrDbTransaction())
            {
                DbManagerProxy manager = avrTran.Manager;
                DbManager      command = manager.SetSpCommand("spAsQueryCacheExist",
                                                              manager.Parameter("idfQuery", queryCacheKey.QueryId),
                                                              manager.Parameter("strLanguage", queryCacheKey.Lang),
                                                              manager.Parameter("blnUseArchivedData", queryCacheKey.IsArchive),
                                                              manager.Parameter("refreshedCacheOnUserCallAfterDays", refresheAfterDays),
                                                              manager.Parameter("allowSelectInvalidated", allowSelectInvalidated)
                                                              );
                object result;
                lock (m_DbSyncLock)
                {
                    result = command.ExecuteScalar();
                    avrTran.CommitTransaction();
                }

                return((result == null || result == DBNull.Value) ? null : (long?)result);
            }
        }
Ejemplo n.º 11
0
        public static DateTime GetQueryRefreshDateTime(long queryId, string lang)
        {
            DateTime date = DateTime.Now;

            using (var avrTran = new AvrDbTransaction())
            {
                DbManagerProxy manager = avrTran.Manager;
                DbManager      command = manager.SetSpCommand("spAsQueryCacheGetRefreshDateTime",
                                                              manager.Parameter("idfQuery", queryId),
                                                              manager.Parameter("strLanguage", lang));
                lock (m_DbSyncLock)
                {
                    using (IDataReader reader = command.ExecuteReader())
                    {
                        if (reader.Read())
                        {
                            date = (DateTime)reader["datQueryRefresh"];
                        }
                    }
                    avrTran.CommitTransaction();
                }
            }
            return(date);
        }
Ejemplo n.º 12
0
        public static int DeleteQueryCache(long queryId, string lang, bool leaveLastRecord)
        {
            using (var avrTran = new AvrDbTransaction())
            {
                DbManagerProxy manager = avrTran.Manager;
                DbManager      command = manager.SetSpCommand("spAsQueryCacheDelete",
                                                              manager.Parameter("idfQuery", queryId),
                                                              manager.Parameter("strLanguage", lang),
                                                              manager.Parameter("blnLeaveLastRecord", leaveLastRecord)
                                                              );

                lock (m_DbSyncLock)
                {
                    object result        = command.ExecuteScalar();
                    int    numberDeleted = 0;
                    if (result is int)
                    {
                        numberDeleted = (int)result;
                    }
                    avrTran.CommitTransaction();
                    return(numberDeleted);
                }
            }
        }