private void btnLoadOneList_Click(object sender, EventArgs e)
        {
            int       iid;
            string    style, round;
            DataTable dtL = this.dt.Clone();

            dtL.Rows.Clear();
            try
            {
                int curRInd = dg.Rows.IndexOf(dg.CurrentRow);
                if (curRInd < 0 || curRInd >= dt.Rows.Count)
                {
                    return;
                }
                object[] row = dt.Rows[curRInd].ItemArray;
                dtL.Rows.Add(row);
                iid = Convert.ToInt32(dg.CurrentRow.Cells["№"].Value);

                style = dg.CurrentRow.Cells["Вид"].Value.ToString();
                round = dg.CurrentRow.Cells["Раунд"].Value.ToString();
                dg.CurrentRow.Cells["Доступ на сайте"].Value = true;
                dtL.Rows[0]["Доступ на сайте"] = true;
            }
            catch
            {
                MessageBox.Show("Протокол не выбран");
                return;
            }
            OnlineUpdater2.GetUpdater(cn).LoadSingleList(iid, true);
            MessageBox.Show("Протокол загружен");
            return;

            if (client != null)
            {
                OnlineUpdater.ReloadOneList(iid, cn, client);
                return;
            }
            SqlCommand cmd = new SqlCommand();

            try
            {
                if (cn.State != ConnectionState.Open)
                {
                    cn.Open();
                }
                cmd.Connection  = cn;
                cmd.CommandText = "UPDATE lists SET online = 1, changed = 0 WHERE iid = " + iid.ToString();
                cmd.ExecuteNonQuery();
            }
            catch (SqlException ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }

            try
            {
                startBroadcast = StaticClass.ReloadListsFromTable(false, dtL, cn, remoteConnection, compForService, client);
                if (startBroadcast)
                {
                    StaticClass.UpdateListData(iid, cn, remoteConnection, true, true, compForService, client);
                    MessageBox.Show("Протокол загружен");
                }
                else
                {
                    throw new Exception();
                }
            }
            catch (Exception ex) { MessageBox.Show("Ошибка добавления протокола\r\n" + ex.Message); }
        }
        private void btnReloadLists_Click(object sender, EventArgs e)
        {
            try
            {
                if (da.UpdateCommand.Connection.State != ConnectionState.Open)
                {
                    da.UpdateCommand.Connection.Open();
                }
                da.Update(this.dt);
                //SqlCommand cmd = new SqlCommand("UPDATE lists SET changed = 0", da.UpdateCommand.Connection);
                //cmd.ExecuteNonQuery();
            }
            catch (SqlException ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }

            try
            {
                OnlineUpdater2.GetUpdater(this.cn).PostUpdatedGroups();
                OnlineUpdater2.Instance.PostChangedClimbers();
                if (OnlineUpdater2.Instance.LoadAllLists() > 0)
                {
                    MessageBox.Show("Протоколы загружены");
                    startBroadcast = true;
                    this.Close();
                    return;
                }
                startBroadcast = false;
                if (MessageBox.Show("Протоколы для загрузки на сайт не выбраны. Выбрать протоколы?", "", MessageBoxButtons.YesNo) == DialogResult.No)
                {
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(String.Format("Ошибка загрузки: {0}", ex));
                return;
            }

            return;

            if (client != null)
            {
                OnlineUpdater.BeginFullUpdate(true, cn, client, OnlineStarted,
                                              String.Format("Данные на сайте перезагружены{0}Трансляция успешно запущена", Environment.NewLine),
                                              OnlineUpdater.UpdateStartMode.AskForWait);
                this.Close();
                startBroadcast = true;
                return;
            }
            startBroadcast = StaticClass.ReloadListsFromTable(true, dt, cn, remoteConnection, compForService, client);
            try
            {
                if (startBroadcast)
                {
                    StaticClass.UpdateListData(true, cn, remoteConnection, true, compForService, client);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ошибка запуска трансляции\r\n" + ex.Message);
                return;
            }
            if (!startBroadcast)
            {
                if (MessageBox.Show("Протоколы для загрузки на сайт не выбраны. Выбрать протоколы?", "", MessageBoxButtons.YesNo) == DialogResult.No)
                {
                    this.Close();
                }
            }
            else
            {
                this.Close();
            }
        }
        private void btnRefresh_Click(object sender, EventArgs e)
        {
            DataTable dtL = null;

            try
            {
                if (da.UpdateCommand.Connection.State != ConnectionState.Open)
                {
                    da.UpdateCommand.Connection.Open();
                }
                da.Update(this.dt);

                startBroadcast = OnlineUpdater2.GetUpdater(cn).LoadLiveLists() > 0;
                if (startBroadcast)
                {
                    this.Close();
                    return;
                }

                if (MessageBox.Show("Протоколы для загрузки на сайт не выбраны. Выбрать протоколы?", "", MessageBoxButtons.YesNo) == DialogResult.No)
                {
                    this.Close();
                }
                return;

                //SqlCommand cmd = new SqlCommand("UPDATE lists SET changed = 0", da.UpdateCommand.Connection);
                //cmd.ExecuteNonQuery();

                dtL = dt.Clone();
                dtL.Rows.Clear();
                foreach (DataRow dr in dt.Rows)
                {
                    if (Convert.ToBoolean(dr["Прямая трансляция"]) &&
                        Convert.ToBoolean(dr["Доступ на сайте"]))
                    {
                        dtL.Rows.Add(dr.ItemArray);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }
            if (client != null)
            {
                OnlineUpdater.BeginFullUpdate(false, cn, client, OnlineStarted, "Трансляция успешно запущена", OnlineUpdater.UpdateStartMode.AskForWait);
                this.Close();
                startBroadcast = true;
                return;
            }
            if (dtL != null && dtL.Rows.Count > 0)
            {
                startBroadcast = StaticClass.ReloadListsFromTable(false, dtL, cn, remoteConnection, compForService, client);
            }
            else
            {
                startBroadcast = false;
            }
            try
            {
                if (startBroadcast)
                {
                    StaticClass.UpdateListData(false, cn, remoteConnection, true, compForService, client);
                }
            }
            catch { }
            if (!startBroadcast)
            {
                if (MessageBox.Show("Протоколы для загрузки на сайт не выбраны. Выбрать протоколы?", "", MessageBoxButtons.YesNo) == DialogResult.No)
                {
                    this.Close();
                }
            }
            else
            {
                this.Close();
            }
        }
        private void btnLoadClimbers_Click(object sender, EventArgs e)
        {
            try
            {
                this.ReloadClimbersList();
            }
            catch (Exception ex)
            {
                MessageBox.Show(String.Format("Ошибка обновления: {0}", ex));
            }
            return;

            if (client != null)
            {
                if (cbLoadInDiffThread.Checked)
                {
                    lock (loaderLocker)
                    {
                        if (climbersLoadingResult != null)
                        {
                            if (MessageBox.Show(this, "Загрузка запущена. Прервать?", String.Empty, MessageBoxButtons.YesNo, MessageBoxIcon.Question)
                                == System.Windows.Forms.DialogResult.Yes)
                            {
                                climbersLoadingResult.Abort();
                            }
                            else
                            {
                                return;
                            }
                        }
                        climbersLoadingResult = OnlineUpdater.BeginRefreshClimbers(true, cn, client, UpdateCompleted, null);
                    }
                }
                else
                {
                    try
                    {
                        OnlineUpdater.RefreshClimbers(true, cn, client, true);
                        StaticClass.ShowExceptionMessageBox("Список участников успешно загружен", owner: this);
                    }
                    catch (WebException wex) { StaticClass.ShowExceptionMessageBox("Ошибка обновления сайта", wex, this); }
                    catch (SqlException s) { StaticClass.ShowExceptionMessageBox("Ошибка работы с данными", s, this); }
                    catch (Exception ex) { StaticClass.ShowExceptionMessageBox("Неизвестная ошибка", ex, this); }
                }
                return;
            }
            loadAgr la = new loadAgr(!cbLoadInDiffThread.Checked, cbLoadPhoto.Checked, cbLoadJudges.Checked,
                                     compForService, client, new MainForm.AfetrStopCallBack(parent.RemThrData), cn);

            if (la.useCurrent)
            {
                LoadClimbers(la);
            }
            else
            {
                if (parent.LoadingThread != null && parent.LoadingThread.IsAlive)
                {
                    if (MessageBox.Show("Загрузка списка участников уже запущена. Прервать?", "Загрузка запущена", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
                        == DialogResult.Yes)
                    {
                        return;
                    }
                }
                parent.LoadingThread = new Thread(LoadClimbers);
                MainForm.ThrData td = new MainForm.ThrData(parent.LoadingThread, MainForm.ThreadStats.IMG_SAV_REM);
                parent.AddThrData(td);
                parent.LoadingThread.Start(la);
            }
        }
Esempio n. 5
0
 public UpdateForm()
 {
     InitializeComponent();
     this.labelUpdate2.Text = this.ApplicationAssembley.GetName().Version.ToString();
     updater = new OnlineUpdater(this);
 }