Esempio n. 1
0
        private void RefreshObjects(bool AddNewsOnly)
        {
            try
            {
                var map = new DataBaseMapper(DataBaseDataSet, SelectedConnection);

                try
                {
                    Progreso = new FormProgress();
                    Progreso.Show();

                    map.ProgressProcessChanged   += ProgressProcessChanged;
                    map.ProgressActionChanged    += ProgressActionChanged;
                    map.ProgressIncrementProcess += ProgressIncrementProcess;
                    map.ProgressIncrementAction  += ProgressIncrementAction;

                    map.LoadAndRefreshAllObjects(true, AddNewsOnly);

                    Progreso.Close();
                    Application.DoEvents();

                    if (map.Log.ToString() != "")
                    {
                        var log = new FormLog();

                        log.AppendText(map.Log.ToString());
                        log.ShowDialog();
                    }
                }
                catch
                {
                    Progreso.Close();
                    Application.DoEvents();
                    throw;
                }
                finally
                {
                    map.ProgressProcessChanged   -= ProgressProcessChanged;
                    map.ProgressActionChanged    -= ProgressActionChanged;
                    map.ProgressIncrementProcess -= ProgressIncrementProcess;
                    map.ProgressIncrementAction  -= ProgressIncrementAction;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Program.AssemblyTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            this.Show();
        }
Esempio n. 2
0
        public static void SearchLyrics(CD cd)
        {
            FormProgress formProgress = new FormProgress();

            formProgress.LabelProgress.Text  = StringTable.SearchLyrics;
            formProgress.ProgressBar.Maximum = cd.Tracks.Count;
            formProgress.Show();

            foreach (Track track in cd.Tracks)
            {
                Application.DoEvents();
                string artist = (cd.Sampler) ? track.Artist : cd.Artist;
                string title  = track.Title;

                if (!string.IsNullOrEmpty(artist) && !string.IsNullOrEmpty(title))
                {
                    string lyrics = Search(artist, title);

                    track.Lyrics = lyrics;
                }

                formProgress.ProgressBar.Value++;
                Application.DoEvents();
            }
            formProgress.Close();
        }
Esempio n. 3
0
 public void UpdateNetwork(Network n)
 {
     try
     {
         //Create Progress Form
         FormProgress fp = new FormProgress();
         //Create Query
         connection = new SQLiteConnection("Data Source=" + dbpath + ";Version=3; foreign keys=true;");
         connection.Open();
         command             = new SQLiteCommand(connection);
         command.CommandText = "UPDATE network SET name=@name, inputtype=@inputtype WHERE networkNumber=@nnr ;";
         command.Parameters.AddWithValue("@nnr", n.NetworkNumber);
         command.Parameters.AddWithValue("@name", n.Name);
         command.Parameters.AddWithValue("@inputtype", n.InputType);
         command.ExecuteNonQuery();
         //drop old ip address connection to this network
         command.CommandText = "DELETE FROM networkipadress WHERE networkNumber=@nnr ;";
         command.Parameters.AddWithValue("@nnr", n.NetworkNumber);
         //initialize Progress Form
         fp.SetMax(n.IpAddresses.Count);
         fp.Show();
         //Add new ip-Addresses
         SQLiteTransaction transaction = connection.BeginTransaction();
         foreach (IPAddress ip in n.IpAddresses)
         {
             try
             {//Write IP to table, if it is already there, throw exception
                 command.CommandText = "INSERT INTO ipaddresses (ipaddress) VALUES(@ipaddress);";
                 command.Parameters.AddWithValue("@ipaddress", ip.ToString());
                 command.ExecuteNonQuery();
             }
             catch (Exception e)
             {
                 Log.WriteLog("Error writing IP to DB: " + e.Message);
             }
             try
             {//Connect ip to netwok in database
                 command.CommandText = "INSERT INTO networkipadress (networkNumber, ipaddress) VALUES(@networkNumber, @ipaddress);";
                 command.Parameters.AddWithValue("@networkNumber", n.NetworkNumber);
                 command.Parameters.AddWithValue("@ipaddress", ip.ToString());
                 command.ExecuteNonQuery();
             }
             catch (Exception e)
             {
                 Log.WriteLog("Error writing IP/NW to DB: " + e.Message);
             }
             fp.Progress();
         }
         transaction.Commit();
         Log.WriteLog(string.Format("Network {0} changed in database.", n.Name));
         fp.Close();
     }
     catch (Exception e)
     {
         MessageBox.Show("Error SQL Write Network", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
         Log.WriteLog(e.Message);
     }
     connection.Close();
 }
Esempio n. 4
0
 public void SaveNetwork(Network n, NetworkInventory ni)
 {
     try
     {
         //Create Progress Form
         FormProgress fp = new FormProgress();
         //Create Query
         connection = new SQLiteConnection("Data Source=" + dbpath + ";Version=3; foreign keys=true;");
         connection.Open();
         command             = new SQLiteCommand(connection);
         command.CommandText = "INSERT INTO network (networkNumber, name, inputtype, networkInventoryNumber) VALUES(@networkNumber, @name, @inputtype, @networkInventoryNumber);";
         command.Parameters.AddWithValue("@networkNumber", n.NetworkNumber);
         command.Parameters.AddWithValue("@name", n.Name);
         command.Parameters.AddWithValue("@inputtype", n.InputType);
         command.Parameters.AddWithValue("@networkInventoryNumber", ni.NetworkInventoryNumber);
         command.ExecuteNonQuery();
         SQLiteTransaction transaction = connection.BeginTransaction();
         //Initialize Progress Form
         fp.SetMax(n.IpAddresses.Count);
         fp.Show();
         foreach (IPAddress ip in n.IpAddresses)
         {
             try
             {//Write IP to table, if it is already there, throw exception
                 command.CommandText = "INSERT INTO ipaddresses (ipaddress) VALUES(@ipaddress);";
                 command.Parameters.AddWithValue("@ipaddress", ip.ToString());
                 command.ExecuteNonQuery();
                 //Log.WriteLog("IPAddress {0} saved to database", ip.ToString());
             }
             catch (Exception e)
             {
                 Log.WriteLog("Error writing IP to DB: " + e.Message);
             }
             try
             {//Connect ip to netwok in database
                 command.CommandText = "INSERT INTO networkipadress (networkNumber, ipaddress) VALUES(@networkNumber, @ipaddress);";
                 command.Parameters.AddWithValue("@networkNumber", n.NetworkNumber);
                 command.Parameters.AddWithValue("@ipaddress", ip.ToString());
                 command.ExecuteNonQuery();
                 //Log.WriteLog("IPaddress {0} connected to network {1} in database.", ip.ToString(), n.Name);
             }
             catch (Exception e)
             {
                 Log.WriteLog("Error writing IP/NW to DB: " + e.Message);
             }
             fp.Progress();
         }
         transaction.Commit();
         Log.WriteLog(string.Format("Network {0} saved to database.", n.Name));
         fp.Close();
     }
     catch (Exception e)
     {
         MessageBox.Show("Error SQL Write Network", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
         Log.WriteLog(e.Message);
     }
     connection.Close();
 }
        public void Dispose()
        {
            if (_Form != null)
            {
                _Form.Close();
                _Form = null;

                _Instance = null;
            }
        }
Esempio n. 6
0
        private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            if (e.ProgressPercentage == 0 && m_Form == null)
            {
                m_Form = new FormProgress();
                m_Form.Show();
            }
            if (e.ProgressPercentage == 100 && m_Form != null)
            {
                m_Form.Close();
                m_Form = null;
                return;
            }
            var message = (string)e.UserState;

            m_Form.UpdateProgress(e.ProgressPercentage, message);
        }
Esempio n. 7
0
        private void TransferFields()
        {
            FormProgress formProgress = new FormProgress();
            Field        sourceField  = ((ComboBoxItem)comboBoxSourceField.SelectedItem).Field;

            try
            {
                formProgress.Text = StringTable.TransferFieldsRunning;
                formProgress.Show();

                TransferFields(formProgress);
            }
            finally
            {
                formProgress.Close();
            }
        }