示例#1
0
        /// <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);
        }
示例#2
0
        /// <summary>
        ///
        /// </summary>
        internal override ReturnResultBase Execute()
        {
            ReturnResultBase result = null;

            if (LocalDataviewManager.UserSorts != null)
            {
                TaskViews.ApplySort(LocalDataviewManager.UserSorts);
            }
            else
            {
                if (!KeepUserSort)
                {
                    TaskViews.ApplySort(Task.RuntimeSorts);
                }
            }

            TaskViews.ApplyUserRangesAndLocates();

            SetTaskMode();

            if (RefreshMode == ViewRefreshMode.CurrentLocation)
            {
                InitCurrentPosition();
                if (startPosition != null)
                {
                    result = ExecuteRefreshAndKeepCurrentLocation();
                    if (result.Success)
                    {
                        LocalDataviewManager.UserGatewayLocates.Clear();
                        LocalDataviewManager.UserLocates.Clear();
                        LocalDataviewManager.UserSorts = null;
                    }

                    return(result);
                }
            }

            // clean the position cache
            LocalDataviewManager.Reset();

            // Release the ViewMain cursor and re-prepare it.
            if (TaskViews.ViewMain != null)
            {
                TaskViews.ViewMain.ReleaseCursor();
                TaskViews.ViewMain.Prepare();
            }

            result = base.Execute();

            if (result.Success)
            {
                DataviewSynchronizer.SetCurrentRecordByIdx(0);
                LocalDataviewManager.UserGatewayLocates.Clear();
                LocalDataviewManager.UserLocates.Clear();
                LocalDataviewManager.UserSorts = null;
            }

            return(result);
        }
        /// <summary>
        /// initialize the start position with current position from DataView.
        /// </summary>
        private void initStartPosition()
        {
            IRecord record = DataviewSynchronizer.GetCurrentRecord();
            DbPos   outPos;

            DataviewSynchronizer.DataviewManager.PositionCache.TryGetValue(new PositionId(record.getId()), out outPos);
            startPosition = outPos;
        }
示例#4
0
 internal override ReturnResultBase Execute()
 {
     if (InvalidateView && !UseFirstRecord)
     {
         DataviewSynchronizer.Invalidate();
     }
     return(base.Execute());
 }
        internal override ReturnResultBase Execute()
        {
            ReturnResultBase result = new ReturnResult();

            // QCR #301538. Only when GotoCreateMode execute Invalidate.
            DataviewSynchronizer.Invalidate();
            result = SetViewForCreateMode();
            return(result);
        }
示例#6
0
        /// <summary>
        /// update dataview after fetch
        /// </summary>
        protected virtual ReturnResultBase UpdateAfterFetch()
        {
            ReturnResultBase result = DataviewSynchronizer.UpdateAfterFetch(clientRecId);

            if (result.Success)
            {
                UpdateTopIndex();
            }
            return(result);
        }
示例#7
0
        /// <summary>
        /// update top index on the form
        /// </summary>
        /// <returns></returns>
        protected override ReturnResultBase UpdateAfterFetch()
        {
            ReturnResultBase result = base.UpdateAfterFetch();

            if (result.Success)
            {
                DataviewSynchronizer.UpdateFormTopIndex();
            }
            return(result);
        }
        /// <summary>
        /// override - always get a new record, and no need to refresh the position cache
        /// </summary>
        /// <returns></returns>
        protected override IRecord GetBasicRecord()
        {
            IRecord       record = DataviewSynchronizer.GetRecord(false);
            GatewayResult result = TaskViews.GetPrimaryView().Fetch(record);

            if (!result.Success)
            {
                DataviewSynchronizer.RemoveRecord(record);
                record = null;
            }
            return(record);
        }
示例#9
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        internal override ReturnResultBase Execute()
        {
            IRecord record = DataviewSynchronizer.GetCurrentRecord();

            GatewayResult result = TaskViews.GetPrimaryView().FetchCurrent(record);

            if (result.Success)
            {
                TaskViews.RecordComputer.Compute(record, false, false, false);
            }

            return(result);
        }
示例#10
0
        internal override ReturnResultBase Execute()
        {
            GatewayResult result         = new GatewayResult();
            IRecord       modifiedRecord = DataviewSynchronizer.GetModifiedRecord();

            DataviewSynchronizer.PrepareForModification();

            if (modifiedRecord != null)
            {
                result = TaskViews.ApplyModifications(modifiedRecord);
                DataviewSynchronizer.UpdateDataviewAfterModification(result.Success);
            }
            return(result);
        }
示例#11
0
        /// <summary>
        /// fetch record
        /// </summary>
        /// <returns></returns>
        protected virtual IRecord GetBasicRecord()
        {
            IRecord record = DataviewSynchronizer.GetRecord(UseFirstRecord);

            UseFirstRecord = false;
            GatewayResult result = TaskViews.GetPrimaryView().Fetch(record);

            UpdateViewEnd(result);
            if (!result.Success)
            {
                DataviewSynchronizer.RemoveRecord(record);
                record = null;
            }
            return(record);
        }
        internal override UnitComputeResult Compute(IRecord record, bool checkRange, bool recompute, bool computeInitExpressions)
        {
            var rangeData = new DataControlRangeDataCollection(rangeDataSourceId, dcValuesRangeBuilder, boundControlId);
            var dcv       = (DataviewSynchronizer.GetDcValues(rangeData));

            if (dcv == null)
            {
                // The range does not exist in the map - need to create a new DcValues object.
                dcv = dcValuesBuilder.Build();
                DataviewSynchronizer.AddDcValues(dcv, rangeData);
            }

            DataviewSynchronizer.ApplyDcValues(dcv, record, boundControlId);
            return(new UnitComputeResult());
        }
示例#13
0
        /// <summary>
        /// setup main cursor for fetch
        /// executed for all types of fetches
        /// </summary>
        /// <returns></returns>
        private GatewayResult SetupMainCursor()
        {
            GatewayResult gatewayResult;


            UpdateViewBoundaries(StartPosition);
            gatewayResult = TaskViews.OpenCursors(Reverse, StartPosition);

            //move to strategy ????
            if (gatewayResult.Success && StartingPositionType == StartingPositionType.AfterStartingRecord &&
                PositionCache.ContainsValue(startPosition))
            {
                IRecord dummyRecord = DataviewSynchronizer.CreateRecord();
                gatewayResult = TaskViews.FetchMain(dummyRecord);
            }

            return(gatewayResult);
        }
示例#14
0
 /// <summary>
 /// CTOR
 /// </summary>
 /// <param name="task"></param>
 internal LocalDataviewManager(Task task)
     : base(task)
 {
     _localDataViewCommandFactory = new LocalDataViewCommandFactory();
     _localDataViewCommandFactory.LocalDataviewManager = this;
     PositionCache        = new PositionCache();
     TaskViewsBuilder     = new TaskViewsCollectionBuilder();
     ClientIdGenerator    = new IdGenerator();
     DataviewSynchronizer = new DataviewSynchronizer()
     {
         DataviewManager = this
     };
     LocalErrorHandlerManager = new LocalErrorHandlerManager()
     {
         DataviewManager = this
     };
     UserGatewayRanges  = new List <RangeData>();
     UserRanges         = new List <UserRange>();
     UserGatewayLocates = new List <RangeData>();
     UserLocates        = new List <UserRange>();
 }
示例#15
0
        internal override ReturnResultBase Execute()
        {
            bool isEmptyDataView = ((DataView)(Task.DataView)).isEmptyDataview();

            DataviewSynchronizer.SetupDataview(Reverse);

            IRecord origRecord = DataviewSynchronizer.GetCurrentRecord();

            TaskViews.ViewMain.IgnorePositionCache = true;

            GatewayResult result = TaskViews.OpenCursors(Reverse, new DbPos(true));

            if (result.Success)
            {
                IRecord record;
                while ((record = GetBasicRecord()) != null)
                {
                    if (RecordComputer.Compute(record, true, false, false).Success)
                    {
                        //execute event OnRecordFetchEvent
                        onRecordFetch((Record)record);
                        DataviewSynchronizer.RemoveRecord(record);
                    }
                }
            }
            TaskViews.CloseMainCursor();

            TaskViews.ViewMain.IgnorePositionCache = false;

            if (origRecord != null)
            {
                DataviewSynchronizer.SetCurrentRecord(origRecord != null ? origRecord.getId() : Int32.MinValue);
                ((DataView)(Task.DataView)).takeFldValsFromCurrRec();
            }

            ((DataView)(Task.DataView)).setEmptyDataview(isEmptyDataView);

            return(result);
        }
示例#16
0
        /// <summary>
        /// !!
        /// </summary>
        /// <param name="command"></param>
        internal override ReturnResult Execute(IClientCommand command)
        {
            LocalDataViewCommandBase localDataViewCommandBase = _localDataViewCommandFactory.CreateLocalDataViewCommand(command);

            DataviewSynchronizer.InLocalDataviewCommand = true;
            ReturnResultBase returnResultBase = localDataViewCommandBase.Execute();

            DataviewSynchronizer.InLocalDataviewCommand = false;
            DataviewSynchronizer.UpdateDBViewSize();

            ReturnResult result = new ReturnResult(returnResultBase);

            if (!result.Success)
            {
                ErrorHandlingInfo errorHandlingInfo = LocalErrorHandlerManager.HandleResult(result);
                if (errorHandlingInfo != null && errorHandlingInfo.Quit)
                {
                    Task.EndTaskOnError(result, false);
                }
            }
            return(result);
        }
        /// <summary>
        /// find the start record and get its position
        /// </summary>
        /// <returns></returns>
        internal override ReturnResultBase Execute()
        {
            IRecord origRecord = DataviewSynchronizer.GetCurrentRecord();

            bool recordFound = FindMatchingRecord();

            if (recordFound)
            {
                // found a record - keep its position
                IRecord currentRecord = DataviewSynchronizer.GetCurrentRecord();
                DbPos   outPos;
                PositionCache.TryGetValue(new PositionId(currentRecord.getId()), out outPos);
                ResultStartPosition = outPos;
                LocalDataviewManager.Reset();
                DataviewSynchronizer.RemoveRecord(currentRecord);
            }
            else
            {
                DataviewSynchronizer.SetCurrentRecord(origRecord != null ? origRecord.getId() : Int32.MinValue);
            }

            return(new GatewayResult());
        }
示例#18
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        internal override ReturnResultBase Execute()
        {
            ReturnResultBase result = new GatewayResult();

            if (Task.getMode() == Constants.TASK_MODE_CREATE)
            {
                // QCR's #430059 & #310574. Execute GotoCreateMode command.
                result = SetViewForCreateMode();
            }
            else if (Task.HasFields)
            {
                if (startPosition == null)
                {
                    CalculateStartPositionFromLocateExpression();
                }

                IsPreloadView = Task.IsPreloadView;
                result        = base.Execute();
            }

            DataviewSynchronizer.ResetFirstDv();
            return(result);
        }
示例#19
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        internal override ReturnResultBase Execute()
        {
            if (Field.IsVirtual)
            {
                return(new ReturnResult());
            }

            // check the conditions which will allow the update
            if (Field.IsLinkField)
            {
                LinkView linkView = TaskViews.LinkViews[Field.getDataviewHeaderId()];
                IRecord  record   = DataviewSynchronizer.GetCurrentRecord();

                if ((linkView.DataviewHeader.Mode == LnkMode.Write && linkView.GetPosition(record) == null) ||
                    linkView.DataviewHeader.Mode == LnkMode.Create)
                {
                    return(new ReturnResult());
                }
            }

            // update not allowed - return the error
            return(new ReturnResult(MsgInterface.RT_STR_NON_MODIFIABLE));
        }
示例#20
0
        /// <summary>
        /// execute command
        /// </summary>
        internal override ReturnResultBase Execute()
        {
            DataviewSynchronizer.SetupDataview(Reverse);
            GatewayResult    gatewayResult = SetupMainCursor();
            ReturnResultBase result;
            int fetchedRecordNumber = 0;

            if (gatewayResult.Success)
            {
                for (fetchedRecordNumber = 0; !StopFetches(fetchedRecordNumber);)
                {
                    IRecord record = GetBasicRecord();
                    if (record != null && RecordComputer.Compute(record, true, false, false).Success)
                    {
                        fetchedRecordNumber++;
                    }
                }
            }
            else
            {
                UpdateViewEnd(gatewayResult);
            }

            TaskViews.CloseMainCursor();

            //If PerformUpdateAfterFetch is false , the UpdateAterFetch () should be called only if recs are fetched.
            if (gatewayResult.Success && (PerformUpdateAfterFetch || fetchedRecordNumber > 0))
            {
                result = UpdateAfterFetch();
            }
            else
            {
                result = gatewayResult;
            }
            return(result);
        }
示例#21
0
 internal override ReturnResultBase Execute()
 {
     // need to remove all records fro the gui thread, since all record indexes are updated and they are used as key in Map data
     DataviewSynchronizer.InvalidateView();
     return(base.Execute());
 }
示例#22
0
 /// <summary>
 /// set top index
 /// </summary>
 protected override void UpdateTopIndex()
 {
     DataviewSynchronizer.UpdateTopIndex(0);
 }
示例#23
0
        /// <summary>
        /// execute the view refresh command while keeping the current location.
        /// </summary>
        /// <param name="result"></param>
        /// <returns></returns>
        ReturnResultBase ExecuteRefreshAndKeepCurrentLocation()
        {
            ReturnResultBase result = new GatewayResult();

            LocalDataviewManager.Reset();

            //In order to build startposition using user locates reset the startposition.
            if (LocalDataviewManager.HasUserLocates)
            {
                startPosition = null;
            }
            // Release the ViewMain cursor and re-prepare it.
            if (TaskViews.ViewMain != null)
            {
                TaskViews.ViewMain.ReleaseCursor();
                TaskViews.ViewMain.Prepare();
            }

            //Performing UpdateAfterFetch(),  while fetching recs with startpos, may cause the task to enter in create/EmptyDataView mode, if
            //no recs are fetched. This should be avoided because if no recs are fetched we should try fetching recs with no startpos.
            PerformUpdateAfterFetch = false;

            //if the location in not on 1st line, fetch from the current location backward
            if (this.RefreshMode == ViewRefreshMode.CurrentLocation)
            {
                result = FetchBackward();
            }

            // fetch from current location forward
            if (result.Success)
            {
                result = base.Execute();
            }

            PerformUpdateAfterFetch = true;

            //look for the right record to set the dataview on
            int currentRecordId = FindCurrentRecordRow();

            // set the dataview on the right record - either the same record, if found, or the same line in te table,
            // if the previously current record was deleted
            if (currentRecordId != 0)
            {
                DataviewSynchronizer.SetCurrentRecord(currentRecordId);
            }
            else
            {
                //If no record found with CurrentLocation. Then set the RefreshMode as FirstRecord, Re-Execute ViewRefresh command.
                if (((DataView)Task.DataView).getSize() == 0)
                {
                    RefreshMode = ViewRefreshMode.FirstRecord;
                    result      = Execute();
                }
                else
                {
                    //If CurrentRecordRow is out of boundary of total records fetched, then set CurrentRecordRow on last record fetched.
                    CurrentRecordRow = CurrentRecordRow > ((DataView)Task.DataView).getSize() ? ((DataView)Task.DataView).getSize() : CurrentRecordRow;
                    DataviewSynchronizer.SetCurrentRecordByIdx(CurrentRecordRow - 1);
                }
            }

            Task.RefreshDisplay();

            return(result);
        }
示例#24
0
 internal override ReturnResultBase Execute()
 {
     DataviewSynchronizer.Invalidate();
     return(base.Execute());
 }