/// <summary> /// 日志输出 /// </summary> /// <param name="prefix"></param> /// <param name="dataParas"></param> /// <param name="IsHeader"></param> /// <param name="isWrt"></param> public static void OutSql2Log(string prefix, string[] dataParas, bool IsHeader = true, bool isWrt = false) { if (Appsettings.App(new string[] { "AppSettings", "LogToDb", "Enabled" }).ToBoolReq()) { OutSql2LogToDB(prefix, dataParas, IsHeader); } else { OutSql2LogToFile(prefix, dataParas, IsHeader, isWrt); } }
public static (List <MutiDBOperate>, List <MutiDBOperate>) MutiInitConn() { List <MutiDBOperate> listdatabase = Appsettings.App <MutiDBOperate>("DBS").Where(i => i.Enabled).ToList(); foreach (var i in listdatabase) { SpecialDbString(i); } List <MutiDBOperate> listdatabaseSimpleDB = new List <MutiDBOperate>(); //单库 List <MutiDBOperate> listdatabaseSlaveDB = new List <MutiDBOperate>(); //从库 // 单库,且不开启读写分离,只保留一个 if (!Appsettings.App(new string[] { "CQRSEnabled" }).ToBoolReq() && !Appsettings.App(new string[] { "MutiDBEnabled" }).ToBoolReq()) { if (listdatabase.Count == 1) { return(listdatabase, listdatabaseSlaveDB); } else { var dbFirst = listdatabase.FirstOrDefault(d => d.ConnId == Appsettings.App(new string[] { "MainDB" }).ToString()); if (dbFirst == null) { dbFirst = listdatabase.FirstOrDefault(); } listdatabaseSimpleDB.Add(dbFirst); return(listdatabaseSimpleDB, listdatabaseSlaveDB); } } // 读写分离,且必须是单库模式,获取从库 if (Appsettings.App(new string[] { "CQRSEnabled" }).ToBoolReq() && !Appsettings.App(new string[] { "MutiDBEnabled" }).ToBoolReq()) { if (listdatabase.Count > 1) { listdatabaseSlaveDB = listdatabase.Where(d => d.ConnId != Appsettings.App(new string[] { "MainDB" }).ToString()).ToList(); } } return(listdatabase, listdatabaseSlaveDB); }