Ejemplo n.º 1
0
        /// <summary>
        /// 导出所有统计数据
        /// </summary>
        public JObject DumpStatisticsData()
        {
            var data           = new JObject();
            var statisticsList = new List <Type>()
            {
                typeof(GunDevelopTotal),
                typeof(GunDevelopHeavyTotal),
                typeof(EquipProduceTotal),
                typeof(EquipDevelopTotal),
                typeof(EquipDevelopHeavyTotal),
                typeof(MissionBattleTotal),
                typeof(MissionFinishTotal),
            };

            foreach (var type in statisticsList)
            {
                var mapping    = _db.GetMapping(type);
                var resultList = _db.Query(mapping, $"SELECT * FROM '{mapping.TableName}';");
                var obj        = new JObject();
                // 这些统计类型都有time_id
                var property = type.GetProperty("time_id");
                foreach (var r in resultList)
                {
                    var t = JsonConvert.SerializeObject(r);
                    obj[property.GetValue(r)] = t;
                }

                data[nameof(type)] = obj;
            }

            return(data);
        }
 public Task <TableMapping> GetMappingAsync <T> ()
 {
     return(Task.Factory.StartNew(() => {
         SQLiteConnectionWithLock conn = GetConnection();
         using (conn.Lock()) {
             return conn.GetMapping(typeof(T));
         }
     }, CancellationToken.None, _taskCreationOptions, _taskScheduler ?? TaskScheduler.Default));
 }
Ejemplo n.º 3
0
        public void RemoveRecipe(int id)
        {
            if (_isDisposed)
            {
                throw new ObjectDisposedException(nameof(RecipePersistenceService));
            }
            using (_connection.Lock())
            {
                _connection.RunInTransaction(() =>
                {
                    //Remove all fields
                    var mapping = _connection.GetMapping <RecipeTextFieldRow>();
                    _connection.Execute($"DELETE FROM {mapping.TableName} WHERE RecipeId = ?", id);

                    //Remove recipe
                    _connection.Delete <RecipeRow>(id);
                });
            }
        }