public void AddUserConf(string email, string id) { UserConf model = new UserConf(); model.Email = email; model.IdInAspNetUsers = id; _context.UserConfs.Add(model); Save(); }
static async Task Main() { InitLogging(); try { Assembly assembly = Assembly.GetExecutingAssembly(); FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location); Log.Information("[b2clone v{0}]", fileVersionInfo.ProductVersion); Console.Title = $"[b2clone v{fileVersionInfo.ProductVersion}]"; if (!File.Exists(userConfPath)) { Log.Information("User configuration file does not exists."); Log.Information("A new template has been auto generated. Edit {0} as required.", userConfPath); await File.WriteAllTextAsync(userConfPath, JsonConvert.SerializeObject(new UserConf(true), Formatting.Indented)); End(); } UserConf userConf = JsonConvert.DeserializeObject <UserConf>(File.ReadAllText(userConfPath)); if (userConf != null) { B2Lib b2Lib = new B2Lib(userConf.KeyId, userConf.ApplicationId, userConf.BucketId); foreach (KeyValuePair <string, string> pathKeyPair in userConf.PathMapper) { await b2Lib.ScanFolderForUploads(pathKeyPair.Value, pathKeyPair.Key); } await b2Lib.StartUploading(); } else { throw new Exception("Unable to read user configuration. Please check again your configuration file."); } Log.CloseAndFlush(); End(); } catch (Exception e) { Log.Fatal(e.ToString()); } }