Exemple #1
0
 protected TimerBase(SerializationInfo info, StreamingContext context)
 {
     _id = (TimerId)info.GetValue("id", typeof(TimerId));
     _startTime = (Time?)info.GetValue("t", typeof(Time?));
     _interval = (Minute)info.GetValue("i", typeof(Minute));
     _schedules = (Dictionary<Minute, Action>)info.GetValue("s", typeof(Dictionary<Minute, Action>));
     _timerDelegate = new TimerCallback(this.Execute);
 }
        /// <summary>
        /// Get's the next valid second after the current .
        /// </summary>
        /// <param name="dateTime">The date time (fractions of a second are removed).</param>
        /// <param name="month">The month.</param>
        /// <param name="week">The week.</param>
        /// <param name="day">The day.</param>
        /// <param name="weekDay">The week day.</param>
        /// <param name="hour">The hour.</param>
        /// <param name="minute">The minute.</param>
        /// <param name="second">The second.</param>
        /// <param name="calendar">The calendar.</param>
        /// <param name="calendarWeekRule">The calendar week rule.</param>
        /// <param name="firstDayOfWeek">The first day of week.</param>
        /// <param name="inclusive">if set to <c>true</c> can return the time specified, otherwise, starts at the next second..</param>
        /// <returns>
        /// The next valid date (or <see cref="DateTime.MaxValue"/> if none).
        /// </returns>
        public static DateTime NextValid(
                this DateTime dateTime,
                Month month = Month.Every,
                Week week = Week.Every,
                Day day = Day.Every,
                WeekDay weekDay = WeekDay.Every,
                Hour hour = Hour.Zeroth,
                Minute minute = Minute.Zeroth,
                Second second = Second.Zeroth,
                Calendar calendar = null,
                CalendarWeekRule calendarWeekRule = CalendarWeekRule.FirstFourDayWeek,
                DayOfWeek firstDayOfWeek = DayOfWeek.Sunday,
                bool inclusive = false)
        {
            // Never case, if any are set to never, we'll never get a valid date.
            if ((month == Month.Never) || (week == Week.Never) ||
                (day == Day.Never) || (weekDay == WeekDay.Never) || (hour == Hour.Never) ||
                (minute == Minute.Never) ||
                (second == Second.Never))
                return DateTime.MaxValue;

            if (calendar == null)
                calendar = CultureInfo.CurrentCulture.Calendar;

            // Set the time to this second (or the next one if not inclusive), remove fractions of a second.
            dateTime = new DateTime(
                    dateTime.Year, dateTime.Month, dateTime.Day, dateTime.Hour, dateTime.Minute, dateTime.Second);
            if (!inclusive)
                dateTime = calendar.AddSeconds(dateTime, 1);

            // Every second case.
            if ((month == Month.Every) && (day == Day.Every) && (weekDay == WeekDay.Every) && (hour == Hour.Every) &&
                (minute == Minute.Every) && (second == Second.Every) &&
                (week == Week.Every))
                return calendar.AddSeconds(dateTime, 1);

            // Get days and months.
            IEnumerable<int> days = day.Days().OrderBy(dy => dy);
            IEnumerable<int> months = month.Months();

            // Remove months where the first day isn't in the month.
            int firstDay = days.First();
            if (firstDay > 28)
            {
                // 2000 is a leap year, so February has 29 days.
                months = months.Where(mn => calendar.GetDaysInMonth(2000, mn) >= firstDay);
                if (months.Count() < 1)
                    return DateTime.MaxValue;
            }

            // Get remaining date components.
            int y = calendar.GetYear(dateTime);
            int m = calendar.GetMonth(dateTime);
            int d = calendar.GetDayOfMonth(dateTime);

            int h = calendar.GetHour(dateTime);
            int n = calendar.GetMinute(dateTime);
            int s = calendar.GetSecond(dateTime);

            IEnumerable<int> weeks = week.Weeks();
            IEnumerable<DayOfWeek> weekDays = weekDay.WeekDays();
            IEnumerable<int> hours = hour.Hours().OrderBy(i => i);
            IEnumerable<int> minutes = minute.Minutes().OrderBy(i => i);
            IEnumerable<int> seconds = second.Seconds();
            
            do
            {
                foreach (int currentMonth in months)
                {
                    if (currentMonth < m)
                        continue;
                    if (currentMonth > m)
                    {
                        d = 1;
                        h = n = s = 0;
                    }
                    m = currentMonth;
                    foreach (int currentDay in days)
                    {
                        if (currentDay < d)
                            continue;
                        if (currentDay > d)
                            h = n = s = 0;
                        d = currentDay;

                        // Check day is valid for this month.
                        if ((d > 28) && (d > calendar.GetDaysInMonth(y, m)))
                            break;

                        // We have a potential day, check week and week day
                        dateTime = new DateTime(y, m, d, h, n, s);
                        if ((week != Week.Every) &&
                            (!weeks.Contains(dateTime.WeekNumber(calendar, calendarWeekRule, firstDayOfWeek))))
                            continue;
                        if ((weekDay != WeekDay.Every) &&
                            (!weekDays.Contains(calendar.GetDayOfWeek(dateTime))))
                            continue;

                        // We have a date match, check time.
                        foreach (int currentHour in hours)
                        {
                            if (currentHour < h) continue;
                            if (currentHour > h)
                                n = s = 0;
                            h = currentHour;
                            foreach (int currentMinute in minutes)
                            {
                                if (currentMinute < n) continue;
                                if (currentMinute > n)
                                    s = 0;
                                n = currentMinute;
                                foreach (int currentSecond in seconds)
                                {
                                    if (currentSecond < s) continue;
                                    return new DateTime(y, m, d, h, n, currentSecond, calendar);
                                }
                                n = s = 0;
                            }
                            h = n = s = 0;
                        }
                        d = 1;
                    }
                    d = 1;
                    h = n = s = 0;
                }
                y++;

                // Don't bother checking max year.
                if (y > 9998)
                    return DateTime.MaxValue;

                // Start next year
                m = d = 1;
                h = n = s = 0;
            } while (true);
        }
Exemple #3
0
 public Duration(int value, Minute unit)
 {
     Value = value;
     Unit  = unit;
 }
Exemple #4
0
 public BuiltInFunctions()
 {
     // Text
     Functions["len"]         = new Len();
     Functions["lower"]       = new Lower();
     Functions["upper"]       = new Upper();
     Functions["left"]        = new Left();
     Functions["right"]       = new Right();
     Functions["mid"]         = new Mid();
     Functions["replace"]     = new Replace();
     Functions["rept"]        = new Rept();
     Functions["substitute"]  = new Substitute();
     Functions["concatenate"] = new Concatenate();
     Functions["char"]        = new CharFunction();
     Functions["exact"]       = new Exact();
     Functions["find"]        = new Find();
     Functions["fixed"]       = new Fixed();
     Functions["proper"]      = new Proper();
     Functions["text"]        = new Text.Text();
     Functions["t"]           = new T();
     Functions["hyperlink"]   = new Hyperlink();
     // Numbers
     Functions["int"] = new CInt();
     // Math
     Functions["abs"]         = new Abs();
     Functions["asin"]        = new Asin();
     Functions["asinh"]       = new Asinh();
     Functions["cos"]         = new Cos();
     Functions["cosh"]        = new Cosh();
     Functions["power"]       = new Power();
     Functions["sign"]        = new Sign();
     Functions["sqrt"]        = new Sqrt();
     Functions["sqrtpi"]      = new SqrtPi();
     Functions["pi"]          = new Pi();
     Functions["product"]     = new Product();
     Functions["ceiling"]     = new Ceiling();
     Functions["count"]       = new Count();
     Functions["counta"]      = new CountA();
     Functions["countblank"]  = new CountBlank();
     Functions["countif"]     = new CountIf();
     Functions["countifs"]    = new CountIfs();
     Functions["fact"]        = new Fact();
     Functions["floor"]       = new Floor();
     Functions["sin"]         = new Sin();
     Functions["sinh"]        = new Sinh();
     Functions["sum"]         = new Sum();
     Functions["sumif"]       = new SumIf();
     Functions["sumifs"]      = new SumIfs();
     Functions["sumproduct"]  = new SumProduct();
     Functions["sumsq"]       = new Sumsq();
     Functions["stdev"]       = new Stdev();
     Functions["stdevp"]      = new StdevP();
     Functions["stdev.s"]     = new Stdev();
     Functions["stdev.p"]     = new StdevP();
     Functions["subtotal"]    = new Subtotal();
     Functions["exp"]         = new Exp();
     Functions["log"]         = new Log();
     Functions["log10"]       = new Log10();
     Functions["ln"]          = new Ln();
     Functions["max"]         = new Max();
     Functions["maxa"]        = new Maxa();
     Functions["median"]      = new Median();
     Functions["min"]         = new Min();
     Functions["mina"]        = new Mina();
     Functions["mod"]         = new Mod();
     Functions["average"]     = new Average();
     Functions["averagea"]    = new AverageA();
     Functions["averageif"]   = new AverageIf();
     Functions["averageifs"]  = new AverageIfs();
     Functions["round"]       = new Round();
     Functions["rounddown"]   = new Rounddown();
     Functions["roundup"]     = new Roundup();
     Functions["rand"]        = new Rand();
     Functions["randbetween"] = new RandBetween();
     Functions["quotient"]    = new Quotient();
     Functions["trunc"]       = new Trunc();
     Functions["tan"]         = new Tan();
     Functions["tanh"]        = new Tanh();
     Functions["atan"]        = new Atan();
     Functions["atan2"]       = new Atan2();
     Functions["atanh"]       = new Atanh();
     Functions["acos"]        = new Acos();
     Functions["acosh"]       = new Acosh();
     Functions["var"]         = new Var();
     Functions["varp"]        = new VarP();
     Functions["large"]       = new Large();
     Functions["small"]       = new Small();
     Functions["degrees"]     = new Degrees();
     // Information
     Functions["isblank"]    = new IsBlank();
     Functions["isnumber"]   = new IsNumber();
     Functions["istext"]     = new IsText();
     Functions["isnontext"]  = new IsNonText();
     Functions["iserror"]    = new IsError();
     Functions["iserr"]      = new IsErr();
     Functions["error.type"] = new ErrorType();
     Functions["iseven"]     = new IsEven();
     Functions["isodd"]      = new IsOdd();
     Functions["islogical"]  = new IsLogical();
     Functions["isna"]       = new IsNa();
     Functions["na"]         = new Na();
     Functions["n"]          = new N();
     // Logical
     Functions["if"]      = new If();
     Functions["iferror"] = new IfError();
     Functions["ifna"]    = new IfNa();
     Functions["not"]     = new Not();
     Functions["and"]     = new And();
     Functions["or"]      = new Or();
     Functions["true"]    = new True();
     Functions["false"]   = new False();
     // Reference and lookup
     Functions["address"] = new Address();
     Functions["hlookup"] = new HLookup();
     Functions["vlookup"] = new VLookup();
     Functions["lookup"]  = new Lookup();
     Functions["match"]   = new Match();
     Functions["row"]     = new Row()
     {
         SkipArgumentEvaluation = true
     };
     Functions["rows"] = new Rows()
     {
         SkipArgumentEvaluation = true
     };
     Functions["column"] = new Column()
     {
         SkipArgumentEvaluation = true
     };
     Functions["columns"] = new Columns()
     {
         SkipArgumentEvaluation = true
     };
     Functions["choose"]   = new Choose();
     Functions["index"]    = new Index();
     Functions["indirect"] = new Indirect();
     Functions["offset"]   = new Offset()
     {
         SkipArgumentEvaluation = true
     };
     // Date
     Functions["date"]       = new Date();
     Functions["today"]      = new Today();
     Functions["now"]        = new Now();
     Functions["day"]        = new Day();
     Functions["month"]      = new Month();
     Functions["year"]       = new Year();
     Functions["time"]       = new Time();
     Functions["hour"]       = new Hour();
     Functions["minute"]     = new Minute();
     Functions["second"]     = new Second();
     Functions["weeknum"]    = new Weeknum();
     Functions["weekday"]    = new Weekday();
     Functions["days360"]    = new Days360();
     Functions["yearfrac"]   = new Yearfrac();
     Functions["edate"]      = new Edate();
     Functions["eomonth"]    = new Eomonth();
     Functions["isoweeknum"] = new IsoWeekNum();
     Functions["workday"]    = new Workday();
 }
        /// <summary>
        /// 데이터베이스에서 데이터 삭제
        /// </summary>
        /// <param name="dataTable">변경된 데이터테이블</param>
        public void DeleteDataTable(DataTable dataTable)
        {
            //전달받은 데이터테이블중 삭제된 행을 새로운 데이터 테이블에 입력
            DataTable dtChanges = dataTable.GetChanges(DataRowState.Deleted);
            string    OnTime, OffTime;

            //테이블의 값이 있는지 확인
            if (dtChanges != null)
            {
                foreach (DataRow data in dtChanges.Rows)
                {
                    //변경된 데이터테이블의 값이 조건에 맞는지 확인
                    if ((!data["OnTime", DataRowVersion.Original].ToString().Contains(":") && data["OnTime", DataRowVersion.Original].ToString().Length != 4) || (!data["OffTime", DataRowVersion.Original].ToString().Contains(":") && data["OffTime", DataRowVersion.Original].ToString().Length != 4) ||
                        (data["OnTime", DataRowVersion.Original].ToString().Contains(":") && data["OnTime", DataRowVersion.Original].ToString().Length > 5) || (data["OffTime", DataRowVersion.Original].ToString().Contains(":") && data["OffTime", DataRowVersion.Original].ToString().Length > 5))
                    {
                        return;
                    }
                    else
                    {
                        string[] swap = SplitString(data["OnTime", DataRowVersion.Original].ToString(), ':');
                        int      Time, Minute;
                        Time   = Convert.ToInt32(swap[0]);
                        Minute = Convert.ToInt32(swap[1]);
                        OnTime = Time.ToString().PadLeft(2, '0') + ":" + Minute.ToString().PadLeft(2, '0');

                        if (Time < 0 || Time > 29 || Minute > 60 || Minute < 0)
                        {
                            return;
                        }

                        swap    = SplitString(data["OffTime", DataRowVersion.Original].ToString(), ':');
                        Time    = Convert.ToInt32(swap[0]);
                        Minute  = Convert.ToInt32(swap[1]);
                        OffTime = Time.ToString().PadLeft(2, '0') + ":" + Minute.ToString().PadLeft(2, '0');

                        if (Time < 0 || Time > 29 || Minute > 60 || Minute < 0)
                        {
                            return;
                        }
                    }

                    string phone = "";

                    //권한이 일반직원인지 확인
                    if (MemberData.GetMemberData.AuthorityData.Authority == 3)
                    {
                        phone = MemberData.GetMemberData.Phone;
                    }
                    else
                    {
                        int index = TransitionPage.wageManagement.cbName.SelectedIndex;
                        phone = CommData.GetCommData().getLoginDataList()[index].Phone;
                    }


                    WageData scheduleData = new WageData();

                    scheduleData.OnTime  = OnTime;
                    scheduleData.OffTime = OffTime;
                    scheduleData.Date    = data["Date", DataRowVersion.Original].ToString();

                    Delete(phone, scheduleData);
                    WageCalculation(phone, data["Date", DataRowVersion.Original].ToString());
                }
            }
        }
Exemple #6
0
 public override string ToString()
 {
     return(Hour.ToString("00") + Minute.ToString("00") + Second.ToString("00") + (Utc ? "Z" : string.Empty));
 }
Exemple #7
0
        private void AddTimer(Minute interval)
        {
            long startDateTicks = _startTime.Value.AsUtc().Ticks;
            long span = interval.AsTimeSpan().Ticks;
            long cycles;
            long remainder = Math.DivRem(DateTime.UtcNow.Ticks - startDateTicks, span, out cycles);
            long dueTime = startDateTicks + (span * (cycles + 1)) - remainder;

            _timers[interval] = new ThreadingTimer(_timerDelegate, interval, dueTime, span);
        }
Exemple #8
0
 public void RingAtEach(Minute interval, Minute duration)
 {
     _duration = duration.AsTimeSpan().Milliseconds;
     EmptySchedules();
     base.AddPeriodicTask(interval, Ring);
 }
Exemple #9
0
 public bool Equals(Minute other)
 {
     return(this.value == other.value);
 }
        /// <summary>Returns the string representation of the value of this instance.</summary>
        /// <param name="format">Format string using the usual characters to interpret custom datetime - as per standard DateTime custom formats</param>
        /// <returns>A string that represents the value of this instance.</returns>
        public String ToString(String format, IFormatProvider provider)
        {
            //parse and replace the format stuff
            MatchCollection matches = Regex.Matches(format, "([a-zA-z])\\1{0,}");

            for (int i = matches.Count - 1; i >= 0; i--)
            {
                Match m = matches[i];
                Int32 mIndex = m.Index, mLength = m.Length;

                if (mIndex > 0 && format[m.Index - 1] == '\\')
                {
                    if (m.Length == 1)
                    {
                        continue;
                    }
                    else
                    {
                        mIndex++;
                        mLength--;
                    }
                }
                switch (m.Value[0])
                {
                case 'y':
                    format = format.Substring(0, mIndex) + Year.ToString("D" + mLength) + format.Substring(mIndex + mLength);
                    break;

                case 'M':
                    if (mLength < 3)
                    {
                        String input2 = Month.ToString("D" + mLength);
                        format = format.Substring(0, mIndex) + input2 + format.Substring(mIndex + mLength);
                    }
                    else if (mLength == 3)
                    {
                        if (KSPDateStructure.CalendarType == CalendarTypeEnum.Earth)
                        {
                            format = format.Substring(0, mIndex) + System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetAbbreviatedMonthName(Month) + format.Substring(mIndex + mLength);
                        }
                        else
                        if (KSPDateStructure.MonthCount < 1)
                        {
                            String input2 = Month.ToString("D" + mLength);
                            format = format.Substring(0, mIndex) + input2 + format.Substring(mIndex + mLength);
                        }
                        else
                        {
                            format = format.Substring(0, mIndex) + KSPDateStructure.Months[Month].ToString().Substring(0, 3) + format.Substring(mIndex + mLength);
                        }
                    }
                    else
                    {
                        if (KSPDateStructure.CalendarType == CalendarTypeEnum.Earth)
                        {
                            format = format.Substring(0, mIndex) + System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(Month) + format.Substring(mIndex + mLength);
                        }
                        else
                        if (KSPDateStructure.MonthCount < 1)
                        {
                            String input2 = Month.ToString("D" + mLength);
                            format = format.Substring(0, mIndex) + input2 + format.Substring(mIndex + mLength);
                        }
                        else
                        {
                            format = format.Substring(0, mIndex) + KSPDateStructure.Months[Month] + format.Substring(mIndex + mLength);
                        }
                    }
                    break;

                case 'd':
                    format = format.Substring(0, mIndex) + Day.ToString("D" + mLength) + format.Substring(mIndex + mLength);
                    break;

                case 'h':
                    //how to do this one AM/PM Hours
                    String HalfDayTime = "";
                    switch (AMPM)
                    {
                    case AMPMEnum.AM:
                        HalfDayTime = Hour.ToString("D" + mLength.Clamp(1, (KSPDateStructure.HoursPerDay / 2).ToString().Length));
                        break;

                    case AMPMEnum.PM:
                        HalfDayTime = (Hour - (KSPDateStructure.HoursPerDay / 2)).ToString("D" + mLength.Clamp(1, (KSPDateStructure.HoursPerDay / 2).ToString().Length));
                        break;

                    case AMPMEnum.OddHoursPerDay:
                    default:
                        HalfDayTime = Hour.ToString("D" + mLength.Clamp(1, KSPDateStructure.HoursPerDay.ToString().Length));
                        break;
                    }

                    format = format.Substring(0, mIndex) + HalfDayTime + format.Substring(mIndex + mLength);
                    break;

                case 't':
                    if (AMPM != AMPMEnum.OddHoursPerDay)
                    {
                        format = format.Substring(0, mIndex) + AMPM.ToString().ToLower() + format.Substring(mIndex + mLength);
                    }
                    break;

                case 'T':
                    if (AMPM != AMPMEnum.OddHoursPerDay)
                    {
                        format = format.Substring(0, mIndex) + AMPM.ToString().ToUpper() + format.Substring(mIndex + mLength);
                    }
                    break;

                case 'H':
                    format = format.Substring(0, mIndex) + Hour.ToString("D" + mLength.Clamp(1, KSPDateStructure.HoursPerDay.ToString().Length)) + format.Substring(mIndex + mLength);
                    break;

                case 'm':
                    format = format.Substring(0, mIndex) + Minute.ToString("D" + mLength.Clamp(1, KSPDateStructure.MinutesPerHour.ToString().Length)) + format.Substring(mIndex + mLength);
                    break;

                case 's':
                    format = format.Substring(0, mIndex) + Second.ToString("D" + mLength.Clamp(1, KSPDateStructure.SecondsPerMinute.ToString().Length)) + format.Substring(mIndex + mLength);
                    break;

                default:
                    break;
                }
            }

            //Now strip out the \ , but not multiple \\
            format = Regex.Replace(format, "\\\\(?=[a-z])", "");

            return(format);
            //if (KSPDateStructure.CalendarType == CalendarTypeEnum.Earth)
            //    return String.Format(format, _EarthDateTime);
            //else
            //    return String.Format(format, this); //"TEST";
        }
 public BuiltInFunctions()
 {
     // Text
     Functions["len"]         = new Len();
     Functions["lower"]       = new Lower();
     Functions["upper"]       = new Upper();
     Functions["left"]        = new Left();
     Functions["right"]       = new Right();
     Functions["mid"]         = new Mid();
     Functions["replace"]     = new Replace();
     Functions["rept"]        = new Rept();
     Functions["substitute"]  = new Substitute();
     Functions["concatenate"] = new Concatenate();
     Functions["concat"]      = new Concat();
     Functions["char"]        = new CharFunction();
     Functions["exact"]       = new Exact();
     Functions["find"]        = new Find();
     Functions["fixed"]       = new Fixed();
     Functions["proper"]      = new Proper();
     Functions["search"]      = new Search();
     Functions["text"]        = new Text.Text();
     Functions["t"]           = new T();
     Functions["hyperlink"]   = new Hyperlink();
     Functions["value"]       = new Value();
     Functions["trim"]        = new Trim();
     Functions["clean"]       = new Clean();
     Functions["unicode"]     = new Unicode();
     Functions["unichar"]     = new Unichar();
     Functions["numbervalue"] = new NumberValue();
     // Numbers
     Functions["int"] = new CInt();
     // Math
     Functions["abs"]             = new Abs();
     Functions["asin"]            = new Asin();
     Functions["asinh"]           = new Asinh();
     Functions["acot"]            = new Acot();
     Functions["acoth"]           = new Acoth();
     Functions["cos"]             = new Cos();
     Functions["cot"]             = new Cot();
     Functions["coth"]            = new Coth();
     Functions["cosh"]            = new Cosh();
     Functions["csc"]             = new Csc();
     Functions["csch"]            = new Csch();
     Functions["power"]           = new Power();
     Functions["gcd"]             = new Gcd();
     Functions["lcm"]             = new Lcm();
     Functions["sec"]             = new Sec();
     Functions["sech"]            = new SecH();
     Functions["sign"]            = new Sign();
     Functions["sqrt"]            = new Sqrt();
     Functions["sqrtpi"]          = new SqrtPi();
     Functions["pi"]              = new Pi();
     Functions["product"]         = new Product();
     Functions["ceiling"]         = new Ceiling();
     Functions["ceiling.precise"] = new CeilingPrecise();
     Functions["ceiling.math"]    = new CeilingMath();
     Functions["iso.ceiling"]     = new IsoCeiling();
     Functions["combin"]          = new Combin();
     Functions["combina"]         = new Combina();
     Functions["count"]           = new Count();
     Functions["counta"]          = new CountA();
     Functions["countblank"]      = new CountBlank();
     Functions["countif"]         = new CountIf();
     Functions["countifs"]        = new CountIfs();
     Functions["fact"]            = new Fact();
     Functions["factdouble"]      = new FactDouble();
     Functions["floor"]           = new Floor();
     Functions["floor.precise"]   = new FloorPrecise();
     Functions["floor.math"]      = new FloorMath();
     Functions["radians"]         = new Radians();
     Functions["roman"]           = new Roman();
     Functions["sin"]             = new Sin();
     Functions["sinh"]            = new Sinh();
     Functions["sum"]             = new Sum();
     Functions["sumif"]           = new SumIf();
     Functions["sumifs"]          = new SumIfs();
     Functions["sumproduct"]      = new SumProduct();
     Functions["sumsq"]           = new Sumsq();
     Functions["sumxmy2"]         = new Sumxmy2();
     Functions["sumx2my2"]        = new SumX2mY2();
     Functions["sumx2py2"]        = new SumX2pY2();
     Functions["seriessum"]       = new Seriessum();
     Functions["stdev"]           = new Stdev();
     Functions["stdevp"]          = new StdevP();
     Functions["stdev.s"]         = new Stdev();
     Functions["stdev.p"]         = new StdevP();
     Functions["subtotal"]        = new Subtotal();
     Functions["exp"]             = new Exp();
     Functions["log"]             = new Log();
     Functions["log10"]           = new Log10();
     Functions["ln"]              = new Ln();
     Functions["max"]             = new Max();
     Functions["maxa"]            = new Maxa();
     Functions["median"]          = new Median();
     Functions["min"]             = new Min();
     Functions["mina"]            = new Mina();
     Functions["mod"]             = new Mod();
     Functions["mround"]          = new Mround();
     Functions["average"]         = new Average();
     Functions["averagea"]        = new AverageA();
     Functions["averageif"]       = new AverageIf();
     Functions["averageifs"]      = new AverageIfs();
     Functions["round"]           = new Round();
     Functions["rounddown"]       = new Rounddown();
     Functions["roundup"]         = new Roundup();
     Functions["rand"]            = new Rand();
     Functions["randbetween"]     = new RandBetween();
     Functions["rank"]            = new Rank();
     Functions["rank.eq"]         = new Rank();
     Functions["rank.avg"]        = new Rank(true);
     Functions["quotient"]        = new Quotient();
     Functions["trunc"]           = new Trunc();
     Functions["tan"]             = new Tan();
     Functions["tanh"]            = new Tanh();
     Functions["atan"]            = new Atan();
     Functions["atan2"]           = new Atan2();
     Functions["atanh"]           = new Atanh();
     Functions["acos"]            = new Acos();
     Functions["acosh"]           = new Acosh();
     Functions["var"]             = new Var();
     Functions["varp"]            = new VarP();
     Functions["large"]           = new Large();
     Functions["small"]           = new Small();
     Functions["degrees"]         = new Degrees();
     Functions["odd"]             = new Odd();
     Functions["even"]            = new Even();
     // Information
     Functions["isblank"]    = new IsBlank();
     Functions["isnumber"]   = new IsNumber();
     Functions["istext"]     = new IsText();
     Functions["isnontext"]  = new IsNonText();
     Functions["iserror"]    = new IsError();
     Functions["iserr"]      = new IsErr();
     Functions["error.type"] = new ErrorType();
     Functions["iseven"]     = new IsEven();
     Functions["isodd"]      = new IsOdd();
     Functions["islogical"]  = new IsLogical();
     Functions["isna"]       = new IsNa();
     Functions["na"]         = new Na();
     Functions["n"]          = new N();
     Functions["type"]       = new TypeFunction();
     // Logical
     Functions["if"]      = new If();
     Functions["ifs"]     = new Ifs();
     Functions["iferror"] = new IfError();
     Functions["ifna"]    = new IfNa();
     Functions["not"]     = new Not();
     Functions["and"]     = new And();
     Functions["or"]      = new Or();
     Functions["true"]    = new True();
     Functions["false"]   = new False();
     Functions["switch"]  = new Switch();
     // Reference and lookup
     Functions["address"]  = new Address();
     Functions["hlookup"]  = new HLookup();
     Functions["vlookup"]  = new VLookup();
     Functions["lookup"]   = new Lookup();
     Functions["match"]    = new Match();
     Functions["row"]      = new Row();
     Functions["rows"]     = new Rows();
     Functions["column"]   = new Column();
     Functions["columns"]  = new Columns();
     Functions["choose"]   = new Choose();
     Functions["index"]    = new RefAndLookup.Index();
     Functions["indirect"] = new Indirect();
     Functions["offset"]   = new Offset();
     // Date
     Functions["date"]             = new Date();
     Functions["today"]            = new Today();
     Functions["now"]              = new Now();
     Functions["day"]              = new Day();
     Functions["month"]            = new Month();
     Functions["year"]             = new Year();
     Functions["time"]             = new Time();
     Functions["hour"]             = new Hour();
     Functions["minute"]           = new Minute();
     Functions["second"]           = new Second();
     Functions["weeknum"]          = new Weeknum();
     Functions["weekday"]          = new Weekday();
     Functions["days"]             = new Days();
     Functions["days360"]          = new Days360();
     Functions["yearfrac"]         = new Yearfrac();
     Functions["edate"]            = new Edate();
     Functions["eomonth"]          = new Eomonth();
     Functions["isoweeknum"]       = new IsoWeekNum();
     Functions["workday"]          = new Workday();
     Functions["workday.intl"]     = new WorkdayIntl();
     Functions["networkdays"]      = new Networkdays();
     Functions["networkdays.intl"] = new NetworkdaysIntl();
     Functions["datevalue"]        = new DateValue();
     Functions["timevalue"]        = new TimeValue();
     // Database
     Functions["dget"]     = new Dget();
     Functions["dcount"]   = new Dcount();
     Functions["dcounta"]  = new DcountA();
     Functions["dmax"]     = new Dmax();
     Functions["dmin"]     = new Dmin();
     Functions["dsum"]     = new Dsum();
     Functions["daverage"] = new Daverage();
     Functions["dvar"]     = new Dvar();
     Functions["dvarp"]    = new Dvarp();
     //Finance
     Functions["pmt"] = new Pmt();
 }
 public override int GetHashCode()
 {
     unchecked {
         return((Minute.GetHashCode() * 397) ^ (Name?.GetHashCode() ?? 0));
     }
 }
Exemple #13
0
 public override string ToString()
 {
     return(Hour.ToString("00") + ":" + Minute.ToString("00"));
 }
Exemple #14
0
 public override string ToString()
 {
     return(String.Format("{0,2}:{1,2}:{2,2}:{3,2}", Day.ToString("D2"), Hour.ToString("D2"), Minute.ToString("D2"), Second.ToString("D2")));
     //return $"{Day}:{Hour}:{Minute}:{Second}";
 }
Exemple #15
0
        protected void UploadFitBitData()
        {
            try
            {
                // Get the fitbit client data
                FitbitClient client = GetFitbitClient();

                // Get the most recent upload date for steps
                string userId = Session["UserId"].ToString();

                var latestSteps = db.Steps.Where(m => m.AspNetUser.Id == userId)
                                  .OrderByDescending(m => m.StepDate)
                                  .FirstOrDefault();

                // Convert lastUpload date to DateTime for comparison
                DateTime lastUploadDateSteps = (DateTime)latestSteps.StepDate;

                // Get total days between now and last upload
                int daysSteps = Convert.ToInt32((DateTime.Now - lastUploadDateSteps).TotalDays);
                TimeSeriesDataList stepsData = client.GetTimeSeries(TimeSeriesResourceType.Steps, DateTime.Now.AddDays(-daysSteps), DateTime.Now);

                // Loop through results to total steps since last upload
                int dayCountSteps = stepsData.DataList.Count - 1;
                foreach (var d in stepsData.DataList)
                {
                    int steps = Convert.ToInt32(d.Value);
                    if (Convert.ToDateTime(latestSteps.StepDate).AddDays(-(dayCountSteps--)) == d.DateTime)
                    {
                        Step lastSteps = db.Steps.Where(m => m.AspNetUser.Id == userId && m.StepDate == d.DateTime)
                                         .FirstOrDefault();
                        lastSteps.StepCount = steps;

                        // Change state to modified
                        db.Entry(lastSteps).State = System.Data.Entity.EntityState.Modified;
                        db.SaveChanges();
                    }
                    else
                    {
                        // Add the record to the database
                        Step step = new Step();
                        step.StepCount = steps;
                        step.StepDate  = d.DateTime;
                        step.UserId    = Session["UserId"].ToString();
                        db.Steps.Add(step);
                        db.SaveChanges();
                    }
                }

                // Get the most recent upload date for distances
                var latestDistance = db.Distances.Where(m => m.AspNetUser.Id == userId)
                                     .OrderByDescending(m => m.DistanceDate)
                                     .FirstOrDefault();

                // Convert lastUpload date to DateTime for comparison
                DateTime lastUploadDateDistances = (DateTime)latestDistance.DistanceDate;

                // Get total days between now and last upload
                int daysDistances = Convert.ToInt32((DateTime.Now - lastUploadDateDistances).TotalDays);
                TimeSeriesDataList distanceData = client.GetTimeSeries(TimeSeriesResourceType.Distance, DateTime.Now.AddDays(-daysDistances), DateTime.Now);

                // Loop through results to total steps since last upload
                int dayCountDistances = distanceData.DataList.Count - 1;
                foreach (var d in distanceData.DataList)
                {
                    decimal distances = Convert.ToDecimal(d.Value);
                    if (Convert.ToDateTime(latestDistance.DistanceDate).AddDays(-(dayCountDistances--)) == d.DateTime)
                    {
                        Distance lastDistances = db.Distances.Where(m => m.AspNetUser.Id == userId && m.DistanceDate == d.DateTime)
                                                 .FirstOrDefault();
                        lastDistances.DistanceCount = distances;

                        // Change state to modified
                        db.Entry(lastDistances).State = System.Data.Entity.EntityState.Modified;
                        db.SaveChanges();
                    }
                    else
                    {
                        // Add the record to the database
                        Distance distance = new Distance();
                        distance.DistanceCount = distances;
                        distance.DistanceDate  = d.DateTime;
                        distance.UserId        = Session["UserId"].ToString();
                        db.Distances.Add(distance);
                        db.SaveChanges();
                    }
                }

                // Get the most recent upload date for minutes
                var latestMinutes = db.Minutes.Where(m => m.AspNetUser.Id == userId)
                                    .OrderByDescending(m => m.MinuteDate)
                                    .FirstOrDefault();

                // Convert lastUpload date to DateTime for comparison
                DateTime lastUploadDateMinutes = (DateTime)latestMinutes.MinuteDate;

                // Get total days between now and last upload
                int daysMinutes = Convert.ToInt32((DateTime.Now - lastUploadDateMinutes).TotalDays);
                TimeSeriesDataList lightlyActive = client.GetTimeSeries(TimeSeriesResourceType.MinutesLightlyActive, DateTime.Now.AddDays(-daysMinutes), DateTime.Now);
                TimeSeriesDataList fairlyActive  = client.GetTimeSeries(TimeSeriesResourceType.MinutesFairlyActive, DateTime.Now.AddDays(-daysMinutes), DateTime.Now);

                // Join the results of both minute datas together so we only have to use one loop to get total minutes
                var minutesData = lightlyActive.DataList.Zip(fairlyActive.DataList, (lightly, fairly) => new { LightlyActive = lightly, FairlyActive = fairly }).ToList();

                // Loop through results to total steps since last upload
                int dayCountMinutes = minutesData.Count - 1;
                foreach (var d in minutesData)
                {
                    decimal minutes = Convert.ToDecimal(d.FairlyActive.Value) + Convert.ToDecimal(d.LightlyActive.Value);
                    if (Convert.ToDateTime(latestMinutes.MinuteDate).AddDays(-(dayCountMinutes--)) == d.FairlyActive.DateTime)
                    {
                        Minute lastMinutes = db.Minutes.Where(m => m.AspNetUser.Id == userId && m.MinuteDate == d.FairlyActive.DateTime)
                                             .FirstOrDefault();
                        lastMinutes.MinuteCount = minutes;

                        // Change state to modified
                        db.Entry(lastMinutes).State = System.Data.Entity.EntityState.Modified;
                        db.SaveChanges();
                    }
                    else
                    {
                        // Add the record to the database
                        Minute minute = new Minute();
                        minute.MinuteCount = minutes;
                        minute.MinuteDate  = d.FairlyActive.DateTime;
                        minute.UserId      = Session["UserId"].ToString();
                        db.Minutes.Add(minute);
                        db.SaveChanges();
                    }
                }

                lblCRUDMessage.Text     = "FitBit Data successfully synchronized.";
                lblCRUDMessage.CssClass = "text-success";
            }
            catch (DataException dx)
            {
                lblCRUDMessage.Text     = "Unable to synchronize FitBit Data. To try again, click the 'Synchronize FitBit Data' button. If the error persists, please inform an Administrator.";
                lblCRUDMessage.CssClass = "text-danger";
                LogFile.WriteToFile("FitBitManager.aspx.cs", "UploadFitBitData", dx, User.Identity.Name + " tried to synchronize FitBit Data.", "HPSErrorLog.txt");
            }
            catch (Exception ex)
            {
                lblCRUDMessage.Text     = "Unable to synchronize FitBit Data. To try again, click the 'Synchronize FitBit Data' button. If the error persists, please inform an Administrator.";
                lblCRUDMessage.CssClass = "text-danger";
                LogFile.WriteToFile("FitBitManager.aspx.cs", "UploadFitBitData", ex, User.Identity.Name + " tried to synchronize FitBit Data.", "HPSErrorLog.txt");
            }
        }
Exemple #16
0
 public CookingEventArgs(Time time, Temperature temperature, Minute plannedConclusion)
 {
     Time = time;
     Temperature = temperature;
     PlannedConclusion = plannedConclusion;
 }
Exemple #17
0
 object r()
 {
     int i = 0, n, t = (sbyte)b[j++]; if (t < 0) switch (t)
         {
             case -1: return rb();
             case -4: return b[j++];
             case -5: return rh();
             case -6: return ri();
             case -7: return rj();
             case -8: return re();
             case -9: return rf();
             case -10: return rc();
             case -11: return rs();
             case -12: return rp();
             case -13: return rm();
             case -14: return rd();
             case -15: return rz();
             case -16: return rn();
             case -17: return ru();
             case -18: return rv();
             case -19: return rt();
         }
     if (t > 99) { if (t == 101 && b[j++] == 0)return null; throw new KException("func"); } if (t == 99) return new Dict(r(), r()); j++; if (t == 98) return new Flip((Dict)r()); n = ri(); switch (t)
     {
         case 0: object[] L = new object[n]; for (; i < n; i++) L[i] = r(); return L;
         case 1: bool[] B = new bool[n]; for (; i < n; i++) B[i] = rb(); return B;
         case 4: byte[] G = new byte[n]; for (; i < n; i++) G[i] = b[j++]; return G;
         case 5: short[] H = new short[n]; for (; i < n; i++) H[i] = rh(); return H;
         case 6: int[] I = new int[n]; for (; i < n; i++) I[i] = ri(); return I;
         case 7: long[] J = new long[n]; for (; i < n; i++) J[i] = rj(); return J;
         case 8: float[] E = new float[n]; for (; i < n; i++) E[i] = re(); return E;
         case 9: double[] F = new double[n]; for (; i < n; i++) F[i] = rf(); return F;
         case 10: char[] C = e.GetChars(b, j, n); j += n; return C;
         case 11: String[] S = new String[n]; for (; i < n; i++) S[i] = rs(); return S;
         case 12: DateTime[] P = new DateTime[n]; for (; i < n; i++) P[i] = rp(); return P;
         case 13: Month[] M = new Month[n]; for (; i < n; i++) M[i] = rm(); return M;
         case 14: Date[] D = new Date[n]; for (; i < n; i++) D[i] = rd(); return D;
         case 15: DateTime[] Z = new DateTime[n]; for (; i < n; i++) Z[i] = rz(); return Z;
         case 16: KTimespan[] N = new KTimespan[n]; for (; i < n; i++) N[i] = rn(); return N;
         case 17: Minute[] U = new Minute[n]; for (; i < n; i++) U[i] = ru(); return U;
         case 18: Second[] V = new Second[n]; for (; i < n; i++) V[i] = rv(); return V;
         case 19: TimeSpan[] T = new TimeSpan[n]; for (; i < n; i++) T[i] = rt(); return T;
     } return null;
 }
Exemple #18
0
        /// <summary>
        /// Возврашает строку в формате "HH.mm"
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            string result = Hour.ToString("00") + "." + Minute.ToString("00");

            return(result);
        }
Exemple #19
0
 protected void RemovePeriodicTask(Minute interval, Action action)
 {
     if(null == action)
         throw new ArgumentNullException("action");
     if(null != action.Target && this != action.Target)
         throw new ArgumentException("The action must be either a static method or a method of this.","action");
     RemoveAction(interval, action);
 }
Exemple #20
0
        }                                                               // Useful to know if "0" means UTC or just undefined

        public override string ToString()
        {
            if (Status == DateStatus.Unused)
            {
                return(string.Empty);
            }
            if (Status == DateStatus.Open)
            {
                return(SpecialValues.Open);
            }
            if (Status == DateStatus.Unknown)
            {
                return(string.Empty);
            }
            if (!Year.HasValue)
            {
                return(string.Empty);
            }

            // FLAG GROUPINGS.

            var isSingleUncertain = Year.IsUncertain && !Month.IsUncertain;
            var isSingleApprox    = Year.IsApproximate && !Month.IsApproximate;

            string result = string.Empty;

            AddFlagsToString(ref result, isSingleApprox, isSingleUncertain);

            result += Year.ToString(4);

            if (Month.HasValue)
            {
                result += "-";

                var isLeftUncertain = !Year.IsUncertain && Month.IsUncertain;
                var isLeftApprox    = !Year.IsApproximate && Month.IsApproximate;

                AddFlagsToString(ref result, isLeftApprox, isLeftUncertain);

                result += Month.ToString(2).PadLeft(2, '0');

                var isRightUncertain = Year.IsUncertain && Month.IsUncertain && !Day.IsUncertain;
                var isRightApprox    = Year.IsApproximate && Month.IsApproximate && !Day.IsApproximate;

                AddFlagsToString(ref result, isRightApprox, isRightUncertain);

                if (Day.HasValue)
                {
                    result         += "-";
                    isLeftUncertain = !(Year.IsUncertain && Month.IsUncertain) && Day.IsUncertain;
                    isLeftApprox    = !(Year.IsApproximate && Month.IsApproximate) && Day.IsApproximate;

                    AddFlagsToString(ref result, isLeftApprox, isLeftUncertain);

                    result += Day.ToString(2).PadLeft(2, '0');

                    isRightUncertain = Year.IsUncertain && Month.IsUncertain && Day.IsUncertain;
                    isRightApprox    = Year.IsApproximate && Month.IsApproximate && Day.IsApproximate;

                    AddFlagsToString(ref result, isRightApprox, isRightUncertain);

                    if ((Hour > 0) || (Minute > 0) || (Second > 0))
                    {
                        result += "T" + Hour.ToString("00") + ":" + Minute.ToString("00") + ":" + Second.ToString("00");
                        if (TimeZoneOffset == 0)
                        {
                            // The standard is somewhat unclear, but suggests that if there is no "Z" and no TZ offset,
                            // the date does not define a time zone and should not be serialized to use UTC.
                            if (!HasTimeZoneOffset)
                            {
                                return(result);
                            }
                            return(result + "Z");
                        }
                        else
                        {
                            var tzHour   = TimeZoneOffset / 60;
                            var tzMinute = TimeZoneOffset % 60;
                            result +=
                                (TimeZoneOffset < 0 ? "-" : "+")
                                + tzHour.ToString("00")
                                + ":" + tzMinute.ToString("00");
                        }
                    }
                }
            }
            return(result);
        }
Exemple #21
0
 private void RemoveTimer(Minute interval)
 {
     ThreadingTimer timer = _timers[interval];
     timer.Dispose();
     _timers.Remove(interval);
 }
Exemple #22
0
        public void GetPreviousMinuteTest()
        {
            Minute minute = new Minute();

            Assert.Equal(minute.GetPreviousMinute(), minute.AddMinutes(-1));
        }         // GetPreviousMinuteTest
        public void WageCalculation(string phone, string date)
        {
            WageData scheduleData = Select(phone, date);
            int      Wage         = SelectWage(phone);

            //출근,퇴근 시간, 분 분리
            int OnTime, OnMinute, OffTime, OffMinute;

            string[] swap = SplitString(scheduleData.OnTime, ':');

            OnTime   = Convert.ToInt32(swap[0]);
            OnMinute = Convert.ToInt32(swap[1]);

            swap = SplitString(scheduleData.OffTime, ':');

            OffTime   = Convert.ToInt32(swap[0]);
            OffMinute = Convert.ToInt32(swap[1]);

            //시간들 계산
            int Time, Minute;

            //24시 이후 퇴근은 24를 더해서 계산
            if (OffTime < 5)
            {
                OffTime += 24;
            }

            //오전 6시 이후 출근
            if (OnTime >= 6)
            {
                //일반시간
                if (OffTime < 22)
                {
                    Time = OffTime - OnTime;
                    if (OnMinute <= OffMinute)
                    {
                        Minute = OffMinute - OnMinute;
                    }
                    else
                    {
                        Time  -= 1;
                        Minute = (OffMinute + 60) - OnMinute;
                    }
                    scheduleData.Time = Time + ":" + Minute.ToString().PadLeft(2, '0');
                }
                //야간시간
                else
                {
                    if (OnTime >= 22)
                    {
                        Time   = 0;
                        Minute = 0;

                        OffMinute -= OnMinute;
                    }
                    else
                    {
                        Time   = 22 - OnTime;
                        Time  -= 1;
                        Minute = 60 - OnMinute;

                        if (Minute >= 60)
                        {
                            Time   += 1;
                            Minute -= 60;
                        }
                    }
                    scheduleData.Time = Time + ":" + Minute.ToString().PadLeft(2, '0');

                    if (OnTime <= 22)
                    {
                        Time = OffTime - 22;
                    }
                    else
                    {
                        Time = OffTime - OnTime;
                    }
                    Minute = OffMinute;
                    scheduleData.NightTime = Time + ":" + Minute.ToString().PadLeft(2, '0');
                }
            }
            //오전 6시 이전 출근
            else
            {
                //일반시간
                if (OffTime < 22)
                {
                    Time              = OffTime - 6;
                    Minute            = OffMinute;
                    scheduleData.Time = Time + ":" + Minute.ToString().PadLeft(2, '0');
                }
                //야간시간
                else
                {
                    Time = (6 - OnTime) + (OffTime - 22);
                    if (OnMinute <= OffMinute)
                    {
                        Minute = OffMinute - OnMinute;
                    }
                    else
                    {
                        Time  -= 1;
                        Minute = (OffMinute + 60) - OnMinute;
                    }
                    scheduleData.NightTime = Time + ":" + Minute.ToString().PadLeft(2, '0');
                }
            }

            //총 시간
            if (!scheduleData.Time.Equals(""))
            {
                swap   = SplitString(scheduleData.Time, ':');
                Time   = Convert.ToInt32(swap[0]);
                Minute = Convert.ToInt32(swap[1]);
            }

            if (!scheduleData.NightTime.Equals(""))
            {
                swap    = SplitString(scheduleData.NightTime, ':');
                Time   += Convert.ToInt32(swap[0]);
                Minute += Convert.ToInt32(swap[1]);
            }

            if (Minute >= 60)
            {
                Time   += 1;
                Minute -= 60;
            }
            scheduleData.TotalTime = Time + ":" + Minute.ToString().PadLeft(2, '0');

            //휴계시간
            if ((Time / 4) > 0)
            {
                Minute = (Time / 4) * 30;
                Time   = 0;
                if (Minute >= 60)
                {
                    Time   += 1;
                    Minute -= 60;
                }
                scheduleData.RestTime = Time + ":" + Minute.ToString().PadLeft(2, '0');
            }

            //연장시간
            swap   = SplitString(scheduleData.TotalTime, ':');
            Time   = Convert.ToInt32(swap[0]);
            Minute = Convert.ToInt32(swap[1]);
            if (Time > 8)
            {
                Time -= 8;
                scheduleData.ExtensionTime = Time + ":" + Minute.ToString().PadLeft(2, '0');

                //일반시간에서 연장시간 빼기
                int Time1, Minute1;
                swap   = SplitString(scheduleData.Time, ':');
                Time   = Convert.ToInt32(swap[0]);
                Minute = Convert.ToInt32(swap[1]);

                swap    = SplitString(scheduleData.ExtensionTime, ':');
                Time1   = Convert.ToInt32(swap[0]);
                Minute1 = Convert.ToInt32(swap[1]);

                Time -= Time1;

                if (Minute < Minute1)
                {
                    Time   -= 1;
                    Minute += 60;
                }

                Minute -= Minute1;

                scheduleData.Time = Time + ":" + Minute;
            }

            //일반시급
            if (!scheduleData.Time.Equals(""))
            {
                swap   = SplitString(scheduleData.Time, ':');
                Time   = Convert.ToInt32(swap[0]);
                Minute = Convert.ToInt32(swap[1]);

                scheduleData.Wage = ((Wage * Time) + (Wage * Minute) / 60).ToString();
            }
            else
            {
                scheduleData.Wage = "0";
            }

            //휴계시급
            if (!scheduleData.RestTime.Equals(""))
            {
                swap   = SplitString(scheduleData.RestTime, ':');
                Time   = Convert.ToInt32(swap[0]);
                Minute = Convert.ToInt32(swap[1]);

                scheduleData.RestWage = ((Wage * Time) + (Wage * Minute) / 60).ToString();
            }
            else
            {
                scheduleData.RestWage = "0";
            }

            //연장시급
            if (!scheduleData.ExtensionTime.Equals(""))
            {
                swap   = SplitString(scheduleData.ExtensionTime, ':');
                Time   = Convert.ToInt32(swap[0]);
                Minute = Convert.ToInt32(swap[1]);

                scheduleData.ExtensionWage = string.Format("{0:F0}", ((Wage * Time) + (Wage * Minute) / 60) * 1.5);
            }
            else
            {
                scheduleData.ExtensionWage = "0";
            }
            //야간시급
            if (!scheduleData.NightTime.Equals(""))
            {
                swap   = SplitString(scheduleData.NightTime, ':');
                Time   = Convert.ToInt32(swap[0]);
                Minute = Convert.ToInt32(swap[1]);

                scheduleData.NightWage = string.Format("{0:F0}", ((Wage * Time) + (Wage * Minute) / 60) * 1.5);
            }
            else
            {
                scheduleData.NightWage = "0";
            }

            //총 시급
            scheduleData.TotalWage = (Convert.ToInt32(scheduleData.Wage) + Convert.ToInt32(scheduleData.ExtensionWage)
                                      + Convert.ToInt32(scheduleData.NightWage) - Convert.ToInt32(scheduleData.RestWage)).ToString();


            Update(phone, scheduleData);
        }
Exemple #24
0
        public void GetNextMinuteTest()
        {
            Minute minute = new Minute();

            Assert.Equal(minute.GetNextMinute(), minute.AddMinutes(1));
        }         // GetNextMinuteTest
Exemple #25
0
 public override string ToString()
 {
     return(Hour.ToString() + ":" + Minute.ToString() + ":" + Second.ToString());
 }
Exemple #26
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (EventType_CD != null)
            {
                iEvent.ToolTip = Minute.ToString() + "'";
                Dictionary <int, string> eventFlagMap = UIHelper.EventCodeEventFlagsMap[EventType_CD];

                foreach (int flag in eventFlagMap.Keys)
                {
                    if ((flag & EventFlags) > 0)
                    {
                        iEvent.ToolTip += ", " + eventFlagMap[flag];
                    }
                }

                switch (EventType_CD)
                {
                case Constants.DB.EventTypeCodes.Goal:
                {
                    if (AppliesToSecondPlayer)
                    {
                        iEvent.ImageUrl = ResolveClientUrl("~/WebApplication/images/assist2.png");
                        iEvent.ToolTip  = "Гол: " + UIHelper.FormatName(Player1) + " - " + iEvent.ToolTip;
                    }
                    else
                    {
                        if (Player2 != null)
                        {
                            iEvent.ToolTip = "Пас: " + UIHelper.FormatName(Player2) + " - " + iEvent.ToolTip;
                        }
                        if ((EventFlags & Constants.DB.EventFlags.OwnGoal) > 0)
                        {
                            iEvent.ImageUrl = ResolveClientUrl("~/WebApplication/images/own_goal.png");
                        }
                        else
                        {
                            iEvent.ImageUrl = ResolveClientUrl("~/WebApplication/images/ball.gif");
                        }
                    }
                    break;
                }

                case Constants.DB.EventTypeCodes.Penalty:
                {
                    iEvent.ImageUrl = ResolveClientUrl("~/WebApplication/images/penalty.png");
                    if (EventFlags.HasValue && ((EventFlags.Value & Constants.DB.EventFlags.PostMatchPenalty) > 0))
                    {
                        iEvent.Style.Add("opacity", "0.3");
                    }
                    break;
                }

                case Constants.DB.EventTypeCodes.YellowCard:
                {
                    iEvent.ImageUrl = ResolveClientUrl("~/WebApplication/images/yells.gif");
                    break;
                }

                case Constants.DB.EventTypeCodes.RedCard:
                {
                    iEvent.ImageUrl = ResolveClientUrl("~/WebApplication/images/reds.gif"); break;
                }

                case Constants.DB.EventTypeCodes.SecondYellowCard:
                {
                    iEvent.ImageUrl = ResolveClientUrl("~/WebApplication/images/yellow2.gif"); break;
                }

                case Constants.DB.EventTypeCodes.MissedPenalty:
                {
                    iEvent.ImageUrl = ResolveClientUrl("~/WebApplication/images/nogoal.png");
                    if (EventFlags.HasValue && ((EventFlags.Value & Constants.DB.EventFlags.PostMatchPenalty) > 0))
                    {
                        iEvent.Style.Add("opacity", "0.3");
                    }
                    break;
                }

                default:
                {
                    iEvent.Visible = false; break;
                }
                }
            }

            if (HasVideo)
            {
                iEvent.Attributes.Add("onclick", string.Format("open_colorbox_video(event, '{0}')", PathHelper.GetWebPath(this.Page, Constants.Paths.RootWebPath, "Public", "Video.aspx?EventId=" + EventId.ToString())));
                iEvent.Attributes.Add("onclick", string.Format("open_colorbox_video(event, '{0}')", PathHelper.GetWebPath(this.Page, Constants.Paths.RootWebPath, "Public", "Video.aspx?EventId=" + EventId.ToString())));
                iEvent.Style.Add("background-color", "#E5F5DF");
            }
        }
        public PacificDateTime(TimeSpan timeOfDay)
        {
            var pacificNow = DateTime.UtcNow.ToPacific();

            Year  = pacificNow.Year;
            Month = pacificNow.Month;
            Day   = pacificNow.Day;

            Hour        = timeOfDay.Hours;
            Minute      = timeOfDay.Minutes;
            Second      = timeOfDay.Seconds;
            Millisecond = timeOfDay.Milliseconds;

            var dateTimeParse =
                DateTime.Parse(string.Concat(Year, "-", Month.ToString("00"), "-", Day.ToString("00"), "T", Hour.ToString("00"), ":", Minute.ToString("00"), ":", Second.ToString("00"), ".", Millisecond.ToString("00"), "Z"))
                .ToUniversalTime();

            Offset = dateTimeParse.IsInDaylightSavingsTime() ? DaylightOffset : StandardOffset;

            Date      = new PacificDateTime(Year, Month, Day);
            DayOfYear = Date.DayOfYear;
            DayOfWeek = Date.DayOfWeek;
        }
Exemple #28
0
 public override int GetHashCode()
 {
     return(Hour.GetHashCode() ^ Minute.GetHashCode() ^ Second.GetHashCode());
 }
        // Module defining this command


        // Optional custom code for this activity


        /// <summary>
        /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run.
        /// </summary>
        /// <param name="context">The NativeActivityContext for the currently running activity.</param>
        /// <returns>A populated instance of System.Management.Automation.PowerShell</returns>
        /// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks>
        protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context)
        {
            System.Management.Automation.PowerShell invoker       = global::System.Management.Automation.PowerShell.Create();
            System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName);

            // Initialize the arguments

            if (Date.Expression != null)
            {
                targetCommand.AddParameter("Date", Date.Get(context));
            }

            if (Year.Expression != null)
            {
                targetCommand.AddParameter("Year", Year.Get(context));
            }

            if (Month.Expression != null)
            {
                targetCommand.AddParameter("Month", Month.Get(context));
            }

            if (Day.Expression != null)
            {
                targetCommand.AddParameter("Day", Day.Get(context));
            }

            if (Hour.Expression != null)
            {
                targetCommand.AddParameter("Hour", Hour.Get(context));
            }

            if (Minute.Expression != null)
            {
                targetCommand.AddParameter("Minute", Minute.Get(context));
            }

            if (Second.Expression != null)
            {
                targetCommand.AddParameter("Second", Second.Get(context));
            }

            if (Millisecond.Expression != null)
            {
                targetCommand.AddParameter("Millisecond", Millisecond.Get(context));
            }

            if (DisplayHint.Expression != null)
            {
                targetCommand.AddParameter("DisplayHint", DisplayHint.Get(context));
            }

            if (UFormat.Expression != null)
            {
                targetCommand.AddParameter("UFormat", UFormat.Get(context));
            }

            if (Format.Expression != null)
            {
                targetCommand.AddParameter("Format", Format.Get(context));
            }


            return(new ActivityImplementationContext()
            {
                PowerShellInstance = invoker
            });
        }
        private void PopulateDateCollection()
        {
            for (int i = 1; i <= DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month); i++)
            {
                if (i < 10)
                {
                    Day.Add("0" + i);
                }
                else
                {
                    Day.Add(i.ToString());
                }
            }

            //populate year
            for (int i = DateTime.Now.Year; i < 2050; i++)
            {
                Year.Add(i.ToString());
            }


            //populate months

            for (int i = 1; i < 13; i++)
            {
                if (!Months.ContainsKey(CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(i).Substring(0, 3)))
                {
                    Months.Add(CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(i).Substring(0, 3), CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(i));
                }
                Month.Add(CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(i).Substring(0, 3));
            }
            Date.Add(Year);
            Date.Add(Month);
            Date.Add(Day);

            for (int i = 1; i <= 24; i++)
            {
                if (i < 10)
                {
                    Hour.Add("0" + i.ToString());
                }
                else
                {
                    Hour.Add(i.ToString());
                }
            }
            for (int j = 0; j < 60; j++)
            {
                if (j < 10)
                {
                    Minute.Add("0" + j);
                }
                else
                {
                    Minute.Add(j.ToString());
                }
            }

            Date.Add(Hour);
            Date.Add(Minute);
        }
Exemple #31
0
 void Awake()
 {
     if(LevelSerializer.IsDeserializing)
     {
         return;
     }
     //Will use playerprefs here to sort this out but for testing purposes...
     currentDate = new DateTime(2012,10,18,6,0,0);
     Time.timeScale = timeSpeed;
     //month = currentDate.Month;
     currentDay = new Day();
     currentMonth = new Month();
     currentYear = new Year();
     currentHour = new Hour(currentDate.Hour);
     currentMinute = new Minute(currentDate.Minute);
     currentDay.day = currentDate.Day;
     currentYear.year = currentDate.Year;
     currentMonth.month = currentDate.Month;
     RandomMinute ();
     //PerformMonthlyActions();
 }
Exemple #32
0
        public string DateStr(TimelineUnits unit)
        {
            switch (unit)
            {
            case TimelineUnits.Minute:
                return(Year.ToString() + "." + Month.ToString() + "." + Day.ToString() + " " + Hour.ToString() + ":" + Minute.ToString());

            case TimelineUnits.Hour:
                return(Year.ToString() + "." + Month.ToString() + "." + Day.ToString() + " " + Hour.ToString() + ":00");

            case TimelineUnits.Day:
                return(Year.ToString() + "." + Month.ToString() + "." + Day.ToString());

            case TimelineUnits.Month:
                return(Year.ToString() + "." + Month.ToString());

            case TimelineUnits.Year:
                return(Year.ToString());

            case TimelineUnits.Decade:
                return(Decade.ToString());

            default:
                return("");
            }
        }
Exemple #33
0
 public void SetReportInterval(Minute interval)
 {
     base.EmptySchedules();
     base.AddPeriodicTask(interval, BuildNewReport);
 }
Exemple #34
0
        public override string ToString()
        {
            var    hour = Hour;
            string ampm;

            if (hour > 12)
            {
                hour -= 12;
                ampm  = "p.m.";
            }
            else
            {
                ampm = "a.m.";
            }

            return
                ($"{AgeName} {Year}, {Moon.DisplayWithOrdinal()} moon, {Sun.DisplayWithOrdinal()} sun, {hour}:{Minute.ToString("d2")} {ampm}");
        }
Exemple #35
0
 void w(Minute u)
 {
     w(u.i);
 }
 /// <summary>
 /// Trigerred when the minutes hand is being stopped dragging
 /// </summary>
 /// <param name="args">The drag event arguments</param>
 protected void MinutesHand_DragEnd(DragEventArgs args)
 {
     //Round the minute angle to multiple of 6 degrees so that minute hand is snapped to a valid number from 0-59
     //(Simply said, this will prevent the minute hand to be placed somewhere between the minutes 30 and 31 and will snap it to the nearest one)
     MinutesDegrees = Minute.ToExactMinsSecsDegrees();
 }
Exemple #37
0
        public static Instant NextValid(
            this Instant instant,
            Month month = Month.Every,
            Week week = Week.Every,
            Day day = Day.Every,
            WeekDay weekDay = WeekDay.Every,
            Hour hour = Hour.Zeroth,
            Minute minute = Minute.Zeroth,
            Second second = Second.Zeroth,
            [CanBeNull] CalendarSystem calendarSystem = null,
            [CanBeNull] DateTimeZone timeZone = null)
        {
            // Never case, if any are set to never, we'll never get a valid date.
            if ((month == Month.Never) ||
                (week == Week.Never) ||
                (day == Day.Never) ||
                (weekDay == WeekDay.Never) ||
                (hour == Hour.Never) ||
                (minute == Minute.Never) ||
                (second == Second.Never))
                return Instant.MaxValue;

            if (calendarSystem == null)
                calendarSystem = CalendarSystem.Iso;
            if (timeZone == null)
                timeZone = DateTimeZone.Utc;
            Debug.Assert(calendarSystem != null);
            Debug.Assert(timeZone != null);

            // Move to next second.
            instant = instant.CeilingSecond();

            // Every second case.
            if ((month == Month.Every) &&
                (day == Day.Every) &&
                (weekDay == WeekDay.Every) &&
                (hour == Hour.Every) &&
                (minute == Minute.Every) &&
                (second == Second.Every) &&
                (week == Week.Every))
                return instant;

            // Get days and months.
            int[] days = Days(day).OrderBy(dy => dy).ToArray();
            int[] months = month.Months().ToArray();

            // Remove months where the first day isn't in the month.
            int firstDay = days.First();
            if (firstDay > 28)
            {
                // 2000 is a leap year, so February has 29 days.
                months = months.Where(mn => calendarSystem.GetDaysInMonth(2000, mn) >= firstDay).ToArray();
                if (months.Length < 1)
                    return Instant.MaxValue;
            }

            // Get zoned date time.
            ZonedDateTime zdt = new ZonedDateTime(instant, timeZone, calendarSystem);
            int y = zdt.Year;
            int m = zdt.Month;
            int d = zdt.Day;
            int h = zdt.Hour;
            int n = zdt.Minute;
            int s = zdt.Second;

            int[] weeks = week.Weeks().ToArray();

            IsoDayOfWeek[] weekDays = weekDay.WeekDays().ToArray();
            int[] hours = hour.Hours().OrderBy(i => i).ToArray();
            int[] minutes = minute.Minutes().OrderBy(i => i).ToArray();
            int[] seconds = second.Seconds().ToArray();

            do
            {
                foreach (int currentMonth in months)
                {
                    if (currentMonth < m)
                        continue;
                    if (currentMonth > m)
                    {
                        d = 1;
                        h = n = s = 0;
                    }
                    m = currentMonth;
                    foreach (int currentDay in days)
                    {
                        if (currentDay < d)
                            continue;
                        if (currentDay > d)
                            h = n = s = 0;
                        d = currentDay;

                        // Check day is valid for this month.
                        if (d > calendarSystem.GetDaysInMonth(y, m))
                            break;

                        // We have a potential day, check week and week day
                        zdt = timeZone.AtLeniently(new LocalDateTime(y, m, d, h, n, s, calendarSystem));
                        if ((week != Week.Every) &&
                            (!weeks.Contains(zdt.WeekOfWeekYear)))
                            continue;
                        if ((weekDay != WeekDay.Every) &&
                            (!weekDays.Contains(zdt.IsoDayOfWeek)))
                            continue;

                        // We have a date match, check time.
                        foreach (int currentHour in hours)
                        {
                            if (currentHour < h) continue;
                            if (currentHour > h)
                                n = s = 0;
                            h = currentHour;
                            foreach (int currentMinute in minutes)
                            {
                                if (currentMinute < n) continue;
                                if (currentMinute > n)
                                    s = 0;
                                n = currentMinute;
                                foreach (int currentSecond in seconds)
                                {
                                    if (currentSecond < s) continue;
                                    return
                                        timeZone.AtLeniently(
                                            new LocalDateTime(y, m, d, h, n, currentSecond, calendarSystem)).ToInstant();
                                }
                                n = s = 0;
                            }
                            h = n = s = 0;
                        }
                        d = 1;
                    }
                    d = 1;
                    h = n = s = 0;
                }
                y++;

                // Don't bother checking max year.
                if (y >= calendarSystem.MaxYear)
                    return Instant.MaxValue;

                // Start next year
                m = d = 1;
                h = n = s = 0;
            } while (true);
        }
Exemple #38
0
 void w(Minute u)
 {
     w(u.i);
 }
Exemple #39
0
 private void AddAction(Minute interval, Action action)
 {
     Action scheduled = null;
     if(!_schedules.TryGetValue(interval, out scheduled))
     {
         scheduled = action;
         if(IsStarted)
             AddTimer(interval);
     }
     else
     {
         scheduled = (Action)Delegate.Combine(scheduled, action);
     }
     _schedules[interval] = scheduled;
 }
Exemple #40
0
        object r()
        {
            int i = 0, n, t = (sbyte)b[j++]; if (t < 0)

            {
                switch (t)

                {
                case -1: return(rb());

                case -2: return(rg());

                case -4: return(b[j++]);

                case -5: return(rh());

                case -6: return(ri());

                case -7: return(rj());

                case -8: return(re());

                case -9: return(rf());

                case -10: return(rc());

                case -11: return(rs());

                case -12: return(rp());

                case -13: return(rm());

                case -14: return(rd());

                case -15: return(rz());

                case -16: return(rn());

                case -17: return(ru());

                case -18: return(rv());

                case -19: return(rt());
                }
            }

            if (t > 99)
            {
                if (t == 101 && b[j++] == 0)
                {
                    return(null);
                }
                throw new KException("func");
            }
            if (t == 99)
            {
                return(new Dict(r(), r()));
            }
            j++; if (t == 98)
            {
                return(new Flip((Dict)r()));
            }
            n = ri(); switch (t)
            {
            case 0: object[] L = new object[n]; for (; i < n; i++)
                {
                    L[i] = r();
                }
                return(L);

            case 1: bool[] B = new bool[n]; for (; i < n; i++)
                {
                    B[i] = rb();
                }
                return(B);

            case 2: { Guid[] G = new Guid[n]; for (; i < n; i++)
                      {
                          G[i] = rg();
                      }
                      return(G); }

            case 4: { byte[] G = new byte[n]; for (; i < n; i++)
                      {
                          G[i] = b[j++];
                      }
                      return(G); }

            case 5: short[] H = new short[n]; for (; i < n; i++)
                {
                    H[i] = rh();
                }
                return(H);

            case 6: int[] I = new int[n]; for (; i < n; i++)
                {
                    I[i] = ri();
                }
                return(I);

            case 7: long[] J = new long[n]; for (; i < n; i++)
                {
                    J[i] = rj();
                }
                return(J);

            case 8: float[] E = new float[n]; for (; i < n; i++)
                {
                    E[i] = re();
                }
                return(E);

            case 9: double[] F = new double[n]; for (; i < n; i++)
                {
                    F[i] = rf();
                }
                return(F);

            case 10: char[] C = e.GetChars(b, j, n); j += n; return(C);

            case 11: string[] S = new string[n]; for (; i < n; i++)
                {
                    S[i] = rs();
                }
                return(S);

            case 12: DateTime[] P = new DateTime[n]; for (; i < n; i++)
                {
                    P[i] = rp();
                }
                return(P);

            case 13: Month[] M = new Month[n]; for (; i < n; i++)
                {
                    M[i] = rm();
                }
                return(M);

            case 14: Date[] D = new Date[n]; for (; i < n; i++)
                {
                    D[i] = rd();
                }
                return(D);

            case 15: DateTime[] Z = new DateTime[n]; for (; i < n; i++)
                {
                    Z[i] = rz();
                }
                return(Z);

            case 16: KTimespan[] N = new KTimespan[n]; for (; i < n; i++)
                {
                    N[i] = rn();
                }
                return(N);

            case 17: Minute[] U = new Minute[n]; for (; i < n; i++)
                {
                    U[i] = ru();
                }
                return(U);

            case 18: Second[] V = new Second[n]; for (; i < n; i++)
                {
                    V[i] = rv();
                }
                return(V);

            case 19: TimeSpan[] T = new TimeSpan[n]; for (; i < n; i++)
                {
                    T[i] = rt();
                }
                return(T);
            }
            return(null);
        }
Exemple #41
0
 private void RemoveAction(Minute interval, Action action)
 {
     Action scheduled = null;
     if(_schedules.TryGetValue(interval, out scheduled))
     {
         if(scheduled.GetInvocationList().Length == 1)
         {
             _schedules.Remove(interval);
             if(IsStarted)
                 RemoveTimer(interval);
         }
         else
         {
             scheduled = (Action)Delegate.Remove(scheduled, action);
             _schedules[interval] = scheduled;
         }
     }
 }
Exemple #42
0
 /// <summary>
 /// 短时间。 15:20:30
 /// </summary>
 /// <returns></returns>
 public string ToShortTimeString()
 {
     return(Hour.ToString("00") + ":" +
            Minute.ToString("00") + ":" +
            Seconds.ToString("00"));
 }
Exemple #43
0
 public string ToDateAndHourMinitePathString()
 {
     return(ToDateString() + "_" + Hour.ToString("00") + "_" + Minute.ToString("00"));
 }
Exemple #44
0
 public Settings()
 {
     DefaultHour   = new Hour(12);
     DefaultMinute = new Minute(15);
 }