Example #1
0
        public async Task <IActionResult> ReplaceInvoice(string taxcode, string ivno, string tmplatecode)
        {
            RootObject r        = new RootObject();
            string     query    = "{ \"supplierTaxCode\":\"" + taxcode + "\",\"invoiceNo\":\"" + ivno + "\",\"templateCode\":\"" + tmplatecode + "\",\"fileType\":\"ZIP\"}";
            var        response = CreateRequest.webRequest("https://demo-sinvoice.viettel.vn:8443/InvoiceAPI/InvoiceUtilsWS/getInvoiceRepresentationFile", query, Authen.AuthString, "POST", "application/json");

            if (response != "")
            {
                r = JsonConvert.DeserializeObject <RootObject>(response);
            }
            toolgenpdf.unzipthaythe(r.fileToBytes, _env);
            invoice     invoicetemp = new invoice();
            XmlDocument doc         = new XmlDocument();

            string[]   filePaths = Directory.GetFiles(_env.WebRootPath + "/THAYTHE/", "*.xml", SearchOption.AllDirectories);
            FileStream fs        = new FileStream(filePaths[0], FileMode.Open, FileAccess.Read);

            doc.Load(fs);
            using (var stringWriter = new StringWriter())
                using (var xmlTextWriter = XmlWriter.Create(stringWriter))
                {
                    doc.WriteTo(xmlTextWriter);
                    xmlTextWriter.Flush();
                    Serializer seri = new Serializer();
                    invoicetemp = seri.Deserialize <invoice>(stringWriter.GetStringBuilder().ToString());
                }
            fs.Close();
            return(PartialView("ReplaceInvoice", invoicetemp));
        }
Example #2
0
        public JsonResult laphoadon(string query, string mst)
        {
            while (query.Contains("\\"))
            {
                query.Replace("\\", "");
            }
            var responce = CreateRequest.webRequest("https://demo-sinvoice.viettel.vn:8443/InvoiceAPI/InvoiceWS/createInvoice/" + mst, query, Authen.AuthString, "POST", "application/json");

            return(Json(responce));
        }
Example #3
0
        public JsonResult viewinvoice(string query)
        {
            string response = CreateRequest.webRequest("https://demo-sinvoice.viettel.vn:8443/InvoiceAPI/InvoiceUtilsWS/getInvoiceRepresentationFile", query, Authen.AuthString, "POST", "application/json");

            if (response != "")
            {
                var item = Json(response);
                return(Json(item));
            }
            return(Json(null));
        }
Example #4
0
        public JsonResult Getitem(string mast, string shd, string ngay, string mabm)
        {
            string pl       = ngay.Replace("/", "");
            string xl       = pl.Replace(" ", "");
            string ngaylap  = xl.Replace(":", "");
            string response = CreateRequest.webRequest("https://demo-sinvoice.viettel.vn:8443/InvoiceAPI/InvoiceUtilsWS/getInvoiceFilePortal?supplierTaxCode=" + mast + "&invoiceNo=" + shd + "&fileType=zip&strIssueDate=" + ngaylap + "&reservationCode=" + mabm, "", Authen.AuthString, "GET", "application/json");

            if (response != "")
            {
                var item = Json(response);
                return(Json(item));
            }
            return(Json(null));
        }
Example #5
0
        public IActionResult ManageInvoice(IFormCollection collect)
        {
            listInvoice vi      = new listInvoice();
            string      tungay  = collect["ngaylaphd1"];
            string      denngay = collect["ngaylaphd2"];

            if (collect["ngaylaphd1"] == collect["ngaylaphd2"])
            {
                tungay = DateTime.Parse(tungay).AddDays(-1).ToString("yyyy-MM-dd");
            }
            string query    = "{\"startDate\" : \"" + tungay + "\",\"endDate\" : \"" + denngay + "\",\"rowPerPage\" : 10000,\"pageNum\" : 1}";
            var    responce = CreateRequest.webRequest("https://demo-sinvoice.viettel.vn:8443/InvoiceAPI/InvoiceUtilsWS/getInvoices/0100109106", query, Authen.AuthString, "POST", "application/json");

            vi = JsonConvert.DeserializeObject <listInvoice>(responce);
            List <InvoiceInformation> s = vi.invoices.DefaultIfEmpty().ToList();

            foreach (InvoiceInformation temp in s)
            {
                temp.issueDate = DateTime.Parse(UnixTimeToDateTime(long.Parse(temp.issueDate)).ToString()).ToString("dd/MM/yyyy HH:mm:ss");
            }
            return(View("ManageInvoice", s));
        }