示例#1
0
        private static int GetMinute(string keyPrefix)
        {
            Dictionary <string, int> dic = CfgService.GetAllUpdateSetConfig();

            if (dic.Keys.Contains(keyPrefix))
            {
                return(dic[keyPrefix]);
            }
            return(DefaultMinute);
        }
示例#2
0
 public void AppStart(object sender, StartupEventArgs args)
 {
     Bootstrap.Build();
     if (CfgService.ReadPropertyParseBool("showCfgWndOnStartup"))
     {
         Window optionsWindow = new OptionsWindow();
         optionsWindow?.ShowDialog();
     }
     else
     {
         Window mainWindow = new MainWindow();
         mainWindow?.Show();
     }
 }
示例#3
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;
                    }
                });
            }
        }