Пример #1
0
        protected override void Invoke(object parameter)
        {
            try
            {
                RoutedEventArgs eventArgs = parameter as RoutedEventArgs;
                if (eventArgs != null)
                {
                    Button exportBtn = eventArgs.OriginalSource as Button;
                    if (exportBtn != null)
                    {
                        switch (exportBtn.Content.ToString())
                        {
                        case "New Document":
                            System.IO.File.Copy(appLocation + @"..\..\TemplateDocument\Document.doc", appLocation + @"..\..\OutputDocument\Document.doc", true);
                            OlapChartWordExport chartWordExport = new OlapChartWordExport(this.Target.OlapChart);
                            chartWordExport.ExportintoNewDoc(appLocation + @"..\..\OutputDocument\Document.doc");
                            if (MessageBox.Show("Do you want to view the MS Word document?", "Document has been created", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes)
                            {
                                System.Diagnostics.Process.Start(appLocation + @"..\..\OutputDocument\Document.doc");
                            }
                            break;

                        case "Default Marker":
                            System.IO.File.Copy(appLocation + @"..\..\TemplateDocument\Document.doc", appLocation + @"..\..\OutputDocument\Document.doc", true);
                            OlapChartWordExport chartMarkerWordExport = new OlapChartWordExport(this.Target.OlapChart);
                            chartMarkerWordExport.ExportIntoTemplateDoc(appLocation + @"..\..\OutputDocument\Document.doc");
                            if (MessageBox.Show("Do you want to view the MS Word document?", "Document has been created", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes)
                            {
                                System.Diagnostics.Process.Start(appLocation + @"..\..\OutputDocument\Document.doc");
                            }
                            break;

                        case "Custom Marker":
                            System.IO.File.Copy(appLocation + @"..\..\TemplateDocument\Document.doc", appLocation + @"..\..\OutputDocument\Document.doc", true);
                            OlapChartWordExport chartCustomMarkerWordExport = new OlapChartWordExport(this.Target.OlapChart);
                            chartCustomMarkerWordExport.ExportIntoTemplateDoc(appLocation + @"..\..\OutputDocument\Document.doc", "MarkerString1");
                            if (MessageBox.Show("Do you want to view the MS Word document?", "Document has been created", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes)
                            {
                                System.Diagnostics.Process.Start(appLocation + @"..\..\OutputDocument\Document.doc");
                            }
                            break;

                        case "New Pdf Document":
                            OlapChartPdfExport chartPdfExport = new OlapChartPdfExport(this.Target.OlapChart);
                            chartPdfExport.ExportIntoNewPdf(@"..\..\TemplateDocument\PdfDocument.pdf");
                            if (MessageBox.Show("Do you want to view the PDF document?", "PDF has been created", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes)
                            {
                                System.Diagnostics.Process.Start(@"..\..\TemplateDocument\PdfDocument.pdf");
                            }
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error while exporting", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Пример #2
0
 protected override void Invoke(object parameter)
 {
     if (((parameter as RoutedEventArgs).Source as Button).Name == "btn3")
     {
         try
         {
             System.IO.File.Copy(appLocation + @"..\..\TemplateDocument\Document.doc", appLocation + @"..\..\OutputDocument\Document.doc", true);
             wordCoverter = new OlapChartWordExport(this.Target);
             wordCoverter.ExportintoNewDoc(appLocation + @"..\..\OutputDocument\Document.doc");
             if (MessageBox.Show("Do you want to view the MS Word document?", "Document has been created", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes)
             {
                 System.Diagnostics.Process.Start(appLocation + @"..\..\OutputDocument\Document.doc");
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
     else if (((parameter as RoutedEventArgs).Source as Button).Name == "btn4")
     {
         try
         {
             System.IO.File.Copy(appLocation + @"..\..\TemplateDocument\Document.doc", appLocation + @"..\..\OutputDocument\Document.doc", true);
             wordCoverter = new OlapChartWordExport(this.Target);
             wordCoverter.ExportIntoTemplateDoc(appLocation + @"..\..\OutputDocument\Document.doc");
             if (MessageBox.Show("Do you want to view the MS Word document?", "Document has been created", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes)
             {
                 System.Diagnostics.Process.Start(appLocation + @"..\..\OutputDocument\Document.doc");
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
     else if (((parameter as RoutedEventArgs).Source as Button).Name == "btn5")
     {
         try
         {
             System.IO.File.Copy(appLocation + @"..\..\TemplateDocument\Document.doc", appLocation + @"..\..\OutputDocument\Document.doc", true);
             wordCoverter = new OlapChartWordExport(this.Target);
             wordCoverter.ExportIntoTemplateDoc(appLocation + @"..\..\OutputDocument\Document.doc", "MarkerString1");
             if (MessageBox.Show("Do you want to view the MS Word document?", "Document has been created", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes)
             {
                 System.Diagnostics.Process.Start(appLocation + @"..\..\OutputDocument\Document.doc");
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
     else if (((parameter as RoutedEventArgs).Source as Button).Name == "btn6")
     {
         try
         {
             pdfConverter = new OlapChartPdfExport(this.Target);
             pdfConverter.ExportIntoNewPdf(@"..\..\TemplateDocument\PdfDocument.pdf");
             if (MessageBox.Show("Do you want to view the PDF document?", "PDF has been created", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes)
             {
                 System.Diagnostics.Process.Start(@"..\..\TemplateDocument\PdfDocument.pdf");
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
 }
Пример #3
0
        protected override void Invoke(object parameter)
        {
            string wordpath   = "";
            string pdfpath    = "";
            string outputpath = "";

            if (AppDomain.CurrentDomain.BaseDirectory.Contains("Binaries"))
            {
                wordpath   = System.IO.Path.GetFullPath(@"..\Data\olapchart\TemplateDocument\Document.doc");
                outputpath = System.IO.Path.GetFullPath(@"..\Data\olapchart\OutputDocument\Document.doc");
                pdfpath    = System.IO.Path.GetFullPath(@"..\Data\olapchart\TemplateDocument\PdfDocument.pdf");
            }
            else
            {
                wordpath   = System.IO.Path.GetFullPath(@"..\..\Data\olapchart\TemplateDocument\Document.doc");
                outputpath = System.IO.Path.GetFullPath(@"..\..\Data\olapchart\OutputDocument\Document.doc");
                pdfpath    = System.IO.Path.GetFullPath(@"..\..\Data\olapchart\TemplateDocument\PdfDocument.pdf");
            }
            if (((parameter as RoutedEventArgs).Source as Button).Name == "btn3")
            {
                try
                {
                    System.IO.File.Copy(wordpath, outputpath, true);
                    wordCoverter = new OlapChartWordExport(this.Target);
                    wordCoverter.ExportintoNewDoc(outputpath);
                    if (MessageBox.Show("Do you want to view the MS Word document?", "Document has been created", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes)
                    {
                        System.Diagnostics.Process.Start(outputpath);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            else if (((parameter as RoutedEventArgs).Source as Button).Name == "btn4")
            {
                try
                {
                    System.IO.File.Copy(wordpath, outputpath, true);
                    wordCoverter = new OlapChartWordExport(this.Target);
                    wordCoverter.ExportIntoTemplateDoc(outputpath);
                    if (MessageBox.Show("Do you want to view the MS Word document?", "Document has been created", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes)
                    {
                        System.Diagnostics.Process.Start(outputpath);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            else if (((parameter as RoutedEventArgs).Source as Button).Name == "btn5")
            {
                try
                {
                    System.IO.File.Copy(wordpath, outputpath, true);
                    wordCoverter = new OlapChartWordExport(this.Target);
                    wordCoverter.ExportIntoTemplateDoc(outputpath, "MarkerString1");
                    if (MessageBox.Show("Do you want to view the MS Word document?", "Document has been created", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes)
                    {
                        System.Diagnostics.Process.Start(outputpath);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            else if (((parameter as RoutedEventArgs).Source as Button).Name == "btn6")
            {
                try
                {
                    pdfConverter = new OlapChartPdfExport(this.Target);
                    pdfConverter.ExportIntoNewPdf(pdfpath);
                    if (MessageBox.Show("Do you want to view the PDF document?", "PDF has been created", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes)
                    {
                        System.Diagnostics.Process.Start(pdfpath);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }