public void InitView()
        {
            if (!string.IsNullOrEmpty(_model.Invoice.Cpf) && DocumentUtility.IsCpfValid(_model.Invoice.Cpf))
            {
                _model.User = new User {
                    Cpf = _model.Invoice.Cpf
                };

                if (OnStepCompletedEventHandler != null)
                {
                    OnStepCompletedEventHandler();
                }
            }

            _view.InitInstruction = AppConfigUtility.sMessageInformCpf;
            _view.SetFocus();
            _view.SetEnabled(true);

            if (OnStepStartTimeoutEventHandler != null)
            {
                TimeoutHandler = new Timer {
                    Interval = AppConfigUtility.iNoInteractionTimeOut
                };

                OnStepStartTimeoutEventHandler();
            }
        }
        private Invoice GetInvoiceFromQrCode(string sQrCode)
        {
            var oInvoice = new Invoice();
            var oKeys    = ParseQrCodeInput(sQrCode);

            if (oKeys == null)
            {
                return(null);
            }
            if (!oKeys.ContainsKey("chNFe"))
            {
                return(null);
            }
            if (!oKeys.ContainsKey("nVersao"))
            {
                return(null);
            }
            if (!oKeys.ContainsKey("tpAmb"))
            {
                return(null);
            }
            if (!oKeys.ContainsKey("dhEmi"))
            {
                return(null);
            }
            if (!oKeys.ContainsKey("vNF"))
            {
                return(null);
            }
            if (!oKeys.ContainsKey("vICMS"))
            {
                return(null);
            }
            if (!oKeys.ContainsKey("digVal"))
            {
                return(null);
            }
            if (!oKeys.ContainsKey("cIdToken"))
            {
                return(null);
            }
            if (!oKeys.ContainsKey("cHashQRCode"))
            {
                return(null);
            }

            oInvoice.QrCode     = oKeys["QrCode"];
            oInvoice.HashQrCode = oKeys["cHashQRCode"];
            oInvoice.Cpf        = oKeys.ContainsKey("cDest") ? DocumentUtility.IsCpfValid(oKeys["cDest"]) ? oKeys["cDest"] : string.Empty : string.Empty;
            oInvoice.Cnpj       = oKeys["chNFe"].Substring(6, 14);
            oInvoice.Value      = Convert.ToDecimal(oKeys["vNF"].Replace('.', ','));
            oInvoice.Icms       = Convert.ToDecimal(oKeys["vICMS"].Replace('.', ','));

            return(oInvoice);
        }
        public void HandleCpfInput(string sCpf)
        {
            try
            {
                if (!sCpf.Length.Equals(11))
                {
                    return;
                }

                _view.SetEnabled(false);

                if (DocumentUtility.IsCpfValid(sCpf))
                {
                    _model.User = new User {
                        Cpf = sCpf
                    };

                    if (OnStepCompletedEventHandler != null)
                    {
                        OnStepCompletedEventHandler();
                    }
                }
                else
                {
                    throw new AlertMessageException(AppConfigUtility.sMessageInvalidCpf);
                }
            }
            catch (AlertMessageException ex)
            {
                if (OnStepWarningEventHandler != null)
                {
                    OnStepWarningEventHandler(ex.Message);
                }
            }
            catch (Exception ex)
            {
                LogUtility.Log(LogUtility.LogType.SystemError, MethodBase.GetCurrentMethod().Name, ex.Message);

                if (OnStepErrorEventHandler != null)
                {
                    OnStepErrorEventHandler(AppConfigUtility.sMessageGenericInvoiceError);
                }
            }
        }