Esempio n. 1
0
 public static void CloseCheck(this IFiscalRegistratorProvider fptr, int typeClose)
 {
     if (fptr.PutTypeClose(typeClose) < 0)
     {
         fptr.CheckError();
     }
     if (fptr.CloseCheck() < 0)
     {
         fptr.CheckError();
     }
 }
Esempio n. 2
0
        internal void Print_OnClick(object sender, EventArgs e)
        {
            _enteredSumEditText.Enabled = false;

            var checkParameters = new Event_EventFiskalProperties
            {
                Id = DbRef.CreateInstance($"Document_{nameof(Event_EventFiskalProperties)}"
                                          , Guid.NewGuid()),
                Ref  = DbRef.FromString(_eventId),
                User = Settings.UserDetailedInfo.Id
            };

            Dialog.ShowProgressDialog(Translator.Translate("please_wait"), true);

            TaskFactory.RunTaskWithTimeout(() =>
            {
                var checkError = false;

                try
                {
                    PrintCheck();

                    if (_fptr.CloseCheck() < 0)
                    {
                        _fptr.CheckError();
                    }

                    checkParameters.Date = DateTime.Now;

                    DBHelper.SaveEntity(checkParameters, false);
                }
                catch (FPTRException exception)
                {
                    Utils.TraceMessage($"Error code {exception.Result} {exception.Message}");
                    checkError = true;
                    Toast.MakeToast(Translator.Translate(exception.Message));
                }
                catch (Exception exception)
                {
                    Utils.TraceMessage($"{exception.Message}{Environment.NewLine}" +
                                       $"Type {exception.GetType()}");
                }

                Utils.TraceMessage($"Check Error: {checkError}");

                if (!checkError)
                {
                    SaveFptrParameters(checkParameters);
                    BusinessProcess.GlobalVariables[Parameters.IdCurrentEventId] = _eventId;

                    Utils.TraceMessage($"GoTo {nameof(COCScreen)}");
                    Application.InvokeOnMainThread(() =>
                    {
                        Navigation.ModalMove(nameof(COCScreen), new Dictionary <string, object>
                        {
                            { Parameters.IdCurrentEventId, _eventId },
                            { Parameters.IdIsReadonly, _readonly },
                            { Parameters.IdWasEventStarted, _wasStarted }
                        });
                    });
                }
                else
                {
                    try
                    {
                        DBHelper.DeleteByRef(checkParameters.Id, false);
                        _fptr.CancelCheck();
                    }
                    catch (FPTRException exception)
                    {
                        Toast.MakeToast(Translator.Translate(exception.Message));
                    }
                    finally
                    {
                        if (_choosedPaymentType == 0)
                        {
                            Application.InvokeOnMainThread(()
                                                           => _enteredSumEditText.Enabled = true);
                        }
                    }
                }
            }, FptrAction.PrintingTimeOut, result =>
            {
                if (result.Finished)
                {
                    Dialog.HideProgressDialog();
                    return;
                }

                Dialog.HideProgressDialog();
                Toast.MakeToast(Translator.Translate("сonnection_error"));
            });
        }