Beispiel #1
0
        public static string GetSubscribedStateChanges()
        {
            Dictionary <string, string> items = new Dictionary <string, string>();

            if (Global.State.Subscriptions["schedulerRunning"].Subscribed && Global.State.Subscriptions["schedulerRunning"].IsReady())
            {
                bool update = (Global.State.SchedulerTC.State == ThreadControlState.Running) != (bool)Global.State.Subscriptions["schedulerRunning"].State;
                if (update)
                {
                    bool val = (Global.State.SchedulerTC.State == ThreadControlState.Running);
                    Global.State.Subscriptions["schedulerRunning"].State = val;
                    items.Add("schedulerRunning", UC.BoolToJSBool(val));
                }
            }

            if (Global.State.Subscriptions["applicationStats"].Subscribed && Global.State.Subscriptions["applicationStats"].IsReady())
            {
                items.Add("applicationStats", SerializerMethods.SerializeApplicationStats());
            }



            if (Global.State.Subscriptions["threadControlTree"].Subscribed && Global.State.Subscriptions["threadControlTree"].IsReady())
            {
                lock (Global.State.ThreadControlTreeLock)
                {
                    long change = GetThreadControlTreeChangeValue();
                    if (change != (long)Global.State.Subscriptions["threadControlTree"].State)
                    {
                        Global.State.Subscriptions["threadControlTree"].State = change;
                        items.Add("threadControlTree", SerializerMethods.SerializeThreadControlTree());
                    }
                }
            }

            // don't do this if we already have a threadControlTree
            if (Global.State.Subscriptions["threadControlState"].Subscribed && !items.ContainsKey("threadControlTree") && Global.State.Subscriptions["threadControlState"].IsReady())
            {
                lock (Global.State.ThreadControlTreeLock)
                {
                    string json  = GetSerializedThreadControlChangedState();
                    string state = UC.MD5Hash(json);
                    if (!string.IsNullOrWhiteSpace(json) && state != (string)Global.State.Subscriptions["threadControlState"].State)
                    {
                        Global.State.Subscriptions["threadControlState"].State = state;
                        items.Add("threadControlState", json);
                    }
                }
            }

            if (Global.State.Subscriptions["threadControlLog"].Subscribed && Global.State.Subscriptions["threadControlLog"].IsReady())
            {
                Tools.LogObjects.Log log = RecursiveFindLogByThreadControlId(Global.State.SelectedThreadControlId, Global.State.ThreadControlTree);
                if (log != null && (log.ChangedSinceLastRead(Verbosity.Verbose) || Global.State.ThreadControlIdChanged))
                {
                    items.Add("threadControlLog", "\"" + System.Web.HttpUtility.JavaScriptStringEncode(log.Read(Verbosity.Verbose)) + "\"");
                }
            }

            Global.State.ThreadControlIdChanged = false;

            return(SerializerMethods.DictionarySerializedValuesToJSON(items));
        }