/// <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> /// 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); }