/// <summary>
 /// Downloads selected device, model, version or template from Gurux www-server.
 /// </summary>
 public Guid Download(object target)
 {
     if (target is GXDeviceManufacturer)
     {
         foreach (GXDeviceModel it in (target as GXDeviceManufacturer).Models)
         {
             Download(it);                    
         }
         (target as GXDeviceManufacturer).Status = DownloadStates.None;
     }
     else if (target is GXDeviceModel)
     {
         foreach (GXDeviceVersion it in (target as GXDeviceModel).Versions)
         {
             Download(it);                    
         }
         (target as GXDeviceModel).Status = DownloadStates.None;
     }
     else if (target is GXDeviceVersion)
     {
         foreach (GXPublishedDeviceProfile it in (target as GXDeviceVersion).Templates)
         {
             Download(it);                    
         }
         (target as GXDeviceVersion).Status = DownloadStates.None;
     }
     else if (target is GXPublishedDeviceProfile)
     {
         GXDeviceProfileVersionCollection versions = (target as GXPublishedDeviceProfile).Versions;
         (target as GXPublishedDeviceProfile).DeviceGuid = Download(versions[versions.Count - 1]);
         (target as GXPublishedDeviceProfile).Status = DownloadStates.None;                
     }
     else if (target is GXDeviceProfileVersion)
     {
         JsonServiceClient Client = new JsonServiceClient(Gurux.DeviceSuite.Properties.Settings.Default.UpdateServer);
         GXDownloadRequest download = new GXDownloadRequest();
         download.Template = target as GXDeviceProfileVersion;
         GXDownloadResponse ret = Client.Get(download);
         GXPublishedDeviceProfile type = UpdatePublishedDeviceType(download.Template, ret.Data);
         (target as GXDeviceProfileVersion).Status = DownloadStates.Installed;
         //If restart is needed.
         if (type == null)
         {
             return Guid.Empty;
         }
         return type.Guid;
     }
     else
     {
         throw new Exception("Invalid target.");
     }
     return Guid.Empty;
 }
Exemplo n.º 2
0
 void Download(object sender, GXAsyncWork work, object[] parameters)
 {
     //TODO:
     GXDeviceProfile dp = parameters[0] as GXDeviceProfile;
     GXJsonClient parser = new GXJsonClient(Arguments.DownloadServer, Arguments.UserName, Arguments.Password);
     GXDownloadRequest req = new GXDownloadRequest(dp);
     GXDownloadResponse res = parser.Post(req);
 }