/// <summary> /// Gerar a nota fiscal eletronica no painel de NFe /// </summary> /// <param name="movimento"></param> /// <returns></returns> public bool GerarNFe(Movimento movimento) { try { using (var ctx = new BalcaoContext()) { var xml = GerarXml(movimento); var nfeEstadual = new NFeEstadual() { ChaveAcesso = movimento.ChaveAcessoNf, IdMovimento = movimento.IdMovimento, StatusXml = TypeStatusEnvioNFe.XmlGerado, XmlNfe = xml }; if (ctx.NFeEstadualDao.Save(nfeEstadual)) { return(true); } } return(false); } catch (Exception ex) { XMessageIts.ExceptionMessageDetails(ex, "Erro ao gerar NFe!"); return(false); } }
/// <summary> /// Assinar um documento eletronico. Ainda em dev. /// Ref.: https://www.profissionaisti.com.br/2010/07/assinando-digitalmente-um-xml-usando-c/ /// </summary> /// <param name="nfe"></param> /// <returns></returns> public bool AssinarNFe(NFeEstadual nfe) { X509Certificate2Collection certificados; //certificados instalados no store da maquina X509Store store = new X509Store(StoreName.My, StoreLocation.LocalMachine); //abre o store store.Open(OpenFlags.ReadOnly); //lista dos certificados certificados = store.Certificates; foreach (X509Certificate2 cert in certificados) { if (cert.HasPrivateKey && cert.NotAfter > DateTime.Now && cert.NotBefore < DateTime.Now) { } } store.Close(); return(true); }