Пример #1
0
        //author:Vamsi
        //date: 27/03/2020
        //To generate latest invoice pdf in byre array format
        public byte[] GenerateInvoicePDFinByteArray(string vc_invoice_number, string invoice_date, long?invoiceId, long?userId)
        {
            InvoiceViewController controller = new InvoiceViewController();
            RouteData             route      = new RouteData();

            route.Values.Add("action", "Invoice");         // ActionName
            route.Values.Add("controller", "InvoiceView"); // Controller Name
            System.Web.Mvc.ControllerContext newContext = new
                                                          System.Web.Mvc.ControllerContext(new HttpContextWrapper(System.Web.HttpContext.Current), route, controller);
            controller.ControllerContext = newContext;
            invoice_date = string.IsNullOrEmpty(invoice_date) ? DateTime.Now.ToString("yyyyMMdd") : invoice_date.Replace("-", "");
            var actionPDF = controller.getinvoicePDFdatainbytes(invoiceId);

            return(actionPDF);
        }
Пример #2
0
        public HttpResponseMessage generateinvoicePdf(long?invoiceid)
        {
            InvoiceViewController controller = new InvoiceViewController();
            RouteData             route      = new RouteData();

            route.Values.Add("action", "Invoice");         // ActionName
            route.Values.Add("controller", "InvoiceView"); // Controller Name
            System.Web.Mvc.ControllerContext newContext = new
                                                          System.Web.Mvc.ControllerContext(new HttpContextWrapper(System.Web.HttpContext.Current), route, controller);
            controller.ControllerContext = newContext;
            var actionPDF = controller.getinvoicePDFdatainbytes(invoiceid);
            HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);

            response.Content = new ByteArrayContent(actionPDF);// new StreamContent(new FileStream(localFilePath, FileMode.Open, FileAccess.Read));
            response.Content.Headers.ContentDisposition          = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment");
            response.Content.Headers.ContentDisposition.FileName = "InvNo-First Name Last Name-Uploaded Date-timestamp.PDF";
            response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/pdf");
            return(response);
        }
Пример #3
0
        //author:Vamsi
        //date: 23/03/2020
        //To generate latest invoice pdf
        public void GenerateInvoicePDF(string vc_invoice_number, string invoice_date, long?invoiceId, long?userId)
        {
            InvoiceViewController controller = new InvoiceViewController();
            RouteData             route      = new RouteData();

            route.Values.Add("action", "Invoice");         // ActionName
            route.Values.Add("controller", "InvoiceView"); // Controller Name
            System.Web.Mvc.ControllerContext newContext = new
                                                          System.Web.Mvc.ControllerContext(new HttpContextWrapper(System.Web.HttpContext.Current), route, controller);
            controller.ControllerContext = newContext;
            invoice_date = string.IsNullOrEmpty(invoice_date) ? DateTime.Now.ToString("yyyyMMdd") : invoice_date.Replace("-", "");
            var    actionPDF         = controller.getinvoicePDFdatainbytes(invoiceId);
            var    UserDetails       = adminMethods.GetAllIBWUsers().Where(x => x.int_user_id == userId).FirstOrDefault();
            string invoicefilename   = UserDetails != null ? vc_invoice_number + "-" + UserDetails.vc_user_name + " " + UserDetails.vc_alias_name + "-" + invoice_date : vc_invoice_number + "-" + invoice_date;
            string FileId            = GoogleDriveFilesRepository.UploadInvoiceFiletoGoogleDrivefolder("", invoicefilename, actionPDF);
            string invoiceaccesslink = GoogleDriveFilesRepository.GetSharableLink(FileId);

            invoiceMethods.UpdateInvoiceGoogleDriveDetails(invoiceId, FileId, invoiceaccesslink);
        }