// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddHttpContextAccessor(); services.AddDbContext <ApplicationDbContext>(options => options.UseNpgsql( Configuration.GetConnectionString("DefaultConnection"), b => b.MigrationsAssembly("ScadaIssuesPortal.Web"))); services.AddIdentity <IdentityUser, IdentityRole>(options => { options.SignIn.RequireConfirmedAccount = false; options.Password.RequireDigit = true; options.Password.RequireLowercase = true; options.Password.RequireNonAlphanumeric = true; options.Password.RequireUppercase = false; options.Password.RequiredLength = 4; options.Password.RequiredUniqueChars = 2; }) .AddEntityFrameworkStores <ApplicationDbContext>() .AddDefaultTokenProviders(); services.ConfigureApplicationCookie(options => { // configure login path for return urls // https://docs.microsoft.com/en-us/aspnet/core/security/authentication/identity?view=aspnetcore-3.1&tabs=visual-studio options.LoginPath = "/Identity/Account/Login"; options.AccessDeniedPath = "/Identity/Account/AccessDenied"; }); // Add application services. services.AddTransient <IEmailSender, EmailSender>(); // add email settings from config as a singleton service EmailConfiguration emailConfig = new EmailConfiguration(); Configuration.Bind("EmailSettings", emailConfig); services.AddSingleton(emailConfig); // add folder path settings from config as a singleton service FolderPaths folderPaths = new FolderPaths(); Configuration.Bind("FolderPaths", folderPaths); services.AddSingleton(folderPaths); // add super admin user details from config as a singleton service IdentityInit identityInit = new IdentityInit(); Configuration.Bind("IdentityInit", identityInit); services.AddSingleton(identityInit); services.AddScoped <ICurrentUserService, CurrentUserService>(); services .AddControllersWithViews() .AddNewtonsoftJson(options => { options.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; }) .AddRazorRuntimeCompilation(); services.AddRazorPages(); }
private void GetFolders(MAPIFolder folder) { try { Utils.Debug($"Try {folder.FullFolderPath}\n"); /* * We reached an end of a folder chain * There are only mails inside */ if (folder.Folders.Count == 0) { // Check if current folder path is in our FolderPaths list if (FolderPaths.Contains(folder.FullFolderPath.ToLower())) { // if contains, include it into user folders Folders.Add(folder); } } else // There are still folders inside, check them too { foreach (MAPIFolder subfolder in folder.Folders) { GetFolders(subfolder); } } } catch (System.Exception e) { Utils.Debug($"Error getting folder {e.Message}\n{e.StackTrace}"); } }
public static void RewriteFileContent(string fileName, object data, FolderPaths path) { BinaryFormatter bf = new BinaryFormatter(); FileStream file = System.IO.File.Open(UnityFile.GetFolderPath(path) + "/" + fileName, FileMode.OpenOrCreate); bf.Serialize(file, data); file.Close(); }
public CaseEditUIController(ILogger <ReportingCasesController> logger, ApplicationDbContext dbContext, UserManager <IdentityUser> userManager, IEmailSender emailSender, FolderPaths folderPaths) { _userManager = userManager; _logger = logger; _context = dbContext; _emailSender = emailSender; _folderPaths = folderPaths; }
internal static void SerializeToXML(DebugData_Barricades settings) { FolderPaths.CheckFolderExists(DefaultFolderPath); var serializer = new XmlSerializer(typeof(DebugData_Barricades)); var textWriter = new StreamWriter(DefaultFilePath); serializer.Serialize(textWriter, settings); textWriter.Close(); }
public static object GetFileContent(string fileName, FolderPaths path) { BinaryFormatter bf = new BinaryFormatter(); FileStream file = System.IO.File.Open(UnityFile.GetFolderPath(path) + "/" + fileName, FileMode.OpenOrCreate); var data = bf.Deserialize(file); file.Close(); return(data); }
public static string GetFolderPath(FolderPaths path) { switch (path) { case FolderPaths.Persistent: return(UnityEngine.Application.persistentDataPath); case FolderPaths.Cache: return(UnityEngine.Application.temporaryCachePath); default: return(""); } }
public override void Clean(Report report) { foreach (var kvp in FolderPaths.Where(kvp => Directory.Exists(kvp.Key))) { try { var folderPath = kvp.Key; var recurse = kvp.Value; MiscFunctions.DeleteDir(folderPath, recurse); report.WriteLine($"Deleted Folder: {folderPath}"); Settings.Default.lastScanErrorsFixed++; } catch (Exception ex) { string message = $"The following folder could not be removed: {kvp.Key}\nError: {ex.Message}"; Debug.WriteLine(message); } } }
public static bool Exists(string fileName, FolderPaths path) { return(System.IO.File.Exists(UnityFile.GetFolderPath(path) + "/" + fileName)); }
public void SetOptions(VFSGroupOption option) { mOption = option; GroupName = option.GroupName; foreach (var path in option.FolderPaths) { if (!path.EndsWith("/")) { string _path = path + "/"; FolderPaths.Add(_path); FolderPathsLower.Add(_path.ToLower()); } else { FolderPaths.Add(path); FolderPathsLower.Add(path.ToLower()); } } foreach (var path in option.AssetPaths) { AssetPaths.Add(path); AssetPathsLower.Add(path.ToLower()); } //忽略子目录,子目录必须是FolderPaths的子目录,这里初始化的时候过滤一下无效的配置,节省后面的运算 foreach (var path in option.IgnoreSubPath) { string _path = (path.EndsWith("/")) ? path : path + "/"; string path_lower = _path.ToLower(); foreach (var folder in FolderPathsLower) { if (VFSUtil.IsSubpath(path_lower, folder, false)) { IgnoreSubpath.Add(_path); IgnoreSubpathLower.Add(path_lower); break; } } } //忽略后缀名 foreach (var ext in option.IngnoreExtName) { IgnoreExtensionLower.Add(ext.StartsWith(".") ? ext.ToLower() : "." + ext.ToLower()); } //特殊打包规则 foreach (var rule in option.FolderSpecialBuildRules) { bool flag = true; if (rule.DevType == FolderBuildDevelopType.normal && rule.BuildType == FolderBuildType.normal) { flag = false;//这是条没必要的规则 } if (rule.FolderPath.IsNullOrEmpty() || rule.FolderPath.IsNullOrWhiteSpace()) { flag = false; } string _folder_path = (rule.FolderPath.EndsWith("/")) ? rule.FolderPath : rule.FolderPath + "/"; string _folder_lower = _folder_path.ToLower(); if (!IsSubfolderOfFolderList(_folder_path)) { flag = false; } if (flag) { var _rule = rule; _rule.FolderPath = _folder_path; var lower_rule = rule; lower_rule.FolderPath = _folder_lower; SpecialFolderBuildRules.Add(_rule); SpecialFolderBuildRulesLower.Add(lower_rule); } } }