/// <summary> /// check field's range /// </summary> /// <returns></returns> internal UnitComputeResult CheckRange() { UnitComputeResult result = new UnitComputeResult(); Boundary boundary = Field.Range; if (boundary != null) { boundary.compute(false); if (!boundary.checkRange(Field.ValueFromCurrentRecord, Field.IsNullFromCurrentRecord)) { result.ErrorCode = UnitComputeErrorCode.RangeFailed; } } // check the user ranges if (result.Success && (Field.IsVirtual || Field.IsLink)) { List <UserRange> userRanges = DataviewSynchronizer.DataviewManager.UserRanges; if (userRanges != null) { // go over all user ranges, check those with the right field id foreach (UserRange userRangeData in userRanges) { if (userRangeData.veeIdx - 1 == Field.Id) { result = CheckUserRange(Field, userRangeData); } } } } return(result); }
/// <summary> /// /// </summary> /// <param name="fieldView"></param> /// <param name="userRange"></param> /// <returns></returns> private UnitComputeResult CheckUserRange(IFieldView fieldView, UserRange userRange) { UnitComputeResult result = new UnitComputeResult(); string fieldValue = fieldView.ValueFromCurrentRecord.Trim(); switch (fieldView.StorageAttribute) { case StorageAttribute.NUMERIC: case StorageAttribute.DATE: case StorageAttribute.TIME: { int fieldValueInt = new NUM_TYPE(fieldValue).NUM_2_LONG(); // check the min value if (!userRange.nullMin && !userRange.discardMin) { int min = new NUM_TYPE(userRange.min).NUM_2_LONG(); if (fieldValueInt < min) { result.ErrorCode = UnitComputeErrorCode.RangeFailed; } } // check the max value if (result.Success && !userRange.nullMax && !userRange.discardMax) { int max = new NUM_TYPE(userRange.max).NUM_2_LONG(); if (fieldValueInt > max) { result.ErrorCode = UnitComputeErrorCode.RangeFailed; } } } break; default: { // check the min value if (!userRange.nullMin && !userRange.discardMin) { if (String.Compare(fieldValue, (string)userRange.min, StringComparison.Ordinal) < 0) { result.ErrorCode = UnitComputeErrorCode.RangeFailed; } } // check the max value if (result.Success && !userRange.nullMax && !userRange.discardMax) { if (String.Compare(fieldValue, (string)userRange.max, StringComparison.Ordinal) > 0) { result.ErrorCode = UnitComputeErrorCode.RangeFailed; } } } break; } return(result); }
/// <summary> /// /// </summary> /// <param name="record"></param> /// <param name="checkRange"> true if we need to check range</param> /// <param name="recompute"> true if need to recompute</param> /// <param name="computeInitExpressions"> true if we need to compute reals</param> /// <returns></returns> internal override UnitComputeResult Compute(IRecord record, bool checkRange, bool recompute, bool computeInitExpressions) { UnitComputeResult result = new UnitComputeResult(); // performance improvement QCR #178301 // Compute is expensive operation on mobile platforms, need to prevent unnesessary compute // value of real fields are already fetched from the database, so no need to compute them in most of the cases // computeInitExpressions will be true when we do need to compute them, like in create line if (computeInitExpressions || ShouldComputeOnFetch) { Field.Compute(false); } else { Field.TakeValFromRec(); } //If toolkit locates Or User locates present then check locates to get correct start position. if (CheckLocate || ((Field.IsVirtual || Field.IsLink) && DataviewSynchronizer.DataviewManager.UserLocates.Count > 0 && DataviewSynchronizer.DataviewManager.TaskViews.UseUserLocates)) { result = CheckLocates(); } if (result.Success && checkRange && Field.ShouldCheckRangeInCompute) { result = CheckRange(); } return(result); }
/// <summary> /// compute link /// </summary> /// <param name="record"></param> /// <returns></returns> internal override UnitComputeResult Compute(IRecord record, bool checkRange, bool recompute, bool computeInitExpressions) { bool linkSuccess = false; UnitComputeResult unitComputeResult = new UnitComputeResult(); if (View.DataviewHeader.Mode != LnkMode.Create && View.ShouldPerformLink) { linkSuccess = FetchLinkedRecord(record, recompute); } if (!linkSuccess) { DataviewSynchronizer.InitLinkFields(View.DataviewHeader, record); } if (checkRange) { unitComputeResult = CheckRangeLinkFields(record); } DataviewSynchronizer.SetLinkReturnValue(View.DataviewHeader, record, linkSuccess, recompute); return(unitComputeResult); }
/// <summary> /// check range on the fields /// </summary> /// <param name="record"></param> /// <returns></returns> private UnitComputeResult CheckRangeLinkFields(IRecord record) { UnitComputeResult unitComputeResult = new UnitComputeResult(); for (int i = 0; i < computeUnitStrategies.Count && unitComputeResult.Success; i++) { unitComputeResult = (computeUnitStrategies[i].CheckRange()); } return(unitComputeResult); }
/// <summary> /// computes fields checking locate values /// </summary> /// <param name="record"></param> /// <returns></returns> private UnitComputeResult ComputeFieldsAndCheckLocate(IRecord record, bool recompute) { UnitComputeResult unitComputeResult = new UnitComputeResult(); for (int i = 0; i < computeUnitStrategies.Count && unitComputeResult.Success; i++) { unitComputeResult = (computeUnitStrategies[i].Compute(record, false, recompute, false)); } return(unitComputeResult); }
/// <summary> /// check field's locates /// </summary> /// <returns></returns> internal UnitComputeResult CheckLocates() { UnitComputeResult result = new UnitComputeResult(); Boundary boundary = Field.Locate; // If toolkit locates and user locates both are present, then after view refresh user locates should be used and not toolkit locate. // DataviewSynchronizer.DataviewManager.TaskViews.UseUserLocates flag is set in view refresh command and once start position is calculated // then reset this flag. if (DataviewSynchronizer.DataviewManager.TaskViews.UseUserLocates) { // check the user ranges if (result.Success && (Field.IsVirtual || Field.IsLink)) { List <UserRange> userLocates = DataviewSynchronizer.DataviewManager.UserLocates; if (userLocates != null) { // go over all user ranges, check those with the right field id foreach (UserRange userRangeData in userLocates) { if (userRangeData.veeIdx - 1 == Field.Id) { result = CheckUserRange(Field, userRangeData); if (!result.Success) { result.ErrorCode = UnitComputeErrorCode.LocateFailed; } } } } } } else { if (boundary != null) { // Compute of locate should search for the range of data only if it done on the main datasource and not for link. // Locate on link is actually a range. boundary.compute(!Field.IsLink); if (!Field.Locate.checkRange(Field.ValueFromCurrentRecord, Field.IsNullFromCurrentRecord)) { result.ErrorCode = UnitComputeErrorCode.LocateFailed; } } } return(result); }
/// <summary> /// /// </summary> /// <param name="record"></param> /// <param name="checkRange"></param> /// <returns></returns> internal override UnitComputeResult Compute(IRecord record, bool checkRange, bool recompute, bool computeInitExpressions) { UnitComputeResult result = new UnitComputeResult(); if (!checkRange) { return(result); } if (!expression.DiscardCndRangeResult()) { GuiExpressionEvaluator.ExpVal expVal = expression.evaluate(StorageAttribute.BOOLEAN); if (!expVal.BoolVal) { result.ErrorCode = UnitComputeErrorCode.RangeFailed; } } return(result); }
/// <summary> /// /// </summary> /// <param name="record"></param> /// <param name="checkRange"></param> /// <returns></returns> internal override UnitComputeResult Compute(IRecord record, bool checkRange, bool recompute, bool computeInitExpressions) { UnitComputeResult result = new UnitComputeResult(); string fieldValue = fieldView.ValueFromCurrentRecord; switch (fieldView.StorageAttribute) { case StorageAttribute.NUMERIC: { NUM_TYPE fetchedValue = new NUM_TYPE(fieldValue); NUM_TYPE minimumValue = new NUM_TYPE(DisplayConvertor.Instance.toNum((string)minValue, new PIC(fieldView.Picture, StorageAttribute.NUMERIC, 0), 0)); if (NUM_TYPE.num_cmp(fetchedValue, minimumValue) < 0) { result.ErrorCode = UnitComputeErrorCode.LocateFailed; } } break; case StorageAttribute.UNICODE: case StorageAttribute.ALPHA: { //QCR # 444514 : Check whether given Incremental Locate String is in between min and max of fetched value. // Locate gets successful when fetched record is greater than or equal to search Incremental Locate String value. string minimumValue = minValue.ToString().PadRight(fieldView.Length, char.MinValue); string maximumValue = minValue.ToString().PadRight(fieldView.Length, char.MaxValue); if (String.Compare(fieldValue, (string)minimumValue, StringComparison.Ordinal) < 0) { result.ErrorCode = UnitComputeErrorCode.LocateFailed; } else if (String.Compare(fieldValue, (string)maximumValue, StringComparison.Ordinal) > 0) { result.ErrorCode = UnitComputeErrorCode.LocateFailed; } } break; } return(result); }
/// <summary> /// compute record /// </summary> /// <param name="useFirstRecord"></param> /// <returns></returns> internal UnitComputeResult Compute(IRecord record, bool checkRange, bool recompute, bool computeInitExpressions) { UnitComputeResult result = new UnitComputeResult(); foreach (var item in orderedComputeUnitStrategies) { result = item.Compute(record, checkRange, recompute, computeInitExpressions); if (!result.Success) { break; } } DataviewSynchronizer.SetComputed(record); if (!result.Success) { DataviewSynchronizer.RemoveRecord(record); } return(result); }
/// <summary> /// fetch record from the link /// </summary> /// <param name="record"></param> /// <returns></returns> private bool FetchLinkedRecord(IRecord record, bool recompute) { GatewayResult result = new GatewayResult(); UnitComputeResult unitComputeResult = new UnitComputeResult(); result = View.OpenCursor(false, new gatewaytypes.DbPos(true), BoudariesFlags.Locate); while (result.Success) { result = View.Fetch(record); if (result.Success) { unitComputeResult = ComputeFieldsAndCheckLocate(record, recompute); if (unitComputeResult.Success) //match found { break; } } } View.CloseCursor(); return(result.Success); }