Ejemplo n.º 1
0
        // TODO: credentials per taxpayer
        static Mictlanix.CFDv32.Comprobante ServisimStamp(FiscalDocument item)
        {
            var cfd = SignCFD (item);
            var cli = new ServisimClient (WebConfig.ServisimUser,
                WebConfig.ServisimPasswd, WebConfig.ServisimUrl);
            var id = string.Format ("{0}-{1:D6}", WebConfig.ServisimPartnerCode, item.Id);
            var timer = new System.Diagnostics.Stopwatch ();

            cli.EndRequest += (object sender, RequestEventArgs e) => {
                timer.Stop ();

                try {
                    string text = "Time: " + timer.ElapsedMilliseconds + " ms\n" +
                                "Request:\n" + e.Request + "\n" +
                                "Response:\n" + e.Response + "\n";
                    string path = HttpContext.Current.Server.MapPath (string.Format (WebConfig.LogFilePattern, id, DateTime.Now));
                    File.WriteAllText (path, text);
                } catch {
                }
            };

            timer.Start ();
            var tfd = cli.Stamp (id, cfd);

            cfd.Complemento = new List<object> ();
            cfd.Complemento.Add (tfd);

            return cfd;
        }
Ejemplo n.º 2
0
        // TODO: credentials per taxpayer
        static bool ServisimCancel(FiscalDocument item)
        {
            var cli = new ServisimClient (WebConfig.ServisimUser,
                WebConfig.ServisimPasswd, WebConfig.ServisimUrl);

            return cli.Cancel (item.Issuer.Id, item.StampId);
        }