Exemplo n.º 1
0
        private ShipsData LoadData(bool forceApi = false)
        {
            ShipsData results = null;
            if (!forceApi)
            {
                results = DeserializeShips();
            }
            //set range for max data age
            if (forceApi ||
               results == null ||
               results.DataCreatedAt == DateTime.MaxValue)
            {
                //put this somewhere safe sometime
                string key = File.ReadAllText("api.secret");
                ApiDAO api = new ApiDAO(key);
                results = api.GetAllShips();

            }
            return results;
        }
Exemplo n.º 2
0
        private ModulesData GetModules()
        {
            ModulesData results = new ModulesData();

            results.AllModules = new Dictionary<long, Module>();
            string key = File.ReadAllText("api.secret");// @"11749197d5c8ca823ed4beb2199922aa";
            ApiDAO api = new ApiDAO(key);
            List<Module> typeResults = new List<Module>();
            foreach ( string type in ModuleTypes)
            {
                string json = api.GetModules(type);
                typeResults = GetModules(json);
                foreach(Module m in typeResults)
                {
                    results.AllModules[m.ID] = m;
                }
            }
            results.AllTypes = ModuleTypes;
            results.DataCreatedAt = DateTime.Now.ToUniversalTime();
            HashSet<String> propNames = new HashSet<string>();
            foreach(Module m in results.AllModules.Values)
            {
                foreach(string name in m.ModuleAttributes.Keys)
                {
                    if(!propNames.Contains(name))
                    {
                        propNames.Add(name);
                    }
                }
            }

            results.AllModuleProperties = propNames.ToList();
            return results;
        }