public static bool addDatabaseLogging(string level, int priority, string Text, LogState State) { int s = (int)State; if (s >= DAL.Session.LogState) { try { var log = new logging(); log.created = DateTime.Now; log.level = level; log.priority = priority; Text += " : User : "******"CheckMailReminder", "addLogin", DAL.Tools.LoggingTool.LogState.low); return(false); } } return(true); }
public void OnException(ExceptionContext filterContext) { if (filterContext.Exception != null) { logging logger = new logging() { exception_message = filterContext.Exception.Message, exception_stack_trace = filterContext.Exception.StackTrace, controller_name = filterContext.RouteData.Values["controller"].ToString(), action_name = filterContext.RouteData.Values["action"].ToString(), user_ip = filterContext.HttpContext.Request.UserHostAddress, user_id = Convert.ToInt32(HttpContext.Current.Session["UserId"]), log_time = DateTime.Now }; _entities.loggings.Add(logger); _entities.SaveChangesAsync(); filterContext.ExceptionHandled = true; //Redirect or return a view, but not both. filterContext.Result = new ViewResult() { ViewName = "InnerErrorView", }; } }
protected void Page_Load(object sender, EventArgs e) { //System.Web.Security.FormsAuthentication.SetAuthCookie("", false); String paymentID, udfAmount, tkId, result, postdate, tranid, auth, trackid, refr;//, RefId, BrTranId; String udfTempDecNo = String.Empty; String udfDeclaraTionId = String.Empty; String udfPaymentType = String.Empty; //, udf5 paymentID = string.IsNullOrEmpty(Request.Form["paymentID"]) ? "0" : Request.Form["paymentID"]; result = Request.Form["result"]; postdate = Request.Form["postdate"]; tranid = Request.Form["tranid"]; auth = Request.Form["auth"]; refr = Request.Form["ref"]; trackid = Request.Form["trackid"]; udfTempDecNo = Request.Form["udf2"]; tkId = string.IsNullOrEmpty(Request.Form["udf3"]) ? "0" : Request.Form["udf3"]; udfPaymentType = Request.Form["udf4"]; udfAmount = string.IsNullOrEmpty(Request.Form["udf1"]) ? "0" : Request.Form["udf1"]; //string data = paymentID + ":paymentID ||||| " + //result + ":result ||||| " + //postdate + ":postdate ||||| " + //tranid + ":tranid ||||| " + //auth + ":auth ||||| " + //refr + ":refr ||||| " + //trackid + ":trackid ||||| " + //udfTempDecNo + ":udfTempDecNo ||||| " + //tkId + ":tkId ||||| " + //udfPaymentType + ":udfPaymentType ||||| udfAmount:" + //udfAmount; logging log = new logging(); //log.SaveLog("NewResponse BeforeVerification", "Data =" + data, System.Diagnostics.EventLogEntryType.Information); if (!log.VerifyOnlinePaymentDetailsGCSReceiptsKnet(tkId, paymentID, udfAmount)) { KnetPayment.PayResp Pr = new KnetPayment.PayResp() { paymentID = paymentID, result = result, postdate = postdate, tranid = tranid, auth = auth, refn = refr, trackid = trackid, udf1 = udfAmount, udf3 = tkId, udf2 = udfTempDecNo, udf4 = udfPaymentType }; AH.LoggerCall <KnetPayment.PayResp>(activity, KnetPayment.LogLevel.Warn, null, tkId, "False Response - VerifyOnlinePaymentDetailsGCSReceiptsKnet", KnetPayment.ErrorAt.PaymentResp, Pr); Response.StatusCode = 404; Response.End(); } }
public static void logToDB(string message, frycz_pcdbEntities entities, string userName) { logging logging = new logging(); logging.info = message; logging.time = DateTime.Now; logging.registered_user = entities.registered_user.FirstOrDefault(u => u.login.Equals((userName))); entities.loggings.Add(logging); }
void Awake() { logging = GameObject.Find("Text").GetComponent <logging>(); antenna = GameObject.Find("AntennaObject").GetComponent <Antenna>(); antenna.DisplayNewGridEvent += OnDisplayNewGridEvent; antenna.WinEvent += OnGameOverEvent; changeColor = gameObject.GetComponent <changeColor>(); changeColor.colors = antenna.colors; SetCoord(); }
//Using reflection to construct C# object from datatable public T BindData <T>(DataTable dt) { DataRow dr = dt.Rows[0]; List <string> columns = new List <string>(); foreach (DataColumn dc in dt.Columns) { columns.Add(dc.ColumnName); } var ob = Activator.CreateInstance <T>(); var fields = typeof(T).GetFields(); foreach (var fieldInfo in fields) { if (columns.Contains(fieldInfo.Name)) { fieldInfo.SetValue(ob, dr[fieldInfo.Name]); } } var properties = typeof(T).GetProperties(); foreach (var propertyInfo in properties) { if (columns.Contains(propertyInfo.Name)) { // Fill the data into the property //Below line is to avoid exception for case - 'Object of type 'System.DBNull' cannot be converted to type 'System.Nullable`1[System.Decimal]'.' var propval = dr[propertyInfo.Name] == DBNull.Value ? null : dr[propertyInfo.Name]; logging LWS = new logging(); //Encrypting the the Token(bigint) from dataset and assigning the encrypted string to TokenId property propval = propertyInfo.Name == "TokenId" ? LWS.Encrypt(propval.ToString()) : propval; //if(propertyInfo.Name == "Amount") //{ // Convert.ToDecimal(propval) + 0.210 //} //Below line to retain decimal value as string (18,3).. Normal decimal property round off it and removes unneccesary trailing zeroes propval = propertyInfo.Name == "Amount" ? propval.ToString() : propval; propertyInfo.SetValue(ob, propval, null); } } return(ob); }
protected override void InitializeCulture() { String language = "ar-KW"; // "en-us"; logging log = new logging(); String tokenId = String.Empty; DataSet paymentDataSet = new DataSet(); try { if (Request.QueryString["TokenId"] != null) { tokenId = Request.QueryString["TokenId"].ToString(); paymentDataSet = log.getPaymentDetails(tokenId); if (paymentDataSet.Tables.Count > 0) { Session["lang"] = paymentDataSet.Tables[0].Rows[0]["lang"].ToString(); if (Session["lang"] != null) { language = Session["lang"].ToString(); } } if (language.Contains("ar") || language.Contains("Ar")) { language = "ar-KW"; Session["lang"] = "ar-KW"; } else if (language.Contains("en") || language.Contains("En")) { language = "en-us"; Session["lang"] = "en-US"; } } //Set the Culture. Thread.CurrentThread.CurrentCulture = new CultureInfo(language); Thread.CurrentThread.CurrentUICulture = new CultureInfo(language); } catch (Exception) { Thread.CurrentThread.CurrentCulture = new CultureInfo(language); Thread.CurrentThread.CurrentUICulture = new CultureInfo(language); } }
public static bool addDatabaseLogging(string level, int priority, string Text, LogState State) { int s = (int)State; if (s >= DAL.Session.LogState) { try { var log = new logging(); log.created = DateTime.Now; log.level = level; log.priority = priority; string username = DAL.Session.GetValidUser.benutzername; //if (DAL.Session.User == null) //{ // username = "******"; //} //else //{ // username = DAL.Session.User.benutzername; //} //Text += " : User : "******"Kein User abgemeldet"; Text += " : User : "******"addDatabaseLogging", "addLogin", DAL.Tools.LoggingTool.LogState.low); return(false); } } return(true); }
public static async Task <IActionResult> Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "GetLogs")] HttpRequest req, ILogger log) { try { Uri serviceEndpoint = new Uri(Environment.GetEnvironmentVariable("CosmosEndPoint")); string key = Environment.GetEnvironmentVariable("ConnectionStringCosmosDB"); DocumentClient client = new DocumentClient(serviceEndpoint, key); var collectionUrl = UriFactory.CreateDocumentCollectionUri("StapOutData", "StepOutData"); FeedOptions queryOptions = new FeedOptions { MaxItemCount = -1, EnableCrossPartitionQuery = true }; string query = $"SELECT * FROM c WHERE c.Gebruik = 'Log'"; logging result = client.CreateDocumentQuery <logging>(collectionUrl, query, queryOptions).AsEnumerable().SingleOrDefault(); return(new OkObjectResult(result.Logs)); } catch (Exception ex) { return(new StatusCodeResult(500)); } }
/// <summary> /// Logging wrapper /// </summary> /// <param name="text"></param> /// <param name="level"></param> /// <param name="colour"></param> /// <param name="noLineBreak"></param> public void log(string text, logging.loglevel level = logging.loglevel.normal, ConsoleColor colour = ConsoleColor.White, bool noLineBreak = false) { Roboto.log.log(text, level, colour, noLineBreak, false, false, false, 2); }
public static ReceiptAction IsReceiptValid(string ReceiptNumber, string Mobile, string Email, string SecurityCode) { ReceiptAction ra = new ReceiptAction(); Activity <ExternalPay> activity = new Activity <ExternalPay>() { ActivityType = ActivityType.ExtPay, }; ExternalPay ep = new ExternalPay() { TempReceiptNumber = ReceiptNumber, Mobile = Mobile, Email = Email, SecurityCode = SecurityCode }; activity.ActivityToLog = ep; ActivityHandler AH = new ActivityHandler(); try { logging Lvws = new logging(); VerifyReceiptDetailsforGCSSite Vrfr = Lvws.VerifyReceiptDetailsforGCSSite(ReceiptNumber, Mobile, Email, SecurityCode); ra.VerifyReceiptDetailsforGCSSite = Vrfr; ReceiptDetailsMinified rd = null; string TokenId = "0"; if (Vrfr.Proceed) { System.Data.DataSet ds = new System.Data.DataSet(); ds = Lvws.GetPaymentDetailsforGCSSite(ReceiptNumber, Mobile, Email, false); //to retain decimal value as string (18, 3)..Normal decimal property round off it and removes unneccesary trailing zeroes ds.Tables[0].Rows[0]["Amount"] = Convert.ToDecimal(ds.Tables[0].Rows[0]["Amount"]) + Convert.ToDecimal(0.210); GCSPayment GP = new GCSPayment(); rd = GP.BindData <ReceiptDetailsMinified>(ds.Tables[0]); TokenId = Lvws.ExplicitDecryptTokenCall(rd.TokenId); //RandomStringGenerator4DotNet is installed to get random text -- To inject false string in token RandomStringGenerator.StringGenerator RSG = new RandomStringGenerator.StringGenerator() { MinNumericChars = 1, MinLowerCaseChars = 2, MinUpperCaseChars = 1 }; string randstr = RSG.GenerateString(4); rd.TokenId = rd.TokenId.Insert(3, randstr); activity.TokenId = TokenId; } ra.ReceiptDetailsMinified = rd; AH.LoggerCall <ExternalPay>(activity, LogLevel.Info, null, TokenId, "Receipt Lookup", ErrorAt.None, ep); return(ra); } catch (Exception ex) { AH.LoggerCall <ExternalPay>(activity, LogLevel.Error, ex, "0", "Receipt Lookup", ErrorAt.ReceiptLookup, ep); VerifyReceiptDetailsforGCSSite VerifyReceiptDetailsforGCSSite = new VerifyReceiptDetailsforGCSSite() { Proceed = false, Message = "Some error has occured . Please Contact IT Team" }; ra.VerifyReceiptDetailsforGCSSite = VerifyReceiptDetailsforGCSSite; return(ra); } }
public void Log <T>(Activity <T> Activity) { try { bool AllowLog = Convert.ToBoolean(ConfigurationManager.AppSettings["AllowLog"].ToString()); bool AllowLogNotifier = Convert.ToBoolean(ConfigurationManager.AppSettings["AllowLogNotifier"].ToString()); String NLogDestination = ConfigurationManager.AppSettings["LogDestination"].ToString(); String NLogNotifyingMode = ConfigurationManager.AppSettings["LogNotifyingMode"].ToString(); string LogMode = (ConfigurationManager.AppSettings["LogMode"].ToString()); string AppName = (ConfigurationManager.AppSettings["LoggingAppName"].ToString()); if (AllowLog) { string XMLString = (Activity.ActivityToLog != null) ? XMLSerialize(Activity.ActivityToLog) : ""; string ReqLog, RespLog; Exception Ex; ReqLog = (Activity.ActivityToLog != null & (Activity.ActivityType == ActivityType.ReqLog | Activity.ActivityType == ActivityType.ExtPay)) ? XMLString : null; RespLog = (Activity.ActivityToLog != null & Activity.ActivityType == ActivityType.RespLog) ? XMLString : null; Activity.Other = (Activity.ActivityToLog != null & Activity.ActivityType == ActivityType.Other) ? XMLString : null; Ex = (Activity.ErrorAt == ErrorAt.PaymentReq | Activity.ErrorAt == ErrorAt.PaymentResp | Activity.ErrorAt == ErrorAt.ReceiptLookup) ? Activity.ex : null; ExceptionTracker et = new ExceptionTracker(); string ErrMsgDet = Ex != null?et.GetAllErrMessages(Ex) : null; LogManager.Configuration.Variables["App"].Text = AppName; LogManager.Configuration.Variables["ReqLog"].Text = ReqLog; LogManager.Configuration.Variables["RespLog"].Text = RespLog; LogManager.Configuration.Variables["Other"].Text = Activity.Other; LogManager.Configuration.Variables["ErrorAt"].Text = Activity.ErrorAt.ToString(); LogManager.Configuration.Variables["ExceptionDetails"].Text = ErrMsgDet; //ExceptionDetails; LogManager.Configuration.Variables["AdditionalInfo"].Text = Activity.AdditionalInfo; // AdditionalInfo; LogManager.Configuration.Variables["TokenId"].Text = Activity.TokenId; // TokenId; LogManager.Configuration.Variables["CustomLogger"].Text = Activity.CallingMethod; string ReqTime = (Activity.ActivityType == ActivityType.ReqLog | Activity.ActivityType == ActivityType.ExtPay) ? DateTime.Now.ToString() : null; string RespTime = (Activity.ActivityType == ActivityType.RespLog | Activity.ActivityType == ActivityType.Other) ? DateTime.Now.ToString() : null; LogManager.Configuration.Variables["ReqTime"].Text = ReqTime; LogManager.Configuration.Variables["RespTime"].Text = RespTime; NLog.Logger NLoggerD = NLog.LogManager.GetLogger(NLogDestination); //LogDestination and LogNotifyingMode passed in Activity object has been overidden here if (LogMode == "Manual") { logging l = new logging(); string URL = HttpContext.Current.Request.Url.PathAndQuery; string ExceptionType = Ex != null?Ex.GetType().ToString() : null; // Ex.GetType().ToString(); string stackTrace = Ex != null ? Ex.StackTrace : null; string InnerExceptionMessage = Ex != null ? Ex.InnerException.Message : null; string ExMessage = Ex != null ? Ex.Message : null; switch (Activity.LogLevel) { case LogLevel.Trace: //NLoggerD.Info(Activity.AdditionalInfo); l.Nlogmanual(Activity.TokenId, Enum.GetName(typeof(LogLevel), LogLevel.Info), "KnetPayment.ActivityHandler.Log", ExceptionType, stackTrace, InnerExceptionMessage, ExMessage, ReqTime, RespTime, GetHostIPAddress(), GetClientIPAddress(), URL, Activity.CallingMethod, AppName, ReqLog, RespLog, Activity.Other, Activity.ErrorAt.ToString(), ErrMsgDet, Activity.AdditionalInfo); break; case LogLevel.Debug: //NLoggerD.Debug(Activity.AdditionalInfo); l.Nlogmanual(Activity.TokenId, Enum.GetName(typeof(LogLevel), LogLevel.Debug), "KnetPayment.ActivityHandler.Log", ExceptionType, stackTrace, InnerExceptionMessage, ExMessage, ReqTime, RespTime, GetHostIPAddress(), GetClientIPAddress(), URL, Activity.CallingMethod, AppName, ReqLog, RespLog, Activity.Other, Activity.ErrorAt.ToString(), ErrMsgDet, Activity.AdditionalInfo); break; case LogLevel.Info: //NLoggerD.Info(Activity.AdditionalInfo); l.Nlogmanual(Activity.TokenId, Enum.GetName(typeof(LogLevel), LogLevel.Info), "KnetPayment.ActivityHandler.Log", ExceptionType, stackTrace, InnerExceptionMessage, ExMessage, ReqTime, RespTime, GetHostIPAddress(), GetClientIPAddress(), URL, Activity.CallingMethod, AppName, ReqLog, RespLog, Activity.Other, Activity.ErrorAt.ToString(), ErrMsgDet, Activity.AdditionalInfo); break; case LogLevel.Warn: //NLoggerD.Warn(Activity.AdditionalInfo); l.Nlogmanual(Activity.TokenId, Enum.GetName(typeof(LogLevel), LogLevel.Warn), "KnetPayment.ActivityHandler.Log", ExceptionType, stackTrace, InnerExceptionMessage, ExMessage, ReqTime, RespTime, GetHostIPAddress(), GetClientIPAddress(), URL, Activity.CallingMethod, AppName, ReqLog, RespLog, Activity.Other, Activity.ErrorAt.ToString(), ErrMsgDet, Activity.AdditionalInfo); break; case LogLevel.Error: //NLoggerD.Error(Activity.ex, Activity.AdditionalInfo); l.Nlogmanual(Activity.TokenId, Enum.GetName(typeof(LogLevel), LogLevel.Error), "KnetPayment.ActivityHandler.Log", ExceptionType, stackTrace, InnerExceptionMessage, ExMessage, ReqTime, RespTime, GetHostIPAddress(), GetClientIPAddress(), URL, Activity.CallingMethod, AppName, ReqLog, RespLog, Activity.Other, Activity.ErrorAt.ToString(), ErrMsgDet, Activity.AdditionalInfo); break; case LogLevel.Fatal: //NLoggerD.Fatal(Activity.AdditionalInfo); l.Nlogmanual(Activity.TokenId, Enum.GetName(typeof(LogLevel), LogLevel.Fatal), "KnetPayment.ActivityHandler.Log", ExceptionType, stackTrace, InnerExceptionMessage, ExMessage, ReqTime, RespTime, GetHostIPAddress(), GetClientIPAddress(), URL, Activity.CallingMethod, AppName, ReqLog, RespLog, Activity.Other, Activity.ErrorAt.ToString(), ErrMsgDet, Activity.AdditionalInfo); break; } } else if (LogMode == "NLog") { switch (Activity.LogLevel) { case LogLevel.Trace: NLoggerD.Info(Activity.AdditionalInfo); break; case LogLevel.Debug: NLoggerD.Debug(Activity.AdditionalInfo); break; case LogLevel.Info: NLoggerD.Info(Activity.AdditionalInfo); break; case LogLevel.Warn: NLoggerD.Warn(Activity.AdditionalInfo); break; case LogLevel.Error: NLoggerD.Error(Activity.ex, Activity.AdditionalInfo); break; case LogLevel.Fatal: NLoggerD.Fatal(Activity.AdditionalInfo); break; } } //FileLogger Test //NLog.Logger NLoggerFL = NLog.LogManager.GetLogger("FileLogger"); //NLoggerFL.Info(Activity.ex, Activity.AdditionalInfo + " , Exception : " + ErrMsgDet + " , " + " {ReqRespParam}", Activity.ActivityToLog); //EventLogger Test //NLog.Logger NLoggerEL = NLog.LogManager.GetLogger("EventLogger"); //NLoggerEL.Info(Activity.ex, Activity.AdditionalInfo +" , Exception : "+ ErrMsgDet+" , "+ " {ReqRespParam}", Activity.ActivityToLog); if (AllowLogNotifier)//Not implemented { LogNotifier(NLogNotifyingMode, Activity.AdditionalInfo); } //NLog.LogManager.Shutdown(); } } catch (Exception ex) { //NLog.Logger NLoggerD = NLog.LogManager.GetLogger("FileLogger"); //This is just for logging, ignore if there is any issue and proceed //NLog.Logger NLoggerFL = NLog.LogManager.GetLogger("FileLogger"); //NLoggerFL.Error(ex, Activity.AdditionalInfo + " {ReqRespParam}", Activity.ActivityToLog); } finally { //LogManager.Flush(); //LogManager.Shutdown(); } }
public void setup() { logging Logging = logging.Instance; b_logger = Logging.getLogger(this); }
public void setup() { logging Logging = logging.Instance; b = Logging.getLogger("blahhh"); }