Exemplo n.º 1
0
 public GStoreErrorInfo(ErrorPage errorPage, Exception exception, RouteData routeData, string controllerName, string actionName, string ipAddress, Models.StoreFront currentstoreFrontOrNull, string rawUrl, string url)
     : base(exception, controllerName, actionName)
 {
     this.ErrorPage = errorPage;
     this.ErrorCode = (int)errorPage;
     this.RouteDataSource = routeData.ToSourceString();
     this.IPAddress = ipAddress;
     this.CurrentstoreFrontOrNull = currentstoreFrontOrNull;
     this.RawUrl = rawUrl;
     this.Url = url;
 }
Exemplo n.º 2
0
        public static UserActionEvent LogUserActionEvent(this IGstoreDb ctx, HttpContextBase httpContext, RouteData routeData, GStoreData.ControllerBase.BaseController controller, UserActionCategoryEnum category, UserActionActionEnum action, string label, bool success, int? cartId = null, string categoryUrlName = null, string discountCode = null, string emailAddress = null, int? notificationId = null, string orderNumber = null, int? orderItemId = null, int? pageId = null, string productUrlName = null, string productBundleUrlName = null, int? blogId = null, int? blogEntryId = null, string smsPhone = null, string uploadFileName = null)
        {
            if (!Settings.AppEnableUserActionLog)
            {
                return null;
            }

            IGstoreDb newctx = ctx.NewContext();

            UserActionEvent newEvent = newctx.UserActionEvents.Create();

            string source = routeData.ToSourceString();

            string message = "User Action Event"
                + " \n-Category: " + category.ToString()
                + " \n-Action: " + action.ToString()
                + " \n-Label: " + label.ToString()
                + " \n-Success: " + success.ToString();

            newEvent.SetBasicFields(httpContext, routeData, source, message, !httpContext.User.IsRegistered(), newctx.GetCurrentUserProfile(false, false), controller);
            newEvent.CartId = cartId;
            newEvent.Category = category;
            newEvent.CategoryUrlName = categoryUrlName;
            newEvent.DiscountCode = discountCode;
            newEvent.EmailAddress = emailAddress;
            newEvent.Label = label;

            newEvent.BlogId = blogId;
            newEvent.BlogEntryId = blogEntryId;

            newEvent.NotificationId = notificationId;
            newEvent.OrderNumber = orderNumber;
            newEvent.OrderItemId = orderItemId;
            newEvent.PageId = pageId;
            newEvent.ProductUrlName = productUrlName;
            newEvent.ProductBundleUrlName = productBundleUrlName;
            newEvent.SmsPhone = smsPhone;
            newEvent.Success = success;
            newEvent.UploadFileName = uploadFileName;
            newEvent.Action = action;
            newEvent.Label = label;

            string simpleInfo = newEvent.SimpleInfo();
            System.Diagnostics.Trace.Indent();
            System.Diagnostics.Trace.WriteLine("--User Action Event: " + newEvent.SimpleInfo());
            System.Diagnostics.Trace.Unindent();

            if (Settings.AppLogUserActionEventsToDb)
            {
                try
                {
                    newctx.UserActionEvents.Add(newEvent);
                    newctx.SaveChanges();
                }
                catch (Exception ex)
                {
                    //can't save to database, attempt save to file
                    ex.LogToFile(httpContext, routeData);
                    newEvent.LogToFile(httpContext);
                }
            }
            if (Settings.AppLogUserActionEventsToFile)
            {
                newEvent.LogToFile(httpContext);
            }

            return newEvent;
        }
Exemplo n.º 3
0
        public static SmsSent LogSmsSent(this IGstoreDb ctx, HttpContextBase httpContext, RouteData routeData, GStoreData.ControllerBase.BaseController controller, string toPhone, string fromPhone, string textBody, string textSignature, bool success, string exceptionString)
        {
            IGstoreDb newctx = ctx.NewContext();

            SmsSent newLog = newctx.SmssSent.Create();
            string message = "Sms sent to '" + toPhone + "' from '" + fromPhone +"'";
            string source = "App";
            if (routeData != null)
            {
                source = routeData.ToSourceString();
            }

            newLog.SetBasicFields(httpContext, routeData, source, message, !httpContext.User.IsRegistered(), ctx.GetCurrentUserProfile(false, false), controller);

            newLog.ToPhone = toPhone.OrDefault("(blank)");
            newLog.FromPhone = fromPhone.OrDefault("(blank)");
            newLog.TextBody = textBody.OrDefault("(blank)");
            newLog.TextSignature = textSignature;
            newLog.Success = success;
            newLog.ExceptionString = exceptionString;

            string simpleInfo = newLog.SimpleInfo();
            System.Diagnostics.Trace.Indent();
            System.Diagnostics.Trace.WriteLine("--Sms Sent Event: " + newLog.SimpleInfo());
            System.Diagnostics.Trace.Unindent();

            if (Settings.AppLogSmsSentToDb)
            {
                try
                {
                    newctx.SmssSent.Add(newLog);
                    newctx.SaveChanges();
                }
                catch (Exception ex)
                {
                    //can't save to database, attempt save to file
                    ex.LogToFile(httpContext, routeData);
                    newLog.LogToFile(httpContext);
                }
            }
            if (Settings.AppLogSmsSentToFile)
            {
                newLog.LogToFile(httpContext);
            }

            return newLog;
        }
Exemplo n.º 4
0
        public static void LogToFile(this Exception ex, HttpContextBase httpContext, RouteData routeData)
        {
            string message = "Exception Log to DB Failed."
                + "  \n-Message: " + ex.Message
                + "  \n-Source: " + ex.Source
                + "  \n-TargetSiteName: " + ex.TargetSite.Name
                + "  \n-StackTrace: " + ex.StackTrace;

            //create POCO version of a system event
            SystemEvent newEvent = new SystemEvent();
            newEvent.SetDefaults(null);
            newEvent.SetBasicFields(httpContext, null, routeData.ToSourceString(), message, true, null, null);
            newEvent.Level = (int)SystemEventLevel.CriticalError;
            newEvent.LevelText = SystemEventLevel.CriticalError.ToString();
            newEvent.ExceptionMessage = ex.Message;
            newEvent.BaseExceptionMessage = ex.GetBaseException().Message;
            newEvent.BaseExceptionToString = ex.GetBaseException().Message.ToString();

            string simpleInfo = newEvent.SimpleInfo();
            System.Diagnostics.Trace.Indent();
            System.Diagnostics.Trace.WriteLine("--Logging Exception: System Event: " + newEvent.SimpleInfo());
            System.Diagnostics.Trace.Unindent();

            string folder = httpContext.Server.MapPath(GStoreFolder_LogExceptions);
            string fileName = DateTime.UtcNow.ToString("yyyy-MM-dd_hh_mm_ss_" + Guid.NewGuid().ToString()) + ".xml";
            newEvent.SaveEntityToFile(folder, fileName);
        }
Exemplo n.º 5
0
        public static FileNotFoundLog LogFileNotFound(this IGstoreDb ctx, HttpContextBase httpContext, RouteData routeData, GStoreData.ControllerBase.BaseController controller)
        {
            IGstoreDb newctx = ctx.NewContext();

            FileNotFoundLog newLog = newctx.FileNotFoundLogs.Create();
            string message = "404 File Not Found: " + httpContext.Request.RawUrl;
            string source = "App";
            if (routeData != null)
            {
                source = routeData.ToSourceString();
            }

            newLog.SetBasicFields(httpContext, routeData, source, message, !httpContext.User.IsRegistered(), ctx.GetCurrentUserProfile(false, false), controller);

            string simpleInfo = newLog.SimpleInfo();
            System.Diagnostics.Trace.Indent();
            System.Diagnostics.Trace.WriteLine("--File Not Found Event: " + newLog.SimpleInfo());
            System.Diagnostics.Trace.Unindent();

            if (Settings.AppLogFileNotFoundEventsToDb)
            {
                try
                {
                    newctx.FileNotFoundLogs.Add(newLog);
                    newctx.SaveChanges();
                }
                catch (Exception ex)
                {
                    //can't save to database, attempt save to file
                    ex.LogToFile(httpContext, routeData);
                    newLog.LogToFile(httpContext);
                }
            }
            if (Settings.AppLogFileNotFoundEventsToFile)
            {
                newLog.LogToFile(httpContext);
            }

            return newLog;
        }