Beispiel #1
0
 private void DataGatheredEvent(object sender, DashboardEventArgs e)
 {
     try
     {
         _clients.Clients.All.InvokeAsync("GetLiveDeltas", new HostDeltasModel
         {
             ElapsedMs = e.ElapsedMs,
             Deltas    = e.HostDeltas.Select(h => new HostDeltaModel
             {
                 Hostname = (string.IsNullOrEmpty(h.Hostname) || h.Hostname == "(none)") ? h.Ip : h.Hostname,
                 Speed    = h.LastCheckDeltaBytes
             })
         }).Wait();
     }
     catch (Exception exc)
     {
         Console.WriteLine("Error pushing dashboard deltas: " + exc.InnerException != null ? exc.InnerException.Message : exc.Message);
     }
 }
Beispiel #2
0
 private void DataGatheredEvent(object sender, DashboardEventArgs e)
 {
     try
     {
         _clients.Clients.All.SendAsync("GetLiveDeltas", new HostDeltasModel
         {
             ElapsedMs = e.ElapsedMs,
             Deltas    = e.HostDeltas.Select(h => new HostDeltaModel
             {
                 Hostname = (string.IsNullOrEmpty(h.Hostname) || h.Hostname == "(none)") ? h.Ip : h.Hostname,
                 Speed    = h.LastCheckDeltaBytes
             })
         }).Wait();
     }
     catch (Exception exc)
     {
         Log.Fatal(exc, "Error pushing dashboard deltas");
     }
 }
 private void OnDashboardView(DashboardEventArgs arg)
 {
     this.RegionManager.RequestNavigate(RegionNames.MainRegion, WindowNames.Dashboard);
 }
Beispiel #4
0
 void Dashboards_DashboardActivated(object sender, DashboardEventArgs e)
 {
     if (e.Dashboard == null) return;
     var s = e.Dashboard.States;
     if (s.ContainsKey(BasemapState))
     {
         AppState.ViewDef.BaseLayers.ChildLayers.Clear();
         var ll = s[BasemapState].Split(';');
         foreach (var l in ll)
         {
             var pp = l.Split('|');
             if (pp.Length == 3)
             {
                
                     AppState.ViewDef.AddMapType(pp[0], double.Parse(pp[2], CultureInfo.InvariantCulture));
                 
             }
         }
         
     }
     if (s.ContainsKey(RotationState))
     {
         AppState.ViewDef.MapControl.Rotation = double.Parse(s[RotationState], CultureInfo.InvariantCulture);
     }
     if (!s.ContainsKey(ExtentState)) return;
     //AppState.ViewDef.StartTransition();
     var ex = s[ExtentState];
     AppState.ViewDef.MapControl.Extent = (Envelope)new EnvelopeConverter().ConvertFromString(ex);
 }
Beispiel #5
0
        private void Dashboards_DashboardActivated(object sender, DashboardEventArgs e)
        {
            if (e.Dashboard == null) return;
            var s = e.Dashboard.States;

            if (!s.ContainsKey("Layers")) return;
            var layerState = s["Layers"].Split('~');
            foreach (var l in layerState)
            {
                try
                {
                    var ll = l.Split('|');
                    if (ll.Length < 4) continue;
                    var id = Guid.Parse(ll[1]);

                    var service = Dsb.Services.FirstOrDefault(k => k.Id == id);
                    var poiService = service as PoiService;
                    if (poiService == null) continue;
                    var ps = poiService;
                    bool started;
                    if (!bool.TryParse(ll[7], out started)) continue;
                    if (!ps.Layer.IsStarted && started) ((IStartStopLayer)ps.Layer).Start();
                    if (ps.Layer.IsStarted && !started)
                        ((IStartStopLayer)ps.Layer).Stop();

                    if (ll.Length > 7)
                    {
                        var sl = ll[8];
                        foreach (var ls in sl.Split(';'))
                        {
                            if (!string.IsNullOrEmpty(ls))
                            {
                                var sll = ls.Split('_');
                                if (sll.Length == 3)
                                {
                                    var a = ps.Layer.ChildLayers.FirstOrDefault(k => k.ID == sll[0]);
                                    if (a!=null)
                                    {
                                        a.Visible = bool.Parse(sll[1]);
                                        a.Opacity = double.Parse(sll[2], CultureInfo.InvariantCulture);
                                    }
                                }
                            }
                        }
                        
                    }
                    //ps.Initialized += (ts, b) =>
                    //{
                    //    if (ll.Length > 7)
                    //    {

                    //        if (ps.Layer is dsBaseLayer)
                    //        {
                    //            var bl = (dsBaseLayer) ps.Layer;
                    //            Execute.OnUIThread(() =>
                    //            {

                    //                bl.Visible = bool.Parse(ll[5]);
                    //                bl.Opacity = double.Parse(ll[6], CultureInfo.InvariantCulture);
                    //            });


                    //            if (bool.TryParse(ll[7], out started))
                    //            {
                    //                if (started) ((IStartStopLayer) bl).Start();
                    //                if ((((IStartStopLayer) bl).IsStarted) && !started)
                    //                    ((IStartStopLayer) bl).Stop();
                    //            }


                    //        }

                    //    }
                    //};
                }
                catch (Exception et)
                {
                    Logger.Log("Dashboard", "Error restoring layer", et.Message, Logger.Level.Error);
                }
            }
            AppState.ViewDef.UpdateLayers();
            //if (s.ContainsKey(TimelineState)) TimelineVisible = bool.Parse(s[TimelineState]);
        }