/// <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); }