Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CollectorForm"/> class.
        /// </summary>
        /// <remarks>Documented by Dev05, 2007-09-27</remarks>
        public CollectorForm()
        {
            InitializeComponent();
            cardEdit.HelpNamespace = this.HelpFile;

            OpenFileDialog openDlg = new OpenFileDialog();

            openDlg.Filter = "Dictionary|*.odx";
            if (openDlg.ShowDialog() == DialogResult.OK)
            {
                if (dictionary != null)
                {
                    dictionary.Dispose();
                }
                MLifter.DAL.Interfaces.IUser user = UserFactory.Create((GetLoginInformation)MLifter.Controls.LoginForm.OpenLoginForm,
                                                                       new ConnectionStringStruct(DatabaseType.Xml, openDlg.FileName, true),
                                                                       (DataAccessErrorDelegate) delegate(object sender, Exception e) { MessageBox.Show(e.ToString()); }, this);
                dictionary = new Dictionary(user.Open(), null);
            }
            else
            {
                Close();
            }

            tableCards.NoItemsText = Properties.Resources.TABLECARDS_NOITEMSTEXT;
        }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CollectorForm"/> class.
        /// </summary>
        /// <param name="Dictionary">The dictionary.</param>
        /// <remarks>Documented by Dev05, 2007-10-02</remarks>
        public CollectorForm(string Dictionary)
        {
            ShowInTaskbar = false;
            InitializeComponent();
            cardEdit.HelpNamespace = this.HelpFile;

            if (dictionary != null)
            {
                dictionary.Dispose();
            }
            MLifter.DAL.Interfaces.IUser user = UserFactory.Create((GetLoginInformation)MLifter.Controls.LoginForm.OpenLoginForm,
                                                                   new ConnectionStringStruct(DatabaseType.Xml, Dictionary, true),
                                                                   (DataAccessErrorDelegate) delegate(object sender, Exception e) { MessageBox.Show(e.ToString()); }, this);
            dictionary = new Dictionary(user.Open(), null);

            tableCards.NoItemsText = Properties.Resources.TABLECARDS_NOITEMSTEXT;
        }
 public void IDictionaryIOExceptionTest()
 {
     TestInfrastructure.DebugLineStart(TestContext);
     //This test will only execute, when using a File-Connection-String
     if (TestInfrastructure.IsActive(TestContext) && TestContext.DataRow["Type"].ToString() == "File")
     {
         using (IDictionary testLM = TestInfrastructure.GetLMConnection(TestContext, string.Empty, false))
         {
             testLM.Save();
             MLifter.DAL.Interfaces.IUser user = UserFactory.Create((GetLoginInformation) delegate(UserStruct u, ConnectionStringStruct c) { return(u); },
                                                                    testLM.Parent.CurrentUser.ConnectionString, (DataAccessErrorDelegate) delegate { return; }, TestContext);
             IDictionary testLM2 = user.Open();
         }
     }
     else
     {
         throw new System.IO.IOException();
     }
     TestInfrastructure.DebugLineEnd(TestContext);
 }
Beispiel #4
0
        /// <summary>
        /// Handles the Click event of the buttonStart control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        /// <remarks>Documented by Dev02, 2008-03-17</remarks>
        private void buttonStart_Click(object sender, EventArgs e)
        {
            if (BusinessLayer.WorkingThreadActive)
            {
                BusinessLayer.AbortWorkingThread();
                return;
            }

            textBoxLog.Clear();
            tracelistener.LogMessages.Clear();

            //check if input file exists
            if (!File.Exists(textBoxLearningModule.Text))
            {
                BusinessLayer.AddLog("The specified learning module file cannot be found");
                return;
            }

            //check if any audio fields are selected
            if (listViewPlaybackSequence.Items.Count == 0)
            {
                BusinessLayer.AddLog("Please select at least one field for the playback sequence");
                return;
            }

            IDictionary dictionary = null;

            try
            {
                AudioBookOptions options = new AudioBookOptions();

                //add mono/stereo selection to options
                options.Stereo = radioButtonStereo.Checked;

                //add selected fields to the options
                foreach (ListViewItem lvi in listViewPlaybackSequence.Items)
                {
                    MediaField mediafield = lvi.Tag as MediaField;
                    if (mediafield != null)
                    {
                        options.MediaFields.Add(mediafield);
                    }
                }

                //check for valid file paths
                FileInfo dictionaryfile = null, audiobook = null;
                try
                {
                    dictionaryfile = new FileInfo(textBoxLearningModule.Text);
                    audiobook      = new FileInfo(textBoxAudiobook.Text);
                    if (string.IsNullOrEmpty(audiobook.Extension))
                    {
                        BusinessLayer.AddLog("Please enter a valid extension for the target audiobook file");
                        return;
                    }
                }
                catch
                {
                    BusinessLayer.AddLog("The specified file paths are not valid. Please check your input");
                    return;
                }

                //save file paths to settings as recent files
                Settings.Default.RecentLearningModule = dictionaryfile.FullName;
                Settings.Default.RecentAudioBook      = audiobook.FullName;
                Settings.Default.Save();

                //open learning module and start audio book generation
                try
                {
                    ConnectionStringStruct       css  = new ConnectionStringStruct(DatabaseType.MsSqlCe, dictionaryfile.FullName);
                    MLifter.DAL.Interfaces.IUser user = UserFactory.Create((GetLoginInformation)MLifter.Controls.LoginForm.OpenLoginForm, css, (DataAccessErrorDelegate) delegate { return; }, this);
                    css.LmId = User.GetIdOfLearningModule(dictionaryfile.FullName, user);
                    user.ConnectionString = css;
                    dictionary            = user.Open();
                }
                catch (System.IO.IOException)
                {
                    BusinessLayer.AddLog("The Learning Module file could not be accessed. Please make sure that it is not open within another program (e.g. MemoryLifter)");
                    return;
                }
                catch (System.Xml.XmlException)
                {
                    BusinessLayer.AddLog("The Learning Module file does not seem to be in a valid format");
                    return;
                }
                catch (ProtectedLearningModuleException)
                {
                    BusinessLayer.AddLog("The Learning Module could not be opened: It is content protected");
                    return;
                }
                catch (Exception exp)
                {
                    BusinessLayer.AddLog("The Learning Module file could not be opened:" + Environment.NewLine + exp.Message);
                    return;
                }
                buttonStart.Text = "Cancel";
                BusinessLayer.GenerateAudioBook(dictionary, audiobook, options, codecs);
            }
            catch (Exception exp)
            {
                BusinessLayer.AddLog("Audio book generation exception happened: " + Environment.NewLine + exp.ToString());
                return;
            }
            finally
            {
                if (dictionary != null)
                {
                    dictionary.Dispose();
                }
            }
        }