Пример #1
0
        private void Connect()
        {
            sControll = new settingsController();
            if (sControll.isFirstRun)
            {
                sForm = new settings(sControll);
                sForm.ShowDialog();
            }
            if (zApi != null)
            {
                zApi.stop();
            }
            trMaps.Items.Clear();
            trTriggers.Items.Clear();

            zApi           = new ZabbixConnection(sControll.host, sControll.user, sControll.pass);
            zApi.onUpdate += update_info;
            this.Cursor    = Cursors.Wait;
            zApi.connect();
        }
Пример #2
0
        public MapVisualElement(MapElement element, Map parentMap, ZabbixConnection connection)
        {
            InitializeComponent();
            // this.ToolTip = element.url ;
            data             = element;
            map              = parentMap;
            label.Content    = data.label;
            zabbixConnection = connection;
            StringBuilder tooltip  = new StringBuilder();
            StringBuilder problems = new StringBuilder();
            StringBuilder works    = new StringBuilder();


            states[0] = new GradientStopCollection();
            states[1] = new GradientStopCollection();
            states[2] = new GradientStopCollection();
            states[3] = new GradientStopCollection();

            states[0].Add(new GradientStop(Color.FromArgb(255, 50, 255, 50), 0.0));

            states[0].Add(new GradientStop(Color.FromArgb(255, 00, 56, 34), 1.0));
            states[1].Add(new GradientStop(Colors.Red, 0.0));
            states[1].Add(new GradientStop(Colors.DarkRed, 1.0));
            states[2].Add(new GradientStop(Colors.Yellow, 0.0));
            states[2].Add(new GradientStop(Colors.OrangeRed, 1.0));
            states[3].Add(new GradientStop(Colors.Gray, 0.0));
            states[3].Add(new GradientStop(Colors.DarkGray, 1.0));

            this.SetState(0);

            tooltip.Append("Триггеры:\n");
            problems.Append("\tПроблемы:\n");
            works.Append("\tНет проблем:\n");

            if (data.triggers != null)
            {
                int WorkTrigger = data.triggers.Length;
                foreach (Zabbix.Trigger tr in data.triggers)
                {
                    if (tr.value != "0")
                    {
                        //problems.Append("\t\t" + tr.description.Replace("{HOSTNAME}", tr.host.host) + "[" + tr.lastchangeDateTime.ToString() + "]\n");
                        tltp.Items.Add(new { text = tr.description.Replace("{HOSTNAME}", tr.host.host), value = tr.value });
                    }
                    //else { works.Append("\t\t" +tr.description.Replace("{HOSTNAME}", tr.host.host) + "[" + tr.lastchangeDateTime.ToString() + "]\n"); }
                    WorkTrigger -= Int32.Parse(tr.value);
                }
                foreach (Zabbix.Trigger tr in data.triggers)
                {
                    if (tr.value == "0")
                    {
                        //problems.Append("\t\t" + tr.description.Replace("{HOSTNAME}", tr.host.host) + "[" + tr.lastchangeDateTime.ToString() + "]\n");
                        tltp.Items.Add(new { text = tr.description.Replace("{HOSTNAME}", tr.host.host), value = tr.value });
                    }
                    //else { works.Append("\t\t" +tr.description.Replace("{HOSTNAME}", tr.host.host) + "[" + tr.lastchangeDateTime.ToString() + "]\n"); }
                    //WorkTrigger -= Int32.Parse(tr.value);
                }
                if (WorkTrigger == data.triggers.Length)
                {
                    SetState(0);
                }
                else
                if (WorkTrigger == 0)
                {
                    SetState(1);
                }
                else
                {
                    SetState(2);
                }
            }
            if (data.elementtype != "0")
            {
                this.SetState(3);
            }
            //this.ToolTip = "Триггеры:\n"+problems+works;
            if (!File.Exists("images/" + data.iconid_off))
            {
                image_on = zabbixConnection.GetImageByID(data.iconid_off);
                FileStream fl = File.Create("images/" + data.iconid_off);
                image_on.CopyTo(fl);
                fl.Close();
            }
            BitmapImage bi = new BitmapImage();

            byte[]       bytes = File.ReadAllBytes("images/" + data.iconid_off);
            MemoryStream ms    = new MemoryStream(bytes);

            bi.BeginInit();
            bi.StreamSource = ms;
            bi.EndInit();
            image.Source = bi;


            //myBrush.GradientStops.Add(new GradientStop(Colors.Orange, 0.5));
        }