private void LoadFirst() { baseVersion = Data.Version; using (ServerSQL dataSQL = new ServerSQL(DatabaseFrom.Database, true)) // чтение { using (ServerSQL fetchSQL = new ServerSQL(DatabaseFrom.Fetchbase, true)) // чтение { if (dataSQL.Connected && fetchSQL.Connected) { foreach (KeyValuePair <string, List <Draw> > item in fetchlist) { string ptname = item.Key; // получение данных Entity ent = Data.GetEntity(ptname, dataSQL); if (!ent.Empty) { ent.Reals = Data.GetRealValues(ptname, fetchSQL, dataSQL); if (ent.Reals.Count == 0) { if (updater != null) { updater.UpdateStatusMessage("Нет связи с SQL-сервером"); } continue; } // Заполнение данными приёмников данных string[] metadata = new string[] { "EUDesc" }; foreach (Draw drw in item.Value) { foreach (string propname in metadata) { if (drw.Props.ContainsKey(propname)) { drw.Props[propname] = ent.Values.ContainsKey(propname) ? (string)ent.Values[propname] : "???"; } } refreshDraw(drw); } } } } } } }
public int LoadLog(int pos, int count, bool print = false) { int result = 0; if (pos < 0) { return(result); } if (String.IsNullOrWhiteSpace(LogSQL)) { return(result); } string SQL = String.Format(LogSQL, pos, Math.Abs(count)); using (ServerSQL mySQL = new ServerSQL(DatabaseFrom.Database, false)) // чтение удалённо { if (mySQL.Connected) { try { ArrayList results = mySQL.GetLogRecords(SQL, LogDateFormat); if (count > 0) { reportrows.Clear(); int row = 0; foreach (string[] rec in results) { ListViewItem item = new ListViewItem(rec[0]); if (row % 2 != 0) { item.BackColor = Color.FromArgb(240, 240, 240); } for (int i = 1; i < rec.Length; i++) { item.SubItems.Add(rec[i]); } reportrows.Add(item); row++; } if (!print) { lvLogView.Items.Clear(); lvLogView.Items.AddRange(reportrows.ToArray()); } } result = results.Count; } catch (Exception e) { IUpdatePanel up = PanelHost as IUpdatePanel; if (up != null) { up.UpdateStatusMessage(e.Message); } } } else { IUpdatePanel up = PanelHost as IUpdatePanel; if (up != null) { up.UpdateStatusMessage("База данных '" + mySQL.CurrentDatabase + "' сервера недоступна!"); } } } return(result); }
public int LoadTable(int pos, int count, bool print = false) { int result = 0; if (pos < 0) { return(result); } using (ServerSQL mySQL = new ServerSQL(DatabaseFrom.Database, false)) // чтение удалённо { if (mySQL.Connected) { string[] items = Data.GroupItems(currGroup, mySQL, ParamGroup.Table); int[] formats = new int[items.Length]; int n = 0; foreach (string item in items) { string ptname = item.Split(new char[] { '.' })[0]; Entity ent = Data.GetEntity(ptname, mySQL); if (!ent.Empty && ent.Values.ContainsKey("FormatPV")) { formats[n] = (int)ent.Values["FormatPV"]; } else { formats[n] = 3; } n++; } for (int i = 1; i <= Data.PlaceCount(ParamGroup.Table); i++) { ColumnHeader header = lvTableView.Columns[i]; if (!header.Text.Equals(items[i - 1])) { for (int j = 0; j < lvTableView.Items.Count; j++) { lvTableView.Items[j].SubItems[i].Text = String.Empty; } } header.Text = items[i - 1]; GroupItem gi = Data.GroupItem(currGroup, i, mySQL, ParamGroup.Table); gi.Group = currGroup; gi.Place = i; header.Tag = gi; } try { ArrayList results = mySQL.GetTableMatrix(TableSQL, items, formats, pos, Math.Abs(count)); if (count > 0) { string[] lastrow; if (results.Count > 0) { lastrow = (string[])results[results.Count - 1]; } else { lastrow = new string[1]; lastrow[0] = String.Empty; } //if (!lastSnapTime.Equals(lastrow[0])) //{ lastSnapTime = lastrow[0]; tablerows.Clear(); int row = 0; foreach (string[] cols in results) { ListViewItem item = new ListViewItem(); if (row % 2 != 0) { item.BackColor = Color.FromArgb(240, 240, 240); } for (int col = 0; col < cols.Length; col++) { if (col == 0) { item.Text = cols[col]; } else { item.SubItems.Add(cols[col]); } } tablerows.Add(item); row++; } if (!print) { lvTableView.Items.Clear(); lvTableView.Items.AddRange(tablerows.ToArray()); } if (Scrolling) { GotoRecord(GoalRecord.LastRecord); } //} } result = results.Count; } catch (Exception e) { updater.UpdateStatusMessage(e.Message); } } else { updater.UpdateStatusMessage("База данных '" + mySQL.CurrentDatabase + "' сервера недоступна!"); } } return(result); }