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);
        }
        /// <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());
        }
Esempio n. 3
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);
        }