using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.IO;
namespace IDS.Rapport.Dell.Helpers
{
public class Logging
{
public static string Perform_Logging(string Data, string FileName)
{
try
{
// Get Random value for Logging
Random RandomGen = new Random();
int intRandom = Convert.ToInt32(Math.Floor(1000000 * RandomGen.NextDouble()));
string strLogFilePart = string.Empty;
string logFilePath = null;
bool logging = false;
logging = Convert.ToBoolean(ConfigurationManager.AppSettings["Logging"].ToString());
if (logging)
{
logFilePath = ConfigurationManager.AppSettings["strLogFilePath"].ToString();
strLogFilePart = DateTime.Now.ToString("s").Replace(":", "-") + " " + intRandom.ToString("000000");
File.WriteAllText(logFilePath + FileName + strLogFilePart + ".txt", Data.Trim());
}
}
catch (Exception ex)
{
//Error Logging
ErrorHandler.WriteError(ex, "Logging.cs Perform_Logging");
}
return "";
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.IO;
namespace IDS.Rapport.Dell.Helpers
{
public class Logging
{
public static string Perform_Logging(string Data, string FileName)
{
try
{
// Get Random value for Logging
Random RandomGen = new Random();
int intRandom = Convert.ToInt32(Math.Floor(1000000 * RandomGen.NextDouble()));
string strLogFilePart = string.Empty;
string logFilePath = null;
bool logging = false;
logging = Convert.ToBoolean(ConfigurationManager.AppSettings["Logging"].ToString());
if (logging)
{
logFilePath = ConfigurationManager.AppSettings["strLogFilePath"].ToString();
strLogFilePart = DateTime.Now.ToString("s").Replace(":", "-") + " " + intRandom.ToString("000000");
File.WriteAllText(logFilePath + FileName + strLogFilePart + ".txt", Data.Trim());
}
}
catch (Exception ex)
{
//Error Logging
ErrorHandler.WriteError(ex, "Logging.cs Perform_Logging");
}
return "";
}
}
}
Calling these functions:
1. Perform_Logging
Logging.Perform_Logging(RequestXmlDoc.OuterXml, "Request_Before_Posting_To_RapportDataImport");
No comments:
Post a Comment