首页 > 代码库 > REPL LOG
REPL LOG
using System;using System.Collections.Generic;using System.Text;using System.Text.RegularExpressions;using System.Threading;namespace ConsoleApplication3{ class Program { static void Main(string[] args) { Console.ForegroundColor = DefaultForeColor; Console.BackgroundColor = DefaultBackColor; Console.Clear(); Console.Title = "日志查询工具"; Msg(HelpText); while (true) { var line = Console.ReadLine().ToLower(); if (constCommand.ContainsKey(line)) { Msg(constCommand[line]); continue; } new LogHelper(line).Open(); } } public static void Msg(string str) { Show(str, MessageForeColor); } public static void Show(string message , ConsoleColor color) { Console.ForegroundColor = MessageForeColor; Console.WriteLine(message); Console.ForegroundColor = DefaultForeColor; } public static ConsoleColor DefaultForeColor = ConsoleColor.White; public static ConsoleColor DefaultBackColor = ConsoleColor.DarkBlue; public static ConsoleColor MessageForeColor = ConsoleColor.DarkCyan; public static string HelpText = "k+数字:\n\r 1.可定检查\n\r 2.创建订单\n\r 3.提交订单\n\r 4.中间产品层\n\rd/h+数字:\n\r 1.一天(h是小时)内日志\n\r 2.两天(h是小时)内日志\n\r以此类推... "; public static List<string> KeyList = new List<string> { "xx", "yy", "zz", "88" }; public static Dictionary<string, string> constCommand = new Dictionary<string, string> { { "help", HelpText }, { "", "默认查询" } }; public class LogHelper { private string cmd,msg,url; private int k, d, h; public LogHelper(string cmd) { this.cmd = cmd.ToLower(); } private int GetNumber(string prefix) { Regex reg = new Regex( prefix + "([1-9]+)", RegexOptions.Compiled); var match = reg.Match(cmd).Groups[1].ToString(); if (string.IsNullOrEmpty(match)) return 0; return Convert.ToInt32(match); } public void Open() { k = GetNumber("k"); d = GetNumber("d"); h = GetNumber("h"); //Msg(d.ToString() + k + h); string result = string.Empty; var dateStr = string.Empty; var key = string.Empty; var end = DateTime.Now; if (d > 0) { var begin = end.AddDays(-d); dateStr = getDateStr(begin, end); } else if (h > 0) { var begin = end.AddHours(-h); dateStr = getDateStr(begin, end); } if (k > 0) { key = "key=" + KeyList[k - 1]; } Msg("正在打开1天内的可定检查日志..."); Thread.Sleep(500); //System.Diagnostics.Process.Start("chrome.exe", "http:\\www."+line+".com"); } private string getDateStr(DateTime begin,DateTime end) { string tf = "{0}~{1}"; var dformat = "yyyy-MM-dd HH:mm:ss"; return string.Format(tf, end.ToString(dformat) ,end.ToString(dformat)); } } }}
REPL LOG
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。