Пример #1
0
 protected virtual void OnNotifyChange(EventArgs args)
 {
     NotifyChange?.Invoke(this, args);
 }
Пример #2
0
 public void UpdatedBack()
 {
     NotifyChange?.Invoke();
 }
Пример #3
0
 private void FileSystemChanged(FileModel model, WatcherChangeTypes type)
 {
     NotifyChange?.Invoke(new ChangedFileModel(model.Name, model.Path, type));
 }
Пример #4
0
        public void Start()
        {
            if (NbxJobTask == null)
            {
                NbxJobTask = Task.Run(() =>
                {
                    IPEndPoint local   = new IPEndPoint(IPAddress.Parse(Ip), 0);
                    IPEndPoint destino = new IPEndPoint(IPAddress.Parse(ServerIp), ServerPort);
                    try
                    {
                        Error = false;
                        using (UdpClient client = new UdpClient(local))
                        {
                            int count = 20;
                            Running   = true;
                            while (Running)
                            {
                                Task.Delay(100).Wait();
                                if (count-- <= 0)
                                {
                                    count = 20;
                                    if (Active)
                                    {
                                        try
                                        {
#if _NBX_NOT_SPLITTED__
                                            Byte[] msg =
                                            {
                                                (Byte)CfgService,       (Byte)RadioService, (Byte)TifxService, (Byte)PresService,
                                                (Byte)0xff,             (Byte)0xff,         (Byte)0xff,        (Byte)0xff,
                                                (Byte)(WebPort & 0xff),
                                                (Byte)(WebPort >> 8)
                                            };
                                            client.Send(msg, msg.Length, destino);
                                            NotifyChange?.Invoke(String.Format("{0}: Sending msg C:{1}, R:{2}, T:{3}, P:{4}", Ip, msg[0], msg[1], msg[2], msg[3]));
#else
                                            if (UlisesNbxItem.Mode == "Mixed")
                                            {
                                                var data = new
                                                {
                                                    Machine         = Environment.MachineName,
                                                    ServerType      = "Mixed",
                                                    GlobalMaster    = "Master",
                                                    RadioService    = RadioService.ToString(),
                                                    CfgService      = CfgService.ToString(),
                                                    PhoneService    = PhoneService.ToString(),
                                                    TifxService     = TifxService.ToString(),
                                                    PresenceService = PresService.ToString(),
                                                    WebPort,
                                                    TimeStamp = DateTime.Now
                                                };
                                                string msg = JsonConvert.SerializeObject(data);
                                                Byte[] bin = Encoding.ASCII.GetBytes(msg);
                                                client.Send(bin, bin.Length, destino);

                                                NotifyChange?.Invoke(String.Format("{0}: Sending msg {1}", Ip, msg));
                                            }
                                            else
                                            {
                                                if (NbxType == NbxTypes.Radio || NbxType == NbxTypes.Ambos)
                                                {
                                                    var data = new
                                                    {
                                                        Machine         = Environment.MachineName,
                                                        ServerType      = "Radio",
                                                        GlobalMaster    = "Master",
                                                        RadioService    = RadioService.ToString(),
                                                        CfgService      = CfgService.ToString(),
                                                        PhoneService    = PhoneService.ToString(),
                                                        TifxService     = TifxService.ToString(),
                                                        PresenceService = PresService.ToString(),
                                                        WebPort,
                                                        TimeStamp = DateTime.Now
                                                    };
                                                    string msg = JsonConvert.SerializeObject(data);
                                                    Byte[] bin = Encoding.ASCII.GetBytes(msg);
                                                    client.Send(bin, bin.Length, destino);

                                                    NotifyChange?.Invoke(String.Format("{0}: Sending msg {1}", Ip, msg));
                                                }

                                                if (NbxType == NbxTypes.Telefonia || NbxType == NbxTypes.Ambos)
                                                {
                                                    var data = new
                                                    {
                                                        Machine         = Environment.MachineName,
                                                        ServerType      = "Phone",
                                                        GlobalMaster    = "Master",
                                                        RadioService    = RadioService.ToString(),
                                                        CfgService      = CfgService.ToString(),
                                                        PhoneService    = PhoneService.ToString(),
                                                        TifxService     = TifxService.ToString(),
                                                        PresenceService = PresService.ToString(),
                                                        WebPort,
                                                        TimeStamp = DateTime.Now
                                                    };
                                                    string msg = JsonConvert.SerializeObject(data);
                                                    Byte[] bin = Encoding.ASCII.GetBytes(msg);
                                                    client.Send(bin, bin.Length, destino);

                                                    NotifyChange?.Invoke(String.Format("{0}: Sending msg {1}", Ip, msg));
                                                }
                                            }
#endif
                                        }
                                        catch (Exception x)
                                        {
                                            _log.Error($"UlisesNbx Exception", x);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception)
                    {
                        Error = true;
                    }
                });
            }
        }