Exemplo n.º 1
0
        public IHttpActionResult GetLogin(string start = "", string end = "", string sort = "CreateTime", string order = "desc")
        {
            DateTime Start, End;

            if (string.IsNullOrEmpty(start))
            {
                Start = DateTime.Parse(DateTime.Now.AddMonths(-1).ToString("yyyy-MM-dd"));
                End   = Start.AddMonths(1).AddDays(1);
            }
            else
            {
                Start = DateTime.Parse(start);
            }
            if (string.IsNullOrEmpty(end))
            {
                End = Start.AddMonths(1).AddDays(1);
            }
            else
            {
                End = DateTime.Parse(end).AddDays(1);
            }
            var logs   = from m in DbContext.UserLog where m.Type == "LOGIN" && m.CreateTime >= Start && m.CreateTime <= End orderby m.CreateTime descending select m;
            var sorts  = sort.Split(',');
            var orders = order.Split(',');

            return(Json(new { total = logs.Count(), rows = logs.ToList() }, JsonConfig.jsSettings));
        }
Exemplo n.º 2
0
        public void Update()
        {
            Active = Start <DateTime.Now && Start.Add(Duration)> DateTime.Now;
            if (RepeatType != GERepeatType.None && Start.Add(Duration) < DateTime.Now)
            {
updateCondition:
                switch (RepeatType)
                {
                case GERepeatType.Annually:
                    Start = Start.AddYears(1);
                    break;

                case GERepeatType.Monthly:
                    Start = Start.AddMonths(1);
                    break;

                case GERepeatType.Weekly:
                    Start = Start.AddDays(7);
                    break;

                case GERepeatType.Daily:
                    Start = Start.AddDays(1);
                    break;
                }
                if (Start.Add(Duration) < DateTime.Now)
                {
                    goto updateCondition;
                }

                Logger
                .ForContext(Constants.SourceContextPropertyName, Name)
                .Information("Updated active period, Start {0} - End {1}", Start, Start.Add(Duration));
            }
        }
Exemplo n.º 3
0
        public void ValueCheck()
        {
            Start = Start == DateTime.MinValue ? DateTime.Now.Date : Start;
            var end = string.IsNullOrWhiteSpace(ParentKey) ? Start.AddMonths(1) : Start.AddDays(7);

            End  = End == DateTime.MinValue ? end : End;
            Name = string.IsNullOrWhiteSpace(Name) ? $"{Start.ToString("yyyy年M月d日")} - {End.ToString("M月d日")}" : Name;
        }
 /// <summary>Term Span</summary>
 public TermSpan TermSpan(uint number = 0) =>
 number > Amount - 1 ?
 throw new MeasureException(MeasureException.TERM_OUTSIDE_PERIOD) :
 new TermSpan()
 {
     Number = number,
     Start  = Start.AddMonths((int)number * (int)Term.AmountOfBaseUnits),
     End    = Start.AddMonths((int)(number + 1) * (int)Term.AmountOfBaseUnits).AddDays(-1)
 };
Exemplo n.º 5
0
        public override string GetUrl(string ticker)
        {
            DateTime yahooStartDate = Start.AddMonths(-1);
            DateTime yahooEndDate   = End.AddMonths(-1);

            return(string.Format(UrlStr, ticker,
                                 yahooStartDate.Month, yahooStartDate.Day, yahooStartDate.Year,
                                 yahooEndDate.Month, yahooEndDate.Day, yahooEndDate.Year,
                                 _intervel));
        }
        /// <summary>Number of specified term</summary>
        private uint TermNumber(DateTime date)
        {
            if (date < Start || End < date)
            {
                throw new MeasureException(MeasureException.TERM_OUTSIDE_PERIOD);
            }

            var i = 0;

            while (Start.AddMonths(i * (int)Term.AmountOfBaseUnits) <= date)
            {
                i++;
            }
            return((uint)i - 1);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Moves the period backwards in time according to the type set. If Type == PeriodType.Year, the start and end is moved -1 year.
        /// </summary>
        public void Subtract()
        {
            switch (Type)
            {
            case PeriodType.Year:
                Start = Start.AddYears(-1);
                End   = End.AddYears(-1);
                break;

            case PeriodType.Halfyear:
                Start = Start.AddMonths(-6);
                End   = End.AddMonths(-6);
                break;

            case PeriodType.Month:
                Start = Start.AddMonths(-1);
                End   = End.AddMonths(-1);
                break;

            default:
                break;
            }
        }
Exemplo n.º 8
0
 public void MonthForward()
 {
     Start  = Start.AddMonths(1);
     Finish = Finish.AddMonths(1);
 }
Exemplo n.º 9
0
 public void MonthBack()
 {
     Start  = Start.AddMonths(-1);
     Finish = Finish.AddMonths(-1);
 }
Exemplo n.º 10
0
 public DateTimeRange SpreadByMonths(int monthsStart, int monthsEnd)
 {
     return(new DateTimeRange(
                start: Start.AddMonths(-monthsStart),
                end: End.AddMonths(monthsEnd)));
 }