Пример #1
0
        public async Task<object> ProcessData(Configuration.Configuration config)
        {
            await Task.Delay(100); // Maybe fetch from service? 

            var hour = Factory.DateTimeFactory.Instance.Now.Hour;

            List<string> compliments = new List<string>();

            if (hour >= 3 && hour < 12 && _complimentType != DayTime.Morning)
            {
                _complimentType = DayTime.Morning;
                compliments = new List<string>(config.DayTimeCompliments[_complimentType]);
            }
            else if (hour >= 12 && hour < 17 && _complimentType != DayTime.Afternoon)
            {
                _complimentType = DayTime.Afternoon;
                compliments = new List<string>(config.DayTimeCompliments[_complimentType]);
            }
            else if (hour >= 17 || hour < 3 && _complimentType != DayTime.Evening)
            {
                _complimentType = DayTime.Evening;
                compliments = new List<string>(config.DayTimeCompliments[_complimentType]);

            }

            return compliments;
        }
        public void Work_WhenEmpty_DoesNothing()
        {
            _dayTime = new DayTime();

            _subject.Work(_dayTime);

            Assert.IsFalse(_subject.OutputBuffer.Any());
            Assert.IsTrue(_subject.Inspection.Buffer.Empty());
            Assert.IsNull(_subject.Inspection.CurrentWo);
        }
Пример #3
0
 // Use this for initialization
 void Start()
 {
     this.game_status    = this.gameObject.GetComponent <GameStatus>();
     this.player_control =
         GameObject.Find("Player").GetComponent <PlayerControl>();
     this.step              = STEP.PLAY;
     this.next_step         = STEP.PLAY;
     this.guistyle.fontSize = 24;
     dt = GameObject.Find("GameRoot").GetComponent <DayTime>();
 }
Пример #4
0
 public Task TellResults(ICity city, DayTime dayTime)
 {
     foreach (var pair in city.LastChanges)
     {
         result.Append($"{pair.Key.Name} {pair.Value}");
     }
     result.Append("\n");
     result.Append("\n");
     return(Task.CompletedTask);
 }
Пример #5
0
        private IEnumerator ShowCycleMessage(DayTime cycle)
        {
            cycleMessage.alpha = 0f;
            cycleMessage.text  = GetCycleMessage(cycle);
            yield return(cycleMessage.DOFade(1f, 0.5f));

            yield return(new WaitForSeconds(5f));

            yield return(cycleMessage.DOFade(0f, 0.5f));
        }
Пример #6
0
 private DayTime GetNextCycle(DayTime cycle)
 {
     return(cycle switch
     {
         DayTime.Night => DayTime.Morning,
         DayTime.Evening => DayTime.Night,
         DayTime.Day => DayTime.Evening,
         DayTime.Morning => DayTime.Day,
         _ => throw new ArgumentOutOfRangeException(nameof(cycle), currentCycle, null)
     });
Пример #7
0
        public void Should_ConvertFromDateTime()
        {
            var now = DateTime.Now;

            var date = DayTime.FromDateTime(now);

            date.Year.Should().Be(now.Year);
            date.Month.Should().Be(now.Month);
            date.Day.Should().Be(now.Day);
        }
Пример #8
0
        public virtual DailySchedule SetTimeOfDay(string time)
        {
            DayTime dt;

            if (!DayTime.TryParse(time, out dt))
            {
                throw new ArgumentException("Invalid time format", nameof(time));
            }
            dayTime = dt;
            return(this);
        }
Пример #9
0
// Constructor
        public Erp(string name, ErpSchedule schedule = (ErpSchedule)0)
        {
            Name                = name;
            Locations           = new Dictionary <string, VirtualPlant>();
            LocationInventories = new Dictionary <string, List <VirtualWorkorder> >();
            Workorders          = new Dictionary <int, VirtualWorkorder>();
            _schedule           = schedule;
            _nextDump           = new DayTime();
            DueDates            = new Dictionary <int, DayTime>();
            NewToSend           = new List <IWork>();
        }
Пример #10
0
        public void Work_SendsToEnterpriseOnce()
        {
            DayTime nextMinute = _dayTime.CreateTimestamp(1);

            _subject.CreateOrder(test_type, _dayTime);

            _subject.Work(_dayTime);

            _subject.Work(nextMinute);
            _enterprise.Received(1).StartOrder(test_type, Arg.Any <DayTime>(), 0);
        }
Пример #11
0
        public async Task TestUpdateAlarm()
        {
            string     alarmId    = "db8f391f-38a6-4e42-81b5-1bf042c87254";
            DayTime    time       = new DayTime(10, 15);
            Repetition repetition = new Repetition {
                Friday = true, Monday = true
            };
            Alarm alarm = await _client.UpdateAlarm(alarmId, true, time, repetition);

            AssertAlarm(alarm);
        }
Пример #12
0
        public void Work(DayTime dt)
        {
            foreach (IAcceptWorkorders wc in Workcenters)
            {
                wc.Work(dt);
            }

            InternalTransportation.ForEach(x => x.Work(dt));

            Mes.Work(dt);
        }
Пример #13
0
// TODO Remove MesSchedule from Constructor, add to configuration.
// Constructor
        public Mes(string name, MesSchedule schedule = (MesSchedule)0)
        {
            Erp                 = null;
            Name                = name;
            Workorders          = new Dictionary <int, IWork>();
            LocationInventories = new Dictionary <string, List <IWork> >();
            Locations           = new Dictionary <string, VirtualWorkcenter>();
            Changes             = new List <Change>();

            _schedule = schedule;
            _nextDump = new DayTime();
        }
Пример #14
0
        private static Dictionary <DayTime, WeatherData> ConvertToOverview(JSONObject json)
        {
            Dictionary <DayTime, WeatherData> overview = new Dictionary <DayTime, WeatherData>();

            foreach (string key in json.keys)
            {
                DayTime dayTime = (DayTime)Enum.Parse(typeof(DayTime), key);
                overview[dayTime] = ConvertToWeatherData(json[key]);
            }

            return(overview);
        }
Пример #15
0
    void Start()
    {
        dayTime         = DayTime.Noon;
        spriteRenderers = GetComponentsInChildren <SpriteRenderer>(true);
        var count = spriteRenderers.Length - 1;

        for (int i = 0; i < spriteRenderers.Length; i++)
        {
            spriteRenderers[i].sortingOrder = count;
            count--;
        }
    }
Пример #16
0
        // PUBLIC METHODS //
        public DayTime CreateTimestamp(int increment)
        {
            DayTime timestamp = new DayTime(Day, Time);

            while (increment > 0)
            {
                timestamp.Next();
                increment--;
            }

            return(timestamp);
        }
Пример #17
0
        public void CreateTimeStamp_FromInitial_CreatesATimestampAMinuteInFuture()
        {
            const int expectedDay          = 0;
            const int expectedTime         = 1;
            const int expectedOriginalTime = 0;

            DayTime next = _dayTime.CreateTimestamp(1);

            Assert.AreEqual(_dayTime.Day, expectedDay);
            Assert.AreEqual(_dayTime.Time, expectedOriginalTime);
            Assert.AreEqual(next.Day, expectedDay);
            Assert.AreEqual(next.Time, expectedTime);
        }
Пример #18
0
 public void ToggleDayTime()
 {
     if (curDayTime == DayTime.Solar)
     {
         curDayTime = DayTime.Night;
     }
     else if (curDayTime == DayTime.Night)
     {
         curDayTime = DayTime.Solar;
     }
     Debug.Log("Toggled to daytime " + curDayTime);
     UpdateDayTime();
 }
Пример #19
0
        public void AddRoad(int from, int to, DayTime dayTime)
        {
            var incomingRoads = _incomingRoads[to];

            DayTime existingRoadType;

            if (!incomingRoads.TryGetValue(from, out existingRoadType))
            {
                existingRoadType = dayTime;
            }

            incomingRoads[from] = existingRoadType | dayTime;
        }
    public void SetRandomTime()
    {
        CurrentDayTime = SetDayTime(Random.Range(0, CurrentEnvironmentEpoch == EnvironmentEpoch.Winter ? EARLY_MORNING - 1 : NIGHT), Random.Range(0, 60));

        if (CurrentDayTime == lastDayTime)
        {
            CurrentDayTime = SetDayTime(this.hours + hours < 20 ? 4 : -4, Random.Range(0, 60));
        }
        else
        {
            lastDayTime = CurrentDayTime;
        }
    }
Пример #21
0
        protected void Setup()
        {
            _dayTime = new DayTime();
            _plant1  = GeneratePlant("P1", 1);
            _plant2  = GeneratePlant("P2", 2);

            //List<IPlant> list = new List<IPlant>() { _plant1, _plant2 };
            _customer = new Customer();

            _subject = new Enterprise(_customer);
            _subject.Add(_plant1);
            _subject.Add(_plant2);
        }
Пример #22
0
    /// <summary>
    /// 把DayTime对象 转换为 DateTime对象
    /// </summary>
    /// <param name="dateTime">要转换的DayTime对象</param>
    /// <returns>转换后的DateTime对象</returns>
    public static DateTime DateTimeToDayTime(int year, int month, int day, DayTime dayTime)
    {
        DateTime dateTime = new DateTime(
            year,                            //年
            month,                           //月
            day,                             //日
            dayTime.Hour,                    //时
            dayTime.Minute, 0);              //分

        dateTime.AddSeconds(dayTime.Second); //秒

        return(dateTime);
    }
Пример #23
0
    void DayTimeListener(DayTime previous, DayTime daytime)
    {
        if (!selected)
        {
            return;
        }

        if (previous == DayTime.Night && daytime == DayTime.Day)
        {
            audio.clip = sound;
            audio.Play();
        }
    }
Пример #24
0
        public void LessThan_WhenLess_ReturnsTrue()
        {
            _dayTime = _dayTime.CreateTimestamp(1440);
            _dayTime.Next();
            DayTime lessDay  = new DayTime((int)DayTime.Days.Sun, 0);
            DayTime lessTime = new DayTime((int)DayTime.Days.Mon, 0);

            Assert.IsTrue(lessDay.LessThan(_dayTime));
            Assert.IsFalse(_dayTime.LessThan(lessDay));
            Assert.IsTrue(lessTime.LessThan(_dayTime));
            Assert.IsFalse(_dayTime.LessThan(lessTime));
            Assert.IsFalse(_dayTime.Equals(lessDay));
            Assert.IsFalse(_dayTime.Equals(lessTime));
        }
Пример #25
0
 private void CheckDayNightStarted()
 {
     if (_time >= dayStartAngle && _time <= nightStartAngle && _dayTime == DayTime.NIGHT)
     {
         _dayTime = DayTime.DAY;
         OnDayStarted();
     }
     else
     if ((_time < dayStartAngle || _time >= nightStartAngle) && _dayTime == DayTime.DAY)
     {
         _dayTime = DayTime.NIGHT;
         OnNightStarted();
     }
 }
Пример #26
0
        public void ReceiveProduct_CompletesOrder()
        {
            DayTime       completedDate     = _dayTime.CreateTimestamp(20);
            List <string> expected_complete = new List <string>()
            {
                test_type + " ; " + ConvertTime(_dayTime) + " ; " + ConvertTime(completedDate)
            };

            _subject.CreateOrder(test_type, _dayTime);
            _subject.ReceiveProduct(test_type, completedDate);

            CollectionAssert.IsEmpty(_subject.ActiveOrders);
            CollectionAssert.AreEquivalent(expected_complete, _subject.CompleteOrders);
        }
Пример #27
0
        public void Work_SendsWorkordersToPlant()
        {
            Workorder.PoType productType = Workorder.PoType.p1;
            DayTime          due         = new DayTime().CreateTimestamp(50);

            _plant1.CanWorkOnType(Arg.Any <Op.OpTypes>()).Returns(false);
            _plant2.CanWorkOnType(Arg.Any <Op.OpTypes>()).Returns(true);

            _subject.CreateWorkorder(productType, due);
            _subject.Work(new DayTime());

            _plant1.DidNotReceive().Add(Arg.Any <IWork>());
            _plant2.Received().Add(Arg.Any <IWork>());
        }
        public void Transport_AtFirstStop_UpdatesLocationAndReceivesCargo()
        {
            Dictionary <int, string> expected = new Dictionary <int, string>();

            expected.Add(_wo1.Id, PLANT2_NAME);

            DayTime newTime = _first.CreateTimestamp(10);

            _subject.Work(newTime);

            Assert.AreEqual(PLANT1_NAME, _subject.CurrentLocation);
            Assert.IsNotEmpty(_subject.Inventory());
            CollectionAssert.AreEquivalent(_subject.Inventory(), expected);
        }
Пример #29
0
    /// <summary>
    /// Whether the time is within a specified region.
    /// </summary>
    /// <param name="d1">Earlier DayTime</param>
    /// <param name="d2">Later DayTime</param>
    /// <param name="time">Time</param>
    /// <returns></returns>
    public static bool BetweenTime(DayTime d1, DayTime d2, float time)
    {
        float a = assocTime.Find(x => x.dt == d1).time;
        float b = assocTime.Find(x => x.dt == d2).time;

        if (time >= a && time < b)
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
Пример #30
0
    void Start()
    {
        this.guistyle.fontSize = 24; // 폰트 크기를 24로.
        repairCount            = 0;
        fireCount = 0;
        dt        = GameObject.Find("GameRoot").GetComponent <DayTime>();
        myFriend  = GameObject.Find("WillsonTable").GetComponent <CsWillson>();

        // CampFire.transform.Translate(new Vector3(0, -50, 0));
        foreach (var part in boatParts)
        {
            part.SetActive(false);
        }
    }
Пример #31
0
        public async Task TellResults(ICity city, DayTime dayTime)
        {
            if (!cityToChat.ContainsKey(city))
            {
                return;
            }

            var chatId = cityToChat[city];

            foreach (var pair in city.LastChanges.Where(pair => pair.Value != PersonState.Immortal))
            {
                await bot.SendTextMessageAsync(chatId, $"{pair.Key.Name} {pair.Value}");
            }
        }
Пример #32
0
        /// <summary>
        /// Creates an object that contains a list with all planned takings for a drug, based on the start- and endtime and the day times where the drug needs to be taken
        /// author: Florian Schnyder
        /// </summary>
        /// <param name="drug">Contanis the drug object for which the taking plan has been created</param>
        /// <param name="takingStart">Startpoint for drug reminder</param>
        /// <param name="takingEnd">Endpoint for a drug reminder, if the enddate is alredy known</param>
        /// <param name="takingDayTime">Contanis the information at which points of the day (morning, lunch, evening, night) the drug should be taken</param>
        /// <param name="takingTime">Contanis the information at what time i have to take the drug</param>
        public TakingPlan(Drug drug, DateTime takingStart, DateTime takingEnd, DayTime takingDayTime, Dictionary<DayTime, DateTime> takingTime)
        {
            this.drug = drug;
            this.takingStart = takingStart;
            this.takingEnd = takingEnd;
            this.takingDayTime = takingDayTime;
            this.takingTime = takingTime;

            //create an XML file with the implemented method
            XmlDocument file = createXML();
            DateTime time = DateTime.Now.AddMinutes(1);

            //add the notificaction to the operating system
            ScheduledToastNotification noti = new ScheduledToastNotification(file, time);
            noti.Id = drug.ToString();
            ToastNotificationManager.CreateToastNotifier().AddToSchedule(noti); 

            //creates daily notifications for the drug if the flag in DayTime is set. At the moment only for one week and without checking the takingEndDate....
            if (drug != null && this.takingStart != null && this.takingStart >= DateTime.Now)
            {
                Settings settings = Settings.Instance;

                //checks if the flag at the specified position is set. If yes, the durg will be added to the realted list
                if (takingDayTime.HasFlag(DayTime.Morning))
                {
                    //create an XML file with the implemented method
                    XmlDocument xml = createXML();

                    //add temporary variable to count one week
                    int temp = 0;

                    //Get the current year, month and day, afterwards, get the needed data form the settings class (just for prototype, afterwards, it will check the drugs own daily taking times)
                    DateTime plannedTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, settings.DefaultMorningTakingTime.Hours, settings.DefaultMorningTakingTime.Minutes, 0);

                    while (temp < 7)
                    {
                        plannedTime = plannedTime.AddDays(1);
                        // add the notification to the operating system
                        ScheduledToastNotification toast = new ScheduledToastNotification(xml, plannedTime);
                        toast.Id = drug.ToString() + temp;
                        ToastNotificationManager.CreateToastNotifier().AddToSchedule(toast);
                        temp++;
                    }

                }

                if (takingDayTime.HasFlag(DayTime.Lunch))
                {
                    //create an XML file with the implemented method
                    XmlDocument xml = createXML();

                    //add temporary variable to count one week
                    int temp = 0;

                    //Get the current year, month and day, afterwards, get the needed data form the settings class (just for prototype, afterwards, it will check the drugs own daily taking times)
                    DateTime plannedTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, settings.DefaultLunchTakingTime.Hours, settings.DefaultLunchTakingTime.Minutes, 0);

                    while (temp < 7)
                    {
                        plannedTime = plannedTime.AddDays(1);
                        // add the notification to the operating system
                        ScheduledToastNotification toast = new ScheduledToastNotification(xml, plannedTime);
                        toast.Id = drug.ToString() + temp;
                        ToastNotificationManager.CreateToastNotifier().AddToSchedule(toast);
                        temp++;
                    }

                }

                if (takingDayTime.HasFlag(DayTime.Evening))
                {
                    //create an XML file with the implemented method
                    XmlDocument xml = createXML();

                    //add temporary variable to count one week
                    int temp = 0;

                    //Get the current year, month and day, afterwards, get the needed data form the settings class (just for prototype, afterwards, it will check the drugs own daily taking times)
                    DateTime plannedTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, settings.DefaultEveningTakingTime.Hours, settings.DefaultEveningTakingTime.Minutes, 0);

                    while (temp < 7)
                    {
                        plannedTime = plannedTime.AddDays(1);
                        // add the notification to the operating system
                        ScheduledToastNotification toast = new ScheduledToastNotification(xml, plannedTime);
                        toast.Id = drug.ToString() + temp;
                        ToastNotificationManager.CreateToastNotifier().AddToSchedule(toast);
                        temp++;
                    }

                }

                if (takingDayTime.HasFlag(DayTime.Night))
                {
                   
                    XmlDocument xml = createXML();

                    //add temporary variable to count one week
                    int temp = 0;

                    //Get the current year, month and day, afterwards, get the needed data form the settings class (just for prototype, afterwards, it will check the drugs own daily taking times)
                    DateTime plannedTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, settings.DefaultNightTakingTime.Hours, settings.DefaultNightTakingTime.Minutes, 0);

                    while (temp < 7)
                    {
                        plannedTime = plannedTime.AddDays(1);
                        // add the notification to the operating system
                        ScheduledToastNotification toast = new ScheduledToastNotification(xml, plannedTime);
                        toast.Id = drug.ToString() + temp;
                        ToastNotificationManager.CreateToastNotifier().AddToSchedule(toast);
                        temp++;
                    }
                }
            }
        }