67 lines
2.2 KiB
C#
67 lines
2.2 KiB
C#
using MySql.Data.MySqlClient;
|
|
using ServiceShared.Crypto;
|
|
using ServiceShared.Database;
|
|
using ServiceShared.Models.Response;
|
|
using System;
|
|
|
|
namespace ServiceOutsideTests.Controllers
|
|
{
|
|
public class BaseTestController
|
|
{
|
|
protected string ServiceOutsideHost = "https://localhost";
|
|
protected string DeviceToken = "f97d687721329da0b0f85cb7b798904be7b7f830161856830d35e2fde679bf1e";
|
|
protected string DeviceUDID = "063FE5AD-CA67-4BE1-BC4D-629986474BE2";
|
|
protected string devDBConnectionString = "server=127.0.0.1;port=3306;uid=root;password=vertrigo;database=befundapp;";
|
|
protected readonly DbContext dbContext = null;
|
|
|
|
public BaseTestController()
|
|
{
|
|
dbContext = new DbContext(devDBConnectionString);
|
|
}
|
|
|
|
public static string GetFileName(string pgs, string udid, string extension = null, bool addTimestamp = false)
|
|
{
|
|
string result = null;
|
|
|
|
if (!string.IsNullOrEmpty(udid))
|
|
{
|
|
result = SHA512.Encrypt(udid + (!string.IsNullOrEmpty(pgs) ? pgs : "")) + (addTimestamp ? "_" + DateTime.Now.ToString("yyyyMMddHHmmss") : "") + (!string.IsNullOrEmpty(extension) ? "." + extension.ToLower() : "");
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
protected int DbCountResults()
|
|
{
|
|
int result = 0;
|
|
|
|
using (MySqlConnection client = new MySqlConnection(devDBConnectionString))
|
|
{
|
|
client.Open();
|
|
MySqlCommand cmd = client.CreateCommand();
|
|
cmd.CommandText = @"select count(*) cnt from results";
|
|
result = Convert.ToInt32(cmd.ExecuteScalar().ToString());
|
|
client.Close();
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
protected int DbCountTraces()
|
|
{
|
|
int result = 0;
|
|
|
|
using (MySqlConnection client = new MySqlConnection(devDBConnectionString))
|
|
{
|
|
client.Open();
|
|
MySqlCommand cmd = client.CreateCommand();
|
|
cmd.CommandText = @"select count(*) cnt from traces";
|
|
result = Convert.ToInt32(cmd.ExecuteScalar().ToString());
|
|
client.Close();
|
|
}
|
|
|
|
return result;
|
|
}
|
|
}
|
|
}
|