public void SetMinZoomPreference(View view) { string text = minZoomlevel.Text.ToString(); if ((text.Trim().Length == 0) || (text == null) || ("".Equals(text))) { Toast.MakeText(this, "Please make sure the minZoom is Edited", ToastLength.Short).Show(); } else { if (!CheckUtils.IsNumber(text.Trim())) { Toast.MakeText(this, "Please make sure the minZoom is right", ToastLength.Short).Show(); return; } if (Single.Parse(text.Trim()) > MapUtils.MAX_ZOOM_LEVEL || Single.Parse(text.Trim()) < MapUtils.MIN_ZOOM_LEVEL) { Toast.MakeText(this, String.Format(Locale.English.ToString(), "The zoom level ranges from %s to %s.", MapUtils.MIN_ZOOM_LEVEL, MapUtils.MAX_ZOOM_LEVEL), ToastLength.Short).Show(); } else { if (null != hMap) { hMap.SetMinZoomPreference(Single.Parse(minZoomlevel.Text.ToString())); } } } }
public void SetPadding(View view) { string leftString = left.Text.ToString(); string topString = top.Text.ToString(); string rightString = right.Text.ToString(); string bottomString = bottom.Text.ToString(); if ((leftString.Trim().Length == 0) || (leftString == null) || ("".Equals(leftString)) || (topString.Trim().Length == 0) || (topString == null) || ("".Equals(topString)) || (rightString.Trim().Length == 0) || (rightString == null) || ("".Equals(rightString)) || (bottomString.Trim().Length == 0) || (bottomString == null) || ("".Equals(bottomString))) { } else { if (!CheckUtils.IsNumber(leftString.Trim()) || !CheckUtils.IsNumber(topString.Trim()) || !CheckUtils.IsNumber(rightString.Trim()) || !CheckUtils.IsNumber(bottomString.Trim())) { Toast.MakeText(this, "Please make sure the padding value is right", ToastLength.Short).Show(); } else { if (null != hMap) { hMap.SetPadding(int.Parse(left.Text.ToString()), int.Parse(top.Text.ToString()), int.Parse(right.Text.ToString()), int.Parse(bottom.Text.ToString())); } } } }
public void SetWidth(View v) { if (null != mPolyline) { string width = polylineStokeWidth.Text.ToString().Trim(); if (CheckUtils.CheckIsEdit(width)) { Toast.MakeText(this, "Please make sure the width is Edited", ToastLength.Short).Show(); } else { if (!CheckUtils.CheckIsRight(width)) { Toast.MakeText(this, "Please make sure the width is right", ToastLength.Short).Show(); } else { if (Single.Parse(width) < 0.0F) { Toast.MakeText(this, "Please make sure the width is right, this value must be non-negative", ToastLength.Short).Show(); return; } mPolyline.Width = Single.Parse(width); } } } }
public void SetRadius(View v) { if (null != mCircle) { string radius = circleRadius.Text.ToString().Trim(); if (CheckUtils.CheckIsEdit(radius)) { Toast.MakeText(this, "Please make sure the radius is Edited", ToastLength.Short).Show(); } else { if (!CheckUtils.CheckIsRight(radius)) { Toast.MakeText(this, "Please make sure the radius is right", ToastLength.Short).Show(); } else { try { mCircle.Radius = System.Double.Parse(radius); } catch (IllegalArgumentException e) { Toast.MakeText(this, "IllegalArgumentException ", ToastLength.Short).Show(); } } } } }
public void SetWidth(View v) { if (null != mCircle) { string width = circleStokeWidth.Text.ToString().Trim(); if (CheckUtils.CheckIsEdit(width)) { Toast.MakeText(this, "Please make sure the width is Edited", ToastLength.Short).Show(); } else { if (!CheckUtils.CheckIsRight(width)) { Toast.MakeText(this, "Please make sure the width is right", ToastLength.Short).Show(); } else { try { mCircle.StrokeWidth = Single.Parse(width); } catch (IllegalArgumentException e) { Log.Error(TAG, "IllegalArgumentException " + e.ToString()); Toast.MakeText(this, "IllegalArgumentException", ToastLength.Short).Show(); } } } } }
/// <summary> /// Validates the name of the user. /// </summary> /// <param name="value">Name of the user.</param> /// <param name="idValue">id value of the entity. It will be used in update mode to check duplicate</param> /// <param name="fnName">Business rule function if it is insert or update</param> /// <param name="errors">The errors.</param> /// <param name="throwIfErrors">Throw BRException if an error happened</param> public bool ValidateUserName(string value, long?idValue, BusinessRuleErrorList errors, RuleFunctionSEnum fnName, bool throwIfErrors) { int errCount = errors.Count; if (CheckUtils.CheckStringShouldNotBeNullOrEmpty(vUser.ColumnNames.UserName, value, errors) == false) { if (throwIfErrors && errors.Count > errCount) { throw new BRException(errors); } else { return(false); } } string colName = vUser.ColumnNames.UserName; //Must consist at least two characters that are alpha characters a-zA-Z //Must consist only ONE underscore or dash allowed anywhere AFTER the first check, //the dash/underscore cannot be at the end as the same rule to apply as the first step //Must be alpha-numeric characters. //var colInfo = this.Entity.EntityColumns[User.ColumnNames.UserName]; if (fnName == RuleFunctionSEnum.Delete) { return(true); } // DEVELOPER NOTE: Change this pattern with pattern specified in UI in FWHtml.cs file for editor // format check // http://stackoverflow.com/questions/3588623/c-sharp-regex-for-a-username-with-a-few-restrictions string valuePattern = @"^(?=.{5,50}$)([A-Za-z0-9][._]?)*$"; //(?=.{5,50}$) Must be 5-50 characters in the string //([A-Za-z0-9][._()\[\]-]?)* The string is a sequence of alphanumerics, // each of which may be followed by a symbol if (System.Text.RegularExpressions.Regex.IsMatch( value, valuePattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase) == false) { errors.Add(colName, BusinessErrorStrings.User.UserName_RegularExpressionCheck ); } // duplicate check if (errors.Count == 0) // Perfomance: We check database only if no error is there. { value = value.ToLower(); // we store all user names in lower case CheckUtils.CheckDuplicateValueNotToBeExists(colName, value, idValue, errors, null, fnName == RuleFunctionSEnum.Insert, BusinessErrorStrings.User.UserName_DuplicateUserName); } if (errors.Count > 0 && throwIfErrors) { throw new BRException(errors); } return(errors.Count == 0); }
//Please write your properties and functions here. This part will not be replaced. public override void CheckRules(object entitySet, RuleFunctionSEnum fnName, BusinessRuleErrorList errors) { base.CheckRules(entitySet, fnName, errors); VitalValue o = (VitalValue)entitySet; if (CheckUtils.DateTimeLessThanUtcNow(o.RecordDateTime, vVitalValue.ColumnNames.RecordDateTime, errors)) { CheckUtils.DateTimeIsInUnixRange(o.RecordDateTime, vVitalValue.ColumnNames.RecordDateTime, errors); } }
/// <summary> /// Validates the phone number /// </summary> /// <param name="value">Phone Number</param> /// <param name="idValue">id value of the entity. It will be used in update mode to check duplicate</param> /// <param name="fnName">Business rule function if it is insert or update</param> /// <param name="canBeNull">See if Phone number can be null or empty</param> /// <param name="errors">The errors.</param> /// <param name="throwIfErrors">Throw BRException if an error happened</param> public bool ValidatePhoneNumber(string value, long?idValue, bool canBeNull, BusinessRuleErrorList errors, RuleFunctionSEnum fnName, bool throwIfErrors) { int errCount = errors.Count; // To simplify Signup, we removed Phone number as mandatory // in addition, RegisterAndLogin option doesn't need to have a phone number // However, if a phone number is provided, we need to check its format if (string.IsNullOrEmpty(value) && canBeNull) { return(true); } if (CheckUtils.CheckStringShouldNotBeNullOrEmpty(vUser.ColumnNames.PhoneNumber, value, errors) == false) { if (throwIfErrors && errors.Count > errCount) { throw new BRException(errors); } else { return(false); } } string colName = vUser.ColumnNames.PhoneNumber; if (fnName == RuleFunctionSEnum.Delete) { return(true); } if (IsValidPhoneNumberE164(value) == false) { errors.Add(colName, BusinessErrorStrings.User.PhoneNumber_NotE164); } // duplicate check if (errors.Count == 0) // Perfomance: We check database only if no error is there. { value = value.ToLower(); // we store all user names in lower case CheckUtils.CheckDuplicateValueNotToBeExists(colName, value, idValue, errors, null, fnName == RuleFunctionSEnum.Insert, BusinessErrorStrings.User.PhoneNumber_DuplicatePhoneNumber); } if (errors.Count > 0 && throwIfErrors) { throw new BRException(errors); } return(errors.Count == 0); }
//Please write your properties and functions here. This part will not be replaced. public override void CheckRules(object entitySet, RuleFunctionSEnum fnName, BusinessRuleErrorList errors) { base.CheckRules(entitySet, fnName, errors); // check to make sure that no duplicate item is exists in the database CheckUtils.CheckDuplicateTwoKeyNotToBeExists(entitySet, vDoctor_Specialty.ColumnNames.SpecialtyID, vDoctor_Specialty.ColumnNames.DoctorID, vDoctor_Specialty.ColumnNames.Doctor_SpecialtyID, errors, null, fnName == RuleFunctionSEnum.Insert, null); }
public void SetTag(View v) { if (null != overlay) { string tag = groundOverlayTag.Text.ToString().Trim(); if (CheckUtils.CheckIsEdit(tag)) { Toast.MakeText(this, "Please make sure the tag is Edited", ToastLength.Short).Show(); } else { overlay.Tag = tag; } } }
//Please write your properties and functions here. This part will not be replaced. public override void CheckRules(object entitySet, RuleFunctionSEnum fnName, BusinessRuleErrorList errors) { TimeSeriesStrip obj = (TimeSeriesStrip)entitySet; if (fnName == RuleFunctionSEnum.Insert) { obj.EndDateOffset = obj.StartDateOffset; CheckUtils.CheckNotEqual(obj.TimeSeriesStripID, Guid.Empty, vTimeSeriesStrip.ColumnNames.TimeSeriesStripID, errors); CheckUtils.CheckNotEqual(obj.TimeSeriesTypeID, 0, vTimeSeriesStrip.ColumnNames.TimeSeriesTypeID, errors); } }
public void SetTag(View v) { if (null != mPolygon) { string tag = polygonTag.Text.ToString().Trim(); if (CheckUtils.CheckIsEdit(tag)) { Toast.MakeText(this, "Please make sure the tag is Edited", ToastLength.Short).Show(); } else { mPolygon.Tag = tag; } } }
public void SetPointsBy1PointsWidthHeight(View view) { if (null != overlay) { String width = imageWidth.Text.ToString().Trim(); String height = imageHeight.Text.ToString().Trim(); String latitude = positionLatitude.Text.ToString().Trim(); String longtitude = positionLongtitude.Text.ToString().Trim(); if (CheckUtils.CheckIsEdit(width) || CheckUtils.CheckIsEdit(height) || CheckUtils.CheckIsEdit(latitude) || CheckUtils.CheckIsEdit(longtitude)) { Toast.MakeText(this, "Please make sure the width & height & position is Edited", ToastLength.Short).Show(); } else { if (!CheckUtils.CheckIsRight(width) || !CheckUtils.CheckIsRight(height) || !CheckUtils.CheckIsRight(latitude) || !CheckUtils.CheckIsRight(longtitude)) { Toast.MakeText(this, "Please make sure the width & height & position is right", ToastLength.Short).Show(); } else { try { if (Single.Parse(width) < 0.0F || Single.Parse(height) < 0.0F) { Toast .MakeText(this, "Please make sure the width & height is right, this value must be non-negative", ToastLength.Short).Show(); return; } LatLng position = new LatLng(Double.Parse(latitude), Double.Parse(longtitude)); overlay.Position = position; overlay.SetDimensions(Single.Parse(width), Single.Parse(height)); CameraPosition cameraPosition = new CameraPosition.Builder().Target(position).Zoom(18).Bearing(0f).Tilt(0f).Build(); CameraUpdate cameraUpdate = CameraUpdateFactory.NewCameraPosition(cameraPosition); hMap.MoveCamera(cameraUpdate); } catch (Java.Lang.IllegalArgumentException e) { Toast.MakeText(this, "IllegalArgumentException:" + e.Message, ToastLength.Short).Show(); } } } } }
public bool ValidateEmail(string value, long?idValue, BusinessRuleErrorList errors, RuleFunctionSEnum fnName, bool throwIfErrors) { if (string.IsNullOrEmpty(value)) { return(true); } //if (CheckUtils.CheckStringShouldNotBeNullOrEmpty(vUser.ColumnNames.Email, value, errors) == false) // if (throwIfErrors) // throw new BRException(errors); // else // return false; if (fnName == RuleFunctionSEnum.Delete) { return(true); } string colName = vUser.ColumnNames.Email; // format check // we try to create a mail address. If format was incorrect then its an error //http://stackoverflow.com/questions/5342375/c-sharp-regex-email-validation try { System.Net.Mail.MailAddress m = new System.Net.Mail.MailAddress(value); } catch (Exception) { errors.Add(colName, BusinessErrorStrings.User.Email_InvalidEmailAddress); } // check duplicate if (errors.Count == 0) // Perfomance: We check database only if no error is there. { value = value.ToLower(); // we store all emails in lower case CheckUtils.CheckDuplicateValueNotToBeExists(colName, value, idValue, errors, null, fnName == RuleFunctionSEnum.Insert, BusinessErrorStrings.User.Email_Duplicate); } if (errors.Count > 0 && throwIfErrors) { throw new BRException(errors); } return(errors.Count == 0); }
public void UpdatePaykeyInDatabase(string payKey) { BusinessRuleErrorList errors = new BusinessRuleErrorList(); if (CheckUtils.CheckStringShouldNotBeNullOrEmpty(vPayment.ColumnNames.PayKey, payKey, errors) == false) { throw new BRException(errors); } // check if pay key is not duplicated in database FilterExpression filter = new FilterExpression(); filter.AddFilter(new Filter(vPayment.ColumnNames.PaymentStatusID, (int)EntityEnums.PaymentStatusEnum.PendingWithPayKey)); if (CheckUtils.CheckDuplicateValueNotToBeExists(vPayment.ColumnNames.PayKey, payKey, null, errors, null, true, null) == false) { throw new BRException(errors[0].ErrorDescription); } }
public void SetPointsBy2Points(View view) { if (null != overlay) { string northeastLatitude = toprightLatitude.Text.ToString().Trim(); string northeastLongtitude = toprightLongtitude.Text.ToString().Trim(); string southwestLatitude = bottomleftLatitude.Text.ToString().Trim(); string southwestLontitude = bottomleftLongtitude.Text.ToString().Trim(); if (CheckUtils.CheckIsEdit(northeastLatitude) || CheckUtils.CheckIsEdit(northeastLongtitude) || CheckUtils.CheckIsEdit(southwestLatitude) || CheckUtils.CheckIsEdit(southwestLontitude)) { Toast.MakeText(this, "Please make sure these latlng are Edited", ToastLength.Short).Show(); } else { if (!CheckUtils.CheckIsRight(northeastLatitude) || !CheckUtils.CheckIsRight(northeastLongtitude) || !CheckUtils.CheckIsRight(southwestLatitude) || !CheckUtils.CheckIsRight(southwestLontitude)) { Toast.MakeText(this, "Please make sure these latlng are right", ToastLength.Short).Show(); } else { try { overlay.SetPositionFromBounds(new LatLngBounds( new LatLng(Double.Parse(southwestLatitude), Double.Parse(southwestLontitude)), new LatLng(Double.Parse(northeastLatitude), Double.Parse(northeastLongtitude)))); CameraPosition cameraPosition = new CameraPosition.Builder() .Target(overlay.Position) .Zoom(18) .Bearing(0f) .Tilt(0f) .Build(); CameraUpdate cameraUpdate = CameraUpdateFactory.NewCameraPosition(cameraPosition); hMap.MoveCamera(cameraUpdate); } catch (Java.Lang.IllegalArgumentException e) { Toast.MakeText(this, "IllegalArgumentException ", ToastLength.Short).Show(); } } } } }
/// <summary> /// Check business rules for continuing quick registration /// </summary> /// <param name="p"></param> public void ContinueQReg(UserContinueQRegSP p) { BusinessRuleErrorList errors = new BusinessRuleErrorList(); if (p.Password != p.ConfirmPassword) { errors.Add(vUser.ColumnNames.PasswordHash, BusinessErrorStrings.User.PasswordAndConfirmPasswordDoesntMatch); } CheckUtils.CheckStringShouldNotBeNullOrEmpty(vUser.ColumnNames.Email, p.Email, errors); CheckUtils.CheckStringShouldNotBeNullOrEmpty(vUser.ColumnNames.UserName, p.UserName, errors); CheckUtils.CheckStringShouldNotBeNullOrEmpty(vUser.ColumnNames.PasswordHash, p.Password, errors); CheckUtils.CheckStringShouldNotBeNullOrEmpty(vUser.ColumnNames.PhoneNumber, p.PhoneNumber, errors); if (errors.Count > 0) { throw new BRException(errors); } }
//Please write your properties and functions here. This part will not be replaced. public override void CheckRules(object entitySet, RuleFunctionSEnum fnName, BusinessRuleErrorList errors) { base.CheckRules(entitySet, fnName, errors); if (CheckUtils.CheckDuplicateTwoKeyNotToBeExists (entitySet , vMedicalHistory.ColumnNames.SectionName, vMedicalHistory.ColumnNames.PatientUserID, vMedicalHistory.ColumnNames.MedicalHistoryID, errors, null, fnName == RuleFunctionSEnum.Insert, null) == false) { // the application shouldn't insert a medical history section when it is exists in the database throw new ImpossibleExecutionException("Medical history section is already saved by another user. Please re-save it."); } }
public bool ValidatePassword(string value, BusinessRuleErrorList errors, bool throwIfException) { string colName = vUser.ColumnNames.PasswordHash; if (CheckUtils.CheckStringShouldNotBeNullOrEmpty(vUser.ColumnNames.PasswordHash, value, errors)) { // Pattern obtained from //http://regexlib.com/(A(13E-t-BjvZ-WvDNI3kEXWexqe-dnRabCLhUJT4HCwiq39cFxk1bCp2xTgMv4ZLuwh4z02qwn-LwirPbo_Y1NF6Tnx6zEJKJ9ukU7WXcOnRM1))/Search.aspx?k=password&c=-1&m=-1&ps=20 string valuePattern = @"(?=^.{6,64}$)(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&*()_+}{":;'?/>.<,])(?!.*\s).*$"; if (System.Text.RegularExpressions.Regex.IsMatch( value, valuePattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase) == false) { errors.Add(colName, BusinessErrorStrings.User.Password_RegularExpression ); } } if (errors.Count > 0 && throwIfException) { throw new BRException(errors); } return(errors.Count == 0); }
//Please write your properties and functions here. This part will not be replaced. public override void CheckRules(object entitySet, RuleFunctionSEnum fnName, BusinessRuleErrorList errors) { TimeSeries_SmallInt_Seconds obj = (TimeSeries_SmallInt_Seconds)entitySet; if (fnName == RuleFunctionSEnum.Insert) { //TODO: Check related TimeSeriesStrip exists //TODO: Check date is greater than startdate in strip //TODO: Check strip is the lastest strip in database CheckUtils.CheckNotEqual(obj.TimeSeriesStripID, Guid.Empty, TimeSeries_SmallInt_Seconds.ColumnNames.TimeSeriesStripID, errors); // typeid should be provided CheckUtils.CheckNotEqual(obj.TimeSeriesTypeID, 0, TimeSeries_SmallInt_Seconds.ColumnNames.TimeSeriesTypeID, errors); // time should be in unix range int maxUtcEpoch = DateTimeEpoch.GetUtcNowEpoch(); CheckUtils.CheckIntBetweenMinMax(TimeSeries_SmallInt_Seconds.ColumnNames.TSDateOffset, obj.TSDateOffset, errors, DateTimeEpoch.UnixMinDateSecondsEpoch, maxUtcEpoch); } }
public void SetOnePoint(View v) { if (null != mPolyline) { string latitude = oneLatitude.Text.ToString().Trim(); string longtitude = oneLongtitude.Text.ToString().Trim(); if (CheckUtils.CheckIsEdit(latitude) || CheckUtils.CheckIsEdit(longtitude)) { Toast.MakeText(this, "Please make sure the latitude & longtitude is Edited", ToastLength.Short).Show(); } else { if (!CheckUtils.CheckIsRight(latitude) || !CheckUtils.CheckIsRight(longtitude)) { Toast.MakeText(this, "Please make sure the latitude & longtitude is right", ToastLength.Short).Show(); } else { points.Add(new LatLng(System.Double.Parse(latitude), System.Double.Parse(longtitude))); mPolyline.Points = points; } } } }
public void SetPoints(View v) { if (null != mPolygon) { string latitude = oneLatitude.Text.ToString().Trim(); string longtitude = oneLongtitude.Text.ToString().Trim(); if (CheckUtils.CheckIsEdit(latitude) || CheckUtils.CheckIsEdit(longtitude)) { Toast.MakeText(this, "Please make sure the latitude & longtitude is Edited", ToastLength.Short).Show(); } else { if (!CheckUtils.CheckIsRight(latitude) || !CheckUtils.CheckIsRight(longtitude)) { Toast.MakeText(this, "Please make sure the latitude & longtitude is right", ToastLength.Short).Show(); } else { mPolygon.Points = (MapUtils .CreateRectangle(new LatLng(System.Double.Parse(latitude), System.Double.Parse(longtitude)), 0.5, 0.5)); } } } }
protected AbstractOauth(string clientId, string clientSecret) { CheckUtils.CheckParams(clientId, clientSecret); this._ClientId = clientId; this._ClientSecret = clientSecret; }
protected virtual void CheckAutomatedRules(object entitySet, RuleFunctionSEnum fnName, BusinessRuleErrorList errors) { foreach (var colInfo in this.Entity.EntityColumns) { ColumnInfo col = colInfo.Value; if ( (col.IsUpdatable && fnName == RuleFunctionSEnum.Update) || (col.IsInsertable && fnName == RuleFunctionSEnum.Insert) ) { object val = FWUtils.EntityUtils.GetObjectFieldValue(entitySet, col.Name); // check allow blank for all types if (col.ValidationIsNullable == false) { if (val == null) { errors.Add(col.Name, string.Format(StringMsgs.BusinessErrors.NotNull, col.Caption)); continue; } // TODO: fix foreign key integer value checking for int //// for integer values if the column is id column, we check not to enter -1 value (that is the default for not having a value) //if (col.Name.EndsWith("ID") && (val is Int16 || val is Int32 || val is Int64)) // if (Convert.ToInt64(val) == -1) // { // errors.Add(col.Name, string.Format(StringMsgs.BusinessErrors.NotNull, col.Caption)); // continue; // } } // checking string length if (col.DataTypeDotNet == typeof(string)) { if (col.ValidationIsNullable == false && ((string)val) == "") { errors.Add(col.Name, string.Format(StringMsgs.BusinessErrors.StringNotNullOrEmpty, col.Caption)); } CheckUtils.CheckStringLenBetweenMinAndMax(col.Name, (string)val, errors, col.ValidationMinLength, col.ValidationMaxLength); } // checking minimum maximum value if existed if (col.ValidationMaxValue != null || col.ValidationMinValue != null) { if (col.DataTypeDotNet == typeof(int)) { CheckUtils.CheckIntBetweenMinMax(col.Name, (int)val, errors, (int?)col.ValidationMinValue, (int?)col.ValidationMaxValue); } else if (col.DataTypeDotNet == typeof(long)) { CheckUtils.CheckLongBetweenMinMax(col.Name, (long)val, errors, (long?)col.ValidationMinValue, (long?)col.ValidationMaxValue); } else if (col.DataTypeDotNet == typeof(double)) { CheckUtils.CheckDoubleBetweenMinMax(col.Name, (double)val, errors, (double?)col.ValidationMinValue, (double?)col.ValidationMaxValue); } else if (col.DataTypeDotNet == typeof(float)) { CheckUtils.CheckFloatBetweenMinMax(col.Name, (float)val, errors, (float?)col.ValidationMinValue, (float?)col.ValidationMaxValue); } else if (col.DataTypeDotNet == typeof(decimal)) { CheckUtils.CheckDecimalBetweenMinMax(col.Name, (decimal)val, errors, (decimal?)col.ValidationMinValue, (decimal?)col.ValidationMaxValue); } else if (col.DataTypeDotNet == typeof(DateTime)) { CheckUtils.CheckDateTimeBetweenMinMax(col.Name, (DateTime)val, errors, (DateTime?)col.ValidationMinValue, (DateTime?)col.ValidationMaxValue); } else if (col.DataTypeDotNet == typeof(short)) { CheckUtils.CheckShortBetweenMinMax(col.Name, (short)val, errors, (short?)col.ValidationMinValue, (short?)col.ValidationMaxValue); } else if (col.DataTypeDotNet == typeof(byte)) { CheckUtils.CheckByteBetweenMinMax(col.Name, (byte)val, errors, (byte?)col.ValidationMinValue, (byte?)col.ValidationMaxValue); } } // duplicate check if (errors.Count == 0 && col.ValidationNoDuplicate) // Perfomance: We check database only if no error is there. { object idValue = ((EntityObjectBase)entitySet).GetPrimaryKeyValue(); CheckUtils.CheckDuplicateValueNotToBeExists(col.Name, val, idValue, errors, null, fnName == RuleFunctionSEnum.Insert, null); } } // end of if column should be validated or not } // end foreach column }
//Please write your properties and functions here. This part will not be replaced. public override void CheckRules(object entitySet, RuleFunctionSEnum fnName, BusinessRuleErrorList errors) { base.CheckRules(entitySet, fnName, errors); var obj = (DoctorSchedule)entitySet; CheckUtils.CheckByteBetweenMinMax(vDoctorSchedule.ColumnNames.NumberOfAllowedPatients, obj.NumberOfAllowedPatients, errors, 1, 100); CheckUtils.CheckByteBetweenMinMax(vDoctorSchedule.ColumnNames.NumberOfRegisteredPatients, obj.NumberOfRegisteredPatients, errors, 0, 100); if (obj.SlotUnixEpoch <= DateTimeEpoch.GetUtcNowEpoch()) { errors.Add(vDoctorSchedule.ColumnNames.SlotUnixEpoch, BusinessErrorStrings.DoctorSchedule.CannotInsertOldTime); } if (fnName == RuleFunctionSEnum.Insert) { DateTime dt = DateTimeEpoch.ConvertSecondsEpochToDateTime(obj.SlotUnixEpoch); // removing seconds and milliseconds from Date time (only hour and minute are allowed here) // obj.AvailableDateTime = new DateTime(obj.AvailableDateTime.Year, obj.AvailableDateTime.Month, obj.AvailableDateTime.Day, obj.AvailableDateTime.Hour, obj.AvailableDateTime.Minute, 0); if (dt.Minute == 0 && dt.Second == 0 && dt.Hour == 0 ) { obj.IsWalkingQueue = true; } else { obj.IsWalkingQueue = false; } // check if time exists FilterExpression filter = new FilterExpression(); filter.AddFilter(new Filter(vDoctorSchedule.ColumnNames.SlotUnixEpoch, obj.SlotUnixEpoch)); filter.AddFilter(new Filter(vDoctorSchedule.ColumnNames.DoctorID, obj.DoctorID)); if (DataAccessObject.GetCount(filter) > 0) { errors.Add(new BusinessRuleError() { ColumnName = vDoctorSchedule.ColumnNames.SlotUnixEpoch, ColumnTitle = this.Entity.EntityColumns[vDoctorSchedule.ColumnNames.SlotUnixEpoch].Caption, ErrorDescription = BusinessErrorStrings.DoctorSchedule.TimeAllocatedBefore }); } } // delete rules if (fnName == RuleFunctionSEnum.Delete) { FilterExpression filter = new FilterExpression(vVisit.ColumnNames.DoctorScheduleID, obj.DoctorScheduleID); CheckUtils.CheckNoDependantRecordExists(vVisit.EntityName, "", filter, errors, BusinessErrorStrings.DoctorSchedule.CannotDeleteBecauseVisitExists); if (obj.SlotUnixEpoch <= DateTimeEpoch.GetUtcNowEpoch()) { errors.Add(vDoctorSchedule.ColumnNames.SlotUnixEpoch, BusinessErrorStrings.DoctorSchedule.CannotDeleteOldTimeSchedules); } } }