/// <summary> /// Returns true if Entry instances are equal /// </summary> /// <param name="other">Instance of Entry to be compared</param> /// <returns>Boolean</returns> public bool Equals(Entry other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Type == other.Type || Type != null && Type.Equals(other.Type) ) && ( DateString == other.DateString || DateString != null && DateString.Equals(other.DateString) ) && ( Date == other.Date || Date != null && Date.Equals(other.Date) ) && ( Sgv == other.Sgv || Sgv != null && Sgv.Equals(other.Sgv) ) && ( Direction == other.Direction || Direction != null && Direction.Equals(other.Direction) ) && ( Noise == other.Noise || Noise != null && Noise.Equals(other.Noise) ) && ( Filtered == other.Filtered || Filtered != null && Filtered.Equals(other.Filtered) ) && ( Unfiltered == other.Unfiltered || Unfiltered != null && Unfiltered.Equals(other.Unfiltered) ) && ( Rssi == other.Rssi || Rssi != null && Rssi.Equals(other.Rssi) )); }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { // credit: http://stackoverflow.com/a/263416/677735 unchecked // Overflow is fine, just wrap { var hash = 41; // Suitable nullity checks etc, of course :) if (Type != null) { hash = hash * 59 + Type.GetHashCode(); } if (DateString != null) { hash = hash * 59 + DateString.GetHashCode(); } if (Date != null) { hash = hash * 59 + Date.GetHashCode(); } if (Sgv != null) { hash = hash * 59 + Sgv.GetHashCode(); } if (Direction != null) { hash = hash * 59 + Direction.GetHashCode(); } if (Noise != null) { hash = hash * 59 + Noise.GetHashCode(); } if (Filtered != null) { hash = hash * 59 + Filtered.GetHashCode(); } if (Unfiltered != null) { hash = hash * 59 + Unfiltered.GetHashCode(); } if (Rssi != null) { hash = hash * 59 + Rssi.GetHashCode(); } return(hash); } }
public override bool Equals(object obj) { var o = obj as LunchDay; if (o != null) { return(DateString.Equals(o.DateString) && Dishes.ContentsAreIdentical(o.Dishes)); } return(false); }
/// <inheritdoc /> protected override void Execute(Context context) { var dateString = DateString.Get(context); var format = DateFormat.Get(context); var date = string.IsNullOrWhiteSpace(format) ? DateTime.Parse(dateString, CultureInfo.InvariantCulture, DateTimeStyles.NoCurrentDateDefault) : DateTime.ParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.NoCurrentDateDefault); Result.Set(context, date); }
protected override void Execute(CodeActivityContext executionContext) { var dateString = DateString.Get <string>(executionContext); var dateFormat = DateFormat.Get <string>(executionContext); DateTime date; if (!String.IsNullOrWhiteSpace(dateString)) { var provider = CultureInfo.InvariantCulture; if (!DateTime.TryParseExact(dateString, dateFormat, provider, DateTimeStyles.None, out date)) { date = Date.Get <DateTime>(executionContext); } } else { date = Date.Get <DateTime>(executionContext); } bool am; var hour = date.Hour; Year.Set(executionContext, date.Year); YearText.Set(executionContext, date.Year.ToString()); Month.Set(executionContext, date.Month); Day.Set(executionContext, date.Day); Hour24.Set(executionContext, date.Hour); var cultureInfo = GetCultureInfo(executionContext, LanguageCode.Get <int>(executionContext)); MonthText.Set(executionContext, date.ToString("MMMM", cultureInfo.DateTimeFormat)); DayOfWeekString.Set(executionContext, date.ToString("dddd", cultureInfo.DateTimeFormat)); if (date.Hour >= 12) { am = false; hour = date.Hour - 12; } else { am = true; } Hour.Set(executionContext, hour); IsAM.Set(executionContext, am); IsPM.Set(executionContext, !am); Minute.Set(executionContext, date.Minute); DayOfWeek.Set(executionContext, (int)date.DayOfWeek); DayOfYear.Set(executionContext, date.DayOfYear); Week.Set(executionContext, GetWeek(date)); }
public bool NotValidateDateFormat() { try { var date = DateString.Split("/"); Code = new DateTime(CastToInt(date[2]), CastToInt(date[1]), CastToInt(date[0])); return(false); } catch (Exception) { return(true); } }
public List <Review> GetHistoric(string StartDate, string EndDate) { DateString dateString = new DateString(); var startDate = dateString.ToDateTime(StartDate); var endDate = dateString.ToDateTime(EndDate); var queryfilter = _entities .Where(x => x.ReviewDate >= startDate && x.ReviewDate <= endDate) .AsNoTracking(); return(queryfilter.ToList()); }
private static List <DateTime> BuildDateTimeFromString(string DateStrings) { List <DateTime> DateList = new List <DateTime>(); CultureInfo Provider = CultureInfo.InvariantCulture; foreach (string DateString in DateStrings.Split(',', StringSplitOptions.RemoveEmptyEntries)) { string CurrentDateString = DateString.Trim(); CurrentDateString = Regex.Replace(CurrentDateString, @"(\(.{3}).*?(\))", "$1$2"); // Standardize weekday name to only three characters. DateTime Date = DateTime.ParseExact(CurrentDateString, "ddMMMyyyy(ddd)", Provider); DateList.Add(Date); } return(DateList); }
public override void OnRefresh() { base.OnRefresh(); AllowCheckedEvent = false; // get a list of all possible dates from datasource DataProcessor Processor = new DataProcessor(); List <string> DefaultFileNames = new List <string>(); UIUtility.OutputFileUtility.GetOutputFiles(Controller, Controller.Selection, DefaultFileNames); Processor.DefaultOutputFileNames = DefaultFileNames; XmlDocument Doc = new XmlDocument(); Doc.LoadXml(Controller.ApsimData.Find(NodePath).FullXML()); DataTable DepthData = Processor.GoFindChildDataTable(Doc.DocumentElement); // get a list of currently selected dates. List <string> SelectedDates = XmlHelper.Values(Data, "Date"); // Convert all dd/mm/yyyy dates in XML to date strings formatted according to current // locale. for (int i = 0; i < SelectedDates.Count; i++) { try { DateTime d = DateTime.ParseExact(SelectedDates[i], "d/M/yyyy", null); SelectedDates[i] = d.ToShortDateString(); } catch (Exception) { SelectedDates[i] = ""; } } DateList.Items.Clear(); if (DepthData != null) { List <string> DateStrings = DataTableUtility.GetDistinctValues(DepthData, "Date"); foreach (string DateString in DateStrings) { string St = DateString.Substring(0, DateString.IndexOf(' ')); int Indx = DateList.Items.Add(St); bool IsSelected = SelectedDates.IndexOf(St) != -1; DateList.SetItemChecked(Indx, IsSelected); } } AllowCheckedEvent = true; }
public override string ToString() { if (DateString.StartsWith("BET 1 JAN")) { return("BET " + DateString.Substring(10)); } else if (DateString.StartsWith("AFT 1 JAN")) { return("AFT " + DateString.Substring(10)); } else { return(DateString); } }
private object _ConvertToType(string value, Type type, ProcessVariablesContainer variables) { object ret = value; switch (type.FullName) { case "System.Boolean": ret = bool.Parse(value); break; case "System.Byte[]": ret = Convert.FromBase64String(value); break; case "System.Char": ret = value[0]; break; case "System.DateTime": ret = new DateString(value).GetTime(variables); break; case "System.Decimal": ret = decimal.Parse(value); break; case "System.Double": ret = double.Parse(value); break; case "System.Single": ret = float.Parse(value); break; case "System.Int32": ret = int.Parse(value); break; case "System.Int64": ret = long.Parse(value); break; case "System.Int16": ret = short.Parse(value); break; } return(ret); }
public DateTime ParseDateString() { if (string.IsNullOrEmpty(DateString)) { return(DateTime.Now); } string[] dateArray = DateString.Split('-'); if (dateArray.Length < 2) { return(DateTime.Now); } return(new DateTime(Convert.ToInt32(dateArray[1]), Convert.ToInt32(dateArray[0]), 1)); }
protected override void ExecuteInternal(LocalWorkflowContext context) { string dateString = DateString.Get(context.CodeActivityContext); string format = DateFormat.Get(context.CodeActivityContext); DateTime date = DateTime.Now; if (DateTime.TryParse(dateString, out date)) { FormattedDateString.Set(context.CodeActivityContext, date.ToString(format)); } else if (dateString.ToUpper() == "NOW") { FormattedDateString.Set(context.CodeActivityContext, DateTime.Now.ToString(format)); } else { FormattedDateString.Set(context.CodeActivityContext, dateString); } }
protected override void Execute(CodeActivityContext context) { DateTime date; String date_string = DateString.Get(context); if (date_string != null) { date = DateTime.Parse(date_string); DayOfWeek day = CultureInfo.InvariantCulture.Calendar.GetDayOfWeek(date); if (day >= DayOfWeek.Monday && day <= DayOfWeek.Wednesday) { date = date.AddDays(3); } WeekNb.Set(context, CultureInfo.InvariantCulture.Calendar.GetWeekOfYear(date, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday)); } }
private void Element_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (sender == icb_validFrom || sender == icb_validTo) { if (icb_validFrom.SelectedIndex >= 0 && icb_validTo.SelectedIndex >= 0) { MessageBox.Show("Message"); DateTime validFrom = new DateString(icb_validFrom.Items[icb_validFrom.SelectedIndex]); DateTime validTo = new DateString(icb_validTo.Items[icb_validTo.SelectedIndex]); if (validTo <= validFrom) { lb_message3.Visibility = System.Windows.Visibility.Visible; } else { lb_message3.Visibility = System.Windows.Visibility.Collapsed; } } } }
private void Button_Click(object sender, RoutedEventArgs e) { if (icb_leaveType.Text.Length == 0 || dp_leavingDate.SelectedDate == null || dp_joiningDate.SelectedDate == null) { MessageBox.Show("Please fill in the required details.", "Incomplete", MessageBoxButton.OK, MessageBoxImage.Exclamation); return; } if (lb_message.Visibility == System.Windows.Visibility.Visible) { MessageBox.Show(lb_message.Content + "!", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } DateTime appliedLeavingDate = dp_leavingDate.SelectedDate.Value; DateTime appliedJoiningDate = dp_joiningDate.SelectedDate.Value; if (appliedLeavingDate < DateTime.Today) { MessageBox.Show("Leaving date cannot be a past date.", "Date Past", MessageBoxButton.OK, MessageBoxImage.Error); return; } MainPage mainPage = baseControl as MainPage; string columns = "LeavingDate, JoiningDate"; string rowConstraints = "EmployeeID = " + mainPage.EmployeeID; DataTable data = LeaveList.GetSpecificLeaveInfo(columns, rowConstraints); string clashInfo = ""; DateString currentLeavingDate = new DateString( ); DateString currentJoiningDate = new DateString( ); foreach (DataRow row in data.Rows) { currentLeavingDate = row[0].ToString( ); currentJoiningDate = row[1].ToString( ); if (appliedLeavingDate >= currentLeavingDate && appliedLeavingDate <= currentJoiningDate || appliedJoiningDate >= currentLeavingDate && appliedJoiningDate <= currentJoiningDate || appliedLeavingDate < currentLeavingDate && appliedJoiningDate > currentJoiningDate) { clashInfo = "You are already assigned a leaving date of " + currentLeavingDate + " and a joining date of " + currentJoiningDate; break; } } if (clashInfo.Length > 0) { MessageBox.Show(clashInfo); return; } mainPage.LeaveAssignmentPage.Load( ); mainPage.LeaveAssignmentPage.icb_employeeID.Text = mainPage.EmployeeID; mainPage.LeaveAssignmentPage.icb_leaveTypes.Text = icb_leaveType.Text; mainPage.LeaveAssignmentPage.dp_leavingDate.SelectedDate = dp_leavingDate.SelectedDate; mainPage.LeaveAssignmentPage.dp_joiningDate.SelectedDate = dp_joiningDate.SelectedDate; object balance = mainPage.LeaveAssignmentPage.lb_balance.Content; if (balance.ToString( ).Length == 0 || balance.ToString( ) == "!!" || double.Parse(balance.ToString( )) < 0) { if (MessageBox.Show("Application might not be granted due to balance issues.\nDo you still wish to continue?", "Warning", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.No) { return; } } LeaveApplications.SendApplication(mainPage.EmployeeID, icb_leaveType.Text.Replace("'", "''"), dp_leavingDate.SelectedDate.Value, dp_joiningDate.SelectedDate.Value, tb_description.Text.Replace("'", "''")); MessageBox.Show("Application sent!", "Success", MessageBoxButton.OK, MessageBoxImage.Information); }