Esempio n. 1
0
 internal ExportStatusReport(Exporter exporter, int cardCount)
 {
     this.exporter = exporter;
     CardCount     = cardCount;
     status        = new StatusMessageEventArgs(StatusMessageType.ExporterProgress, CardCount);
 }
Esempio n. 2
0
 internal ExportStatusReport(Exporter exporter, int cardCount)
 {
     this.exporter = exporter;
     CardCount = cardCount;
     status = new StatusMessageEventArgs(StatusMessageType.ExporterProgress, CardCount);
 }
Esempio n. 3
0
        /// <summary>
        /// Exports the dictionary.
        /// </summary>
        /// <remarks>Documented by Dev05, 2007-08-30</remarks>
        private void ExportDictionary()
        {
            if (exportChapterFrm.Total == 0 || exportFieldsFrm.StrOrder.Length == 0)
            {
                MessageBox.Show(Resources.EXPORTER_NOTHING_SELECTED_TEXT, Resources.EXPORTER_NOTHING_SELECTED_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            SaveFileDialog dlgExportFile = new SaveFileDialog();
            dlgExportFile.Title = Resources.EXPORT_SAVEDIALOG_TITLE;
            dlgExportFile.Filter = Resources.EXPORT_FILETYPE;
            dlgExportFile.AddExtension = true;
            dlgExportFile.OverwritePrompt = true;
            dlgExportFile.CreatePrompt = false;
            dlgExportFile.CheckPathExists = true;

            if (dlgExportFile.ShowDialog() == DialogResult.OK)
            {
                string separator;
                switch (cmbFileFormat.SelectedIndex)
                {
                    case 1:
                        separator = ";";
                        break;
                    case 2:
                        separator = "\t";
                        break;
                    case 0:
                    default:
                        separator = ",";
                        break;
                }

                string chapters = separator;
                foreach (int chapter in exportChapterFrm.SelChapters)
                    chapters += chapter + separator;

                # region header and fields
                string headerline = "";
                bool containsFiles = false;

                XmlDocument document = new XmlDocument();
                document.LoadXml("<fieldsToExport></fieldsToExport>");
                for (int i = 0; i < exportFieldsFrm.StrOrder.Length; i++)
                {
                    headerline += exportFieldsFrm.StrOrder[i];
                    headerline += separator;

                    string caption = exportFieldsFrm.StrOrder[i];
                    XmlNode node = document.CreateNode(XmlNodeType.Element, "fieldName", null);

                    if (isSameField(caption,Resources.LISTBOXFIELDS_QUESTION_DISTRACTORS_TEXT))
                    {
                        node.InnerText += "questiondistractors";
                    }
                    else if (isSameField(caption,Resources.LISTBOXFIELDS_ANSWER_DISTRACTORS_TEXT))
                    {
                        node.InnerText += "answerdistractors";
                    }
                    else if (isSameField(caption,Resources.LISTBOXFIELDS_ANSWER_TEXT))
                        node.InnerText += "answer";
                    else if (isSameField(caption,Resources.LISTBOXFIELDS_EXANSWER_TEXT))
                        node.InnerText += "answerexample";
                    else if (isSameField(caption,Resources.LISTBOXFIELDS_QUESTION_TEXT))
                        node.InnerText += "question";
                    else if (isSameField(caption,Resources.LISTBOXFIELDS_EXQUESTION_TEXT))
                        node.InnerText += "questionexample";
                    else if (isSameField(caption,Resources.LISTBOXFIELDS_IMAGE_ANSWER_TEXT))
                    {
                        node.InnerText += "answerimage";
                        containsFiles = true;
                    }
                    else if (isSameField(caption,Resources.LISTBOXFIELDS_IMAGE_QUESTION_TEXT))
                    {
                        node.InnerText += "questionimage";
                        containsFiles = true;
                    }
                    else if (isSameField(caption,Resources.LISTBOXFIELDS_SOUND_ANSWER_TEXT))
                    {
                        node.InnerText += "answeraudio";
                        containsFiles = true;
                    }
                    else if (isSameField(caption,Resources.LISTBOXFIELDS_SOUND_EXANSWER_TEXT))
                    {
                        node.InnerText += "answerexampleaudio";
                        containsFiles = true;
                    }
                    else if (isSameField(caption,Resources.LISTBOXFIELDS_SOUND_EXQUESTION_TEXT))
                    {
                        node.InnerText += "questionexampleaudio";
                        containsFiles = true;
                    }
                    else if (isSameField(caption,Resources.LISTBOXFIELDS_SOUND_QUESTION_TEXT))
                    {
                        node.InnerText += "questionaudio";
                        containsFiles = true;
                    }
                    else if (isSameField(caption,Resources.LISTBOXFIELDS_VIDEO_ANSWER_TEXT))
                    {
                        node.InnerText += "answervideo";
                        containsFiles = true;
                    }
                    else if (isSameField(caption,Resources.LISTBOXFIELDS_VIDEO_QUESTION_TEXT))
                    {
                        node.InnerText += "questionvideo";
                        containsFiles = true;
                    }
                    else if (caption == Resources.LISTBOXFIELDS_CHAPTER)
                        node.InnerText += "chapter";

                    document.DocumentElement.AppendChild(node);
                }
                headerline = headerline.Remove(headerline.LastIndexOf(separator));
                # endregion

                bool copyFiles = false;
                if (containsFiles)
                {
                    copyFiles = (0 == MLifter.Controls.TaskDialog.ShowCommandBox(Resources.EXPORTER_COPY_MEDIA_TITLE, Resources.EXPORTER_COPY_MEDIA_TEXT,
                        Resources.EXPORTER_COPY_MEDIA_CONTENT, string.Empty, string.Empty, string.Empty, Properties.Resources.EXPORTER_COPY_MEDIA_COMMANDS, false,
                        MLifter.Controls.TaskDialogIcons.Question, MLifter.Controls.TaskDialogIcons.Question));
                }

                statusDialog = new LoadStatusMessage(Properties.Resources.EXPORT_STATUS_CAPTION, 100, true);
                statusDialog.Show();

                bool exceptionhappened = false;
                try
                {
                    Exporter exporter = new Exporter();
                    exporter.ProgressChanged += new EventHandler<MLifter.DAL.Tools.StatusMessageEventArgs>(exporter_ProgressChanged);
                    exporter.ExportToCSV(dlgExportFile.FileName, Path.Combine(Application.StartupPath, @"Designs\System\Export\default.xsl"),
                        MainForm.LearnLogic.Dictionary.DictionaryDAL, separator, chapters, headerline, copyFiles, document);
                }
                catch (IOException exp)
                {
                    exceptionhappened = true;
                    MessageBox.Show(Properties.Resources.DIC_ERROR_SAVING_TEXT, Properties.Resources.DIC_ERROR_SAVING_CAPTION);
                    System.Diagnostics.Trace.WriteLine("Export file save exception: " + exp.ToString());
                }

                statusDialog.Hide();

                if (!exceptionhappened)
                    Close();
            }
        }