Exemplo n.º 1
0
        internal void ConnectToFptr_OnClick(object sender, EventArgs e)
        {
            if (!Settings.EnableFPTR)
            {
                Toast.MakeToast(Translator.Translate("fr_disable"));
                return;
            }
            if (!DBHelper.CheckRole(nameof(WebactionsEnum.MobileFPRAccess)))
            {
                Toast.MakeToast(Translator.Translate("fr_role_disable"));
                return;
            }
            if (_readonlyForIos)
            {
                Toast.MakeToast(Translator.Translate("Функциональность не поддерживается на iOS"));
                return;
            }

            Dialog.ShowProgressDialog(Translator.Translate("please_wait"), true);
            TaskFactory.RunTaskWithTimeout(() =>
            {
                try
                {
                    if (_fptr.CurrentStatus >= 0)
                    {
                        _fptr.Beep();
                        ChangeLayoutsAsync();
                    }
                    else
                    {
                        _fptr.PutDeviceSettings(_fptr.Settings);
                        _fptr.PutDeviceEnabled(true);
                        ChangeLayoutsAsync();
                        Utils.TraceMessage($"{nameof(_fptr.CurrentStatus)}: {_fptr.CurrentStatus}");
                    }
                }
                catch (FPTRException fptrException)
                {
                    Utils.TraceMessage($"ExceptionMessage: {fptrException.Message}" +
                                       $" ResultCode: {fptrException.Result}");

                    Application.InvokeOnMainThread(() => Toast.MakeToast(fptrException.Message));
                }
            }, FptrAction.DefaultTimeOut, result =>
            {
                if (result.Finished)
                {
                    Dialog.HideProgressDialog();
                    return;
                }
                Utils.TraceMessage($"Change status to offline");
                Application.InvokeOnMainThread(() => ChangeLayoutStatus(-1));

                Dialog.HideProgressDialog();

                Application.InvokeOnMainThread(()
                                               => Toast.MakeToast(Translator.Translate("сonnection_error")));
            });
        }
Exemplo n.º 2
0
        internal void PrintZ_OnClick(object sender, EventArgs e)
        {
            if (!Settings.EnableFPTR)
            {
                Toast.MakeToast(Translator.Translate("fr_disable"));
                return;
            }
            if (!DBHelper.CheckRole(nameof(WebactionsEnum.MobileFPRAccess)))
            {
                Toast.MakeToast(Translator.Translate("fr_role_disable"));
                return;
            }
            if (_readonlyForIos)
            {
                Toast.MakeToast(Translator.Translate("Функциональность не поддерживается на iOS"));
                return;
            }


            Dialog.Ask(Translator.Translate("printZ_caption_ask"), (o, args) =>
            {
                if (args.Result == Dialog.Result.No)
                {
                    return;
                }

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

                TaskFactory.RunTaskWithTimeout(() =>
                {
                    try
                    {
                        _fptr.PrintZ();
                    }
                    catch (FPTRException exception)
                    {
                        Toast.MakeToast(exception.Message);
                    }
                }, FptrAction.PrintingTimeOut, result =>
                {
                    if (result.Finished)
                    {
                        Dialog.HideProgressDialog();
                        return;
                    }

                    Application.InvokeOnMainThread(() => ChangeLayoutStatus(-1));

                    Dialog.HideProgressDialog();

                    Application.InvokeOnMainThread(()
                                                   => Toast.MakeToast(Translator.Translate("сonnection_error")));
                });
            });
        }
Exemplo n.º 3
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"));
            });
        }
Exemplo n.º 4
0
 public override void OnDraw()
 {
     base.OnDraw();
     Dialog.HideProgressDialog();
 }
Exemplo n.º 5
0
 // TopInfo parts
 internal void TopInfo_LeftButton_OnClick(object sender, EventArgs e)
 {
     Toast.MakeToast(Translator.Translate("start_sync"));
     Dialog.HideProgressDialog();
     DBHelper.SyncAsync();
 }
Exemplo n.º 6
0
 public override void OnShow()
 {
     base.OnShow();
     GpsTracking.StartAsync();
     Dialog.HideProgressDialog();
 }