Ejemplo n.º 1
0
        /// <summary>
        /// update dataview after fetch of the record
        /// </summary>
        /// <param name="curRecId"></param>
        internal ReturnResultBase UpdateAfterFetch(int curRecId)
        {
            UpdateIncludes();

            if (Dataview.getSize() == 0)
            {
                if (Task.getMode() == Constants.TASK_MODE_CREATE)
                {
                    Dataview.addRecord(false, false);
                }
                else
                {
                    Dataview.addFirstRecord();
                }
            }

            if (Form != null)
            {
                Form.SetTableItemsCount(false);
            }

            SetCurrentRecord(curRecId);
            ReturnResultBase result = UpdateEmptyDataview();

            ComputeRecord();
            Task.SetRefreshType(Constants.TASK_REFRESH_TABLE);
            return(result);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// execute the command by pass requests to the server
        /// </summary>
        /// <param name="command"></param>
        internal override ReturnResult Execute(IClientCommand command)
        {
            base.Execute(command);

            RemoteDataViewCommandBase remoteDataViewCommandBase = _remoteDataViewCommandFactory.CreateDataViewCommand((ClientOriginatedCommand)command);
            ReturnResultBase          gatewayResult             = remoteDataViewCommandBase.Execute();

            return(new ReturnResult(gatewayResult));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// update dataview after fetch
        /// </summary>
        protected virtual ReturnResultBase UpdateAfterFetch()
        {
            ReturnResultBase result = DataviewSynchronizer.UpdateAfterFetch(clientRecId);

            if (result.Success)
            {
                UpdateTopIndex();
            }
            return(result);
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Calculate start position for Locate Next operation.
        /// </summary>
        private void  calculateNextStartPosition()
        {
            LocateNextLocalDataCommand locateNextCommand = new LocateNextLocalDataCommand(Command);

            locateNextCommand.DataviewManager = DataviewManager;
            locateNextCommand.LocalManager    = LocalManager;
            ReturnResultBase result = locateNextCommand.Execute();

            if (PositionCache.Count > 0)
            {
                LocalDataviewManager.LocalErrorHandlerManager.HandleResult(result);
            }

            startPosition = locateNextCommand.ResultStartPosition;
        }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="gatewayResult"></param>
        public ErrorHandlingInfo GetErrorInfo(ReturnResultBase returnResultBase)
        {
            ErrorHandlingInfo errorHandlingInfo = null;


            if (returnResultBase.InnerResult is GatewayResult)
            {
                GatewayErrorHandlingInfoTable.TryGetValue((GatewayErrorCode)returnResultBase.InnerResult.GetErrorId(), out errorHandlingInfo);
            }
            else if (returnResultBase.InnerResult is ReturnResult)
            {
                RtErrorHandlingInfoTable.TryGetValue((string)returnResultBase.InnerResult.GetErrorId(), out errorHandlingInfo);
            }
            else if (returnResultBase.InnerResult == null)
            {
                RtErrorHandlingInfoTable.TryGetValue((string)returnResultBase.GetErrorId(), out errorHandlingInfo);
            }
            else
            {
                Debug.Assert(false);
            }

            return(errorHandlingInfo);
        }
Ejemplo n.º 9
0
        ///// <summary>
        ///// return true if this error need to be handled
        ///// </summary>
        ///// <param name="returnResultBase"></param>
        ///// <returns></returns>
        //private bool ErroNeedToBeHandled(ReturnResultBase returnResultBase)
        //{
        //   Boolean isErroNeedToBeHandled = false;

        //   ReturnResultBase innerResult = returnResultBase.InnerResult;

        //   if (innerResult is GatewayResult)
        //   {
        //      GatewayResult GatewayResult = innerResult as GatewayResult;
        //      // macro ERROR_TO_BE_HANDLED
        //      isErroNeedToBeHandled = ((GatewayErrorCode)innerResult.GetErrorId() < GatewayErrorCode.InErrorZone);
        //   }
        //   else if (innerResult is ReturnResult)
        //   {
        //      ReturnResult ReturnResult = innerResult as ReturnResult;
        //      isErroNeedToBeHandled = (((String)innerResult.GetErrorId()).Equals(MsgInterface.FMERROR_STR_DB_PROT)) ||
        //         (((String)innerResult.GetErrorId()).Equals(MsgInterface.FMERROR_STR_NO_DATABASE)) ||
        //         (((String)innerResult.GetErrorId()).Equals(MsgInterface.FMERROR_STR_EXTUSE_MULU_CNFLCT)) ||
        //         (((String)innerResult.GetErrorId()).Equals(MsgInterface.FMERROR_STR_DB_GW_VERSION_CNFLCT)) ||
        //         (((String)innerResult.GetErrorId()).Equals(MsgInterface.FMERROR_STR_NO_HDLS)) ||
        //         (((String)innerResult.GetErrorId()).Equals(MsgInterface.FMERROR_STR_TRANS_OPEN_FAILED) ||
        //         (((String)innerResult.GetErrorId()).Equals(MsgInterface.RT_STR_NON_MODIFIABLE))
        //         );
        //   }
        //   return isErroNeedToBeHandled;
        //}
        /// <summary>
        ///
        /// </summary>
        /// <param name="returnResultBase"></param>
        internal ErrorHandlingInfo HandleResult(ReturnResultBase returnResultBase)
        {
            VerifyDisplay displayType = VerifyDisplay.Box;

            ErrorHandlingInfo errorHandlingInfo = GetErrorInfo(returnResultBase);

            if (errorHandlingInfo != null)
            {
                // The "if ErroNeedToBeHandled" code need to be un comment while implement the error handling (rtry_handle_error)
                // mg_rtry.cpp "ERROR_TO_BE_HANDLED"
                //if (ErroNeedToBeHandled(returnResultBase))

                // take the display type
                displayType = errorHandlingInfo.DisplayType;
                // if the error is quit then we display it to message box otherwise display to status bar(the default)
                if (errorHandlingInfo.Quit)
                {
                    displayType = VerifyDisplay.Box;
                }

                switch (displayType)
                {
                case VerifyDisplay.Box:
                    DataviewManager.Task.ShowError(returnResultBase.ErrorDescription);
                    break;

                case VerifyDisplay.Status:
                    DataviewManager.Task.DisplayMessageToStatusBar(returnResultBase.ErrorDescription);
                    break;

                default:
                    break;
                }
            }
            return(errorHandlingInfo);
        }