Commit 5542d755 authored by Clint Mourlevat's avatar Clint Mourlevat

Adding TickerService and VanityService / in-memory Distributed cache

parent 97bb7c71
using System;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Hosting;
using Newtonsoft.Json;
using RestSharp;
namespace Stratis.Guru.Services
{
public class TickerService : IHostedService, IDisposable
{
private readonly IMemoryCache _memoryCache;
public TickerService(IMemoryCache memoryCache)
{
_memoryCache = memoryCache;
}
public Task StartAsync(CancellationToken cancellationToken)
{
var updateTimer = new System.Timers.Timer();
updateTimer.Interval = 10000;
updateTimer.Elapsed += (sender, args) =>
{
var coinmarketCapApiClient = new RestSharp.RestClient("https://api.coinmarketcap.com/v2/ticker/1343/");
var coinmarketCapApiRequest = new RestRequest(Method.GET);
var coinmarketcapApi = coinmarketCapApiClient.Execute(coinmarketCapApiRequest);
_memoryCache.Set("Coinmarketcap", coinmarketcapApi.Content);
//dynamic resultAPI = JsonConvert.DeserializeObject(coinmarketcapAPI.Content);
};
updateTimer.Start();
return Task.CompletedTask;
}
public Task StopAsync(CancellationToken cancellationToken)
{
return Task.CompletedTask;
}
public void Dispose()
{
}
}
}
\ No newline at end of file
using System;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Hosting;
namespace Stratis.Guru.Services
{
public class VanityService : IHostedService, IDisposable
{
public Task StartAsync(CancellationToken cancellationToken)
{
return Task.CompletedTask;
}
public Task StopAsync(CancellationToken cancellationToken)
{
return Task.CompletedTask;
}
public void Dispose()
{
}
}
}
\ No newline at end of file
...@@ -11,6 +11,7 @@ using Microsoft.AspNetCore.Mvc; ...@@ -11,6 +11,7 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.FileProviders; using Microsoft.Extensions.FileProviders;
using Stratis.Guru.Services;
namespace Stratis.Guru namespace Stratis.Guru
{ {
...@@ -33,6 +34,11 @@ namespace Stratis.Guru ...@@ -33,6 +34,11 @@ namespace Stratis.Guru
options.MinimumSameSitePolicy = SameSiteMode.None; options.MinimumSameSitePolicy = SameSiteMode.None;
}); });
services.AddMemoryCache();
services.AddHostedService<TickerService>();
services.AddHostedService<VanityService>();
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
} }
......
...@@ -8,10 +8,25 @@ ...@@ -8,10 +8,25 @@
<div class="row"> <div class="row">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 align-self-center text-center"> <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 align-self-center text-center">
<h1>The <strong>$STRAT</strong> price in realtime.</h1> <h1>The <strong>$STRAT</strong> price in realtime.</h1>
<p>Arda makes it easy creation and deployment of decentralized applications, that can be downloaded by end-users from the application store.</p> <h1 class="align-middle">
<div>
<span class="click-edit">1 STRAT</span> =
</div>
<span class="display-1 font-weight-bold">@(2.ToString("C2"))</span>
</h1>
<a href="#" class="btn-secondary-box">Download Whitepaper</a> <a href="#" class="btn-secondary-box">Download Whitepaper</a>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</section> </section>
@section Scripts
{
<script type="text/javascript">
$(document).ready(function() {
$(".click-edit").click(function() {
alert("ok");
})
})
</script>
}
\ No newline at end of file
@using Microsoft.AspNetCore.Http.Features
@{
var consentFeature = Context.Features.Get<ITrackingConsentFeature>();
var showBanner = !consentFeature?.CanTrack ?? false;
var cookieString = consentFeature?.CreateConsentCookie();
}
@if (showBanner)
{
<nav id="cookieConsent" class="navbar navbar-default navbar-fixed-top" role="alert">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#cookieConsent .navbar-collapse">
<span class="sr-only">Toggle cookie consent banner</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<span class="navbar-brand"><span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span></span>
</div>
<div class="collapse navbar-collapse">
<p class="navbar-text">
Use this space to summarize your privacy and cookie use policy.
</p>
<div class="navbar-right">
@*<a asp-controller="Home" asp-action="Privacy" class="btn btn-info navbar-btn">Learn More</a>*@
<button type="button" class="btn btn-default navbar-btn" data-cookie-string="@cookieString">Accept</button>
</div>
</div>
</div>
</nav>
<script>
(function () {
document.querySelector("#cookieConsent button[data-cookie-string]").addEventListener("click", function (el) {
document.cookie = el.target.dataset.cookieString;
document.querySelector("#cookieConsent").classList.add("hidden");
}, false);
})();
</script>
}
\ No newline at end of file
...@@ -25,10 +25,11 @@ ...@@ -25,10 +25,11 @@
<img src="~/images/logos/white-logo-dark.svg" class="dark-logo" alt="Arda ICO"/> <img src="~/images/logos/white-logo-dark.svg" class="dark-logo" alt="Arda ICO"/>
</a> </a>
<ul class="nav"> <ul class="nav">
<li><a asp-action="About" asp-controller="Home"><i class="fa fa-info-circle"></i> ABOUT</a></li> <li><a asp-action="Index" asp-controller="Home"><i class="fa fa-home"></i> HOME</a></li>
<li><a asp-action="Explorer" asp-controller="Home"><i class="fa fa-book"></i> BLOCK EXPLORER</a></li> <li><a asp-action="Explorer" asp-controller="Home"><i class="fa fa-at"></i> VANITY</a></li>
<li><a asp-action="Generator" asp-controller="Home"><i class="fa fa-qrcode"></i> ADDRESS GENERATOR</a></li> <li><a asp-action="Generator" asp-controller="Home"><i class="fa fa-qrcode"></i> ADDRESS GENERATOR</a></li>
<li><a asp-action="Contact" asp-controller="Home"><i class="fa fa-envelope"></i> CONTACT</a></li>-code <li><a asp-action="About" asp-controller="Home"><i class="fa fa-info-circle"></i> ABOUT</a></li>
<li><a asp-action="Contact" asp-controller="Home"><i class="fa fa-envelope"></i> CONTACT</a></li>
</ul> </ul>
<a class='menu-trigger'> <a class='menu-trigger'>
<span>Menu</span> <span>Menu</span>
...@@ -52,6 +53,7 @@ ...@@ -52,6 +53,7 @@
<script src="~/js/owl.carousel.min.js"></script> <script src="~/js/owl.carousel.min.js"></script>
<script src="~/js/particle-green.js"></script> <script src="~/js/particle-green.js"></script>
<script src="~/js/custom.js"></script> <script src="~/js/custom.js"></script>
@RenderSection("Scripts", false)
</body> </body>
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-111742056-1"></script> <script async src="https://www.googletagmanager.com/gtag/js?id=UA-111742056-1"></script>
<script> <script>
...@@ -61,68 +63,6 @@ ...@@ -61,68 +63,6 @@
gtag('config', 'UA-111742056-1'); gtag('config', 'UA-111742056-1');
</script> </script>
<!--stratisguru-->
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-5a48282c1ee2c396"></script>
</html>
@*<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="Clint Mourlevat">
<link rel="icon" href="~/favicon.ico">
<title>Stratis.Guru | Online Stratis Tool</title>
<!-- Bootstrap core CSS -->
<link href="~/npm/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="~/css/site.css" rel="stylesheet">
</head>
<body>
<header>
<nav class="navbar navbar-expand-md navbar-dark fixed-top bg-transparent mt-4">
<div class="container">
<a class="navbar-brand mr-5 mt-0" asp-controller="Home" asp-action="Index"><img class="logo" src="~/images/logo.png"/> Stratis.Guru</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="navbar-right">
<div class="collapse navbar-collapse ml-auto" id="navbarCollapse">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link ml-4" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link ml-4" href="#">Disabled</a>
</li>
</ul>
</div>
</div>
</div>
</nav>
</header>
@RenderBody()
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-111742056-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', 'UA-111742056-1');
</script>
<!--stratisguru--> <!--stratisguru-->
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-5a48282c1ee2c396"></script> <script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-5a48282c1ee2c396"></script>
</body>
</html> </html>
\ No newline at end of file
*@
\ No newline at end of file
...@@ -3189,3 +3189,9 @@ h2 ...@@ -3189,3 +3189,9 @@ h2
border: 0; border: 0;
font-size: 12pt !important; font-size: 12pt !important;
} }
.click-edit
{
border-bottom: 1px dotted #EEEEEE;
cursor: pointer;
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment