Example #1
0
        /// <summary>
        /// This code has to be in code behind because it manages view information
        /// Shows a csv version of the buglist view (in landscape format)
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">instance containing the event data</param>
        private void CSV(object sender, RoutedEventArgs e)
        {
            //path not exist -> create directory
            if (!Directory.Exists(this.buglistPath))
            {
                System.IO.Directory.CreateDirectory(this.buglistPath);
                if (!Directory.Exists(this.buglistPath))
                {
                    MessageBox.Show("Directory not exist", "error export buglist csv", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }
            }

            string fullCsvPath = this.buglistPath + this.buglistCsvName;

            try
            {
                var link = new PrintableControlLink(Buglist);
                link.Landscape = true;
                link.CreateDocument(true);
                link.ExportToCsv(fullCsvPath);

                //open file after create
                System.Diagnostics.Process.Start(fullCsvPath);
            }
            catch
            {
                //check if File is already in use
                bool fileInUse = HelpFunctions.Helpers.IsFileInUse(fullCsvPath);

                // inform user, that the file is not possible to open
                if (fileInUse == true)
                {
                    MessageBox.Show("File is already in use", "error export buglist csv", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }