Exemplo n.º 1
0
        public string CreateTokenAlta(string RFC, Int64 transactionID, ref string token)
        {
            string result = string.Empty;

            try
            {
                #region Build Token
                using (var securitySrv = new SrvSecurity.SeguridadClient())
                {
                    var serviceToken = securitySrv.ObtenerToken(RFC, ref transactionID);
                    var toHash       = String.Format("{0}|{1}|{2}", INTEGRATOR_ID, AltaIntegrador_ID, serviceToken);
                    token = Security.Hash(toHash);
                }
                #endregion
            }
            #region Security service exceptions
            catch (FaultException <SrvSecurity.FallaServicio> serviceFault)
            {
                using (var errorForm = new Forms.Error(TranslateFault.ToServiceError(serviceFault.Detail)))
                {
                    errorForm.ShowDialog();
                }
            }
            catch (FaultException <SrvSecurity.FallaSesion> sessionFauld)
            {
                _view.ShowSessionError(TranslateFault.ToSessionError(sessionFauld.Detail));
                result = TranslateFault.ToSessionError(sessionFauld.Detail).Description;
            }
            #endregion
            catch (Exception ex)
            {
                _view.ShowUnknownError(ex.Message);
                result = ex.Message;
            }
            return(result);
        }
Exemplo n.º 2
0
        void _view_OnCancelProcessStart(object sender, EventArgs e)
        {
            var    rfc           = _view.SourceRFC;
            long   transactionID = _random.Next();
            var    token         = string.Empty;
            String UUID          = _view.SourceUUID;
            string Error;

            Utils.Utilerias Util = new Utils.Utilerias(_view);
            Error = Util.CreateToken(rfc, transactionID, ref token);
            if (!string.IsNullOrEmpty(Error))
            {
                _view.ShowUnknownError(Error);
                return;
            }
            try
            {
                #region Token
                //using (var securitySrv = new SrvSecurity.SeguridadClient())
                //{
                //    var serviceToken = securitySrv.ObtenerToken(rfc, ref transactionID);
                //    var toHash = String.Format("{0}|{1}", INTEGRATOR_ID, serviceToken);
                //    token = Security.Hash(toHash);
                //}
                #endregion
                var cancelaTimbrado = new SrvTimbrado.TimbradoClient();
                var Result          = cancelaTimbrado.CancelaTimbrado(rfc, token, ref transactionID, UUID);
                if (Result)
                {
                    _view.ShowResult(String.Format("The UUID:{0} has canceled.", UUID));
                }
                else
                {
                    _view.ShowUnknownError(String.Format("Cannot cancel de UUID: {0}", UUID));
                }
            }
            #region Security service exceptions
            catch (FaultException <SrvSecurity.FallaServicio> serviceFault)
            {
                using (var errorForm = new Forms.Error(TranslateFault.ToServiceError(serviceFault.Detail)))
                {
                    errorForm.ShowDialog();
                }
            }
            catch (FaultException <SrvSecurity.FallaSesion> sessionFauld)
            {
                _view.ShowSessionError(TranslateFault.ToSessionError(sessionFauld.Detail));
            }
            #endregion
            #region Timbrado service exceptions
            catch (FaultException <SrvTimbrado.FallaServicio> serviceFault)
            {
                _view.ShowUnknownError(serviceFault.Detail.Descripcion);
                //using (var errorForm = new Forms.Error(TranslateFault.ToServiceError(serviceFault.Detail)))
                //{
                //    errorForm.ShowDialog();
                //}
            }
            catch (FaultException <SrvTimbrado.FallaSesion> sessionFauld)
            {
                _view.ShowUnknownError(sessionFauld.Detail.Descripcion);
                //_view.ShowSessionError(TranslateFault.ToSessionError(sessionFauld.Detail));
            }
            #endregion
            catch (Exception ex)
            {
                _view.ShowUnknownError(ex.Message);
            }
        }
        void _view_onObtenerTimbrado(object sender, EventArgs e)
        {
            string rfc              = _view.RFC;
            string UUID             = _view.UUID;
            Int64  transactionID    = _view.transactionID;
            Int64  transactionNueva = _random.Next();
            string token            = string.Empty;
            string Error;

            Utils.Utilerias Util = new Utils.Utilerias(_view);
            Error = Util.CreateToken(rfc, transactionID, ref token);
            if (!string.IsNullOrEmpty(Error))
            {
                _view.ShowUnknownError(Error);
                return;
            }
            try
            {
                #region Token
                //using (var securitySrv = new SrvSecurity.SeguridadClient())
                //{
                //    var serviceToken = securitySrv.ObtenerToken(rfc, ref transactionID);
                //    var toHash = String.Format("{0}|{1}", INTEGRATOR_ID, serviceToken);
                //    token = Security.Hash(toHash);
                //}
                #endregion
                using (var srvTimbrado = new SrvTimbrado.TimbradoClient())
                {
                    var respuesta = srvTimbrado.ObtenerTimbrado(rfc, token, ref transactionNueva, transactionID, UUID);
                    _view.stringTimbrado = respuesta.DatosXML;
                }
            }
            #region Security service exceptions
            catch (FaultException <SrvSecurity.FallaServicio> serviceFault)
            {
                using (var errorForm = new Forms.Error(TranslateFault.ToServiceError(serviceFault.Detail)))
                {
                    errorForm.ShowDialog();
                }
            }
            catch (FaultException <SrvSecurity.FallaSesion> sessionFauld)
            {
                _view.ShowSessionError(TranslateFault.ToSessionError(sessionFauld.Detail));
            }
            #endregion
            #region Timbrado service exceptions
            catch (FaultException <SrvTimbrado.FallaServicio> serviceFault)
            {
                _view.ShowUnknownError(serviceFault.Detail.Descripcion);
                //using (var errorForm = new Forms.Error(TranslateFault.ToServiceError(serviceFault.Detail)))
                //{
                //    errorForm.ShowDialog();
                //}
            }
            catch (FaultException <SrvTimbrado.FallaSesion> sessionFauld)
            {
                _view.ShowUnknownError(sessionFauld.Detail.Descripcion);
                //_view.ShowSessionError(TranslateFault.ToSessionError(sessionFauld.Detail));
            }
            #endregion
            catch (Exception ex)
            {
                _view.ShowUnknownError(ex.Message);
            }
        }