public EntityParser(FacebookExportDbContext dbContext, string filePath, EntityParserSettings settings) { DbContext = dbContext; FilePath = filePath; CultureInfoProvider = CultureInfo.InvariantCulture; Settings = settings; }
static async Task MainAsync(string[] args) { var builder = new ConfigurationBuilder() .AddJsonFile("appsettings.json") .AddJsonFile("appsettings.local.json", true); var configuration = builder.Build(); var connectionString = configuration.GetConnectionString("DefaultConnection"); if (string.IsNullOrEmpty(connectionString)) { //Indicates that a connection string was not provided in the appsettings file throw new InvalidOperationException("A connection string must be configured"); } //Configure database var optionsBuilder = new DbContextOptionsBuilder(); var dbOptions = optionsBuilder .UseSqlServer(connectionString, providerOptions => providerOptions.CommandTimeout(60)) .UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking) .Options; //Bind to typed config objects var appsettings = new Appsettings(); var friendsParserSettings = new EntityParserSettings(); var timelinePostParserSettings = new EntityParserSettings(); configuration.GetSection("Appsettings").Bind(appsettings); configuration.GetSection("FriendsParserSettings").Bind(friendsParserSettings); configuration.GetSection("TimelinePostParserSettings").Bind(timelinePostParserSettings); //Process parsing of export using (var dbContext = new FacebookExportEntities.FacebookExportDbContext(dbOptions)) { //Parse friends var friendsFilePath = Path.Combine(appsettings.FacebookExportPath, friendsParserSettings.FilePath); var friendsParser = new FriendsParser(dbContext, friendsFilePath, friendsParserSettings); await friendsParser.ProcessImport(); //Parse timeline posts var timelinePostsPath = Path.Combine(appsettings.FacebookExportPath, timelinePostParserSettings.FilePath); var timelinePostParser = new TimelinePostParser(dbContext, timelinePostsPath, timelinePostParserSettings); await timelinePostParser.ProcessImport(); } }
public FriendsParser(FacebookExportDbContext dbContext, string filePath, EntityParserSettings settings) : base(dbContext, filePath, settings) { FriendRegex = new Regex(".* ((.*))"); DateFormat = "MMM d, yyyy"; }
public TimelinePostParser(FacebookExportDbContext dbContext, string filePath, EntityParserSettings settings) : base(dbContext, filePath, settings) { DateFormat = "dddd, MMMM d, yyyy a\\t h:mmtt"; Friends = dbContext.Friend.ToList(); FriendNameRegex = new Regex("(.*)<br>"); }