Exemplo n.º 1
0
        private void OnReprint(Window window)
        {
            if (string.IsNullOrEmpty(RegistrationNumber))
            {
                return;
            }

            IsLoading = true;

            Document document = FindDocumentLocally();

            if (document != null)
            {
                Print(document);
                window.Close();
                return;
            }

            GetInstance <IConnectClient>().CallAsync(ConnectHelper.GetConnectKeys(), client =>
            {
                return(client.Service.Find(RegistrationNumber.ToUpper().Replace(" ", string.Empty), DocumentType.Tachograph | DocumentType.Undownloadability | DocumentType.LetterForDecommissioning));
            },
                                                     result =>
            {
                if (result.Data == null)
                {
                    MessageBoxHelper.ShowError(Resources.ERR_UNABLE_FIND_ANY_MATCHES, Window);
                    return;
                }

                Print((Document)result.Data);
            },
                                                     exception =>
            {
                MessageBoxHelper.ShowError(Resources.TXT_ONE_OR_MORE_ERRORS, new object[] { ExceptionPolicy.HandleException(ContainerBootstrapper.Container, exception) }, window);
            },
                                                     () =>
            {
                window.Close();
            });
        }