Allow editors to use bulk add; Add sanitised dump tool

This commit is contained in:
BuildFeed Bot 2019-01-14 20:23:39 +00:00
parent dee85fc12d
commit 4d58fd3970
No known key found for this signature in database
GPG Key ID: 3757685ADD91E0A1
8 changed files with 182 additions and 8 deletions

View File

@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2010
# Visual Studio Version 16
VisualStudioVersion = 16.0.28407.52
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BuildFeed", "BuildFeed\BuildFeed.csproj", "{CDDCF754-ECAA-4A66-ADAA-62957A57A51B}"
ProjectSection(ProjectDependencies) = postProject
@ -25,7 +25,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
README.md = README.md
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BuildFeed.Local", "BuildFeed.Local\BuildFeed.Local.csproj", "{9EBD4DB1-1D37-456B-AD90-357AA89DD1B7}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BuildFeed.Local", "BuildFeed.Local\BuildFeed.Local.csproj", "{9EBD4DB1-1D37-456B-AD90-357AA89DD1B7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DumpJson", "DumpJson\DumpJson.csproj", "{6F516C0F-3543-4DF8-833A-0259603A49CC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -127,6 +129,22 @@ Global
{9EBD4DB1-1D37-456B-AD90-357AA89DD1B7}.Release|x64.Build.0 = Release|Any CPU
{9EBD4DB1-1D37-456B-AD90-357AA89DD1B7}.Release|x86.ActiveCfg = Release|Any CPU
{9EBD4DB1-1D37-456B-AD90-357AA89DD1B7}.Release|x86.Build.0 = Release|Any CPU
{6F516C0F-3543-4DF8-833A-0259603A49CC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6F516C0F-3543-4DF8-833A-0259603A49CC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6F516C0F-3543-4DF8-833A-0259603A49CC}.Debug|ARM.ActiveCfg = Debug|Any CPU
{6F516C0F-3543-4DF8-833A-0259603A49CC}.Debug|ARM.Build.0 = Debug|Any CPU
{6F516C0F-3543-4DF8-833A-0259603A49CC}.Debug|x64.ActiveCfg = Debug|Any CPU
{6F516C0F-3543-4DF8-833A-0259603A49CC}.Debug|x64.Build.0 = Debug|Any CPU
{6F516C0F-3543-4DF8-833A-0259603A49CC}.Debug|x86.ActiveCfg = Debug|Any CPU
{6F516C0F-3543-4DF8-833A-0259603A49CC}.Debug|x86.Build.0 = Debug|Any CPU
{6F516C0F-3543-4DF8-833A-0259603A49CC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6F516C0F-3543-4DF8-833A-0259603A49CC}.Release|Any CPU.Build.0 = Release|Any CPU
{6F516C0F-3543-4DF8-833A-0259603A49CC}.Release|ARM.ActiveCfg = Release|Any CPU
{6F516C0F-3543-4DF8-833A-0259603A49CC}.Release|ARM.Build.0 = Release|Any CPU
{6F516C0F-3543-4DF8-833A-0259603A49CC}.Release|x64.ActiveCfg = Release|Any CPU
{6F516C0F-3543-4DF8-833A-0259603A49CC}.Release|x64.Build.0 = Release|Any CPU
{6F516C0F-3543-4DF8-833A-0259603A49CC}.Release|x86.ActiveCfg = Release|Any CPU
{6F516C0F-3543-4DF8-833A-0259603A49CC}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -553,12 +553,12 @@ public async Task<ActionResult> AddBuild(Build build)
}
[Route("bulk/")]
[Authorize(Roles = "Administrators")]
[Authorize(Roles = "Administrators,Editors")]
public ActionResult AddBulk() => View();
[Route("bulk/")]
[ValidateAntiForgeryToken]
[Authorize(Roles = "Administrators")]
[Authorize(Roles = "Administrators,Editors")]
[HttpPost]
public async Task<ActionResult> AddBulk(FormCollection values)
{

View File

@ -173,9 +173,6 @@
<i class="fa fa-fw fa-plus-square"></i> @VariantTerms.Common_AddBuild
</a>
</li>
}
if (Roles.IsUserInRole("Administrators"))
{
<li>
<a href="@Url.Action(nameof(FrontController.AddBulk), new
{

9
DumpJson/App.config Normal file
View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="data:MongoDB" value="BuildFeed" />
</appSettings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>

69
DumpJson/DumpJson.csproj Normal file
View File

@ -0,0 +1,69 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{6F516C0F-3543-4DF8-833A-0259603A49CC}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>DumpJson</RootNamespace>
<AssemblyName>DumpJson</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BuildFeed.Local\BuildFeed.Local.csproj">
<Project>{9ebd4db1-1d37-456b-ad90-357aa89dd1b7}</Project>
<Name>BuildFeed.Local</Name>
</ProjectReference>
<ProjectReference Include="..\BuildFeed.Model\BuildFeed.Model.csproj">
<Project>{7e2b4f61-1c11-4471-af80-5480e94c0664}</Project>
<Name>BuildFeed.Model</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

41
DumpJson/Program.cs Normal file
View File

@ -0,0 +1,41 @@
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using BuildFeed.Model;
using Newtonsoft.Json;
namespace DumpJson
{
internal class Program
{
public static async Task Main(string[] args)
{
var bRepo = new BuildRepository();
var builds = (await bRepo.Select()).Select(b => new
{
b.MajorVersion,
b.MinorVersion,
b.Number,
b.Revision,
b.Lab,
b.BuildTime,
b.Family,
b.SourceType,
b.SourceDetails,
b.LeakDate,
b.FullBuildString,
b.AlternateBuildString,
});
string outJson = JsonConvert.SerializeObject(builds, Formatting.Indented);
using (TextWriter writer = File.CreateText("output.json"))
{
writer.Write(outJson);
}
}
}
}

View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("DumpJson")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("DumpJson")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("6f516c0f-3543-4df8-833a-0259603a49cc")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

4
DumpJson/packages.config Normal file
View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="12.0.1" targetFramework="net472" />
</packages>