Exemplo n.º 1
0
 private void SyncOSDConfig(DeviceModel deviceModel)
 {
     this.MainGridEnabled = false;
     try
     {
         OSDConfig     osd             = NetworkDeviceHelper.GetOSDConfig(deviceModel);
         int           currentCount    = 0;
         int           maxCount        = 100;
         DeviceModel[] selectedDevices = this.Devices.Where(x => x.IsSelected == true).ToArray();
         foreach (var item in selectedDevices)
         {
             do
             {
                 if (currentCount < maxCount)
                 {
                     Interlocked.Increment(ref currentCount);
                     Task task = Task.Run(() =>
                     {
                         CopyOSDConfig(item, osd);
                     })
                                 .ContinueWith(x =>
                     {
                         Interlocked.Decrement(ref currentCount);
                     });
                     break;
                 }
                 System.Threading.Thread.Sleep(100);
             } while (true);
         }
         while (currentCount > 0)
         {
             System.Threading.Thread.Sleep(100);
         }
         this.ShowMessageAsync("同步OSD参数完成", null);
     }
     catch (Exception ex)
     {
         this.ShowMessageAsync("同步OSD参数失败", ex.Message.ToString());
         Helper.Logger.Error(String.Format("SyncOSDConfig {0} error.", deviceModel?.IPAddress), ex);
     }
     finally
     {
         this.MainGridEnabled = true;
     }
 }
Exemplo n.º 2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="model"></param>
 /// <param name="osd"></param>
 public static void CopyOSDConfig(DeviceModel model, OSDConfig osd)
 {
     using (NetworkDeviceConnection conn = NetworkDeviceProviderFactories.GetFactory(model.ProtocolType).CreateConnection())
     {
         NetworkDeviceConnectionStringBuilder builder = NetworkDeviceProviderFactories.GetFactory(model.ProtocolType).CreateConnectionStringBuilder();
         builder.Host          = model.IPAddress;
         builder.Port          = model.Port;
         builder.Username      = model.Username;
         builder.Password      = model.Password;
         conn.ConnectionString = new Uri(builder.ToString());
         conn.Open();
         NetworkDeviceDataReader reader = NetworkDeviceProviderFactories.GetFactory(model.ProtocolType).CreateDataReader();
         reader.Connection = conn;
         reader.CopyOSDConfig(new Howell.Net.NetworkDevice.MediaIdentifier()
         {
             No = 0
         }, osd);
     }
 }
Exemplo n.º 3
0
 private void CopyOSDConfig(DeviceModel deviceModel, OSDConfig osd)
 {
     //Object[] data = state as Object[];
     //DeviceModel deviceModel = data[0] as DeviceModel;
     //OSDConfig osd = data[1] as OSDConfig;
     try
     {
         NetworkDeviceHelper.CopyOSDConfig(deviceModel, osd);
         deviceModel.SettingSucceed = true;
     }
     catch (Exception ex)
     {
         deviceModel.SettingSucceed = false;
         Helper.Logger.Error(String.Format("CopyOSDConfig failed. DeviceIP:{0}", deviceModel.IPAddress), ex);
     }
     //DeviceSettingDelegate parameterizedThreadStart = (x,y) =>
     //{
     //    x.SettingSucceed = y;
     //};
     //Application.Current.Dispatcher.BeginInvoke(parameterizedThreadStart, deviceModel,succeed);
 }