예제 #1
0
 /// <summary>
 /// 导入数据
 /// </summary>
 /// <param name="json"></param>
 public static bool Load(string json)
 {
     try
     {
         DataModel data = JsonConvert.DeserializeObject <DataModel>(json);
         if (data.devName != null)
         {
             foreach (var mac in data.devName.Keys)
             {
                 DeviceName.SetDeviceName(mac, data.devName[mac]);
             }
         }
         if (data.devType != null)
         {
             foreach (var mac in data.devType.Keys)
             {
                 DeviceType.SetDeviceType(mac, (Model.DeviceType)data.devType[mac]);
             }
         }
         if (data.whiteList != null)
         {
             SetSetting("DeviceWhiteList", JsonConvert.SerializeObject(data.whiteList));
         }
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
예제 #2
0
 /// <summary>
 /// 导入数据
 /// </summary>
 /// <param name="json"></param>
 public static void Load(string json)
 {
     try
     {
         DataModel data = JsonConvert.DeserializeObject <DataModel>(json);
         if (data.devName != null)
         {
             foreach (var mac in data.devName.Keys)
             {
                 DeviceName.SetDeviceName(mac, data.devName[mac]);
             }
         }
         if (data.devType != null)
         {
             foreach (var mac in data.devType.Keys)
             {
                 DeviceType.SetDeviceType(mac, (Model.DeviceType)data.devType[mac]);
             }
         }
     }
     catch (Exception)
     {
     }
 }