Exemplo n.º 1
0
        public override bool ToBool()
        {
            DateTime leftValue  = leftSide.ToTime();
            DateTime rightValue = rightSide.ToTime();

            switch (type)
            {
            case ComparisonType.Equals:
                return(leftValue.Equals(rightValue) ? true : false);

            case ComparisonType.NotEquals:
                return(leftValue.Equals(rightValue) ? false : true);

            case ComparisonType.Bigger:
                return(leftValue.CompareTo(rightValue) == 1 ? true : false);

            case ComparisonType.Smaller:
                return(leftValue.CompareTo(rightValue) == -1 ? true : false);

            case ComparisonType.BiggerOrEquals:
                return(leftValue.CompareTo(rightValue) > -1 ? true : false);

            case ComparisonType.SmallerOrEquals:
                return(leftValue.CompareTo(rightValue) < 1 ? true : false);
            }

            return(false);
        }
Exemplo n.º 2
0
        protected override void FileAction(string fileName, string rawLocation)
        {
            string location = rawLocation + "\\" + fileName;

            try
            {
                File.SetCreationTime(@location, newTime.ToTime());
                RuntimeVariables.GetInstance().Success();
                Logger.GetInstance().LogCommand("Modification of " + fileName + " is now " + newTime.ToString());
            }
            catch (Exception ex)
            {
                RuntimeVariables.GetInstance().Failure();

                if (ex is IOException || ex is UnauthorizedAccessException)
                {
                    throw new CommandException("Action ignored! Access denied during changing creation time of " + fileName + ".");
                }
                else
                {
                    throw new CommandException("Action ignored! Something went wrong during changing creation time of " + fileName + ".");
                }
            }
        }
Exemplo n.º 3
0
        public override DateTime ToTime()
        {
            DateTime dtime = time.ToTime();

            int hours   = (int)clock.ToHour();
            int minutes = (int)clock.ToMinute();
            int seconds = (int)clock.ToSecond();

            TimeValidator.ValidateClock(hours, minutes, seconds);

            TimeSpan ts = new TimeSpan(hours, minutes, seconds);

            dtime = dtime.Date + ts;

            return(dtime);
        }
Exemplo n.º 4
0
        public override bool ToBool()
        {
            DateTime left  = leftBound.ToTime();
            DateTime right = rightBound.ToTime();
            DateTime v     = value.ToTime();

            if (left < right)
            {
                return((v > left) && (v < right));
            }
            else if (left > right)
            {
                return((v < left) && (v > right));
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 5
0
 public void Run()
 {
     RuntimeVariables.GetInstance().Actualize(name, value.ToTime());
 }
Exemplo n.º 6
0
 public override DateTime ToTime()
 {
     return(condition.ToBool() ? leftValue.ToTime() : rightValue.ToTime());
 }
Exemplo n.º 7
0
 public override decimal ToNumber()
 {
     return((decimal)arg0.ToTime().DayOfYear);
 }
Exemplo n.º 8
0
 private decimal YearsBetween()
 {
     return(Math.Abs((arg0.ToTime().Year - arg1.ToTime().Year)));
 }
Exemplo n.º 9
0
        public override DateTime ToTime()
        {
            DateTime source = referenceTime.ToTime();

            foreach (RelativeTimeStruct var in variables)
            {
                int count = (int)var.value.ToNumber();

                if (var.timeDirection == TimeDirection.Before)
                {
                    count *= -1;
                }

                try
                {
                    switch (var.type)
                    {
                    case RelativeTimeType.Centuries:
                        source = source.AddYears(count * 100);
                        break;

                    case RelativeTimeType.Decades:
                        source = source.AddYears(count * 10);
                        break;

                    case RelativeTimeType.Years:
                        source = source.AddYears(count);
                        break;

                    case RelativeTimeType.Months:
                        source = source.AddMonths(count);
                        break;

                    case RelativeTimeType.Weeks:
                        source = source.AddDays(count * 7);
                        break;

                    case RelativeTimeType.Days:
                        source = source.AddDays(count);
                        break;

                    case RelativeTimeType.Hours:
                        source = source.AddHours(count);
                        break;

                    case RelativeTimeType.Minutes:
                        source = source.AddMinutes(count);
                        break;

                    case RelativeTimeType.Seconds:
                        source = source.AddSeconds(count);
                        break;
                    }
                }
                catch (Exception)
                {
                    throw new RuntimeException("RUNTIME ERROR! Time out of range occured.");
                }
            }
            return(source);
        }