public void RUNPS() { Console.WriteLine("Check RunPS..."); var oRes = SWUpdate._RunPS("sleep 5", "", new TimeSpan(0, 0, 40)); oRes.ToString(); Assert.IsNotNull(oRes); }
private void miCreateExe_Click(object sender, RoutedEventArgs e) { Mouse.OverrideCursor = Cursors.Wait; try { foreach (var oItem in lvSW.SelectedItems) { try { SWUpdate oSW = null; if (oItem.GetType() == typeof(GetSoftware)) { GetSoftware dgr = oItem as GetSoftware; //sPS = GetSWInstallPS(dgr.ProductName, dgr.ProductVersion, ""); oSW = new SWUpdate(dgr.ProductName, dgr.ProductVersion, dgr.Manufacturer); } if (oItem.GetType() == typeof(AddSoftware)) { AddSoftware dgr = oItem as AddSoftware; //sPS = GetSWInstallPS(dgr.ProductName, dgr.ProductVersion, ""); oSW = new SWUpdate(dgr); } CreateExe oExe = new CreateExe(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, oSW.SW.ShortName + "_setup.exe")); //Get Icon if missing if (oSW.SW.Image == null) { oSW.SW.Image = RZRestAPIv2.GetIcon(oSW.SW.IconHash); } oExe.Icon = oSW.SW.Image; oExe.Sources.Add(Properties.Resources.Source.Replace("RZRZRZ", oSW.SW.ShortName)); oExe.Sources.Add(Properties.Resources.RZUpdate); oExe.Sources.Add(Properties.Resources.RZRestApi); oExe.Sources.Add(Properties.Resources.Assembly.Replace("RZRZRZ", oSW.SW.ShortName)); if (!oExe.Compile()) { MessageBox.Show("Failed to create .Exe", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } else { MessageBox.Show(oSW.SW.ShortName + "_setup.exe" + " created in: " + AppDomain.CurrentDomain.BaseDirectory, "EXE created", MessageBoxButton.OK, MessageBoxImage.Information); } } catch { } } } finally { Mouse.OverrideCursor = null; } }
void oInstPanel_onEdit(object sender, EventArgs e) { AnonymousDelegate update = delegate() { try { bool bNoPreReqCheck = false; if (sender.GetType() == typeof(GetSoftware)) { GetSoftware oSelectedItem = (GetSoftware)sender; //Ignore PreRequisites if SHIFT is pressed if (Keyboard.Modifiers == ModifierKeys.Shift) { bNoPreReqCheck = true; } //Load Software details for a valid DeploymentType... SWUpdate oSW = new SWUpdate(oSelectedItem.ProductName, oSelectedItem.ProductVersion, oSelectedItem.Manufacturer, bNoPreReqCheck); //get Icon if (oSW.SW != null) { oSW.SW.Image = RZRestAPIv2.GetIcon(oSW.SW.IconHash); oNewPanel.OpenXML(oSW.SW); } tabNewSWSMI.Tag = tabWizard.SelectedItem; tabWizard.SelectedItem = tabNewSWSMI; } if (sender.GetType() == typeof(AddSoftware)) { AddSoftware oSelectedItem = (AddSoftware)sender; //Ignore PreRequisites if SHIFT is pressed if (Keyboard.Modifiers == ModifierKeys.Shift) { bNoPreReqCheck = true; } //Load Software details for a valid DeploymentType... SWUpdate oSW = new SWUpdate(oSelectedItem.ProductName, oSelectedItem.ProductVersion, oSelectedItem.Manufacturer, bNoPreReqCheck); oNewPanel.OpenXML(oSW.SW); tabNewSWSMI.Tag = tabWizard.SelectedItem; tabWizard.SelectedItem = tabNewSWSMI; } } catch { } }; Dispatcher.Invoke(update); }
private void miCreateExe_Click(object sender, RoutedEventArgs e) { Mouse.OverrideCursor = Cursors.Wait; try { foreach (var oItem in lvSW.SelectedItems) { try { SWUpdate oSW = null; if (oItem.GetType() == typeof(GetSoftware)) { GetSoftware dgr = oItem as GetSoftware; //sPS = GetSWInstallPS(dgr.ProductName, dgr.ProductVersion, ""); oSW = new SWUpdate(dgr.ProductName, dgr.ProductVersion, dgr.Manufacturer); } if (oItem.GetType() == typeof(AddSoftware)) { AddSoftware dgr = oItem as AddSoftware; //sPS = GetSWInstallPS(dgr.ProductName, dgr.ProductVersion, ""); oSW = new SWUpdate(dgr); } CreateExe oExe = new CreateExe(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, oSW.SW.ShortName + "_setup.exe")); oExe.Icon = oSW.SW.Image; oExe.Sources.Add(Properties.Resources.Source.Replace("RZRZRZ", oSW.SW.ShortName)); oExe.Sources.Add(Properties.Resources.RZUpdate); oExe.Sources.Add(Properties.Resources.RZRestApi); oExe.Sources.Add(Properties.Resources.Assembly.Replace("RZRZRZ", oSW.SW.ShortName)); if (!oExe.Compile()) { MessageBox.Show("Failed to create .Exe", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } //Non authenticated Users can create one EXE if (!EnableEdit) { miCreateExe.IsEnabled = false; return; } } catch { } } } finally { Mouse.OverrideCursor = null; } }
private void miDownloadFiles_Click(object sender, RoutedEventArgs e) { if (lvSW.SelectedItem != null) { try { foreach (var oItem in lvSW.SelectedItems) { try { SWUpdate oSW = null; if (oItem.GetType() == typeof(GetSoftware)) { GetSoftware dgr = oItem as GetSoftware; //sPS = GetSWInstallPS(dgr.ProductName, dgr.ProductVersion, ""); oSW = new SWUpdate(dgr.ProductName, dgr.ProductVersion, dgr.Manufacturer); } if (oItem.GetType() == typeof(AddSoftware)) { AddSoftware dgr = oItem as AddSoftware; //sPS = GetSWInstallPS(dgr.ProductName, dgr.ProductVersion, ""); oSW = new SWUpdate(dgr); } oSW.sUserName = Properties.Settings.Default.UserKey; //lDLTasks.Add(oSW.downloadTask); if (dm.lDLTasks.FirstOrDefault(t => t.ProductName == oSW.SW.ProductName) == null) { //oSW.Downloaded += OSW_Downloaded; oSW.ProgressDetails += OSW_ProgressDetails; oSW.downloadTask.AutoInstall = false; oSW.Download(false).ConfigureAwait(false); dm.lDLTasks.Add(oSW.downloadTask); } dm.Show(); continue; } catch (Exception ex) { Debug.WriteLine(ex.Message); } } } catch { } OnSWUpdated(this, new EventArgs()); } }
private void miOpenFolders_Click(object sender, RoutedEventArgs e) { tSearch.Stop(); if (lvSW.SelectedItems.Count > 0) { int iSelecteItems = lvSW.SelectedItems.Count; foreach (GetSoftware oSelectedItem in lvSW.SelectedItems) { try { //AddSoftware oItem = Converter.Convert(Converter.Convert(oSelectedItem, oAPI)); SWUpdate oUpd = new SWUpdate(oSelectedItem.ProductName, oSelectedItem.ProductVersion, oSelectedItem.Manufacturer); Process.Start("explorer.exe", oUpd.GetDLPath()); } catch { } } } }
private void InstallSW(List <AddSoftware> lSW) { foreach (AddSoftware oItem in lSW) { try { SWUpdate oSW = new SWUpdate(oItem); oSW.GetInstallType(); oSW.SW.Author = oItem.Author; //Author is used to store the Bootstrap flag if (dm.lDLTasks.FirstOrDefault(t => t.ProductName == oSW.SW.ProductName) == null) { oSW.ProgressDetails += OSW_ProgressDetails; oSW.downloadTask.AutoInstall = true; oSW.Download(false).ConfigureAwait(false); dm.lDLTasks.Add(oSW.downloadTask); if (oSW.SW.PreRequisites != null) { foreach (string sPreReq in oSW.SW.PreRequisites) { try { SWUpdate oPreReq = new SWUpdate(sPreReq); oPreReq.GetInstallType(); if (dm.lDLTasks.FirstOrDefault(t => t.ProductName == oPreReq.SW.ProductName) == null) { oPreReq.ProgressDetails += OSW_ProgressDetails; oPreReq.downloadTask.AutoInstall = true; oPreReq.Download(false).ConfigureAwait(false); dm.lDLTasks.Add(oPreReq.downloadTask); } } catch { } } } } dm.Show(); } catch { } OnSWUpdated(this, new EventArgs()); } }
private void miUninstall_Click(object sender, RoutedEventArgs e) { try { if (lvSW.SelectedItems.Count > 0) { try { string sProdName = ((AddSoftware)lvSW.SelectedItem).ProductName; List <AddSoftware> possibleSW = lInstalledSW.Where(t => t.Manufacturer == ((AddSoftware)lvSW.SelectedItem).Manufacturer & t.ProductVersion == ((AddSoftware)lvSW.SelectedItem).MSIProductID).ToList(); if (possibleSW.Count == 1) { SWUpdate._RunPS(possibleSW[0].PSUninstall.ToString()); } if (possibleSW.Count > 1) { bool bRun = false; foreach (AddSoftware aSW in possibleSW) { string subProdName = new String(sProdName.Where(c => c != '-' && c != '.' && (c <'0' || c> '9')).ToArray()).Trim(); if (subProdName == new String(aSW.ProductName.Where(c => c != '-' && c != '.' && (c < '0' || c > '9')).ToArray()).Trim()) { SWUpdate._RunPS(aSW.PSUninstall.ToString()); bRun = true; continue; } } if (!bRun) { Process.Start("control", "appwiz.cpl"); } } } catch { } } } catch { } }
private void miUninstall_Click(object sender, RoutedEventArgs e) { tSearch.Stop(); lvSW.ContextMenu.IsOpen = false; Thread.Sleep(200); Dispatcher.Invoke(new Action(() => { }), System.Windows.Threading.DispatcherPriority.ContextIdle, null); if (lvSW.SelectedItem != null) { try { foreach (var oItem in lvSW.SelectedItems) { try { SWUpdate oSW = null; if (oItem.GetType() == typeof(GetSoftware)) { GetSoftware dgr = oItem as GetSoftware; //sPS = GetSWInstallPS(dgr.ProductName, dgr.ProductVersion, ""); oSW = new SWUpdate(dgr.ProductName, dgr.ProductVersion, dgr.Manufacturer); if (oSW.SW == null) { dm.lDLTasks.Add(new DLTask() { ProductName = dgr.ProductName, ProductVersion = dgr.ProductVersion, Error = true, ErrorMessage = "Requirements not valid." }); dm.Show(); continue; } } if (oItem.GetType() == typeof(AddSoftware)) { AddSoftware dgr = oItem as AddSoftware; //sPS = GetSWInstallPS(dgr.ProductName, dgr.ProductVersion, ""); oSW = new SWUpdate(dgr); if (oSW.SW == null) { dm.lDLTasks.Add(new DLTask() { ProductName = dgr.ProductName, ProductVersion = dgr.ProductVersion, Error = true, ErrorMessage = "Requirements not valid." }); dm.Show(); continue; } } oSW.sUserName = Properties.Settings.Default.UserKey; //lDLTasks.Add(oSW.downloadTask); if (dm.lDLTasks.FirstOrDefault(t => t.ProductName == oSW.SW.ProductName) == null) { //oSW.Downloaded += OSW_Downloaded; oSW.ProgressDetails += OSW_ProgressDetails; oSW.downloadTask.AutoInstall = true; dm.lDLTasks.Add(oSW.downloadTask); oSW.UnInstall(false, false).ConfigureAwait(false); } dm.Show(); } catch (Exception ex) { Debug.WriteLine(ex.Message); } } } catch { } OnSWUpdated(this, new EventArgs()); } }
private void btInstall_Click(object sender, RoutedEventArgs e) { if (lvSW.SelectedItem != null) { tSearch.Stop(); try { foreach (var oItem in lvSW.SelectedItems) { try { SWUpdate oSW = null; if (oItem.GetType() == typeof(GetSoftware)) { GetSoftware dgr = oItem as GetSoftware; if (oSW == null) { oSW = new SWUpdate(dgr.ProductName, dgr.ProductVersion, dgr.Manufacturer); } if (oSW.SW == null) { dm.lDLTasks.Add(new DLTask() { ProductName = dgr.ProductName, ProductVersion = dgr.ProductVersion, Error = true, ErrorMessage = "Requirements not valid. Installation will not start." }); dm.Show(); continue; } } if (oItem.GetType() == typeof(AddSoftware)) { AddSoftware dgr = oItem as AddSoftware; //sPS = GetSWInstallPS(dgr.ProductName, dgr.ProductVersion, ""); oSW = new SWUpdate(dgr); if (oSW.SW == null) { dm.lDLTasks.Add(new DLTask() { ProductName = dgr.ProductName, ProductVersion = dgr.ProductVersion, Error = true, ErrorMessage = "Requirements not valid. Installation will not start." }); dm.Show(); continue; } } oSW.sUserName = Properties.Settings.Default.UserKey; try { var xRem = dm.lDLTasks.Where(x => x.ProductName == oSW.SW.ProductName && (x.Error || (x.PercentDownloaded == 100 && x.AutoInstall == false) || (x.Status == "Waiting" && x.DownloadedBytes == 0 && x.Downloading == false) || x.UnInstalled)).ToList(); foreach (var o in xRem) { try { dm.lDLTasks.Remove(o); } catch { } } //xRem.ForEach(x => lDLTasks.Remove(x)); } catch { } //Allow only one entry if (dm.lDLTasks.FirstOrDefault(t => t.ProductName == oSW.SW.ProductName) == null) { //oSW.Downloaded += OSW_Downloaded; oSW.ProgressDetails += OSW_ProgressDetails; oSW.downloadTask.AutoInstall = true; oSW.Download(false).ConfigureAwait(false);; dm.lDLTasks.Add(oSW.downloadTask); foreach (string sPreReq in oSW.SW.PreRequisites) { try { SWUpdate oPreReq = new SWUpdate(sPreReq); if (oPreReq.GetInstallType()) { oPreReq.sUserName = Properties.Settings.Default.UserKey; if (dm.lDLTasks.FirstOrDefault(t => t.ProductName == oPreReq.SW.ProductName) == null) { //oPreReq.Downloaded += OSW_Downloaded; oPreReq.ProgressDetails += OSW_ProgressDetails; oPreReq.downloadTask.AutoInstall = true; oPreReq.Download(false).ConfigureAwait(false);; dm.lDLTasks.Add(oPreReq.downloadTask); } } } catch { } } } dm.Show(); } catch (Exception ex) { Debug.WriteLine(ex.Message); } } } catch { } OnSWUpdated(this, new EventArgs()); } }
private void miDownloadIpfs_Click(object sender, RoutedEventArgs e) { if (lvSW.SelectedItem != null) { try { foreach (var oItem in lvSW.SelectedItems) { try { SWUpdate oSW = null; if (oItem.GetType() == typeof(GetSoftware)) { GetSoftware dgr = oItem as GetSoftware; //sPS = GetSWInstallPS(dgr.ProductName, dgr.ProductVersion, ""); oSW = new SWUpdate(dgr.ProductName, dgr.ProductVersion, dgr.Manufacturer); } if (oItem.GetType() == typeof(AddSoftware)) { AddSoftware dgr = oItem as AddSoftware; //sPS = GetSWInstallPS(dgr.ProductName, dgr.ProductVersion, ""); oSW = new SWUpdate(dgr.ProductName, dgr.ProductVersion, dgr.Manufacturer); //oSW = new SWUpdate(dgr); } oSW.sUserName = Properties.Settings.Default.UserKey; //lDLTasks.Add(oSW.downloadTask); if (dm.lDLTasks.FirstOrDefault(t => t.ProductName == oSW.SW.ProductName) == null) { //oSW.Downloaded += OSW_Downloaded; oSW.ProgressDetails += OSW_ProgressDetails; oSW.downloadTask.AutoInstall = false; foreach (var oFile in oSW.SW.Files.ToList()) { //Check if there is a known IPFS hash and update URL if there is... string sHash = RuckZuck_WCF.RZRestAPI.GetIPFS(oSW.SW.ContentID, oFile.FileName); if (sHash.Length > 12) { oFile.URL = RuckZuck_WCF.RZRestAPI.ipfs_GW_URL + "/" + sHash + "/"; oSW.Download(false).ConfigureAwait(false); } else { return; } } dm.lDLTasks.Add(oSW.downloadTask); } dm.Show(); continue; } catch (Exception ex) { Debug.WriteLine(ex.Message); } } } catch { } OnSWUpdated(this, new EventArgs()); } }
private void miCreateArtifact_Click(object sender, RoutedEventArgs e) { Mouse.OverrideCursor = Cursors.Wait; try { foreach (var oItem in lvSW.SelectedItems) { try { SWUpdate oSW = null; if (oItem.GetType() == typeof(GetSoftware)) { GetSoftware dgr = oItem as GetSoftware; //sPS = GetSWInstallPS(dgr.ProductName, dgr.ProductVersion, ""); oSW = new SWUpdate(dgr.ProductName, dgr.ProductVersion, dgr.Manufacturer); } if (oItem.GetType() == typeof(AddSoftware)) { AddSoftware dgr = oItem as AddSoftware; //sPS = GetSWInstallPS(dgr.ProductName, dgr.ProductVersion, ""); oSW = new SWUpdate(dgr); } string sDir = AppDomain.CurrentDomain.BaseDirectory; sDir = Path.Combine(sDir, "windows-" + oSW.SW.Shortname.Replace(" ", "")).Trim(); Directory.CreateDirectory(sDir); CreateExe oExe = new CreateExe(Path.Combine(sDir, oSW.SW.Shortname.Replace(" ", "") + "_setup.exe")); oExe.Icon = oSW.SW.Image; oExe.Sources.Add(Properties.Resources.Source.Replace("RZRZRZ", oSW.SW.Shortname)); oExe.Sources.Add(Properties.Resources.RZUpdate); oExe.Sources.Add(Properties.Resources.RZRestApi); oExe.Sources.Add(Properties.Resources.Assembly.Replace("RZRZRZ", oSW.SW.Shortname)); if (!oExe.Compile()) { MessageBox.Show("Failed to create .Exe", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } List <string> lLines = new List <string>(); lLines.Add("{"); lLines.Add("\t\"title\": \"" + oSW.SW.Shortname + "\","); lLines.Add("\t\"description\": \"" + oSW.SW.Description + "\","); lLines.Add("\t\"publisher\": \"" + oSW.SW.Manufacturer + "\","); lLines.Add("\t\"tags\": [\"Windows\""); if (((GetSoftware)oItem).Categories.Count > 0) { foreach (string sCat in ((GetSoftware)oItem).Categories) { lLines.Add("\t, \"" + sCat + "\""); } lLines.Add("\t],"); } else { lLines.Add("\t],"); } lLines.Add("\t\"iconUri\": \"https://ruckzuck.azurewebsites.net/wcf/RZService.svc/rest/GetIcon?id=" + ((GetSoftware)oItem).IconId + "\","); lLines.Add("\t\"targetOsType\": \"Windows\","); lLines.Add("\t\"runCommand\": { \"commandToExecute\": \"" + oSW.SW.Shortname.Replace(" ", "") + "_setup.exe" + "\" }"); lLines.Add("}"); System.IO.File.WriteAllLines(Path.Combine(sDir, "artifactfile.json"), lLines.ToArray()); //Non authenticated Users can create one EXE if (!EnableEdit) { miCreateArtifact.IsEnabled = false; return; } } catch { } } } finally { Mouse.OverrideCursor = null; } }