Skip to content

Commit

Permalink
Fix: Always load local json before check REST API
Browse files Browse the repository at this point in the history
  • Loading branch information
rzander committed Aug 7, 2018
1 parent d3ff910 commit 7032bf8
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 47 deletions.
2 changes: 1 addition & 1 deletion RZUpdate/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.6.2.*")]
[assembly: AssemblyFileVersion("1.6.2.7")]
[assembly: AssemblyFileVersion("1.6.2.8")]
101 changes: 57 additions & 44 deletions RZUpdate/RZUpdate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -406,48 +406,57 @@ public SWUpdate(string Shortname)

try
{
var oGetSW = RZRestAPI.SWGet(Shortname).FirstOrDefault(); ;


SW = new AddSoftware();

if (oGetSW == null)
//Always use local JSON-File if exists
if (File.Exists(Path.Combine(Environment.ExpandEnvironmentVariables("%TEMP%"), Shortname + ".json")))
{
if (File.Exists(Path.Combine(Environment.ExpandEnvironmentVariables("%TEMP%"), Shortname + ".json")))
{
string sSWFile = Path.Combine(Environment.ExpandEnvironmentVariables("%TEMP%"), Shortname + ".json");
SW = new SWUpdate(RZUpdater.ParseJSON(sSWFile)).SW;
}
string sSWFile = Path.Combine(Environment.ExpandEnvironmentVariables("%TEMP%"), Shortname + ".json");
SW = new SWUpdate(RZUpdater.ParseJSON(sSWFile)).SW;
}
else
{
SW.ProductName = oGetSW.ProductName;
SW.ProductVersion = oGetSW.ProductVersion;
SW.Manufacturer = oGetSW.Manufacturer;
}
var oGetSW = RZRestAPI.SWGet(Shortname).FirstOrDefault();
if (oGetSW != null)
{
SW.ProductName = oGetSW.ProductName;
SW.ProductVersion = oGetSW.ProductVersion;
SW.Manufacturer = oGetSW.Manufacturer;

//Get Install-type
GetInstallType();
if (SW.Architecture == null)
{
SW = RZRestAPI.GetSWDefinitions(oGetSW.ProductName, oGetSW.ProductVersion, oGetSW.Manufacturer).FirstOrDefault();

if (SW == null)
{
SW = RZRestAPI.GetSWDefinitions(oGetSW.ProductName, oGetSW.ProductVersion, oGetSW.Manufacturer).FirstOrDefault();
try
{
if (SW.Image == null)
{
SW.Image = RZRestAPI.GetIcon(SW.SWId);
}
}
catch { }

try
{
if (SW.Image == null)
{
SW.Image = RZRestAPI.GetIcon(SW.SWId);
if (SW.Files == null)
SW.Files = new List<contentFiles>();

if (string.IsNullOrEmpty(SW.PSPreReq))
SW.PSPreReq = "$true; ";
}
}
catch { }

if (SW.Files == null)
SW.Files = new List<contentFiles>();
if (string.IsNullOrEmpty(SW.Shortname))
return;
//Get Install-type
GetInstallType();


if (string.IsNullOrEmpty(SW.PSPreReq))
SW.PSPreReq = "$true; ";
}





downloadTask = new DLTask() { ProductName = SW.ProductName, ProductVersion = SW.ProductVersion, Manufacturer = SW.Manufacturer, Shortname = SW.Shortname, Image = SW.Image, Files = SW.Files };

foreach (contentFiles vFile in SW.Files)
Expand All @@ -461,38 +470,42 @@ public SWUpdate(string Shortname)

public bool GetInstallType(bool bGetFirst = false)
{
foreach (var DT in RZRestAPI.GetSWDefinitions(SW.ProductName, SW.ProductVersion, SW.Manufacturer))
//Only get other DeploymentTypes if Architecture is not defined...
if (string.IsNullOrEmpty(this.SW.Architecture))
{
try
foreach (var DT in RZRestAPI.GetSWDefinitions(SW.ProductName, SW.ProductVersion, SW.Manufacturer))
{
//Check PreReqs
try
{
if (!string.IsNullOrEmpty(DT.PSPreReq))
//Check PreReqs
try
{
if (!bGetFirst)
if (!string.IsNullOrEmpty(DT.PSPreReq))
{
if (!(bool)_RunPS(DT.PSPreReq)[0].BaseObject)
continue;
if (!bGetFirst)
{
if (!(bool)_RunPS(DT.PSPreReq)[0].BaseObject)
continue;
}
}
}
}
catch { continue; }
catch { continue; }

SW = DT;
SW = DT;

try
{
if (SW.Image == null)
try
{
SW.Image = RZRestAPI.GetIcon(SW.SWId);
if (SW.Image == null)
{
SW.Image = RZRestAPI.GetIcon(SW.SWId);
}
}
catch { }

return true;
}
catch { }

return true;
}
catch { }
}

return false;
Expand Down
4 changes: 2 additions & 2 deletions RZUpdate/RZUpdate.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>x64</PlatformTarget>
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<Prefer32Bit>true</Prefer32Bit>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
</PropertyGroup>
Expand Down

0 comments on commit 7032bf8

Please sign in to comment.