using System;
|
using System.Collections.Generic;
|
using System.IO;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
using System.Windows;
|
using System.Windows.Controls;
|
using System.Windows.Data;
|
using System.Windows.Documents;
|
using System.Windows.Input;
|
using System.Windows.Markup;
|
using System.Windows.Media;
|
using System.Windows.Media.Imaging;
|
using System.Windows.Navigation;
|
using System.Windows.Shapes;
|
using System.Runtime.Serialization;
|
using System.Collections.Concurrent;
|
using System.ServiceModel;
|
using Newtonsoft.Json;
|
using Newtonsoft.Json.Linq;
|
using System.Net;
|
using NLog;
|
using NLog.Config;
|
using NLog.Targets;
|
using GZ.DB.Map.OIDATABASE;
|
using GZ.DB.App.OIDATABASE;
|
using GZ.DB.Repository.OIDATABASE;
|
using GZ.DB.IRepository.OIDATABASE;
|
using GZ.DB.Entity.OIDATABASE;
|
namespace GZ.Projects.AuxAllWCS
|
{
|
/// <summary>
|
/// 集成互联
|
/// </summary>
|
public class Conn
|
{
|
public static GZ.Modular.Log.Logger 默认日志 = null;
|
//public static GZ.Modular.Redis.RedisTagHelper 默认Redis = new GZ.Modular.Redis.RedisTagHelper("127.0.0.1:6379", 1000, 1000);
|
//public static GZ.Modular.Redis.RedisTagHelper 默认Redis = new GZ.Modular.Redis.RedisTagHelper();
|
public static GZ.Modular.Redis.RedisTagHelper 默认Redis = new GZ.Modular.Redis.RedisTagHelper(默认日志);
|
public Conn()
|
{
|
//GZ.Modular.Redis.RedisHelper.RedisHostStr="127.0.0.1:6379";
|
//GZ.Modular.Redis.RedisHelper.RedisMaxReadPool=1000;
|
//GZ.Modular.Redis.RedisHelper.RedisMaxWritePool=1000;
|
|
try
|
{
|
string[] allKeys = System.Configuration.ConfigurationManager.AppSettings.AllKeys;
|
if(allKeys.Contains("LogDir"))
|
{
|
if (!System.IO.File.Exists(System.Configuration.ConfigurationManager.AppSettings["LogDir"]))
|
{
|
System.IO.Directory.CreateDirectory(System.Configuration.ConfigurationManager.AppSettings["LogDir"]);
|
}
|
}
|
else
|
{
|
if (!System.IO.File.Exists(@"D:\WCS.LogDB"))
|
{
|
System.IO.Directory.CreateDirectory(@"D:\WCS.LogDB");
|
}
|
}
|
string 默认日志DbPath=@"D:\WCS.LogDB\S7Log";
|
if(allKeys.Contains("LogDir")&&allKeys.Contains("LogFile"))
|
{
|
默认日志DbPath=System.IO.Path.Combine(System.Configuration.ConfigurationManager.AppSettings["LogDir"], System.Configuration.ConfigurationManager.AppSettings["LogFile"]);
|
}
|
int 默认日志DelDays;
|
if(!allKeys.Contains("LogDelDays")||!int.TryParse(System.Configuration.ConfigurationManager.AppSettings["LogDelDays"],out 默认日志DelDays))
|
{
|
默认日志DelDays = 30;
|
}
|
int 默认日志DelLevel;
|
if(!allKeys.Contains("LogDelLevel")||!int.TryParse(System.Configuration.ConfigurationManager.AppSettings["LogDelLevel"],out 默认日志DelLevel))
|
{
|
默认日志DelLevel = 3;
|
}
|
bool 默认日志Info = true;
|
if(allKeys.Contains("LogInfo"))
|
{
|
默认日志Info = System.Configuration.ConfigurationManager.AppSettings["LogInfo"]=="1";
|
}
|
bool 默认日志Debug = true;
|
if(allKeys.Contains("LogDebug"))
|
{
|
默认日志Debug = System.Configuration.ConfigurationManager.AppSettings["LogDebug"]=="1";
|
}
|
bool 默认日志Warn = true;
|
if(allKeys.Contains("LogWarn"))
|
{
|
默认日志Warn = System.Configuration.ConfigurationManager.AppSettings["LogWarn"]=="1";
|
}
|
bool 默认日志Error = true;
|
if(allKeys.Contains("LogError"))
|
{
|
默认日志Error = System.Configuration.ConfigurationManager.AppSettings["LogError"]=="1";
|
}
|
默认日志 = new GZ.Modular.Log.Logger(默认日志DbPath, "S7", 默认日志DelDays, 默认日志DelLevel, 默认日志Info, 默认日志Debug, 默认日志Warn, 默认日志Error,1);
|
默认Redis.Log = 默认日志;
|
|
}
|
catch(Exception ex)
|
{
|
默认日志 = new GZ.Modular.Log.Logger(@"D:\WCS.LogDB\S7Log", "S7", 30, 3, true, true, true, true,1);
|
if(默认日志!=null)
|
{
|
默认日志.Error(ex.ToString());
|
}
|
}
|
|
}
|
}
|
}
|