public void _Report(_PassFailStep eStatus, string sContent) { if (!Config.bGenerateReport) { return; } string sDir = Directory.GetCurrentDirectory(); for (int i = 0; i < 3; i++) { DirectoryInfo info = Directory.GetParent(sDir); sDir = info.FullName; } // this is for VS2012 folder sturcture sDir = sDir + "\\" + Config._ReturnProjectName() + "\\_TestLog\\"; ////////sDir = sDir + "\\_TestLog\\"; if (this._DirExists(sDir)) { switch (eStatus) { case _PassFailStep.Step: sContent = "STEP: " + sContent; break; case _PassFailStep.Pass: sContent = "PASS: "******"FAIL: " + sContent; break; case _PassFailStep.Header: sContent = "##########\t\t" + sContent + "\t\t##########" + Environment.NewLine; break; case _PassFailStep.Description: sContent = "-------->" + sContent; break; } if (this._FileExists(sDir + this._ReturnDateStampYYYYMMDD() + ".txt", false) && eStatus == _PassFailStep.Header) { return; // log file already created, means Header must be added, no need to add again } File.AppendAllText(sDir + this._ReturnDateStampYYYYMMDD() + ".txt", sContent + Environment.NewLine); // create the directory using datetime stamp if it does not exist or current one size > 500K FileInfo fInfo = new FileInfo(sDir + this._ReturnDateStampYYYYMMDD() + ".txt"); if (Convert.ToInt32(fInfo.Length / 1024) > 500) { File.Delete(sDir + this._ReturnDateStampYYYYMMDD() + ".txt"); } } }
public void _Report(_PassFailStep eStatus, string sReportName, string sContent) { if (!Config.bGenerateReport) { return; } if (eStatus.Equals(_PassFailStep.Description)) { bool bThreadFinsihed = false; while (!bThreadFinsihed) { bThreadFinsihed = Config.bThreadFinsihed; _gLib._Wait(1); } ////////////Boolean bReady = false; ////////////int iTime = 0; ////////////while (!bReady && iTime < 200) ////////////{ //////////// int iMaxTry = 0; //////////// Process[] lstProcess = Process.GetProcessesByName("EXCEL"); //////////// for (int i = 0; i < 20; i++) //////////// { //////////// lstProcess = Process.GetProcessesByName("EXCEL"); //////////// Boolean xlsExists = true; //////////// if (lstProcess.Length != 0) //////////// xlsExists = true; //////////// else //////////// xlsExists = false; //////////// if (!xlsExists) //////////// iMaxTry++; //////////// _gLib._Wait(1); //////////// } //////////// if (iMaxTry == 20) //////////// bReady = true; //////////// iTime++; ////////////} ////////////_gLib._KillProcessByName("EXCEL"); ////////////////////_gLib._MsgBox("Ready to go", "-------"); } Config.bThreadFinsihed = false; string sDir_Local = Directory.GetCurrentDirectory(); string sDir_NetDrive = @"\\mercer.com\US_Data\Shared\DFL\Data1\RSS\SQA\RETIRE_STUDIO_BENCHMARK REPORTS\CUIT\"; for (int i = 0; i < 3; i++) { DirectoryInfo info = Directory.GetParent(sDir_Local); sDir_Local = info.FullName; } ////// this is for VS2012 folder sturcture sDir_Local = sDir_Local + "\\" + Config._ReturnProjectName() + "\\_TestLog\\"; //////sDir_Local = sDir_Local + "\\_TestLog\\"; if (_gLib._DirExists(sDir_Local)) { switch (eStatus) { case _PassFailStep.Step: sContent = "STEP: " + Environment.NewLine + sContent + Environment.NewLine; break; case _PassFailStep.Pass: sContent = "PASS: "******"FAIL: " + sReportName + Environment.NewLine + sContent + Environment.NewLine; break; case _PassFailStep.Header: sContent = "##########\t\t" + sContent + "\t\t##########" + Environment.NewLine; break; case _PassFailStep.Description: sContent = "-----------------> " + sContent + " <-----------------" + Environment.NewLine + Environment.NewLine; break; } if (_gLib._FileExists(sDir_Local + _gLib._ReturnDateStampYYYYMMDD() + "_" + this._sClient + "_Res.txt", false) && eStatus == _PassFailStep.Header) { return; // log file already created, means Header must be added, no need to add again } // create the directory using datetime stamp if it does not exist File.AppendAllText(sDir_Local + _gLib._ReturnDateStampYYYYMMDD() + "_" + this._sClient + "_Res.txt", sContent + Environment.NewLine); if (_gLib._FileExists(sDir_NetDrive + _gLib._ReturnDateStampYYYYMMDD() + "_" + this._sClient + "_Res.txt", false) && eStatus == _PassFailStep.Header) { return; // log file already created, means Header must be added, no need to add again } File.AppendAllText(sDir_NetDrive + _gLib._ReturnDateStampYYYYMMDD() + "_" + this._sClient + "_Res.txt", sContent + Environment.NewLine); } }