1
czw
2025-06-19 81c4b6f2f8317dc179f52c7d2868cb9af9b16bac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
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());
                }
            }
            
        }
    }
}