public string ModelToViewDescription(RepositoryRef repositoryRef) { if (repositoryRef == null) { return(Description); } string replaceString = ""; if (!string.IsNullOrEmpty(repositoryRef?.ResourcesContainerCacheRootUrl)) { replaceString = Path.Combine(repositoryRef?.ResourcesContainerCacheRootUrl, repositoryRef?.ResourcesContainer); replaceString = replaceString.Replace(@"\", @"/"); } else { if (repositoryRef.ResourcesContainerCacheRootPath != null && repositoryRef?.ResourcesContainer != null) { replaceString = Path.Combine(repositoryRef?.ResourcesContainerCacheRootPath, repositoryRef?.ResourcesContainer); replaceString = replaceString.Replace(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); } } return(Description? .Replace(repositoryRef.ResourcesContainer, replaceString)); }
public string ViewToModelDescription(RepositoryRef repositoryRef, string contentView) { if (repositoryRef == null || string.IsNullOrEmpty(contentView)) { return(contentView); } string replaceString; if (!string.IsNullOrEmpty(repositoryRef?.ResourcesContainerCacheRootUrl)) { replaceString = Path.Combine(repositoryRef?.ResourcesContainerCacheRootUrl, repositoryRef?.ResourcesContainer); replaceString = replaceString.Replace(@"\", @"/"); } else { replaceString = Path.Combine(repositoryRef?.ResourcesContainerCacheRootPath, repositoryRef?.ResourcesContainer); replaceString = replaceString.Replace(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); } return(contentView .Replace(replaceString, repositoryRef.ResourcesContainer)); }
public KntUserRepository(DbConnection singletonConnection, RepositoryRef repositoryRef) : base(singletonConnection, repositoryRef) { }
public ServiceRef(RepositoryRef repositoryRef) { RepositoryRef = repositoryRef; }
public KntSystemValuesRepository(RepositoryRef repositoryRef) : base(repositoryRef) { }
public KntUserRepository(RepositoryRef repositoryRef) : base(repositoryRef) { }
public KntFolderRepository(RepositoryRef repositoryRef) : base(repositoryRef) { }
public KntSystemValuesRepository(KntDbContext singletonContext, RepositoryRef repositoryRef) : base(singletonContext, repositoryRef) { }
public KntKAttributeRepository(RepositoryRef repositoryRef) : base(repositoryRef) { }
public KntNoteTypeRepository(KntDbContext singletonContext, RepositoryRef repositoryRef) : base(singletonContext, repositoryRef) { }
public KntSystemValuesRepository(DbConnection singletonConnection, RepositoryRef repositoryRef) : base(singletonConnection, repositoryRef) { }
public KntKAttributeRepository(DbConnection singletonConnection, RepositoryRef repositoryRef) : base(singletonConnection, repositoryRef) { }
public KntKAttributeRepository(RepositoryRef repositoryRef, bool throwKntException = false) : base(repositoryRef) { }
public KntKAttributeRepository(KntDbContext singletonContext, RepositoryRef repositoryRef) : base(singletonContext, repositoryRef) { }
public KntRepositoryBase(KntDbContext singletonConnection, RepositoryRef repositoryRef) { SingletonConnection = singletonConnection; _repositoryRef = repositoryRef; _repositoryRef.ConnectionString = singletonConnection.Database.GetConnectionString(); }
static async void LoadAppStore(Store store) { var pathApp = Application.StartupPath; var appFileConfig = Path.Combine(pathApp, "KNoteData.config"); if (!File.Exists(appFileConfig)) { // Create default repository and add link var pathData = Path.Combine(pathApp, "Data"); if (!Directory.Exists(pathData)) { Directory.CreateDirectory(pathData); } var dbFile = Path.Combine(pathData, $"knote_{SystemInformation.UserName}.db"); var pathResourcesCache = Path.Combine(pathApp, "ResourcesCache"); if (!Directory.Exists(pathResourcesCache)) { Directory.CreateDirectory(pathResourcesCache); } var r0 = new RepositoryRef { Alias = "Personal respository", ConnectionString = $"Data Source={dbFile}", Provider = "Microsoft.Data.Sqlite", Orm = "EntityFramework", ResourcesContainer = "NotesResources", ResourcesContainerCacheRootPath = pathResourcesCache, ResourcesContainerCacheRootUrl = @"file:///" + pathResourcesCache.Replace(@"\", @"/") }; var initialServiceRef = new ServiceRef(r0); var resCreateDB = await initialServiceRef.Service.CreateDataBase(SystemInformation.UserName); if (resCreateDB) { store.AddServiceRef(initialServiceRef); store.AppConfig.RespositoryRefs.Add(r0); } // Default values store.AppConfig.AutoSaveActivated = true; store.AppConfig.AutoSaveSeconds = 105; store.AppConfig.AlarmActivated = true; store.AppConfig.AlarmSeconds = 30; store.AppConfig.LastDateTimeStart = DateTime.Now; store.AppConfig.RunCounter = 1; store.AppConfig.LogFile = pathApp + @"\KNoteWinApp.log"; store.AppConfig.LogActivated = false; } else { store.LoadConfig(appFileConfig); foreach (var r in store.AppConfig.RespositoryRefs) { store.AddServiceRef(new ServiceRef(r)); } } // Set session values store.AppUserName = SystemInformation.UserName; store.ComputerName = SystemInformation.ComputerName; store.AppConfig.LastDateTimeStart = DateTime.Now; store.AppConfig.RunCounter += 1; store.SaveConfig(appFileConfig); // default folder var firstService = store.GetFirstServiceRef(); var folder = (await firstService.Service.Folders.GetHomeAsync()).Entity; store.DefaultFolderWithServiceRef = new FolderWithServiceRef { ServiceRef = firstService, FolderInfo = folder }; }
public KntRepository(RepositoryRef repositoryRef) { _repositoryRef = repositoryRef; }
// This method gets called by the runtime. Use this method to add services to the container. // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { services.AddCors(o => o.AddPolicy("KntPolicy", buider => { buider.AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader(); })); var appSettingsSection = configuration.GetSection("AppSettings"); services.Configure <AppSettings>(appSettingsSection); var appSettings = appSettingsSection.Get <AppSettings>(); var orm = configuration["ConnectionStrings:DefaultORM"]; var prov = configuration["ConnectionStrings:DefaultProvider"]; var conn = configuration["ConnectionStrings:DefaultConnection"]; var repositoryRef = new RepositoryRef { Alias = "KaNote", ConnectionString = conn, Provider = prov, Orm = orm, ResourceContentInDB = appSettings.ResourcesContentInDB, ResourcesContainer = appSettings.ResourcesContainer, ResourcesContainerCacheRootPath = appSettings.ResourcesContainerRootPath, ResourcesContainerCacheRootUrl = appSettings.ResourcesContainerRootUrl }; if (orm == "Dapper") { services.AddScoped <IKntRepository>(provider => new DP.KntRepository(repositoryRef)); } else if (orm == "EntityFramework") { services.AddScoped <IKntRepository>(provider => new EF.KntRepository(repositoryRef)); } services.AddScoped <IKntService, KntService>(); #region Doc, test // For test, use DbContext //services.AddDbContext<KntDbContext>(options => // options.UseSqlServer(configuration.GetConnectionString("DefaultConnection"))); #endregion services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) .AddJwtBearer(options => options.TokenValidationParameters = new TokenValidationParameters { ValidateIssuer = false, ValidateAudience = false, ValidateLifetime = true, ValidateIssuerSigningKey = true, IssuerSigningKey = new SymmetricSecurityKey( // Encoding.UTF8.GetBytes(configuration["jwt:key"]) Encoding.ASCII.GetBytes(appSettings.Secret) ), ClockSkew = TimeSpan.Zero }); services.AddScoped <IFileStore, LocalFileStore>(); services.AddHttpContextAccessor(); services.AddControllersWithViews().AddNewtonsoftJson(options => options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore); services.AddRazorPages(); services.AddResponseCompression(opts => { opts.MimeTypes = ResponseCompressionDefaults.MimeTypes.Concat( new[] { "application/octet-stream" }); }); }
public KntRepositoryBase(DbConnection singletonConnection, RepositoryRef repositoryRef) { SingletonConnection = singletonConnection; _repositoryRef = repositoryRef; }
public KntNoteTypeRepository(RepositoryRef repositoryRef) : base(repositoryRef) { }
public KntFolderRepository(KntDbContext singletonContext, RepositoryRef repositoryRef) : base(singletonContext, repositoryRef) { }
public KntRepository(DbConnection singletonConnection, RepositoryRef repositoryRef) : this(repositoryRef) { _db = singletonConnection; }
public KntNoteTypeRepository(DbConnection singletonConnection, RepositoryRef repositoryRef) : base(singletonConnection, repositoryRef) { }