diff --git a/BuildFeed/App_Start/RouteConfig.cs b/BuildFeed/App_Start/RouteConfig.cs index d29fada..55a35b4 100644 --- a/BuildFeed/App_Start/RouteConfig.cs +++ b/BuildFeed/App_Start/RouteConfig.cs @@ -9,6 +9,13 @@ public class RouteConfig public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); + routes.MapHttpRoute("API", "api/{action}/{id}", + new + { + controller = "api", + action = "GetBuilds", + id = UrlParameter.Optional + }); routes.AppendTrailingSlash = true; routes.MapMvcAttributeRoutes(); } diff --git a/BuildFeed/Areas/admin/Views/meta/create.cshtml b/BuildFeed/Areas/admin/Views/meta/create.cshtml index 53f7f99..3b5cf63 100644 --- a/BuildFeed/Areas/admin/Views/meta/create.cshtml +++ b/BuildFeed/Areas/admin/Views/meta/create.cshtml @@ -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); } -

@($"Add metadata for {Model.Id.Value}")

+

@string.Format("Add metadata for {0}", Model.Id.Value)

+ @using (Html.BeginForm()) { - @Html.AntiForgeryToken() + @Html.AntiForgeryToken() - @Html.HiddenFor(model => model.Id.Type) - @Html.HiddenFor(model => model.Id.Value) + @Html.HiddenFor(model => model.Id.Type) + @Html.HiddenFor(model => model.Id.Value) -
-
- @Html.LabelFor(model => model.MetaDescription, htmlAttributes: new { @class = "control-label col-sm-2" }) -
-
-
- @Html.TextAreaFor(model => model.MetaDescription, new { @class = "form-control", rows = "2" }) -
-
- @Html.ValidationMessageFor(model => model.MetaDescription) +
+
+ @Html.LabelFor(model => model.MetaDescription, htmlAttributes: new { @class = "control-label col-sm-2" }) +
+
+
+ @Html.TextAreaFor(model => model.MetaDescription, new { @class = "form-control", rows = "2" }) +
-
+ @Html.ValidationMessageFor(model => model.MetaDescription) +
+
-
- @Html.LabelFor(model => model.PageContent, new { @class = "control-label col-sm-2" }) -
-
-
- @Html.TextAreaFor(model => model.PageContent, new { @class = "form-control" }) -
-
- @Html.ValidationMessageFor(model => model.PageContent) +
+ @Html.LabelFor(model => model.PageContent, new { @class = "control-label col-sm-2" }) +
+
+
+ @Html.TextAreaFor(model => model.PageContent, new { @class = "form-control" }) +
-
+ @Html.ValidationMessageFor(model => model.PageContent) +
+
-
-
- -
-
-
+
+
+ +
+
+
} @section Scripts { - - + + - @Scripts.Render("~/bundles/jqueryval") + @Scripts.Render("~/bundles/jqueryval") - + $("#@Html.IdFor(model => model.PageContent)").trumbowyg({ + semantic: true, + autogrow: true, + btns: ['viewHTML', + '|', 'strong', 'em', + '|', 'link', + '|', btnsGrps.justify, + '|', btnsGrps.lists] + }); + }) + } \ No newline at end of file diff --git a/BuildFeed/Controllers/apiController.cs b/BuildFeed/Controllers/apiController.cs index 25a1aa6..113a194 100644 --- a/BuildFeed/Controllers/apiController.cs +++ b/BuildFeed/Controllers/apiController.cs @@ -19,7 +19,6 @@ public apiController() : base() bModel = new Build(); } - [Route("/api/GetWin10Labs/")] public async Task> GetWin10Labs() { List labs = new List(); @@ -34,7 +33,6 @@ public async Task> GetWin10Labs() } [HttpPost] - [Route("/api/AddWin10Builds/")] public async Task AddWin10Builds(NewBuild apiModel) { if (apiModel == null) @@ -61,10 +59,9 @@ public async Task AddWin10Builds(NewBuild apiModel) } } - [Route("/api/GetSearchResult/{query}/")] - public async Task> GetSearchResult(string query) + public async Task> GetSearchResult(string id) { - if (string.IsNullOrWhiteSpace(query)) + if (string.IsNullOrWhiteSpace(id)) { return new SearchResult[0]; } @@ -72,12 +69,12 @@ public async Task> GetSearchResult(string query) List results = new List(); var sourceResults = from s in Enum.GetValues(typeof(TypeOfSource)).Cast().Select(s => new { Text = DisplayHelpers.GetDisplayTextForEnum(s), Value = s }) - where s.Text.ToLower().Contains(query.ToLower()) - orderby s.Text.ToLower().IndexOf(query.ToLower(), StringComparison.Ordinal) ascending + where s.Text.ToLower().Contains(id.ToLower()) + orderby s.Text.ToLower().IndexOf(id.ToLower(), StringComparison.Ordinal) ascending select new SearchResult() { Url = Url.Route("Source Root", new { controller = "front", action = "viewSource", source = s.Value }), - Label = s.Text.Replace(query, "" + query + ""), + Label = s.Text.Replace(id, "" + id + ""), Title = s.Text, 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() - where $"{v.Major}.{v.Minor}".StartsWith(query) + where $"{v.Major}.{v.Minor}".StartsWith(id) orderby v.Major descending, v.Minor descending select new SearchResult() { Url = Url.Route("Version Root", new { controller = "front", action = "viewVersion", major = v.Major, minor = v.Minor }), - Label = $"{v.Major}.{v.Minor}".Replace(query, "" + query + ""), + Label = $"{v.Major}.{v.Minor}".Replace(id, "" + id + ""), Title = "", 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() - where y.ToString().Contains(query) + where y.ToString().Contains(id) orderby y descending select new SearchResult() { Url = Url.Route("Year Root", new { controller = "front", action = "viewYear", year = y }), - Label = y.ToString().Replace(query, "" + query + ""), + Label = y.ToString().Replace(id, "" + id + ""), Title = "", Group = Common.SearchYear }; @@ -113,13 +110,13 @@ orderby y descending results.AddRange(yearResults); - var labResults = from l in await bModel.SearchBuildLabs(query) - orderby l.IndexOf(query.ToLower()) ascending, + var labResults = from l in await bModel.SearchBuildLabs(id) + orderby l.IndexOf(id.ToLower()) ascending, l.Length ascending select new SearchResult() { Url = Url.Route("Lab Root", new { controller = "front", action = "viewLab", lab = l.Replace('/', '-') }), - Label = l.Replace(query, $"{query}"), + Label = l.Replace(id, $"{id}"), Title = l, Group = Common.SearchLab }; @@ -128,13 +125,13 @@ l.Length ascending var buildResults = from b in await bModel.Select() - where b.FullBuildString.ToLower().Contains(query.ToLower()) - orderby b.FullBuildString.ToLower().IndexOf(query.ToLower(), StringComparison.Ordinal) ascending, + where b.FullBuildString.ToLower().Contains(id.ToLower()) + orderby b.FullBuildString.ToLower().IndexOf(id.ToLower(), StringComparison.Ordinal) ascending, b.BuildTime descending select new SearchResult() { Url = Url.Route("Build", new { controller = "front", action = "viewBuild", id = b.Id }), - Label = b.FullBuildString.Replace(query, $"{query}"), + Label = b.FullBuildString.Replace(id, $"{id}"), Title = b.FullBuildString, Group = Common.SearchBuild }; diff --git a/BuildFeed/Local/Common.nl.resx b/BuildFeed/Local/Common.nl.resx index d785005..8e53ad4 100644 --- a/BuildFeed/Local/Common.nl.resx +++ b/BuildFeed/Local/Common.nl.resx @@ -127,7 +127,7 @@ Draag bij via - Dankwoord + Dankwoord Ontwikkeld door diff --git a/BuildFeed/Web.Debug.config b/BuildFeed/Web.Debug.config index a5b06f4..b62dca2 100644 --- a/BuildFeed/Web.Debug.config +++ b/BuildFeed/Web.Debug.config @@ -2,5 +2,19 @@ + + + + + + + + + + + + + + diff --git a/BuildFeed/Web.Release.config b/BuildFeed/Web.Release.config index 35e7f26..f516414 100644 --- a/BuildFeed/Web.Release.config +++ b/BuildFeed/Web.Release.config @@ -1,29 +1,29 @@  - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/BuildFeed/Web.config b/BuildFeed/Web.config index 5fa31a6..31240da 100644 --- a/BuildFeed/Web.config +++ b/BuildFeed/Web.config @@ -35,21 +35,21 @@ - - + - + + @@ -83,10 +83,6 @@ - - - - diff --git a/RedisMongoMigration/MetaItem.cs b/RedisMongoMigration/MetaItem.cs new file mode 100644 index 0000000..1fb4065 --- /dev/null +++ b/RedisMongoMigration/MetaItem.cs @@ -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 + } +} diff --git a/RedisMongoMigration/Mongo/MetaItem.cs b/RedisMongoMigration/Mongo/MetaItem.cs new file mode 100644 index 0000000..deac7a1 --- /dev/null +++ b/RedisMongoMigration/Mongo/MetaItem.cs @@ -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 _buildCollection; + + public MetaItem() + { + _dbClient = new MongoClient(new MongoClientSettings() + { + Server = new MongoServerAddress("localhost", 27017) + }); + + _buildCollection = _dbClient.GetDatabase("BuildFeed").GetCollection(_buildCollectionName); + } + + public List 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 items) + { + var task = _buildCollection.InsertManyAsync(items); + task.Wait(); + } + } +} diff --git a/RedisMongoMigration/Program.cs b/RedisMongoMigration/Program.cs index 46fa8b6..27b14d5 100644 --- a/RedisMongoMigration/Program.cs +++ b/RedisMongoMigration/Program.cs @@ -7,6 +7,9 @@ using MBuildModel = RedisMongoMigration.Mongo.BuildModel; using MBuild = RedisMongoMigration.Mongo.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 RedisLevelOfFlight = RedisMongoMigration.Redis.RedisLevelOfFlight; using MMemberModel = RedisMongoMigration.Mongo.MemberModel; @@ -48,6 +51,21 @@ static void Main(string[] args) mb.InsertAll(builds); 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() select new MMemberModel() { diff --git a/RedisMongoMigration/Redis/MetaItem.cs b/RedisMongoMigration/Redis/MetaItem.cs index 8942968..6ec88fa 100644 --- a/RedisMongoMigration/Redis/MetaItem.cs +++ b/RedisMongoMigration/Redis/MetaItem.cs @@ -1,46 +1,50 @@ using NServiceKit.DataAnnotations; using NServiceKit.DesignPatterns.Model; +using NServiceKit.Redis; using System; +using System.Collections.Generic; using System.ComponentModel; using System.ComponentModel.DataAnnotations; namespace RedisMongoMigration.Redis { - [DataObject] - public class MetaItem : IHasId - { - [Key] - [Index] - public MetaItemKey Id { get; set; } + [DataObject] + public class MetaItem : IHasId + { + [Key] + [Index] + 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) - { - var items = id.Split(':'); - Type = (MetaType)Enum.Parse(typeof(MetaType), items[0]); - Value = items[1]; - } + public static IEnumerable Select() + { + using (RedisClient rClient = new RedisClient("localhost", 6379, db: 1)) + { + var client = rClient.As(); + return client.GetAll(); + } + } + } - public override string ToString() - { - return $"{Type}:{Value}"; - } - } + public struct MetaItemKey + { + public string Value { get; set; } + public MetaType Type { get; set; } - public enum MetaType - { - Lab, - Version, - Source, - Year - } + 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}"; + } + } } diff --git a/RedisMongoMigration/RedisMongoMigration.csproj b/RedisMongoMigration/RedisMongoMigration.csproj index c6f5cab..e87cf53 100644 --- a/RedisMongoMigration/RedisMongoMigration.csproj +++ b/RedisMongoMigration/RedisMongoMigration.csproj @@ -45,16 +45,16 @@ ..\packages\MongoDB.Driver.Core.2.0.1\lib\net45\MongoDB.Driver.Core.dll True - - ..\packages\NServiceKit.Common.1.0.40\lib\net35\NServiceKit.Common.dll + + ..\packages\NServiceKit.Common.1.0.27\lib\net35\NServiceKit.Common.dll True - - ..\packages\NServiceKit.Common.1.0.40\lib\net35\NServiceKit.Interfaces.dll + + ..\packages\NServiceKit.Common.1.0.27\lib\net35\NServiceKit.Interfaces.dll True - - ..\packages\NServiceKit.Redis.1.0.17\lib\net35\NServiceKit.Redis.dll + + ..\packages\NServiceKit.Redis.1.0.10\lib\net35\NServiceKit.Redis.dll True @@ -73,7 +73,9 @@ + + diff --git a/RedisMongoMigration/packages.config b/RedisMongoMigration/packages.config index e1d3ca0..1df5d4c 100644 --- a/RedisMongoMigration/packages.config +++ b/RedisMongoMigration/packages.config @@ -3,7 +3,7 @@ - - + + \ No newline at end of file