-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBaseController.cs
More file actions
75 lines (65 loc) · 2.59 KB
/
Copy pathBaseController.cs
File metadata and controls
75 lines (65 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;
using System.Linq;
using System.Data.SqlClient;
using Microsoft.Extensions.Configuration;
using System.IO;
using System.Data;
using System;
using System.Reflection;
using BitcoinLib.Services.Coins.Bitcoin;
using BitcoinLib.Responses;
using BitcoinLib.Responses.SharedComponents;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Logging;
namespace SAPI.API.Controllers
{
public class BaseController : Controller
{
private static IConfiguration Configuration { get; set; }
internal static SmartCashLib CoinService;
internal static string connString = string.Empty;
static string serverURL = "http://127.0.0.1:9679";
static string serverUser = string.Empty;
static string serverPass = string.Empty;
readonly ILogger<BaseController> logger;
public BaseController(IHostingEnvironment hostingEnvironment, ILogger<BaseController> log)
{
logger = log;
var builder = new ConfigurationBuilder()
.SetBasePath(hostingEnvironment.ContentRootPath)
.AddJsonFile("appsettings.json");
Configuration = builder.Build();
connString = $"Server=tcp:localhost,1433;Initial Catalog=SAPI;User ID=sa;Password={Configuration["SyncDb"]};Connection Timeout=30;";
serverUser = Configuration["rpcuser"];
serverPass = Configuration["rpcpass"];
CoinService = new SmartCashLib(serverURL,
serverUser,
serverPass,
"",
60);
CoinService.Parameters.CoinLongName = "SmartCash";
CoinService.Parameters.CoinShortName = "SMART";
CoinService.Parameters.IsoCurrencyCode = "XSC";
CoinService.Parameters.UseTestnet = false;
}
internal static List<T> DataReaderMapToList<T>(IDataReader dr)
{
List<T> list = new List<T>();
T obj = default(T);
while (dr.Read())
{
obj = Activator.CreateInstance<T>();
foreach (PropertyInfo prop in obj.GetType().GetProperties())
{
if (!object.Equals(dr[prop.Name], DBNull.Value))
{
prop.SetValue(obj, dr[prop.Name], null);
}
}
list.Add(obj);
}
return list;
}
}
}