/// <summary>
        /// Wird während der Ausführung periodisch aufgerufen.
        /// </summary>
        /// <param name="sender">Wird ignoriert.</param>
        /// <param name="e">Wird ignoriert.</param>
        private void ticker_Tick( object sender, EventArgs e )
        {
            // See if scanner is done
            if (!m_Scanner.Done)
                return;

            // Stop timer
            ticker.Enabled = false;

            // Final update
            UpdateCounter( null );

            // Prepare to terminate
            using (TransponderScanner scanner = m_Scanner)
            {
                // Forget
                m_Scanner = null;

                // Must finish
                try
                {
                    // Process all scan locations found
                    foreach (ScanLocation location in scanner.ScanLocations)
                    {
                        // Configure
                        if (!string.IsNullOrEmpty( location.UniqueName ))
                            dlgSave.FileName = location.UniqueName + "." + dlgSave.DefaultExt;

                        // Ask user what to do
                        if (DialogResult.OK != dlgSave.ShowDialog( this ))
                            continue;

                        // Update inner name
                        if (string.IsNullOrEmpty( location.DisplayName ))
                            location.DisplayName = Path.GetFileNameWithoutExtension( dlgSave.FileName );

                        // Create wrapper
                        ScanLocations save = new ScanLocations();

                        // Add this one
                        save.Locations.Add( location );

                        // Save to disk
                        save.Save( dlgSave.FileName );
                    }
                }
                finally
                {
                    // Report to site
                    m_Site.OperationDone();
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Wird in einem festen Interval aufgerufen und prüft, ob die Operation bereits abgeschlossen ist
        /// oder abgebrochen werden soll.
        /// </summary>
        /// <param name="sender">Wird ignoriert.</param>
        /// <param name="e">Wird ignoriert.</param>
        private void tickEnd_Tick( object sender, EventArgs e )
        {
            // See if scanner is done
            if (!m_Scanner.Done)
                return;

            // Stop timer
            tickEnd.Enabled = false;

            // Final update
            UpdateCounter( null );

            // Prepare to terminate
            using (TransponderScanner scanner = m_Scanner)
            {
                // Forget
                m_Scanner = null;

                // Must finish
                try
                {
                    // Create question
                    string quest = string.Format( Properties.Resources.Save_Profile, scanner.Profile.Name );

                    // Ask user
                    DialogResult saveMode = MessageBox.Show( this, quest, Properties.Resources.Save_Profile_Titel, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1 );

                    // Profile
                    if (DialogResult.Cancel != saveMode)
                    {
                        // Check for reset
                        if (!ckMerge.Checked)
                            scanner.Profile.Locations.Clear();

                        // Update in memory
                        scanner.UpdateProfile();

                        // Save to disk
                        scanner.Profile.Save();
                    }

                    // Protocol
                    if (DialogResult.Yes == saveMode)
                        if (DialogResult.OK == saveProtocol.ShowDialog(this))
                            using (StreamWriter protocol = new StreamWriter( saveProtocol.FileName, false, Encoding.Unicode ))
                            {
                                // Head line
                                protocol.WriteLine( ProtocolRecord.LineFormat );

                                // All lines
                                foreach (ProtocolRecord record in scanner.Protocol)
                                    protocol.WriteLine( record );
                            }
                }
                finally
                {
                    // Report to site
                    m_Site.OperationDone();
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Beginnt mit der Ausführung der Aufgabe.
        /// </summary>
        /// <returns>Gesetzt, wenn die Aufgabe synchron abgeschlossen wurde.</returns>
        bool IPlugInControl.Start()
        {
            // Create scanner
            m_Scanner = new TransponderScanner( m_PlugIn.Profile );

            // Connect all events
            m_Scanner.OnStartGroup += ( l, g, s ) => UpdateCounter( string.Format( "{0} {1}", g, l ) );
            m_Scanner.OnStartLocation += ( l, s ) => UpdateCounter( null );
            m_Scanner.OnDoneGroup += ( l, g, s ) => UpdateCounter( null );
            m_Scanner.OnDoneLocation += ( l, s ) => UpdateCounter( null );

            // Start with counter
            UpdateCounter( null );

            // Start the scan
            m_Scanner.Scan();

            // Start the timer
            tickEnd.Enabled = true;

            // Runs in background
            return false;
        }
        /// <summary>
        /// Beginnt einen Sendersuchlauf auf dem aktuellen Geräteprofil.
        /// </summary>
        protected override void OnStartScan()
        {
            // Process
            Start( device =>
                {
                    // Check mode
                    if (EPGProgress.HasValue)
                        CardServerException.Throw( new EPGActiveFault() );
                    if (m_ScanProgress >= 0)
                        CardServerException.Throw( new SourceUpdateActiveFault() );
                    if (!string.IsNullOrEmpty( Profile.UseSourcesFrom ))
                        CardServerException.Throw( new NoSourceListFault( Profile.Name ) );

                    // Stop all
                    RemoveAll();

                    // Create scanner
                    m_Scanner = new TransponderScanner( Profile );

                    // Configure
                    m_Scanner.OnDoneLocation += ( l, s ) => OnUpdateScan();
                    m_Scanner.OnDoneGroup += ( l, g, s ) => OnUpdateScan();

                    // Mark as started
                    m_ScanProgress = 0;
                    m_ScanSources = 0;

                    // Start it
                    m_Scanner.Scan();
                } );
        }
        /// <summary>
        /// Beendet einen Sendersuchlauf auf dem aktuellen Geräteprofil.
        /// </summary>
        /// <param name="updateProfile">Gesetzt, wenn das Geräteprofil aktualisiert werden soll.</param>
        protected override void OnEndScan( bool? updateProfile )
        {
            // Process
            Start( device =>
                {
                    // Check mode
                    if (m_ScanProgress < 0)
                        CardServerException.Throw( new SourceUpdateNotActiveFault() );
                    if (null != m_ScanAbort)
                        CardServerException.Throw( new SourceUpdateNotActiveFault() );

                    // Install action
                    m_ScanAbort = () =>
                        {
                            // With cleanup
                            using (TransponderScanner scanner = m_Scanner)
                            {
                                // Mark as done
                                m_ScanProgress = -1;
                                m_Scanner = null;

                                // Check mode
                                if (updateProfile.HasValue)
                                {
                                    // Do NOT merge
                                    if (!updateProfile.Value)
                                        scanner.Profile.Locations.Clear();

                                    // Process
                                    scanner.UpdateProfile();

                                    // Save it
                                    scanner.Profile.Save();
                                }
                            }

                            // Report
                            ActionDone( null, null );
                        };

                    // Done
                    return DelayedOperationTag;
                } );
        }