Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            // Check for license and apply if exists
            string licenseFile = AppDomain.CurrentDomain.BaseDirectory + "Aspose.Words.lic";
            if (File.Exists(licenseFile))
            {
                // Apply Aspose.Words API License
                Aspose.Words.License license = new Aspose.Words.License();
                // Place license file in Bin/Debug/ Folder
                license.SetLicense("Aspose.Words.lic");
            }

            string filePath = Path.GetDirectoryName(Path.GetDirectoryName(Directory.GetCurrentDirectory())) + @"\data\" + "Extract Images from Word Document.doc";

            Document wordDocument = new Document(filePath);
            
            NodeCollection pictures = wordDocument.GetChildNodes(NodeType.Shape, true);
            int imageindex = 0;
            foreach (Shape shape in pictures)
            {
                string imageType = FileFormatUtil.ImageTypeToExtension(shape.ImageData.ImageType);
                if (shape.HasImage)
                {
                    string imageFileName = "Aspose_" + (imageindex++).ToString() + "_" + shape.Name + imageType;
                    shape.ImageData.Save(imageFileName);
                }
            }

        }
        /// <summary>
        /// Load liencse for apose
        /// </summary>
        private static void LicenseAspose()
        {
            Aspose.Words.License word = new Aspose.Words.License();
            word.SetLicense("Aspose.Total.lic");

            Aspose.Cells.License excel = new Aspose.Cells.License();
            excel.SetLicense("Aspose.Total.lic");
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            // Check for license and apply if exists
            string licenseFile = AppDomain.CurrentDomain.BaseDirectory + "Aspose.Words.lic";
            if (File.Exists(licenseFile))
            {
                // Apply Aspose.Words API License
                Aspose.Words.License license = new Aspose.Words.License();
                // Place license file in Bin/Debug/ Folder
                license.SetLicense("Aspose.Words.lic");
            }

            Document doc = new Document();

            DocumentBuilder builder = new DocumentBuilder(doc);

            Table table = builder.StartTable();
            builder.InsertCell();

            // Set the borders for the entire table.
            table.SetBorders(LineStyle.Single, 2.0, Color.Black);
            // Set the cell shading for this cell.
            builder.CellFormat.Shading.BackgroundPatternColor = Color.DarkGray;
            builder.Writeln("Cell #1");

            builder.InsertCell();
            // Specify a different cell shading for the second cell.
            builder.CellFormat.Shading.BackgroundPatternColor=Color.Blue;
            builder.Writeln("Cell #2");

            // End this row.
            builder.EndRow();

            // Clear the cell formatting from previous operations.
            builder.CellFormat.ClearFormatting();

            // Create the second row.
            builder.InsertCell();

            // Create larger borders for the first cell of this row. This will be different
            // compared to the borders set for the table.
            builder.CellFormat.Borders.Left.LineWidth=4.0;
            builder.CellFormat.Borders.Right.LineWidth=4.0;
            builder.CellFormat.Borders.Top.LineWidth=4.0;
            builder.CellFormat.Borders.Bottom.LineWidth=4.0;
            builder.Writeln("Cell #3");

            builder.InsertCell();
            // Clear the cell formatting from the previous cell.
            builder.CellFormat.ClearFormatting();
            builder.Writeln("Cell #4");

            doc.Save("Format Table in Document.doc");
        }
Ejemplo n.º 4
0
 internal static void SetUnlimitedLicense()
 {
     if (File.Exists(TestLicenseFileName))
     {
         // This shows how to use an Aspose.Words license when you have purchased one.
         // You don't have to specify full path as shown here. You can specify just the
         // file name if you copy the license file into the same folder as your application
         // binaries or you add the license to your project as an embedded resource.
         Aspose.Words.License license = new Aspose.Words.License();
         license.SetLicense(TestLicenseFileName);
     }
 }
Ejemplo n.º 5
0
 private static void License()
 {
     try
     {
         const string licName = "Aspose.Total.lic";
         var wlic = new Aspose.Words.License();
         wlic.SetLicense(licName);
     }
     catch (Exception ex)
     {
         Logs.Error("WordHelper License Exception : " + ex.ToString());
     }
 }
Ejemplo n.º 6
0
        public static void createFileDownload(string reportTemplate, DataSet reportData, string saveName, Aspose.Words.SaveFormat saveFormat, Aspose.Words.SaveType saveType, HttpResponse Response)
        {
            Aspose.Words.License license = new Aspose.Words.License();
            license.SetLicense("Aspose.Words.lic");

            //Open the template document
            Aspose.Words.Document reportDoc = new Aspose.Words.Document(reportTemplate);

            // Fill the fields in the document with user data.
            reportDoc.MailMerge.ExecuteWithRegions(reportData);

            // Send the document in Word format to the client browser with an option to save to disk or open inside the current browser.
            reportDoc.Save(saveName, saveFormat, saveType, Response);
        }
Ejemplo n.º 7
0
        protected void Application_Start()
        {
            ViewEngines.Engines.Clear();
            ViewEngines.Engines.Add(new RazorViewEngine());

            AreaRegistration.RegisterAllAreas();
            RouteConfig.RegisterRoutes(RouteTable.Routes);

            BundleConfig.RegisterBundles(BundleTable.Bundles);

            Aspose.Words.License license = new Aspose.Words.License();
            license.SetLicense(ConfigurationManager.AppSettings["AsposeLicFileName"].ToString());

            log4net.Config.XmlConfigurator.Configure();
        }
        protected void btnIssueFreeFormatMessage_Click(object sender, EventArgs e)
        {
            Aspose.Words.License license = new Aspose.Words.License();
            license.SetLicense("Aspose.Words.lic");

            //Open template
            string path = Context.Server.MapPath("~/DesktopModules/TrainingCoreBanking/BankProject/Report/Template/IssueFreeFormatMessage.doc");
            //Open the template document
            Aspose.Words.Document doc = new Aspose.Words.Document(path);
            //Execute the mail merge.
            DataSet ds = new DataSet();
            ds = SQLData.B_BFREETEXTMESSAGE_Report(hiddenId.Value);

            // Fill the fields in the document with user data.
            doc.MailMerge.ExecuteWithRegions(ds); //moas mat thoi jan voi cuc gach nay woa
            // Send the document in Word format to the client browser with an option to save to disk or open inside the current browser.
            doc.Save("IssueFreeFormatMessage_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".pdf", Aspose.Words.SaveFormat.Pdf, Aspose.Words.SaveType.OpenInApplication, Response);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Set license here
        /// </summary>
        public static void SetLicense()
        {
            // Path to license file
            String licFile = @"d:\data\aspose\lic\Aspose.Total.lic";

            // Set the license, if not already set
            if (isLicSet == false)//
            {
                try
                {
                    Aspose.Words.License licWords = new Aspose.Words.License();
                    licWords.SetLicense(licFile);
                    Console.WriteLine("License set.");
                }
                catch(Exception ex)
                {
                    Console.WriteLine("License NOT set.");
                }
            }
        }
Ejemplo n.º 10
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            ModelBinders.Binders.Add(typeof(DateTime), new CustomDateBinder());
            ModelBinders.Binders.Add(typeof(DateTime?), new NullableCustomDateBinder());

            Stream stream = new MemoryStream(StrToByteArray(Resources.Licence));

            stream.Position = 0;
            Aspose.Pdf.License     licensePdf     = new Aspose.Pdf.License();
            Aspose.Words.License   licenseWords   = new Aspose.Words.License();
            Aspose.Cells.License   licenseCells   = new Aspose.Cells.License();
            Aspose.Slides.License  licenseSlides  = new Aspose.Slides.License();
            Aspose.BarCode.License licenseBarCode = new Aspose.BarCode.License();

            licensePdf.SetLicense(stream);
            stream.Position = 0;
            licenseWords.SetLicense(stream);
            stream.Position = 0;
            licenseCells.SetLicense(stream);
            stream.Position = 0;
            licenseSlides.SetLicense(stream);
            stream.Position = 0;
            licenseBarCode.SetLicense(stream);
            stream.Close();
            //   CreateLogins();

            //	CheckLogins();

            LogHelper.InitLogger();
            LogHelper.Log.Info("Application Start");

            EmployePermissionHelper.Init();


            QScheduler.Start();
        }
Ejemplo n.º 11
0
        static void Main(string[] args)
        {
            string filePath = Path.GetDirectoryName(Path.GetDirectoryName(Directory.GetCurrentDirectory())) + @"\data\" + "Working with Headers.doc";
            // Check for license and apply if exists
            string licenseFile = AppDomain.CurrentDomain.BaseDirectory + "Aspose.Words.lic";
            if (File.Exists(licenseFile))
            {
                // Apply Aspose.Words API License
                Aspose.Words.License license = new Aspose.Words.License();
                // Place license file in Bin/Debug/ Folder
                license.SetLicense("Aspose.Words.lic");
            }


            Document wordDocument = new Document(filePath);
            HeaderFooterCollection headers = wordDocument.FirstSection.HeadersFooters;
            foreach (HeaderFooter header in headers)
            {
                if (header.HeaderFooterType == HeaderFooterType.HeaderFirst || header.HeaderFooterType == HeaderFooterType.HeaderPrimary || header.HeaderFooterType == HeaderFooterType.HeaderEven)
                    Console.WriteLine(header.GetText());
            }
        }
Ejemplo n.º 12
0
        static void Main(string[] args)
        {
            string filePath = Path.GetDirectoryName(Path.GetDirectoryName(Directory.GetCurrentDirectory())) + @"\data\" + "Get Document Properties.doc";

            // Check for license and apply if exists
            string licenseFile = AppDomain.CurrentDomain.BaseDirectory + "Aspose.Words.lic";
            if (File.Exists(licenseFile))
            {
                // Apply Aspose.Words API License
                Aspose.Words.License license = new Aspose.Words.License();
                // Place license file in Bin/Debug/ Folder
                license.SetLicense("Aspose.Words.lic");
            }


            Document doc = new Document(filePath);
            foreach (DocumentProperty prop in doc.BuiltInDocumentProperties)
            {
                Console.WriteLine(prop.Name+": "+ prop.Value);

            }
        }
Ejemplo n.º 13
0
        static void Main(string[] args)
        {
            string filePath = Path.GetDirectoryName(Path.GetDirectoryName(Directory.GetCurrentDirectory())) + @"\data\" + "Get Document Properties.doc";

            // Check for license and apply if exists
            string licenseFile = AppDomain.CurrentDomain.BaseDirectory + "Aspose.Words.lic";

            if (File.Exists(licenseFile))
            {
                // Apply Aspose.Words API License
                Aspose.Words.License license = new Aspose.Words.License();
                // Place license file in Bin/Debug/ Folder
                license.SetLicense("Aspose.Words.lic");
            }


            Document doc = new Document(filePath);

            foreach (DocumentProperty prop in doc.BuiltInDocumentProperties)
            {
                Console.WriteLine(prop.Name + ": " + prop.Value);
            }
        }
Ejemplo n.º 14
0
        public LoginWindow()
        {
            InitializeComponent();

            // IP, MAC Address
            new ClientInitProcess().docThongTinCauHinhClient(1);

            // No IP, MAC Address
            //docThongTinCauHinhClient(1);

            if (!ClientInformation.Theme.Equals("default"))
            {
                SetThemes();
            }

            /* LANGUAGE */
            if (!ClientInformation.LanguageList.Equals(""))
            {
                string          LanguagePattern = ClientInformation.LanguageList;
                List <Language> LanguageList    = (new Language()).getLanguageList(LanguagePattern);

                int    i     = 0;
                int    index = 0;
                string value = "";
                foreach (Language e in LanguageList)
                {
                    RadComboBoxItem item = new RadComboBoxItem();
                    item.Content = e.LanguageName; item.Tag = e.LanguageCode;
                    cboLanguage.Items.Add(item);

                    if (e.LanguageStatus.Equals("1"))
                    {
                        index = i;
                        value = e.LanguageStatus;
                    }
                    ++i;
                }

                cboLanguage.SelectedIndex = index;
                //cboLanguage.SelectedValue = value;
            }
            else
            {
            }
            /* LANGUAGE */

            process = new ZAMainAppProcess();

            //Icon & title setting
            CommonFunction.setIcon(this);

            //Set licence Aspose Words and Cells
            MemoryStream aspLic = new MemoryStream();
            StreamWriter sw     = new StreamWriter(aspLic, Encoding.UTF8);

            Aspose.Words.License licenseWord = new Aspose.Words.License();
            //Set the license of Aspose.Cells to avoid the evaluation
            //limitations
            sw.WriteLine(BusinessConstant.asposeWordLic);
            sw.Flush();
            aspLic.Position = 0;
            licenseWord.SetLicense(aspLic);

            Aspose.Cells.License licenseExcel = new Aspose.Cells.License();
            //Set the license of Aspose.Cells to avoid the evaluation
            //limitations
            sw.WriteLine(BusinessConstant.asposeWordLic);
            sw.Flush();
            aspLic.Position = 0;
            licenseExcel.SetLicense(aspLic);

            ApplicationConstant.DonViSuDung company = ApplicationConstant.layDonViSuDung(ClientInformation.Company);

            if (company == ApplicationConstant.DonViSuDung.BINHKHANH)
            {
                lblLanguage.Visibility = Visibility.Hidden;
                cboLanguage.Visibility = Visibility.Hidden;
                lblTitle.Visibility    = Visibility.Visible;

                //imgConfig.Visibility = Visibility.Collapsed;
                string ServerPattern = ClientInformation.ServerList;
                if (!string.IsNullOrEmpty(ServerPattern))
                {
                    Server        server     = new Server();
                    List <Server> ServerList = server.getServerList(ServerPattern);

                    if (ServerList.Count <= 1)
                    {
                        imgConfig.Visibility = Visibility.Collapsed;
                    }
                    else
                    {
                        foreach (Server item in ServerList)
                        {
                            MenuItem mnuItem = new MenuItem();
                            mnuItem.Name   = "" + item.ServerName;
                            mnuItem.Header = "" + item.ServerName;
                            mnuItem.Uid    = "" + item.ServerIP + "#" + item.ServerPort + "#" + item.ServerCode;
                            if (item.ServerName.Equals(ClientInformation.ServerName))
                            {
                                mnuItem.Icon = new Image {
                                    Source = new BitmapImage(new Uri(@"pack://*****:*****@"pack://application:,,,/Utilities.Common;component/Images/Action/approve.png", UriKind.RelativeOrAbsolute)), Width = 12, Height = 12
                                };
                            }
                            mnuItem.Click += mnu_Click;

                            mnuConfig.Items.Add(mnuItem);
                        }
                    }
                }
                else
                {
                    imgConfig.Visibility = Visibility.Collapsed;
                }
            }
            else
            {
                if (company == ApplicationConstant.DonViSuDung.BIDV ||
                    company == ApplicationConstant.DonViSuDung.BIDV_BLF)
                {
                    //cboLanguage.SelectedIndex = 1;
                }

                //imgConfig.Visibility = Visibility.Collapsed;
                string ServerPattern = ClientInformation.ServerList;
                if (!string.IsNullOrEmpty(ServerPattern))
                {
                    Server        server     = new Server();
                    List <Server> ServerList = server.getServerList(ServerPattern);

                    if (ServerList.Count <= 1)
                    {
                        imgConfig.Visibility = Visibility.Collapsed;
                    }
                    else
                    {
                        foreach (Server item in ServerList)
                        {
                            MenuItem mnuItem = new MenuItem();
                            mnuItem.Name   = "" + item.ServerName;
                            mnuItem.Header = "" + item.ServerName;
                            mnuItem.Uid    = "" + item.ServerIP + "#" + item.ServerPort + "#" + item.ServerCode;
                            if (item.ServerName.Equals(ClientInformation.ServerName))
                            {
                                mnuItem.Icon = new Image {
                                    Source = new BitmapImage(new Uri(@"pack://application:,,,/Utilities.Common;component/Images/Action/approve.png", UriKind.RelativeOrAbsolute)), Width = 12, Height = 12
                                };
                            }
                            mnuItem.Click += mnu_Click;

                            mnuConfig.Items.Add(mnuItem);
                        }
                    }
                }
                else
                {
                    imgConfig.Visibility = Visibility.Collapsed;
                }
            }
            cboLanguage.SelectionChanged += cboLanguage_SelectionChanged;
        }
 public DocumentEngine(){
     var license = new Aspose.Words.License();
     license.SetLicense("Licenses/Aspose.Words.lic");
 }
Ejemplo n.º 16
0
 internal static void RemoveLicense()
 {
     Aspose.Words.License license = new Aspose.Words.License();
     license.SetLicense("");
 }
Ejemplo n.º 17
0
        private void PrintDocument()
        {
            Aspose.Words.License license = new Aspose.Words.License();
            license.SetLicense("Aspose.Words.lic");
            //Open template
            string docPath = Context.Server.MapPath("~/DesktopModules/TrainingCoreBanking/BankProject/Report/Template/AccountTransaction/CashDeposit.docx");
            //Open the template document
            Aspose.Words.Document document = new Aspose.Words.Document(docPath);
            //Execute the mail merge.

            var ds = BankProject.DataProvider.Database.BCASHDEPOSIT_Print_GetByCode(txtId.Text);
            document.MailMerge.ExecuteWithRegions(ds.Tables[0]); //moas mat thoi jan voi cuc gach nay woa
            // Send the document in Word format to the client browser with an option to save to disk or open inside the current browser.
            document.Save("CashDeposit_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".doc", Aspose.Words.SaveFormat.Doc, Aspose.Words.SaveType.OpenInBrowser, Response);
        }
        protected void btnAmendNhapNgoaiBang_Click(object sender, EventArgs e)
        {
            Aspose.Words.License license = new Aspose.Words.License();
            license.SetLicense("Aspose.Words.lic");

            //Open template
            string path = Context.Server.MapPath("~/DesktopModules/TrainingCoreBanking/BankProject/Report/Template/DocumentaryCollection/Export/RegisterDocumentaryCollection_Amend_PHIEUNHAPNGOAIBANG.doc");
            //Open the template document
            Aspose.Words.Document doc = new Aspose.Words.Document(path);
            //Execute the mail merge.
            DataSet ds = new DataSet();
            ds = SQLData.P_BEXPORTDOCUMETARYCOLLECTION_AMEND_PHIEUNHAPNGOAIBANG_Report(txtCode.Text, UserInfo.Username);

            // Fill the fields in the document with user data.
            doc.MailMerge.ExecuteWithRegions(ds); //moas mat thoi jan voi cuc gach nay woa
            // Send the document in Word format to the client browser with an option to save to disk or open inside the current browser.
            doc.Save("AmendDocumentaryCollectionPHIEUNHAPNGOAIBANG_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".doc", Aspose.Words.SaveFormat.Doc, Aspose.Words.SaveType.OpenInBrowser, Response);
        }
Ejemplo n.º 19
0
 bool AsposeOpen(string file)
 {
     var tmp = CopyFile(file);
     try
     {
         var lic = new Aspose.Words.License();
         lic.SetLicense("Workshare.Policy.Actions.Tests.Aspose.Total.lic");
         Aspose.Words.Document document = new Aspose.Words.Document(tmp);
         return true;
     }
     finally
     {
         File.Delete(tmp);
     }
 }
        protected void Print_Deal_Slip()
        {
            Aspose.Words.License license = new Aspose.Words.License();
            license.SetLicense("Aspose.Words.lic");

            DataSet ds;
            if (rcbProductID.SelectedValue == "1000")
            {
                //Open template
                string docPath = Context.Server.MapPath("~/DesktopModules/TrainingCoreBanking/BankProject/Report/Template/OutWardTransactions/transfer_by_account_dien_CMND.doc");
                //Open the template document
                Aspose.Words.Document document = new Aspose.Words.Document(docPath);
                //Execute the mail merge.
                ds = BankProject.DataProvider.TriTT.Print_Deal_slip("Trans_By_Acct", "CMND", tbID.Text.Trim());
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    ds.Tables[0].TableName = "Info";
                    document.MailMerge.ExecuteWithRegions(ds.Tables["Info"]);
                    document.Save("TransferByAccount_CMND_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".doc", Aspose.Words.SaveFormat.Doc, Aspose.Words.SaveType.OpenInBrowser, Response);
                }
            }
            else
            {
                //Open template
                string docPath = Context.Server.MapPath("~/DesktopModules/TrainingCoreBanking/BankProject/Report/Template/OutWardTransactions/transfer_by_account_dien_CITAD.doc");
                //Open the template document
                Aspose.Words.Document document = new Aspose.Words.Document(docPath);
                //Execute the mail merge.
                ds = BankProject.DataProvider.TriTT.Print_Deal_slip("Trans_By_Acct", "CITAD", tbID.Text.Trim());
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    //ds.Tables[0].Rows[0]["ChiNhanh"] = ConfigurationManager.AppSettings["ChiNhanh"];
                    //ds.Tables[0].Rows[0]["BranchAddress"] = ConfigurationManager.AppSettings["BranchAddress"];
                    //ds.Tables[0].Rows[0]["BranchTel"] = ConfigurationManager.AppSettings["BranchTel"];
                    ds.Tables[0].TableName = "Info";
                    //ds.Tables[1].TableName = "Detail";
                    //document.MailMerge.ExecuteWithRegions(ds.Tables["Info"]);
                    document.MailMerge.ExecuteWithRegions(ds.Tables["Info"]);
                    // Send the document in Word format to the client browser with an option to save to disk or open inside the current browser.
                    document.Save("TransferByAccount_CITAD_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".doc", Aspose.Words.SaveFormat.Doc, Aspose.Words.SaveType.OpenInBrowser, Response);
                }
            }
        }
Ejemplo n.º 21
0
        public string MoveLocalToServerFile(string fileName, string batchId, string localStoragePath, string serverStoragePath, int orderNo, string partNo)
        {
            string        fileDiskNameResult = "";
            DirectoryInfo Localdirectory     = new DirectoryInfo(localStoragePath);

            if (!Localdirectory.Exists)
            {
                Localdirectory = Directory.CreateDirectory(localStoragePath);
            }
            if (!Directory.Exists(serverStoragePath))
            {
                Directory.CreateDirectory(serverStoragePath);
            }
            //Move Step 6 file to Upload Batch folder
            string UploadBatchPath = ConfigurationManager.AppSettings["TempStorageDirectory"].ToString() + "/" + orderNo + "/" + partNo.Replace(",", "-");

            if (!Directory.Exists(UploadBatchPath))
            {
                Directory.CreateDirectory(UploadBatchPath);
            }
            foreach (var file in Localdirectory.GetFiles("*" + batchId + "_" + fileName + "*"))
            {
                var    objFile     = file.Name.Split('_');
                string objFileName = string.Empty;
                if (objFile.Length > 3)
                {
                    for (int i = 0; i < objFile.Length; i++)
                    {
                        if (i > 1)
                        {
                            objFileName += objFile[i] + "_";
                        }
                    }
                    objFileName = objFileName.Trim('_');
                }
                else
                {
                    objFileName = objFile[2];
                }


                if (objFile.Length > 0 && objFile[1] == batchId && objFileName == fileName)
                {
                    string             fileType = file.Extension;
                    Aspose.Pdf.License license  = new Aspose.Pdf.License();
                    license.SetLicense("Aspose.Pdf.lic");

                    Aspose.Words.License license1 = new Aspose.Words.License();
                    license1.SetLicense("Aspose.Words.lic");

                    string fileDiskName = Guid.NewGuid().ToString();
                    if (fileType.ToUpper() == ".DOC" || fileType.ToUpper() == ".DOCX")
                    {
                        fileDiskName += ".pdf";
                        Aspose.Words.Document doc = new Aspose.Words.Document(file.FullName);
                        doc.Save(Path.Combine(serverStoragePath, fileDiskName));
                        doc.Save(Path.Combine(UploadBatchPath, fileDiskName));
                    }
                    else if (fileType.ToUpper() == ".PDF")
                    {
                        fileDiskName += ".pdf";
                        Aspose.Pdf.Document doc = new Aspose.Pdf.Document(file.FullName);
                        doc.Save(Path.Combine(serverStoragePath, fileDiskName));
                        doc.Save(Path.Combine(UploadBatchPath, fileDiskName));
                    }
                    else
                    {
                        fileDiskName += file.Extension;
                        file.CopyTo(Path.Combine(serverStoragePath, fileDiskName));
                        file.CopyTo(Path.Combine(UploadBatchPath, fileDiskName));
                    }
                    fileDiskNameResult = fileDiskName;
                    //file.Delete();
                }
            }
            return(fileDiskNameResult);
        }
 protected void Print_Deal_Slip()
 {
     Aspose.Words.License license = new Aspose.Words.License();
     license.SetLicense("Aspose.Words.lic");
     //Open template
     string docPath = Context.Server.MapPath("~/DesktopModules/TrainingCoreBanking/BankProject/Report/Template/OutWardTransactions/cheque_withdrawl.doc");
     //Open the template document
     Aspose.Words.Document document = new Aspose.Words.Document(docPath);
     //Execute the mail merge.
     var ds = BankProject.DataProvider.TriTT.Print_Deal_slip("Cheque", "withdrwal", tbID.Text.Trim());
     if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
     {
         ds.Tables[0].TableName = "Info";
         document.MailMerge.ExecuteWithRegions(ds.Tables["Info"]);
         document.Save("Cheque_Withdrwal_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".doc", Aspose.Words.SaveFormat.Doc, Aspose.Words.SaveType.OpenInBrowser, Response);
     }
 }
 private void PrintSavingAccDocument()
 {
     Aspose.Words.License license = new Aspose.Words.License();
     license.SetLicense("Aspose.Words.lic");
     //Open template
     string docPath = Context.Server.MapPath("~/DesktopModules/TrainingCoreBanking/BankProject/Report/Template/SavingAcc/SavingAccount.docx");
     //Open the template document
     Aspose.Words.Document document = new Aspose.Words.Document(docPath);
     //Execute the mail merge.
     var ds = PrepareData2Print();
     // Fill the fields in the document with user data.
     document.MailMerge.ExecuteWithRegions(ds.Tables["Info"]);
     document.MailMerge.ExecuteWithRegions(ds.Tables["Items"]);
     // Send the document in Word format to the client browser with an option to save to disk or open inside the current browser.
     document.Save("SavingAccount_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".doc", Aspose.Words.SaveFormat.Doc, Aspose.Words.SaveType.OpenInBrowser, Response);
 }
Ejemplo n.º 24
0
 private static void LoadLicense(string ext)
 {
     switch (ext)
     {
         case ".PDF":
             var pdfLicense = new Aspose.Pdf.License();
             pdfLicense.SetLicense("Aspose.Total.lic");
             break;
         case ".DOC":
         case ".DOCX":
         case ".RTF":
             var docLicense = new Aspose.Words.License();
             docLicense.SetLicense("Aspose.Total.lic");
             break;
         case ".XLS":
         case ".XLSX":
         case ".CSV":
             var xlsLicense = new Aspose.Cells.License();
             xlsLicense.SetLicense("Aspose.Total.lic");
             break;
         case ".PPT":
         case ".PPTX":
             var pptLicense = new Aspose.Slides.License();
             pptLicense.SetLicense("Aspose.Total.lic");
             break;
         case ".VSD":
         case ".VSDX":
             var vsdLicense = new Aspose.Diagram.License();
             vsdLicense.SetLicense("Aspose.Total.lic");
             break;
         case ".MSG":
             var emaiLicense = new Aspose.Email.License();
             var msgPdfLicense = new Aspose.Words.License();
             emaiLicense.SetLicense("Aspose.Total.lic");
             msgPdfLicense.SetLicense("Aspose.Total.lic");
             break;
         default:
             var license = new Aspose.Words.License();
             license.SetLicense("Aspose.Total.lic");
             break;
     }
 }
Ejemplo n.º 25
0
 ///<Summary>
 /// SetAsposeWordsLicense method to Aspose.Words License
 ///</Summary>
 public static void SetAsposeWordsLicense()
 {
     Aspose.Words.License awLic = new Aspose.Words.License();
     awLic.SetLicense("Aspose.Total.lic");
 }
Ejemplo n.º 26
0
        public HttpResponseMessage PrintCheckIIFFiles(string fromDate, string toDate, string checkID, int checkNo, int CompanyNo)
        {
            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK);

            try
            {
                SqlParameter[] param = { new SqlParameter("FromDate", (object)fromDate ?? (object)DBNull.Value)
                                         ,                            new SqlParameter("ToDate", (object)toDate ?? (object)DBNull.Value)
                                         ,                            new SqlParameter("CheckID", (object)checkID ?? (object)DBNull.Value)
                                         ,                            new SqlParameter("CheckNumber", (object)checkNo ?? (object)DBNull.Value)
                                         ,                            new SqlParameter("CompanyNo", (object)CompanyNo ?? (object)DBNull.Value) };
                var            result = _repository.ExecuteSQL <IIFPrintCheckEntity>("PrintCheckIIFFiles ", param).ToList();
                if (result.Count > 0)
                {
                    DataTable dt = new DataTable();
                    dt = Common.CommonHelper.ToDataTable(result);
                    Aspose.Words.License license = new Aspose.Words.License();
                    license.SetLicense(HttpContext.Current.Server.MapPath("~/ProjectLicFiles/" + "Aspose.Words.lic"));
                    string fileName = "ChequeFormat.doc";
                    string path     = HttpContext.Current.Server.MapPath("~/PrintCheck/" + fileName);

                    MemoryStream ms = new MemoryStream();

                    Aspose.Words.Document doc = new Aspose.Words.Document(path);
                    // doc.MailMerge.RemoveEmptyParagraphs = true;
                    doc.MailMerge.Execute(dt);
                    System.Collections.IEnumerator enumerator = dt.Rows.GetEnumerator();


                    //   doc.Save(ms,SaveFormat.Docx);

                    doc.Save(ms, Aspose.Words.SaveFormat.Pdf);

                    string PDFpath              = HttpContext.Current.Server.MapPath("~/PrintCheck/");
                    string fileNames            = DateTime.Now.ToString("yyyy-MM-dd");
                    string FullPathWithFileName = Path.Combine(PDFpath, fileNames + ".pdf");
                    if (System.IO.File.Exists(FullPathWithFileName))
                    {
                        System.IO.File.Delete(FullPathWithFileName);
                    }
                    FileStream file = new FileStream(FullPathWithFileName, FileMode.CreateNew, FileAccess.ReadWrite);

                    ms.WriteTo(file);

                    file.Close();
                    ms.Close();

                    byte[] bytes;                                    // = new byte[file.Length];
                    bytes = File.ReadAllBytes(FullPathWithFileName); //ms.ToArray();


                    using (FileStream stream = new FileStream(FullPathWithFileName, FileMode.Create))
                    {
                        stream.Write(bytes, 0, bytes.Length);
                    }

                    //Read the File into a Byte Array.

                    //Set the Response Content.
                    response.Content = new ByteArrayContent(bytes);

                    response.Content.Headers.Clear();
                    response.Content.Headers.Add("Content-Disposition", "attachment; filename=" + fileNames + ".pdf");
                    response.Content.Headers.Add("Content-Length", bytes.Length.ToString());
                    response.Content.Headers.ContentType = new MediaTypeHeaderValue(MimeMapping.GetMimeMapping("application/pdf"));



                    //Set the Response Content Length.
                    //response.Content.Headers.ContentLength = bytes.LongLength;

                    //Set the Content Disposition Header Value and FileName.
                    //  response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment");
                    //   response.Content.Headers.ContentDisposition.FileName = FullPathWithFileName;


                    //Set the File Content Type.
                    // response.Content.Headers.ContentType = "Application/pdf";// new MediaTypeHeaderValue(MimeMapping.GetMimeMapping(FullPathWithFileName));

                    return(response);
                }
            }
            catch (Exception ex)
            {
                // response.Message.Add(ex.Message);
            }

            return(response);
        }
        private void PrintLoanDocument()
        {
            Aspose.Words.License license = new Aspose.Words.License();
            license.SetLicense("Aspose.Words.lic");
            //Open template
            //string docPath = Context.Server.MapPath("~/DesktopModules/TrainingCoreBanking/BankProject/Report/Template/LoanContract/LichTraLai.docx");
            string docPath = Context.Server.MapPath("~/DesktopModules/TrainingCoreBanking/BankProject/Report/Template/LoanContract/LichTraNoHopDongVay.docx");
            //Open the template document
            Aspose.Words.Document document = new Aspose.Words.Document(docPath);
            //Execute the mail merge.
            var ds = PrepareDataForLoanContractSchedule();
            // Fill the fields in the document with user data.
            document.MailMerge.ExecuteWithRegions(ds.DtInfor);
            document.MailMerge.ExecuteWithRegions(ds.DtItems.DefaultView);
            document.MailMerge.ExecuteWithRegions(ds.DateReport);
            // Send the document in Word format to the client browser with an option to save to disk or open inside the current browser.
            document.Save("LichTraNoHDTinDung_" + tbNewNormalLoan.Text + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".pdf", Aspose.Words.SaveFormat.Pdf, Aspose.Words.SaveType.OpenInApplication, Response);

            //doc.Save("RegisterDocumentaryCollectionMT410_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".pdf", Aspose.Words.SaveFormat.Pdf, Aspose.Words.SaveType.OpenInApplication, Response);
        }
Ejemplo n.º 28
0
        private void PrintVat()
        {
            Aspose.Words.License license = new Aspose.Words.License();
            license.SetLicense("Aspose.Words.lic");
            //Open template
            string docPath = Context.Server.MapPath("~/DesktopModules/TrainingCoreBanking/BankProject/Report/Template/CollectCharge/CollectChargeVAT.doc");
            //Open the template document
            Aspose.Words.Document document = new Aspose.Words.Document(docPath);
            //Execute the mail merge.

            var ds = BankProject.DataProvider.Database.BCOLLECTCHARGESFROMACCOUNT_Print_GetByCode(tbDepositCode.Text);
            if (ds.Tables != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                ds.Tables[0].TableName = "Table";
                document.MailMerge.ExecuteWithRegions(ds.Tables["Table"]); //moas mat thoi jan voi cuc gach nay woa
                // Send the document in Word format to the client browser with an option to save to disk or open inside the current browser.
                document.Save("BCOLLECTCHARGESFROMACCOUNT_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".doc", Aspose.Words.SaveFormat.Doc, Aspose.Words.SaveType.OpenInBrowser, Response);
            }
        }
        protected void Print_Deal_Slip()
        {
            Aspose.Words.License license = new Aspose.Words.License();
            license.SetLicense("Aspose.Words.lic");
            //Open template
            if (rcbProductID.SelectedValue == "1000")
            {
                string docPath = Context.Server.MapPath("~/DesktopModules/TrainingCoreBanking/BankProject/Report/Template/OutWardTransactions/transfer_by_cash_dien_CMND.doc");
                //Open the template document
                Aspose.Words.Document document = new Aspose.Words.Document(docPath);
                //Execute the mail merge.

                var ds = BankProject.DataProvider.TriTT.Print_Deal_slip("Trans_By_Cash", "CMND", txtId.Text.Trim());
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    ds.Tables[0].TableName = "Info";
                    document.MailMerge.ExecuteWithRegions(ds.Tables["Info"]);
                    document.Save("TransferByCash_CMND_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".doc", Aspose.Words.SaveFormat.Doc, Aspose.Words.SaveType.OpenInBrowser, Response);
                }
            }
            else
            {
                string docPath = Context.Server.MapPath("~/DesktopModules/TrainingCoreBanking/BankProject/Report/Template/OutWardTransactions/transfer_by_cash_dien_CITAD.doc");
                //Open the template document
                Aspose.Words.Document document = new Aspose.Words.Document(docPath);
                //Execute the mail merge.

                var ds = BankProject.DataProvider.TriTT.Print_Deal_slip("Trans_By_Cash", "CITAD", txtId.Text.Trim());
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    ds.Tables[0].TableName = "Info";
                    document.MailMerge.ExecuteWithRegions(ds.Tables["Info"]);
                    document.Save("TransferByCash_CITAD_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".doc", Aspose.Words.SaveFormat.Doc, Aspose.Words.SaveType.OpenInBrowser, Response);
                }
            }
        }
 protected void Print_Deal_Slip()
 {
     Aspose.Words.License license = new Aspose.Words.License();
     license.SetLicense("Aspose.Words.lic");
     //Open template
     string docPath = Context.Server.MapPath("~/DesktopModules/TrainingCoreBanking/BankProject/Report/Template/CollectCharge/credit_card_payment_cash.doc");
     //Open the template document
     Aspose.Words.Document document = new Aspose.Words.Document(docPath);
     //Execute the mail merge.
     var ds = TriTT.Print_Credit_CardPayment_Cash(txtId.Text);
     if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
     {
         ds.Tables[0].TableName = "Info";
         document.MailMerge.ExecuteWithRegions(ds.Tables["Info"]);
         document.Save("Credit_Card_Payment_Cash" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".doc", Aspose.Words.SaveFormat.Doc, Aspose.Words.SaveType.OpenInBrowser, Response);
     }
 }
Ejemplo n.º 31
0
        static void Main(string[] args)
        {
            // Check for license and apply if exists
            string licenseFile = AppDomain.CurrentDomain.BaseDirectory + "Aspose.Words.lic";

            if (File.Exists(licenseFile))
            {
                // Apply Aspose.Words API License
                Aspose.Words.License license = new Aspose.Words.License();
                // Place license file in Bin/Debug/ Folder
                license.SetLicense("Aspose.Words.lic");
            }

            Document        doc     = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            builder.ParagraphFormat.Alignment                = ParagraphAlignment.Center;
            builder.ParagraphFormat.Borders.LineStyle        = LineStyle.Double;
            builder.ParagraphFormat.Borders.Bottom.LineStyle = LineStyle.Single;

            builder.Font.Bold      = true;
            builder.Font.Name      = "Courier";
            builder.Font.Underline = Underline.DotDotDash;
            builder.Font.Position  = 100;
            builder.Writeln("The quick brown fox");

            builder.ParagraphFormat.ClearFormatting();
            builder.ParagraphFormat.Borders.LineStyle     = LineStyle.Double;
            builder.ParagraphFormat.Borders.Top.LineStyle = LineStyle.None;
            builder.ParagraphFormat.Alignment             = ParagraphAlignment.Right;
            builder.Font.ClearFormatting();
            builder.Font.StrikeThrough = true;
            builder.Font.Size          = 20;
            builder.Write("jumped over the lazy dog");

            builder.Font.StrikeThrough = true;
            builder.Font.Size          = 20;
            builder.Font.Superscript   = true;
            builder.Font.Color         = System.Drawing.ColorTranslator.FromHtml("#FF0000");
            builder.Writeln("and went away");
            builder.ParagraphFormat.ClearFormatting();

            builder.InsertBreak(BreakType.PageBreak);
            builder.Font.ClearFormatting();

            builder.ParagraphFormat.Alignment       = ParagraphAlignment.Justify;
            builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly;
            builder.ParagraphFormat.FirstLineIndent = 600;

            builder.Font.Position = 20;
            builder.Writeln("To be, or not to be: that is the question: "
                            + "Whether 'tis nobler in the mind to suffer "
                            + "The slings and arrows of outrageous fortune, "
                            + "Or to take arms against a sea of troubles, "
                            + "And by opposing end them? To die: to sleep; ");

            builder.ParagraphFormat.ClearFormatting();
            builder.Font.ClearFormatting();
            builder.Font.Italic = true;
            builder.Writeln("No more; and by a sleep to say we end "
                            + "The heart-ache and the thousand natural shocks "
                            + "That flesh is heir to, 'tis a consummation "
                            + "Devoutly to be wish'd. To die, to sleep; "
                            + "To sleep: perchance to dream: ay, there's the rub; "
                            + ".......");

            builder.ParagraphFormat.ClearFormatting();
            builder.Font.ClearFormatting();

            builder.Font.Position = 10;
            builder.Writeln("For in that sleep of death what dreams may come");
            builder.InsertBreak(BreakType.LineBreak);
            builder.Writeln("When we have shuffled off this mortal coil,"
                            + "Must give us pause: there's the respect"
                            + "That makes calamity of so long life;");

            builder.InsertBreak(BreakType.LineBreak);

            builder.Writeln("For who would bear the whips and scorns of time,"
                            + "The oppressor's wrong, the proud man's contumely,");

            builder.InsertBreak(BreakType.LineBreak);

            builder.Font.ClearFormatting();
            builder.Writeln("The pangs of despised love, the law's delay,"
                            + "The insolence of office and the spurns" + ".......");

            doc.Save("ParagraphFormattingAspose.docx");
        }
        private void PrintDocument()
        {
            Aspose.Words.License license = new Aspose.Words.License();
            license.SetLicense("Aspose.Words.lic");
            //Open template
            string docPath = Context.Server.MapPath("~/DesktopModules/TrainingCoreBanking/BankProject/Report/Template/MainAccount/OpenAccount.docx");
            //Open the template document
            Aspose.Words.Document document = new Aspose.Words.Document(docPath);
            //Execute the mail merge.

            var ds = BankProject.DataProvider.Database.BOPENACCOUNT_Print_GetByCode(txtId.Text);
            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                ds.Tables[0].Rows[0]["ChiNhanh"] = ConfigurationManager.AppSettings["ChiNhanh"];
                ds.Tables[0].Rows[0]["BranchAddress"] = ConfigurationManager.AppSettings["BranchAddress"];
                ds.Tables[0].Rows[0]["BranchTel"] = ConfigurationManager.AppSettings["BranchTel"];
            }
            document.MailMerge.ExecuteWithRegions(ds.Tables[0]); //moas mat thoi jan voi cuc gach nay woa
            // Send the document in Word format to the client browser with an option to save to disk or open inside the current browser.
            document.Save("OpenAccount_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".doc", Aspose.Words.SaveFormat.Doc, Aspose.Words.SaveType.OpenInBrowser, Response);
        }
Ejemplo n.º 33
0
        public void ConfigureServices(IServiceCollection services)
        {
            OnConfiguringServices(services);

            services.AddHttpContextAccessor();
            services.AddScoped <HttpClient>(serviceProvider =>
            {
                var uriHelper = serviceProvider.GetRequiredService <NavigationManager>();

                return(new HttpClient
                {
                    BaseAddress = new Uri(uriHelper.BaseUri)
                });
            });

            services.AddHttpClient();
            services.AddScoped <LocalhostService>();

            services.AddDbContext <Flashcardgenerator.Data.LocalhostContext>(options =>
            {
                options.UseMySql(Configuration.GetConnectionString("localhostConnection"), ServerVersion.AutoDetect(Configuration.GetConnectionString("localhostConnection")));
            });

            services.AddRazorPages();
            services.AddServerSideBlazor().AddHubOptions(o =>
            {
                o.MaximumReceiveMessageSize = 10 * 1024 * 1024;
            });

            services.AddScoped <DialogService>();
            services.AddScoped <NotificationService>();
            services.AddScoped <TooltipService>();
            services.AddScoped <ContextMenuService>();
            services.AddScoped <GlobalsService>();
            services.AddBlazorDownloadFile(ServiceLifetime.Scoped);


            try
            {
                System.IO.DirectoryInfo di = new DirectoryInfo("wwwroot/temp");

                foreach (System.IO.FileInfo file in di.GetFiles())
                {
                    file.Delete();
                }
                foreach (DirectoryInfo dir in di.GetDirectories())
                {
                    dir.Delete(true);
                }
            } catch (Exception e)
            {
                Console.WriteLine("Unable to clear temp directory.");
            }


            try
            {
                Aspose.Words.License license = new Aspose.Words.License();
                var licenseResource          = "Flashcardgenerator.Aspose.Words.lic";

                license.SetLicense(licenseResource);

                Console.WriteLine("License set successfully.");
            }
            catch (Exception e)
            {
                // We do not ship any license with this example, visit the Aspose site to obtain either a temporary or permanent license.
                Console.WriteLine("\nThere was an error setting the license: " + e.Message);
            }


            OnConfigureServices(services);
        }
Ejemplo n.º 34
0
 /// <summary>
 /// Save word Report as pdf
 /// </summary>
 /// <param name="ms"></param>
 /// <param name="certificatePath"></param>
 public static void SaveWordReportAsPdf(MemoryStream ms, string certificatePath)
 {
     try
     {
         ms.Position = 0;
         //****By requirements definition. The reports originally made in Word are saved as Pdf
         Aspose.Words.License license = new Aspose.Words.License();
         license.SetLicense("Aspose.Words.lic");
         Aspose.Words.Document d = new Aspose.Words.Document(ms);
         ms.Close();
         using (System.IO.MemoryStream asposeStream = new System.IO.MemoryStream())
         {
             d.Save(asposeStream, Aspose.Words.SaveFormat.Pdf);
             asposeStream.Position = 0;
             byte[] bytes = new byte[asposeStream.Length];
             asposeStream.Read(bytes, 0, System.Convert.ToInt32(asposeStream.Length));
             //****End requirement definition
             using (System.IO.FileStream fs = System.IO.File.Create(certificatePath.Replace(".docx", ".pdf")))
                 asposeStream.WriteTo(fs);
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Ejemplo n.º 35
0
        public override void Execute(Action onSuccess, Action <Exception> onFailure)
        {
            try
            {
                StorageCredentials  storageCredentials      = new StorageCredentials(System.Environment.GetEnvironmentVariable("StorageAccountName", EnvironmentVariableTarget.Process), System.Environment.GetEnvironmentVariable("StorageKeyVault", EnvironmentVariableTarget.Process));
                CloudStorageAccount account                 = new CloudStorageAccount(storageCredentials, useHttps: true);
                CloudBlobClient     storageClient           = account.CreateCloudBlobClient();
                CloudBlobContainer  storageSupportContainer = storageClient.GetContainerReference("support");

                CloudBlockBlob blob = storageSupportContainer.GetBlockBlobReference("Aspose.Total.lic");
                blob.FetchAttributes();
                long   fileByteLength = blob.Properties.Length;
                Byte[] b = new Byte[fileByteLength];
                blob.DownloadToByteArray(b, 0);

                SharedFilesConfiguration.Current.AsposeLicense = b;

                blob = storageSupportContainer.GetBlockBlobReference("ETA_Form_9061_English_FINAL_11_(expires_January_31,2020).pdf");
                blob.FetchAttributes();
                fileByteLength = blob.Properties.Length;
                b = new Byte[fileByteLength];
                blob.DownloadToByteArray(b, 0);

                SharedFilesConfiguration.Current.Form9061 = b;

                blob = storageSupportContainer.GetBlockBlobReference("8850-page2.docx");
                blob.FetchAttributes();
                fileByteLength = blob.Properties.Length;
                b = new Byte[fileByteLength];
                blob.DownloadToByteArray(b, 0);

                SharedFilesConfiguration.Current.Form8850Page2 = b;

                blob = storageSupportContainer.GetBlockBlobReference("WOTCCover.docx");
                blob.FetchAttributes();
                fileByteLength = blob.Properties.Length;
                b = new Byte[fileByteLength];
                blob.DownloadToByteArray(b, 0);

                SharedFilesConfiguration.Current.CoverLetter = b;

                Aspose.Words.License wordsLicense = new Aspose.Words.License();
                wordsLicense.SetLicense(new MemoryStream(SharedFilesConfiguration.Current.AsposeLicense));

                Aspose.Pdf.License pdfLicense = new Aspose.Pdf.License();
                pdfLicense.SetLicense(new MemoryStream(SharedFilesConfiguration.Current.AsposeLicense));

                string filename = string.Format("{0}_{1}_{2}_{3}_{4}_{5}_{6}_{7}.pdf",
                                                State,
                                                StartDate.Month,
                                                StartDate.Day,
                                                StartDate.Year,
                                                EndDate.Month,
                                                EndDate.Day,
                                                EndDate.Year,
                                                DateTime.Now.Ticks);

                MongoClient    client   = new MongoClient(System.Environment.GetEnvironmentVariable("ScreeningCosmosDb", EnvironmentVariableTarget.Process));
                IMongoDatabase database = client.GetDatabase("Screening");
                IMongoCollection <BsonDocument> collection = database.GetCollection <BsonDocument>("Screening");

                if (Screenings != null)
                {
                    Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document();

                    foreach (var screening in Screenings.OrderBy(s => s.Applicant.LastName + "_" + s.Applicant.FirstName))
                    {
                        Aspose.Pdf.Document form8850Pdf = new Aspose.Pdf.Document(RenderIRSForm8850Page2(screening));
                        pdfDocument.Pages.Add(form8850Pdf.Pages);

                        Aspose.Pdf.Document form9061Pdf = new Aspose.Pdf.Document(RenderIRSForm9061(screening));
                        pdfDocument.Pages.Add(form9061Pdf.Pages);

                        var jsonObject = JObject.FromObject(screening);

                        jsonObject.Add("Type", "StateSubmissionRecord");
                        jsonObject.Add("State", State);
                        jsonObject.Add("DatePrepared", DateTime.Now.ToString());
                        jsonObject.Add("FileProduced", string.Empty);
                        jsonObject.Add("DateSent", string.Empty);
                        jsonObject.Add("DateValidated", string.Empty);
                        jsonObject.Add("OutputFile", filename);

                        collection.InsertOne(
                            MongoDB.Bson.Serialization.BsonSerializer.Deserialize <BsonDocument>(jsonObject.ToString()));
                    }

                    Aspose.Pdf.Document wotcCoverPdf = new Aspose.Pdf.Document(RenderCoverLetter("Address Goes Here", "Salutation Goes Here", Screenings));
                    pdfDocument.Pages.Add(wotcCoverPdf.Pages);

                    MemoryStream stream = new MemoryStream();
                    pdfDocument.Save(stream);

                    CloudBlobContainer storagePackageContainer = storageClient.GetContainerReference("statepackages");
                    storagePackageContainer.CreateIfNotExists(BlobContainerPublicAccessType.Off);

                    blob = storagePackageContainer.GetBlockBlobReference(filename);

                    if (stream.Length == 0)
                    {
                        return;
                    }
                    blob.UploadFromStream(stream, stream.Length, null, null, null);
                }

                string filter = string.Format("{{ Type: 'StateSubmissionRecord', OutputFile : '{0}'}}", filename);
                var    update = Builders <BsonDocument> .Update.Set("FileProduced", DateTime.Now.ToString());

                collection.UpdateMany(filter, update);
            }
            catch (Exception e)
            {
                onFailure(e);
            }

            onSuccess();
        }
Ejemplo n.º 36
0
 internal static void RemoveLicense()
 {
     Aspose.Words.License license = new Aspose.Words.License();
     license.SetLicense("");
 }
        public BaseApiResponse UploadDocument(int CompanyNo)
        {
            var response      = new BaseApiResponse();
            int FileversionID = 0;

            try
            {
                var modal = HttpContext.Current.Request.Form[0];
                var data  = (Newtonsoft.Json.Linq.JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(modal);
                if (data == null)
                {
                    response.Success = false;
                }
                bool isFileUploaded = HttpContext.Current.Request.Files.AllKeys.Any();
                int  rcvdid         = 0;
                if (Convert.ToInt32(data["PartNo"]) > 0 && Convert.ToInt32(data["FileTypeId"]) == 11)
                {
                    if (Convert.ToInt32(data["RecordTypeId"]) != 41 && Convert.ToInt32(data["RecordTypeId"]) != 137)
                    {
                        int compdateResult = 0;
                        try
                        {
                            SqlParameter[] paramCompDate = { new SqlParameter("OrderId", (object)Convert.ToInt32(data["OrderId"]) ?? (object)DBNull.Value)
                                                             ,                           new SqlParameter("PartNo", (object)Convert.ToInt32(data["PartNo"]) ?? (object)DBNull.Value) };
                            compdateResult = _repository.ExecuteSQL <int>("UpdateCompDate", paramCompDate).FirstOrDefault();
                        }
                        catch (Exception ex)
                        {
                        }
                    }


                    try
                    {
                        SqlParameter[] param = { new SqlParameter("OrderId", (object)Convert.ToInt32(data["OrderId"]) ?? (object)DBNull.Value)
                                                 ,                           new SqlParameter("PartNo", (object)Convert.ToInt32(data["PartNo"]) ?? (object)DBNull.Value)
                                                 ,                           new SqlParameter("RecordTypeId", (object)Convert.ToInt32(data["RecordTypeId"]) ?? (object)DBNull.Value)
                                                 ,                           new SqlParameter("PageNo", (object)Convert.ToInt32(data["PageNo"]) ?? (object)DBNull.Value)
                                                 ,                           new SqlParameter("EmpId", (object)data["EmpId"].ToString() ?? (object)DBNull.Value)
                                                 ,                           new SqlParameter("isFileUploaded", (object)isFileUploaded ?? (object)DBNull.Value) };
                        rcvdid = _repository.ExecuteSQL <int>("InsertFileRCVD", param).FirstOrDefault();
                    }
                    catch (Exception ex)
                    {
                    }
                }

                string tempPath   = ConfigurationManager.AppSettings["TempStorageDirectory"].ToString();
                string serverPath = ConfigurationManager.AppSettings["UploadRoot"].ToString();
                string subFolder  = Convert.ToInt32(data["PartNo"]) <= 0 ? "/" + data["OrderId"].ToString() : "/" + data["OrderId"].ToString() + "/" + data["PartNo"].ToString();
                serverPath += subFolder;
                if (!Directory.Exists(serverPath))
                {
                    Directory.CreateDirectory(serverPath);
                }
                string tempFullPath = tempPath + subFolder;
                if (!Directory.Exists(tempFullPath))
                {
                    Directory.CreateDirectory(tempFullPath);
                }
                Guid CreatedByGUID = new Guid(data["CreatedBy"].ToString());
                int  RecordTypeID  = 0;

                try
                {
                    RecordTypeID = Convert.ToInt32(data["RecordTypeId"]);
                }
                catch (Exception Ex)
                {
                }



                if (HttpContext.Current.Request.Files.AllKeys.Any())
                {
                    for (int i = 0; i < HttpContext.Current.Request.Files.Count; i++)
                    {
                        var    httpPostedFile = HttpContext.Current.Request.Files[i];
                        string FileExtension  = System.IO.Path.GetExtension(httpPostedFile.FileName);
                        string fileType       = FileExtension;
                        string FileName       = httpPostedFile.FileName;
                        string fileGuid       = Guid.NewGuid().ToString();

                        string fDiskName = fileGuid + FileExtension;
                        httpPostedFile.SaveAs(tempPath + "/" + subFolder + "/" + fileGuid + FileExtension);
                        if (!string.IsNullOrEmpty(FileExtension) && (FileExtension.ToUpper() == ".DOC" || FileExtension.ToUpper() == ".DOCX"))
                        {
                            FileExtension = ".Pdf";
                        }
                        string FileDiskName = fileGuid + FileExtension;   //DateTime.Now.ToString("yyyyMMddHHmmssfff")


                        SqlParameter[] param = { new SqlParameter("OrderId", (object)Convert.ToInt32(data["OrderId"]) ?? (object)DBNull.Value)
                                                 ,                           new SqlParameter("PartNo", (object)Convert.ToInt32(data["PartNo"]) ?? (object)DBNull.Value)
                                                 ,                           new SqlParameter("FileName", (object)FileName ?? (object)DBNull.Value)
                                                 ,                           new SqlParameter("FileTypeId", (object)Convert.ToInt32(data["FileTypeId"]) ?? (object)DBNull.Value)
                                                 ,                           new SqlParameter("IsPublic", (object)Convert.ToBoolean(data["IsPublic"]) ?? (object)DBNull.Value)
                                                 ,                           new SqlParameter("RecordTypeId", (object)Convert.ToInt32(data["RecordTypeId"]) ?? (object)DBNull.Value)
                                                 ,                           new SqlParameter("FileDiskName", (object)FileDiskName ?? (object)DBNull.Value)
                                                 ,                           new SqlParameter("PageNo", (object)Convert.ToInt32(data["PageNo"]) ?? (object)DBNull.Value)
                                                 ,                           new SqlParameter("CreatedBy", (object)CreatedByGUID ?? (object)DBNull.Value) };

                        var result = _repository.ExecuteSQL <int>("InsertFile", param).FirstOrDefault();
                        FileversionID = result;
                        if (result > 0)
                        {
                            FileDiskName            = fDiskName;
                            FileExtension           = fileType;
                            response.lng_InsertedId = result;
                            response.Success        = true;

                            #region SaveFileTypeRecordBillFirm
                            SqlParameter[] paramBillFirm  = { new SqlParameter("OrderId", (object)Convert.ToInt32(data["OrderId"]) ?? (object)DBNull.Value) };
                            var            resultbillFirm = _repository.ExecuteSQL <FileTypeRecordBillFirm>("GetDetailforFileTypeRecordBillFirm", paramBillFirm).FirstOrDefault();
                            if (resultbillFirm != null)//(Convert.ToInt32(data["RecordTypeId"]) != 0)
                            {
                                string AttyName = resultbillFirm.AttorneyName;
                                string BillFirm = resultbillFirm.OrderingFirmID;
                                string ClaimNo  = resultbillFirm.BillingClaimNo;
                                if (BillFirm == null || BillFirm == "")
                                {
                                    // continue;
                                }
                                System.IO.MemoryStream ms = new System.IO.MemoryStream();


                                Aspose.Pdf.License license = new Aspose.Pdf.License();
                                license.SetLicense("Aspose.Pdf.lic");

                                Aspose.Words.License license1 = new Aspose.Words.License();
                                license1.SetLicense("Aspose.Words.lic");
                                string tmpFullPath = tempPath + "/" + subFolder + "/" + FileDiskName;

                                if (!string.IsNullOrEmpty(FileExtension) && FileExtension.ToUpper() == ".DOC" || FileExtension.ToUpper() == ".DOCX")
                                {
                                    Aspose.Words.Document doc = new Aspose.Words.Document((tmpFullPath));
                                    doc.Save(Path.Combine(serverPath, fileGuid + ".pdf"));
                                    File.Delete((tmpFullPath));
                                }
                                else if (!string.IsNullOrEmpty(FileExtension) && FileExtension.ToUpper() == ".PDF")
                                {
                                    Aspose.Pdf.Document doc = new Aspose.Pdf.Document((tmpFullPath));
                                    doc.Save(Path.Combine(serverPath, fileGuid + ".pdf"));
                                    File.Delete((tmpFullPath));
                                }
                                else
                                {
                                    File.Copy((tmpFullPath), Path.Combine(serverPath, FileDiskName));
                                    File.Delete((tmpFullPath));
                                }

                                string TStamp       = DateTime.Now.ToString("yyyyMMddHHmmssfff");
                                string _storageRoot = string.Empty;
                                string FilePath     = string.Empty;

                                if (ClaimNo == "")
                                {
                                    ClaimNo = "0";
                                }
                                if (FileExtension == "doc" || FileExtension == "DOC" || FileExtension == "docx" || FileExtension == "DOCX")
                                {
                                    FileExtension = "pdf";
                                }

                                if (BillFirm == "GRANCO01")
                                {
                                    _storageRoot = ConfigurationManager.AppSettings["GrangeRoot"].ToString();
                                    FilePath     = _storageRoot + string.Format("{0}-{1}-{2}-{3}", ClaimNo, TStamp, data["OrderId"].ToString(), data["PartNo"].ToString() + "." + FileExtension);
                                }
                                if (BillFirm == "HANOAA01")
                                {
                                    _storageRoot = ConfigurationManager.AppSettings["HanoverRoot"].ToString();
                                    FilePath     = _storageRoot + string.Format("{0}_{1}_{2}_{3}-{4}", ClaimNo, AttyName, TStamp, data["OrderId"].ToString(), data["PartNo"].ToString() + "." + FileExtension);
                                }
                                if (BillFirm == "GRANCO01" || BillFirm == "HANOAA01")
                                {
                                    System.IO.DirectoryInfo dis = new System.IO.DirectoryInfo(_storageRoot);
                                    if (!dis.Exists)
                                    {
                                        dis.Create();
                                    }
                                    int    count        = 1;
                                    string fileNameOnly = Path.GetFileNameWithoutExtension(FilePath);
                                    string extension    = Path.GetExtension(FilePath);
                                    string path         = Path.GetDirectoryName(FilePath);
                                    string newFullPath  = FilePath;

                                    while (System.IO.File.Exists(newFullPath))
                                    {
                                        string tempFileName = string.Format("{0}({1})", fileNameOnly, count++);
                                        newFullPath = Path.Combine(path, tempFileName + extension);
                                    }

                                    FileStream fs = new FileStream(newFullPath, FileMode.Create, FileAccess.Write);
                                    ms.WriteTo(fs);
                                    fs.Close();
                                }
                            }
                            #endregion
                        }
                    }
                    Directory.Delete((tempPath + "/" + data["OrderId"].ToString()), true);



                    //TODO:Send Email
                    //http://localhost:51617/Secured/Data/GetMRBillingData.aspx/SendMailOnUploadDocument
                    try
                    {
                        BillingApiController bc = new BillingApiController();
                        int OrderID             = Convert.ToInt32(data["OrderId"]);
                        int PartNo = Convert.ToInt32(data["PartNo"]);
                        ApiResponse <BillToAttorneyDetailsEntity> objBillToDetails = bc.GetBillToAttorneyDetailsByOrderId(OrderID.ToString(), PartNo.ToString());
                        ApiResponse <SoldToAttorneyDetailsEntity> objSoldToDetails = bc.GetSoldToAttorneyDetailsByOrderId(OrderID.ToString(), PartNo.ToString());

                        ApiResponse <BillToAttorneyEntity> objBillToAttorney = new ApiResponse <BillToAttorneyEntity>();
                        ApiResponse <BillToAttorneyEntity> objSoldtoAttorney = new ApiResponse <BillToAttorneyEntity>();

                        if (objSoldToDetails.Data.Count > 0)
                        {
                            objSoldtoAttorney = bc.GetSoldToAttorneyByOrderNo(OrderID.ToString(), PartNo.ToString());
                        }

                        if (objBillToDetails.Data.Count > 0)
                        {
                            objBillToAttorney = bc.GetBillToAttorneyByFirmId(objBillToDetails.Data[0].BillingFirmID);
                        }
                        string strBilltoAttorney = objBillToAttorney.Data.Count > 0 ? objBillToAttorney.Data[0].AttyId : "";

                        List <SoldAttorneyEntity> soldAttorneyList = new List <SoldAttorneyEntity>();


                        foreach (var item in objSoldtoAttorney.Data)
                        {
                            soldAttorneyList.Add(new SoldAttorneyEntity {
                                AttyId = item.AttyId, AttyType = "Ordering"
                            });
                        }

                        bc.GenerateInvoice(OrderID, PartNo, strBilltoAttorney, CompanyNo, soldAttorneyList, RecordTypeID, FileversionID);
                    }
                    catch (Exception ex)
                    {
                        Log.ServicLog("========== GENERATE BILL AFTER UPLOADING DOCUMENT ==================");
                        Log.ServicLog(ex.ToString());
                    }
                }

                // GENERATE BILL FOR THESE RECORD TYPE EVEN IF NO FILE IS UPLOADED
                // RecordTypeID = 50(Cd Of Films)
                // RecordTypeID = 41(Cancelled)
                // RecordTypeID = 168(Custodian Fee)
                else if (isFileUploaded || RecordTypeID == 50 || RecordTypeID == 41 || RecordTypeID == 168)
                {
                    #region --- GENERATE BILL ---
                    try
                    {
                        BillingApiController bc = new BillingApiController();
                        int OrderID             = Convert.ToInt32(data["OrderId"]);
                        int PartNo = Convert.ToInt32(data["PartNo"]);
                        ApiResponse <BillToAttorneyDetailsEntity> objBillToDetails = bc.GetBillToAttorneyDetailsByOrderId(OrderID.ToString(), PartNo.ToString());
                        ApiResponse <SoldToAttorneyDetailsEntity> objSoldToDetails = bc.GetSoldToAttorneyDetailsByOrderId(OrderID.ToString(), PartNo.ToString());

                        ApiResponse <BillToAttorneyEntity> objBillToAttorney = new ApiResponse <BillToAttorneyEntity>();
                        ApiResponse <BillToAttorneyEntity> objSoldtoAttorney = new ApiResponse <BillToAttorneyEntity>();

                        if (objSoldToDetails.Data.Count > 0)
                        {
                            objSoldtoAttorney = bc.GetSoldToAttorneyByOrderNo(OrderID.ToString(), PartNo.ToString());
                        }

                        if (objBillToDetails.Data.Count > 0)
                        {
                            objBillToAttorney = bc.GetBillToAttorneyByFirmId(objBillToDetails.Data[0].BillingFirmID);
                        }
                        string strBilltoAttorney = objBillToAttorney.Data.Count > 0 ? objBillToAttorney.Data[0].AttyId : "";

                        List <SoldAttorneyEntity> soldAttorneyList = new List <SoldAttorneyEntity>();


                        foreach (var item in objSoldtoAttorney.Data)
                        {
                            soldAttorneyList.Add(new SoldAttorneyEntity {
                                AttyId = item.AttyId, AttyType = "Ordering"
                            });
                        }

                        bc.GenerateInvoice(OrderID, PartNo, strBilltoAttorney, CompanyNo, soldAttorneyList, RecordTypeID, FileversionID);
                    }
                    catch (Exception ex)
                    {
                        Log.ServicLog("========== GENERATE BILL AFTER UPLOADING DOCUMENT ==================");
                        Log.ServicLog(ex.ToString());
                    }

                    #endregion

                    response.Success = true;
                }


                #region Send Mail
                if (Convert.ToInt32(data["FileTypeId"]) == 11 && isFileUploaded)
                {
                    try
                    {
                        SqlParameter[] param = { new SqlParameter("OrderId", (object)Convert.ToInt64(data["OrderId"]) ?? (object)DBNull.Value)
                                                 ,                           new SqlParameter("PartNo", (object)Convert.ToInt32(data["PartNo"]) ?? (object)DBNull.Value)
                                                 ,                           new SqlParameter("FileTypeId", (object)Convert.ToInt32(data["FileTypeId"]) ?? (object)DBNull.Value)
                                                 ,                           new SqlParameter("RecordTypeId", (object)Convert.ToInt32(data["RecordTypeId"]) ?? (object)DBNull.Value) };
                        var            result = _repository.ExecuteSQL <AssistContactEmail>("GetAssistContactEmailList", param).ToList();
                        if (result != null && result.Any(x => x.NewRecordAvailable))
                        {
                            CompanyDetailForEmailEntity objCompany = CommonFunction.CompanyDetailForEmail(CompanyNo);
                            string subject     = "Your Records Are Available " + Convert.ToString(data["OrderId"]) + "-" + Convert.ToString(data["PartNo"]);
                            string LiveSiteURL = ConfigurationManager.AppSettings["LiveSiteURL"].ToString();

                            foreach (AssistContactEmail item in result.Where(x => x.NewRecordAvailable && !string.IsNullOrEmpty(x.AssistantEmail)))
                            {
                                System.Text.StringBuilder body = new System.Text.StringBuilder();
                                using (System.IO.StreamReader reader = new System.IO.StreamReader(HttpContext.Current.Server.MapPath("~/MailTemplate/BillingRecords.html")))
                                {
                                    body.Append(reader.ReadToEnd());
                                }

                                body = body.Replace("{UserName}", "Hello " + item.AssistantName + ",");
                                body = body.Replace("{LOCATION}", item.LocationName + " (" + item.LocID + ")");
                                body = body.Replace("{PATIENT}", item.PatientName);
                                body = body.Replace("{CLAIMNO}", item.BillingClaimNo);
                                body = body.Replace("{ORDERNO}", data["OrderId"] + "-" + data["PartNo"]);
                                body = body.Replace("{InvHdr}", item.InvHdr);
                                body = body.Replace("{Pages}", Convert.ToString(data["PageNo"]));
                                body = body.Replace("{LINK}", Convert.ToString(objCompany.SiteURL) + "/PartDetail?OrderId=" + data["OrderId"] + "&PartNo=" + data["PartNo"]);
                                body = body.Replace("{LogoURL}", objCompany.Logopath);
                                body = body.Replace("{ThankYou}", objCompany.ThankYouMessage);
                                body = body.Replace("{CompanyName}", objCompany.CompName);
                                body = body.Replace("{Link}", objCompany.SiteURL);

                                EmailHelper.Email.Send(CompanyNo: objCompany.CompNo
                                                       , mailTo: item.AssistantEmail
                                                       , body: body.ToString()
                                                       , subject: subject
                                                       , ccMail: ""
                                                       , bccMail: "[email protected],[email protected]");
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.ServicLog("========== Email for UPLOADING DOCUMENT ==================");
                        Log.ServicLog(ex.ToString());
                    }
                }
                #endregion
                #region Send Mail To Client Of Employee
                bool IsAttorneyLogin;

                try
                {
                    if (bool.TryParse(Convert.ToString(data["IsAttorneyLogin"]), out IsAttorneyLogin) && IsAttorneyLogin)
                    {
                        SqlParameter[] param        = { new SqlParameter("OrderId", (object)Convert.ToInt64(data["OrderId"]) ?? (object)DBNull.Value) };
                        var            clientOfUser = _repository.ExecuteSQL <AccntRepDetails>("GetClientOfEmailByOrderId", param).FirstOrDefault();
                        if (clientOfUser != null && !string.IsNullOrEmpty(clientOfUser.Email))
                        {
                            CompanyDetailForEmailEntity objCompany = CommonFunction.CompanyDetailForEmail(CompanyNo);

                            string subject     = "Document uploaded by client " + Convert.ToString(data["OrderId"]) + "-" + Convert.ToString(data["PartNo"]);
                            string LiveSiteURL = ConfigurationManager.AppSettings["LiveSiteURL"].ToString();

                            System.Text.StringBuilder body = new System.Text.StringBuilder();
                            using (System.IO.StreamReader reader = new System.IO.StreamReader(HttpContext.Current.Server.MapPath("~/MailTemplate/DocumentUploadedByClient.html")))
                            {
                                body.Append(reader.ReadToEnd());
                            }

                            body = body.Replace("{UserName}", clientOfUser.Name);
                            body = body.Replace("{ORDERNO}", data["OrderId"] + "-" + data["PartNo"]);
                            body = body.Replace("{LINK}", Convert.ToString(objCompany.SiteURL) + "/PartDetail?OrderId=" + data["OrderId"] + "&PartNo=" + data["PartNo"]);
                            body = body.Replace("{LogoURL}", objCompany.Logopath);
                            body = body.Replace("{ThankYou}", objCompany.ThankYouMessage);
                            body = body.Replace("{CompanyName}", objCompany.CompName);
                            body = body.Replace("{Link}", objCompany.SiteURL);

                            EmailHelper.Email.Send(CompanyNo: objCompany.CompNo
                                                   , mailTo: clientOfUser.Email
                                                   , body: body.ToString()
                                                   , subject: subject
                                                   , ccMail: ""
                                                   , bccMail: "[email protected],[email protected]");
                        }
                    }
                }
                catch (Exception ex)
                {
                    Log.ServicLog("========== Email for UPLOADING DOCUMENT ==================");
                    Log.ServicLog(ex.ToString());
                }
                #endregion
                if (!isFileUploaded)
                {
                    response.Success = true;
                }
            }
            catch (Exception ex)
            {
                response.Message.Add(ex.Message);
            }

            return(response);
        }
Ejemplo n.º 38
0
        public HttpResponseMessage GetPrintCheckIIFFiles(DateTime fromDate, DateTime toDate, string checkNo, string checkId)
        {
            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK);

            try
            {
                SqlParameter[] param = { new SqlParameter("dtFrom", (object)fromDate.ToString("MM/dd/yyyy") ?? (object)DBNull.Value),
                                         new SqlParameter("dtTo",   (object)toDate.ToString("MM/dd/yyyy") ?? (object)DBNull.Value) };
                var            result = _repository.ExecuteSQL <LocationFeeCheckIIF>("GetLocationFeeCheckIIF", param).ToList();
                if (!string.IsNullOrEmpty(checkId) && !string.IsNullOrEmpty(checkNo))
                {
                    int      chkno = Convert.ToInt32(checkNo);
                    string[] s     = checkId.Split(',');
                    for (int i = 0; i < s.Length; i++)
                    {
                        UpdateCheckNo(Convert.ToInt32(s[i]), chkno);
                        chkno = chkno + 1;
                    }
                }
                if (!string.IsNullOrEmpty(checkId))
                {
                    var chkIdList = checkId.Split(',').Select(n => Convert.ToInt64(n)).ToArray();
                    result = result.Where(x => chkIdList.Contains(x.ChkID)).ToList();
                }
                else
                {
                    List <string> list         = result.Select(x => string.IsNullOrEmpty(x.ChkNo) ? "0" : x.ChkNo).ToList();
                    string[]      greatervalue = list.Where(x => Convert.ToInt64(x) >= Convert.ToInt64(checkNo)).OrderByDescending(x => x).ToArray();
                    result = result.Where(x => greatervalue.Contains(x.ChkNo)).OrderBy(x => x.OrderNo).ThenBy(x => x.PartNo).ToList();
                }

                var dt = Common.CommonHelper.ToDataTable(result);
                foreach (DataRow dr in dt.Rows)
                {
                    dr["AmountInWords"] = NumWords.FormatAmount(NumWords.Convert(Convert.ToDecimal(dr["ChkAmt"])));
                }
                Aspose.Words.License license = new Aspose.Words.License();
                license.SetLicense("Aspose.Words.lic");
                string                fileName = "ChequeFormat.doc";
                string                path     = HttpContext.Current.Server.MapPath("~/PrintFolder/" + fileName);
                MemoryStream          ms       = new MemoryStream();
                Aspose.Words.Document doc      = new Aspose.Words.Document(path);
                doc.MailMerge.Execute(dt);
                System.Collections.IEnumerator enumerator = dt.Rows.GetEnumerator();
                doc.Save(ms, Aspose.Words.SaveFormat.Pdf);

                string PDFpath              = HttpContext.Current.Server.MapPath("~/PrintCheck/");
                string fileNames            = DateTime.Now.ToString("yyyy-MM-dd");
                string FullPathWithFileName = Path.Combine(PDFpath, fileNames + ".pdf");
                if (File.Exists(FullPathWithFileName))
                {
                    File.Delete(FullPathWithFileName);
                }

                FileStream file = new FileStream(FullPathWithFileName, FileMode.CreateNew, FileAccess.ReadWrite);
                ms.WriteTo(file);
                file.Close();
                ms.Close();

                byte[] bytes = File.ReadAllBytes(FullPathWithFileName);
                using (FileStream stream = new FileStream(FullPathWithFileName, FileMode.Create))
                {
                    stream.Write(bytes, 0, bytes.Length);
                }
                response.Content = new ByteArrayContent(bytes);

                response.Content.Headers.Clear();
                response.Content.Headers.Add("Content-Disposition", "attachment; filename=" + fileNames + ".pdf");
                response.Content.Headers.Add("Content-Length", bytes.Length.ToString());
                response.Content.Headers.ContentType = new MediaTypeHeaderValue(MimeMapping.GetMimeMapping("application/pdf"));
            }
            catch (Exception ex)
            {
            }
            return(response);
        }
        private void PrintVat()
        {
            Aspose.Words.License license = new Aspose.Words.License();
            license.SetLicense("Aspose.Words.lic");
            //Open template
            string docPath = Context.Server.MapPath("~/DesktopModules/TrainingCoreBanking/BankProject/Report/Template/CollectCharge/CollectChargeVAT.doc");
            //Open the template document
            Aspose.Words.Document document = new Aspose.Words.Document(docPath);
            //Execute the mail merge.

            var ds = BankProject.DataProvider.Database.BCOLLECTCHARGESBYCASH_Print_GetByCode(txtId.Text);
            document.MailMerge.ExecuteWithRegions(ds.Tables[0]);
            // Send the document in Word format to the client browser with an option to save to disk or open inside the current browser.
            document.Save("BCOLLECTCHARGESBYCASH_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".doc", Aspose.Words.SaveFormat.Doc, Aspose.Words.SaveType.OpenInBrowser, Response);
        }