Beispiel #1
0
        static void Main(string[] args)
        {
            // 创建Redis
            RedisClient redis = new RedisClient("127.0.0.1", 6379, "");

            redis.SetPersistentConnection( ); // 设置长连接

            // 创建日志
            ILogNet logNet = new LogNetSingle("log.txt");

            logNet.BeforeSaveToFile += LogNet_BeforeSaveToFile;

            SharpNodeServer sharpNodeServer = new SharpNodeServer( );

            sharpNodeServer.LogNet            = logNet;
            sharpNodeServer.WriteCustomerData = (Device.DeviceCore deviceCore, string name) =>
            {
                OperateResult write = redis.WriteKey(string.Join(":", deviceCore.DeviceNodes) + ":" + name, deviceCore.GetStringValueByName(name));
                if (!write.IsSuccess)
                {
                    Console.WriteLine("Redis Write Failed");
                }
            };
            // 加载配置文件之前设置redis写入方法
            sharpNodeServer.LoadByXmlFile("settings.xml");
            sharpNodeServer.ServerStart(12345);

            Console.ReadLine( );
        }
Beispiel #2
0
        private void FormLogNet_Load(object sender, EventArgs e)
        {
            logNet = new LogNetSingle("log.txt");
            comboBox1.DataSource            = HslCommunication.BasicFramework.SoftBasic.GetEnumValues <HslMessageDegree>( );
            comboBox1.SelectedItem          = HslMessageDegree.DEBUG;
            comboBox2.DataSource            = HslCommunication.BasicFramework.SoftBasic.GetEnumValues <HslMessageDegree>( );
            comboBox2.SelectedItem          = HslMessageDegree.DEBUG;
            comboBox2.SelectedIndexChanged += ComboBox2_SelectedIndexChanged;

            logNet.FiltrateKeyword("123");
        }
        private void FormLogNet_Load(object sender, EventArgs e)
        {
            logNet = new LogNetSingle("log.txt");
            comboBox1.DataSource            = HslCommunication.BasicFramework.SoftBasic.GetEnumValues <HslMessageDegree>( );
            comboBox1.SelectedItem          = HslMessageDegree.DEBUG;
            comboBox2.DataSource            = HslCommunication.BasicFramework.SoftBasic.GetEnumValues <HslMessageDegree>( );
            comboBox2.SelectedItem          = HslMessageDegree.DEBUG;
            comboBox2.SelectedIndexChanged += ComboBox2_SelectedIndexChanged;

            logNet.FiltrateKeyword("123");    // 过滤关键字123的存储
            logNet.BeforeSaveToFile += LogNet_BeforeSaveToFile;
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
        }
Beispiel #4
0
        public Form1()
        {
            InitializeComponent();
            #region 添加启动日志 Srz
            logNetStart = new LogNetSingle("StartLog.txt");
            logNetStart.RecordMessage(HslMessageDegree.DEBUG, null, "程序启动" + DateTime.Now.ToString());
            #endregion
            //if (result.IsSuccess)
            //{
            //    s7Net.ReadByte("DB0.0");
            //  OperateResult<byte[]>  results = s7Net.Read("DB0.0",10);


            //}
        }
Beispiel #5
0
        static void Main(string[] args)
        {
            // 创建日志
            ILogNet logNet = new LogNetSingle("log.txt");

            logNet.BeforeSaveToFile += LogNet_BeforeSaveToFile;

            SharpNodeServer sharpNodeServer = new SharpNodeServer( );

            sharpNodeServer.LogNet = logNet;
            sharpNodeServer.LoadByXmlFile("settings.xml");
            sharpNodeServer.ServerStart(12345);


            Console.ReadLine( );
        }
Beispiel #6
0
        private void FormLogNet_Load(object sender, EventArgs e)
        {
            logNet = new LogNetSingle("log.txt");
            comboBox1.DataSource            = HslCommunication.BasicFramework.SoftBasic.GetEnumValues <HslMessageDegree>( );
            comboBox1.SelectedItem          = HslMessageDegree.DEBUG;
            comboBox2.DataSource            = HslCommunication.BasicFramework.SoftBasic.GetEnumValues <HslMessageDegree>( );
            comboBox2.SelectedItem          = HslMessageDegree.DEBUG;
            comboBox2.SelectedIndexChanged += ComboBox2_SelectedIndexChanged;

            logNet.FiltrateKeyword("123");    // 过滤关键字123的存储
            logNet.BeforeSaveToFile += LogNet_BeforeSaveToFile;

            if (!Program.ShowAuthorInfomation)
            {
                label2.Visible     = false;
                linkLabel1.Visible = false;
                label20.Visible    = false;
            }
        }
        static void Main(string[] args)
        {
            // 创建Redis
            ConnectionMultiplexer redis = null;

            try
            {
                redis = ConnectionMultiplexer.Connect("127.0.0.1:6379");
            }
            catch
            {
                Console.WriteLine("本次数据创建失败,请稍候重试,具体原因。");
                Console.ReadLine( );
                return;
            }

            // 创建日志
            ILogNet logNet = new LogNetSingle("log.txt");

            logNet.BeforeSaveToFile += LogNet_BeforeSaveToFile;

            SharpNodeServer sharpNodeServer = new SharpNodeServer( );

            sharpNodeServer.LogNet            = logNet;
            sharpNodeServer.WriteCustomerData = (Device.DeviceCore deviceCore, string name) =>
            {
                try
                {
                    IDatabase redisDb = redis.GetDatabase( );
                    redisDb.StringSet(string.Join(":", deviceCore.DeviceNodes) + ":" + name, deviceCore.GetStringValueByName(name));
                }
                catch
                {
                    logNet.WriteError("写入Redis失败");
                }
            };
            // 加载配置文件之前设置redis写入方法
            sharpNodeServer.LoadByXmlFile("settings.xml");
            sharpNodeServer.ServerStart(12345);

            Console.ReadLine( );
        }