private void PGGetObjects_Click(object sender, EventArgs e) { /* * Date.LocalHqToSystemEx(); * внутренне представление начала суток планирования */ DateTime dt_ = PGDate.Value.Date.LocalHqToSystemEx(); SyncZone syncZone = (SyncZone)PGSync.SelectedIndex; IModesTimeSlice ts = null; if (api_ != null) { ts = api_.GetModesTimeSlice(dt_, syncZone , TreeContent.PGObjects /*только оборудование, по которому СО публикует ПГ(включая родителей)*/ , false); PGObjects.Items.Clear(); foreach (IGenObject IGO in ts.GenTree) { ExpandTree(PGObjects.Items, IGO, ""); } if (PGObjects.Items.Count > 0) { PGObjects.SelectedIndex = 0; } } dataGridView1.Visible = false; outputBox.Visible = true; }
private void button1_Click(object sender, EventArgs e) { DateTime dt_ = dateTimePicker1.Value.Date.LocalHqToSystemEx(); SyncZone syncZone = (SyncZone)comboBox1.SelectedIndex; TreeContent content = (TreeContent)comboBox3.SelectedIndex; bool loadData_ = checkBox1.Checked; IModesTimeSlice ts = null; if (api_ != null) { ts = api_.GetModesTimeSlice(dt_, syncZone, content, loadData_); IList <IGenObject> list = null; list = ts.GetGenObjectFlatList(); outputBox.Items.Clear(); foreach (IGenObject obj in list) { outputBox.Items.Add(String.Format("Имя: {0}; Наименование: {1}; Тип: {2} \r\n", obj.Name, obj.Description, obj.GenObjType.Name)); } } dataGridView1.Visible = false; outputBox.Visible = true; }
private void button4_Click(object sender, EventArgs e) { DateTime dt_ = dateTimePicker4.Value.Date.LocalHqToSystemEx(); if (comboBox8.SelectedItem == null) { return; } syncZone = (SyncZone)comboBox8.SelectedIndex; ModelType model_ = ModelType.M53500; if (syncZone == SyncZone.First) { colCount = 24; } if (syncZone == SyncZone.Second) { colCount = 48; } IModesTimeSlice tsForGetVarParam = null; if (api_ != null) { tsForGetVarParam = api_.GetModesTimeSlice(dt_, syncZone, TreeContent.AllObjects, true); if (model_ == ModelType.M53500) { listGenObjectForGetVarParam = tsForGetVarParam.GetGenObjectFlatList(); } else { listGenObjectForGetVarParam = tsForGetVarParam.GenTree; } outputBox.Items.Clear(); if (listGenObjectForGetVarParam != null) { foreach (IGenObject obj in listGenObjectForGetVarParam) { outputBox.Items.Add(String.Format("Имя: {0}; Наименование: {1}; Тип: {2} \r\n", obj.Name, obj.Description, obj.GenObjType.Name)); } } comboBox9.Items.Clear(); if (listGenObjectForGetVarParam != null) { foreach (IGenObject obj in listGenObjectForGetVarParam) { bool isExist = false; foreach (string str in comboBox9.Items) { if (obj.GenObjType.Name == str) { isExist = true; break; } } if (!isExist) { comboBox9.Items.Add(obj.GenObjType.Name); } } } if (comboBox9.Items.Count > 0) { comboBox9.SelectedIndex = 0; } listLayersForGetVarParam = api_.GetLayersBySyncZone(syncZone); comboBox6.Items.Clear(); foreach (ModesLayer layer_ in listLayersForGetVarParam) { comboBox6.Items.Add(layer_.Name); } if (comboBox6.Items.Count > 0) { comboBox6.SelectedIndex = 0; } groupBox5.Enabled = true; button5.Enabled = true; dataGridView1.Visible = false; outputBox.Visible = true; } }
public MCServerReader(DateTime date, bool writeNPBR = true) { Logger.Info("Чтение ПБР за " + date.ToString()); Date = date; AutooperData = new List <string>(); Logger.Info("Connect MC"); ProcessedPBRS = new Dictionary <int, MCPBRData>(); try { modesConnect(); SyncZone zone = SyncZone.First; IModesTimeSlice ts = null; ts = api.GetModesTimeSlice(date.Date.LocalHqToSystemEx(), zone , TreeContent.PGObjects /*только оборудование, по которому СО публикует ПГ(включая родителей)*/ , false); bool ok = true; foreach (IGenObject obj in ts.GenTree) { ok = ok && getPlan(obj); } if (ok) { if (ProcessedPBRS.Count != 7) { Logger.Info("Количество ПБР !=7. Отправка в автооператор не производится"); } else { foreach (MCPBRData pbr in ProcessedPBRS.Values) { pbr.CreateData(); pbr.addAutooperData(AutooperData); } Logger.Info("АО кол.строк " + AutooperData.Count); if (AutooperData.Count == 100) { Logger.Info("Отправка в АО кол.строк "); try { sendAutooperData(); Logger.Info("Данный отправлены в АО"); } catch (Exception e) { Logger.Info("Ошибка при отправке данных в АО"); Logger.Info(e.ToString()); } } else { Logger.Info("Неверное количество данных в АО"); } } } //return; if (ok) { Logger.Info("Зaпись ПБР в Базу"); foreach (MCPBRData pbr in ProcessedPBRS.Values) { try { pbr.CreateData(); bool okWrite = false; int i = 0; while (!okWrite && i < 3) { Logger.Info(String.Format("Запись {0} ПБР. Попытка {1}", pbr.Item, i)); okWrite = pbr.ProcessData(); i++; } } catch { Logger.Info("Ошибка при записи ПБР в базу"); } } Logger.Info("Запись номера ПБР"); DateTime ds = DateTime.Now; DateTime de = this.Date.AddDays(1); List <ShadeSelector> sel = new List <ShadeSelector>(); sel.Add(new ShadeSelector() { period = new TimePeriod() { from = new Timestamp() { second = EDSClass.toTS(ds) }, till = new Timestamp() { second = EDSClass.toTS(de) } }, pointId = new PointId() { iess = "NPBR.EDS@CALC" } }); Logger.Info("Удаление номера ПБР"); uint id = EDSClass.Client.requestShadesClear(EDSClass.AuthStr, sel.ToArray()); ok = EDSClass.ProcessQuery(id); if (ok) { List <Shade> shades = new List <Shade>(); List <ShadeValue> vals = new List <ShadeValue>(); vals.Add(new ShadeValue() { period = new TimePeriod() { from = new Timestamp() { second = EDSClass.toTS(ds) }, till = new Timestamp() { second = EDSClass.toTS(de) } }, quality = Quality.QUALITYGOOD, value = new PointValue() { av = NPBR, avSpecified = true } }); shades.Add(new Shade() { pointId = new PointId() { iess = "NPBR.EDS@CALC" }, values = vals.ToArray() }); Logger.Info("Запись данных"); id = EDSClass.Client.requestShadesWrite(EDSClass.AuthStr, shades.ToArray()); ok = EDSClass.ProcessQuery(id); } } } catch (Exception e) { Logger.Info("Ошибка при получении ПБР с сервера MC " + e); } finally { ModesApiFactory.CloseConnection(); } }