private static void sender_Sended(object sender, DistributedEventArgs e) { var dispatcher = sender as IDispatcher; if (dispatcher == null) { throw new AnycmdException(); } Console.ForegroundColor = ConsoleColor.Green; if (!e.Context.Result.IsSuccess) { Console.ForegroundColor = ConsoleColor.Red; } Console.WriteLine(string.Format("响应 {0} {1}", e.Context.Result.ReasonPhrase, e.Context.Result.Description)); Console.WriteLine(string.Format("状态码:{0}\n说明:{1}", e.Context.Result.Status.ToString(), e.Context.Result.Description)); if (!e.Context.Result.IsSuccess) { Console.ForegroundColor = ConsoleColor.Green; } Console.WriteLine(string.Format("完成发送时间戳:{0}\n本次发送耗时长:{1}", e.DistributedOn, e.TimeSpan)); Console.WriteLine(string.Format( "累计发送{0}条,成功{1}条,失败{2}条", dispatcher.SucessCount + dispatcher.FailCount, dispatcher.SucessCount, dispatcher.FailCount)); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write(@"----------------------------------"); Console.Write(@"发送结束"); Console.Write(@"----------------------------------"); Console.ForegroundColor = ConsoleColor.Gray; }
private static void sender_Sended(object sender, DistributedEventArgs e) { var dispatcher = sender as IDispatcher; if (dispatcher == null) { throw new AnycmdException(); } Console.ForegroundColor = ConsoleColor.Green; if (!e.Context.Result.IsSuccess) { Console.ForegroundColor = ConsoleColor.Red; } Console.WriteLine(string.Format("响应 {0} {1}", e.Context.Result.ReasonPhrase, e.Context.Result.Description)); Console.WriteLine(string.Format("状态码:{0}\n说明:{1}", e.Context.Result.Status.ToString(), e.Context.Result.Description)); if (!e.Context.Result.IsSuccess) { Console.ForegroundColor = ConsoleColor.Green; } Console.WriteLine(string.Format("完成发送时间戳:{0}\n本次发送耗时长:{1}", e.DistributedOn, e.TimeSpan)); Console.WriteLine(string.Format( "累计发送{0}条,成功{1}条,失败{2}条", dispatcher.SucessCount + dispatcher.FailCount, dispatcher.SucessCount, dispatcher.FailCount)); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write(@"----------------------------------"); Console.Write(@"发送结束"); Console.Write(@"----------------------------------"); Console.ForegroundColor = ConsoleColor.Gray; }