Complete bulk addition; Component update

refactor-intermediate-models
Thomas Hounsell 2017-02-08 22:34:48 +00:00
parent 813aa09205
commit ef206ddb8a
13 changed files with 130 additions and 52 deletions

3
.gitmodules vendored
View File

@ -1,3 +0,0 @@
[submodule "External/OneSignal-CSharp-SDK"]
path = External/OneSignal-CSharp-SDK
url = https://github.com/hounsell/OneSignal-CSharp-SDK.git

View File

@ -1,6 +1,6 @@
namespace BuildFeed.Model.View
{
public class AddBulk
public class BulkAddition
{
public string Builds { get; set; }

View File

@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26014.0
VisualStudioVersion = 15.0.26020.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BuildFeed", "BuildFeed\BuildFeed.csproj", "{CDDCF754-ECAA-4A66-ADAA-62957A57A51B}"
EndProject
@ -29,10 +29,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BuildFeed.Model", "BuildFee
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MigrateBuildStrings", "Tools\MigrateBuildStrings\MigrateBuildStrings.csproj", "{8C3BD4DC-1DB5-4082-A051-4518AA8250A0}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "External", "External", "{A6A39494-EC12-483B-82ED-DA6D6B18236E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OneSignal.CSharp.SDK", "External\OneSignal-CSharp-SDK\src\OneSignal.CSharp.SDK\OneSignal.CSharp.SDK.csproj", "{81900249-B891-4B10-99B4-9810D793C8CF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -213,22 +209,6 @@ Global
{8C3BD4DC-1DB5-4082-A051-4518AA8250A0}.Release|x64.Build.0 = Release|Any CPU
{8C3BD4DC-1DB5-4082-A051-4518AA8250A0}.Release|x86.ActiveCfg = Release|Any CPU
{8C3BD4DC-1DB5-4082-A051-4518AA8250A0}.Release|x86.Build.0 = Release|Any CPU
{81900249-B891-4B10-99B4-9810D793C8CF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{81900249-B891-4B10-99B4-9810D793C8CF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{81900249-B891-4B10-99B4-9810D793C8CF}.Debug|ARM.ActiveCfg = Debug|Any CPU
{81900249-B891-4B10-99B4-9810D793C8CF}.Debug|ARM.Build.0 = Debug|Any CPU
{81900249-B891-4B10-99B4-9810D793C8CF}.Debug|x64.ActiveCfg = Debug|Any CPU
{81900249-B891-4B10-99B4-9810D793C8CF}.Debug|x64.Build.0 = Debug|Any CPU
{81900249-B891-4B10-99B4-9810D793C8CF}.Debug|x86.ActiveCfg = Debug|Any CPU
{81900249-B891-4B10-99B4-9810D793C8CF}.Debug|x86.Build.0 = Debug|Any CPU
{81900249-B891-4B10-99B4-9810D793C8CF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{81900249-B891-4B10-99B4-9810D793C8CF}.Release|Any CPU.Build.0 = Release|Any CPU
{81900249-B891-4B10-99B4-9810D793C8CF}.Release|ARM.ActiveCfg = Release|Any CPU
{81900249-B891-4B10-99B4-9810D793C8CF}.Release|ARM.Build.0 = Release|Any CPU
{81900249-B891-4B10-99B4-9810D793C8CF}.Release|x64.ActiveCfg = Release|Any CPU
{81900249-B891-4B10-99B4-9810D793C8CF}.Release|x64.Build.0 = Release|Any CPU
{81900249-B891-4B10-99B4-9810D793C8CF}.Release|x86.ActiveCfg = Release|Any CPU
{81900249-B891-4B10-99B4-9810D793C8CF}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -241,6 +221,5 @@ Global
{B7EC3C45-E5CE-4AD5-B303-65D865F12454} = {938956E0-6FA0-4432-A238-DAE704686F26}
{B68C450F-1475-4B9C-B513-43C79CBAA338} = {938956E0-6FA0-4432-A238-DAE704686F26}
{8C3BD4DC-1DB5-4082-A051-4518AA8250A0} = {938956E0-6FA0-4432-A238-DAE704686F26}
{81900249-B891-4B10-99B4-9810D793C8CF} = {A6A39494-EC12-483B-82ED-DA6D6B18236E}
EndGlobalSection
EndGlobal

View File

@ -99,19 +99,22 @@
<HintPath>..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="MongoDB.Bson, Version=2.4.1.18, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MongoDB.Bson.2.4.1\lib\net45\MongoDB.Bson.dll</HintPath>
<Reference Include="MongoDB.Bson, Version=2.4.2.27, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MongoDB.Bson.2.4.2\lib\net45\MongoDB.Bson.dll</HintPath>
</Reference>
<Reference Include="MongoDB.Driver, Version=2.4.1.18, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MongoDB.Driver.2.4.1\lib\net45\MongoDB.Driver.dll</HintPath>
<Reference Include="MongoDB.Driver, Version=2.4.2.27, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MongoDB.Driver.2.4.2\lib\net45\MongoDB.Driver.dll</HintPath>
</Reference>
<Reference Include="MongoDB.Driver.Core, Version=2.4.1.18, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MongoDB.Driver.Core.2.4.1\lib\net45\MongoDB.Driver.Core.dll</HintPath>
<Reference Include="MongoDB.Driver.Core, Version=2.4.2.27, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MongoDB.Driver.Core.2.4.2\lib\net45\MongoDB.Driver.Core.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="OneSignal.CSharp.SDK, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\OneSignal.CSharp.SDK.0.9\lib\net45\OneSignal.CSharp.SDK.dll</HintPath>
</Reference>
<Reference Include="RestSharp, Version=105.2.3.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\RestSharp.105.2.3\lib\net46\RestSharp.dll</HintPath>
</Reference>
@ -285,7 +288,6 @@
<Content Include="res\css\dark.scss" />
<Content Include="manifest.json" />
<None Include="package.json" />
<None Include="Properties\PublishProfiles\Milestone 1 [DEV].pubxml" />
<Content Include="res\Web.config" />
<Content Include="res\css\light.scss" />
<None Include="Scripts\jquery-3.1.1.intellisense.js" />
@ -442,10 +444,6 @@
<Project>{7e2b4f61-1c11-4471-af80-5480e94c0664}</Project>
<Name>BuildFeed.Model</Name>
</ProjectReference>
<ProjectReference Include="..\External\OneSignal-CSharp-SDK\src\OneSignal.CSharp.SDK\OneSignal.CSharp.SDK.csproj">
<Project>{81900249-b891-4b10-99b4-9810d793c8cf}</Project>
<Name>OneSignal.CSharp.SDK</Name>
</ProjectReference>
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>

View File

@ -93,7 +93,6 @@ namespace BuildFeed.Controllers
{
await _bModel.Insert(build);
OneSignalClient osc = new OneSignalClient(ConfigurationManager.AppSettings["push:OneSignalApiKey"]);
osc.Notifications.Create(new NotificationCreateOptions
{
@ -114,7 +113,7 @@ namespace BuildFeed.Controllers
{
{LanguageCodes.English, build.AlternateBuildString}
},
Url = $"https://buildfeed.net{Url.Route(nameof(FrontController.ViewBuild), new { controller = "Front", id = build.Id })}?utm_source=notification&utm_campaign=new_build"
Url = $"https://buildfeed.net{Url.Route("Build", new { controller = "Front", action = nameof(FrontController.ViewBuild), id = build.Id, area = "", httproute = "" })}?utm_source=notification&utm_campaign=new_build"
});
}
return true;

View File

@ -5,8 +5,10 @@ using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Drawing.Text;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Web.Mvc;
using BuildFeed.Code;
@ -458,9 +460,84 @@ namespace BuildFeed.Controllers
[Route("bulk/")]
[Authorize]
[HttpPost]
public async Task<ActionResult> AddBulk(AddBulk builds)
public async Task<ActionResult> AddBulk(FormCollection values)
{
return View(builds);
OneSignalClient osc = new OneSignalClient(ConfigurationManager.AppSettings["push:OneSignalApiKey"]);
var success = new List<Build>();
var failed = new List<string>();
bool notify = bool.Parse(values[nameof(BulkAddition.SendNotifications)].Split(',')[0]);
foreach (string line in values[nameof(BulkAddition.Builds)].Split(new[]
{
'\r',
'\n'
},
StringSplitOptions.RemoveEmptyEntries))
{
Match m = Regex.Match(line, @"(([\d]{1,2})\.([\d]{1,2})\.)?([\d]{4,5})(\.([\d]{1,5}))?(\.| \()([a-zA-Z][a-zA-Z0-9._\(\)-]+?)\.(\d\d\d\d\d\d-\d\d\d\d)\)?");
if (m.Success)
{
try
{
Build b = new Build
{
MajorVersion = uint.Parse(m.Groups[2].Value),
MinorVersion = uint.Parse(m.Groups[3].Value),
Number = uint.Parse(m.Groups[4].Value),
Revision = string.IsNullOrEmpty(m.Groups[6].Value)
? null
: uint.Parse(m.Groups[6].Value) as uint?,
Lab = m.Groups[8].Value,
BuildTime = string.IsNullOrEmpty(m.Groups[9].Value)
? null
: DateTime.SpecifyKind(DateTime.ParseExact(m.Groups[9].Value, "yyMMdd-HHmm", CultureInfo.CurrentCulture.DateTimeFormat), DateTimeKind.Utc) as DateTime?,
Added = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc),
Modified = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc),
SourceType = TypeOfSource.PrivateLeak
};
await _bModel.Insert(b);
if (notify)
{
osc.Notifications.Create(new NotificationCreateOptions
{
AppId = Guid.Parse(ConfigurationManager.AppSettings["push:AppId"]),
IncludedSegments = new List<string>
{
#if DEBUG
"Testers"
#else
"All"
#endif
},
Headings =
{
{LanguageCodes.English, "A new build has been added to BuildFeed!"}
},
Contents =
{
{LanguageCodes.English, b.AlternateBuildString}
},
Url = $"https://buildfeed.net{Url.Action(nameof(ViewBuild), new { id = b.Id })}?utm_source=notification&utm_campaign=new_build"
});
}
success.Add(b);
}
catch (Exception)
{
failed.Add(line);
}
}
}
ViewBag.Results = success.ToArray();
return View(new BulkAddition
{
Builds = string.Join("\r\n", failed),
SendNotifications = notify
});
}
[Route("edit/{id}/")]

View File

@ -1,4 +1,6 @@
@model BuildFeed.Model.View.AddBulk
@using BuildFeed.Controllers
@using BuildFeed.Model
@model BuildFeed.Model.View.BulkAddition
@{
ViewBag.Title = $"{VariantTerms.Common_AddBulk} | {InvariantTerms.SiteName}";
@ -6,10 +8,28 @@
<h1>Add builds in bulk</h1>
@if (ViewBag.Results != null)
{
<p>These builds have been added successfully.</p>
<ul>
@foreach (Build b in ViewBag.Results)
{
<li>
<a href="@Url.Action(nameof(FrontController.ViewBuild), new
{
id = b.Id
})" target="_blank">
@b.AlternateBuildString</a>
</li>
}
</ul>
}
<p>Add multiple builds below by typing the full build string out each on one line. All builds added via this page will have a Source Type of "Private Leak".</p>
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
<div class="form-group">
<label for="@Html.IdFor(m => m.Builds)">Builds</label>

View File

@ -8,10 +8,10 @@
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
<add key="data:MongoDB" value="BuildFeed" />
<add key="site:OSGLab" value="rs_prerelease" />
<add key="site:InsiderLab" value="rs_prerelease" />
<add key="site:OSGLab" value="rs_prerelease;rs2_release" />
<add key="site:InsiderLab" value="rs_prerelease;rs2_release" />
<add key="site:ReleaseLab" value="rs1_release;rs1_release_inmarket;rs1_release_sec;rs1_release_inmarket_rim" />
<add key="site:XboxLab" value="rs1_xbox_rel_1610" />
<add key="site:XboxLab" value="rs1_xbox_rel_1610;rs_xbox_dev_flight" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.6.2">

View File

@ -66,10 +66,11 @@
<package id="Microsoft.jQuery.Unobtrusive.Validation" version="3.2.3" targetFramework="net462" />
<package id="Microsoft.Net.Compilers" version="1.3.2" targetFramework="net462" developmentDependency="true" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net462" />
<package id="MongoDB.Bson" version="2.4.1" targetFramework="net462" />
<package id="MongoDB.Driver" version="2.4.1" targetFramework="net462" />
<package id="MongoDB.Driver.Core" version="2.4.1" targetFramework="net462" />
<package id="MongoDB.Bson" version="2.4.2" targetFramework="net462" />
<package id="MongoDB.Driver" version="2.4.2" targetFramework="net462" />
<package id="MongoDB.Driver.Core" version="2.4.2" targetFramework="net462" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net462" />
<package id="OneSignal.CSharp.SDK" version="0.9" targetFramework="net462" />
<package id="RestSharp" version="105.2.3" targetFramework="net462" />
<package id="System.Collections" version="4.3.0" targetFramework="net462" />
<package id="System.Linq" version="4.3.0" targetFramework="net462" />

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -874,3 +874,11 @@ footer#page-footer
}
}
}
@media (max-width: 1300px)
{
.latest-flex .latest-flex-item
{
min-width: calc(50% - 2em);
}
}

@ -1 +0,0 @@
Subproject commit d1dd8a4c6bd99add33fffe517ca06c5b8d0860ae