Пример #1
0
        /// <summary>
        /// Update the "Database Status" textboxes
        /// </summary>
        public void UpdateDatabaseStatus()
        {
            if (!UpdateStatusDuringHarvest.Checked)
            {
                Application.DoEvents();
                return;
            }

            try
            {
                if ((UpdateDB == null) || (UpdateDB.DSN != DSN.Text))
                {
                    UpdateDB = new Database(DSN.Text);
                }
                bool TablesCreated;
                int  NumPeople;
                int  NumHarvestedPeople;
                int  NumPublications;
                int  NumErrors;
                UpdateDB.GetStatus(out TablesCreated, out NumPeople, out NumHarvestedPeople, out NumPublications, out NumErrors);
                this.TablesCreated.Text = TablesCreated.ToString();
                this.TablesCreated.Refresh();
                this.People.Text = NumPeople.ToString();
                this.People.Refresh();
                this.PeopleHarvested.Text = NumHarvestedPeople.ToString();
                this.PeopleHarvested.Refresh();
                this.PublicationsFound.Text = NumPublications.ToString();
                this.PublicationsFound.Refresh();

                // People With Errors textbox -- set it to red if there are errors
                this.PeopleWithErrors.Text = NumErrors.ToString();
                if (NumErrors > 0)
                {
                    PeopleWithErrors.BackColor = Color.Red;
                }
                else
                {
                    PeopleWithErrors.BackColor = People.BackColor;
                }
                this.PeopleNotHarvested.Text = ((int)(NumPeople - NumHarvestedPeople)).ToString();

                // People Not Harvested textbox -- set it to red if there are unharvested
                // people and the software is not currently processing
                if (!Processing && (NumPeople - NumHarvestedPeople > 0))
                {
                    PeopleNotHarvested.BackColor = Color.Red;
                }
                else
                {
                    PeopleNotHarvested.BackColor = People.BackColor;
                }
                Application.DoEvents();
            }
            catch
            {
                this.TablesCreated.Text = "Error";
                this.TablesCreated.Refresh();
                this.People.Text = "Error";
                this.People.Refresh();
                this.PeopleHarvested.Text = "Error";
                this.PeopleHarvested.Refresh();
                this.PublicationsFound.Text = "Error";
                this.PublicationsFound.Refresh();
                Application.DoEvents();
            }
        }
Пример #2
0
        public void UpdateStatus()
        {
            try
            {
                Database UpdateDB = new Database(DSN.Text);
                bool     TablesCreated;
                int      NumPeople;
                int      NumHarvestedPeople;
                int      NumPublications;
                int      NumErrors;
                UpdateDB.GetStatus(out TablesCreated, out NumPeople, out NumHarvestedPeople, out NumPublications, out NumErrors);
                this.TablesCreated.Text = TablesCreated.ToString();
                this.TablesCreated.Refresh();
                this.People.Text = NumPeople.ToString();
                this.People.Refresh();
                this.PeopleHarvested.Text = NumHarvestedPeople.ToString();
                this.PeopleHarvested.Refresh();
                this.PublicationsFound.Text = NumPublications.ToString();
                this.PublicationsFound.Refresh();

                // People With Errors textbox -- set it to red if there are errors
                this.PeopleWithErrors.Text = NumErrors.ToString();
                if (NumErrors > 0)
                {
                    PeopleWithErrors.BackColor = Color.Red;
                }
                else
                {
                    PeopleWithErrors.BackColor = People.BackColor;
                }

                this.PeopleNotHarvested.Text = ((int)(NumPeople - NumHarvestedPeople)).ToString();

                // People Not Harvested textbox -- set it to red if there are unharvested
                // people and the software is not currently processing
                if (NumPeople - NumHarvestedPeople > 0)
                {
                    PeopleNotHarvested.BackColor = Color.Red;
                }
                else
                {
                    PeopleNotHarvested.BackColor = People.BackColor;
                }


                // Get the colleague status, enable buttons appropriately
                int DiadsFound;
                int ColleaguesFound;
                int ColleaguesHarvested;
                int ColleaguePublications;
                int StarsWithColleagues;
                ColleagueFinder.GetDBStatus(UpdateDB, out ColleaguesFound, out DiadsFound, out ColleaguesHarvested, out ColleaguePublications, out StarsWithColleagues);
                this.DiadsFound.Text            = DiadsFound.ToString();
                this.ColleaguesFound.Text       = ColleaguesFound.ToString();
                this.ColleaguesHarvested.Text   = ColleaguesHarvested.ToString();
                this.ColleaguePublications.Text = ColleaguePublications.ToString();
                this.StarsWithColleagues.Text   = StarsWithColleagues.ToString();

                // Colleagues With Errors textbox -- set it to red if there are errors
                // (first check ColleaguesFound so we don't issue this SELECT against a database with no Colleagues table)
                if (ColleaguesFound > 0)
                {
                    try
                    {
                        NumErrors = UpdateDB.GetIntValue("SELECT Count(*) FROM Colleagues WHERE Error IS NOT NULL");
                        this.ColleaguesWithErrors.Text = NumErrors.ToString();
                    }
                    catch (Exception ex)
                    {
                        this.ColleaguesWithErrors.Text = ex.Message;
                        NumErrors = -1;
                    }
                    if (NumErrors != 0)
                    {
                        ColleaguesWithErrors.BackColor = Color.Red;
                    }
                    else
                    {
                        ColleaguesWithErrors.BackColor = People.BackColor;
                    }
                }

                // Enable/disable buttons
                if (ColleaguesFound == 0)
                {
                    RetrieveColleaguePublications.Enabled = false;
                    CopyPublicationsFromAnotherDB.Enabled = false;
                }
                else
                {
                    RetrieveColleaguePublications.Enabled = true;
                    CopyPublicationsFromAnotherDB.Enabled = true;
                }

                if (ColleaguePublications > 0)
                {
                    RemoveFalseColleagues.Enabled = true;
                }
                else
                {
                    RemoveFalseColleagues.Enabled = false;
                }


                // Roster status -- disable buttons if the roster is not loaded
                if (roster != null)
                {
                    this.RosterRows.Text            = roster.RosterData.Rows.Count.ToString();
                    FindPotentialColleagues.Enabled = true;
                }
                else
                {
                    this.RosterRows.Text                  = "not loaded";
                    FindPotentialColleagues.Enabled       = false;
                    RetrieveColleaguePublications.Enabled = false;
                    CopyPublicationsFromAnotherDB.Enabled = false;
                }

                Application.DoEvents();
            }
            catch
            {
                //
            }
        }