private void tsbQuitAll_Click(object sender, EventArgs e) { if (updater.UserLevel() >= UserLevel.Оператор) { updater.AlarmShortUp(); Data.SendShortUpCommand(); timerBlink.Enabled = false; try { using (ServerSQL dataSQL = new ServerSQL(DatabaseFrom.Database, true)) // чтение { using (ServerSQL fetchlocalSQL = new ServerSQL(DatabaseFrom.Fetchbase, true)) // чтение { if (dataSQL.Connected && fetchlocalSQL.Connected) { HashSet <string> list = new HashSet <string>(); for (int i = 0; i < lvLogView.Items.Count; i++) { string ptname = lvLogView.Items[i].SubItems[3].Text; if (!list.Contains(ptname)) { list.Add(ptname); Entity ent = Data.GetEntity(ptname, dataSQL); using (ServerSQL fetchSQL = new ServerSQL(DatabaseFrom.Fetchbase)) // запись { if (!ent.Empty && fetchSQL.Connected) { ent.Reals = Data.GetRealValues(ptname, fetchlocalSQL, dataSQL); bool propexists = ent.Reals.ContainsKey("QuitAlarms"); if (propexists && !bool.Parse(ent.Reals["QuitAlarms"]) || !propexists) { ent.QuitAlarms(updater.UserName()); ent.SetRealProp("QuitAlarms", true.ToString()); Data.WriteRealVals(ent, fetchSQL); } } else { Data.RemoveAlarms(ptname, fetchSQL); } } } } } } } } finally { timerBlink.Enabled = true; } } }
private void miQuit_Click(object sender, EventArgs e) { Entity ent = (Entity)miQuit.Tag; if (!ent.Empty && updater != null) { string ptname = (string)ent.Values["PtName"]; ent.Reals = Data.GetRealValues(ptname); ent.QuitAlarms(updater.UserName()); ent.SetRealProp("QuitAlarms", true.ToString()); Data.WriteRealVals(ent); updater.AlarmShortUp(); Data.SendShortUpCommand(); } }