Exemplo n.º 1
0
        public static void Add(TraceMessage trm)
        {
            if (traceMessageList.Count >= DecisionServiceTrace.MaxTraceCount)
            {
                traceMessageList.Clear();
                DecisionServiceTrace.Add(new TraceMessage {
                    Message = string.Format("Max # trace messages received : {0}, resetting.", DecisionServiceTrace.MaxTraceCount)
                });
            }

            string lowerCaseMessage = trm.Message.ToLower();

            if (lowerCaseMessage.Contains("model update") ||
                lowerCaseMessage.Contains("successfully uploaded") ||
                lowerCaseMessage.Contains("retrieved new model"))
            {
                trm.Message = TraceMessage.GetHeader(TraceMessage.TraceComponentType.Client) + trm.Message;
            }

            traceMessageList.Add(trm);

            IHubContext hub = GlobalHost.ConnectionManager.GetHubContext <TraceHub>();

            hub.Clients.All.addNewMessageToPage(trm.Message, trm.TimeStampInMillisecSinceUnixEpoch);
        }
Exemplo n.º 2
0
        public static void Reset()
        {
            // Clear trace messages
            DecisionServiceTrace.Clear();

            // Reset DecisionService objects
            if (Service != null)
            {
                Service.Flush();
                Service.Dispose();
            }

            Explorer             = null;
            Configuration        = null;
            Service              = null;
            LastBlobModifiedDate = new DateTimeOffset();

            // Reset all settings via the command center (storage, metadata, etc...)
            using (var client = new System.Net.Http.HttpClient())
            {
                var values = new Dictionary <string, string>
                {
                    { "token", appToken }
                };
                var content = new System.Net.Http.FormUrlEncodedContent(values);

                var responseTask = client.PostAsync(
                    // TODO: use https
                    commandCenterAddress + "/Application/Reset",
                    content
                    );
                responseTask.Wait();

                var response = responseTask.Result;
                if (!response.IsSuccessStatusCode)
                {
                    var t2 = response.Content.ReadAsStringAsync();
                    t2.Wait();
                    System.Diagnostics.Trace.TraceError("Failed to reset application. Result : {0}, Reason: {1}, Details: {2}",
                                                        t2.Result, response.ReasonPhrase, response.Headers.ToString());
                }
            }
        }
 public override void WriteLine(string message)
 {
     DecisionServiceTrace.Add(new TraceMessage {
         Message = message
     });
 }