Ejemplo n.º 1
0
        /// <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);
            });
        }
Ejemplo 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
                {
                    // Check for error
                    var error = scanner.Error;
                    if (error != null)
                    {
                        MessageBox.Show(this, error.ToString(), Properties.Resources.Scanner_Error, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }

                    // 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();
                }
            }
        }