private void User() { try { WindowUser window = new WindowUser(EventsBase.GetInstance().GetControlEvents(OpcServer.OpcList.Rbu)); window.Show(); } catch (Exception) { MessageBox.Show("Нет связи с базой данных", "Предупреждение"); } }
private void LoginPasswordCorrect(User user) { SelUser.GetInstance().SetSelUser(user); if (!_isLoad) { Closed += _elScreen.OnClose; _elScreen.Initialize(_logger); ScreenGrid.Children.Add(_elScreen); _elScreen.Visibility = Visibility.Visible; _elScreen.LoginClick += Login; _elScreen.UserClick += User; _isLoad = true; } EventsBase.GetInstance().GetControlEvents(OpcServer.OpcList.Rbu).AddEvent("Пользователь " + user.UserName + " вошел в программу", SystemEventType.Message); _elScreen.ViewModelScreenRbu.GetUserPermit(); this.Show(); }
public void GetLink() { CurrentDateTime = !Cherry?DateTime.Now.ToString("HH:mm:ss dd.MM.yyyy") : _linkValue.ToString(); _link = _linkValue != _currentLinkValue; _currentLinkValue = _linkValue; if (_link) { if (!Static.Link) { EventsBase.GetInstance().GetControlEvents(_opcName).AddEvent("Связь со шкафом управления установлена", SystemEventType.Message); } if (!_firstLink) { CreateAutoEvent(); _firstLink = true; } _cycle = 0; LinkOk = Static.Link = true; } else { _cycle++; } if (_cycle > 12) { if (Static.Link || !_firstCheckLink) { EventsBase.GetInstance().GetControlEvents(_opcName).AddEvent("Нет связи со шкафом управления", SystemEventType.Alarm); _firstCheckLink = true; } LinkOk = Static.Link = false; _cycle = 15; } IsUpdating = false; }
public MainWindow() { ServiceData.Init(@"Data/Service.xlsx"); Release.Init(Assembly.GetExecutingAssembly().GetName().Version); _windowSplash = new WindowSplash(); _windowSplash.Show(); Opc.UaFx.Client.Licenser.LicenseKey = "AALOERR5OO7EKFNQCABINGCH6TYOVHPLFC2QCUYAV3IYL7FGRNBJ4TYJX2GM6HKSCKZLBJWGHUWWXQ5HKWI7OFVYYMERDPQDC7ZW7ZTLPTM" + "LWLMY3RMLD2UQ6OXKUKC2YBBPBRGK6SBRI4DBXF4NGVKZUATMW3VI7EALG5FQNCETII7JG7OT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FQ2KTXXIB75LVC7EHAZ2AF3OELXR2YP2AVTIGKBEPXAJIFQLB6CKHQQEHHSSPWO3HQHTYVZYGMVM4KUTDRHHSGUA"; Stimulsoft.Base.StiLicense.Key = "6vJhGtLLLz2GNviWmUTrhSqnOItdDwjBylQzQcAOiHlo0BLi03H5eu1wfyYtghdwJHRIUDASSNqz5wYiN/0REuF5rx" + "l0PuYej+g+9PW3zj9rf4q2Hr3Rp+4siFan2+bLDIWecyw4cso2kClUxmGiOPMf8e9yf/4LU06O2KwITH9htGzZ5H8f" + "WkYXqiSRovW8fvjzPHMKsHri+ywu+vv1sGfAwA0zzPsF2OEmeNC34NoNvq0aHta9JYfhfq9bkKZym8x02csbJJuI2R" + "c3V1rG5B/jATAQfCMOVMRttnnmQ6VnSEiSRStLhvBtVE0bC1kq4Z4RNpUVrGVcBn6w41aSyD8uOc78dBIu7a3ykZ45" + "1A/Q3ww3T1GtnmfAkGLK2b/srd675k7fpZrVlyiLH7BfEyo+hrBj51dYG0IaJqzseeuSh7GFjJZCihujJNgugyR4Id" + "N4KjrZg2sAuO4JeNlvzZvyQ7wNzu92lFHGoZGLnnKIAUQUk8FECgamOxYIYzP4UzLturdpFL6MBW6c9E0SdRy+Ydnb" + "SH40eSD+WGmkWgDhi8JDzJK2aIjAcTpjguEE"; InitializeComponent(); #region Init _logger = Service.GetInstance().GetLogger(); LibService.Init(_logger); LibService.GetInstance().SetDbConnectionString(Service.GetInstance().GetOpcDict()["DbConnectionString"]); AsLibraryCore.LibService.GetInstance().SetEventsDbConnectionString(Service.GetInstance().GetOpcDict()["EventsDbConnectionString"]); NewOpcServer.Init(_logger); NewOpcServer.GetInstance().InitOpc(NewOpcServer.OpcList.Rbu); NewOpcServer.GetInstance().ConnectOpc(NewOpcServer.OpcList.Rbu); var reportHelper = new ReportHelper(_logger); reportHelper.SubscribeReportSaving(); OpcServer.Init(@"Data/Service.xlsx"); OpcServer.GetInstance(); OpcServer.GetInstance().InitOpc(OpcServer.OpcList.Rbu, Service.GetInstance().GetOpcDict()["OpcServerAddress"]); OpcServer.GetInstance().ConnectOpc(OpcServer.OpcList.Rbu); EventsBase.GetInstance().CreateControlEvents(OpcServer.OpcList.Rbu); #endregion Title = ServiceData.GetInstance().GetTitle() + " " + Release.GetInstance().GetReleaseTitle(); Login(); EventsBase.GetInstance().GetControlEvents(OpcServer.OpcList.Rbu).AddEvent("Программа управления открыта", SystemEventType.Message); #region Масштаб экрана (comment) //var rect = SystemParameters.WorkArea; //if (rect.Width != 1920) // MainGrid.LayoutTransform = // new ScaleTransform(Math.Min(rect.Width, 1920) / 1920, Math.Min(rect.Height, 1080) / 1080); #endregion }
void Program_Closing(object sender, CancelEventArgs e) { EventsBase.GetInstance().GetControlEvents(OpcServer.OpcList.Rbu).AddEvent("Программа управления закрыта", SystemEventType.Message); }
private void Save() { try { ParameterValue = ParameterValue.Replace(".", ","); var result = Double.TryParse(ParameterValue, out _finishValue); if (result) { if (_finishValue <= MaxValue && _finishValue >= MinValue) { switch (_valueType) { case ValueType.Byte: _opc.cl.WriteByte(_opcTag, Convert.ToByte(_finishValue), out _err); break; case ValueType.Int16: _opc.cl.WriteInt16(_opcTag, Convert.ToInt16(_finishValue), out _err); if (!string.IsNullOrEmpty(_additionalTag)) { _opc.cl.WriteInt16(_additionalTag, Convert.ToInt16(_finishValue), out _err); } break; case ValueType.Int32: _opc.cl.WriteInt32(_opcTag, Convert.ToInt32(_finishValue), out _err); break; case ValueType.Real: _opc.cl.WriteReal(_opcTag, (float)_finishValue, out _err); break; case ValueType.UInt16: _opc.cl.WriteUInt16(_opcTag, Convert.ToUInt16(_finishValue), out _err); break; case ValueType.UInt32: _opc.cl.WriteUInt32(_opcTag, Convert.ToUInt32(_finishValue) * 1000, out _err); break; } EventsBase.GetInstance().GetControlEvents(OpcServer.OpcList.Rbu).AddEvent("Параметр \"" + ParameterName + "\" изменен с " + _startValue + " на " + _finishValue.ToString($"F{_digit}"), SystemEventType.UserDoing); if (_err) { MessageBox.Show("Возможно запись не прошла.\nПроверьте OPC-сервер или соответствующий тег", "Предупреждение"); } Close(); } else { MessageBox.Show("Введите число в заданном диапазоне. Повторите ввод", "Предупреждение"); } } else { MessageBox.Show("В строке не содержится число", "Ошибка!"); } } catch (Exception ex) { MessageBox.Show("Запись не прошла. Повторите ввод\n" + ex.Message, "Ошибка"); } }