mirror of
https://github.com/stokebob/bnhtrade.git
synced 2026-05-18 19:48:23 +00:00
29f9fae508
* complete read invoices from db * wip * wip * wip * wip * wip * wip * wip * wip * updated nuget package spapi * WIP * wip, now test * wip, jut need to fix tax inclusive line amounts not supported * wip * wip, before I f everything up * no, it complies now, this is the one before I f everything up * wip * wip * wip, logic ready for testing * wip it builds!!!! * wip tested, working, need to complete the gui section * wip * wip * wip - created export invoice data delete, time for testing * wip testing phase * wip - delete function fully tested and working * wip on to sorting out the issue with settlement invoices not tallying * wip * wip * wip * wip * wip before I complete change the ReadInvoiceLineItem sections * that appears to have worked, on with the main quest * no it's doesn't work, saving before i remove the confusing cache system (just use a dictionary!!) * wipping picadilli * wip * wip * implemented uow on inovice export, now for testing * wip * wip all tested do invoice currency convertion fearure * wip * pretty much done so long as xero accepts the exported invoices * Complete!
98 lines
3.4 KiB
C#
98 lines
3.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Data.SqlClient;
|
|
using System.Configuration;
|
|
|
|
namespace bnhtrade.Core.Data.Database
|
|
{
|
|
public class Connection
|
|
{
|
|
//protected readonly string SqlConnectionString;
|
|
private Model.Credentials.bnhtradeDB _dbCredentials;
|
|
|
|
protected string SqlConnectionString
|
|
{
|
|
get { return _dbCredentials.ConnectionString; }
|
|
}
|
|
|
|
public Connection()
|
|
{
|
|
var config = new Config().GetConfiguration();
|
|
|
|
// attempt to retrive credentials from app.local.config
|
|
try
|
|
{
|
|
string dataSource = config.AppSettings.Settings["DbDataSource"].Value;
|
|
string userId = config.AppSettings.Settings["DbUserId"].Value;
|
|
string pass = config.AppSettings.Settings["DbUserPassword"].Value;
|
|
|
|
// check
|
|
if (string.IsNullOrEmpty(dataSource))
|
|
{
|
|
throw new ArgumentException("Could not retrive 'DbDataSource' from config file");
|
|
}
|
|
else if (string.IsNullOrEmpty(userId))
|
|
{
|
|
throw new ArgumentException("Could not retrive 'DbUserId' from config file");
|
|
}
|
|
else if (string.IsNullOrEmpty(pass))
|
|
{
|
|
throw new ArgumentException("Could not retrive 'DbUserPassword' from config file");
|
|
}
|
|
|
|
var dbCredentials = new bnhtrade.Core.Model.Credentials.bnhtradeDB(dataSource, userId, pass);
|
|
this._dbCredentials = dbCredentials;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception("Unable to retirve DB credentials: " + ex.Message);
|
|
}
|
|
}
|
|
|
|
private void ConnectionOld()
|
|
{
|
|
// attempt to retrive credentials from app.local.config
|
|
try
|
|
{
|
|
string dataSource = ConfigurationManager.AppSettings["DbDataSource"];
|
|
string userId = ConfigurationManager.AppSettings["DbUserId"];
|
|
string pass = ConfigurationManager.AppSettings["DbUserPassword"];
|
|
|
|
// check
|
|
if (string.IsNullOrEmpty(dataSource))
|
|
{
|
|
throw new ArgumentException("Could not retrive 'DbDataSource' from config file");
|
|
}
|
|
else if (string.IsNullOrEmpty(userId))
|
|
{
|
|
throw new ArgumentException("Could not retrive 'DbUserId' from config file");
|
|
}
|
|
else if (string.IsNullOrEmpty(pass))
|
|
{
|
|
throw new ArgumentException("Could not retrive 'DbUserPassword' from config file");
|
|
}
|
|
|
|
var dbCredentials = new bnhtrade.Core.Model.Credentials.bnhtradeDB(dataSource, userId, pass);
|
|
this._dbCredentials = dbCredentials;
|
|
}
|
|
catch(Exception ex)
|
|
{
|
|
throw new Exception("Unable to retirve DB credentials: " + ex.Message);
|
|
}
|
|
}
|
|
|
|
public Connection(Model.Credentials.bnhtradeDB dbCredentials)
|
|
{
|
|
// setup sql parameters
|
|
if (dbCredentials == null)
|
|
{
|
|
throw new Exception("DB credentials object is null");
|
|
}
|
|
this._dbCredentials = dbCredentials;
|
|
}
|
|
}
|
|
}
|