public Record(string firstname, string lastname, DateTime beginning, DateTime end) { FirstName = firstname; LastName = lastname; Month = beginning.Month; Year = beginning.Year; Beginning = beginning.ToString("H:mm"); Ending = end.ToString("H:mm"); StartDay = beginning.Day; EndDay = end.Day; //Property Begin se musí nastavit před property Time, protože Time s ní následně pracuje! Begin = beginning; End = end; Time = (end - beginning).ToString(); if (StartDay == EndDay) { ConcatDay = StartDay.ToString(); } else if (StartDay != EndDay & EndDay == 0) { ConcatDay = StartDay.ToString(); } else { ConcatDay = StartDay + " až " + EndDay; } }
private ChartingViewModel GetNext() { DateTime newStartDate; DateTime newFinishDate; if (IntervalType == DayConstant) { newStartDate = StartDay.AddDays(1); newFinishDate = FinishDay.AddDays(1); } else if (IntervalType == WeekConstant) { newStartDate = StartDay.AddDays(7).FirstDayOfWeek(); newFinishDate = FinishDay.AddDays(7).LastDayOfWeek(); } else { var previousMonth = StartDay.AddMonths(1); newStartDate = new DateTime(previousMonth.Year, previousMonth.Month, 1); newFinishDate = StartDay.AddMonths(1).AddDays(-1); } // start date can be future date if (newStartDate < DateTime.Now) { StartDay = newStartDate; FinishDay = newFinishDate; } return(new ChartingViewModel(AppService.GetStatisticData(StartDay, FinishDay), StartDay, FinishDay)); }
public void InitializeDdlSettingWindow(Ddl ddl) { InitializeComponent(); DdlNameTextBox.Text = ddl.Name; DdlPriority.Value = ddl.Priority; InitializeStartTime(ddl.StartTime); ChineseCheckbox.IsChecked = ddl.IsChineseCalender; InitializeEndTime(ddl.EndTime); var format = System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern; if (format == "M/d/yyyy") { StartMonth.SetValue(Grid.ColumnProperty, 0); StartDay.SetValue(Grid.ColumnProperty, 1); StartYear.SetValue(Grid.ColumnProperty, 2); EndMonth.SetValue(Grid.ColumnProperty, 0); EndDay.SetValue(Grid.ColumnProperty, 1); EndYear.SetValue(Grid.ColumnProperty, 2); } else if (format == "d/M/yyyy") { StartDay.SetValue(Grid.ColumnProperty, 0); StartMonth.SetValue(Grid.ColumnProperty, 1); StartYear.SetValue(Grid.ColumnProperty, 2); EndDay.SetValue(Grid.ColumnProperty, 0); EndMonth.SetValue(Grid.ColumnProperty, 1); EndYear.SetValue(Grid.ColumnProperty, 2); } LoopCheckbox.IsChecked = ddl.IsLoop; if (ddl.IsLoop) { InitializeLoopinterval(ddl.LoopInterval); } NoticeCheckbox.IsChecked = (ddl.Inform[0] == '1'); WindowCheckbox.IsChecked = (ddl.Inform[1] == '1'); SoundCheckbox.IsChecked = (ddl.Inform[2] == '1'); RemindCheckbox.IsChecked = ddl.IsRemind != -1; if (ddl.IsRemind != -1) { InitializeRemind(ddl.RemindInterval, ddl.RemindTime); } if (System.Threading.Thread.CurrentThread.CurrentUICulture.Name != "zh-CN") { ChineseCheckbox.Visibility = Visibility.Hidden; ChineseCheckbox.IsEnabled = false; } }
public void StartNewDay(StartDay startDay) { PlayerMovement.canMove = false; numberOfDay++; dayText.text = ""; StartCoroutine(ShowDawn(startDay)); }
IEnumerator ShowDawn(StartDay startDay) { while (dawn.alpha < 1) { dawn.alpha += Time.deltaTime * speed; yield return(null); } dayText.text = "Day " + numberOfDay.ToString(); yield return(new WaitForSeconds(2f)); StartCoroutine(HideDawn(startDay)); }
public override List <Period> GetPeriods() { List <Period> periods = new List <Period> (); var start = StartDay; while (start != StartDay.AddYears(1)) { Period period = new Period(start, start); start = start.AddDays(1); periods.Add(period); } return(periods); }
public StartDay GetFirstDay(int pIntYear) { StartDay lObjStartDay = new StartDay(); try { lObjStartDay = mObjQueryManager.GetObjectsList <StartDay>("Name", pIntYear.ToString(), "[@UG_TR_DAY]").FirstOrDefault(); //lStrFirstDay = mObjQueryManager.GetValue("U_FirstDay", "U_Year", pIntYear.ToString(), "[@UG_TR_DAY]"); } catch (Exception lObjException) { LogService.WriteError("GetFirstDay: " + lObjException.Message); LogService.WriteError(lObjException); UIApplication.ShowError(string.Format("GetFirstDay: {0}", lObjException.Message)); } return(lObjStartDay); }
IEnumerator HideDawn(StartDay startDay) { startDay(); ItemSpawner[] itemSpawners = (ItemSpawner[])GameObject.FindObjectsOfType(typeof(ItemSpawner)); foreach (ItemSpawner itemSpawner in itemSpawners) { itemSpawner.Spawn(); } while (dawn.alpha > 0) { dawn.alpha -= Time.deltaTime * speed; yield return(null); } PlayerMovement.canMove = true; }
private ChartingViewModel AddPrevious() { if (IntervalType == DayConstant) { StartDay = StartDay.AddDays(-1); FinishDay = FinishDay.AddDays(-1); } else if (IntervalType == WeekConstant) { StartDay = StartDay.AddDays(-7).FirstDayOfWeek(); FinishDay = FinishDay.AddDays(-7).LastDayOfWeek(); } else { var previousMonth = StartDay.AddMonths(-1); StartDay = new DateTime(previousMonth.Year, previousMonth.Month, 1); FinishDay = StartDay.AddMonths(1).AddDays(-1); } return(new ChartingViewModel(AppService.GetStatisticData(StartDay, FinishDay), StartDay, FinishDay)); }
public string Load(string url) { var param = new AkpReportParameters().GetParameters(); var browser = Browser.GetBrowser(); param.formParams["ctl00_ContentPlaceHolder1_Date1"] = StartDay.ToString("dd.MM.yyyy"); param.formParams["ctl00_ContentPlaceHolder1_Date2"] = EndDate.ToString("dd.MM.yyyy"); var reportPage = browser.NavigateToPage(new Uri(url)); var form = reportPage.FindForm(param.formId); foreach (string key in param.formParams) { form[key] = param.formParams[key]; } foreach (string key in param.headParams) { browser.Headers.Add(key, param.headParams[key]); } form.Method = HttpVerb.Post; WebPage response = form.Submit(); return(JObject.Parse(response)["result"].ToString()); }
public bool IsPlannable(IEnumerable <Course> courses, int priority, string code) { // dont do anything when this status already is unplannable... if (this.Status == Status.UNPLANNABLE) { return(false); } _logger.Debug("IsPlannable"); if (!this.Intersects(courses)) { _logger.Debug(string.Format(_culture, "Course with code {0} and startdate {1} doesn't intersect with other course", code, StartDay.ToString("dd-MM-yyyy"))); return(true); } if (this.IntersectsOnlyWithStatus(courses, Status.UNPLANNABLE)) { _logger.Debug(string.Format(_culture, "Course with code {0} and startdate {1} intersects only with unplannable implementations", code, StartDay.ToString("dd-MM-yyyy"))); return(true); } if (this.IntersectsWithStatus(courses, Status.PLANNED)) { _logger.Debug(string.Format(_culture, "Course with code {0} and startdate {1} intersects with planned implementation", code, StartDay.ToString("dd-MM-yyyy"))); return(false); } return(true); List <string> scannedCourses = new List <string>(); var coursesToCheck = courses.Where(course => course.Code != code).ToList(); //Add self for intersection coursesToCheck.Add(new Course { Code = code, Priority = priority, CourseImplementations = new List <CourseImplementation> { this, }, }); _logger.Debug(string.Format(_culture, "Course with code {0} and startdate {1} returns IsPlannable", code, StartDay.ToString("dd-MM-yyyy"))); return(IsPlannable(coursesToCheck, scannedCourses, priority)); }
private bool IsPlannable(IEnumerable <Course> courses, List <string> scannedCourses, int priority) { _logger.Debug(string.Format(_culture, "private IsPlannable with startdate {0}", StartDay.ToString("dd-MM-yyyy"))); bool plannable = false; if (this.GetIntersectedCourseImplementations(courses).All(ci => ci.Status == Status.PLANNED)) { _logger.Debug("All intersected course implementations are planned"); return(false); } var notPlannedIntersectedCourses = this.GetIntersectedCourses(courses) .Where(course => course.CourseImplementations.All(ci => ci.Status != Status.PLANNED) && course.Priority <= priority); var notPlannedIntersectedCoursesWithoutScanned = notPlannedIntersectedCourses.Where(intersectedCourse => !scannedCourses.Contains(intersectedCourse.Code)).ToList(); foreach (var intersectedCourse in notPlannedIntersectedCoursesWithoutScanned) { scannedCourses.Add(intersectedCourse.Code); if (intersectedCourse.HasIntersectedCourseWithFreeImplementation(courses, priority)) { _logger.Debug(string.Format(_culture, "Inersected course {0} intersects with course with free implementation", intersectedCourse.Code)); return(true); } if (!plannable) { _logger.Debug(string.Format(_culture, "plannable is false recursive IsPlannable all implementations from instersected course {0}", intersectedCourse.Code)); plannable = intersectedCourse.CourseImplementations.Any(ci => ci.IsPlannable(courses, scannedCourses, priority)); } } _logger.Debug(string.Format(_culture, "return plannable {0}", plannable)); return(plannable); }
public IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { DateTime startDate; bool isValidStartDate = SystemTime.TryParse(StartYear.GetValueOrDefault(), StartMonth.GetValueOrDefault(), StartDay.GetValueOrDefault(), out startDate); if (!isValidStartDate) { yield return(new ValidationResult(IndexResources.FromValid, new[] { "StartDay" })); } DateTime endDate; bool isValidEndDate = SystemTime.TryParse(EndYear.GetValueOrDefault(), EndMonth.GetValueOrDefault(), EndDay.GetValueOrDefault(), out endDate); if (!isValidEndDate) { yield return(new ValidationResult(IndexResources.ToValid, new[] { "EndDay" })); } if (!(isValidStartDate && isValidEndDate)) { // Stop further validation if either date is not a valid date yield break; } if (startDate > endDate) { yield return(new ValidationResult(IndexResources.FromDateAfterToDate, new[] { "StartYear" })); } }
void ReleaseDesignerOutlets() { if (DatePickerBar != null) { DatePickerBar.Dispose(); DatePickerBar = null; } if (DatePickerVacation != null) { DatePickerVacation.Dispose(); DatePickerVacation = null; } if (DateToolBar != null) { DateToolBar.Dispose(); DateToolBar = null; } if (DoneButton != null) { DoneButton.Dispose(); DoneButton = null; } if (EndDay != null) { EndDay.Dispose(); EndDay = null; } if (EndMonth != null) { EndMonth.Dispose(); EndMonth = null; } if (EndYear != null) { EndYear.Dispose(); EndYear = null; } if (Page != null) { Page.Dispose(); Page = null; } if (PageImage != null) { PageImage.Dispose(); PageImage = null; } if (StartDay != null) { StartDay.Dispose(); StartDay = null; } if (StartMonth != null) { StartMonth.Dispose(); StartMonth = null; } if (StartYear != null) { StartYear.Dispose(); StartYear = null; } if (StatusSegment != null) { StatusSegment.Dispose(); StatusSegment = null; } if (TypeImageView != null) { TypeImageView.Dispose(); TypeImageView = null; } if (TypeText != null) { TypeText.Dispose(); TypeText = null; } if (DatePickerToolbar != null) { DatePickerToolbar.Dispose(); DatePickerToolbar = null; } }
private async void Retrive_Option2_LongFilter(object sender, RoutedEventArgs e) { var rowKeys = new List <string>(); var endTime = EndTimePicker.Time; var days = EndDay.Date.Subtract(StartDay.Date).Days; for (var d = 0; d <= days; d++) { for (var hour = 0; hour <= endTime.Hours; hour++) { var endMinutes = hour == endTime.Hours ? endTime.Minutes : 60; for (var minute = 0; minute < endMinutes; minute++) { for (var second = 0; second <= 60; second++) { rowKeys.Add(StartDay.AddDays(d).AddHours(hour).AddMinutes(minute).AddSeconds(second).ToString("yyyyMMddHHmmss")); } } } } var table = tableClient.GetTableReference("option2"); try { Stopwatch sw = new Stopwatch(); sw.Start(); var finalResult = new List <MessageEntity>(); var tasks = new List <Task>(); var partitionFilter = TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, StartDay.Date.ToString("yyyyMMdd")); var rowsFilter = new StringBuilder(); var k = 0; for (var i = 0; i < rowKeys.Count; i++) { k++; var r = rowKeys[i]; rowsFilter.Append(TableQuery.GenerateFilterCondition("RowKey", QueryComparisons.Equal, r)); if (i != rowKeys.Count - 1 && k != 700) { rowsFilter.Append(" " + TableOperators.Or + " "); } if (k == 700) { var combinedFilter = TableQuery.CombineFilters(partitionFilter, TableOperators.And, rowsFilter.ToString()); var query = new TableQuery <MessageEntity>().Where(combinedFilter); tasks.Add(Task.Run(async() => { var token = new TableContinuationToken(); do { var seg = await table.ExecuteQuerySegmentedAsync(query, token); token = seg.ContinuationToken; lock (finalResult) { finalResult.AddRange(seg); } }while (token != null); })); rowsFilter.Clear(); k = 0; } } if (rowsFilter.Length > 0) { var combinedFilter = TableQuery.CombineFilters(partitionFilter, TableOperators.And, rowsFilter.ToString()); var query = new TableQuery <MessageEntity>().Where(combinedFilter); tasks.Add(Task.Run(async() => { var token = new TableContinuationToken(); do { var seg = await table.ExecuteQuerySegmentedAsync(query, token); token = seg.ContinuationToken; lock (finalResult) { finalResult.AddRange(seg); } }while (token != null); })); } await Task.WhenAll(tasks); sw.Stop(); ResultTextBox.Text = $"Option2 long filter: Found {finalResult.Count} records. It took {String.Format("{0:0.00000}", sw.Elapsed.TotalSeconds)} seconds."; } catch (Exception ex) { ResultTextBox.Text = ex.Message; Debug.WriteLine(ex.Message); } }
public SetIntendedShipmentInfoForNotification ToRequest(Guid notificationId) { DateTime startDate; SystemTime.TryParse(StartYear.GetValueOrDefault(), StartMonth.GetValueOrDefault(), StartDay.GetValueOrDefault(), out startDate); DateTime endDate; SystemTime.TryParse(EndYear.GetValueOrDefault(), EndMonth.GetValueOrDefault(), EndDay.GetValueOrDefault(), out endDate); return(new SetIntendedShipmentInfoForNotification( notificationId, int.Parse(NumberOfShipments, NumberStyles.AllowThousands), Convert.ToDecimal(Quantity), Units.GetValueOrDefault(), startDate, endDate)); }
public IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { if (!IsNumberOfShipmentsValid()) { yield return(new ValidationResult(ShipmentResources.NumberOfShipmentsValid, new[] { "NumberOfShipments" })); } if (!IsQuantityValid() && Units.HasValue) { yield return(new ValidationResult(string.Format(ShipmentResources.DecimalPlacesValid, ShipmentQuantityUnitsMetadata.Precision[Units.Value]), new[] { "Quantity" })); } DateTime startDate; bool isValidStartDate = SystemTime.TryParse(StartYear.GetValueOrDefault(), StartMonth.GetValueOrDefault(), StartDay.GetValueOrDefault(), out startDate); if (!isValidStartDate) { yield return(new ValidationResult(ShipmentResources.FirstDepartureValid, new[] { "StartDay" })); } DateTime endDate; bool isValidEndDate = SystemTime.TryParse(EndYear.GetValueOrDefault(), EndMonth.GetValueOrDefault(), EndDay.GetValueOrDefault(), out endDate); if (!isValidEndDate) { yield return(new ValidationResult(ShipmentResources.LastDepartureValid, new[] { "EndDay" })); } if (!(isValidStartDate && isValidEndDate)) { // Stop further validation if either date is not a valid date yield break; } if (startDate < SystemTime.Now.Date && Status == NotificationStatus.NotSubmitted) { yield return(new ValidationResult(ShipmentResources.FirstDeparturePastDate, new[] { "StartDay" })); } if (startDate > endDate) { yield return(new ValidationResult(ShipmentResources.FirstDepartureBeforeLastDate, new[] { "StartYear" })); } var monthPeriodLength = IsPreconsentedRecoveryFacility ? 36 : 12; if (endDate >= startDate.AddMonths(monthPeriodLength)) { yield return(new ValidationResult(string.Format(ShipmentResources.DepartureDateRange, monthPeriodLength), new[] { "EndYear" })); } }
private async void Retrive_Option4(object sender, RoutedEventArgs e) { ResultTextBox.Text = ""; var table = tableClient.GetTableReference("option4"); var startTime = StartTimePicker.Time; var endTime = EndTimePicker.Time; var days = EndDay.Date.Subtract(StartDay.Date).Days; try { Stopwatch sw = new Stopwatch(); sw.Start(); var finalResult = new List <MessageEntity>(); var tasks = new List <Task>(); for (var d = 0; d <= days; d++) { for (var hour = 0; hour <= endTime.Hours; hour++) { var endMinutes = d == days && hour == endTime.Hours ? endTime.Minutes : 60; if (endMinutes == 60) // full hour { var partitionFilter = TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, StartDay.AddDays(d).AddHours(hour).ToString("yyyyMMddHH")); var query = new TableQuery <MergedMessageEntity_Option4>().Where(partitionFilter); tasks.Add(Task.Run(async() => { //Stopwatch sw1 = new Stopwatch(); //sw1.Start(); var token = new TableContinuationToken(); do { var seg = await table.ExecuteQuerySegmentedAsync(query, token); token = seg.ContinuationToken; var messages = seg.SelectMany(merged => { var mm = new List <MessageEntity>(); for (var sec = 0; sec < 60; sec++) { var m = new MessageEntity(); m.Sensor1 = merged.Sensor1Dict[$"{sec}"]; m.Sensor2 = merged.Sensor2Dict[$"{sec}"]; m.Sensor3 = merged.Sensor3Dict[$"{sec}"]; m.Sensor4 = merged.Sensor4Dict[$"{sec}"]; m.Sensor5 = merged.Sensor5Dict[$"{sec}"]; mm.Add(m); } return(mm); }); lock (finalResult) { finalResult.AddRange(messages); } }while (token != null); //sw1.Stop(); //Debug.WriteLine($"Retrieve 1 hour block takes: {String.Format("{0:0.00000}", sw1.Elapsed.TotalSeconds)}"); })); } else // left minutes { var h = StartDay.AddDays(d).AddHours(hour); var rowKeys = new List <string>(); var partitionFilter = TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, h.ToString("yyyyMMddHH")); for (var i = 0; i <= endMinutes; i++) { rowKeys.Add(h.AddMinutes(i).ToString("yyyyMMddHHmm")); } var rowsFilter = new StringBuilder(); for (var i = 0; i < rowKeys.Count; i++) { var r = rowKeys[i]; rowsFilter.Append(TableQuery.GenerateFilterCondition("RowKey", QueryComparisons.Equal, r)); if (i != rowKeys.Count - 1) { rowsFilter.Append(" " + TableOperators.Or + " "); } } if (rowsFilter.Length > 0) { var combinedFilter = TableQuery.CombineFilters(partitionFilter, TableOperators.And, rowsFilter.ToString()); var query = new TableQuery <MergedMessageEntity_Option4>().Where(combinedFilter); tasks.Add(Task.Run(async() => { //Stopwatch sw1 = new Stopwatch(); //sw1.Start(); var token = new TableContinuationToken(); do { var seg = await table.ExecuteQuerySegmentedAsync(query, token); token = seg.ContinuationToken; var messages = seg.SelectMany(merged => { var mm = new List <MessageEntity>(); for (var sec = 0; sec < 60; sec++) { var m = new MessageEntity(); m.Sensor1 = merged.Sensor1Dict[$"{sec}"]; m.Sensor2 = merged.Sensor2Dict[$"{sec}"]; m.Sensor3 = merged.Sensor3Dict[$"{sec}"]; m.Sensor4 = merged.Sensor4Dict[$"{sec}"]; m.Sensor5 = merged.Sensor5Dict[$"{sec}"]; mm.Add(m); } return(mm); }); lock (finalResult) { finalResult.AddRange(messages); } }while (token != null); //sw1.Stop(); //Debug.WriteLine($"Retrieve left minutes {leftMinutes} takes: {String.Format("{0:0.00000}", sw1.Elapsed.TotalSeconds)}"); })); } } } } await Task.WhenAll(tasks); sw.Stop(); ResultTextBox.Text = $"Option4: Found {finalResult.Count} records. It took {String.Format("{0:0.00000}", sw.Elapsed.TotalSeconds)} seconds."; } catch (Exception ex) { ResultTextBox.Text = ex.Message; Debug.WriteLine(ex.Message); } }
public override string ToString() { return(StartDay.ToString() + ";" + EndDay.ToString()); }