private void miSendFeedback_Click(object sender, RoutedEventArgs e) { if (lvSW.SelectedItems.Count > 0) { try { GetSoftware oSelectedItem = ((GetSoftware)lvSW.SelectedItem); var vDB = Task.Run(() => { try { AnonymousDelegate update = delegate() { FeedbackForm oFeedBack = new FeedbackForm(); oFeedBack.Title = oSelectedItem.ProductName + " " + oSelectedItem.ProductVersion; oFeedBack.ShowDialog(); if (oFeedBack.hasFeedback) { RZRestAPI.Feedback(oSelectedItem.ProductName, oSelectedItem.ProductVersion, oSelectedItem.Manufacturer, "", oFeedBack.isWorking.ToString(), Properties.Settings.Default.UserKey, oFeedBack.tbFeedback.Text).ConfigureAwait(false);; } }; Dispatcher.Invoke(update); } catch { } }); } catch { } } }
private void miSendFeedback_Click(object sender, RoutedEventArgs e) { if (lvSW.SelectedItems.Count > 0) { try { GetSoftware oSelectedItem = ((GetSoftware)lvSW.SelectedItem); var vDB = Task.Run(() => { try { AnonymousDelegate update = delegate() { FeedbackForm oFeedBack = new FeedbackForm(); oFeedBack.Title = oSelectedItem.ProductName + " " + oSelectedItem.ProductVersion; oFeedBack.ShowDialog(); if (oFeedBack.hasFeedback) { RZRestAPIv2.Feedback(oSelectedItem.ProductName, oSelectedItem.ProductVersion, oSelectedItem.Manufacturer, oFeedBack.isWorking.ToString(), System.Reflection.Assembly.GetExecutingAssembly().GetName().Name, oFeedBack.tbFeedback.Text, RZRestAPIv2.CustomerID).ConfigureAwait(false);; } }; Dispatcher.Invoke(update); } catch { } }); } catch { } } }
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); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value.GetType() == typeof(GetSoftware)) { GetSoftware oSW = (GetSoftware)value; return(oSW.Categories[0]); } return(null); }
private void miEdit_Click(object sender, RoutedEventArgs e) { lvSW.ContextMenu.IsOpen = false; Thread.Sleep(200); Dispatcher.Invoke(new Action(() => { }), System.Windows.Threading.DispatcherPriority.ContextIdle, null); if (lvSW.SelectedItems.Count > 0) { GetSoftware oSelectedItem = lvSW.SelectedItems[0] as GetSoftware; onEdit?.Invoke(oSelectedItem, EventArgs.Empty); } }
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()); } }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { try { if (value.GetType() == typeof(GetSoftware)) { GetSoftware oSW = (GetSoftware)value; return(oSW.Categories[0]); } } catch (Exception ex) { ex.Message.ToString(); } return(null); }
private void btInstallSoftware_Click(object sender, RoutedEventArgs e) { Mouse.OverrideCursor = Cursors.Wait; try { if (oSCAN.SoftwareRepository.Count == 0) { try { oSCAN.GetSWRepository().Wait(2000); } catch { } } List <GetSoftware> oDBCat = new List <GetSoftware>(); PropertyGroupDescription PGD = new PropertyGroupDescription("", new ShortNameToCategory()); foreach (GetSoftware oSW in oSCAN.SoftwareRepository) { try { if (oSW.Categories.Count > 1) { foreach (string sCAT in oSW.Categories) { try { //Check if SW is already installed if (lSoftware.FirstOrDefault(t => t.ProductName == oSW.ProductName && t.ProductVersion == oSW.ProductVersion) != null) { GetSoftware oNew = new GetSoftware() { Categories = new List <string> { sCAT }, Description = oSW.Description, Downloads = oSW.Downloads, SWId = oSW.SWId, Manufacturer = oSW.Manufacturer, ProductName = oSW.ProductName, ProductURL = oSW.ProductURL, ProductVersion = oSW.ProductVersion, ShortName = oSW.ShortName, IconHash = oSW.IconHash, isInstalled = true }; oDBCat.Add(oNew); } else { GetSoftware oNew = new GetSoftware() { Categories = new List <string> { sCAT }, Description = oSW.Description, Downloads = oSW.Downloads, SWId = oSW.SWId, Manufacturer = oSW.Manufacturer, ProductName = oSW.ProductName, ProductURL = oSW.ProductURL, ProductVersion = oSW.ProductVersion, ShortName = oSW.ShortName, IconHash = oSW.IconHash, isInstalled = false }; oDBCat.Add(oNew); } } catch { } } } else { //Check if SW is already installed if (lSoftware.FirstOrDefault(t => t.ProductName == oSW.ProductName && t.ProductVersion == oSW.ProductVersion) != null) { oDBCat.Add(new GetSoftware() { Categories = oSW.Categories, Description = oSW.Description, Downloads = oSW.Downloads, SWId = oSW.SWId, Manufacturer = oSW.Manufacturer, ProductName = oSW.ProductName, ProductURL = oSW.ProductURL, ProductVersion = oSW.ProductVersion, ShortName = oSW.ShortName, IconHash = oSW.IconHash, isInstalled = true }); } else { oDBCat.Add(new GetSoftware() { Categories = oSW.Categories, Description = oSW.Description, Downloads = oSW.Downloads, SWId = oSW.SWId, Manufacturer = oSW.Manufacturer, ProductName = oSW.ProductName, ProductURL = oSW.ProductURL, ProductVersion = oSW.ProductVersion, ShortName = oSW.ShortName, IconHash = oSW.IconHash, isInstalled = false }); } } } catch { } } ListCollectionView lcv = new ListCollectionView(oDBCat.ToList()); foreach (var o in RZRestAPIv2.GetCategories(oSCAN.SoftwareRepository)) { PGD.GroupNames.Add(o); } lcv.GroupDescriptions.Add(PGD); oInstPanel.lvSW.ItemsSource = lcv; oInstPanel.lSoftware = lSoftware; oInstPanel.lAllSoftware = oSCAN.SoftwareRepository; //Mark all installed... oInstPanel.lAllSoftware.ForEach(x => { if (lSoftware.FirstOrDefault(t => (t.ProductName == x.ProductName && t.ProductVersion == x.ProductVersion)) != null) { x.isInstalled = true; } }); /*if (!string.IsNullOrEmpty(tbURL.Text)) * oInstPanel.sInternalURL = tbURL.Text;*/ } finally { Mouse.OverrideCursor = null; } tabWizard.SelectedItem = tabInstallSW; }
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()); } }
//public event ChangedEventHandler onEdit; public InstallSwPanel() { InitializeComponent(); tSearch.Elapsed += TSearch_Elapsed; tSearch.Enabled = false; tSearch.AutoReset = false; Mouse.OverrideCursor = Cursors.Wait; try { if (string.IsNullOrEmpty(sAuthToken)) { sAuthToken = RZRestAPI.GetAuthToken("FreeRZ", GetTimeToken()); } RZRestAPI.Token = sAuthToken; RZScan oSCAN = new RZScan(false, false); Task.Run(() => oSCAN.GetSWRepository()).Wait(); lAllSoftware = oSCAN.SoftwareRepository; List <GetSoftware> oDBCat = new List <GetSoftware>(); PropertyGroupDescription PGD = new PropertyGroupDescription("", new ShortnameToCategory()); foreach (GetSoftware oSW in oSCAN.SoftwareRepository) { try { if (oSW.Categories.Count > 1) { foreach (string sCAT in oSW.Categories) { try { //Check if SW is already installed if (lSoftware.FirstOrDefault(t => t.ProductName == oSW.ProductName & t.ProductVersion == oSW.ProductVersion) != null) { GetSoftware oNew = new GetSoftware() { Categories = new List <string> { sCAT }, Description = oSW.Description, Downloads = oSW.Downloads, IconId = oSW.IconId, Manufacturer = oSW.Manufacturer, ProductName = oSW.ProductName, ProductURL = oSW.ProductURL, ProductVersion = oSW.ProductVersion, Quality = oSW.Quality, Shortname = oSW.Shortname, isInstalled = true }; oDBCat.Add(oNew); } else { GetSoftware oNew = new GetSoftware() { Categories = new List <string> { sCAT }, Description = oSW.Description, Downloads = oSW.Downloads, IconId = oSW.IconId, Manufacturer = oSW.Manufacturer, ProductName = oSW.ProductName, ProductURL = oSW.ProductURL, ProductVersion = oSW.ProductVersion, Quality = oSW.Quality, Shortname = oSW.Shortname, isInstalled = false }; oDBCat.Add(oNew); } } catch { } } } else { //Check if SW is already installed if (lSoftware.FirstOrDefault(t => t.ProductName == oSW.ProductName & t.ProductVersion == oSW.ProductVersion) != null) { oDBCat.Add(new GetSoftware() { Categories = oSW.Categories, Description = oSW.Description, Downloads = oSW.Downloads, IconId = oSW.IconId, Manufacturer = oSW.Manufacturer, ProductName = oSW.ProductName, ProductURL = oSW.ProductURL, ProductVersion = oSW.ProductVersion, Quality = oSW.Quality, Shortname = oSW.Shortname, isInstalled = true }); } else { oDBCat.Add(new GetSoftware() { Categories = oSW.Categories, Description = oSW.Description, Downloads = oSW.Downloads, IconId = oSW.IconId, Manufacturer = oSW.Manufacturer, ProductName = oSW.ProductName, ProductURL = oSW.ProductURL, ProductVersion = oSW.ProductVersion, Quality = oSW.Quality, Shortname = oSW.Shortname, isInstalled = false }); } } } catch { } } ListCollectionView lcv = new ListCollectionView(oDBCat.ToList()); foreach (var o in RZRestAPI.GetCategories(oSCAN.SoftwareRepository)) { PGD.GroupNames.Add(o); } lcv.GroupDescriptions.Add(PGD); lvSW.ItemsSource = lcv; } catch { } Mouse.OverrideCursor = null; }
private void btInstall_Click(object sender, RoutedEventArgs e) { if (lvSW.SelectedItem != null) { Mouse.OverrideCursor = Cursors.Wait; try { foreach (var oItem in lvSW.SelectedItems) { try { //string sPS = ""; string sProdName = ""; string sProdVersion = ""; string sManuf = ""; if (oItem.GetType() == typeof(GetSoftware)) { GetSoftware dgr = oItem as GetSoftware; sProdName = dgr.ProductName; sProdVersion = dgr.ProductVersion; sManuf = dgr.Manufacturer; } bool bInstalled = false; foreach (var DT in RZRestAPI.GetSWDefinitions(sProdName, sProdVersion, sManuf)) { //Check PreReqs try { if (!string.IsNullOrEmpty(DT.PSPreReq) & !bInstalled) { if (!(bool)oAgent.Client.GetObjectsFromPS(DT.PSPreReq, true, new TimeSpan(0, 0, 0))[0].BaseObject) { //PreReq not match continue; } else { //Check if already installed if ((bool)oAgent.Client.GetObjectsFromPS(DT.PSDetection, true, new TimeSpan(0, 0, 0))[0].BaseObject) { MessageBox.Show("Software is already installed.", "Installation Status:", MessageBoxButton.OK, MessageBoxImage.Information); bInstalled = true; continue; } //Create target Folder oAgent.Client.GetStringFromPS("$Folder = join-path $env:TEMP '" + DT.ContentID + "'; New-Item -ItemType Directory -Force -Path $Folder -ErrorAction SilentlyContinue | Out-Null", true); //Download Files foreach (var File in DT.Files) { if (!File.URL.StartsWith("http", StringComparison.InvariantCultureIgnoreCase) & !File.URL.StartsWith("ftp", StringComparison.InvariantCultureIgnoreCase)) { try { File.URL = oAgent.Client.GetStringFromPS(File.URL); } catch { } } oAgent.Client.GetStringFromPS("$Folder = join-path $env:TEMP '" + DT.ContentID + "'; $Target = join-path $Folder '" + File.FileName + "' ;Invoke-WebRequest '" + File.URL + "' -MaximumRedirection 2 -OutFile $Target -UserAgent 'chocolatey command line' ", true); } //Install string sInst = "Set-Location -Path $Folder -ErrorAction SilentlyContinue; "; if (!string.IsNullOrEmpty(DT.PSPreInstall)) { sInst = sInst + "Invoke-Expression " + DT.PSPreInstall + " | Out-Null; "; } if (!string.IsNullOrEmpty(DT.PSInstall)) { sInst = sInst + "Invoke-Expression " + DT.PSInstall + " | Out-Null; "; } if (!string.IsNullOrEmpty(DT.PSPostInstall)) { sInst = sInst + "Invoke-Expression " + DT.PSPostInstall + " | Out-Null; "; } string sRes = oAgent.Client.GetStringFromPS(sInst, true); //Check if installed if ((bool)oAgent.Client.GetObjectsFromPS(DT.PSDetection, true, new TimeSpan(0, 0, 0))[0].BaseObject) { RZRestAPI.Feedback(DT.ProductName, DT.ProductVersion, DT.Manufacturer, DT.Architecture, "true", "SCCMCliCtr", "Ok...").ConfigureAwait(false); MessageBox.Show("Software installed successfully.", "Installation Status:", MessageBoxButton.OK, MessageBoxImage.Information); bInstalled = true; continue; } else { MessageBox.Show("Software installation failed.. " + sRes, "Installation Status:", MessageBoxButton.OK, MessageBoxImage.Warning); } } } } catch { } } } catch (Exception ex) { Debug.WriteLine(ex.Message); } } } catch { } Mouse.OverrideCursor = null; } }
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; } }