public bool Apply(Guid? id) { if (id == null) return false; using (BaseDbContext db = new BaseDbContext()) { try { var activityOperation = db.ActivityOperations.Find(id); if (activityOperation == null) return false; id = Guid.NewGuid(); ActivityOperation = activityOperation; ActionTime = DateTime.Now; Receiver = db.Users.Find(HttpContext.Current.User.Identity.GetUserId()); RemarkContent = ""; RemarkRate = RemarkType.None; Time = new DateTime(2000, 1, 1, 0, 0, 0); ActivityOperation.Count++; db.ActivityRecords.Add(this); db.SaveChanges(); return true; } catch { return false; } } }
public static Material Create(string description, MaterialType type, HttpPostedFileBase file, BaseDbContext db) { if (!type.Match(file)) return null; string uploadFileName = DateTime.Now.ToString("yyyyMMddHHmmss") + Path.GetExtension(file.FileName); string absolutFileName; switch (type) { case MaterialType.Identity: absolutFileName = HttpContext.Current.Server.MapPath("~/UserUpload/") + "Identity/" + uploadFileName; break; case MaterialType.Avatar: absolutFileName = HttpContext.Current.Server.MapPath("~/UserUpload/") + "Avatar/" + uploadFileName; break; default: absolutFileName = HttpContext.Current.Server.MapPath("~/UserUpload/") + "Administrator/" + uploadFileName; break; } //执行上传 if (File.Exists(absolutFileName)) { File.Delete(absolutFileName); } file.SaveAs(absolutFileName); Material material = new Material(uploadFileName, description, type); //添加Material记录 db.Materials.Add(material); //保存更改 db.SaveChanges(); return db.Materials.Find(material.Id); }
public void CreateTutorInformation(User tutor, ITutor information) { Message = ""; Succeed = false; using (var db = new BaseDbContext()) { var contextUser = db.Users.Find(tutor.Id); if (contextUser == null) { Message = "未能从数据库中找到用户"; return; } var info = new TutorInformation { Tutor = contextUser, Introduction = information.TutorIntroduction, Position = information.TutorPosition, Avatar = information.TutorAvatar }; db.TutorInformations.Add(info); try { db.SaveChanges(); } catch (Exception) { Message = "出现错误"; return; } Succeed = true; return; } }
public void NewActivity(BaseDbContext db) { Id = Guid.NewGuid(); Creator = db.Users.Find(Extensions.GetUserId()); Time = DateTime.Now; Enabled = true; Count = 0; }
public Message(string title, string content, string userId, MessageType type, BaseDbContext db) { ID = Guid.NewGuid(); Publisher = Extensions.GetContextUser(db); Receiver = db.Users.Find(userId); Title = title; Content = content; Type = type; HaveRead = false; Time = DateTime.Now; }
public static List<ActivityOperation> List(string select, bool IsAdministrator) { using (BaseDbContext db = new BaseDbContext()) { try { int pageSize = 5; int page = 0; IQueryable<ActivityOperation> Activity = db.ActivityOperations.Where(a => a.Enabled != false); if (IsAdministrator) { var user = db.Users.Find(HttpContext.Current.User.Identity.GetUserId()); if (select == null | select == "") { Activity = (from a in db.ActivityOperations where a.Creator.Id == user.Id orderby a.Name select a).AsQueryable(); } else { Activity = (from a in db.ActivityOperations where a.Creator.Id == user.Id && a.Name == @select orderby a.Name select a).AsQueryable(); } } else { if (select == null) { Activity = (from a in db.ActivityOperations where a.StartTime > DateTime.Now orderby a.Time select a).AsQueryable(); } else { Activity = (from a in db.ActivityOperations where a.Name == @select && a.StartTime > DateTime.Now orderby a.Time select a).AsQueryable(); } } var paginatedNews = new ListPage<ActivityOperation>(Activity, page, pageSize); return paginatedNews; } catch { return db.ActivityOperations.ToList(); } } }
public ActionResult RecordList() { using (BaseDbContext db = new BaseDbContext()) { User user = db.Users.Find(User.Identity.GetUserId()); var educations = user.Education; var works = user.Work; educations.OrderBy(e => e.DegreeType); ViewBag.Educations = educations; ViewBag.Works = works; return View(); } }
public bool Remark() { using (BaseDbContext db = new BaseDbContext()) { try { Time = DateTime.Now; db.Entry(this).State = EntityState.Modified; db.SaveChanges(); return true; } catch { return false; } } }
public static bool Update([Bind(Include = "Id,Usable,Location,Name,StartTime,EndTime,Content,State")] RoomOperation RoomOperation) { using (BaseDbContext db = new BaseDbContext()) { try { RoomOperation.Time = DateTime.Now; db.Entry(RoomOperation).State = EntityState.Modified; db.SaveChanges(); if (db.RoomOperations.Find(RoomOperation.Id) != null) return true; return false; } catch { return false; } } }
public bool Delete() { using (BaseDbContext db = new BaseDbContext()) { try { Enabled = false; db.Entry(this).State = EntityState.Modified; db.SaveChanges(); if (this.Enabled == false) return true; return false; } catch { return false; } } }
public bool Edit() { using (BaseDbContext db = new BaseDbContext()) { try { Time = DateTime.Now; db.Entry(this).State = EntityState.Modified; db.SaveChanges(); if (db.CourseOperations.Find(Id) != null) if (db.CourseOperations.Find(Id) == this) return true; return false; } catch { return false; } } }
public static bool Delete(Guid id) { using (BaseDbContext db = new BaseDbContext()) { try { RoomOperation RoomOperation = db.RoomOperations.Find(id); RoomOperation.Enabled = false; db.Entry(RoomOperation).State = EntityState.Modified; db.SaveChanges(); if (RoomOperation.Enabled == false) return true; return false; } catch { return false; } } }
public bool Edit() { using (BaseDbContext db = new BaseDbContext()) { //try //{ Time = DateTime.Now; Usable = true; db.Entry(this).State = EntityState.Modified; db.SaveChanges(); if (db.RoomOperations.Find(Id) != null) return true; return false; //} //catch (Exception e) //{ // return false; //} } }
public bool Delete(ref BaseDbContext db) { try { Enabled = false; if (!db.RoomOperations.Local.Contains(this)) { db.RoomOperations.Attach(this); } var listRecord = (db.RoomRecords.Where(r => r.RoomOperation.Id == Id)); foreach (RoomRecord roomRecord in listRecord.ToList()) { db.Messages.Add(new Message(roomRecord.Receiver, roomRecord.RoomOperation.Name, MessageType.System, MessageTemplate.RoomDelete, ref db)); db.RoomRecords.Remove(roomRecord); } db.RoomOperations.Remove(this); db.SaveChanges(); return true; } catch { return false; } }
public bool Create() { using (BaseDbContext db = new BaseDbContext()) { try { Id = Guid.NewGuid(); Time = DateTime.Now; Usable = true; Enabled = true; Creator = db.Users.Find(HttpContext.Current.User.Identity.GetUserId()); db.RoomOperations.Add(this); db.SaveChanges(); var Room = db.RoomOperations.Find(Id); if (Room != null) return true; return false; } catch { return false; } } }
protected override void Dispose(bool disposing) { if (disposing && _userManager != null) { _userManager.Dispose(); _userManager = null; } if (db != null) { db.Dispose(); db = null; } base.Dispose(disposing); }
public ActionResult AddWorkRecord(WorkRecord workRecord) { using (BaseDbContext db = new BaseDbContext()) { if (ModelState.IsValid) { workRecord.Id = Guid.NewGuid(); if (db.Users.Find(User.Identity.GetUserId()).Work == null) db.Users.Find(User.Identity.GetUserId()).Work = new System.Collections.Generic.List<WorkRecord>(); db.Users.Find(User.Identity.GetUserId()).Work.Add(workRecord); db.SaveChanges(); return RedirectToAction("Index", new { Message = ManageMessageId.AddWorkSuccess }); } } return RedirectToAction("Index", new { Message = ManageMessageId.Error }); }
public bool Apply(Guid Id) { using (BaseDbContext db = new BaseDbContext()) { try { CourseOperation = db.CourseOperations.Find(Id); Id = Guid.NewGuid(); ActionTime = DateTime.Now; Receiver = db.Users.Find(HttpContext.Current.User.Identity.GetUserId()); RemarkContent = ""; RemarkRate = RemarkType.None; Time = new DateTime(2000, 1, 1, 0, 0, 0); CourseOperation.Count++; CourseOperation.Students.Add(Receiver); db.CourseRecords.Add(this); db.SaveChanges(); return true; } catch { return false; } } }
public bool Quit(Guid? id) { if (id == null) return false; using (BaseDbContext db = new BaseDbContext()) { try { if (ActivityOperation.Id != id) return false; var activityOperation = db.ActivityOperations.Find(id); var contextRecord = db.ActivityRecords.Find(Id); var user = db.Users.Find(HttpContext.Current.User.Identity.GetUserId()); activityOperation.Count--; if (activityOperation.Records != null) { activityOperation.Records.Remove(contextRecord); } db.ActivityRecords.Remove(contextRecord); db.SaveChanges(); return true; } catch { return false; } } }
public CompositeKeyFieldsRepository(BaseDbContext dbContext) : base(dbContext) { }
public static List<RoomOperation> List(string select, bool IsTeacher) { using (BaseDbContext db = new BaseDbContext()) { try { //模拟触发器 foreach (RoomOperation roomOperation in db.RoomOperations) { if (DateTime.Now > roomOperation.EndTime) { roomOperation.StartTime.AddDays(7.0); roomOperation.EndTime.AddDays(7.0); roomOperation.Usable = true; } } db.SaveChanges(); int pageSize = 5; int page = 0; IQueryable<RoomOperation> Room = db.RoomOperations.Where(a => a.Enabled != false); if (IsTeacher) { var user = db.Users.Find(HttpContext.Current.User.Identity.GetUserId()); if (select == null | select == "") { Room = (from a in db.RoomOperations where a.Creator.Id == user.Id orderby a.Name select a).AsQueryable(); } else { Room = (from a in db.RoomOperations where a.Creator.Id == user.Id && a.Name == @select orderby a.Name select a).AsQueryable(); } } else { if (select == null) { Room = (from a in db.RoomOperations where a.StartTime > DateTime.Now orderby a.Time select a).AsQueryable(); } else { Room = (from a in db.RoomOperations where a.Name == @select && a.StartTime > DateTime.Now orderby a.Time select a).AsQueryable(); } } var paginatedNews = new ListPage<RoomOperation>(Room, page, pageSize); return paginatedNews; } catch { return db.RoomOperations.ToList(); } } }
public static bool Remark([Bind(Include = "Id,ActionTime,RemarkContent,RemarkRate,Time")] RoomRecord RoomRecord) { using (BaseDbContext db = new BaseDbContext()) { try { User user = db.Users.Find(HttpContext.Current.User.Identity.GetUserId()); RoomRecord.RoomOperation = db.RoomOperations.First(t => t.Creator == user); RoomRecord.Time = DateTime.Now; db.Entry(RoomRecord).State = EntityState.Modified; db.SaveChanges(); return true; } catch { return false; } } }
protected Repository(BaseDbContext context) { _context = context; _repo = _context.Set <T>(); }
public PostRepository(BaseDbContext dbContext) : base(dbContext) { }
public H_ElementRepository(BaseDbContext dbContext) : base(dbContext) { }
public MagazineRepository(BaseDbContext dbContext) : base(dbContext) { }
public AccountRepository(BaseDbContext dbContext) : base(dbContext) { }
public VtTripRepository(BaseDbContext dbContext) : base(dbContext) { }
/// <inheritdoc /> public DefaultRepositorySpatial(BaseDbContext <Guid> context) : base(context) { }
public GalleryController(BaseDbContext context) { _context = context; _pageItems = Convert.ToInt16(WebConfigurationManager.AppSettings.Get("PageItems")); }
public void NewProject(BaseDbContext db) { Id = Guid.NewGuid(); Admin = db.Users.Find(Extensions.GetCurrentUser().Id); Time = DateTime.Now; Status = ProjectStatus.ToApprove; }
/// <summary> /// Configure EF Core as repository implementation. /// This methods uses a single DbContext for all repositories /// </summary> /// <param name="bootstrapper">Bootstrapper instance</param> /// <param name="dbContext">Instance of BaseDbContext to use</param> /// <param name="options">Custom options to use of using EF.</param> public static Bootstrapper UseEFCoreAsMainRepository(this Bootstrapper bootstrapper, BaseDbContext dbContext, EFCoreOptions options = null) { if (dbContext == null) { throw new ArgumentNullException(nameof(dbContext)); } InitializeBootstrapperService( bootstrapper, (ctx) => { if (ctx.IsServiceRegistered(BootstrapperServiceType.IoC)) { var entities = ReflectionTools.GetAllTypes() .Where(t => typeof(IPersistableEntity).IsAssignableFrom(t)).ToList(); foreach (var item in entities) { var efRepoType = typeof(EFRepository <>).MakeGenericType(item); var dataReaderRepoType = typeof(IDataReaderRepository <>).MakeGenericType(item); var databaseRepoType = typeof(IDatabaseRepository <>).MakeGenericType(item); var dataUpdateRepoType = typeof(IDataUpdateRepository <>).MakeGenericType(item); bootstrapper.AddIoCRegistration(new InstanceTypeRegistration(dbContext, dbContext.GetType())); bootstrapper .AddIoCRegistration(new FactoryRegistration(() => efRepoType.CreateInstance(dbContext), efRepoType, dataUpdateRepoType, databaseRepoType, dataReaderRepoType)); } } }, options); return(bootstrapper); }
public OutboxAccessor(BaseDbContext <T> context) { dbContext = context; }
public CommentVoteRepository(BaseDbContext dbContext) : base(dbContext) { }
public bool Apply(Guid Id) { using (BaseDbContext db = new BaseDbContext()) { try { var roomOperation = db.RoomOperations.Find(Id); if (roomOperation == null) return false; Id = Guid.NewGuid(); RoomOperation = roomOperation; ActionTime = DateTime.Now; Receiver = db.Users.Find(HttpContext.Current.User.Identity.GetUserId()); RemarkContent = ""; RemarkRate = RemarkType.None; Time = new DateTime(2000, 1, 1, 0, 0, 0); RoomOperation.Usable = false; db.RoomRecords.Add(this); db.SaveChanges(); return true; } catch { return false; } } }
public override IRepository GetRepository(BaseDbContext baseDbContext) => new PostgreSqlRepository(baseDbContext);
public GetExamsQuery(ILogger logger, BaseDbContext dbContext) : base(logger, dbContext) { }
public KeyRelationshipsRepository(BaseDbContext dbContext) : base(dbContext) { }
public static List<CourseOperation> List(string select, bool IsTeacher,User user) { using (BaseDbContext db = new BaseDbContext()) { try { int pageSize = 5; int page = 0; IQueryable<CourseOperation> Course = db.CourseOperations.Where(a => a.Enabled != false); if (IsTeacher) { user = db.Users.Find(user.Id); if (select == null | select == "") { Course = (from a in db.CourseOperations where a.Creator.Id == user.Id orderby a.Name select a).AsQueryable(); } else { Course = (from a in db.CourseOperations where a.Creator.Id == user.Id && a.Name == @select orderby a.Name select a).AsQueryable(); } } else { if (select == null) { Course = (from a in db.CourseOperations where a.StartTime > DateTime.Now orderby a.Time select a).AsQueryable(); } else { Course = (from a in db.CourseOperations where a.Name == @select && a.StartTime > DateTime.Now orderby a.Time select a).AsQueryable(); } } var paginatedNews = new ListPage<CourseOperation>(Course, page, pageSize); return paginatedNews; } catch { return null; } } }
public GetMasterListController(BaseDbContext ctx) : base(ctx, "GetMasterList", "MasterId", typeof(Master)) { }
private void SaveNoteButton_Click(object sender, RoutedEventArgs e) { try { string rtbText = new TextRange(NoteRichTextBox.Document.ContentStart, NoteRichTextBox.Document.ContentEnd).Text; //string to save to db TextRange textRange = new TextRange(NoteRichTextBox.Document.ContentStart, NoteRichTextBox.Document.ContentEnd); var text = textRange.Text; if (text.Length < 4000) { if (rtbText != "\r\n") { var dbContext = new BaseDbContext(); var unitOfWork = new UnitOfWork(dbContext); var user = unitOfWork.UserRepository.Entities .FirstOrDefault(n => n.Login == Login); string date = Convert.ToDateTime(DateNote.Text).ToString("yyyy-MM-dd"); DateTime selDate = Convert.ToDateTime(DateNote.Text); var Oldnote = unitOfWork.NoteRepository.Entities .FirstOrDefault(b => (b.User.Login == Login) && (b.Date == selDate)); if (Oldnote != null) { Oldnote.Text = Oldnote.Text + "------------------------------------------------------------------------\n" + rtbText; var res = MessageBox.Show("Заметка на данную дату уже была создана. Дополнить ее?", "Дополнение заметки", MessageBoxButton.YesNo, MessageBoxImage.Question); if (res == MessageBoxResult.Yes) { unitOfWork.Commit(); } } else { var note = new Note() { Date = Convert.ToDateTime(date), Id_User = user.Id, Text = rtbText }; unitOfWork.NoteRepository.Add(note); unitOfWork.Commit(); for (int i = 0; i < a; i++) { var attPhoto = new AttPhoto { Path = Locations[i], Id_Note = note.Id_Note }; unitOfWork.PhotosRepository.Add(attPhoto); unitOfWork.Commit(); } a = 0; // чтобы можно было добавить фотографии к заметке на другой день сразу после добавления на текущий Locations.Clear(); firstImg.Source = null; secImg.Source = null; thirdImg.Source = null; firstImg.IsEnabled = true; secImg.IsEnabled = true; thirdImg.IsEnabled = true; MessageBox.Show("Добавлена новая заметка"); } } else { MessageBox.Show("Не было введено текста"); } } else { MessageBox.Show("Было введено слишком много символов!", "Превышение количества символов", MessageBoxButton.OK, MessageBoxImage.Exclamation); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public async Task <User> ValidateAsync(LoginModel model, HttpContext httpContext, BaseDbContext DataContext) { var user = await DataContext.Users .Include(u => u.Role) .FirstOrDefaultAsync(u => u.Phone == model.Phone && u.Password == model.Password); return(user ?? null); }
public ActionResult UserProfile(Profile model) { if (ModelState.IsValid) { using (BaseDbContext db = new BaseDbContext()) { db.Users.Find(User.Identity.GetUserId()).Profile = model; db.SaveChanges(); } TempData["Alert"] = "修改成功!"; return View(); } return RedirectToAction("Index", new { Message = ManageMessageId.Error }); }
public ConfirmEmailCommand(ILogger logger, BaseDbContext dbContext, SendEmailCommand sendEmailCommand) : base(logger, dbContext) { _sendEmailCommand = sendEmailCommand; }
private bool HasIdentitied() { using (BaseDbContext db = new BaseDbContext()) { return db.Users.Find(User.Identity.GetUserId()).Identitied; } }
/// <summary> /// Dispatches all integration events for Entities that are being tracked by EF Core. /// </summary> /// <param name="mediator"><see cref="IMediator"/> for publishing Domain Events as <see cref="INotification"/></param> /// <param name="ctx">Instance of <see cref="BaseDbContext"/></param> public static async Task DispatchIntegrationEventsAsync(this IMediator mediator, BaseDbContext ctx) { // Get all Entities in the ChangeTracker that have Integration Events. var integrationEntities = ctx.ChangeTracker .Entries <Entity>() .Where(x => x.Entity.IntegrationEvents != null && x.Entity.IntegrationEvents.Any()) .ToList(); if (!integrationEntities.Any()) { return; } // Merge all domain events into new List. var integrationEvents = integrationEntities .SelectMany(x => x.Entity.IntegrationEvents) .ToList(); // Clear out IntegrationEvents. foreach (var integrationEntity in integrationEntities) { integrationEntity.Entity.ClearIntegrationEvents(); } // Publish Mediator Notifications. foreach (var integrationEvent in integrationEvents) { await mediator.Publish(integrationEvent); } }
public void NewTeam(ref Project project) { Id = Guid.NewGuid(); Name = project.Name; Admin = project.Admin; Time = DateTime.Now; Introduction = "此处的信息将作为团队的对外介绍。"; Announcement = "此处的信息将作为团队的内部公告"; project.Team = this; using (BaseDbContext db = new BaseDbContext()) { var TeamRecord = new TeamRecord(this, TeamMemberStatus.Admin,Extensions.GetContextUser(db)); } }
public GetExistingPaymentLinkQuery(ILogger logger, BaseDbContext dbContext) : base(logger, dbContext) { }
public OrderRepository(BaseDbContext _iBaseDbContext, IMapper _iMapper) : base(_iBaseDbContext, _iMapper) { }
public ItemController(BaseDbContext db) { this.db = db; }
public bool Quit(Guid Id) { using (BaseDbContext db = new BaseDbContext()) { try { var roomOperation = db.RoomOperations.Find(Id); if (RoomOperation != roomOperation) return false; var user = db.Users.Find(HttpContext.Current.User.Identity.GetUserId()); RoomOperation.Usable = true; if (RoomOperation.RoomRecords != null) { if (RoomOperation.RoomRecords.Contains(this)) RoomOperation.RoomRecords.Remove(this); } db.RoomRecords.Remove(this); db.SaveChanges(); return true; } catch { return false; } } }
public CustomLinkBehavior(BaseDbContext dbContext, NavigationMenuItemModel menuItemModel, int?parentId = null) : base(dbContext, menuItemModel, parentId) { }
public ReadOnlyEFWorkspace(BaseDbContext context) { _context = context; }
public static Material ChangeFile(Guid id, HttpPostedFileBase file, BaseDbContext db) { Material material = db.Materials.Find(id); if (!material.Type.Match(file)) return null; string uploadFileName = DateTime.Now.ToString("yyyyMMddHHmmssfff") + "-" + Guid.NewGuid() + Path.GetExtension(file.FileName); string absolutFileName; switch (material.Type) { case MaterialType.Identity: absolutFileName = HttpContext.Current.Server.MapPath("~/UserUpload/") + "Identity/" + uploadFileName; break; case MaterialType.Avatar: absolutFileName = HttpContext.Current.Server.MapPath("~/UserUpload/") + "Avatar/" + uploadFileName; break; case MaterialType.Management: absolutFileName = HttpContext.Current.Server.MapPath("~/UserUpload/") + "Management/" + uploadFileName; break; default: absolutFileName = HttpContext.Current.Server.MapPath("~/UserUpload/") + "Administrator/" + uploadFileName; break; } if (!Directory.Exists(Path.GetDirectoryName(absolutFileName))) { Directory.CreateDirectory(Path.GetDirectoryName(absolutFileName)); } //执行上传 file.SaveAs(absolutFileName); material.Name = uploadFileName; //保存更改 db.Materials.Attach(material); db.Entry(material).State = EntityState.Modified; db.SaveChanges(); return db.Materials.Find(material.Id); }
public bool Remark() { using (BaseDbContext db = new BaseDbContext()) { try { User user = db.Users.Find(HttpContext.Current.User.Identity.GetUserId()); RoomOperation = db.RoomOperations.First(t => t.Creator == user); Time = DateTime.Now; db.Entry(this).State = EntityState.Modified; db.SaveChanges(); return true; } catch { return false; } } }
public async Task <OperationResult> UpdateConnectionString(InitialSettingsModel initialSettingsModel) { var customerNo = initialSettingsModel.GeneralAppSetupSettingsModel.CustomerNo.ToString(); var dbNamePrefix = ""; if (initialSettingsModel.ConnectionStringSdk.PrefixAllDatabases) { dbNamePrefix = "Microting_"; } var sdkDbName = $"{dbNamePrefix}{customerNo}_SDK"; var angularDbName = $"{dbNamePrefix}{customerNo}_Angular"; var sdkConnectionString = $"host= {initialSettingsModel.ConnectionStringSdk.Host};" + $"Database={sdkDbName};{initialSettingsModel.ConnectionStringSdk.Auth}" + $"port={initialSettingsModel.ConnectionStringSdk.Port};" + "Convert Zero Datetime = true;SslMode=none;"; var angularConnectionString = $"host= {initialSettingsModel.ConnectionStringSdk.Host};" + $"Database={angularDbName};{initialSettingsModel.ConnectionStringSdk.Auth}" + $"port={initialSettingsModel.ConnectionStringSdk.Port};" + "Convert Zero Datetime = true;SslMode=none;"; if (!string.IsNullOrEmpty(_connectionStringsSdk.Value.SdkConnection)) { return(new OperationResult(false, _localizationService.GetString("ConnectionStringAlreadyExist"))); } try { Log.LogEvent($"SettingsService.ConnectionStringExist: connection string is {sdkConnectionString}"); var adminTools = new AdminTools(sdkConnectionString); // Setup SDK DB await adminTools.DbSetup(initialSettingsModel.ConnectionStringSdk.Token); // var core = await _coreHelper.GetCore(); Core core = new Core(); await core.StartSqlOnly(sdkConnectionString); await core.SetSdkSetting(Settings.customerNo, customerNo); } catch (Exception exception) { _logger.LogError(exception.Message); _logger.LogError(exception.StackTrace); if (exception.InnerException != null) { return(new OperationResult(false, exception.Message + " - " + exception.InnerException.Message)); } return(new OperationResult(false, exception.Message)); //return new OperationResult(false, // _localizationService.GetString("SDKConnectionStringIsInvalid")); } // Migrate DB var dbContextOptionsBuilder = new DbContextOptionsBuilder <BaseDbContext>(); try { dbContextOptionsBuilder.UseMySql(angularConnectionString, new MariaDbServerVersion( new Version(10, 4, 0)), b => b.EnableRetryOnFailure()); await using var dbContext = new BaseDbContext(dbContextOptionsBuilder.Options); await dbContext.Database.MigrateAsync(); if (initialSettingsModel.AdminSetupModel != null) { // Seed admin and demo users await SeedAdminHelper.SeedAdmin(initialSettingsModel.AdminSetupModel, initialSettingsModel.GeneralAppSetupSettingsModel.DefaultLocale, dbContext); } } catch (Exception exception) { _logger.LogError(exception.Message); _logger.LogError(exception.StackTrace); //return new OperationResult(false, // _localizationService.GetString("MainConnectionStringIsInvalid")); if (exception.Message == "Could not create the user") { return(new OperationResult(false, _localizationService.GetString(exception.Message))); } if (exception.InnerException != null) { return(new OperationResult(false, exception.Message + " - " + exception.InnerException.Message)); } return(new OperationResult(false, exception.Message)); } try { // Generate SigningKey var key = new byte[32]; RandomNumberGenerator.Create().GetBytes(key); var signingKey = Convert.ToBase64String(key); // Update Database settings await using var dbContext = new BaseDbContext(dbContextOptionsBuilder.Options); await _tokenOptions.UpdateDb((options) => { options.SigningKey = signingKey; }, dbContext); await _applicationSettings.UpdateDb( options => { options.DefaultLocale = initialSettingsModel.GeneralAppSetupSettingsModel.DefaultLocale; }, dbContext); await _connectionStringsSdk.UpdateDb((options) => { options.SdkConnection = sdkConnectionString; }, dbContext); // Update connection string _connectionStrings.UpdateFile((options) => { options.DefaultConnection = angularConnectionString; }); } catch (Exception exception) { _logger.LogError(exception.Message); _logger.LogError(exception.StackTrace); return(exception.InnerException != null ? new OperationResult(false, exception.Message + " - " + exception.InnerException.Message) : new OperationResult(false, exception.Message)); //return new OperationResult(false, // _localizationService.GetString("CouldNotWriteConnectionString")); } Program.Restart(); return(new OperationResult(true)); }
public UserRoleRepository(BaseDbContext context) : base(context) { }
public PostgreSqlDbAccessor(BaseDbContext baseDbContext) : base(baseDbContext) { }
public DeleteMasterController(BaseDbContext ctx) : base(ctx, "DeleteMaster", "MasterId", typeof(Master)) { }
public MenuController(BaseDbContext db) { this.db = db; }