private void ValidateDataItems(Guid value, IList <ValidationError> errors) { ObsDef def = ObsDef.GetEntityByObdGuid(value); //Only performs validation if it's a data item. if (def.ObsDefDataFormat == ObsDefDataFormat.Choice) { return; } //If the data item type is in the list of allowed data item types, return. if (AllowedDataItemTypes.Contains(def.ObsDefDataFormat)) { return; } //Otherwise, add error. IEnumerable <string> supportedTypes = AllowedDataItemTypes.Select(ConvertToString); string supportedTypeString = String.Join(", ", supportedTypes); string errorMsg = AllowedDataItemTypes.Count > 0 ? Rope.Format(Strings.IQDataItemVarActivity_DataItemTypeNotAllowed, def.Label, supportedTypeString) : Rope.Format(Strings.IQDataItemVarActivity_DataItemsNotAllowed, def.Label); errors.Add(new ValidationError(errorMsg, false, "Config")); }
private void ValidateTableTitle(Guid value, IList <ValidationError> errors) { ObsDef def = ObsDef.GetEntityByObdGuid(value); //No validation necessary if it's not a table title or if it is a table title and table titles are allowed. if (def.ObsDefDataFormat != ObsDefDataFormat.Choice || AllowTableTitles) { return; } //Otherwise, add error. string errorMsg = Rope.Format(Strings.IQDataItemVarActivity_TableTitlesNotAllowed, def.Label); errors.Add(new ValidationError(errorMsg, false, "Config")); }
/// <summary> /// Checks to see if the value is within the range of the constraints provided. /// </summary> /// <param name="value"></param> /// <param name="valueType"></param> /// <param name="errors"></param> private void ValidateValueCheckInRange(IList <ValidationError> errors, int value, IQVarElementTarget valueType) { string message = String.Empty; //Min and max values are defined. if (MinValue.HasValue && MaxValue.HasValue && (value < MinValue.Value || value > MaxValue.Value)) { message = Rope.Format(Strings.DoubleMustBeBetween, valueType == IQVarElementTarget.Selected ? Strings.SelectedValue : Strings.PredefinedValue, value, MinValue.Value, MaxValue.Value); } //Only minimum value is defined. else if (MinValue.HasValue && !MaxValue.HasValue && (value < MinValue.Value)) { message = Rope.Format(Strings.DoubleMustBeGreaterThan, valueType == IQVarElementTarget.Selected ? Strings.SelectedValue : Strings.PredefinedValue, value, MinValue.Value); } //Only maximum value is defined. else if (!MinValue.HasValue && MaxValue.HasValue && (value > MaxValue.Value)) { message = Rope.Format(Strings.DoubleMustBeLessThan, valueType == IQVarElementTarget.Selected ? Strings.SelectedValue : Strings.PredefinedValue, value, MaxValue.Value); } if (!String.IsNullOrWhiteSpace(message)) { errors.Add(new ValidationError(message, false, "Config")); } }
private void ShowError() { string message = string.Empty; if (MinValue.HasValue && MaxValue.HasValue) { message = Rope.Format(Strings.RangeErrorBetween, MinValue, MaxValue); } else if (MinValue.HasValue) { message = Rope.Format(Strings.RangeErrorBelowMin, MinValue); } else if (MaxValue.HasValue) { message = Rope.Format(Strings.RangeErrorAboveMax, MaxValue); } if (!string.IsNullOrWhiteSpace(message)) { XlateMessageBox.Information(message); } }