Beispiel #1
0
        private void bw_SynchronizeComplete(object sender, RunWorkerCompletedEventArgs e)
        {
            // Update Dataset-datagridview control with changes
            InitializeDatasetGrid();

            // update subscribers last index from db
            txbSubscrLastindex.Text = SubscriberDatasetManager.GetLastIndex(_currentDatasetId);

            // Display in geoserver openlayers
            UpdateToolStripStatusLabel("Display Map");

            UpdateToolStripStatusLabel("Ready");
            SetSynchButtonActive();
            Hourglass(false);
            if (_synchController.TransactionsSummary != null)
            {
                var logMessage = "Syncronization Transaction summary:";
                listBoxLog.Items.Add(logMessage);
                logMessage = "TotalInserted: " + _synchController.TransactionsSummary.TotalInserted;
                listBoxLog.Items.Add(logMessage);
                logMessage = "TotalUpdated: " + _synchController.TransactionsSummary.TotalUpdated;
                listBoxLog.Items.Add(logMessage);
                logMessage = "TotalDeleted: " + _synchController.TransactionsSummary.TotalDeleted;
                listBoxLog.Items.Add(logMessage);
                logMessage = "TotalReplaced: " + _synchController.TransactionsSummary.TotalReplaced;
                listBoxLog.Items.Add(logMessage);
                // Scroll down automatically
                listBoxLog.SelectedIndex = listBoxLog.Items.Count - 1;
            }
        }
Beispiel #2
0
        /// <summary>
        ///     Initialize _currentDatasetId
        /// </summary>
        private void InitializeCurrentDataset()
        {
            _currentDatasetId = Properties.Subscriber.Default.DefaultDatasetId;

            // Get subscribers last index from db
            txbSubscrLastindex.Text = SubscriberDatasetManager.GetLastIndex(_currentDatasetId);
        }
Beispiel #3
0
        /// <summary>
        ///     Handles the Click event of the btnOfflineSync control.
        ///     Starts Offline sync.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        private void btnOfflineSync_Click(object sender, EventArgs e)
        {
            try
            {
                var path = Environment.CurrentDirectory;
                //string fileName = "";
                var zipFile = "";

                var openFileDialog1 = new OpenFileDialog();
                //openFileDialog1.InitialDirectory = path.Substring(0, path.LastIndexOf("bin")) +
                //                                   @"..\Kartverket.Geosynkronisering.Subscriber.BL\SchemaMapping"; //System.Environment.CurrentDirectory;
                openFileDialog1.Filter           = "zip files (*.zip)|*.zip|All files (*.*)|*.*";
                openFileDialog1.FilterIndex      = 1;
                openFileDialog1.RestoreDirectory = true;
                openFileDialog1.CheckFileExists  = true;
                openFileDialog1.Title            = "Select file for Offline Syncronization";

                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    try
                    {
                        zipFile = openFileDialog1.FileName;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Error: Could not open file. Original error: " + ex.Message);
                    }
                }
                else
                {
                    return;
                }

                //string zipFile = "";
                //// zipFile = @"C:\Users\leg\AppData\Local\Temp\abonnent\6fa6e29d-e978-4ba5-a660-b7f355b233ef.zip";
                //zipFile = @"C:\Users\b543836\AppData\Local\Temp\abonnent\6fa6e29d-e978-4ba5-a660-b7f355b233ef.zip";

                var dataset = SubscriberDatasetManager.GetDataset(_currentDatasetId);
                var lastChangeIndexSubscriber = (int)dataset.LastIndex;
                if (lastChangeIndexSubscriber > 0)
                {
                    var buttons = MessageBoxButtons.YesNo;
                    var result  =
                        MessageBox.Show(
                            "TestOfflineSyncronizationComplete could fail if lastChangeIndexSubscriber > 0. Do you want to continue?",
                            "", buttons);
                    if (result != DialogResult.Yes)
                    {
                        return;
                    }
                }

                tabControl1.SelectTab(0);
                var status = _synchController.DoSyncronizationOffline(zipFile, _currentDatasetId, 0);

                if (status)
                {
                    // Oppdaterer dgDataset
                    dgDataset.DataSource = SubscriberDatasetManager.GetAllDataset();
                    // update subscribers last index from db
                    txbSubscrLastindex.Text = SubscriberDatasetManager.GetLastIndex(_currentDatasetId);

                    if (_synchController.TransactionsSummary != null)
                    {
                        var logMessage = "Offline Syncronization Transaction summary:";
                        listBoxLog.Items.Add(logMessage);
                        logMessage = "TotalInserted: " + _synchController.TransactionsSummary.TotalInserted;
                        listBoxLog.Items.Add(logMessage);
                        logMessage = "TotalUpdated: " + _synchController.TransactionsSummary.TotalUpdated;
                        listBoxLog.Items.Add(logMessage);
                        logMessage = "TotalDeleted: " + _synchController.TransactionsSummary.TotalDeleted;
                        listBoxLog.Items.Add(logMessage);
                        logMessage = "TotalReplaced: " + _synchController.TransactionsSummary.TotalReplaced;
                        listBoxLog.Items.Add(logMessage);
                        // Scroll down automatically
                        listBoxLog.SelectedIndex = listBoxLog.Items.Count - 1;
                    }
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace, "btnOfflneSync_Click");

                //   throw;
            }
        }
 public static string GetLastIndex(int datasetId)
 {
     return(SubscriberDatasetManager.GetLastIndex(datasetId));
 }