chore: initial commit of TaskTracker project
Existing ASP.NET API with vanilla JS SPA, WindowWatcher, Chrome extension, and MCP server. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
62
TaskTracker.Infrastructure/Data/TaskTrackerDbContext.cs
Normal file
62
TaskTracker.Infrastructure/Data/TaskTrackerDbContext.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using TaskTracker.Core.Entities;
|
||||
|
||||
namespace TaskTracker.Infrastructure.Data;
|
||||
|
||||
public class TaskTrackerDbContext(DbContextOptions<TaskTrackerDbContext> options) : DbContext(options)
|
||||
{
|
||||
public DbSet<WorkTask> Tasks => Set<WorkTask>();
|
||||
public DbSet<TaskNote> Notes => Set<TaskNote>();
|
||||
public DbSet<ContextEvent> ContextEvents => Set<ContextEvent>();
|
||||
public DbSet<AppMapping> AppMappings => Set<AppMapping>();
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.Entity<WorkTask>(e =>
|
||||
{
|
||||
e.HasKey(t => t.Id);
|
||||
e.Property(t => t.Title).HasMaxLength(500).IsRequired();
|
||||
e.Property(t => t.Status).HasConversion<string>().HasMaxLength(50);
|
||||
e.Property(t => t.Category).HasMaxLength(100);
|
||||
e.HasMany(t => t.SubTasks).WithOne(t => t.ParentTask).HasForeignKey(t => t.ParentTaskId).OnDelete(DeleteBehavior.Restrict);
|
||||
e.HasIndex(t => t.ParentTaskId);
|
||||
e.HasMany(t => t.Notes).WithOne(n => n.WorkTask).HasForeignKey(n => n.WorkTaskId);
|
||||
e.HasMany(t => t.ContextEvents).WithOne(c => c.WorkTask).HasForeignKey(c => c.WorkTaskId);
|
||||
});
|
||||
|
||||
modelBuilder.Entity<TaskNote>(e =>
|
||||
{
|
||||
e.HasKey(n => n.Id);
|
||||
e.Property(n => n.Content).IsRequired();
|
||||
e.Property(n => n.Type).HasConversion<string>().HasMaxLength(50);
|
||||
});
|
||||
|
||||
modelBuilder.Entity<ContextEvent>(e =>
|
||||
{
|
||||
e.HasKey(c => c.Id);
|
||||
e.Property(c => c.Source).HasMaxLength(100).IsRequired();
|
||||
e.Property(c => c.AppName).HasMaxLength(200).IsRequired();
|
||||
e.Property(c => c.WindowTitle).HasMaxLength(1000).IsRequired();
|
||||
e.Property(c => c.Url).HasMaxLength(2000);
|
||||
e.HasIndex(c => c.Timestamp);
|
||||
});
|
||||
|
||||
modelBuilder.Entity<AppMapping>(e =>
|
||||
{
|
||||
e.HasKey(m => m.Id);
|
||||
e.Property(m => m.Pattern).HasMaxLength(500).IsRequired();
|
||||
e.Property(m => m.MatchType).HasMaxLength(50).IsRequired();
|
||||
e.Property(m => m.Category).HasMaxLength(100).IsRequired();
|
||||
e.Property(m => m.FriendlyName).HasMaxLength(200);
|
||||
});
|
||||
|
||||
// Seed default app mappings
|
||||
modelBuilder.Entity<AppMapping>().HasData(
|
||||
new AppMapping { Id = 1, Pattern = "SLDWORKS", MatchType = "ProcessName", Category = "Engineering", FriendlyName = "SolidWorks" },
|
||||
new AppMapping { Id = 2, Pattern = "OUTLOOK", MatchType = "ProcessName", Category = "Email", FriendlyName = "Outlook" },
|
||||
new AppMapping { Id = 3, Pattern = "notepad", MatchType = "ProcessName", Category = "General", FriendlyName = "Notepad" },
|
||||
new AppMapping { Id = 4, Pattern = "pep", MatchType = "UrlContains", Category = "LaserCutting", FriendlyName = "PEP System" },
|
||||
new AppMapping { Id = 5, Pattern = "solidworks", MatchType = "TitleContains", Category = "Engineering", FriendlyName = "SolidWorks" }
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user