Esempio n. 1
0
        /// <summary>
        /// 获取网站活动配置
        /// </summary>
        public string GetActityConfig()
        {
            var configList = ActivityCache.QueryActivityConfig();
            var query      = from c in configList
                             select string.Format("{0}_{1}_{2}", c.ConfigKey, c.ConfigName, c.ConfigValue);

            return(string.Join("|", query.ToArray()));
        }
Esempio n. 2
0
 /// <summary>
 /// 更新网站活动配置
 /// </summary>
 public CommonActionResult UpdateActivityConfig(string key, string value)
 {
     try
     {
         ActivityCache.UpdateActivityConfig(key, value);
         return(new CommonActionResult(true, "更新成功"));
     }
     catch (Exception ex)
     {
         return(new CommonActionResult(false, ex.Message));
     }
 }
Esempio n. 3
0
        public IActionResult Delete(long id)
        {
            try
            {
                _dbcontext.ActivityRecords.Remove(_dbcontext.ActivityRecords.Single(r => r.Id == id));
                _dbcontext.SaveChanges();

                ActivityCache.InvalidateCache();

                _logger.Log(LogSeverityLevel.Info, $"Deleted activity with ID: {id}");
            }
            catch (Exception ex)
            {
                _logger.Log(LogSeverityLevel.Error, $"Error deleting activity with ID: {id}");
                _logger.Log(LogSeverityLevel.Error, ex.Message);
                return(RedirectToAction("Log", "Home"));
            }

            return(RedirectToAction("Index", "Home"));
        }
Esempio n. 4
0
        public IActionResult SaveDescription(string description, long id)
        {
            try
            {
                var record = _dbcontext.ActivityRecords.Single(r => r.Id == id);
                record.Description = description;
                _dbcontext.SaveChanges();

                ActivityCache.InvalidateCache();

                _logger.Log(LogSeverityLevel.Info, $"Changed description for activity with ID: {id}");
            }
            catch (Exception ex)
            {
                _logger.Log(LogSeverityLevel.Error, $"Error changing description for activity with ID: {id}");
                _logger.Log(LogSeverityLevel.Error, ex.Message);
                return(RedirectToAction("Log", "Home"));
            }

            return(RedirectToAction("Run", "Home", new { id }));
        }
Esempio n. 5
0
        public IActionResult ToggleRace(long id)
        {
            try
            {
                var record = _dbcontext.ActivityRecords.Single(r => r.Id == id);
                record.IsRace = !record.IsRace;
                _dbcontext.SaveChanges();

                ActivityCache.InvalidateCache();

                _logger.Log(LogSeverityLevel.Info, $"Toggled IsRace for activity with ID: {id}");
            }
            catch (Exception ex)
            {
                _logger.Log(LogSeverityLevel.Error, $"Error toggling IsRace for activity with ID: {id}");
                _logger.Log(LogSeverityLevel.Error, ex.Message);
                return(RedirectToAction("Log", "Home"));
            }

            return(RedirectToAction("Run", "Home", new { id = id }));
        }
Esempio n. 6
0
        private ActionResult ChartMenuHelper(int index)
        {
            var numOfCharts = Enum.GetNames(typeof(ChartsMenuModel.ChartType)).Length;

            if (index == 0)
            {
                index = numOfCharts;
            }
            if (index == numOfCharts + 1)
            {
                index = 1;
            }

            return(index switch
            {
                1 => View("ChartsProgression", new ChartsProgressionModel(ActivityCache.Get(_dbcontext))),
                2 => View("ChartsMetrics", new ChartsMetricsModel(ActivityCache.Get(_dbcontext))),
                3 => View("ChartsWorkload", new ChartsWorkloadModel(ActivityCache.Get(_dbcontext))),
                4 => View("ChartsVolume", new ChartsVolumeModel(ActivityCache.Get(_dbcontext))),
                5 => View("ChartsComparison", new ChartsComparisonModel(ActivityCache.Get(_dbcontext))),
                6 => View("ChartsEddington", new ChartsEddingtonModel(ActivityCache.Get(_dbcontext))),
                _ => View("ChartsProgression", new ChartsProgressionModel(ActivityCache.Get(_dbcontext)))
            });
Esempio n. 7
0
 public IActionResult EditDescription(long id)
 {
     return(View("EditRun", ActivityCache.Get(_dbcontext).Single(a => a.Id == id)));
 }
Esempio n. 8
0
 public IActionResult Map()
 {
     return(View("Map", new MapModel(ActivityCache.Get(_dbcontext))));
 }
Esempio n. 9
0
 public IActionResult Races()
 {
     return(View("Races", new RacesModel(ActivityCache.Get(_dbcontext).Where(a => a.IsRace).ToList())));
 }
Esempio n. 10
0
 public IActionResult Stats()
 {
     return(View("Stats", new StatsModel(ActivityCache.Get(_dbcontext))));
 }
Esempio n. 11
0
 public IActionResult Charts()
 {
     return(View("ChartsProgression", new ChartsProgressionModel(ActivityCache.Get(_dbcontext))));
 }
Esempio n. 12
0
 public IActionResult Index()
 {
     return(View("Index", new IndexModel(ActivityCache.Get(_dbcontext))));
 }
Esempio n. 13
0
 /// <summary>
 /// 根据activityId获取当前活动配置
 /// </summary>
 /// <param name="activityId"></param>
 /// <returns></returns>
 public Task <OperationResult <FixedPriceActivityRoundResponse> > GetFixedPriceActivityRoundAsync(Guid activityId)
 => OperationResult.FromResultAsync(ActivityCache.GetFixedPriceActivityRoundCache(activityId));
Esempio n. 14
0
 /// <summary>
 /// 重置活动计数器
 /// </summary>
 /// <param name="activityId"></param>
 /// <returns></returns>
 public Task <OperationResult <bool> > UpdateBaoYangPurchaseCountAsync(Guid activityId)
 => OperationResult.FromResultAsync(ActivityCache.UpdateBaoYangPurchaseCount(activityId));
Esempio n. 15
0
 /// <summary>
 /// 更新保养活动配置
 /// </summary>
 /// <param name="activityId"></param>
 /// <returns></returns>
 public Task <OperationResult <bool> > UpdateBaoYangActivityConfigAsync(Guid activityId)
 => OperationResult.FromResultAsync(ActivityCache.UpdateBaoYangActivityConfig(activityId));
Esempio n. 16
0
 /// <summary>
 /// 根据key获取配置的值
 /// </summary>
 /// <param name="key"></param>
 /// <returns></returns>
 public string QueryActivityConfig(string key)
 {
     return(ActivityCache.QueryActivityConfig(key).ConfigValue);
 }