Пример #1
0
 public ActionResult ajxPreview(int idInvoice, string pattern)
 {
     try
     {
         Company         currentCom = ((EInvoiceContext)FXContext.Current).CurrentCompany;
         IInvoiceService IInvSrv    = InvServiceFactory.GetService(pattern, currentCom.id);
         logtest.Info("call: " + idInvoice + " pattern: " + pattern + " company: " + currentCom.id);
         IInvoice oInvoice = IInvSrv.Getbykey <IInvoice>(idInvoice);
         //IViewer _iViewerSrv = IoC.Resolve<IViewer>();
         IViewer _iViewerSrv = InvServiceFactory.GetViewer(pattern, currentCom.id);
         if (oInvoice.Status != InvoiceStatus.NewInv)
         {
             IRepositoryINV _iRepoSrv = IoC.Resolve <IRepositoryINV>();
             byte[]         data      = _iRepoSrv.GetData(oInvoice);
             return(Json(new { invData = _iViewerSrv.GetHtml(data), status = oInvoice.Status }));
         }
         else
         {
             return(Json(new { invData = _iViewerSrv.GetHtml(System.Text.Encoding.UTF8.GetBytes(oInvoice.GetXMLData())), status = 0 }));
         }
     }
     catch (Exception ex)
     {
         logtest.Error(ex);
         return(Json(new { invData = "Có lỗi xảy ra, vui lòng thực hiện lại.", status = 0 }));
     }
 }
Пример #2
0
 public VerifyController()
 {
     currentCom = ((EInvoiceContext)FXContext.Current).CurrentCompany;
     iCer       = IoC.Resolve <ICertificateService>();
     //iGen = IoC.Resolve<IGeneratorINV>();
     iRepo = IoC.Resolve <IRepositoryINV>();
 }
Пример #3
0
        public IHttpActionResult convertForVerify(DataAPI portal)
        {
            Company _currentCompany = ((EInvoiceContext)FXContext.Current).CurrentCompany;
            int     comID           = _currentCompany.id;

            if (_currentCompany == null)
            {
                return(Unauthorized());                        //username khong phu hop - ko tim thay company phu hop voi [username]
            }
            string invPattern = null, invSerial = null;

            getPublishInvoice(portal.pattern, _currentCompany.id, out invPattern, out invSerial);
            if (string.IsNullOrWhiteSpace(invPattern))
            {
                return(Ok("ERR:20"));
            }
            IInvoiceService _iInvoicSrv  = InvServiceFactory.GetService(invPattern, comID);
            IInvoice        oInvoiceBase = InvServiceFactory.NewInstance(invPattern, comID);

            if (portal.invNo > 0)
            {
                oInvoiceBase = _iInvoicSrv.GetByNo(comID, invPattern, invSerial, portal.invNo);
            }
            else
            {
                oInvoiceBase = _iInvoicSrv.GetByFkey(comID, portal.fkey);
            }
            if (null == oInvoiceBase)
            {
                return(Ok <string>("ERR:6"));     //không tìm thấy hóa đơn
            }
            //lay html
            IRepositoryINV _repository = IoC.Resolve <IRepositoryINV>();

            byte[] invdata = _repository.GetData(oInvoiceBase);
            string err     = "";
            string rv      = _iInvoicSrv.ConvertForVerify(oInvoiceBase, "", out err);

            if (string.IsNullOrEmpty(rv) && !string.IsNullOrEmpty(err))
            {
                return(Ok <string>("ERR:8")); //hóa đơn đã convert rồi
            }
            return(Ok <string>(rv));
        }
Пример #4
0
        public IHttpActionResult convertForStore(DataAPI portal)
        {
            Company _currentCompany = ((EInvoiceContext)FXContext.Current).CurrentCompany;
            int     comID           = _currentCompany.id;

            if (_currentCompany == null)
            {
                return(Unauthorized());                        //username khong phu hop - ko tim thay company phu hop voi [username]
            }
            string invPattern = null, invSerial = null;

            getPublishInvoice(portal.pattern, _currentCompany.id, out invPattern, out invSerial);
            if (string.IsNullOrWhiteSpace(invPattern))
            {
                return(Ok("ERR:20"));
            }
            IInvoiceService _iInvoicSrv = InvServiceFactory.GetService(invPattern, comID);
            IInvoice        currentInv  = InvServiceFactory.NewInstance(invPattern, comID);

            if (portal.invNo > 0)
            {
                currentInv = _iInvoicSrv.GetByNo(comID, invPattern, invSerial, portal.invNo);
            }
            else
            {
                currentInv = _iInvoicSrv.GetByFkey(comID, portal.fkey);
            }
            if (null == currentInv)
            {
                return(NotFound());
            }
            //lay html
            IRepositoryINV _repository = IoC.Resolve <IRepositoryINV>();

            byte[] invdata = _repository.GetData(currentInv);
            string err     = "";
            string rv      = _iInvoicSrv.ConvertForStore(currentInv, "", out err);

            return(Ok <string>(rv));
        }
Пример #5
0
        public HttpResponseMessage convertToHTML(DataAPI portal)
        {
            Company _currentCompany = ((EInvoiceContext)FXContext.Current).CurrentCompany;
            int     comID           = _currentCompany.id;

            if (_currentCompany == null)
            {
                return new HttpResponseMessage()
                       {
                           Content = new StringContent("ERR:1-Unauthorized")
                       }
            }
            ;
            string invPattern = null, invSerial = null;

            getPublishInvoice(portal.pattern, _currentCompany.id, out invPattern, out invSerial);
            if (string.IsNullOrWhiteSpace(invPattern))
            {
                return new HttpResponseMessage()
                       {
                           Content = new StringContent("ERR:20")
                       }
            }
            ;

            IInvoiceService _iInvoicSrv = InvServiceFactory.GetService(invPattern, comID);
            IInvoice        currentInv  = InvServiceFactory.NewInstance(invPattern, comID);

            if (portal.invNo > 0)
            {
                currentInv = _iInvoicSrv.GetByNo(comID, invPattern, invSerial, portal.invNo);
            }
            else
            {
                currentInv = _iInvoicSrv.GetByFkey(comID, portal.fkey);
            }
            if (null == currentInv)
            {
                return(new HttpResponseMessage()
                {
                    Content = new StringContent("ERR:2")
                });  //khong ton tai hoa don
            }

            //lay html
            IRepositoryINV _repository = IoC.Resolve <IRepositoryINV>();

            byte[] invdata = _repository.GetData(currentInv);
            string err     = "";
            string rv      = _iInvoicSrv.ConvertForStore(currentInv, "", out err);

            if (!string.IsNullOrWhiteSpace(err))
            {
                log.Error(err);
                return(new HttpResponseMessage()
                {
                    Content = new StringContent("ERR:" + err)
                });
            }
            var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(rv);

            return(new HttpResponseMessage()
            {
                Content = new StringContent(System.Convert.ToBase64String(plainTextBytes))
            });
        }