ability to save spotlight data for current date
This commit is contained in:
+2
-1
@@ -183,4 +183,5 @@ Development/*.js
|
||||
# Project
|
||||
# =========================
|
||||
src/OnePeek.sln.ide/*
|
||||
src/OnePeek.Console/
|
||||
src/OnePeek.Console/
|
||||
AppData/
|
||||
@@ -1,14 +1,19 @@
|
||||
using Nancy;
|
||||
using Newtonsoft.Json;
|
||||
using OnePeek.Api;
|
||||
using OnePeek.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
|
||||
namespace OnePeek.WebConsole.Modules
|
||||
{
|
||||
public class ApiModule : NancyModule
|
||||
{
|
||||
public ApiModule() : base("api/")
|
||||
public ApiModule(IRootPathProvider rootProvider) : base("api/")
|
||||
{
|
||||
OnePeekApi api = new OnePeekApi();
|
||||
|
||||
@@ -19,6 +24,51 @@ namespace OnePeek.WebConsole.Modules
|
||||
};
|
||||
|
||||
|
||||
Post["/spotlight", true] = async (ctx, token) =>
|
||||
{
|
||||
IEnumerable<StoreSpotlightIdResults> apps1 = await api.GetSpotlightIdsForAllCultures(StoreSpotlightType.Apps, StoreType.WindowsPhone8, default(CancellationToken));
|
||||
IEnumerable<StoreSpotlightIdResults> games1 = await api.GetSpotlightIdsForAllCultures(StoreSpotlightType.Games, StoreType.WindowsPhone8, default(CancellationToken));
|
||||
|
||||
Dictionary<string, string> apps = new Dictionary<string, string>();
|
||||
Dictionary<string, string> games = new Dictionary<string, string>();
|
||||
|
||||
foreach (var result in apps1)
|
||||
{
|
||||
foreach (var id in result.Ids)
|
||||
{
|
||||
if (!apps.ContainsKey(id))
|
||||
{
|
||||
apps.Add(id, result.StoreCultureType.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
apps[id] = apps[id] + "," + result.StoreCultureType.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var result in games1)
|
||||
{
|
||||
foreach (var id in result.Ids)
|
||||
{
|
||||
if (!games.ContainsKey(id))
|
||||
{
|
||||
games.Add(id, result.StoreCultureType.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
games[id] = games[id] + "," + result.StoreCultureType.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File.WriteAllText(Path.Combine(rootProvider.GetRootPath(), "AppData", "apps-" + DateTime.Now.ToString("yyyy-MM-dd") + ".json"), JsonConvert.SerializeObject(apps));
|
||||
File.WriteAllText(Path.Combine(rootProvider.GetRootPath(), "AppData", "games-" + DateTime.Now.ToString("yyyy-MM-dd") + ".json"), JsonConvert.SerializeObject(games));
|
||||
|
||||
return Response.AsText("ok");
|
||||
};
|
||||
|
||||
|
||||
Get["/reviews/{id}", true] = async (ctx, token) =>
|
||||
{
|
||||
AppReviews reviews = await api.GetReviews(ctx.id, StoreType.WindowsPhone8, StoreCultureType.EN_US, StoreReviewSorting.Latest);
|
||||
|
||||
@@ -49,6 +49,10 @@
|
||||
<Reference Include="Nancy.ViewEngines.Razor">
|
||||
<HintPath>..\packages\Nancy.Viewengines.Razor.1.1\lib\net40\Nancy.ViewEngines.Razor.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Newtonsoft.Json.7.0.1-beta3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Web.DynamicData" />
|
||||
<Reference Include="System.Web.Entity" />
|
||||
|
||||
@@ -37,8 +37,11 @@
|
||||
<br /><br />
|
||||
|
||||
<div class="large-12 columns">
|
||||
<h3>SPOTLIGHT SUMMARY</h3>
|
||||
<a href="/spotlight" class="button">load</a>
|
||||
<form action="/api/spotlight" method="post">
|
||||
<h3>SPOTLIGHT SUMMARY</h3>
|
||||
<a href="/spotlight" class="button">load</a>
|
||||
<input type="submit" value="save" class="button" />
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div style="clear:both;"></div>
|
||||
|
||||
@@ -4,4 +4,5 @@
|
||||
<package id="Nancy" version="1.1" targetFramework="net45" />
|
||||
<package id="Nancy.Hosting.Aspnet" version="1.1" targetFramework="net45" />
|
||||
<package id="Nancy.Viewengines.Razor" version="1.1" targetFramework="net451" />
|
||||
<package id="Newtonsoft.Json" version="7.0.1-beta3" targetFramework="net451" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user