/// <summary> /// Creates the edit field. /// </summary> /// <returns> /// The <see cref="UPMEditField"/>. /// </returns> public override UPMEditField CreateEditField() { var field = new UPMDateTimeEditField(this.FieldIdentifier) { Type = DateTimeType.Time }; this.ApplyAttributesOnEditFieldConfig(field, this.FieldConfig); return(field); }
/// <summary> /// Initializes a new instance of the <see cref="UPMContactTime"/> class. /// </summary> /// <param name="weekDay">The week day.</param> /// <param name="timeType">The time type.</param> /// <param name="fromTime">From time.</param> /// <param name="toTime">To time.</param> public UPMContactTime(int weekDay, string timeType, UPMDateTimeEditField fromTime, UPMDateTimeEditField toTime) : base(StringIdentifier.IdentifierWithStringId("ContactTime")) { this.weekDay = weekDay; this.timeType = timeType; this.fromTime = fromTime; this.toTime = toTime; if (this.fromTime == null) { this.fromTime = new UPMDateTimeEditField(StringIdentifier.IdentifierWithStringId("fromTime")); } if (this.toTime == null) { this.toTime = new UPMDateTimeEditField(StringIdentifier.IdentifierWithStringId("toTime")); } }
private static UPMContactTime CreateContactTime(string fromDateString, string toDateString, int weekDay, string timeType) { var today = DateTime.Now; var hour = fromDateString.HourFromCrmTime(); var minute = fromDateString.MinuteFromCrmTime(); var fromDate = new DateTime(today.Year, today.Month, today.Day, hour, minute, 0); hour = toDateString.HourFromCrmTime(); minute = toDateString.MinuteFromCrmTime(); var toDate = new DateTime(today.Year, today.Month, today.Day, hour, minute, 0); var fromTime = new UPMDateTimeEditField(StringIdentifier.IdentifierWithStringId("fromTime")) { Type = DateTimeType.Time, DateValue = fromDate }; var toTime = new UPMDateTimeEditField(StringIdentifier.IdentifierWithStringId("toTime")) { Type = DateTimeType.Time, DateValue = toDate }; return(new UPMContactTime(weekDay, timeType, fromTime, toTime)); }
private void FillTimesVrianteWithTypeFromResultRowTimeType(UPCRMResultRow resultRow, string timeType) { if (string.IsNullOrEmpty(this.contactTimesGroup.TimeTypeTitleForTimeType(timeType))) { return; } var valuesWithFunctions = resultRow.ValuesWithFunctions(); DateTime fromDate; DateTime toDate; UPMDateTimeEditField fromTime; UPMDateTimeEditField toTime; UPMContactTime contactTime; string from = "FROM"; string to = "TO"; string afternoonFrom = "AFTERNOONFROM"; string afternoonTo = "AFTERNOONTO"; int weekDay = ((string)valuesWithFunctions.ValueOrDefault("DAYOFWEEK")).ToInt(); if (weekDay < 7) { weekDay++; } else { weekDay = 1; } if ((valuesWithFunctions.ValueOrDefault(from) != null && ((string)valuesWithFunctions.ValueOrDefault(from)).ToInt() > 0) || (valuesWithFunctions.ValueOrDefault(to) != null && ((string)valuesWithFunctions.ValueOrDefault(to)).ToInt() > 0)) { fromDate = ((string)valuesWithFunctions.ValueOrDefault(from)).TimeFromCrmValue(); toDate = ((string)valuesWithFunctions.ValueOrDefault(to)).TimeFromCrmValue(); fromTime = new UPMDateTimeEditField(StringIdentifier.IdentifierWithStringId("fromTime")) { Type = DateTimeType.Time, DateValue = fromDate }; toTime = new UPMDateTimeEditField(StringIdentifier.IdentifierWithStringId("toTime")) { Type = DateTimeType.Time, DateValue = toDate }; contactTime = new UPMContactTime(weekDay, timeType, fromTime, toTime) { RecordIdentification = resultRow.RecordIdentificationAtFieldIndex(0) }; this.contactTimesGroup.AddChild(contactTime); } if ((valuesWithFunctions.ValueOrDefault(afternoonFrom) != null && ((string)valuesWithFunctions.ValueOrDefault(afternoonFrom)).ToInt() > 0) || (valuesWithFunctions.ValueOrDefault(afternoonTo) != null && ((string)valuesWithFunctions.ValueOrDefault(afternoonTo)).ToInt() > 0)) { fromDate = ((string)valuesWithFunctions.ValueOrDefault(afternoonFrom)).TimeFromCrmValue(); toDate = ((string)valuesWithFunctions.ValueOrDefault(afternoonTo)).TimeFromCrmValue(); fromTime = new UPMDateTimeEditField(StringIdentifier.IdentifierWithStringId("fromTime")) { Type = DateTimeType.Time, DateValue = fromDate }; toTime = new UPMDateTimeEditField(StringIdentifier.IdentifierWithStringId("toTime")) { Type = DateTimeType.Time, DateValue = toDate }; contactTime = new UPMContactTime(weekDay, timeType, fromTime, toTime) { RecordIdentification = resultRow.RecordIdentificationAtFieldIndex(0) }; this.contactTimesGroup.AddChild(contactTime); } }
private void FillTimesVrianteWithoutTypeFromResultRowTimeTypePrefix(UPCRMResultRow resultRow, string timeType, string prefix) { var valuesWithFunctions = resultRow.ValuesWithFunctions(); DateTime fromDate; DateTime toDate; UPMDateTimeEditField fromTime; UPMDateTimeEditField toTime; UPMContactTime contactTime; var from = $"{prefix}FROM"; var to = $"{prefix}TO"; var afternoonFrom = $"{prefix}AFTERNOONFROM"; var afternoonTo = $"{prefix}AFTERNOONTO"; int weekDay = ((string)valuesWithFunctions.ValueOrDefault("DAYOFWEEK")).ToInt(); if (weekDay < 7) { weekDay++; } else { weekDay = 1; } if (valuesWithFunctions.ValueOrDefault(to) != null && ((string)valuesWithFunctions.ValueOrDefault(to)).ToInt() > 0) { fromDate = (valuesWithFunctions.ValueOrDefault(from) as string).TimeFromCrmValue(); toDate = (valuesWithFunctions.ValueOrDefault(to) as string).TimeFromCrmValue(); fromTime = new UPMDateTimeEditField(StringIdentifier.IdentifierWithStringId("fromTime")) { Type = DateTimeType.Time, DateValue = fromDate }; toTime = new UPMDateTimeEditField(StringIdentifier.IdentifierWithStringId("toTime")) { Type = DateTimeType.Time, DateValue = toDate }; contactTime = new UPMContactTime(weekDay, timeType, fromTime, toTime) { RecordIdentification = resultRow.RecordIdentificationAtFieldIndex(0) }; this.contactTimesGroup.AddChild(contactTime); } else { contactTime = new UPMContactTime(weekDay, timeType, null, null); this.contactTimesGroup.AddChild(contactTime); } if (valuesWithFunctions.ValueOrDefault(afternoonTo) != null && ((string)valuesWithFunctions.ValueOrDefault(afternoonTo)).ToInt() > 0) { fromDate = (valuesWithFunctions.ValueOrDefault(afternoonFrom) as string).TimeFromCrmValue(); toDate = (valuesWithFunctions.ValueOrDefault(afternoonTo) as string).TimeFromCrmValue(); fromTime = new UPMDateTimeEditField(StringIdentifier.IdentifierWithStringId("fromTime")) { Type = DateTimeType.Time, DateValue = fromDate }; toTime = new UPMDateTimeEditField(StringIdentifier.IdentifierWithStringId("toTime")) { Type = DateTimeType.Time, DateValue = toDate }; contactTime = new UPMContactTime(weekDay, timeType, fromTime, toTime) { RecordIdentification = resultRow.RecordIdentificationAtFieldIndex(0) }; this.contactTimesGroup.AddChild(contactTime); } else { contactTime = new UPMContactTime(weekDay, timeType, null, null) { RecordIdentification = resultRow.RecordIdentificationAtFieldIndex(0) }; this.contactTimesGroup.AddChild(contactTime); } }