Inheritance: MonoBehaviour
 protected TimeOfDayChangedAction(SerializationInfo info, StreamingContext context)
     : base(info, context)
 {
     v3dLayer = EditorManager.Project.Scene.MainLayer as V3DLayer;
       oldConfig = (TimeOfDay)info.GetValue("oldConfig", typeof(TimeOfDay));
       newConfig = (TimeOfDay)info.GetValue("newConfig", typeof(TimeOfDay));
 }
Ejemplo n.º 2
0
        public static string GetOrderList(List<int> listDishes, TimeOfDay tod)
        {
            var output = string.Empty;
            listDishes = listDishes.OrderBy(x => x).ToList();
            var last = -1;

            foreach (var dishType in listDishes)
            {
                if (dishType == last)
                    continue;
                last = dishType;

                Dish dish = rest.FindDish(tod, (DishType)dishType);
                if (dish == null)
                {
                    output += "error,";
                    continue;
                }

                var quantity = GetValidQuantity(listDishes, dish);
                if (quantity == -1)
                {
                    Console.WriteLine("Invalid quantity.");
                    break;
                }

                // Concatenating the output and adding the quantity if necessary
                output += quantity > 1 ? rest.FindFood(dish.FoodID).Name + "(x" + quantity + ")," : rest.FindFood(dish.FoodID).Name + ",";
            }

            return output;
        }
Ejemplo n.º 3
0
 public Filter(bool exclude, FieldIndex fieldIndex, TimeOfDay value, FilterTest test)
 {
     Exclude_ = exclude;
     FieldIndex_ = fieldIndex;
     Value_ = value.DayMinutes;
     Test_ = test;
 }
Ejemplo n.º 4
0
        public static TimeSpan GetTimeBetween(TimeOfDay first, TimeOfDay next)
        {
            var times = new Dictionary<TimeOfDay, DateTime>
            {
                [TimeOfDay.Breakfast] = new DateTime(2015, 2, 1, MedicineWithDoses.BreakfastHour, 0, 0),
                [TimeOfDay.Lunch] = new DateTime(2015, 2, 1, MedicineWithDoses.LunchHour, 0, 0),
                [TimeOfDay.Dinner] = new DateTime(2015, 2, 1, MedicineWithDoses.DinnerHour, 0, 0)
            };

            var firstIdx = (int)first;
            var nextIdx = (int)next;

            if (firstIdx < nextIdx)
            {
                return times[next] - times[first];
            }
            else if (firstIdx > nextIdx)
            {
                return times[next] - times[first].DayBefore();
            }
            else
            {
                return TimeSpan.FromDays(1).Subtract(TimeSpan.FromSeconds(1));
            }



        }
 public void CanConstructTimeOfDayFrom12HoursAndMinutes()
 {
     TimeOfDay time = new TimeOfDay(11, 59, Meridiem.PM);
     const long expected = 23 * TimeSpan.TicksPerHour +
                           59 * TimeSpan.TicksPerMinute;
     Assert.Equal(expected, time.Ticks);
 }
Ejemplo n.º 6
0
    // Update is called once per frame
    void Update()
    {
        sunMoonTransform[0].Rotate(new Vector3(_degreeRotation, 0, 0) * Time.deltaTime);
        //		if (moon_light.transform.position.y < 0) {
        //			moon_light.enabled = false;
        //			moon_spot_light.enabled = false;
        //		} else {
        //			moon_light.enabled = true;
        //			moon_spot_light.enabled = true;
        //		}
        //		if (sun_light.transform.position.y < 0) {
        //			sun_light.enabled = false;
        //			sun_spot_light.enabled = false;
        //		} else {
        //			sun_light.enabled = true;
        //			sun_spot_light.enabled = true;
        //		}

        _timeOfDay += Time.deltaTime;

        if (_timeOfDay > _dayCycleInSeconds) _timeOfDay -= _dayCycleInSeconds;

        if (_timeOfDay > sunRise &&
            _timeOfDay < sunSet &&
            RenderSettings.skybox.GetColor("_Tint")[3] < 1) {
            _tod = GameTime.TimeOfDay.SunRise;
            updateSkyBox();
        } else if (_timeOfDay > sunSet && RenderSettings.skybox.GetColor("_Tint")[3] > 0) {
            _tod = GameTime.TimeOfDay.SunSet;
            updateSkyBox();
        } else {
            _tod = GameTime.TimeOfDay.Idle;
        }
    }
        public void MultipleTypeCustomInstanceAnnotationsOnErrorShouldRoundtrip()
        {
            var originalInt = new KeyValuePair<string, ODataValue>("int.error", new ODataPrimitiveValue(1));
            var originalDouble = new KeyValuePair<string, ODataValue>("double.error", new ODataPrimitiveValue(double.NaN));
            DateTimeOffset dateTimeOffset = new DateTimeOffset(2012, 10, 10, 12, 12, 59, new TimeSpan());
            var originalDateTimeOffset = new KeyValuePair<string, ODataValue>("DateTimeOffset.error", new ODataPrimitiveValue(dateTimeOffset));
            Date date = new Date(2014, 12, 12);
            var originalDate = new KeyValuePair<string, ODataValue>("Date.error", new ODataPrimitiveValue(date));
            TimeOfDay time = new TimeOfDay(10, 12, 3, 9);
            var originaltime = new KeyValuePair<string, ODataValue>("TimeOfDay.error", new ODataPrimitiveValue(time));
            TimeSpan timeSpan = new TimeSpan(12345);
            var originalTimeSpan = new KeyValuePair<string, ODataValue>("TimeSpan.error", new ODataPrimitiveValue(timeSpan));
            GeographyPoint geographyPoint = GeographyPoint.Create(32.0, -100.0);
            var originalGeography = new KeyValuePair<string, ODataValue>("Geography.error", new ODataPrimitiveValue(geographyPoint));
            var originalNull = new KeyValuePair<string, ODataValue>("null.error", new ODataNullValue());

            var complexValue = new ODataComplexValue
            {
                TypeName = "ns.ErrorDetails",
                Properties = new[] { new ODataProperty { Name = "ErrorDetailName", Value = "inner property value" } }
            };
            var originalComplex = new KeyValuePair<string, ODataValue>("sample.error", complexValue);

            var error = this.WriteThenReadErrorWithInstanceAnnotation(originalInt, originalDouble, originalDate, originalDateTimeOffset, originaltime, originalTimeSpan, originalGeography, originalNull, originalComplex);

            var annotation = RunBasicVerificationAndGetAnnotationValue("int.error", error);
            annotation.Should().BeOfType<ODataPrimitiveValue>();
            annotation.As<ODataPrimitiveValue>().Value.Should().Be(1);

            annotation = RunBasicVerificationAndGetAnnotationValue("double.error", error);
            annotation.Should().BeOfType<ODataPrimitiveValue>();
            annotation.As<ODataPrimitiveValue>().Value.Should().Be(double.NaN);

            annotation = RunBasicVerificationAndGetAnnotationValue("Date.error", error);
            annotation.Should().BeOfType<ODataPrimitiveValue>();
            annotation.As<ODataPrimitiveValue>().Value.Should().Be(date);

            annotation = RunBasicVerificationAndGetAnnotationValue("DateTimeOffset.error", error);
            annotation.Should().BeOfType<ODataPrimitiveValue>();
            annotation.As<ODataPrimitiveValue>().Value.Should().Be(dateTimeOffset);

            annotation = RunBasicVerificationAndGetAnnotationValue("TimeOfDay.error", error);
            annotation.Should().BeOfType<ODataPrimitiveValue>();
            annotation.As<ODataPrimitiveValue>().Value.Should().Be(time);

            annotation = RunBasicVerificationAndGetAnnotationValue("TimeSpan.error", error);
            annotation.Should().BeOfType<ODataPrimitiveValue>();
            annotation.As<ODataPrimitiveValue>().Value.Should().Be(timeSpan);

            annotation = RunBasicVerificationAndGetAnnotationValue("Geography.error", error);
            annotation.Should().BeOfType<ODataPrimitiveValue>();
            annotation.As<ODataPrimitiveValue>().Value.Should().Be(geographyPoint);

            annotation = RunBasicVerificationAndGetAnnotationValue("null.error", error);
            annotation.Should().BeOfType<ODataNullValue>();

            annotation = RunBasicVerificationAndGetAnnotationValue("sample.error", error);
            annotation.Should().BeOfType<ODataComplexValue>();
            annotation.As<ODataComplexValue>().Properties.First().Value.Should().Be("inner property value");
        }
Ejemplo n.º 8
0
 public Dish(int dishID, int foodID, DishType dishType, TimeOfDay timeOfDay)
 {
     DishID = dishID;
     FoodID = foodID;
     DishType = dishType;
     TimeOfDay = timeOfDay;
 }
 public void CanConstructTimeOfDayFrom24HoursAndMinutesAndSeconds()
 {
     TimeOfDay time = new TimeOfDay(23, 59, 59);
     const long expected = 23 * TimeSpan.TicksPerHour +
                           59 * TimeSpan.TicksPerMinute +
                           59 * TimeSpan.TicksPerSecond;
     Assert.Equal(expected, time.Ticks);
 }
Ejemplo n.º 10
0
        public void CanCalculateDuration_OverMidnight()
        {
            TimeOfDay startTime = new TimeOfDay(23, 0);
            TimeOfDay endTime = new TimeOfDay(1, 0);

            TimeSpan duration = TimeOfDay.CalculateDuration(startTime, endTime);
            Assert.Equal(TimeSpan.FromHours(2), duration);
        }
Ejemplo n.º 11
0
        public void CanAddPositiveTime()
        {
            TimeOfDay startTime = new TimeOfDay(12, 0);
            TimeOfDay actual = startTime.AddHours(13);
            TimeOfDay expected = new TimeOfDay(1, 0);

            Assert.Equal(expected, actual);
        }
Ejemplo n.º 12
0
        public Dish FindDish(TimeOfDay timeOfDay, DishType dishType)
        {
            foreach (var dish in dishList)
                if (dish.TimeOfDay == timeOfDay && dish.DishType == dishType)
                    return dish;

            return null;
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Session" /> class.
        /// </summary>
        /// <param name="timeOfDay">The time of day.</param>
        public Session(TimeOfDay timeOfDay)
        {
            this._talks = new List<Talk>();
            this._timeOfDay = timeOfDay;

            // Total possible duration can be 3 hrs if it is a morning session; 4 hrs otherwise
            this.totalPossibleDuration = timeOfDay == TimeOfDay.Morning ? 60 * 3 : 60 * 4;
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Looks at a supplied time of day and figures out what TimeOfDayState needs to be returned that matches the time of day.
        /// </summary>
        /// <param name="currentTime">The current time.</param>
        /// <returns>
        /// Returns an instance of ITimeOfDayState that represents the current time of day in the game.
        /// </returns>
        internal TimeOfDayState GetTimeOfDayState(DateTime? currentTime = null)
        {
            TimeOfDay time = new TimeOfDay();
            time.Hour = currentTime.Value.Hour;
            time.Minute = currentTime.Value.Minute;

            return this.GetTimeOfDayState(time);
        }
Ejemplo n.º 15
0
        public void CanCalculateDuration_Normal()
        {
            TimeOfDay startTime = new TimeOfDay(10, 0);
            TimeOfDay endTime = new TimeOfDay(12, 0);

            TimeSpan duration = endTime - startTime;
            Assert.Equal(TimeSpan.FromHours(2), duration);
        }
Ejemplo n.º 16
0
 // Handle switching for the time of day
 void TimeChanged(TimeOfDay newTime)
 {
     Flip ();
     if (newTime == ForceRightWhen) {
         forceVec= force;
     } else {
         forceVec= -force;
     }
 }
Ejemplo n.º 17
0
        public void CanCompareTimes_Instance_Equal()
        {
            var t1 = new TimeOfDay(0, 0);
            var t2 = new TimeOfDay(0, 0);

            var c = t1.CompareTo(t2);

            Assert.Equal(0, c);
        }
Ejemplo n.º 18
0
        public void CanCompareTimes_Object_Equal()
        {
            var t1 = new TimeOfDay(0, 0);
            var t2 = new TimeOfDay(0, 0);

            var c = t1.CompareTo((object)t2);

            Assert.Equal(0, c);
        }
Ejemplo n.º 19
0
        public void CanCompareTimes_Static_After()
        {
            var t1 = new TimeOfDay(0, 1);
            var t2 = new TimeOfDay(0, 0);

            var c = TimeOfDay.Compare(t1, t2);

            Assert.Equal(1, c);
        }
Ejemplo n.º 20
0
        public void CanGetDateTimeFromTimeOnDate()
        {
            Date date = new Date(2000, 12, 31);
            TimeOfDay time = new TimeOfDay(23, 59, 59);
            DateTime dt = time.On(date);

            DateTime expected = new DateTime(2000, 12, 31, 23, 59, 59);
            Assert.Equal(expected, dt);
        }
Ejemplo n.º 21
0
 public void Schedule(string jobName, IJob job, TimeSpan interval, TimeOfDay startTime, IDictionary<string, string> jobData)
 {
     lock (_lock)
     {
         var schedule = new Schedule(Instance, jobName, job, interval, startTime, jobData);
         _schedules.Add(jobName, schedule);
         schedule.Start();
     }
 }
Ejemplo n.º 22
0
        public void CanGetDateTimeFromDateAtTime()
        {
            Date date = new Date(2000, 12, 31);
            TimeOfDay time = new TimeOfDay(23, 59, 59);
            DateTime dt = date.At(time);

            DateTime expected = new DateTime(2000, 12, 31, 23, 59, 59);
            Assert.Equal(expected, dt);
        }
Ejemplo n.º 23
0
 public PizzaMan(PizzaOven pizzaOven)
 {
     PizzaOven = pizzaOven;
     PizzaOven.AddObserver(this);
     Factory = new PizzaFactory();
     PriceStrategy = TimeOfDay.Lunch;
     EveningPriceStrategy = new EveningPriceStrategy();
     LunchPriceStrategy = new LunchPriceStrategy();
     NightPriceStrategy = new NightPriceStrategy();
 }
Ejemplo n.º 24
0
    /// <summary>
    /// Changes the Current Time
    /// </summary>
    /// <param name="newTime"></param>
    public void ChangeTime(TimeOfDay newTime)
    {
        _time = newTime;

        // If anyone is listening to the time change event,
        // let them know that the time changed
        if(TimeChanged != null)
        {
            TimeChanged(newTime);
        }
    }
Ejemplo n.º 25
0
        public static void Convertion(TimeOfDay time)
        {
            // 将TimeOfDay转换为string
            string time_to_str = time.ToString();
            Console.WriteLine(time_to_str);

            // 将string转换为TimeOfDay
            string str_to_time = "Evening";
            TimeOfDay time_type = (TimeOfDay)Enum.Parse(typeof(TimeOfDay), str_to_time, true);

        }
Ejemplo n.º 26
0
 public void AddDoseTime(TimeOfDay time)
 {
     if (!Times.ContainsKey(time))
     {
         Times.Add(time, 1);
     }
     else
     {
         Times[time] = Times[time] + 1;
     }
 }
Ejemplo n.º 27
0
 public Schedule(string instance, string jobName, IJob job, TimeSpan interval, TimeOfDay startTime, IDictionary<string, string> jobData)
 {
     Instance = instance;
     JobName = jobName;
     _job = job;
     JobData = jobData;
     Interval = interval;
     StartTime = startTime;
     _thread = new Thread(DoWork);
     _event = new AutoResetEvent(false);
 }
        public static bool HeadlightsStateByTimeOfDay(TimeOfDay timeOfDay)
        {
            switch (timeOfDay)
            {
                case TimeOfDay.Sunset:
                case TimeOfDay.Night:
                case TimeOfDay.LateNight:
                    return true;
            }

            return false;
        }
Ejemplo n.º 29
0
        public void TimeOfDayLessThan()
        {
            //Arange
            TimeOfDay Time1 = new TimeOfDay(4, 35, 30);
            TimeOfDay Time2 = new TimeOfDay(4, 46, 40);

            //Act
            bool IsGreater = Time1 < Time2;

            //Assert
            Assert.IsTrue(IsGreater);
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DefaultRealm"/> class.
        /// </summary>
        public DefaultRealm(IWorld world, TimeOfDay worldTimeOfDay)
        {
            ExceptionFactory
                .ThrowIf<ArgumentNullException>(world == null, "A valid world instance must be supplied.")
                .Or(worldTimeOfDay == null, "A valid TImeOfDay instance is required to initialize a realm.");

            this.World = world;
            this.timeOfDayStateManager = new TimeOfDayStateManager(world.TimeOfDayStates);
            this.ApplyTimeZoneOffset(worldTimeOfDay);

            this.CreationDate = DateTime.Now;
        }
Ejemplo n.º 31
0
 public void Parse_InvalidFormatWith4PartsInsteadOf3_ThrowsException()
 {
     TimeOfDay.Parse("10:10:10:10");
 }
Ejemplo n.º 32
0
        public void QueryOptionsOnTimeOfDayProperty()
        {
            this.TestClientContext.MergeOption = MergeOption.OverwriteChanges;
            var birthTime = new TimeOfDay(23, 59, 50, 340);

            // Post an entity
            Person person = new Person
            {
                FirstName  = "Sheldon",
                LastName   = "Cooper",
                UserName   = "******",
                BirthTime  = birthTime,
                BirthTime2 = birthTime,
            };

            this.TestClientContext.AddToPeople(person);
            this.TestClientContext.SaveChanges();
            long?personId = person.PersonId;

            // Filter this entity
            var persons = this.TestClientContext.People
                          .AddQueryOption("$filter", "BirthTime eq 23:59:50.34")
                          .ToList();

            Assert.Equal(1, persons.Count);
            persons = this.TestClientContext.People
                      .AddQueryOption("$filter", "BirthTime2 eq 23:59:01.00")
                      .ToList();
            Assert.Equal(1, persons.Count);

            // Filter with Parameter alias
            // ODL Bug: https://github.com/OData/odata.net/issues/316
            //this.TestClientContext.People
            //    .AddQueryOption("$filter", string.Format("BirthTime eq @p1 and PersonId gt {0}&@p1=23:59:50.34", personId - 1))
            //    .ToList();
            //Assert.Equal(1, persons.Count);

            // Projection
            this.TestClientContext.Detach(person);
            person = this.TestClientContext.People.Where(p => p.PersonId == personId)
                     .Select(p =>
                             new Person
            {
                PersonId   = p.PersonId,
                UserName   = p.UserName,
                BirthTime  = p.BirthTime,
                BirthTime2 = p.BirthTime2
            }).FirstOrDefault();
            Assert.Equal(personId, person.PersonId);
            Assert.Equal(birthTime, person.BirthTime);
            Assert.NotNull(person.UserName);
            Assert.Null(person.FirstName);
            Assert.Null(person.LastName);

            // Order by BirthTime desc
            var people2 = this.TestClientContext.People.OrderByDescending(p => p.BirthTime).ToList();

            Assert.Equal(birthTime, people2.First().BirthTime);
            people2 = this.TestClientContext.People.OrderByDescending(p => p.BirthTime2).ToList();
            Assert.Equal(birthTime, people2.First().BirthTime2);

            // Order by BirthTime
            people2 = this.TestClientContext.People.OrderBy(p => p.BirthTime).ToList();
            Assert.Equal(birthTime, people2.Last().BirthTime);
            people2 = this.TestClientContext.People.OrderBy(p => p.BirthTime2).ToList();
            Assert.Equal(birthTime, people2.Last().BirthTime2);

            // top
            people2 = this.TestClientContext.People.OrderBy(p => p.BirthTime).Take(3).ToList();
            Assert.Equal(3, people2.Count);
            people2 = this.TestClientContext.People.OrderBy(p => p.BirthTime2).Take(3).ToList();
            Assert.Equal(3, people2.Count);

            // skip
            people2 = this.TestClientContext.People.Skip((int)(personId - 1)).ToList();
            Assert.Equal(birthTime, people2.First().BirthTime);
            Assert.Equal(birthTime, people2.First().BirthTime2);

            // TODO GitHubIssue#46 : case for $count=true
        }
Ejemplo n.º 33
0
 public void Parse_Null_ThrowsException()
 {
     TimeOfDay.Parse(null);
 }
Ejemplo n.º 34
0
        /**
         **@ brief:  this method shutdown the Quartz which is a thread which automatically starts on the given time
         * first it will check the password if password is correct then it will shutdown the Day Schedular and KeepAliveJob Quartz
         *@ Params:  string password
         *@ return:  bool
         **/
        public bool shutdownMainQuartz(string password)
        {
            bool isSuccess = false;

            try
            {
                if (password == "abc")
                {
                    //////////////////////////////  keep job alive /////////////////////////
                    var schedulerFactory = new StdSchedulerFactory();
                    var scheduler        = schedulerFactory.GetScheduler();

                    var keepAliveJob     = JobBuilder.Create <KeepAliveJob>().Build();
                    var keepAliveTrigger = TriggerBuilder.Create()
                                           .WithSimpleSchedule(x => x.WithIntervalInMinutes(10).RepeatForever())
                                           .Build();
                    scheduler.ScheduleJob(keepAliveJob, keepAliveTrigger);
                    scheduler.Shutdown();

                    ///////////////////////////////// Day schedular /////////////////////////
                    var schedulerFact       = new StdSchedulerFactory();
                    var sched               = schedulerFact.GetScheduler();
                    var DaySchedular        = JobBuilder.Create <DaySchedular>().Build();
                    var DaySchedularTrigger = TriggerBuilder.Create()
                                              .WithDailyTimeIntervalSchedule(x => x.WithIntervalInHours(24).OnEveryDay().StartingDailyAt(TimeOfDay.HourAndMinuteOfDay(4, 0)))
                                              .Build();
                    sched.ScheduleJob(DaySchedular, DaySchedularTrigger);
                    sched.Shutdown();
                    isSuccess = true;
                }
                else
                {
                    isSuccess = false;
                }
            }
            catch (Exception ex)
            {
                isSuccess = false;
            }
            return(isSuccess);
        }
Ejemplo n.º 35
0
 public JobSchedulerOptions()
     : this(TimeOfDay.HourAndMinuteOfDay(23, 55), TimeOfDay.HourAndMinuteOfDay(23, 56), 20)
 {
 }
Ejemplo n.º 36
0
        /// <summary>
        /// Converts the TimeOfDay to a String.
        /// </summary>
        /// <param name="time">The <see cref="ODataToolkit.TimeOfDay"/> to be converted</param>
        /// <returns>A System.String representation of the supplied <see cref="ODataToolkit.TimeOfDay"/>.</returns>
        internal static string TimeOfDayAsXml(TimeOfDay time)
        {
            var value = time.ToString();

            return(value);
        }
        public static TimeOfDay NextTimeOfDayBetween(this Random random, TimeOfDay min, TimeOfDay max)
        {
            if (min == null)
            {
                throw new ArgumentNullException(nameof(min));
            }
            if (max == null)
            {
                throw new ArgumentNullException(nameof(max));
            }

            return(random.NextTimeOfDayBetween(min.AbsoluteSeconds, max.AbsoluteSeconds));
        }
Ejemplo n.º 38
0
 public IEnumerable <Dish> GetDishesByTimeOfDay(TimeOfDay timeOfDay)
 {
     return(this.Dishes.Where(dish => dish.TimeOfDay == timeOfDay));
 }
Ejemplo n.º 39
0
            public bool AddStream(Stream stream)
            {
                // if the stream clashes with another stream
                if (!Fits(stream))
                {
                    return(false);
                }

                // add to list of streams
                Streams.Add(stream);

                // run through list of classes
                foreach (Session session in stream.Classes)
                {
                    // increase total time spent in classes
                    TimeInClasses += session.Length;

                    // if we're adding the class to an empty day
                    if (_classesByDay[session.Day].Count == 0)
                    {
                        // increment day count
                        Days++;
                        // add start and ending times to totals
                        _totalStart += new TimeLength(session.StartTime.DayMinutes);
                        _totalEnd   += new TimeLength(session.EndTime.DayMinutes);

                        // add length to total time at uni
                        TimeAtUni += session.Length;
                    }
                    else
                    {
                        // if it's earlier than the earliest class of that day
                        if (session.StartTime < _classesByDay[session.Day][0].StartTime)
                        {
                            TimeLength difference = _classesByDay[session.Day][0].StartTime - session.StartTime;
                            // remove the difference for total start
                            _totalStart -= difference;
                            // add the difference for total time at uni
                            TimeAtUni += difference;
                        }
                        // if it's later than the latest class
                        if (session.EndTime > _classesByDay[session.Day][_classesByDay[session.Day].Count - 1].EndTime)
                        {
                            TimeLength difference = session.EndTime -
                                                    _classesByDay[session.Day][_classesByDay[session.Day].Count - 1]
                                                    .EndTime;
                            // add the difference for total end
                            _totalEnd += difference;
                            // add the difference for total time at uni
                            TimeAtUni += difference;
                        }
                    }
                    // update average day length
                    AverageDayLength = TimeAtUni / Days;

                    // add new classes to day-indexed list
                    _classesByDay[session.Day].Add(session);
                    //ClassesByDay_[session.Day].Sort();

                    // check class start/end times against maxima/minima
                    if (session.StartTime < EarlyStart)
                    {
                        EarlyStart = session.StartTime;
                    }
                    if (session.StartTime > LateStart)
                    {
                        LateStart = session.StartTime;
                    }
                    if (session.EndTime < EarlyEnd)
                    {
                        EarlyEnd = session.EndTime;
                    }
                    if (session.EndTime > LateEnd)
                    {
                        LateEnd = session.EndTime;
                    }

                    // check day length
                    TimeLength dayLength = _classesByDay[session.Day][_classesByDay[session.Day].Count - 1].EndTime -
                                           _classesByDay[session.Day][0].StartTime;
                    if (dayLength < MinDayLength)
                    {
                        MinDayLength = dayLength;
                    }
                    if (dayLength > MaxDayLength)
                    {
                        MaxDayLength = dayLength;
                    }
                }

                // clear break data
                NumberBreaks = 0;
                AverageBreak = new TimeLength(0, 0);
                ShortBreak   = new TimeLength(24, 0);
                LongBreak    = new TimeLength(0, 0);
                TimeInBreaks = new TimeLength(0, 0);
                // clear block data
                NumberBlocks = 0;
                AverageBlock = new TimeLength(0, 0);
                ShortBlock   = new TimeLength(24, 0);
                LongBlock    = new TimeLength(0, 0);
                // TODO: rewrite to avoid full sweep?
                // do a fresh sweep of all days to rebuild break/block data
                foreach (List <Session> daySessions in _classesByDay)
                {
                    // empty day - skip
                    if (daySessions.Count == 0)
                    {
                        continue;
                    }

                    int i;
                    CompareAdjacent(daySessions, out i);
                }

                if (NumberBreaks > 0)
                {
                    // divide the sum of breaks to find the mean
                    AverageBreak = TimeInBreaks / NumberBreaks;
                }

                // divide the sum of blocks to find the mean
                AverageBlock /= NumberBlocks;

                AverageStart = new TimeOfDay(_totalStart.TotalMinutes / Days);
                AverageEnd   = new TimeOfDay(_totalEnd.TotalMinutes / Days);

                return(true);
            }
Ejemplo n.º 40
0
 public void WriteValue(TimeOfDay value)
 {
     throw new System.NotImplementedException();
 }
        private static void Main(string[] args)
        {
            Common.Logging.LogManager.Adapter = new Common.Logging.Simple.ConsoleOutLoggerFactoryAdapter
            {
                Level = Common.Logging.LogLevel.Info
            };

            NameValueCollection properties = new NameValueCollection
            {
                // Setting some scheduler properties
                ["quartz.scheduler.instanceName"]    = "QuartzRavenDBDemo",
                ["quartz.scheduler.instanceId"]      = "instance_one",
                ["quartz.threadPool.type"]           = "Quartz.Simpl.SimpleThreadPool, Quartz",
                ["quartz.threadPool.threadCount"]    = "1",
                ["quartz.threadPool.threadPriority"] = "Normal",
                // Setting RavenDB as the persisted JobStore
                ["quartz.jobStore.type"] = "Quartz.Impl.RavenDB.RavenJobStore, Quartz.Impl.RavenDB",
            };

            try
            {
                ISchedulerFactory sf        = new StdSchedulerFactory(properties);
                IScheduler        scheduler = sf.GetScheduler();
                scheduler.Start();

                IJobDetail emptyFridgeJob = JobBuilder.Create <EmptyFridge>()
                                            .WithIdentity("EmptyFridgeJob", "Office")
                                            .Build();

                IJobDetail turnOffLightsJob = JobBuilder.Create <TurnOffLights>()
                                              .WithIdentity("TurnOffLightsJob", "Office")
                                              .Build();

                IJobDetail checkAliveJob = JobBuilder.Create <CheckAlive>()
                                           .WithIdentity("CheckAliveJob", "Office")
                                           .Build();

                // Weekly, Friday at 10 AM (Cron Trigger)
                var emptyFridgeTrigger = TriggerBuilder.Create()
                                         .WithIdentity("EmptyFridge", "Office")
                                         .WithCronSchedule("0 0 10 ? * FRI")
                                         .ForJob("EmptyFridgeJob", "Office")
                                         .Build();

                // Daily at 6 PM (Daily Interval Trigger)
                var turnOffLightsTrigger = TriggerBuilder.Create()
                                           .WithIdentity("TurnOffLights", "Office")
                                           .WithDailyTimeIntervalSchedule(s => s
                                                                          .WithIntervalInHours(24)
                                                                          .OnEveryDay()
                                                                          .StartingDailyAt(TimeOfDay.HourAndMinuteOfDay(18, 0)))
                                           .Build();

                // Periodic check every 10 seconds (Simple Trigger)
                ITrigger checkAliveTrigger = TriggerBuilder.Create()
                                             .WithIdentity("CheckAlive", "Office")
                                             .StartAt(DateTime.UtcNow.AddSeconds(3))
                                             .WithSimpleSchedule(x => x
                                                                 .WithIntervalInSeconds(10)
                                                                 .RepeatForever())
                                             .Build();


                scheduler.ScheduleJob(checkAliveJob, checkAliveTrigger);
                scheduler.ScheduleJob(emptyFridgeJob, emptyFridgeTrigger);
                scheduler.ScheduleJob(turnOffLightsJob, turnOffLightsTrigger);

                // some sleep to show what's happening
                Thread.Sleep(TimeSpan.FromSeconds(600));

                scheduler.Shutdown();
            }
            catch (SchedulerException se)
            {
                Console.WriteLine(se);
            }

            Console.WriteLine("Press any key to close the application");
            Console.ReadKey();
        }
Ejemplo n.º 42
0
 public FormLink <IImageSpaceAdapterGetter> this[TimeOfDay time]
 {
     get => time switch
Ejemplo n.º 43
0
        public static void Start()

        {
            IScheduler scheduler = StdSchedulerFactory.GetDefaultScheduler();

            scheduler.Start();
            IJobDetail job     = JobBuilder.Create <AutoInsertUpdateJob>().Build();
            ITrigger   trigger = TriggerBuilder.Create().WithDailyTimeIntervalSchedule(s => s.WithIntervalInHours(24).OnEveryDay()

                                                                                       .StartingDailyAt(TimeOfDay.HourAndMinuteOfDay(6, 0))).Build();



            scheduler.ScheduleJob(job, trigger);
        }
Ejemplo n.º 44
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            //Start();
            IScheduler defaultScheduler = StdSchedulerFactory.GetDefaultScheduler();

            defaultScheduler.Start();
            //IJobDetail AutoJob = JobBuilder.Create<AutoInsertUpdateJob>().WithIdentity("AutoJob", "Group1").Build();
            //ITrigger Trigger = SimpleScheduleTriggerBuilderExtensions.WithSimpleSchedule(
            //    TriggerBuilder.Create().WithIdentity("AutoJob", "Group1").StartNow(),
            //    x => x.WithIntervalInHours(24).RepeatForever()
            //    ).Build();
            IJobDetail job     = JobBuilder.Create <AutoInsertUpdateJob>().Build();
            ITrigger   trigger = TriggerBuilder.Create().WithDailyTimeIntervalSchedule(s => s.WithIntervalInHours(24).OnEveryDay()
                                                                                       .StartingDailyAt(TimeOfDay.HourAndMinuteOfDay(6, 0))).Build();
            ITrigger trigger1 = TriggerBuilder.Create().WithDailyTimeIntervalSchedule(s => s.WithIntervalInHours(24).OnEveryDay()
                                                                                      .StartingDailyAt(TimeOfDay.HourAndMinuteOfDay(15, 0))).Build();
            ITrigger trigger2 = TriggerBuilder.Create().WithDailyTimeIntervalSchedule(s => s.WithIntervalInHours(24).OnEveryDay()
                                                                                      .StartingDailyAt(TimeOfDay.HourAndMinuteOfDay(18, 0))).Build();

            defaultScheduler.ScheduleJob(job, trigger);
            //defaultScheduler.ScheduleJob(job, trigger1);
            //defaultScheduler.ScheduleJob(job, trigger2);
        }
Ejemplo n.º 45
0
 internal TrainTime CopyAndReflect(TimeOfDay aroundTime)
 {
     return(CopyWithTime(Time?.CopyAndReflect(aroundTime)));
 }
 public IActionResult BoundFunction(int key, [FromODataUri] Date modifiedDate, [FromODataUri] TimeOfDay modifiedTime,
                                    [FromODataUri] Date?nullableModifiedDate, [FromODataUri] TimeOfDay?nullableModifiedTime)
 {
     return(Ok(BuildString(modifiedDate, modifiedTime, nullableModifiedDate, nullableModifiedTime)));
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var items = new List <ScheduleChartItem>
                {
                    new ScheduleChartItem
                    {
                        Content         = "Resource 1",
                        GanttChartItems = new List <GanttChartItem>
                        {
                            new GanttChartItem {
                                Content = "Task A (Resource 1)", Start = new DateTime(year, month, 2, 8, 0, 0), Finish = new DateTime(year, month, 8, 16, 0, 0), CompletedFinish = new DateTime(year, month, 5, 16, 0, 0)
                            }
                        }
                    },
                    new ScheduleChartItem
                    {
                        Content         = "Resource 2",
                        GanttChartItems = new List <GanttChartItem>
                        {
                            new GanttChartItem {
                                Content = "Task A (Resource 2)", Start = new DateTime(year, month, 2, 8, 0, 0), Finish = new DateTime(year, month, 8, 16, 0, 0), CompletedFinish = new DateTime(year, month, 5, 16, 0, 0), AssignmentsContent = "50%"
                            },
                            new GanttChartItem {
                                Content = "Task B (Resource 2)", Start = new DateTime(year, month, 11, 8, 0, 0), Finish = new DateTime(year, month, 12, 16, 0, 0), CompletedFinish = new DateTime(year, month, 12, 16, 0, 0)
                            },
                            new GanttChartItem {
                                Content = "Task C (Resource 2)", Start = new DateTime(year, month, 14, 8, 0, 0), Finish = new DateTime(year, month, 14, 16, 0, 0)
                            }
                        }
                    },
                    new ScheduleChartItem
                    {
                        Content         = "Resource 3",
                        GanttChartItems = new List <GanttChartItem>
                        {
                            new GanttChartItem {
                                Content = "Task D (Resource 3)", Start = new DateTime(year, month, 12, 12, 0, 0), Finish = new DateTime(year, month, 14, 16, 0, 0)
                            }
                        }
                    }
                };
                for (int i = 4; i <= 16; i++)
                {
                    items.Add(new ScheduleChartItem
                    {
                        Content         = "Resource " + i,
                        GanttChartItems = new List <GanttChartItem>
                        {
                            new GanttChartItem {
                                Content = "Task X (Resource " + i + ")", Start = new DateTime(year, month, 2, 8, 0, 0), Finish = new DateTime(year, month, 5, 16, 0, 0)
                            },
                            new GanttChartItem {
                                Content = "Task Y (Resource " + i + ")", Start = new DateTime(year, month, 7, 8, 0, 0), Finish = new DateTime(year, month, 8, 16, 0, 0)
                            }
                        }
                    });
                }
                ScheduleChartView.Items = items;

                ScheduleChartView.DisplayedTime = new DateTime(year, month, 1);
                ScheduleChartView.CurrentTime   = new DateTime(year, month, 2, 12, 0, 0);

                // Set up continuous schedule (24/7).
                ScheduleChartView.WorkingWeekStart  = DayOfWeek.Sunday;
                ScheduleChartView.WorkingWeekFinish = DayOfWeek.Saturday;
                ScheduleChartView.VisibleDayStart   = TimeOfDay.Parse("00:00:00");
                ScheduleChartView.VisibleDayFinish  = TimeOfDay.Parse("24:00:00");

                // Optionally, initialize custom theme and templates (themes.js, templates.js).
                ScheduleChartView.InitializingClientCode = @"
                    initializeScheduleChartTheme(control.settings, theme);
                    initializeScheduleChartTemplates(control.settings, theme);";
            }
        }
Ejemplo n.º 48
0
        public static object ConvertPrimitiveValue(object value, Type type, TimeZoneInfo timeZoneInfo)
        {
            Contract.Assert(value != null);
            Contract.Assert(type != null);

            // if value is of the same type nothing to do here.
            if (value.GetType() == type || value.GetType() == Nullable.GetUnderlyingType(type))
            {
                return(value);
            }

            if (type.IsInstanceOfType(value))
            {
                return(value);
            }

            string str = value as string;

            if (type == typeof(char))
            {
                if (str == null || str.Length != 1)
                {
                    throw new ValidationException(Error.Format(SRResources.PropertyMustBeStringLengthOne));
                }

                return(str[0]);
            }
            else if (type == typeof(char?))
            {
                if (str == null || str.Length > 1)
                {
                    throw new ValidationException(Error.Format(SRResources.PropertyMustBeStringMaxLengthOne));
                }

                return(str.Length > 0 ? str[0] : (char?)null);
            }
            else if (type == typeof(char[]))
            {
                if (str == null)
                {
                    throw new ValidationException(Error.Format(SRResources.PropertyMustBeString));
                }

                return(str.ToCharArray());
            }
            else if (type == typeof(XElement))
            {
                if (str == null)
                {
                    throw new ValidationException(Error.Format(SRResources.PropertyMustBeString));
                }

                return(XElement.Parse(str));
            }
            else
            {
                type = Nullable.GetUnderlyingType(type) ?? type;
                if (TypeHelper.IsEnum(type))
                {
                    if (str == null)
                    {
                        throw new ValidationException(Error.Format(SRResources.PropertyMustBeString));
                    }

                    return(Enum.Parse(type, str));
                }
                else if (type == typeof(DateTime))
                {
                    if (value is DateTimeOffset)
                    {
                        DateTimeOffset dateTimeOffsetValue = (DateTimeOffset)value;
                        TimeZoneInfo   timeZone            = timeZoneInfo ?? TimeZoneInfo.Local;
                        dateTimeOffsetValue = TimeZoneInfo.ConvertTime(dateTimeOffsetValue, timeZone);
                        return(dateTimeOffsetValue.DateTime);
                    }

                    if (value is Date)
                    {
                        Date dt = (Date)value;
                        return((DateTime)dt);
                    }

                    throw new ValidationException(Error.Format(SRResources.PropertyMustBeDateTimeOffsetOrDate));
                }
                else if (type == typeof(TimeSpan))
                {
                    if (value is TimeOfDay)
                    {
                        TimeOfDay tod = (TimeOfDay)value;
                        return((TimeSpan)tod);
                    }

                    throw new ValidationException(Error.Format(SRResources.PropertyMustBeTimeOfDay));
                }
                else if (type == typeof(bool))
                {
                    bool result;
                    if (str != null && Boolean.TryParse(str, out result))
                    {
                        return(result);
                    }

                    throw new ValidationException(Error.Format(SRResources.PropertyMustBeBoolean));
                }
                else
                {
                    Contract.Assert(type == typeof(uint) || type == typeof(ushort) || type == typeof(ulong));

                    // Note that we are not casting the return value to nullable<T> as even if we do it
                    // CLR would unbox it back to T.
                    return(Convert.ChangeType(value, type, CultureInfo.InvariantCulture));
                }
            }
        }
Ejemplo n.º 49
0
 public TimeOfDay GetTimeOfDay([FromODataUri] TimeOfDay id)
 {
     ThrowIfInsideThrowsController();
     return(id);
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="_v3dLayer"></param>
 /// <param name="_newConfig"></param>
 public TimeOfDayChangedAction(V3DLayer _v3dLayer, TimeOfDay _newConfig)
 {
     v3dLayer  = _v3dLayer;
     oldConfig = v3dLayer.TimeOfDay;
     newConfig = _newConfig;
 }
        protected override TriggerPropertyBundle GetTriggerPropertyBundle(SimplePropertiesTriggerProperties props)
        {
            int    repeatCount     = (int)props.Long1;
            int    interval        = props.Int1;
            string intervalUnitStr = props.String1;
            string daysOfWeekStr   = props.String2;
            string timeOfDayStr    = props.String3;

            IntervalUnit intervalUnit = (IntervalUnit)Enum.Parse(typeof(IntervalUnit), intervalUnitStr, true);
            DailyTimeIntervalScheduleBuilder scheduleBuilder = DailyTimeIntervalScheduleBuilder.Create()
                                                               .WithInterval(interval, intervalUnit)
                                                               .WithRepeatCount(repeatCount);

            if (!string.IsNullOrEmpty(props.TimeZoneId))
            {
                scheduleBuilder.InTimeZone(TimeZoneUtil.FindTimeZoneById(props.TimeZoneId));
            }

            if (daysOfWeekStr != null)
            {
                ISet <DayOfWeek> daysOfWeek = new HashSet <DayOfWeek>();
                string[]         nums       = daysOfWeekStr.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                if (nums.Length > 0)
                {
                    foreach (string num in nums)
                    {
                        daysOfWeek.Add((DayOfWeek)Int32.Parse(num));
                    }
                    scheduleBuilder.OnDaysOfTheWeek(daysOfWeek);
                }
            }
            else
            {
                scheduleBuilder.OnDaysOfTheWeek(DailyTimeIntervalScheduleBuilder.AllDaysOfTheWeek);
            }

            if (timeOfDayStr != null)
            {
                string[]  nums = timeOfDayStr.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                TimeOfDay startTimeOfDay;
                if (nums.Length >= 3)
                {
                    int hour = Int32.Parse(nums[0]);
                    int min  = Int32.Parse(nums[1]);
                    int sec  = Int32.Parse(nums[2]);
                    startTimeOfDay = new TimeOfDay(hour, min, sec);
                }
                else
                {
                    startTimeOfDay = TimeOfDay.HourMinuteAndSecondOfDay(0, 0, 0);
                }
                scheduleBuilder.StartingDailyAt(startTimeOfDay);

                TimeOfDay endTimeOfDay;
                if (nums.Length >= 6)
                {
                    int hour = Int32.Parse(nums[3]);
                    int min  = Int32.Parse(nums[4]);
                    int sec  = Int32.Parse(nums[5]);
                    endTimeOfDay = new TimeOfDay(hour, min, sec);
                }
                else
                {
                    endTimeOfDay = TimeOfDay.HourMinuteAndSecondOfDay(23, 59, 59);
                }
                scheduleBuilder.EndingDailyAt(endTimeOfDay);
            }
            else
            {
                scheduleBuilder.StartingDailyAt(TimeOfDay.HourMinuteAndSecondOfDay(0, 0, 0));
                scheduleBuilder.EndingDailyAt(TimeOfDay.HourMinuteAndSecondOfDay(23, 59, 59));
            }


            int timesTriggered = props.Int2;

            string[] statePropertyNames  = { "timesTriggered" };
            object[] statePropertyValues = { timesTriggered };

            return(new TriggerPropertyBundle(scheduleBuilder, statePropertyNames, statePropertyValues));
        }
Ejemplo n.º 52
0
 /// <summary>
 /// Compare this object to a <see cref="TimeOfDay" /> instance.
 /// </summary>
 /// <param name="other">The instance to compare against.</param>
 /// <returns>-1, 0 or 1 according to whether the other object's value is less than, equal to or greater than this instance.</returns>
 public int CompareTo(TimeOfDay other)
 {
     return(Time.CompareTo(other));
 }
Ejemplo n.º 53
0
 /// <summary>
 /// Converts a string to a TimeOfDay value.
 /// </summary>
 /// <param name="text">String text to convert.</param>
 /// <param name="targetValue">After invocation, converted value.</param>
 /// <returns>true if the value was converted; false otherwise.</returns>
 internal static bool TryUriStringToTimeOfDay(string text, out TimeOfDay targetValue)
 {
     return(PlatformHelper.TryConvertStringToTimeOfDay(text, out targetValue));
 }
Ejemplo n.º 54
0
 public void Parse_StringIs01_00_00_Expecting1Hours()
 {
     Assert.AreEqual(1, TimeOfDay.Parse("01:00:00").Hours);
 }
Ejemplo n.º 55
0
 public void Parse_StringIs00_01_00_Expecting1Minutes()
 {
     Assert.AreEqual(1, TimeOfDay.Parse("00:01:00").Minutes);
 }
Ejemplo n.º 56
0
 public void Parse_StringIs00_00_01_Expecting1Seconds()
 {
     Assert.AreEqual(1, TimeOfDay.Parse("00:00:01").Seconds);
 }
Ejemplo n.º 57
0
 public JobSchedulerOptions(TimeOfDay performance, TimeOfDay kpi, int routing)
 {
     this.PerformanceScheduleTimeStart = performance;
     this.KPIEvalutionTimeStart        = kpi;
     this.AutomaticRoutingMinuteStart  = routing;
 }
Ejemplo n.º 58
0
 public void Parse_EmptyString_ThrowsException()
 {
     TimeOfDay.Parse("");
 }
 public IActionResult UnboundFunction([FromODataUri] Date p1, [FromODataUri] TimeOfDay p2,
                                      [FromODataUri] Date?p3, [FromODataUri] TimeOfDay?p4)
 {
     return(Ok(BuildString(p1, p2, p3, p4)));
 }
 public void Log(string message, params object[] args)
 {
     Console.WriteLine("{0} [Thread #{1}] {2}", TimeOfDay.ToString("hh:mm:tt"), Thread.CurrentThread.ManagedThreadId, String.Format(message, args));
     Thread.Sleep(200);
 }