/// <summary> /// 记录Fetal日志 /// </summary> /// <param name="message"></param> /// <param name="isEnableDbLog"></param> public static void Fatal(string message, bool isEnableDbLog = false) { if (string.IsNullOrEmpty(message)) { return; } try { Slogger.Fatal(message); if (isEnableDbLog) { LogItem item = new LogItem() { Id = GuidUtils.GetGuid32(), LogSource = "", LogType = "fatal", CreateTime = DateTime.Now, LogContent = message }; CommonObject model = new CommonObject() { TheObject = item, TheObjectType = CommonModelType.LogType }; SblockingQueueEx.Add(model); } } catch (Exception) { } }
public static void Main(string[] args) { //红黑树 SortedDictionary <string, string> rbTree = new SortedDictionary <string, string>(); DirectoryHold.ResetCurrentDir(); NLogHelper.Info(GuidUtils.GetGuid32()); NLogHelper.Trace("Trace"); NLogHelper.Debug("Debug"); NLogHelper.Info("Info"); NLogHelper.Warn("Warn"); NLogHelper.Error("Error"); NLogHelper.Fatal("Fatal"); }
/// <summary> /// 该代码正常运行 /// /// 默认ef的provider是sqlserver,通过注释[DbConfigurationType(typeof(MySqlEFConfiguration))]来改变 /// </summary> public static void TestDynamicConnectionString() { string conStr = @"Server=127.0.0.1;Port=3306;Database=test{0}db;Uid=root;Pwd=root;Pooling=True;Max Pool Size=15;CharSet=utf8;Keepalive=16;"; for (int i = 0; i < 8; i++) { string conStrTemp = string.Format(conStr, i); using (MySqlDbContext context = new MySqlDbContext(conStrTemp)) { context.ListItems.Add(new Common.Utils.sqls.EF2.CommonDbModels.ListItem() { Id = GuidUtils.GetGuid32(), Item = i.ToString(), CreateTime = DateTime.Now }); context.SaveChanges(); } } }