/// <summary> /// Clears the user tables. /// </summary> /// <param name="postfix">The postfix.</param> public void ClearUserTables(string postfix) { var tableList = new List <string> { TableNameHelper.GetHostVisitCountTableName(postfix), TableNameHelper.GetHostVisitCountHourlyTableName(postfix), TableNameHelper.GetLocationAndUserDemoTableName(postfix), TableNameHelper.GetNewsHourlyTableName(postfix), TableNameHelper.GetNewsSentimentTableName(postfix), TableNameHelper.GetNewsStreamTableName(postfix), TableNameHelper.GetSentimentResultNewsTableName(postfix), TableNameHelper.GetSentimentResultTableName(postfix), TableNameHelper.GetWordCloudTableName(postfix) }; using (var db = ContextFactory.GetProfileContext()) { var sb = new StringBuilder(); foreach (var table in tableList) { sb.AppendLine($"Truncate Table {table};"); } db.Database.CommandTimeout = 300; try { db.Database.ExecuteSqlCommand(sb.ToString()); }catch (Exception e) { } } repository.CleanUserDataLoadHistory(postfix); }
/// <summary> /// Initializes a new instance of the <see cref="WeeklyReportRepository"/> class. /// </summary> /// <param name="user">The user.</param> public WeeklyReportRepository(ClientUser user) { this.currentUser = user; var postfix = this.currentUser.GetProfile().Postfix; this.locationAndUserDemoTableName = TableNameHelper.GetLocationAndUserDemoTableName(postfix); this.newsStreamTableName = TableNameHelper.GetNewsStreamTableName(postfix); this.newsSentimentsTableName = TableNameHelper.GetNewsSentimentTableName(postfix); this.hostVisitCountTableName = TableNameHelper.GetHostVisitCountTableName(postfix); }
/// <summary> /// Initializes a new instance of the <see cref="NewsSentimentsMap"/> class. /// </summary> /// <param name="postfix">The postfix.</param> public NewsSentimentsMap(string postfix) { // Primary Key this.HasKey(t => new { t.Date, t.ClusterId0, t.Attitude, t.ContentHash }); // Properties this.Property(t => t.ClusterId0).IsRequired().HasMaxLength(255); this.Property(t => t.Attitude).IsRequired().HasMaxLength(255); this.Property(t => t.ContentHash).IsRequired().HasMaxLength(255); this.Property(t => t.Content).IsRequired().HasMaxLength(4000); // Table & Column Mappings this.ToTable(TableNameHelper.GetNewsSentimentTableName(postfix)); this.Property(t => t.Date).HasColumnName("Date"); this.Property(t => t.ClusterId0).HasColumnName("ClusterId0"); this.Property(t => t.Attitude).HasColumnName("Attitude"); this.Property(t => t.ContentHash).HasColumnName("ContentHash"); this.Property(t => t.Content).HasColumnName("Content"); this.Property(t => t.Vote).HasColumnName("Vote"); }