mirror of
https://gitlab.com/buildfeed/BuildFeed.git
synced 2024-03-22 21:10:34 +08:00
Let's go live.
inb4 everything breaks.
This commit is contained in:
parent
a84b410cea
commit
e55b1667f4
|
@ -9,6 +9,13 @@ public class RouteConfig
|
||||||
public static void RegisterRoutes(RouteCollection routes)
|
public static void RegisterRoutes(RouteCollection routes)
|
||||||
{
|
{
|
||||||
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
|
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
|
||||||
|
routes.MapHttpRoute("API", "api/{action}/{id}",
|
||||||
|
new
|
||||||
|
{
|
||||||
|
controller = "api",
|
||||||
|
action = "GetBuilds",
|
||||||
|
id = UrlParameter.Optional
|
||||||
|
});
|
||||||
routes.AppendTrailingSlash = true;
|
routes.AppendTrailingSlash = true;
|
||||||
routes.MapMvcAttributeRoutes();
|
routes.MapMvcAttributeRoutes();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,71 +1,71 @@
|
||||||
@model BuildFeed.Models.MetaItem
|
@model BuildFeed.Models.MetaItemModel
|
||||||
|
|
||||||
@{
|
@{
|
||||||
ViewBag.Title = $"Add metadata for {Model.Id.Value} | BuildFeed";
|
ViewBag.Title = string.Format("Add metadata for {0} | BuildFeed", Model.Id.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
<h2>@($"Add metadata for {Model.Id.Value}")</h2>
|
<h2>@string.Format("Add metadata for {0}", Model.Id.Value)</h2>
|
||||||
|
|
||||||
|
|
||||||
@using (Html.BeginForm())
|
@using (Html.BeginForm())
|
||||||
{
|
{
|
||||||
@Html.AntiForgeryToken()
|
@Html.AntiForgeryToken()
|
||||||
|
|
||||||
@Html.HiddenFor(model => model.Id.Type)
|
@Html.HiddenFor(model => model.Id.Type)
|
||||||
@Html.HiddenFor(model => model.Id.Value)
|
@Html.HiddenFor(model => model.Id.Value)
|
||||||
|
|
||||||
<div class="form-horizontal">
|
<div class="form-horizontal">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
@Html.LabelFor(model => model.MetaDescription, htmlAttributes: new { @class = "control-label col-sm-2" })
|
@Html.LabelFor(model => model.MetaDescription, htmlAttributes: new { @class = "control-label col-sm-2" })
|
||||||
<div class="col-sm-10">
|
<div class="col-sm-10">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
@Html.TextAreaFor(model => model.MetaDescription, new { @class = "form-control", rows = "2" })
|
@Html.TextAreaFor(model => model.MetaDescription, new { @class = "form-control", rows = "2" })
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
@Html.ValidationMessageFor(model => model.MetaDescription)
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
@Html.ValidationMessageFor(model => model.MetaDescription)
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
@Html.LabelFor(model => model.PageContent, new { @class = "control-label col-sm-2" })
|
@Html.LabelFor(model => model.PageContent, new { @class = "control-label col-sm-2" })
|
||||||
<div class="col-sm-10">
|
<div class="col-sm-10">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
@Html.TextAreaFor(model => model.PageContent, new { @class = "form-control" })
|
@Html.TextAreaFor(model => model.PageContent, new { @class = "form-control" })
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
@Html.ValidationMessageFor(model => model.PageContent)
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
@Html.ValidationMessageFor(model => model.PageContent)
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="col-sm-offset-2 col-sm-10">
|
<div class="col-sm-offset-2 col-sm-10">
|
||||||
<input type="submit" value="Add metadata" class="btn btn-primary" />
|
<input type="submit" value="Add metadata" class="btn btn-primary" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
@section Scripts
|
@section Scripts
|
||||||
{
|
{
|
||||||
<script src="~/Scripts/trumbowyg/trumbowyg.min.js" type="text/javascript"></script>
|
<script src="~/Scripts/trumbowyg/trumbowyg.min.js" type="text/javascript"></script>
|
||||||
<link href="~/Scripts/trumbowyg/ui/trumbowyg.min.css" rel="stylesheet" type="text/css" />
|
<link href="~/Scripts/trumbowyg/ui/trumbowyg.min.css" rel="stylesheet" type="text/css" />
|
||||||
|
|
||||||
@Scripts.Render("~/bundles/jqueryval")
|
@Scripts.Render("~/bundles/jqueryval")
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(function () {
|
$(function () {
|
||||||
var btnsGrps = $.trumbowyg.btnsGrps;
|
var btnsGrps = $.trumbowyg.btnsGrps;
|
||||||
|
|
||||||
$("#@Html.IdFor(model => model.PageContent)").trumbowyg({
|
$("#@Html.IdFor(model => model.PageContent)").trumbowyg({
|
||||||
semantic: true,
|
semantic: true,
|
||||||
autogrow: true,
|
autogrow: true,
|
||||||
btns: ['viewHTML',
|
btns: ['viewHTML',
|
||||||
'|', 'strong', 'em',
|
'|', 'strong', 'em',
|
||||||
'|', 'link',
|
'|', 'link',
|
||||||
'|', btnsGrps.justify,
|
'|', btnsGrps.justify,
|
||||||
'|', btnsGrps.lists]
|
'|', btnsGrps.lists]
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
}
|
}
|
|
@ -19,7 +19,6 @@ public apiController() : base()
|
||||||
bModel = new Build();
|
bModel = new Build();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Route("/api/GetWin10Labs/")]
|
|
||||||
public async Task<IEnumerable<string>> GetWin10Labs()
|
public async Task<IEnumerable<string>> GetWin10Labs()
|
||||||
{
|
{
|
||||||
List<string> labs = new List<string>();
|
List<string> labs = new List<string>();
|
||||||
|
@ -34,7 +33,6 @@ public async Task<IEnumerable<string>> GetWin10Labs()
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Route("/api/AddWin10Builds/")]
|
|
||||||
public async Task<bool> AddWin10Builds(NewBuild apiModel)
|
public async Task<bool> AddWin10Builds(NewBuild apiModel)
|
||||||
{
|
{
|
||||||
if (apiModel == null)
|
if (apiModel == null)
|
||||||
|
@ -61,10 +59,9 @@ public async Task<bool> AddWin10Builds(NewBuild apiModel)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Route("/api/GetSearchResult/{query}/")]
|
public async Task<IEnumerable<SearchResult>> GetSearchResult(string id)
|
||||||
public async Task<IEnumerable<SearchResult>> GetSearchResult(string query)
|
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(query))
|
if (string.IsNullOrWhiteSpace(id))
|
||||||
{
|
{
|
||||||
return new SearchResult[0];
|
return new SearchResult[0];
|
||||||
}
|
}
|
||||||
|
@ -72,12 +69,12 @@ public async Task<IEnumerable<SearchResult>> GetSearchResult(string query)
|
||||||
List<SearchResult> results = new List<SearchResult>();
|
List<SearchResult> results = new List<SearchResult>();
|
||||||
|
|
||||||
var sourceResults = from s in Enum.GetValues(typeof(TypeOfSource)).Cast<TypeOfSource>().Select(s => new { Text = DisplayHelpers.GetDisplayTextForEnum(s), Value = s })
|
var sourceResults = from s in Enum.GetValues(typeof(TypeOfSource)).Cast<TypeOfSource>().Select(s => new { Text = DisplayHelpers.GetDisplayTextForEnum(s), Value = s })
|
||||||
where s.Text.ToLower().Contains(query.ToLower())
|
where s.Text.ToLower().Contains(id.ToLower())
|
||||||
orderby s.Text.ToLower().IndexOf(query.ToLower(), StringComparison.Ordinal) ascending
|
orderby s.Text.ToLower().IndexOf(id.ToLower(), StringComparison.Ordinal) ascending
|
||||||
select new SearchResult()
|
select new SearchResult()
|
||||||
{
|
{
|
||||||
Url = Url.Route("Source Root", new { controller = "front", action = "viewSource", source = s.Value }),
|
Url = Url.Route("Source Root", new { controller = "front", action = "viewSource", source = s.Value }),
|
||||||
Label = s.Text.Replace(query, "<strong>" + query + "</strong>"),
|
Label = s.Text.Replace(id, "<strong>" + id + "</strong>"),
|
||||||
Title = s.Text,
|
Title = s.Text,
|
||||||
Group = Common.SearchSource
|
Group = Common.SearchSource
|
||||||
};
|
};
|
||||||
|
@ -86,12 +83,12 @@ orderby s.Text.ToLower().IndexOf(query.ToLower(), StringComparison.Ordinal) asce
|
||||||
|
|
||||||
|
|
||||||
var versionResults = from v in await bModel.SelectBuildVersions()
|
var versionResults = from v in await bModel.SelectBuildVersions()
|
||||||
where $"{v.Major}.{v.Minor}".StartsWith(query)
|
where $"{v.Major}.{v.Minor}".StartsWith(id)
|
||||||
orderby v.Major descending, v.Minor descending
|
orderby v.Major descending, v.Minor descending
|
||||||
select new SearchResult()
|
select new SearchResult()
|
||||||
{
|
{
|
||||||
Url = Url.Route("Version Root", new { controller = "front", action = "viewVersion", major = v.Major, minor = v.Minor }),
|
Url = Url.Route("Version Root", new { controller = "front", action = "viewVersion", major = v.Major, minor = v.Minor }),
|
||||||
Label = $"{v.Major}.{v.Minor}".Replace(query, "<strong>" + query + "</strong>"),
|
Label = $"{v.Major}.{v.Minor}".Replace(id, "<strong>" + id + "</strong>"),
|
||||||
Title = "",
|
Title = "",
|
||||||
Group = Common.SearchVersion
|
Group = Common.SearchVersion
|
||||||
};
|
};
|
||||||
|
@ -100,12 +97,12 @@ orderby s.Text.ToLower().IndexOf(query.ToLower(), StringComparison.Ordinal) asce
|
||||||
|
|
||||||
|
|
||||||
var yearResults = from y in await bModel.SelectBuildYears()
|
var yearResults = from y in await bModel.SelectBuildYears()
|
||||||
where y.ToString().Contains(query)
|
where y.ToString().Contains(id)
|
||||||
orderby y descending
|
orderby y descending
|
||||||
select new SearchResult()
|
select new SearchResult()
|
||||||
{
|
{
|
||||||
Url = Url.Route("Year Root", new { controller = "front", action = "viewYear", year = y }),
|
Url = Url.Route("Year Root", new { controller = "front", action = "viewYear", year = y }),
|
||||||
Label = y.ToString().Replace(query, "<strong>" + query + "</strong>"),
|
Label = y.ToString().Replace(id, "<strong>" + id + "</strong>"),
|
||||||
Title = "",
|
Title = "",
|
||||||
Group = Common.SearchYear
|
Group = Common.SearchYear
|
||||||
};
|
};
|
||||||
|
@ -113,13 +110,13 @@ orderby y descending
|
||||||
results.AddRange(yearResults);
|
results.AddRange(yearResults);
|
||||||
|
|
||||||
|
|
||||||
var labResults = from l in await bModel.SearchBuildLabs(query)
|
var labResults = from l in await bModel.SearchBuildLabs(id)
|
||||||
orderby l.IndexOf(query.ToLower()) ascending,
|
orderby l.IndexOf(id.ToLower()) ascending,
|
||||||
l.Length ascending
|
l.Length ascending
|
||||||
select new SearchResult()
|
select new SearchResult()
|
||||||
{
|
{
|
||||||
Url = Url.Route("Lab Root", new { controller = "front", action = "viewLab", lab = l.Replace('/', '-') }),
|
Url = Url.Route("Lab Root", new { controller = "front", action = "viewLab", lab = l.Replace('/', '-') }),
|
||||||
Label = l.Replace(query, $"<strong>{query}</strong>"),
|
Label = l.Replace(id, $"<strong>{id}</strong>"),
|
||||||
Title = l,
|
Title = l,
|
||||||
Group = Common.SearchLab
|
Group = Common.SearchLab
|
||||||
};
|
};
|
||||||
|
@ -128,13 +125,13 @@ l.Length ascending
|
||||||
|
|
||||||
|
|
||||||
var buildResults = from b in await bModel.Select()
|
var buildResults = from b in await bModel.Select()
|
||||||
where b.FullBuildString.ToLower().Contains(query.ToLower())
|
where b.FullBuildString.ToLower().Contains(id.ToLower())
|
||||||
orderby b.FullBuildString.ToLower().IndexOf(query.ToLower(), StringComparison.Ordinal) ascending,
|
orderby b.FullBuildString.ToLower().IndexOf(id.ToLower(), StringComparison.Ordinal) ascending,
|
||||||
b.BuildTime descending
|
b.BuildTime descending
|
||||||
select new SearchResult()
|
select new SearchResult()
|
||||||
{
|
{
|
||||||
Url = Url.Route("Build", new { controller = "front", action = "viewBuild", id = b.Id }),
|
Url = Url.Route("Build", new { controller = "front", action = "viewBuild", id = b.Id }),
|
||||||
Label = b.FullBuildString.Replace(query, $"<strong>{query}</strong>"),
|
Label = b.FullBuildString.Replace(id, $"<strong>{id}</strong>"),
|
||||||
Title = b.FullBuildString,
|
Title = b.FullBuildString,
|
||||||
Group = Common.SearchBuild
|
Group = Common.SearchBuild
|
||||||
};
|
};
|
||||||
|
|
|
@ -127,7 +127,7 @@
|
||||||
<value>Draag bij via</value>
|
<value>Draag bij via</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="Credits" xml:space="preserve">
|
<data name="Credits" xml:space="preserve">
|
||||||
<value>Dankwoord </value>
|
<value>Dankwoord</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="DevelopedBy" xml:space="preserve">
|
<data name="DevelopedBy" xml:space="preserve">
|
||||||
<value>Ontwikkeld door</value>
|
<value>Ontwikkeld door</value>
|
||||||
|
|
|
@ -2,5 +2,19 @@
|
||||||
|
|
||||||
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
|
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
|
||||||
<system.web>
|
<system.web>
|
||||||
|
<httpModules>
|
||||||
|
<add name="Glimpse" type="Glimpse.AspNet.HttpModule, Glimpse.AspNet" xdt:Transform="Insert" />
|
||||||
|
</httpModules>
|
||||||
|
<httpHandlers>
|
||||||
|
<add path="glimpse.axd" verb="GET" type="Glimpse.AspNet.HttpHandler, Glimpse.AspNet" xdt:Transform="Insert" />
|
||||||
|
</httpHandlers>
|
||||||
</system.web>
|
</system.web>
|
||||||
|
<system.webServer>
|
||||||
|
<handlers>
|
||||||
|
<add name="Glimpse" path="glimpse.axd" verb="GET" type="Glimpse.AspNet.HttpHandler, Glimpse.AspNet" preCondition="integratedMode" xdt:Transform="Insert" />
|
||||||
|
</handlers>
|
||||||
|
<modules>
|
||||||
|
<add name="Glimpse" type="Glimpse.AspNet.HttpModule, Glimpse.AspNet" preCondition="integratedMode" xdt:Transform="Insert" />
|
||||||
|
</modules>
|
||||||
|
</system.webServer>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|
|
@ -1,29 +1,29 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
|
|
||||||
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
|
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
|
||||||
<system.web>
|
<system.web>
|
||||||
<compilation xdt:Transform="RemoveAttributes(debug)" />
|
<compilation xdt:Transform="RemoveAttributes(debug)" />
|
||||||
<trace enabled="false" requestLimit="40" pageOutput="false" xdt:Transform="Replace" />
|
<trace enabled="false" requestLimit="40" pageOutput="false" xdt:Transform="Replace" />
|
||||||
<httpModules>
|
<httpModules>
|
||||||
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" xdt:Transform="Insert" />
|
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" xdt:Transform="Insert" />
|
||||||
</httpModules>
|
</httpModules>
|
||||||
</system.web>
|
</system.web>
|
||||||
<system.webServer>
|
<system.webServer>
|
||||||
<modules>
|
<modules>
|
||||||
<remove name="ApplicationInsightsWebTracking" xdt:Transform="Insert" />
|
<remove name="ApplicationInsightsWebTracking" xdt:Transform="Insert" />
|
||||||
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler" xdt:Transform="Insert" />
|
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler" xdt:Transform="Insert" />
|
||||||
</modules>
|
</modules>
|
||||||
<rewrite>
|
<rewrite>
|
||||||
<rules>
|
<rules>
|
||||||
<rule name="CanonicalHost" stopProcessing="true" xdt:Transform="Insert">
|
<rule name="CanonicalHost" stopProcessing="true" xdt:Transform="Insert">
|
||||||
<match url="(.*)" />
|
<match url="(.*)" />
|
||||||
<conditions logicalGrouping="MatchAny">
|
<conditions logicalGrouping="MatchAny">
|
||||||
<add input="{HTTP_HOST}" pattern="^buildfeed\.net$" negate="true" />
|
<add input="{HTTP_HOST}" pattern="^buildfeed\.net$" negate="true" />
|
||||||
<add input="{HTTPS}" pattern="off" />
|
<add input="{HTTPS}" pattern="off" />
|
||||||
</conditions>
|
</conditions>
|
||||||
<action type="Redirect" url="https://buildfeed.net/{R:1}" />
|
<action type="Redirect" url="https://buildfeed.net/{R:1}" />
|
||||||
</rule>
|
</rule>
|
||||||
</rules>
|
</rules>
|
||||||
</rewrite>
|
</rewrite>
|
||||||
</system.webServer>
|
</system.webServer>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|
|
@ -35,21 +35,21 @@
|
||||||
</providers>
|
</providers>
|
||||||
</roleManager>
|
</roleManager>
|
||||||
<httpModules>
|
<httpModules>
|
||||||
<add name="Glimpse" type="Glimpse.AspNet.HttpModule, Glimpse.AspNet" />
|
|
||||||
</httpModules>
|
</httpModules>
|
||||||
<httpHandlers>
|
<httpHandlers>
|
||||||
<add path="glimpse.axd" verb="GET" type="Glimpse.AspNet.HttpHandler, Glimpse.AspNet" />
|
|
||||||
</httpHandlers>
|
</httpHandlers>
|
||||||
</system.web>
|
</system.web>
|
||||||
<system.webServer>
|
<system.webServer>
|
||||||
<urlCompression doDynamicCompression="true" />
|
<urlCompression doDynamicCompression="true" />
|
||||||
|
<validation validateIntegratedModeConfiguration="false" />
|
||||||
<handlers>
|
<handlers>
|
||||||
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
|
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
|
||||||
<remove name="OPTIONSVerbHandler" />
|
<remove name="OPTIONSVerbHandler" />
|
||||||
<remove name="TRACEVerbHandler" />
|
<remove name="TRACEVerbHandler" />
|
||||||
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
|
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
|
||||||
<add name="Glimpse" path="glimpse.axd" verb="GET" type="Glimpse.AspNet.HttpHandler, Glimpse.AspNet" preCondition="integratedMode" />
|
|
||||||
</handlers>
|
</handlers>
|
||||||
|
<modules>
|
||||||
|
</modules>
|
||||||
<rewrite>
|
<rewrite>
|
||||||
<rules>
|
<rules>
|
||||||
<rule name="(2015-05) Support Pages">
|
<rule name="(2015-05) Support Pages">
|
||||||
|
@ -83,10 +83,6 @@
|
||||||
</rewriteMap>
|
</rewriteMap>
|
||||||
</rewriteMaps>
|
</rewriteMaps>
|
||||||
</rewrite>
|
</rewrite>
|
||||||
<validation validateIntegratedModeConfiguration="false" />
|
|
||||||
<modules>
|
|
||||||
<add name="Glimpse" type="Glimpse.AspNet.HttpModule, Glimpse.AspNet" preCondition="integratedMode" />
|
|
||||||
</modules>
|
|
||||||
</system.webServer>
|
</system.webServer>
|
||||||
<system.net>
|
<system.net>
|
||||||
<mailSettings>
|
<mailSettings>
|
||||||
|
|
39
RedisMongoMigration/MetaItem.cs
Normal file
39
RedisMongoMigration/MetaItem.cs
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace RedisMongoMigration
|
||||||
|
{
|
||||||
|
public class MetaItemKey
|
||||||
|
{
|
||||||
|
public string Value { get; set; }
|
||||||
|
public MetaType Type { get; set; }
|
||||||
|
|
||||||
|
public MetaItemKey()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public MetaItemKey(string id)
|
||||||
|
{
|
||||||
|
var items = id.Split(':');
|
||||||
|
Type = (MetaType)Enum.Parse(typeof(MetaType), items[0]);
|
||||||
|
Value = items[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return $"{Type}:{Value}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum MetaType
|
||||||
|
{
|
||||||
|
Lab,
|
||||||
|
Version,
|
||||||
|
Source,
|
||||||
|
Year
|
||||||
|
}
|
||||||
|
}
|
58
RedisMongoMigration/Mongo/MetaItem.cs
Normal file
58
RedisMongoMigration/Mongo/MetaItem.cs
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
using MongoDB.Bson;
|
||||||
|
using MongoDB.Bson.Serialization.Attributes;
|
||||||
|
using MongoDB.Driver;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace RedisMongoMigration.Mongo
|
||||||
|
{
|
||||||
|
public class MetaItemModel
|
||||||
|
{
|
||||||
|
[BsonId]
|
||||||
|
public MetaItemKey Id { get; set; }
|
||||||
|
|
||||||
|
public string PageContent { get; set; }
|
||||||
|
|
||||||
|
public string MetaDescription { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class MetaItem
|
||||||
|
{
|
||||||
|
private const string _buildCollectionName = "metaitem";
|
||||||
|
|
||||||
|
private MongoClient _dbClient;
|
||||||
|
private IMongoCollection<MetaItemModel> _buildCollection;
|
||||||
|
|
||||||
|
public MetaItem()
|
||||||
|
{
|
||||||
|
_dbClient = new MongoClient(new MongoClientSettings()
|
||||||
|
{
|
||||||
|
Server = new MongoServerAddress("localhost", 27017)
|
||||||
|
});
|
||||||
|
|
||||||
|
_buildCollection = _dbClient.GetDatabase("BuildFeed").GetCollection<MetaItemModel>(_buildCollectionName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<MetaItemModel> Select()
|
||||||
|
{
|
||||||
|
var task = _buildCollection.Find(new BsonDocument()).ToListAsync();
|
||||||
|
task.Wait();
|
||||||
|
return task.Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Insert(MetaItemModel item)
|
||||||
|
{
|
||||||
|
var task = _buildCollection.InsertOneAsync(item);
|
||||||
|
task.Wait();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void InsertAll(IEnumerable<MetaItemModel> items)
|
||||||
|
{
|
||||||
|
var task = _buildCollection.InsertManyAsync(items);
|
||||||
|
task.Wait();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,6 +7,9 @@
|
||||||
using MBuildModel = RedisMongoMigration.Mongo.BuildModel;
|
using MBuildModel = RedisMongoMigration.Mongo.BuildModel;
|
||||||
using MBuild = RedisMongoMigration.Mongo.Build;
|
using MBuild = RedisMongoMigration.Mongo.Build;
|
||||||
using RBuild = RedisMongoMigration.Redis.Build;
|
using RBuild = RedisMongoMigration.Redis.Build;
|
||||||
|
using MMetaItemModel = RedisMongoMigration.Mongo.MetaItemModel;
|
||||||
|
using MMetaItem = RedisMongoMigration.Mongo.MetaItem;
|
||||||
|
using RMetaItem = RedisMongoMigration.Redis.MetaItem;
|
||||||
using MongoLevelOfFlight = RedisMongoMigration.Mongo.MongoLevelOfFlight;
|
using MongoLevelOfFlight = RedisMongoMigration.Mongo.MongoLevelOfFlight;
|
||||||
using RedisLevelOfFlight = RedisMongoMigration.Redis.RedisLevelOfFlight;
|
using RedisLevelOfFlight = RedisMongoMigration.Redis.RedisLevelOfFlight;
|
||||||
using MMemberModel = RedisMongoMigration.Mongo.MemberModel;
|
using MMemberModel = RedisMongoMigration.Mongo.MemberModel;
|
||||||
|
@ -48,6 +51,21 @@ static void Main(string[] args)
|
||||||
mb.InsertAll(builds);
|
mb.InsertAll(builds);
|
||||||
Console.WriteLine("Builds: Complete");
|
Console.WriteLine("Builds: Complete");
|
||||||
|
|
||||||
|
var metas = from b in RMetaItem.Select()
|
||||||
|
select new MMetaItemModel()
|
||||||
|
{
|
||||||
|
Id = new MetaItemKey()
|
||||||
|
{
|
||||||
|
Type = b.Id.Type,
|
||||||
|
Value = b.Id.Value
|
||||||
|
},
|
||||||
|
MetaDescription = b.MetaDescription,
|
||||||
|
PageContent = b.PageContent
|
||||||
|
};
|
||||||
|
MMetaItem mmi = new MMetaItem();
|
||||||
|
mmi.InsertAll(metas);
|
||||||
|
Console.WriteLine("Meta Item: Complete");
|
||||||
|
|
||||||
var members = from r in RMember.Select()
|
var members = from r in RMember.Select()
|
||||||
select new MMemberModel()
|
select new MMemberModel()
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,46 +1,50 @@
|
||||||
using NServiceKit.DataAnnotations;
|
using NServiceKit.DataAnnotations;
|
||||||
using NServiceKit.DesignPatterns.Model;
|
using NServiceKit.DesignPatterns.Model;
|
||||||
|
using NServiceKit.Redis;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
namespace RedisMongoMigration.Redis
|
namespace RedisMongoMigration.Redis
|
||||||
{
|
{
|
||||||
[DataObject]
|
[DataObject]
|
||||||
public class MetaItem : IHasId<MetaItemKey>
|
public class MetaItem : IHasId<MetaItemKey>
|
||||||
{
|
{
|
||||||
[Key]
|
[Key]
|
||||||
[Index]
|
[Index]
|
||||||
public MetaItemKey Id { get; set; }
|
public MetaItemKey Id { get; set; }
|
||||||
|
|
||||||
public string PageContent { get; set; }
|
public string PageContent { get; set; }
|
||||||
|
|
||||||
public string MetaDescription { get; set; }
|
public string MetaDescription { get; set; }
|
||||||
}
|
|
||||||
|
|
||||||
public struct MetaItemKey
|
|
||||||
{
|
|
||||||
public string Value { get; set; }
|
|
||||||
public MetaType Type { get; set; }
|
|
||||||
|
|
||||||
public MetaItemKey(string id)
|
public static IEnumerable<MetaItem> Select()
|
||||||
{
|
{
|
||||||
var items = id.Split(':');
|
using (RedisClient rClient = new RedisClient("localhost", 6379, db: 1))
|
||||||
Type = (MetaType)Enum.Parse(typeof(MetaType), items[0]);
|
{
|
||||||
Value = items[1];
|
var client = rClient.As<MetaItem>();
|
||||||
}
|
return client.GetAll();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override string ToString()
|
public struct MetaItemKey
|
||||||
{
|
{
|
||||||
return $"{Type}:{Value}";
|
public string Value { get; set; }
|
||||||
}
|
public MetaType Type { get; set; }
|
||||||
}
|
|
||||||
|
|
||||||
public enum MetaType
|
public MetaItemKey(string id)
|
||||||
{
|
{
|
||||||
Lab,
|
var items = id.Split(':');
|
||||||
Version,
|
Type = (MetaType)Enum.Parse(typeof(MetaType), items[0]);
|
||||||
Source,
|
Value = items[1];
|
||||||
Year
|
}
|
||||||
}
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return $"{Type}:{Value}";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,16 +45,16 @@
|
||||||
<HintPath>..\packages\MongoDB.Driver.Core.2.0.1\lib\net45\MongoDB.Driver.Core.dll</HintPath>
|
<HintPath>..\packages\MongoDB.Driver.Core.2.0.1\lib\net45\MongoDB.Driver.Core.dll</HintPath>
|
||||||
<Private>True</Private>
|
<Private>True</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="NServiceKit.Common, Version=1.0.40.0, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="NServiceKit.Common, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\NServiceKit.Common.1.0.40\lib\net35\NServiceKit.Common.dll</HintPath>
|
<HintPath>..\packages\NServiceKit.Common.1.0.27\lib\net35\NServiceKit.Common.dll</HintPath>
|
||||||
<Private>True</Private>
|
<Private>True</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="NServiceKit.Interfaces, Version=1.0.40.0, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="NServiceKit.Interfaces, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\NServiceKit.Common.1.0.40\lib\net35\NServiceKit.Interfaces.dll</HintPath>
|
<HintPath>..\packages\NServiceKit.Common.1.0.27\lib\net35\NServiceKit.Interfaces.dll</HintPath>
|
||||||
<Private>True</Private>
|
<Private>True</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="NServiceKit.Redis, Version=1.0.17.0, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="NServiceKit.Redis, Version=1.0.10.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\NServiceKit.Redis.1.0.17\lib\net35\NServiceKit.Redis.dll</HintPath>
|
<HintPath>..\packages\NServiceKit.Redis.1.0.10\lib\net35\NServiceKit.Redis.dll</HintPath>
|
||||||
<Private>True</Private>
|
<Private>True</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="NServiceKit.Text, Version=1.0.10.0, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="NServiceKit.Text, Version=1.0.10.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
@ -73,7 +73,9 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Build.cs" />
|
<Compile Include="Build.cs" />
|
||||||
|
<Compile Include="MetaItem.cs" />
|
||||||
<Compile Include="Mongo\Build.cs" />
|
<Compile Include="Mongo\Build.cs" />
|
||||||
|
<Compile Include="Mongo\MetaItem.cs" />
|
||||||
<Compile Include="Mongo\MongoMember.cs" />
|
<Compile Include="Mongo\MongoMember.cs" />
|
||||||
<Compile Include="Mongo\MongoRole.cs" />
|
<Compile Include="Mongo\MongoRole.cs" />
|
||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs" />
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<package id="MongoDB.Bson" version="2.0.1" targetFramework="net46" />
|
<package id="MongoDB.Bson" version="2.0.1" targetFramework="net46" />
|
||||||
<package id="MongoDB.Driver" version="2.0.1" targetFramework="net46" />
|
<package id="MongoDB.Driver" version="2.0.1" targetFramework="net46" />
|
||||||
<package id="MongoDB.Driver.Core" version="2.0.1" targetFramework="net46" />
|
<package id="MongoDB.Driver.Core" version="2.0.1" targetFramework="net46" />
|
||||||
<package id="NServiceKit.Common" version="1.0.40" targetFramework="net46" />
|
<package id="NServiceKit.Common" version="1.0.27" targetFramework="net46" />
|
||||||
<package id="NServiceKit.Redis" version="1.0.17" targetFramework="net46" />
|
<package id="NServiceKit.Redis" version="1.0.10" targetFramework="net46" />
|
||||||
<package id="NServiceKit.Text" version="1.0.10" targetFramework="net46" />
|
<package id="NServiceKit.Text" version="1.0.10" targetFramework="net46" />
|
||||||
</packages>
|
</packages>
|
Loading…
Reference in New Issue
Block a user