コード例 #1
0
        protected override void OnInquiryActionComplete(InquiryActionResult <TEntity> result)
        {
            switch (result.Result)
            {
            case InquiryActionResultType.RequestedNew:
                this.OnAddNew();
                break;

            default:
                base.OnInquiryActionComplete(result);
                break;
            }
        }
コード例 #2
0
ファイル: LoginViewModel.cs プロジェクト: evan-zang/Chronosv2
        protected override void OnInquiryActionComplete(InquiryActionResult <UserLogin> result)
        {
            if (result.Result == InquiryActionResultType.DataFetched)
            {
                Channel <AuthenticationInfo> .Public.OnNext(
                    new AuthenticationInfo
                {
                    Action = AuthenticationAction.LoggedIn,
                    UserId = this.UserId
                }, true);

                ServiceLocator.GetService <IVirtualDesktopManager>().CloseDialog();
            }
            else if (result.Result == InquiryActionResultType.DataNotFound)
            {
                this.NotificationMessage = "Username and password do not match.";

                this.ViewMode = ViewModeType.Default;
            }
        }
コード例 #3
0
        protected virtual void OnInquiryActionComplete(InquiryActionResult <TEntity> result)
        {
            switch (result.Result)
            {
            case InquiryActionResultType.DataNotFound:
                this.OriginalEntity = null;

                this.ResetDataModel();

                this.ViewMode = ViewModeType.ViewOnly;
                break;

            case InquiryActionResultType.RequestedNew:
                throw new InvalidOperationException("Requested New is not valid on this type of ViewModel");

            case InquiryActionResultType.DataFetched:
                this.ResetDataModel(result.Data);

                this.OriginalEntity = this.entity;
                this.ViewMode       = ViewModeType.ViewOnly;
                break;
            }
        }
コード例 #4
0
ファイル: LoginViewModel.cs プロジェクト: evan-zang/Chronosv2
 protected override void OnInquiryAction(InquiryActionResult <UserLogin> result)
 {
     result.Data   = this.Entity;
     result.Result = InquiryActionResultType.DataFetched;
 }
コード例 #5
0
 protected override void OnInquiryAction(InquiryActionResult <EmpresaEntity> result)
 {
 }
コード例 #6
0
 protected abstract void OnInquiryAction(InquiryActionResult <TEntity> result);
コード例 #7
0
        protected void OnInquiryData()
        {
            InquiryActionResult <TEntity> result = new InquiryActionResult <TEntity>
            {
                Result = InquiryActionResultType.DataNotFound
            };

            this.ViewMode      = ViewModeType.Busy;
            this.StatusMessage = "Obteniendo datos, espere por favor ...";

            Task task = Task.Factory.StartNew
                        (
                (o) =>
            {
                Logger.Debug("Obteniendo datos '{0}'", this.Entity.ToString());

                this.OnInquiryAction(result);
            }, result
                        );

            task.ContinueWith
            (
                (t) =>
            {
                Logger.Debug("Error al obtener datos '{0}'", t.Exception.InnerException.ToString());

                this.OnInquiryActionFailed();

                Exception exception = null;
                this.OriginalEntity = null;

                if (t.Exception.InnerException != null)
                {
                    exception = t.Exception.InnerException;
                }
                else
                {
                    exception = t.Exception;
                }

                this.NotificationMessage = exception.Message;
            },
                CancellationToken.None,
                TaskContinuationOptions.OnlyOnFaulted | TaskContinuationOptions.AttachedToParent,
                TaskScheduler.FromCurrentSynchronizationContext()
            );

            task.ContinueWith
            (
                _ =>
            {
                Logger.Debug("Datos obtenidos correctamente '{0}'", this.Entity.ToString());

                this.StatusMessage = null;
                this.OnInquiryActionComplete(result);
            },
                CancellationToken.None,
                TaskContinuationOptions.OnlyOnRanToCompletion | TaskContinuationOptions.AttachedToParent,
                TaskScheduler.FromCurrentSynchronizationContext()
            );
        }