Exemple #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);
        }
Exemple #2
0
        /// <summary>
        /// Gets the latest sentiment result.
        /// </summary>
        /// <param name="userName">Name of the user.</param>
        /// <returns>IEnumerable&lt;SentimentScanResult&gt;.</returns>
        public IEnumerable <SentimentScanResult> GetLatestSentimentResult(ClientUser user)
        {
            var userName           = user.Name;
            var postfix            = user.Postfix;
            var sentimentTableName = TableNameHelper.GetSentimentResultTableName(postfix);
            var sql = $"select top 1 * from {sentimentTableName} where Name = N'{userName}' order by Date Desc";

            return(this.dbUtilities.ExecuteStoreQuery <SentimentScanResult>(this.Context, sql));
        }