private static bool ProcessWebForm_ToFile(BaseController controller, WebForm webForm, Page page) { if (controller == null) { throw new ArgumentNullException("controller"); } StoreFront storeFront = controller.CurrentStoreFrontOrThrow; if (!controller.ModelState.IsValid) { return(false); } string subject = BuildFormSubject(controller, webForm, page); string bodyText = BuildFormBodyText(controller, webForm, page, false); string virtualDir = storeFront.StoreFrontVirtualDirectoryToMap(controller.Request.ApplicationPath) + "\\Forms\\" + webForm.Name.ToFileName(); string fileDir = controller.Server.MapPath(virtualDir); if (!System.IO.Directory.Exists(fileDir)) { System.IO.Directory.CreateDirectory(fileDir); } string fileName = DateTime.UtcNow.ToFileSafeString() + System.Guid.NewGuid().ToString() + ".txt"; System.IO.File.AppendAllText(fileDir + "\\" + fileName, bodyText); return(true); }
protected string ChildRecordSummary(StoreFront storeFront, IGstoreDb db) { if (storeFront == null) { throw new ArgumentNullException("storeFront"); } if (db == null) { throw new ArgumentNullException("db"); } StringBuilder output = new StringBuilder(); int storeFrontId = storeFront.StoreFrontId; string name = storeFront.CurrentConfigOrAny() == null ? "id " + storeFront.StoreFrontId : storeFront.CurrentConfigOrAny().Name; output.AppendLine("--File and Child Record Summary for Store Front '" + name.ToHtml() + " [" + storeFrontId + "]--"); output.AppendLine("--Store Front Linked Records--"); output.AppendLine("Store Fronts: " + db.StoreFronts.Where(sf => sf.StoreFrontId == storeFrontId).Count()); output.AppendLine("Client User Roles: " + db.ClientUserRoles.Where(sf => sf.ScopeStoreFrontId == storeFrontId).Count()); output.AppendLine("Carts: " + db.Carts.Where(sf => sf.StoreFrontId == storeFrontId).Count()); output.AppendLine("Cart Items: " + db.CartItems.Where(sf => sf.StoreFrontId == storeFrontId).Count()); output.AppendLine("Cart Bundles: " + db.CartBundles.Where(sf => sf.StoreFrontId == storeFrontId).Count()); output.AppendLine("Discounts: " + db.Discounts.Where(sf => sf.StoreFrontId == storeFrontId).Count()); output.AppendLine("Nav Bar Items: " + db.NavBarItems.Where(sf => sf.StoreFrontId == storeFrontId).Count()); output.AppendLine("Notifications: " + db.Notifications.Where(sf => sf.StoreFrontId == storeFrontId).Count()); output.AppendLine("Notification Links: " + db.NotificationLinks.Where(sf => sf.StoreFrontId == storeFrontId).Count()); output.AppendLine("Pages: " + db.Pages.Where(sf => sf.StoreFrontId == storeFrontId).Count()); output.AppendLine("Page Sections: " + db.PageSections.Where(sf => sf.StoreFrontId == storeFrontId).Count()); output.AppendLine("Product Categories: " + db.ProductCategories.Where(sf => sf.StoreFrontId == storeFrontId).Count()); output.AppendLine("Products: " + db.Products.Where(sf => sf.StoreFrontId == storeFrontId).Count()); output.AppendLine("Product Bundles: " + db.ProductBundles.Where(sf => sf.StoreFrontId == storeFrontId).Count()); output.AppendLine("Product Bundle Items: " + db.ProductBundleItems.Where(sf => sf.StoreFrontId == storeFrontId).Count()); output.AppendLine("Store Bindings: " + db.StoreBindings.Where(sf => sf.StoreFrontId == storeFrontId).Count()); output.AppendLine("Store Front Configurations: " + db.StoreFrontConfigurations.Where(sf => sf.StoreFrontId == storeFrontId).Count()); output.AppendLine("User Profiles: " + db.UserProfiles.Where(sf => sf.StoreFrontId == storeFrontId).Count()); output.AppendLine("Web Form Responses: " + db.WebFormResponses.Where(sf => sf.StoreFrontId == storeFrontId).Count()); output.AppendLine("Web Form Field Responses: " + db.WebFormFieldResponses.Where(sf => sf.StoreFrontId == storeFrontId).Count()); output.AppendLine("--event logs--"); output.AppendLine("Bad Requests: " + db.BadRequests.Where(sf => sf.StoreFrontId == storeFrontId).Count()); output.AppendLine("File Not Found Logs: " + db.FileNotFoundLogs.Where(sf => sf.StoreFrontId == storeFrontId).Count()); output.AppendLine("Page View Events: " + db.PageViewEvents.Where(sf => sf.StoreFrontId == storeFrontId).Count()); output.AppendLine("Security Events: " + db.SecurityEvents.Where(sf => sf.StoreFrontId == storeFrontId).Count()); output.AppendLine("System Events: " + db.SystemEvents.Where(sf => sf.StoreFrontId == storeFrontId).Count()); output.AppendLine("User Action Events: " + db.UserActionEvents.Where(sf => sf.StoreFrontId == storeFrontId).Count()); output.AppendLine("--File System--"); string folderPath = Server.MapPath(storeFront.StoreFrontVirtualDirectoryToMap(Request.ApplicationPath)); output.AppendLine("Virtual Directory: '" + storeFront.StoreFrontVirtualDirectoryToMap(Request.ApplicationPath) + "'"); output.AppendLine("Physicial Directory: '" + folderPath + "'"); output.AppendLine("Folder Exists: " + System.IO.Directory.Exists(folderPath)); if (System.IO.Directory.Exists(folderPath)) { output.AppendLine("SubFolders: " + System.IO.Directory.EnumerateDirectories(folderPath, "*", System.IO.SearchOption.AllDirectories).Count()); output.AppendLine("Files: " + System.IO.Directory.EnumerateFiles(folderPath, "*", System.IO.SearchOption.AllDirectories).Count()); } return(output.ToString()); }