Skip to content

Commit

Permalink
Sync for V1.6.0.3
Browse files Browse the repository at this point in the history
Fix: RZTool , close MSI file after import
New:  optional Manufacturer attribute on CheckForUpdate
  • Loading branch information
rzander committed Sep 29, 2017
1 parent 835f1de commit 3edec57
Show file tree
Hide file tree
Showing 9 changed files with 92 additions and 175 deletions.
4 changes: 3 additions & 1 deletion RZ.OneGetProvider/RZRestAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ public static bool UploadSWEntry(AddSoftware lSoftware)

public static async void TrackDownloads(string contentID)
{
contentID.ToString();
//depreciated
}

Expand Down Expand Up @@ -511,7 +512,8 @@ public string IconURL
{
if (SWId > 0)
{
return RZRestAPI.sURL + "/rest/GetIcon?id=" + SWId.ToString();
string sURL = RZRestAPI.sURL + "/rest/GetIcon?id=" + SWId.ToString();
return sURL;
}
return "";
}
Expand Down
71 changes: 11 additions & 60 deletions RZ.OneGetProvider/RZScan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -276,60 +276,6 @@ private void RZScan_OnSWScanCompleted(object sender, EventArgs e)
}
}

/// <summary>
/// Check for updated Version in the RuckZuck Repository
/// </summary>
/// <param name="aSWCheck">null = all Installed SW</param>
internal void CheckUpdatesOld(List<AddSoftware> aSWCheck)
{
var tCheckUpd = Task.Run(() =>
{
try
{
if (aSWCheck == null || aSWCheck.Count() == 0)
aSWCheck = InstalledSoftware.Select(t => new AddSoftware() { ProductName = t.ProductName, ProductVersion = t.ProductVersion, Manufacturer = t.Manufacturer }).ToList();

var vSWCheck = aSWCheck.Select(t => new AddSoftware() { ProductName = t.ProductName, ProductVersion = t.ProductVersion, Manufacturer = t.Manufacturer }).ToList();
List<AddSoftware> lCheckResult = RZRestAPI.CheckForUpdate(vSWCheck).ToList();

var lResult = lCheckResult.Select(item => new AddSoftware()
{
Architecture = item.Architecture,
Category = item.Category,
Description = item.Description,
Image = item.Image,
Manufacturer = item.Manufacturer,
ProductName = item.ProductName,
ProductURL = item.ProductURL,
ProductVersion = item.ProductVersion,
MSIProductID = item.MSIProductID,
Shortname = item.Shortname
}).ToList();

//Only take updated Versions
var lNew = lResult.Where(t => t.Shortname != "new").ToList();


lock (NewSoftwareVersions)
{
//Store new Versions of existing SW
NewSoftwareVersions.AddRange(lNew);

//Remove duplicates
NewSoftwareVersions = NewSoftwareVersions.GroupBy(x => x.Shortname).Select(y => y.First()).ToList();
}
if (lNew.Count > 0)
OnUpdatesDetected(lNew, new EventArgs());
}
catch (Exception ex)
{
ex.ToString();
}

OnUpdScanCompleted(this, new EventArgs());
});
}

/// <summary>
/// Check for updated Version in the RuckZuck Repository
/// </summary>
Expand All @@ -347,20 +293,25 @@ internal void _CheckUpdates(List<AddSoftware> aSWCheck)
aSWCheck = InstalledSoftware.Select(t => new AddSoftware() { ProductName = t.ProductName, ProductVersion = t.ProductVersion, Manufacturer = t.Manufacturer }).ToList();

var vSWCheck = aSWCheck.Select(t => new AddSoftware() { ProductName = t.ProductName, ProductVersion = t.ProductVersion, Manufacturer = t.Manufacturer }).ToList();
List<AddSoftware> lCheckResult = RZRestAPI.CheckForUpdate(vSWCheck).ToList();

//we do not have to check for updates if it's in the Catalog
List<AddSoftware> tRes = vSWCheck.Where(t => SoftwareRepository.FirstOrDefault(r => r.ProductName == t.ProductName & r.ProductVersion == t.ProductVersion & r.Manufacturer == t.Manufacturer) == null).ToList();

List<AddSoftware> lCheckResult = RZRestAPI.CheckForUpdate(tRes).ToList();

var lResult = lCheckResult.Select(item => new AddSoftware()
{
Architecture = item.Architecture,
Category = item.Category,
Description = item.Description,
Image = item.Image,
//Image = item.Image,
Manufacturer = item.Manufacturer,
ProductName = item.ProductName,
ProductURL = item.ProductURL,
ProductVersion = item.ProductVersion,
MSIProductID = item.MSIProductID,
Shortname = item.Shortname
Shortname = item.Shortname,
SWId = item.SWId
}).ToList();

//Only take updated Versions
Expand Down Expand Up @@ -483,7 +434,7 @@ internal AddSoftware GetSWProperties(RegistryKey oRegkey)
if (bIsMSI)
{
oResult.MSIProductID = sMSI;
oResult.PSUninstall = "$proc = (Start-Process -FilePath \"msiexec.exe\" -ArgumentList \"/x " + sMSI + " /qb! \" -PassThru);$proc.WaitForExit();$ExitCode = $proc.ExitCode";
oResult.PSUninstall = "$proc = (Start-Process -FilePath \"msiexec.exe\" -ArgumentList \"/x " + sMSI + " /qb! REBOOT=REALLYSUPPRESS \" -Wait -PassThru);$proc.WaitForExit();$ExitCode = $proc.ExitCode";


oResult.PSDetection = @"Test-Path 'HKLM:\SOFTWARE\Classes\Installer\Products\" + EncKey + "'";
Expand All @@ -493,7 +444,7 @@ internal AddSoftware GetSWProperties(RegistryKey oRegkey)
RegistryKey oSource = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Classes\Installer\Products\" + EncKey + "\\SourceList");
if (oSource != null)
{
oResult.PSInstall = "$proc = (Start-Process -FilePath \"msiexec.exe\" -ArgumentList \"/i `\"" + oSource.GetValue("PackageName") + "`\" /qb! ALLUSERS=2 REBOOT=REALLYSUPPRESS\" -Wait -PassThru);$proc.WaitForExit();$ExitCode = $proc.ExitCode";
oResult.PSInstall = "$proc = (Start-Process -FilePath \"msiexec.exe\" -ArgumentList \"/i `\"" + oSource.GetValue("PackageName") + "`\" /qn ALLUSERS=2 REBOOT=REALLYSUPPRESS\" -Wait -PassThru);$proc.WaitForExit();$ExitCode = $proc.ExitCode";
}
}
catch
Expand All @@ -504,7 +455,7 @@ internal AddSoftware GetSWProperties(RegistryKey oRegkey)
}
catch { }

oResult.PSInstall = "$proc = (Start-Process -FilePath \"msiexec.exe\" -ArgumentList \"/i `\"<PackageName.msi>`\" /qb! ALLUSERS=2 REBOOT=REALLYSUPPRESS\" -Wait -PassThru);$proc.WaitForExit();$ExitCode = $proc.ExitCode";
oResult.PSInstall = "$proc = (Start-Process -FilePath \"msiexec.exe\" -ArgumentList \"/i `\"<PackageName.msi>`\" /qn ALLUSERS=2 REBOOT=REALLYSUPPRESS\" -Wait -PassThru);$proc.WaitForExit();$ExitCode = $proc.ExitCode";
}
}
else
Expand Down
3 changes: 2 additions & 1 deletion RZ.OneGetProvider/RZUpdate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,15 @@ public RZUpdater(string sSWFile)
/// <param name="ProductName">Name of the Software Product (must be in the RuckZuck Repository !)</param>
/// <param name="Version">>Current Version of the Software</param>
/// <returns>SWUpdate if an Update is available otherwise null</returns>
public SWUpdate CheckForUpdate(string ProductName, string Version)
public SWUpdate CheckForUpdate(string ProductName, string Version, string Manufacturer = "")
{
try
{
AddSoftware oSW = new AddSoftware();

oSW.ProductName = ProductName; // ;
oSW.ProductVersion = Version; // ;
oSW.Manufacturer = Manufacturer ?? "";

List<AddSoftware> oResult = RZRestAPI.CheckForUpdate(new List<AddSoftware>() { oSW }).ToList();
if (oResult.Count > 0)
Expand Down
4 changes: 3 additions & 1 deletion RZUpdate/RZRestAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ public static bool UploadSWEntry(AddSoftware lSoftware)

public static async void TrackDownloads(string contentID)
{
contentID.ToString();
//depreciated
}

Expand Down Expand Up @@ -511,7 +512,8 @@ public string IconURL
{
if (SWId > 0)
{
return RZRestAPI.sURL + "/rest/GetIcon?id=" + SWId.ToString();
string sURL = RZRestAPI.sURL + "/rest/GetIcon?id=" + SWId.ToString();
return sURL;
}
return "";
}
Expand Down
65 changes: 8 additions & 57 deletions RZUpdate/RZScan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -276,60 +276,6 @@ private void RZScan_OnSWScanCompleted(object sender, EventArgs e)
}
}

/// <summary>
/// Check for updated Version in the RuckZuck Repository
/// </summary>
/// <param name="aSWCheck">null = all Installed SW</param>
internal void CheckUpdatesOld(List<AddSoftware> aSWCheck)
{
var tCheckUpd = Task.Run(() =>
{
try
{
if (aSWCheck == null || aSWCheck.Count() == 0)
aSWCheck = InstalledSoftware.Select(t => new AddSoftware() { ProductName = t.ProductName, ProductVersion = t.ProductVersion, Manufacturer = t.Manufacturer }).ToList();

var vSWCheck = aSWCheck.Select(t => new AddSoftware() { ProductName = t.ProductName, ProductVersion = t.ProductVersion, Manufacturer = t.Manufacturer }).ToList();
List<AddSoftware> lCheckResult = RZRestAPI.CheckForUpdate(vSWCheck).ToList();

var lResult = lCheckResult.Select(item => new AddSoftware()
{
Architecture = item.Architecture,
Category = item.Category,
Description = item.Description,
Image = item.Image,
Manufacturer = item.Manufacturer,
ProductName = item.ProductName,
ProductURL = item.ProductURL,
ProductVersion = item.ProductVersion,
MSIProductID = item.MSIProductID,
Shortname = item.Shortname
}).ToList();

//Only take updated Versions
var lNew = lResult.Where(t => t.Shortname != "new").ToList();


lock (NewSoftwareVersions)
{
//Store new Versions of existing SW
NewSoftwareVersions.AddRange(lNew);

//Remove duplicates
NewSoftwareVersions = NewSoftwareVersions.GroupBy(x => x.Shortname).Select(y => y.First()).ToList();
}
if (lNew.Count > 0)
OnUpdatesDetected(lNew, new EventArgs());
}
catch (Exception ex)
{
ex.ToString();
}

OnUpdScanCompleted(this, new EventArgs());
});
}

/// <summary>
/// Check for updated Version in the RuckZuck Repository
/// </summary>
Expand All @@ -347,20 +293,25 @@ internal void _CheckUpdates(List<AddSoftware> aSWCheck)
aSWCheck = InstalledSoftware.Select(t => new AddSoftware() { ProductName = t.ProductName, ProductVersion = t.ProductVersion, Manufacturer = t.Manufacturer }).ToList();

var vSWCheck = aSWCheck.Select(t => new AddSoftware() { ProductName = t.ProductName, ProductVersion = t.ProductVersion, Manufacturer = t.Manufacturer }).ToList();
List<AddSoftware> lCheckResult = RZRestAPI.CheckForUpdate(vSWCheck).ToList();

//we do not have to check for updates if it's in the Catalog
List<AddSoftware> tRes = vSWCheck.Where(t => SoftwareRepository.FirstOrDefault(r => r.ProductName == t.ProductName & r.ProductVersion == t.ProductVersion & r.Manufacturer == t.Manufacturer) == null).ToList();

List<AddSoftware> lCheckResult = RZRestAPI.CheckForUpdate(tRes).ToList();

var lResult = lCheckResult.Select(item => new AddSoftware()
{
Architecture = item.Architecture,
Category = item.Category,
Description = item.Description,
Image = item.Image,
//Image = item.Image,
Manufacturer = item.Manufacturer,
ProductName = item.ProductName,
ProductURL = item.ProductURL,
ProductVersion = item.ProductVersion,
MSIProductID = item.MSIProductID,
Shortname = item.Shortname
Shortname = item.Shortname,
SWId = item.SWId
}).ToList();

//Only take updated Versions
Expand Down
3 changes: 2 additions & 1 deletion RZUpdate/RZUpdate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,15 @@ public RZUpdater(string sSWFile)
/// <param name="ProductName">Name of the Software Product (must be in the RuckZuck Repository !)</param>
/// <param name="Version">>Current Version of the Software</param>
/// <returns>SWUpdate if an Update is available otherwise null</returns>
public SWUpdate CheckForUpdate(string ProductName, string Version)
public SWUpdate CheckForUpdate(string ProductName, string Version, string Manufacturer = "")
{
try
{
AddSoftware oSW = new AddSoftware();

oSW.ProductName = ProductName; // ;
oSW.ProductVersion = Version; // ;
oSW.Manufacturer = Manufacturer ?? "";

List<AddSoftware> oResult = RZRestAPI.CheckForUpdate(new List<AddSoftware>() { oSW }).ToList();
if (oResult.Count > 0)
Expand Down
Loading

0 comments on commit 3edec57

Please sign in to comment.