Ejemplo n.º 1
0
        private void LoadStatus(string sampleDataPath, TimeSpan offset)
        {
            var files = System.IO.Directory.GetFiles(sampleDataPath, "status-*.json");

            foreach (var f in files)
            {
                var name = System.IO.Path.GetFileNameWithoutExtension(f).Replace("status-", "");

                var statusJson = System.IO.File.ReadAllText(f);
                var curSt      = (BlackMaple.MachineWatchInterface.CurrentStatus)JsonConvert.DeserializeObject(
                    statusJson,
                    typeof(BlackMaple.MachineWatchInterface.CurrentStatus),
                    _jsonSettings
                    );
                curSt.TimeOfCurrentStatusUTC = curSt.TimeOfCurrentStatusUTC.Add(offset);

                foreach (var uniq in curSt.Jobs.Keys)
                {
                    MockServerBackend.OffsetJob(curSt.Jobs[uniq], offset);
                }
                Statuses.Add(name, curSt);
            }

            string statusFromEnv = System.Environment.GetEnvironmentVariable("BMS_CURRENT_STATUS");

            if (string.IsNullOrEmpty(statusFromEnv) || !Statuses.ContainsKey(statusFromEnv))
            {
                CurrentStatus = Statuses.OrderBy(st => st.Key).First().Value;
            }
            else
            {
                CurrentStatus = Statuses[statusFromEnv];
            }
        }