Ejemplo n.º 1
0
        static bool InitExtensionItem(string tableName, LoaderExtensionItem item)
        {
            var wasAdded = false;

            var queryParams = new object[]
            {
                "@Name", item.DatabaseName,
                "@ExtensionId", item.Extension.DatabaseId
            };

            var id = DatabaseUtil.ExecuteNullableScalar <int>(
                String.Format("SELECT Id FROM {0} WHERE ExtensionId = @ExtensionId AND Name = @Name", tableName),
                queryParams);

            if (id == null)
            {
                id = DatabaseUtil.ExecuteInsert(
                    String.Format("INSERT INTO {0} (ExtensionId, Name) VALUES (@ExtensionId, @Name) ", tableName),
                    queryParams);

                wasAdded = true;
            }

            item.DatabaseId = id.Value;

            return(wasAdded);
        }
Ejemplo n.º 2
0
        public static bool TryUpdateFacetFactoryIndex(LoaderFacetFactory info)
        {
            var ffwi = info.Factory as IFacetFactoryWithIndex;

            if (ffwi == null)
            {
                throw new ArgumentException("factory is not indexed");
            }

            var lastUpdatedAt = DatabaseUtil.ExecuteNullableScalar <DateTime>(
                "SELECT LastIndexUpdate FROM FacetFactories WHERE Id = @Id",
                "@Id", info.DatabaseId);

            if (!ffwi.ShouldUpdateIndex(FacetIndexReason.Startup, lastUpdatedAt))
            {
                return(false);
            }

            ThreadPool.QueueUserWorkItem(notused =>
            {
                // what is this for?
                // Thread.Sleep(2000);
                UpdateFromFactory(info);
            });

            return(true);
        }
Ejemplo n.º 3
0
        public static void InitExtension(LoaderExtension extension)
        {
            var queryParams = new object[]
            {
                "@Path", extension.Path,
                "@IsScript", extension is LoaderScriptExtension
            };

            var id = DatabaseUtil.ExecuteNullableScalar <int>(
                "SELECT Id FROM Extensions WHERE Path = @Path AND IsScript = @IsScript",
                queryParams);

            if (id == null)
            {
                id = DatabaseUtil.ExecuteInsert(
                    "INSERT INTO Extensions (Path, IsScript) VALUES (@Path, @IsScript)",
                    queryParams);
            }

            extension.DatabaseId = id.Value;
        }