//fixedLen = Maximum length of that field
//val = value to be shown
//Say, fixedLen = 20 [datatype in DB.table.Col = Varchar(20)]
//& say, val = “Ruaha” Then there we are addaing 20-5=15 spaces after ruaha
//Making it “ruaha “
//So that presentation in the table format in corr. Text file remains nice.
public static string FormatedSpace(string val, int fixedLen)
{
int len = 0;
string retVal = string.Empty;
try
{
len = val.Length;
retVal = val;
for (int cnt = 0; cnt < fixedLen – len – 1; cnt++)
{
retVal = retVal + ” “;
}
}
catch (Exception)
{
throw;
}
return retVal;
}
private void CreateExceptionLog(DataSet ds)
{
StreamWriter swExceptionLog =
null;
try
{
swExceptionLog = new
StreamWriter(Constants.BLL_EXC_LOG_PATH
+ Constants.BLL_EXC_LOG_FILE,
true);
swExceptionLog.WriteLine(“Exceptional data recorded
on dated : “ + DateTime.Now);
swExceptionLog.WriteLine(“—————————————————————————-“);
swExceptionLog.WriteLine(“Sl.No.\tDebtorID\t\tAccounts\tPlanID\t\tObligationNo”);//heading
swExceptionLog.WriteLine(“—— ——————– ———- ———— ————“);
for (int intCnt
= 0; intCnt <= ds.Tables[0].Rows.Count – 1; intCnt++)//Each occurrence => each row
{
swExceptionLog.WriteLine(Utility.FormatedSpace(Convert.ToString(intCnt + 1), 6) + “\t”
+ Utility.FormatedSpace(Convert.ToString(ds.Tables[0].Rows[intCnt][“debtor_id”]), 20) + “\t”
+ Utility.FormatedSpace(Convert.ToString(ds.Tables[0].Rows[intCnt][“id”]), 10) + “\t”
+ Utility.FormatedSpace(Convert.ToString(ds.Tables[0].Rows[intCnt][“ipp_number”]), 11) + “\t”
+ Utility.FormatedSpace(Convert.ToString(ds.Tables[0].Rows[intCnt][“ObligationNo”]), 11));
}
swExceptionLog.WriteLine(“============================================================================”);
swExceptionLog.WriteLine();
}
catch (Exception)
{
throw;
}
finally
{
swExceptionLog.Flush();
swExceptionLog.Close();
}
}
//Output: