Example #1
0
        /// <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="HostVisitCountMap"/> class.
        /// </summary>
        /// <param name="postfix">The postfix.</param>
        public HostVisitCountMap(string postfix)
        {
            // Primary Key
            this.HasKey(t => new { t.Date, t.ClusterId0, t.State, t.City, t.NewsSource });

            // Properties
            this.Property(t => t.ClusterId0).IsRequired().HasMaxLength(255);

            this.Property(t => t.State).IsRequired().HasMaxLength(255);

            this.Property(t => t.City).IsRequired().HasMaxLength(255);

            this.Property(t => t.NewsSource).IsRequired().HasMaxLength(255);

            // Table & Column Mappings
            this.ToTable(TableNameHelper.GetHostVisitCountTableName(postfix));
            this.Property(t => t.Date).HasColumnName("Date");
            this.Property(t => t.ClusterId0).HasColumnName("ClusterId0");
            this.Property(t => t.State).HasColumnName("State");
            this.Property(t => t.City).HasColumnName("City");
            this.Property(t => t.NewsSource).HasColumnName("NewsSource");
            this.Property(t => t.Count).HasColumnName("Count");
        }