Skip to content

Commit

Permalink
Merge pull request #13 from Slowking770/Development
Browse files Browse the repository at this point in the history
Logging
  • Loading branch information
M-Zuber committed Jan 1, 2014
2 parents 1745ed0 + 6a8128d commit 83cbaf6
Show file tree
Hide file tree
Showing 16 changed files with 548 additions and 30 deletions.
38 changes: 38 additions & 0 deletions BL/Backup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,24 @@

namespace BL
{
#region Delegate Region

public delegate void TableProgressDelegate();

public delegate void AllDataProgressDelegate();

#endregion

public class Backup
{
#region Event Members

public event TableProgressDelegate TableProgress;

public event AllDataProgressDelegate AllDataProgress;

#endregion

#region Data Members

private DirectoryInfo backupFolder = new DirectoryInfo("./Backup Files");
Expand Down Expand Up @@ -45,6 +61,26 @@ public Backup()

#endregion

#region Event Methods

private void OnTableComplete()
{
if (this.AllDataProgress != null)
{
this.AllDataProgress();
}
}

private void OnLineWritten()
{
if (this.TableProgress != null)
{
this.TableProgress();
}
}

#endregion

#region Other Methods

public void BackupData()
Expand All @@ -66,8 +102,10 @@ private void BackupTable(string tableName)
{
stwrAppend.WriteLine(dataPiece);
}
this.OnLineWritten();
}
}
this.OnTableComplete();
}

#endregion
Expand Down
26 changes: 26 additions & 0 deletions BL/ExpBL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ public void Save()
// -If so performs an update
if (drExpense != null)
{
Globals.LogFiles["BusinessLayerLog"].AddMessages(
"Updating existing expense with id of: " + this.ID,
DateTime.Today.ToString());

// Updates each field with the data in the members of the class
drExpense["AMOUNT"] = this.Amount;
drExpense["exp_DATE"] = this.Date;
Expand All @@ -86,6 +90,10 @@ public void Save()
// If a new row is being added
else
{
Globals.LogFiles["BusinessLayerLog"].AddMessages(
"Creating new expense with id of: " + this.ID,
DateTime.Today.ToString());

// Intializes the variable with an empty skeleton of the row format
// and adds in the data based on the members of the class
drExpense = Cache.SDB.t_expenses.Newt_expensesRow();
Expand All @@ -112,12 +120,24 @@ public static SortedDictionary<int, ExpBL> GetAll()
SortedDictionary<int, ExpBL> srtAllExpenses =
new SortedDictionary<int, ExpBL>();

int rowsInCache = Cache.SDB.t_expenses.Rows.Count;
int rowsPulled = 0;

// Goes over every row in the table in the cache
foreach (StaticDataSet.t_expensesRow currRow in Cache.SDB.t_expenses)
{
// Adds the row to the dictionary, creating the entity as it gets added
srtAllExpenses.Add(int.Parse(currRow["ID"].ToString()),
Load(int.Parse(currRow["ID"].ToString())));
rowsPulled++;
}

if (rowsInCache != rowsPulled)
{
Globals.LogFiles["ErrorLog"].AddError(Globals.ErrorCodes.BL_ERROR,
"The amount in the cache is:" + rowsInCache +
" but only " + rowsPulled + " expenses where pulled",
DateTime.Today);
}

// Returns the list to the calling function
Expand Down Expand Up @@ -181,6 +201,12 @@ public static ExpBL Load(int nId)
expLoadExpense.Method = Convert.ToInt32(drExpense["METHOD"].ToString());
expLoadExpense.Comment = drExpense["COMMENT"].ToString();
}
else
{
Globals.LogFiles["ErrorLog"].AddError(Globals.ErrorCodes.BL_ERROR,
"Attempt to pull non exsistent expense with an id of:" + nId,
DateTime.Today);
}

// Returns the variable to the calling function
return (expLoadExpense);
Expand Down
24 changes: 24 additions & 0 deletions BL/ExpCatBL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,18 @@ public override void Save()
// If the category already exists
if (drExpenseCat != null)
{
Globals.LogFiles["BusinessLayerLog"].AddMessages(
"Updating existing expense category with id of: " + this.ID,
DateTime.Today.ToString());
// Updates the name of the category
drExpenseCat["NAME"] = this.Name;
}
// If the category does not exist yet
else
{
Globals.LogFiles["BusinessLayerLog"].AddMessages(
"Creating new expense category with id of: " + this.ID,
DateTime.Today.ToString());
// Adds a new row to the table in the cache with the wanted Id and name
Cache.SDB.t_expenses_category.
Addt_expenses_categoryRow((uint)this.ID, this.Name);
Expand All @@ -79,12 +85,24 @@ public static SortedDictionary<int, ExpCatBL> GetAll()
SortedDictionary<int, ExpCatBL> srtAllExpensesCat =
new SortedDictionary<int, ExpCatBL>();

int rowsInCache = Cache.SDB.t_expenses_category.Rows.Count;
int rowsPulled = 0;

// Goes over every row in the table in the cache
foreach (StaticDataSet.t_expenses_categoryRow currRow in Cache.SDB.t_expenses_category)
{
// Adds the row to the dictionary, creating the entity as it gets added
srtAllExpensesCat.Add(int.Parse(currRow["ID"].ToString()),
Load(int.Parse(currRow["ID"].ToString())));
rowsPulled++;
}

if (rowsInCache != rowsPulled)
{
Globals.LogFiles["ErrorLog"].AddError(Globals.ErrorCodes.BL_ERROR,
"The amount in the cache is:" + rowsInCache +
" but only " + rowsPulled + " expense categories where pulled",
DateTime.Today);
}

// Returns the list to the calling function
Expand Down Expand Up @@ -145,6 +163,12 @@ public static ExpCatBL Load(int nId)
// Sets the name property based on the data in the row
expLoadExpenseCat.Name = drExpenseCat["NAME"].ToString();
}
else
{
Globals.LogFiles["ErrorLog"].AddError(Globals.ErrorCodes.BL_ERROR,
"Attempt to pull non exsistent expense category with an id of:" + nId,
DateTime.Today);
}

// Returns the variable to the calling function
return (expLoadExpenseCat);
Expand Down
2 changes: 1 addition & 1 deletion BL/GlobalBL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public class GlobalBL
public static void IntializeData()
{
// Loads all the tables one at a time -but in the appropiate order
BaseDA.LoadToCache();
GlobalBL.LoadToCache();

// Intializes variables with values for new ids
BaseDA.SetNewIdStart();
Expand Down
26 changes: 26 additions & 0 deletions BL/IncBL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ public void Save()
// -If so performs an update
if (drIncome != null)
{
Globals.LogFiles["BusinessLayerLog"].AddMessages(
"Updating existing income with id of: " + this.ID,
DateTime.Today.ToString());

// Updates each field with the data in the members of the class
drIncome["AMOUNT"] = this.Amount;
drIncome["INC_DATE"] = this.Date;
Expand All @@ -86,6 +90,10 @@ public void Save()
// If a new row is being added
else
{
Globals.LogFiles["BusinessLayerLog"].AddMessages(
"Creating new income with id of: " + this.ID,
DateTime.Today.ToString());

// Intializes the variable with an empty skeleton of the row format
// and adds in the data based on the members of the class
drIncome = Cache.SDB.t_incomes.Newt_incomesRow();
Expand All @@ -112,12 +120,24 @@ public static SortedDictionary<int, IncBL> GetAll()
SortedDictionary<int, IncBL> srtAllIncomes =
new SortedDictionary<int, IncBL>();

int rowsInCache = Cache.SDB.t_incomes.Rows.Count;
int rowsPulled = 0;

// Goes over every row in the table in the cache
foreach (StaticDataSet.t_incomesRow currRow in Cache.SDB.t_incomes)
{
// Adds the row to the dictionary, creating the entity as it gets added
srtAllIncomes.Add(int.Parse(currRow["ID"].ToString()),
Load(int.Parse(currRow["ID"].ToString())));
rowsPulled++;
}

if (rowsInCache != rowsPulled)
{
Globals.LogFiles["ErrorLog"].AddError(Globals.ErrorCodes.BL_ERROR,
"The amount in the cache is:" + rowsInCache +
" but only " + rowsPulled + " incomes where pulled",
DateTime.Today);
}

// Returns the list to the calling function
Expand Down Expand Up @@ -181,6 +201,12 @@ public static IncBL Load(int nId)
incLoadInc.Method = Convert.ToInt32(drExpense["METHOD"].ToString());
incLoadInc.Comment = drExpense["COMMENT"].ToString();
}
else
{
Globals.LogFiles["ErrorLog"].AddError(Globals.ErrorCodes.BL_ERROR,
"Attempt to pull non exsistent income with an id of:" + nId,
DateTime.Today);
}

// Returns the variable to the calling function
return (incLoadInc);
Expand Down
26 changes: 26 additions & 0 deletions BL/IncCatBL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,20 @@ public override void Save()
// If the category already exists
if (drIncomeCat != null)
{
Globals.LogFiles["BusinessLayerLog"].AddMessages(
"Updating existing income category with id of: " + this.ID,
DateTime.Today.ToString());

// Updates the name of the category
drIncomeCat["NAME"] = this.Name;
}
// If the category does not exist yet
else
{
Globals.LogFiles["BusinessLayerLog"].AddMessages(
"Creating new income category with id of: " + this.ID,
DateTime.Today.ToString());

// Adds a new row to the table in the cache with the wanted Id and name
Cache.SDB.t_incomes_category.
Addt_incomes_categoryRow(this.ID, this.Name);
Expand All @@ -79,12 +87,24 @@ public static SortedDictionary<int, IncCatBL> GetAll()
SortedDictionary<int, IncCatBL> srtAllIncomesCat =
new SortedDictionary<int, IncCatBL>();

int rowsInCache = Cache.SDB.t_incomes_category.Rows.Count;
int rowsPulled = 0;

// Goes over every row in the table in the cache
foreach (StaticDataSet.t_incomes_categoryRow currRow in Cache.SDB.t_incomes_category)
{
// Adds the row to the dictionary, creating the entity as it gets added
srtAllIncomesCat.Add(int.Parse(currRow["ID"].ToString()),
Load(int.Parse(currRow["ID"].ToString())));
rowsPulled++;
}

if (rowsInCache != rowsPulled)
{
Globals.LogFiles["ErrorLog"].AddError(Globals.ErrorCodes.BL_ERROR,
"The amount in the cache is:" + rowsInCache +
" but only " + rowsPulled + " income categories where pulled",
DateTime.Today);
}

// Returns the list to the calling function
Expand Down Expand Up @@ -145,6 +165,12 @@ public static IncCatBL Load(int nId)
// Sets the name property based on the data in the row
incLoadIncCat.Name = drIncomeCat["NAME"].ToString();
}
else
{
Globals.LogFiles["ErrorLog"].AddError(Globals.ErrorCodes.BL_ERROR,
"Attempt to pull non exsistent expense with an id of:" + nId,
DateTime.Today);
}

// Returns the variable to the calling function
return (incLoadIncCat);
Expand Down
26 changes: 26 additions & 0 deletions BL/MethodBL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,20 @@ public override void Save()
// If the category already exists
if (drMethods != null)
{
Globals.LogFiles["BusinessLayerLog"].AddMessages(
"Updating existing payment method with id of: " + this.ID,
DateTime.Today.ToString());

// Updates the name of the category
drMethods["NAME"] = this.Name;
}
// If the category does not exist yet
else
{
Globals.LogFiles["BusinessLayerLog"].AddMessages(
"Creating new payment method with id of: " + this.ID,
DateTime.Today.ToString());

// Adds a new row to the table in the cache with the wanted Id and name
Cache.SDB.t_payment_methods.
Addt_payment_methodsRow(this.Name);
Expand All @@ -79,12 +87,24 @@ public static SortedDictionary<int, MethodBL> GetAll()
SortedDictionary<int, MethodBL> srtAllMethods =
new SortedDictionary<int, MethodBL>();

int rowsInCache = Cache.SDB.t_payment_methods.Rows.Count;
int rowsPulled = 0;

// Goes over every row in the table in the cache
foreach (StaticDataSet.t_payment_methodsRow currRow in Cache.SDB.t_payment_methods)
{
// Adds the row to the dictionary, creating the entity as it gets added
srtAllMethods.Add(int.Parse(currRow["ID"].ToString()),
Load(int.Parse(currRow["ID"].ToString())));
rowsPulled++;
}

if (rowsInCache != rowsPulled)
{
Globals.LogFiles["ErrorLog"].AddError(Globals.ErrorCodes.BL_ERROR,
"The amount in the cache is:" + rowsInCache +
" but only " + rowsPulled + " payment methods where pulled",
DateTime.Today);
}

// Returns the list to the calling function
Expand Down Expand Up @@ -145,6 +165,12 @@ public static MethodBL Load(int nId)
// Sets the name property based on the data in the row
mthLoadMethod.Name = drMethod["NAME"].ToString();
}
else
{
Globals.LogFiles["ErrorLog"].AddError(Globals.ErrorCodes.BL_ERROR,
"Attempt to pull non exsistent expense with an id of:" + nId,
DateTime.Today);
}

// Returns the variable to the calling function
return (mthLoadMethod);
Expand Down
Loading

0 comments on commit 83cbaf6

Please sign in to comment.