示例#1
0
        public static void SilentAll(bool activate = true, bool includeMethods = false)
        {
            string className  = GetCallerClassName();
            string methodName = GetCallerMethodName();

            if (activate)
            {
                if (includeMethods && !_allowedThreadMethod.Contains(methodName))
                {
                    _allowedThreadMethod.Add(methodName);
                }

                if (!_allowedThreadClass.Contains(className))
                {
                    _allowedThreadClass.Add(className);
                }

                XConsole.WriteLine($"ALL CHANNELS SILENT WITHOUT {className}~{methodName}");
            }
            else
            {
                _allowedThreadClass.Remove(className);
                _allowedThreadMethod.Remove(methodName);
            }
        }
示例#2
0
        public static void WebException(WebException ex)
        {
            WriteGenericLog(ex);
            logManager.Write(ex.Response?.ResponseUri.AbsoluteUri);

            XConsole.WriteLine(ex.Response?.ResponseUri.AbsoluteUri, colorSet);
        }
示例#3
0
        public static T WebGet <T>(string method, string apiKey, params object[] parameters)
        {
            try
            {
#if DEBUG
                WebRequest request = WebRequest.CreateHttp($"http://{Extensions.GetLocalIPAddress()}:90/{method}/{string.Join("/", parameters)}?NGAuthVKey={apiKey}");
#else
                WebRequest request = WebRequest.CreateHttp($"{serverUrl}/{method}/{string.Join("/", parameters)}?NGAuthVKey={apiKey}");
#endif
                request.Method      = "GET";
                request.ContentType = "application/json";

                WebResponse response = request.GetResponse();

                StreamReader responseStream = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
                string       incMsg         = responseStream.ReadToEnd();
                T            json           = JsonConvert.DeserializeObject <T>(incMsg);
                return(json);
            }
            catch (WebException ex)
            {
                logManager.Write(ex.Message);
                logManager.Write(ex.StackTrace);
                logManager.Write(ex.HResult.ToString());
                logManager.Write(ex.Source);
                logManager.Write(ex.Data.ToString());
                logManager.Write(ex.Response.ResponseUri.AbsoluteUri);
                XConsole.WriteLine(ex.ToString(), ConsoleTheming.ConsoleColorSetRed.Instance);
                XConsole.WriteLine(ex.Response.ResponseUri.AbsoluteUri, ConsoleTheming.ConsoleColorSetRed.Instance);
                return(default);
示例#4
0
        private static void WriteGenericLog(Exception ex)
        {
            logManager.Write(ex.Message);
            logManager.Write(ex.StackTrace);
            logManager.Write(ex.HResult.ToString());
            logManager.Write(ex.Source);
            logManager.Write(ex.Data.ToString());

            XConsole.WriteLine(ex.ToString(), colorSet);
        }