Esempio n. 1
0
 public void SaveConfig(Setting setting)
 {
     if (setting == null || string.IsNullOrEmpty(cfgFile))
     {
         return;
     }
     SerOrDerModel <Setting> .Serialize(setting, cfgFile);
 }
Esempio n. 2
0
        public void LoadConfig(ref Setting setting)
        {
            //读取异常,将加载系统默认设置
            if (!System.IO.File.Exists(cfgFile) || setting == null)
            {
                setting              = new Setting();
                setting.ParkLot      = new ParkingLot();
                setting.ParkLot.Id   = "0";
                setting.ParkLot.No   = "0";
                setting.ParkLot.Name = "未命名";
                setting.ParkLot.Addr = "";

                Guard guard1 = new Guard();
                guard1.IsExit  = false;
                guard1.No      = "默认";
                guard1.Primary = new GuardItem()
                {
                    IP = "192.168.1.101", ScreenType = 1, ScreenIP = "192.168.1.101"
                };


                Guard guard2 = new Guard();
                guard2.IsExit  = true;
                guard2.No      = "默认";
                guard2.Primary = new GuardItem()
                {
                    IP = "192.168.1.102", ScreenType = 1, ScreenIP = "192.168.1.102"
                };
                setting.Guards = new List <Guard>()
                {
                    guard1, guard2
                };
                setting.EnabledShowLeftCount    = false;
                setting.EnabledHotel            = false;
                setting.EnabledWhiteListNoOrder = false;
                setting.EnabledWhiteList        = false;
                setting.EnabledWLGO             = false;
                setting.ImagePath              = @"D:\";
                setting.InVolume               = 10;
                setting.OutVolume              = 10;
                setting.InDelay                = 3000;
                setting.OutDelay               = 3000;
                setting.InLine                 = 4;
                setting.OutLine                = 4;
                setting.ScreenInDelay          = 80;
                setting.ScreenOutDelay         = 80;
                setting.EnableOneSpaceMoreCars = false;

                setting.Serv = new Server()
                {
                    HeartBeatFreq          = 3,
                    Url                    = "http://47.100.229.60:8080",
                    HeartBeatMaxRetryCount = 5,
                    PayCheckFreq           = 5000,
                    PayCheckMaxRetryCount  = 25,
                    GateKeepOpenFreq       = 3000,
                    DataSyncFreq           = 600000
                };


                SaveConfig(setting);
            }
            else
            {
                setting = SerOrDerModel <Setting> .Deserialize(cfgFile);
            }
        }