コード例 #1
0
 public bool ValidateCreateModel(out string message)
 {
     message = String.Empty;
     base.ValidateRoomModel(out message);
     if (StartDate < DateTime.Now)
     {
         message = "Inicio da sessão não pode ser antecessor a momento atual";
     }
     else if (EndDate < DateTime.Now)
     {
         message = "O fim da sessão não pode ser antecessor a momento atual";
     }
     else if (StartDate > EndDate)
     {
         message = "O inicio da sessão não pode ser posterior a final da sessão";
     }
     else if (StartDate.AddHours(6) < EndDate)
     {
         message = "Sessão não pode ter duração superior a 6 horas de duração";
     }
     else if (StartDate.AddHours(1) > EndDate)
     {
         message = "Sessão não pode ter duração inferior a 1 hora de duração";
     }
     else if (Id < 1)
     {
         message = "Dados inválidos, favor recarregue a página e tente novamente";
     }
     return(message == String.Empty);
 }
コード例 #2
0
        public void Calculate_ThirdHour_CorrectRate()
        {
            // ARRANGE
            var endDateTimes = new[] { 2.0, 2.5, 2.9 }.Select(i => StartDate.AddHours(i));

            // ACT
            var responses = endDateTimes.Select(i => SUT.Calculate(new CalculateRequest(StartDate, i))).ToList();

            // ASSERT
            AssertHelpers.AssertCalculateResponses(responses, Enumerable.Repeat(15M, 3).ToList(), ExpectedRateName);
        }
コード例 #3
0
        public void Calculate_ThreePlusHours_CorrectRate()
        {
            // ARRANGE
            var endDateTimes = new[] { 3, 9, 18, 27, 36 }.Select(i => StartDate.AddHours(i));

            // ACT
            var responses = endDateTimes.Select(i => SUT.Calculate(new CalculateRequest(StartDate, i))).ToList();

            // ASSERT
            var expectedPrices = new[] { 20M, 40M, 40M, 40M, 60M }.ToList();

            AssertHelpers.AssertCalculateResponses(responses, expectedPrices, ExpectedRateName);
        }
コード例 #4
0
ファイル: PCViewModel.cs プロジェクト: Maxusbr/ClientApps
 void UpdateStartTrip(bool setFirst = false)
 {
     StartTrip.Clear();
     StartTrip.Add(new TripAdvisorViewModel("00:00", string.Empty));
     foreach (var el in PCHandler.Instance.ListTrip.Where(o => o.StartEng >= StartDate &&
                                                          o.StartEng <= StartDate.AddHours(23).AddMinutes(59)))
     {
         StartTrip.Add(el);
     }
     if (setFirst)
     {
         SelectedStart = StartTrip[0];
     }
 }
コード例 #5
0
        public Punishment(IPAddress clientAddress, RevokedPerms revokedPerms, int duration = -1) : this()
        {
            ClientAddress = clientAddress;
            RevokedPerms  = revokedPerms;

            if (duration < 0)
            {
                IsTempBan = false;
                StartDate = DateTime.Now;
                EndDate   = DateTime.Now;
            }
            else
            {
                IsTempBan = true;
                StartDate = DateTime.UtcNow;
                EndDate   = StartDate.AddHours(duration);
            }
        }
コード例 #6
0
        private async void initAvailableAttractions()
        {
            if (Destination == null ||
                StartDate == null ||
                FinishDate == null)
            {
                return;
            }

            var events =
                await new Seatwave(Seatwave.DEFAULT_API_KEY, Seatwave.DEFAULT_API_SECRET)
                .GetEventsAsync
                (
                    Destination.Name,
                    StartDate.AddHours(AfterArrivalRelaxTime),
                    FinishDate.AddHours(BeforeDepartureRelaxTime),
                    WhatAttraction
                );

            if (events == null)
            {
                return;
            }

            var avail = (from e in events
                         select new Attraction
            {
                Code = e.Id,
                Name = e.GroupName,
                Site = e.EventSwURL,
                VenueId = e.VenueId,
                Photos = new Uri[1] {
                    new Uri(e.GroupImageURL)
                },
                Tickets = createTickets(e)
            });

            if (avail == null)
            {
                return;
            }

            AvailableAttractions = avail.ToArray();
        }
コード例 #7
0
        public DayOverviewViewModel(ITimeEntryService timeEntryService, IBusyService busyService)
        {
            _timeEntryService = timeEntryService;
            _busyService      = busyService;
            _busyService.ShowBusy(_dayoverviewKey);
            TimeEntries = new List <DataOverviewItemViewModel>();

            PreviousDateCommand          = new DelegateCommand <object>(a => StartDate = StartDate.AddDays(-1));
            NextDayCommand               = new DelegateCommand <object>(a => StartDate = StartDate.AddDays(1));
            TodayCommand                 = new DelegateCommand <object>(a => StartDate = GetNuetralKindDateTimeToday());
            EditTaskCommand              = new DelegateCommand <object>(EditTaskExecute);
            _saveCommandCompletedCommand = new DelegateCommand <object>(SaveTaskCompleted);
            TaskCommands.SaveTaskCompleted.RegisterCommand(_saveCommandCompletedCommand);
            OverviewCommands.GoToDaySubMenu.RegisterCommand(new DelegateCommand <object>(ChangeDate));

            VisiblePeriodStart = StartDate.AddHours(6);
            VisiblePeriodEnd   = EndDate.AddHours(-6);
            StartDate          = GetNuetralKindDateTimeToday();
        }
コード例 #8
0
        public SensorHistoryParameters(int sensorId, int average, DateTime?startDate, DateTime?endDate, int?count)
        {
            if (average < 0)
            {
                throw new ArgumentException("Average must be greater than or equal to 0", nameof(average));
            }

            SensorId = sensorId;

            StartDate = startDate ?? DateTime.Now;
            EndDate   = endDate ?? StartDate.AddHours(-1);
            Average   = average;

            if (count != null)
            {
                Count = count;
            }

            SortBy        = Property.DateTime;
            SortDirection = SortDirection.Descending;
        }
コード例 #9
0
        public string QueryBuilder(string whereExpression = null)
        {
            var returnQueryString = "";

            QueryString = "SELECT " + (PageCount > 0 ? "TOP " + PageCount.ToString() + " " : "") +
                          "NULLIF(LTRIM(RTRIM([Audit_Ser_Num])), '') AS [SERIAL_NO], " +
                          "NULLIF(LTRIM(RTRIM([Audit_Part_Num])), '') AS [PART_NO], " +
                          "NULLIF(LTRIM(RTRIM([Audit_Source_Site_Num])), '') AS [SOURCE_SITE_NO], " +
                          "NULLIF(LTRIM(RTRIM([Audit_Dest_Site_Num])), '') AS [DESTINATION_SITE_NO], " +
                          "NULLIF(LTRIM(RTRIM([Audit_Rem])), '') AS [REMARK], " +
                          "NULLIF(LTRIM(RTRIM([Audit_User])), '') AS [USER], " +
                          "[Audit_Move_Date] AS [MOVE_DATE], " +
                          "[Audit_Last_Update] AS [UPDATE_DATE] " +
                          "FROM scaudit (nolock) ";

            if (string.IsNullOrEmpty(WhereExpression))
            {
                if (StartDate > DateTime.MinValue)
                {
                    if (TimeRange > 0)
                    {
                        WhereExpression = "WHERE audit_last_update >= CONVERT(datetime, '" + StartDate + "', 103) AND audit_last_update <= CONVERT(datetime, '" + StartDate.AddHours(TimeRange) + "', 103) ";
                    }
                    else if (DateRange > 0)
                    {
                        WhereExpression = "WHERE audit_last_update >= CONVERT(datetime, '" + StartDate + "', 103) AND audit_last_update <= CONVERT(datetime, '" + StartDate.AddDays(DateRange) + "', 103) ";
                    }
                    else if (EndDate > DateTime.MinValue)
                    {
                        WhereExpression = "WHERE audit_last_update >= CONVERT(datetime, '" + StartDate + "', 103) AND audit_last_update <= CONVERT(datetime, '" + EndDate + "', 103) ";
                    }
                    else
                    {
                        WhereExpression = "WHERE audit_last_update >= CONVERT(datetime, '" + StartDate + "', 103) AND audit_last_update <= CONVERT(datetime, '" + StartDate.AddDays(1) + "', 103) ";
                    }
                }
                else
                {
                    WhereExpression = "";
                }
            }

            OrderBy = !string.IsNullOrEmpty(OrderBy) ? OrderBy : _orderBy;

            LastQueryString = returnQueryString = QueryString + WhereExpression + OrderBy;
            // Need to reset the Where and Order by, otherwise they remain in memory for next request
            Reset();

            return(returnQueryString);
        }
コード例 #10
0
        public string QueryBuilder(string whereExpression = null)
        {
            var returnQueryString = "";

            QueryString = "SELECT " + (PageCount > 0 ? "TOP " + PageCount.ToString() + " " : "") +
                          "NULLIF(LTRIM(RTRIM([Part_Num])), '') AS [PART_NO], " +
                          "NULLIF(LTRIM(RTRIM([Part_Desc])), '') AS [PART_DESC], " +
                          "NULLIF(LTRIM(RTRIM([Part_Alt_Part_Num])), '') AS [PART_DESC_ALT], " +
                          "NULLIF(LTRIM(RTRIM([Part_Type])), '') AS [PART_TYPE], " +
                          "NULLIF(LTRIM(RTRIM([Part_Last_Update])), '') AS [UPDATE_DATE] " +
                          "FROM [SCPart] (NOLOCK) ";
            //QueryStringJoin = "LEFT JOIN [SCPart] ON audit_part_num = [Part_Num]";
            //QueryString = QueryString + QueryStringJoin;

            //if (string.IsNullOrEmpty(WhereExpression))
            if (StartDate > DateTime.MinValue)
            {
                if (TimeRange > 0)
                {
                    _whereExpression = "WHERE [Part_Last_Update] >= CONVERT(DATETIME, '" + StartDate + "', 103) AND [Part_Last_Update] <= CONVERT(DATETIME, '" + StartDate.AddHours(TimeRange) + "', 103) ";
                }
                else if (DateRange > 0)
                {
                    _whereExpression = "WHERE [Part_Last_Update] >= CONVERT(DATETIME, '" + StartDate + "', 103) AND [Part_Last_Update] <= CONVERT(DATETIME, '" + StartDate.AddDays(DateRange) + "', 103) ";
                }
                else if (EndDate > DateTime.MinValue)
                {
                    _whereExpression = "WHERE [Part_Last_Update] >= CONVERT(DATETIME, '" + StartDate + "', 103) AND [Part_Last_Update] <= CONVERT(DATETIME, '" + EndDate + "', 103) ";
                }
                else
                {
                    _whereExpression = "WHERE [Part_Last_Update] >= CONVERT(DATETIME, '" + StartDate + "', 103) AND [Part_Last_Update] <= CONVERT(DATETIME, '" + StartDate.AddDays(1) + "', 103) ";
                }
            }
            else
            {
                _whereExpression = "";
            }
            WhereExpression = string.IsNullOrEmpty(WhereExpression) ? _whereExpression :
                              string.IsNullOrEmpty(_whereExpression) ? WhereExpression : _whereExpression + WhereExpression.Replace("WHERE", "AND");
            //WhereExpression = !string.IsNullOrEmpty(WhereExpression) ? WhereExpression + "AND [Part_Type] != 'D' " : "WHERE [Part_Type] != 'D'";

            OrderBy = !string.IsNullOrEmpty(OrderBy) ? OrderBy : _orderBy;

            LastQueryString = returnQueryString = QueryString + WhereExpression + OrderBy;
            // Need to reset the Where and Order by, otherwise they remain in memory for next request
            Reset();

            return(returnQueryString);
        }
コード例 #11
0
        private static DateTime SetDateWithChecks(DateTime obj, int year, int month, int day, int?hour, int?minute, int?second, int?millisecond)
        {
            DateTime StartDate;

            if (year == 0)
            {
                StartDate = new DateTime(obj.Year, 1, 1, 0, 0, 0, 0);
            }
            else
            {
                if (DateTime.MaxValue.Year < year)
                {
                    StartDate = new DateTime(DateTime.MinValue.Year, 1, 1, 0, 0, 0, 0);
                }
                else if (DateTime.MinValue.Year > year)
                {
                    StartDate = new DateTime(DateTime.MaxValue.Year, 1, 1, 0, 0, 0, 0);
                }
                else
                {
                    StartDate = new DateTime(year, 1, 1, 0, 0, 0, 0);
                }
            }

            if (month == 0)
            {
                StartDate = StartDate.AddMonths(obj.Month - 1);
            }
            else
            {
                StartDate = StartDate.AddMonths(month - 1);
            }
            if (day == 0)
            {
                StartDate = StartDate.AddDays(obj.Day - 1);
            }
            else
            {
                StartDate = StartDate.AddDays(day - 1);
            }
            if (!hour.HasValue)
            {
                StartDate = StartDate.AddHours(obj.Hour);
            }
            else
            {
                StartDate = StartDate.AddHours(hour.Value);
            }
            if (!minute.HasValue)
            {
                StartDate = StartDate.AddMinutes(obj.Minute);
            }
            else
            {
                StartDate = StartDate.AddMinutes(minute.Value);
            }
            if (!second.HasValue)
            {
                StartDate = StartDate.AddSeconds(obj.Second);
            }
            else
            {
                StartDate = StartDate.AddSeconds(second.Value);
            }
            if (!millisecond.HasValue)
            {
                StartDate = StartDate.AddMilliseconds(obj.Millisecond);
            }
            else
            {
                StartDate = StartDate.AddMilliseconds(millisecond.Value);
            }

            return(StartDate);
        }
コード例 #12
0
 public Booking()
 {
     CreatedDate = DateTime.UtcNow;
     EndDate     = StartDate.AddHours(1);
 }
コード例 #13
0
        public string QueryBuilder(string whereExpression = null)
        {
            var returnQueryString = "";

            if (QueryBuilderObject != null)
            {
                base.DateRange        = QueryBuilderObject.DateRange;
                base.EndDate          = QueryBuilderObject.EndDate;
                base.EndDateInclusive = QueryBuilderObject.EndDateInclusive;
                base.EndDateString    = QueryBuilderObject.EndDateString;
                base.LastQueryString  = QueryBuilderObject.LastQueryString;
                base.OrderBy          = QueryBuilderObject.OrderBy;
                base.PageCount        = QueryBuilderObject.PageCount;
                base.SkipCount        = QueryBuilderObject.SkipCount;
                base.StartDate        = QueryBuilderObject.StartDate;
                base.StartDateString  = QueryBuilderObject.StartDateString;
                base.TimeRange        = QueryBuilderObject.TimeRange;
                base.WhereExpression  = QueryBuilderObject.WhereExpression;
            }

            QueryString = "SELECT " + (PageCount > 0 ? "TOP " + PageCount.ToString() + " " : "") +
                          "NULLIF(LTRIM(RTRIM(SL.[Fsrl_Id_Num])), '') AS [SERIAL_NO], " +
                          "NULLIF(LTRIM(RTRIM(SL.[Fsrl_Ret_Id])), '') AS [SERIAL_NO_RETURNED], " +
                          "NULLIF(LTRIM(RTRIM(SL.[Fsrl_Part_Num])), '') AS [PART_NO], " +
                          "NULLIF(NULLIF(LTRIM(RTRIM(SL.[Fsrl_Ret_Part_Num])), ''), 'NONE') AS [PART_NO_RETURNED], " +
                          "NULLIF(LTRIM(RTRIM(SL.[Fsrl_Part_Desc])), '') AS [PART_DESC], " +
                          "NULLIF(NULLIF(LTRIM(RTRIM(SCP.[Part_Desc])), ''), 'PART USED NONE RETURNED') AS [PART_DESC_RETURNED], " +
                          //"NULLIF(LTRIM(RTRIM(SCA.[Audit_Source_Site_Num])), '') AS [SOURCE_SITE_NO], " +
                          //"NULLIF(LTRIM(RTRIM(SCA.[Audit_Dest_Site_Num])), '') AS [DESTINATION_SITE_NO], " +
                          "NULLIF(LTRIM(RTRIM(SCP.[Part_Type])), '') AS [Part_Type], " +
                          "NULLIF(LTRIM(RTRIM(SCP.[Part_Alt_Part_Num])), '') AS [Part_Code], " +
                          "NULLIF(LTRIM(RTRIM(SL.[Fsrl_Call_Num])), '') AS [Call_Num], " +
                          "NULLIF(LTRIM(RTRIM(SC.[Call_Contact])), '') AS [Call_Contact], " +
                          //"NULLIF(LTRIM(RTRIM(SC.[Call_Num])), '') AS [Call_Num], " +
                          "NULLIF(LTRIM(RTRIM(SC.[Call_Ref])), '') AS [Call_Ref], " +
                          "CASE WHEN LEFT([Call_Phone], 2) LIKE '0%' THEN NULL ELSE LTRIM(RTRIM([Call_Phone])) END AS [Cost_Code], " +
                          "SL.[Fsrl_Last_Update] AS [UPDATE_DATE] " +
                          "FROM [SCFsrl] AS SL (NOLOCK) ";
            QueryStringJoin  = "FULL JOIN [SCPart] AS SCP ON SL.[Fsrl_Part_Num] = SCP.[Part_Num] ";
            QueryStringJoin += "FULL JOIN [SCCall] AS SC ON SL.[Fsrl_Call_Num] = SC.[Call_Num] ";
            QueryStringJoin += "FULL JOIN [SCCalt] AS SCT ON SC.[Call_Calt_Code] = SCT.[Calt_Code] ";
            QueryString      = QueryString + QueryStringJoin;

            //if (string.IsNullOrEmpty(WhereExpression))
            if (StartDate > DateTime.MinValue)
            {
                if (TimeRange > 0)
                {
                    _whereExpression = "WHERE [Fsrl_Last_Update]  >= CONVERT(DATETIME, '" + StartDate + "', 103) AND [Fsrl_Last_Update] <= CONVERT(DATETIME, '" + StartDate.AddHours(TimeRange) + "', 103) ";
                }
                else if (DateRange > 0)
                {
                    _whereExpression = "WHERE [Fsrl_Last_Update] >= CONVERT(DATETIME, '" + StartDate + "', 103) AND [Fsrl_Last_Update] <= CONVERT(DATETIME, '" + StartDate.AddDays(DateRange) + "', 103) ";
                }
                else if (EndDate > DateTime.MinValue && EndDate > DateTime.MinValue.AddDays(1))
                {
                    _whereExpression = "WHERE [Fsrl_Last_Update] >= CONVERT(DATETIME, '" + StartDate + "', 103) AND [Fsrl_Last_Update] <= CONVERT(DATETIME, '" + EndDate + "', 103) ";
                }
                else
                {
                    _whereExpression = "WHERE [Fsrl_Last_Update] >= CONVERT(DATETIME, '" + StartDate + "', 103) AND [Fsrl_Last_Update] <= CONVERT(DATETIME, '" + StartDate.AddDays(1) + "', 103) ";
                }
            }
            else
            {
                _whereExpression = "";
            }
            WhereExpression = !string.IsNullOrEmpty(WhereExpression) ? WhereExpression + "AND [Part_Type] != 'D' " : "WHERE [Part_Type] != 'D'";
            WhereExpression = string.IsNullOrEmpty(WhereExpression) ? _whereExpression :
                              string.IsNullOrEmpty(_whereExpression) ? WhereExpression : _whereExpression + WhereExpression.Replace("WHERE", "AND");

            OrderBy = !string.IsNullOrEmpty(OrderBy) ? OrderBy : _orderBy;

            LastQueryString = returnQueryString = QueryString + WhereExpression + OrderBy;
            if (QueryBuilderObject != null)
            {
                QueryBuilderObject.LastQueryString = LastQueryString;
            }
            // Need to reset the Where and Order by, otherwise they remain in memory for next request
            Reset();

            return(returnQueryString);
        }
コード例 #14
0
        public string QueryBuilder(string whereExpression = null)
        {
            var returnQueryString = "";

            QueryString = "SELECT " + (PageCount > 0 ? "TOP " + PageCount.ToString() + " " : "") +
                          "NULLIF(LTRIM(RTRIM(SCA.[Audit_Ser_Num])), '') AS [SERIAL_NO], " +
                          "NULLIF(LTRIM(RTRIM(SCA.[Audit_Part_Num])), '') AS [PART_NO], " +
                          "NULLIF(LTRIM(RTRIM(SCP.[Part_Desc])), '') AS [PART_DESC], " +
                          "NULLIF(LTRIM(RTRIM(SCP.[Part_Alt_Part_Num])), '') AS [PART_DESC_ALT], " +
                          "NULLIF(LTRIM(RTRIM(SCA.[Audit_Source_Site_Num])), '') AS [SOURCE_SITE_NO], " +
                          "NULLIF(LTRIM(RTRIM(SCA.[Audit_Dest_Site_Num])), '') AS [DESTINATION_SITE_NO], " +
                          "NULLIF(LTRIM(RTRIM(SCP.[Part_Type])), '') AS [PART_TYPE], " +
                          "NULLIF(LTRIM(RTRIM(SCA.[Audit_Rem])), '') AS [REMARK], " +
                          "NULLIF(LTRIM(RTRIM(SCA.[Audit_User])), '') AS [USER], " +
                          "SCA.[Audit_Move_Date] AS [MOVE_DATE], " +
                          "SCA.[Audit_Last_Update] AS [UPDATE_DATE] " +
                          "FROM [SCAudit] AS SCA (NOLOCK) ";
            QueryStringJoin = "FULL JOIN [SCPart] AS SCP ON SCA.[Audit_Part_Num] = SCP.[Part_Num] ";
            QueryString     = QueryString + QueryStringJoin;

            //if (string.IsNullOrEmpty(WhereExpression))
            if (StartDate > DateTime.MinValue)
            {
                if (TimeRange > 0)
                {
                    _whereExpression = "WHERE [Audit_Last_Update] >= CONVERT(DATETIME, '" + StartDate + "', 103) AND [Audit_Last_Update] <= CONVERT(DATETIME, '" + StartDate.AddHours(TimeRange) + "', 103) ";
                }
                else if (DateRange > 0)
                {
                    _whereExpression = "WHERE [Audit_Last_Update] >= CONVERT(DATETIME, '" + StartDate + "', 103) AND [Audit_Last_Update] <= CONVERT(DATETIME, '" + StartDate.AddDays(DateRange) + "', 103) ";
                }
                else if (EndDate > DateTime.MinValue && EndDate > DateTime.MinValue.AddDays(1))
                {
                    _whereExpression = "WHERE [Audit_Last_Update] >= CONVERT(DATETIME, '" + StartDate + "', 103) AND [Audit_Last_Update] <= CONVERT(DATETIME, '" + EndDate + "', 103) ";
                }
                else
                {
                    _whereExpression = "WHERE [Audit_Last_Update] >= CONVERT(DATETIME, '" + StartDate + "', 103) AND [Audit_Last_Update] <= CONVERT(DATETIME, '" + StartDate.AddDays(1) + "', 103) ";
                }
            }
            else
            {
                _whereExpression = "";
            }
            WhereExpression = !string.IsNullOrEmpty(WhereExpression) ? WhereExpression + "AND [Part_Type] != 'D' " : "WHERE [Part_Type] != 'D'";
            WhereExpression = string.IsNullOrEmpty(WhereExpression) ? _whereExpression :
                              string.IsNullOrEmpty(_whereExpression) ? WhereExpression : _whereExpression + WhereExpression.Replace("WHERE", "AND");

            OrderBy = !string.IsNullOrEmpty(OrderBy) ? OrderBy : _orderBy;

            LastQueryString = returnQueryString = QueryString + WhereExpression + OrderBy;
            if (QueryBuilderObject != null)
            {
                QueryBuilderObject.LastQueryString = LastQueryString;
            }

            // Need to reset the Where and Order by, otherwise they remain in memory for next request
            Reset();

            return(returnQueryString);
        }