From 0581ebfc40ef4935c424ddda7d8821e8347717e6 Mon Sep 17 00:00:00 2001 From: Roger Zander Date: Thu, 15 Dec 2022 20:15:01 +0100 Subject: [PATCH] Fix: unable to create .exe --- RZ.Base/RZRestAPIv2.cs | 15 ++++++- RZ.Base/RZUpdate.cs | 41 ++++++++++--------- RuckZuck_Tool/DownloadMonitor.xaml.cs | 6 +-- RuckZuck_Tool/InstallSwPanel.xaml.cs | 2 +- .../Properties/Resources.Designer.cs | 4 +- 5 files changed, 42 insertions(+), 26 deletions(-) diff --git a/RZ.Base/RZRestAPIv2.cs b/RZ.Base/RZRestAPIv2.cs index 1a2f3f2..549e165 100644 --- a/RZ.Base/RZRestAPIv2.cs +++ b/RZ.Base/RZRestAPIv2.cs @@ -12,7 +12,7 @@ using System.Threading; using System.Threading.Tasks; using System.Web; -using System.Web.Script.Serialization; +//using System.Web.Script.Serialization; namespace RuckZuck.Base { @@ -750,4 +750,17 @@ public static bool UploadSWEntry(AddSoftware lSoftware, string customerid = "") return false; } } + + internal class JavaScriptSerializer + { + internal T Deserialize(string jsonObject) + { + throw new NotImplementedException(); + } + + internal string Serialize(T jsonObject) + { + throw new NotImplementedException(); + } + } } \ No newline at end of file diff --git a/RZ.Base/RZUpdate.cs b/RZ.Base/RZUpdate.cs index 61165f3..e01cf7c 100644 --- a/RZ.Base/RZUpdate.cs +++ b/RZ.Base/RZUpdate.cs @@ -482,27 +482,30 @@ public SWUpdate(string ProductName, string ProductVersion, string Manufacturer, if (SW == null) { - //Load all MetaData for the specific SW - foreach (AddSoftware SWCheck in RZRestAPIv2.GetSoftwaresAsync(SW.ProductName, SW.ProductVersion, SW.Manufacturer, RZRestAPIv2.CustomerID).Result) + Task.Run(async () => { - if (string.IsNullOrEmpty(SWCheck.PSPreReq)) - SWCheck.PSPreReq = "$true; "; - - //Check PreReq for all Installation-types of the Software - if ((bool)(SWUpdate._RunPSAsync(SWCheck.PSPreReq).GetAwaiter().GetResult())[0].BaseObject) + //Load all MetaData for the specific SW + foreach (AddSoftware SWCheck in await RZRestAPIv2.GetSoftwaresAsync(SW.ProductName, SW.ProductVersion, SW.Manufacturer, RZRestAPIv2.CustomerID)) { - SW = SWCheck; - break; + if (string.IsNullOrEmpty(SWCheck.PSPreReq)) + SWCheck.PSPreReq = "$true; "; + + //Check PreReq for all Installation-types of the Software + if ((bool)(SWUpdate._RunPSAsync(SWCheck.PSPreReq).GetAwaiter().GetResult())[0].BaseObject) + { + SW = SWCheck; + break; + } } - } - //SW = RZRestAPIv2.GetSoftwares(ProductName, ProductVersion, Manufacturer, RZRestAPIv2.CustomerID).FirstOrDefault(); + //SW = RZRestAPIv2.GetSoftwares(ProductName, ProductVersion, Manufacturer, RZRestAPIv2.CustomerID).FirstOrDefault(); - if (SW.Files == null) - SW.Files = new List(); + if (SW.Files == null) + SW.Files = new List(); - if (string.IsNullOrEmpty(SW.PSPreReq)) - SW.PSPreReq = "$true; "; + if (string.IsNullOrEmpty(SW.PSPreReq)) + SW.PSPreReq = "$true; "; + }).Wait(); } if (SW.Files != null) @@ -721,10 +724,10 @@ public async Task _DownloadFile2Async(string URL, string FileName, long Fi { //_DownloadFile(URL, FileName).Result.ToString(); var httpRequest = (HttpWebRequest)WebRequest.Create(URL); - httpRequest.UserAgent = "chocolatey command line"; + //httpRequest.UserAgent = "ruckzuck package manager"; httpRequest.AllowAutoRedirect = true; httpRequest.MaximumAutomaticRedirections = 5; - Response = httpRequest.GetResponse(); + Response = await httpRequest.GetResponseAsync(); // Get back the HTTP response for web server //Response = (HttpWebResponse)httpRequest.GetResponse(); @@ -792,7 +795,7 @@ public async Task _DownloadFile2Async(string URL, string FileName, long Fi } } } - catch(Exception ex) + catch (Exception ex) { ex.Message.ToString(); } @@ -1651,7 +1654,7 @@ private async Task _InstallAsync(bool Force = false) catch (Exception ex) { Trace.WriteLine("ERROR: " + ex.Message); - RZRestAPIv2.FeedbackAsync(SW.ProductName, SW.ProductVersion, SW.Manufacturer, "false", System.Reflection.Assembly.GetExecutingAssembly().GetName().Name, "ERROR: " + ex.Message, RZRestAPIv2.CustomerID); + RZRestAPIv2.FeedbackAsync(SW.ProductName, SW.ProductVersion, SW.Manufacturer, "false", System.Reflection.Assembly.GetExecutingAssembly().GetName().Name, "ERROR: " + ex.Message, RZRestAPIv2.CustomerID).Result.ToString(); downloadTask.Error = true; downloadTask.ErrorMessage = "WARNING: Product not detected after installation."; downloadTask.Installed = false; diff --git a/RuckZuck_Tool/DownloadMonitor.xaml.cs b/RuckZuck_Tool/DownloadMonitor.xaml.cs index f02e4fc..45afbce 100644 --- a/RuckZuck_Tool/DownloadMonitor.xaml.cs +++ b/RuckZuck_Tool/DownloadMonitor.xaml.cs @@ -101,7 +101,7 @@ private void TaskUpdate() Mutex mRes = null; if (!Mutex.TryOpenExisting(@"RuckZuck", out mRes)) { - oDL.SWUpd.InstallAsync(false, false).ConfigureAwait(false); + _ = oDL.SWUpd.InstallAsync(false, false); } return; @@ -131,7 +131,7 @@ private void TaskUpdate() Mutex mRes = null; if (!Mutex.TryOpenExisting(@"RuckZuck", out mRes)) { - oDL.SWUpd.InstallAsync(false, false).ConfigureAwait(false); + _ = oDL.SWUpd.InstallAsync(false, false); } return; @@ -145,7 +145,7 @@ private void TaskUpdate() Mutex mRes = null; if (!Mutex.TryOpenExisting(@"RuckZuck", out mRes)) { - oDL.SWUpd.InstallAsync(false, false).ConfigureAwait(false); + _ = oDL.SWUpd.InstallAsync(false, false); } return; diff --git a/RuckZuck_Tool/InstallSwPanel.xaml.cs b/RuckZuck_Tool/InstallSwPanel.xaml.cs index df82b20..d63ee01 100644 --- a/RuckZuck_Tool/InstallSwPanel.xaml.cs +++ b/RuckZuck_Tool/InstallSwPanel.xaml.cs @@ -315,7 +315,7 @@ private void miDownloadFiles_Click(object sender, RoutedEventArgs e) //oSW.Downloaded += OSW_Downloaded; oSW.ProgressDetails += OSW_ProgressDetails; oSW.downloadTask.AutoInstall = false; - _ = oSW.DownloadAsync(false).ConfigureAwait(false); + _ = oSW.DownloadAsync(false); dm.lDLTasks.Add(oSW.downloadTask); } diff --git a/RuckZuck_Tool/Properties/Resources.Designer.cs b/RuckZuck_Tool/Properties/Resources.Designer.cs index d936834..b4d5528 100644 --- a/RuckZuck_Tool/Properties/Resources.Designer.cs +++ b/RuckZuck_Tool/Properties/Resources.Designer.cs @@ -96,14 +96,14 @@ internal static string Assembly { ///using System.Threading; ///using System.Threading.Tasks; ///using System.Web; - ///using System.Web.Script.Serialization; + /////using System.Web.Script.Serialization; /// ///namespace RuckZuck.Base ///{ /// public class AddSoftware /// { /// public string Architecture { get; set; } - /// public string Aut [rest of string was truncated]";. + /// public string A [rest of string was truncated]";. /// internal static string RZRestApi { get {