Esempio n. 1
0
        //----------------------------------------------------------------------------------------------------
        private static void ASPdb_View__SyncViewsWithProperties_Helper1__GetAndPopulate(int connectionId, List <ASPdb_View> viewsList, Dictionary <string, ASPdb_View> dict)
        {
            string sql = "select * from [" + Config.SystemProperties.AppSchema + @"].[ASPdb_Views] where [ConnectionId] = @ConnectionId order by [ViewName]";

            using (DbConnectionCommand command = UniversalADO.OpenConnectionCommand(sql))
            {
                command.AddParameter("@ConnectionId", connectionId);
                using (DbReaderWrapper reader = command.ExecuteReaderWrapper())
                {
                    while (reader.Read())
                    {
                        string db_ViewName      = reader.Get("ViewName", "");
                        string db_Schema        = reader.Get("Schema", "");
                        string db_UniqueNameKey = db_Schema.ToLower().Trim() + "." + db_ViewName.ToLower().Trim();
                        if (dict.ContainsKey(db_UniqueNameKey))
                        {
                            ASPdb_View item = dict[db_UniqueNameKey];
                            item.ViewId       = reader.Get("ViewId", -1);
                            item.ConnectionId = reader.Get("ConnectionId", -1);
                            item.ViewName     = db_ViewName;
                            item.Schema       = db_Schema;
                            item.Hide         = reader.Get("Hide", false);
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        //----------------------------------------------------------------------------------------------------
        /// <summary>
        /// Always uses cache (if already stored in cache).
        /// Does not perform table sync.
        /// </summary>
        public static ASPdb_View ASPdb_View__Get(int viewId)
        {
            AjaxService.ASPdatabaseService.GetSetVal();
            var cache = ASPdatabaseNET.Memory.AppCache.Get();

            if (cache.ASPdb_View_Dictionary2 != null)
            {
                if (cache.ASPdb_View_Dictionary2.ContainsKey(viewId) && cache.ASPdb_View_Dictionary2[viewId] != null)
                {
                    return(cache.ASPdb_View_Dictionary2[viewId]); // return from cache if it's there
                }
            }
            ASPdb_View rtn = null;

            int connectionId = -1;
            string sql       = "select [ConnectionId] from [" + Config.SystemProperties.AppSchema + @"].[ASPdb_Views] where [ViewId] = @ViewId";
            using (DbConnectionCommand command = UniversalADO.OpenConnectionCommand(sql))
            {
                command.AddParameter("@ViewId", viewId);
                using (DbReaderWrapper reader = command.ExecuteReaderWrapper())
                {
                    if (reader.Read())
                    {
                        connectionId = reader.Get("ConnectionId", -1);
                    }
                    if (connectionId < 0)
                    {
                        return(null);
                    }
                }
            }
            var aspdb_Views = ASPdb_View__GetAll(connectionId);
            for (int i = 0; i < aspdb_Views.Count; i++)
            {
                if (aspdb_Views[i].ViewId == viewId)
                {
                    rtn = aspdb_Views[i];
                    i   = aspdb_Views.Count + 1;
                }
            }

            // store in cache before returning
            if (rtn != null)
            {
                if (cache.ASPdb_View_Dictionary2 == null)
                {
                    cache.ASPdb_View_Dictionary2 = new Dictionary <int, ASPdb_View>();
                }
                if (cache.ASPdb_View_Dictionary2.ContainsKey(viewId))
                {
                    cache.ASPdb_View_Dictionary2[viewId] = rtn;
                }
                else
                {
                    cache.ASPdb_View_Dictionary2.Add(viewId, rtn);
                }
            }
            return(rtn);
        }
Esempio n. 3
0
        //----------------------------------------------------------------------------------------------------
        private static void ASPdb_View__SyncViewsWithProperties_Helper2__Insert(ASPdb_View aspdb_View)
        {
            string sql = String.Format(@"
                insert into [" + Config.SystemProperties.AppSchema + @"].[ASPdb_Views]
                ([ConnectionId], [ViewName], [Schema], [Hide])
                values
                (@ConnectionId, @ViewName, @Schema, 0)
            ");

            using (DbConnectionCommand command = UniversalADO.OpenConnectionCommand(sql))
            {
                command.AddParameter("@ConnectionId", aspdb_View.ConnectionId);
                command.AddParameter("@ViewName", aspdb_View.ViewName);
                command.AddParameter("@Schema", aspdb_View.Schema);
                command.Command.ExecuteNonQuery();
            }
        }