Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
maartenba committed Sep 26, 2015
2 parents 767112a + 88e6ad4 commit d73c7b7
Show file tree
Hide file tree
Showing 118 changed files with 1,650 additions and 1,071 deletions.
34 changes: 34 additions & 0 deletions src/NuGetGallery.Core/Entities/EntitiesConfiguration.cs
@@ -0,0 +1,34 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Data.Entity.SqlServer;
using System.Runtime.Remoting.Messaging;

namespace NuGetGallery
{
public class EntitiesConfiguration
: DbConfiguration
{
public EntitiesConfiguration()
{
// Configure Connection Resiliency / Retry Logic
// See https://msdn.microsoft.com/en-us/data/dn456835.aspx and msdn.microsoft.com/en-us/data/dn307226
SetExecutionStrategy("System.Data.SqlClient", () => SuspendExecutionStrategy
? (IDbExecutionStrategy)new DefaultExecutionStrategy() : new SqlAzureExecutionStrategy());
}

public static bool SuspendExecutionStrategy
{
get
{
return (bool?)CallContext.LogicalGetData("SuspendExecutionStrategy") ?? false;
}
set
{
CallContext.LogicalSetData("SuspendExecutionStrategy", value);
}
}
}
}
3 changes: 2 additions & 1 deletion src/NuGetGallery.Core/Entities/EntitiesContext.cs
Expand Up @@ -5,8 +5,9 @@

namespace NuGetGallery
{
[DbConfigurationType(typeof(EntitiesConfiguration))]
public class EntitiesContext
: EntityInterceptorDbContext, IEntitiesContext
: ObjectMaterializedInterceptingDbContext, IEntitiesContext
{
static EntitiesContext()
{
Expand Down
Expand Up @@ -3,7 +3,7 @@

namespace NuGetGallery
{
public interface IEntityInterceptor
public interface IObjectMaterializedInterceptor
{
void InterceptObjectMaterialized(object entity);
}
Expand Down
Expand Up @@ -2,24 +2,23 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System.Data.Entity;
using System.Data.Entity.Core.Objects;
using System.Data.Entity.Infrastructure;
using System.Data.Objects;

namespace NuGetGallery
{
public class EntityInterceptorDbContext
public class ObjectMaterializedInterceptingDbContext
: DbContext
{

public EntityInterceptorDbContext(string connectionString)
public ObjectMaterializedInterceptingDbContext(string connectionString)
: base(connectionString)
{
ObjectContext.ObjectMaterialized += ObjectContextOnObjectMaterialized;
}

private void ObjectContextOnObjectMaterialized(object sender, ObjectMaterializedEventArgs objectMaterializedEventArgs)
{
EntityInterception.InterceptObjectMaterialized(objectMaterializedEventArgs.Entity);
ObjectMaterializedInterception.InterceptObjectMaterialized(objectMaterializedEventArgs.Entity);
}

protected ObjectContext ObjectContext
Expand Down
Expand Up @@ -5,11 +5,11 @@

namespace NuGetGallery
{
public static class EntityInterception
public static class ObjectMaterializedInterception
{
private static readonly List<IEntityInterceptor> Interceptors = new List<IEntityInterceptor>();
private static readonly List<IObjectMaterializedInterceptor> Interceptors = new List<IObjectMaterializedInterceptor>();

public static void AddInterceptor(IEntityInterceptor interceptor)
public static void AddInterceptor(IObjectMaterializedInterceptor interceptor)
{
Interceptors.Add(interceptor);
}
Expand Down
18 changes: 12 additions & 6 deletions src/NuGetGallery.Core/NuGetGallery.Core.csproj
Expand Up @@ -37,8 +37,14 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="EntityFramework">
<HintPath>..\..\packages\EntityFramework.5.0.0\lib\net45\EntityFramework.dll</HintPath>
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="EntityFramework.SqlServer">
<HintPath>..\..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Data.Edm, Version=5.6.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Data.Edm.5.6.5-beta\lib\net40\Microsoft.Data.Edm.dll</HintPath>
Expand Down Expand Up @@ -76,7 +82,6 @@
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Data.Entity" />
<Reference Include="System.Data.Services.Client" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.Spatial, Version=5.6.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
Expand Down Expand Up @@ -104,15 +109,16 @@
<Compile Include="Entities\CuratedFeed.cs" />
<Compile Include="Entities\CuratedPackage.cs" />
<Compile Include="Entities\EmailMessage.cs" />
<Compile Include="Entities\EntitiesConfiguration.cs" />
<Compile Include="Entities\EntitiesContext.cs" />
<Compile Include="Entities\EntityException.cs" />
<Compile Include="Entities\Interception\EntityInterception.cs" />
<Compile Include="Entities\Interception\EntityInterceptorDbContext.cs" />
<Compile Include="Entities\Interception\ObjectMaterializedInterception.cs" />
<Compile Include="Entities\Interception\ObjectMaterializedInterceptingDbContext.cs" />
<Compile Include="Entities\EntityRepository.cs" />
<Compile Include="Entities\GallerySetting.cs" />
<Compile Include="Entities\IEntitiesContext.cs" />
<Compile Include="Entities\IEntity.cs" />
<Compile Include="Entities\Interception\IEntityInterceptor.cs" />
<Compile Include="Entities\Interception\IObjectMaterializedInterceptor.cs" />
<Compile Include="Entities\IEntityRepository.cs" />
<Compile Include="Entities\Package.cs" />
<Compile Include="Entities\PackageAuthor.cs" />
Expand Down
14 changes: 14 additions & 0 deletions src/NuGetGallery.Core/app.config
@@ -1,5 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
Expand All @@ -23,4 +27,14 @@
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
</configuration>
2 changes: 1 addition & 1 deletion src/NuGetGallery.Core/packages.config
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="EntityFramework" version="5.0.0" targetFramework="net45" />
<package id="EntityFramework" version="6.1.3" targetFramework="net452" />
<package id="Microsoft.Data.Edm" version="5.6.5-beta" targetFramework="net45" />
<package id="Microsoft.Data.OData" version="5.6.5-beta" targetFramework="net45" />
<package id="Microsoft.Data.Services.Client" version="5.6.5-beta" targetFramework="net45" />
Expand Down
11 changes: 8 additions & 3 deletions src/NuGetGallery.Operations/NuGetGallery.Operations.csproj
Expand Up @@ -46,8 +46,14 @@
<Reference Include="Dapper">
<HintPath>..\..\packages\Dapper.1.13\lib\net45\Dapper.dll</HintPath>
</Reference>
<Reference Include="EntityFramework">
<HintPath>..\..\packages\EntityFramework.5.0.0\lib\net45\EntityFramework.dll</HintPath>
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="EntityFramework.SqlServer">
<HintPath>..\..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Data.Edm, Version=5.6.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Data.Edm.5.6.5-beta\lib\net40\Microsoft.Data.Edm.dll</HintPath>
Expand Down Expand Up @@ -116,7 +122,6 @@
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Core" />
<Reference Include="System.Data.Entity" />
<Reference Include="System.Data.Services.Client" />
<Reference Include="System.Net" />
<Reference Include="System.Net.Http">
Expand Down
11 changes: 0 additions & 11 deletions src/NuGetGallery.Operations/Tasks/HandleFailedPackageEditsTask.cs
@@ -1,19 +1,8 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Data.EntityClient;
using System.Data.Objects;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Threading;
using Microsoft.WindowsAzure.Storage.Blob;
using NuGet;
using NuGetGallery.Packaging;

namespace NuGetGallery.Operations.Tasks
{
Expand Down
Expand Up @@ -2,11 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Data.EntityClient;
using System.Data.Objects;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
Expand Down
18 changes: 16 additions & 2 deletions src/NuGetGallery.Operations/app.config
@@ -1,5 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
Expand Down Expand Up @@ -36,7 +40,7 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" culture="neutral" />
Expand All @@ -51,4 +55,14 @@
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
</configuration>
2 changes: 1 addition & 1 deletion src/NuGetGallery.Operations/packages.config
Expand Up @@ -2,7 +2,7 @@
<packages>
<package id="AnglicanGeek.DbExecutor" version="0.1.2" targetFramework="net45" />
<package id="Dapper" version="1.13" targetFramework="net45" />
<package id="EntityFramework" version="5.0.0" targetFramework="net45" />
<package id="EntityFramework" version="6.1.3" targetFramework="net452" />
<package id="Microsoft.AspNet.Razor" version="3.2.3" targetFramework="net45" />
<package id="Microsoft.AspNet.WebPages" version="3.2.3" targetFramework="net45" />
<package id="Microsoft.Bcl" version="1.1.10" targetFramework="net45" />
Expand Down
2 changes: 1 addition & 1 deletion src/NuGetGallery/App_Start/DefaultDependenciesModule.cs
Expand Up @@ -365,7 +365,7 @@ private static void ConfigureForAzureStorage(ContainerBuilder builder, Configura
.AsSelf()
.As<IDownloadCountService>()
.SingleInstance();
EntityInterception.AddInterceptor(new DownloadCountEntityInterceptor(downloadCountService));
ObjectMaterializedInterception.AddInterceptor(new DownloadCountObjectMaterializedInterceptor(downloadCountService));

builder.RegisterType<JsonStatisticsService>()
.AsSelf()
Expand Down
25 changes: 25 additions & 0 deletions src/NuGetGallery/Areas/Admin/DynamicData/Content/Images/web.config
@@ -0,0 +1,25 @@
<?xml version="1.0"?>
<!--
The purpose of this file is to block access to the template files, that are not meant
to be directly requested.
-->
<configuration>
<system.web>
<httpHandlers>
<clear />
</httpHandlers>
</system.web>

<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<handlers>
<clear />
<add
name="StaticFile"
path="*" verb="*"
modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule"
resourceType="Either"
requireAccess="Read" />
</handlers>
</system.webServer>
</configuration>
Expand Up @@ -6,7 +6,7 @@
using System.Diagnostics.CodeAnalysis;
using System.Web.DynamicData;
using System.Web.Routing;
using DynamicData.EFCodeFirstProvider;
using Microsoft.AspNet.DynamicData.ModelProviders;
using NuGetGallery.Configuration;

namespace NuGetGallery.Areas.Admin.DynamicData
Expand Down Expand Up @@ -36,7 +36,7 @@ private static void InitializeDynamicData(RouteCollection routes, string root, I
try
{
DefaultModel.RegisterContext(
new EFCodeFirstDataModelProvider(
new EFDataModelProvider(
() => new EntitiesContext(configuration.SqlConnectionString, readOnly: false)), // DB Admins do not need to respect read-only mode.
configuration: new ContextConfiguration { ScaffoldAllTables = true });
}
Expand Down
@@ -1,15 +1,15 @@
<%@ Control Language="C#" CodeBehind="Default.ascx.cs" Inherits="NuGetGallery.Areas.Admin.DynamicData.DefaultEntityTemplate" %>
<%@ Control Language="C#" CodeBehind="Default.ascx.cs" Inherits="NuGetGallery.DefaultEntityTemplate" %>

<asp:EntityTemplate runat="server" ID="EntityTemplate1">
<ItemTemplate>
<tr class="td">
<td class="DDLightHeader">
<asp:Label runat="server" OnInit="Label_Init" />
</td>
<td>
<asp:DynamicControl runat="server" OnInit="DynamicControl_Init" />
</td>
</tr>
</ItemTemplate>
<tr class="td">
<td class="DDLightHeader">
<asp:Label runat="server" OnInit="Label_Init" />
</td>
<td>
<asp:DynamicControl runat="server" OnInit="DynamicControl_Init" />
</td>
</tr>
</ItemTemplate>
</asp:EntityTemplate>

0 comments on commit d73c7b7

Please sign in to comment.