private void Awake()
    {
        DateTime today = DateTime.Now.Date;

        // parse log files on start if exists

        // symptom tracker
        string            path     = Path.Combine(Helper.GetDataPath(), LOGS_FOLDER, SYMPTOM_LOG);
        List <JSONObject> jsonList = GetJsonList(path);

        for (int i = 0; i < jsonList.Count; i++)
        {
            JSONObject  jsonObj = jsonList[i];
            SymptomData data    = new SymptomData(jsonObj.ToString());

            // don't manage outdated logs
            if ((today - data.GetDate()).Days > LOG_LIFE_TIME)
            {
                continue;
            }

            _symptomJsonObjectList.Add(data);

            // check if this date already exists
            if (_trackerDictionary.ContainsKey(data.GetDate()))
            {
                // modify existing entry
                UpdateEntry(data.GetDate(), data);
            }
            else
            {
                // add new entry
                UpdateEntry(data.GetDate(), new LogData {
                    symptomData = data
                });
            }
        }

        // asthma test
        path     = Path.Combine(Helper.GetDataPath(), LOGS_FOLDER, ASTHMA_TEST_LOG);
        jsonList = GetJsonList(path);

        for (int i = 0; i < jsonList.Count; i++)
        {
            JSONObject jsonObj = jsonList[i];
            AsthmaData data    = new AsthmaData(jsonObj.ToString());

            // don't manage outdated logs
            if ((today - data.GetDate()).Days > LOG_LIFE_TIME)
            {
                continue;
            }

            _asthmaJsonObjectList.Add(data);

            // check if this date already exists
            if (_trackerDictionary.ContainsKey(data.GetDate()))
            {
                // modify existing entry
                UpdateEntry(data.GetDate(), data);
            }
            else
            {
                // add new entry
                UpdateEntry(data.GetDate(), new LogData {
                    asthmaData = data
                });
            }
        }

        // CSU test
        path     = Path.Combine(Helper.GetDataPath(), LOGS_FOLDER, CSU_LOG);
        jsonList = GetJsonList(path);

        for (int i = 0; i < jsonList.Count; i++)
        {
            JSONObject jsonObj = jsonList[i];
            CSUData    data    = new CSUData(jsonObj.ToString());

            // don't manage outdated logs
            if ((today - data.GetDate()).Days > LOG_LIFE_TIME)
            {
                continue;
            }

            _csuJsonObjectList.Add(data);

            // check if this date already exists
            if (_trackerDictionary.ContainsKey(data.GetDate()))
            {
                // modify existing entry
                UpdateEntry(data.GetDate(), data);
            }
            else
            {
                // add new entry
                UpdateEntry(data.GetDate(), new LogData {
                    csuData = data
                });
            }
        }

        // UAS test
        path     = Path.Combine(Helper.GetDataPath(), LOGS_FOLDER, UAS_LOG);
        jsonList = GetJsonList(path);

        for (int i = 0; i < jsonList.Count; i++)
        {
            JSONObject jsonObj = jsonList[i];
            UASData    data    = new UASData(jsonObj.ToString());

            // don't manage outdated logs
            if ((today - data.GetDate()).Days > LOG_LIFE_TIME)
            {
                continue;
            }

            _uasJsonObjectList.Add(data);

            // check if this date already exists
            if (_trackerDictionary.ContainsKey(data.GetDate()))
            {
                // modify existing entry
                UpdateEntry(data.GetDate(), data);
            }
            else
            {
                // add new entry
                UpdateEntry(data.GetDate(), new LogData {
                    uasData = data
                });
            }
        }

        _logDataList = _logDataList.OrderBy(x => x.date).ToList();
    }
Example #2
0
    private void Start()
    {
        // parse log files on start if exists

        // symptom tracker file
        string            path     = Path.Combine(Helper.StreamingAssetPath(), SYMPTOM_LOG);
        List <JSONObject> jsonList = GetJsonList(path);

        for (int i = 0; i < jsonList.Count; i++)
        {
            JSONObject  jsonObj = jsonList[i];
            SymptomData data    = JsonUtility.FromJson <SymptomData>(jsonObj.str);

            // check if this date already exists
            if (_calendarDictionary.ContainsKey(data.GetDate()))
            {
                // modify existing entry
                _calendarDictionary[data.GetDate()].symptomData = data;
            }
            else
            {
                // add new entry
                _calendarDictionary.Add(data.GetDate(), new LogData {
                    symptomData = data
                });
            }
        }

        // asthma test
        path     = Path.Combine(Helper.StreamingAssetPath(), ASTHMA_TEST_LOG);
        jsonList = GetJsonList(path);

        for (int i = 0; i < jsonList.Count; i++)
        {
            JSONObject jsonObj = jsonList[i];
            AsthmaData data    = JsonUtility.FromJson <AsthmaData>(jsonObj.str);

            // check if this date already exists
            if (_calendarDictionary.ContainsKey(data.GetDate()))
            {
                // modify existing entry
                _calendarDictionary[data.GetDate()].asthmaData = data;
            }
            else
            {
                // add new entry
                _calendarDictionary.Add(data.GetDate(), new LogData {
                    asthmaData = data
                });
            }
        }

        // CSU test
        path     = Path.Combine(Helper.StreamingAssetPath(), CSU_LOG);
        jsonList = GetJsonList(path);

        for (int i = 0; i < jsonList.Count; i++)
        {
            JSONObject jsonObj = jsonList[i];
            CSUData    data    = JsonUtility.FromJson <CSUData>(jsonObj.str);

            // check if this date already exists
            if (_calendarDictionary.ContainsKey(data.GetDate()))
            {
                // modify existing entry
                _calendarDictionary[data.GetDate()].csuData = data;
            }
            else
            {
                // add new entry
                _calendarDictionary.Add(data.GetDate(), new LogData {
                    csuData = data
                });
            }
        }

        // UAS test
        path     = Path.Combine(Helper.StreamingAssetPath(), UAS_LOG);
        jsonList = GetJsonList(path);

        for (int i = 0; i < jsonList.Count; i++)
        {
            JSONObject jsonObj = jsonList[i];
            UASData    data    = JsonUtility.FromJson <UASData>(jsonObj.str);

            // check if this date already exists
            if (_calendarDictionary.ContainsKey(data.GetDate()))
            {
                // modify existing entry
                _calendarDictionary[data.GetDate()].uasData = data;
            }
            else
            {
                // add new entry
                _calendarDictionary.Add(data.GetDate(), new LogData {
                    uasData = data
                });
            }
        }
    }