Exemple #1
0
        /// <summary>
        ///     发送广播的后台任务
        /// </summary>
        private static void SendTask()
        {
            _state = 2;
            while (_state == 2)
            {
                if (!_items.StartProcess(out var item, 100))
                {
                    continue;
                }
                if (!GetSocket(item.Station, out var socket))
                {
                    LogRecorder.Trace(LogType.Error, "Publish",
                                      $@"因为无法找到站点而导致向【{item.Station}】广播的主题为【{item.Title}】的消息被遗弃,内容为:
{item.Content}");
                    _items.EndProcess();
                    continue;
                }
                if (!Send(socket, item))
                {
                    LogRecorder.Trace(LogType.Warning, "Publish",
                                      $@"向【{item.Station}】广播的主题为【{item.Title}】的消息发送失败,内容为:
{item.Content}");
                    continue;
                }
                _items.EndProcess();
            }
            _state = 4;
        }
Exemple #2
0
 public IApiResult TaskTest()
 {
     LogRecorder.Trace(Task.CurrentId?.ToString());
     Task.Delay(100);
     LogRecorder.Trace(Task.CurrentId?.ToString());
     LogRecorder.Trace("VoidAsync");
     return(ApiResultHelper.Succees());
 }
Exemple #3
0
        private static string GetHostIps()
        {
            var ips = new StringBuilder();

            try
            {
                var    first    = true;
                string hostName = Dns.GetHostName();
                LogRecorder.Trace("HostName:{0}", hostName);
                foreach (var address in Dns.GetHostAddresses(hostName))
                {
                    if (address.IsIPv4MappedToIPv6 || address.IsIPv6LinkLocal || address.IsIPv6Multicast ||
                        address.IsIPv6SiteLocal || address.IsIPv6Teredo)
                    {
                        continue;
                    }
                    var ip = address.ToString();
                    if (ip == "127.0.0.1" || ip == "127.0.1.1" || ip == "::1" || ip == "-1")
                    {
                        continue;
                    }
                    if (first)
                    {
                        first = false;
                    }
                    else
                    {
                        ips.Append(" , ");
                    }
                    ips.Append(ip);
                }
            }
            catch (Exception e)
            {
                LogRecorder.Exception(e);
            }

            return(ips.ToString());
        }
Exemple #4
0
 public Task VoidAsync()
 {
     LogRecorder.Trace(Task.CurrentId?.ToString());
     return(Task.Factory.StartNew(TaskTest));
 }
Exemple #5
0
 public Task <IApiResult> FullAsync(Argument arg)
 {
     LogRecorder.Trace($"FullAsync : {arg.Value}");
     LogRecorder.Trace(Task.CurrentId?.ToString());
     return(Task.Factory.StartNew(TaskTest));
 }
Exemple #6
0
 public async Task ArgumentAsync(Argument arg)
 {
     LogRecorder.Trace($"ArgumentAsync : {arg.Value}");
     await Task.Factory.StartNew(TaskTest);
 }
Exemple #7
0
 public async Task <IApiResult> ResultAsync()
 {
     LogRecorder.Trace($"ResultAsync");
     return(await Task.Factory.StartNew(TaskTest));
 }
Exemple #8
0
 public void Argument(Argument arg)
 {
     LogRecorder.Trace($"Argument : {arg.Value}");
 }
Exemple #9
0
 public void GetVoid()
 {
     LogRecorder.Trace("GetVoid");
 }
Exemple #10
0
 public string Full(int name)
 {
     LogRecorder.Trace("Full");
     return("Full");
 }
Exemple #11
0
 public IApiResult Result()
 {
     LogRecorder.Trace("Result");
     return(ApiResultHelper.Succees());
 }
Exemple #12
0
 public ApiResult Get()
 {
     LogRecorder.Trace("Call");
     return(ApiResult.Succees());
 }
 /// <summary>
 ///   校验证书
 /// </summary>
 /// <param name="certificate"> 证书 </param>
 public override void Validate(X509Certificate2 certificate)
 {
     LogRecorder.Trace(certificate.Subject);
     LogRecorder.Trace(certificate.Thumbprint);
 }