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 { } } }
/// <summary> /// Authenticate User and refresh token /// </summary> public void Authenticate() { try { //Authenticate with custom User and Password from config file... if (!string.IsNullOrEmpty(Properties.Settings.Default.UserPW)) { string sResponse = RZRestAPI.GetAuthToken(Properties.Settings.Default.UserKey, Decrypt(Properties.Settings.Default.UserPW, Environment.UserName)); try { Guid.Parse(sResponse); sAuthToken = sResponse; //tbURL.Text = Properties.Settings.Default.InternalURL; //oInstPanel.sInternalURL = Properties.Settings.Default.InternalURL; tbURL.IsEnabled = true; tbIPFSGW.IsEnabled = true; } catch { } } //Authenticate with dummy account if (string.IsNullOrEmpty(sAuthToken)) { sAuthToken = RZRestAPI.GetAuthToken("FreeRZ", GetTimeToken()); } } catch { } }
private void btApproval_Click(object sender, RoutedEventArgs e) { Mouse.OverrideCursor = Cursors.Wait; try { tSearch.Stop(); var badSW = RZRestAPI.SWResults("--APPROVE--").Distinct().Select(x => new GetSoftware() { Categories = x.Categories.ToList(), Description = x.Description, Downloads = x.Downloads, IconId = x.IconId, Image = x.Image, Manufacturer = x.Manufacturer, ProductName = x.ProductName, ProductURL = x.ProductURL, ProductVersion = x.ProductVersion, Quality = x.Quality, Shortname = x.Shortname, isInstalled = false }).ToList(); tbSearch.Text = ""; //Mark all installed... badSW.ForEach(x => { if (lSoftware.FirstOrDefault(t => (t.ProductName == x.ProductName & t.ProductVersion == x.ProductVersion)) != null) { x.isInstalled = true; } }); ListCollectionView lcv = new ListCollectionView(badSW.ToList()); lvSW.ItemsSource = lcv; } finally { Mouse.OverrideCursor = null; } }
private void btNew_Click(object sender, RoutedEventArgs e) { Mouse.OverrideCursor = Cursors.Wait; try { tSearch.Stop(); var badSW = RZRestAPI.SWResults("--NEW--").ToList(); tbSearch.Text = ""; //Mark all installed... badSW.ForEach(x => { if (lSoftware.FirstOrDefault(t => (t.ProductName == x.ProductName & t.ProductVersion == x.ProductVersion)) != null) { x.isInstalled = true; } }); ListCollectionView lcv = new ListCollectionView(badSW.ToList()); lvSW.ItemsSource = lcv; } finally { Mouse.OverrideCursor = null; } }
/// <summary> /// Check for updated Version in the RuckZuck Repository /// </summary> /// <param name="aSWCheck">null = all Installed SW</param> internal void CheckUpdates(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()); }); }
private void _addPackageSource(string name, string location, bool trusted, Request request) { Properties.Settings.Default.Location = location; //Set default URL if no loaction is specified if (!string.IsNullOrEmpty(location)) { Properties.Settings.Default.Location = location; Properties.Settings.Default.Save(); } //RZRestAPI.sURL = Properties.Settings.Default.Location; string sUser = "******"; SecureString sPW = ToSecureString(GetTimeToken()); if (request.OptionKeys.Contains("Username")) { Properties.Settings.Default.Username = request.GetOptionValue("Username"); sUser = Properties.Settings.Default.Username; } else { Properties.Settings.Default.Username = ""; } if (request.OptionKeys.Contains("Password")) { sPW = ToSecureString(request.GetOptionValue("Password")); Properties.Settings.Default.Password = EncryptString(sPW); } else { Properties.Settings.Default.Password = ""; } if (request.OptionKeys.Contains("ContentURL")) { Properties.Settings.Default.ContentURL = request.GetOptionValue("ContentURL"); } else { Properties.Settings.Default.ContentURL = ""; } Properties.Settings.Default.Save(); _AuthenticationToken = RZRestAPI.GetAuthToken(sUser, ToInsecureString(sPW)); Guid gToken; if (!Guid.TryParse(_AuthenticationToken, out gToken)) { request.Warning(_AuthenticationToken); dLastTokenRefresh = new DateTime(); return; } }
private void tbSearch_MouseDoubleClick(object sender, MouseButtonEventArgs e) { tSearch.Stop(); lAllSoftware = RZRestAPI.SWResults("").Distinct().OrderBy(t => t.Shortname).ThenByDescending(t => t.ProductVersion).ThenByDescending(t => t.ProductName).Select(x => new GetSoftware() { isInstalled = false }).ToList(); //Mark all installed... lAllSoftware.ToList().ForEach(x => { if (lSoftware.FirstOrDefault(t => (t.ProductName == x.ProductName & t.ProductVersion == x.ProductVersion)) != null) { x.isInstalled = true; } }); }
private void MenuItem_Click_1(object sender, RoutedEventArgs e) { try { List <GetSoftware> oSW = RZRestAPI.SWResults(tbProductName.Text).ToList(); if (oSW.FirstOrDefault() != null) { tbProductURL.Text = oSW.FirstOrDefault().ProductURL; tbDescription.Text = oSW.FirstOrDefault().Description; } btUpload.IsEnabled = true; } catch { } }
private void tbSearch_Search(object sender, RoutedEventArgs e) { Mouse.OverrideCursor = Cursors.Wait; if (string.IsNullOrEmpty(tbSearch.Text)) { tbSearch.Foreground = new SolidColorBrush(Colors.LightGray); tbSearch.Tag = "Search"; tbSearch.Text = "Search..."; ListCollectionView lcv = new ListCollectionView(lAllSoftware.Distinct().OrderBy(t => t.ShortName).ThenByDescending(t => t.ProductVersion).ThenByDescending(t => t.ProductName).ToList()); //ListCollectionView lcv = new ListCollectionView(oAPI.SWResults("", "").Distinct().OrderBy(t => t.ShortName).ThenByDescending(t => t.ProductVersion).ThenByDescending(t => t.ProductName).ToList()); PropertyGroupDescription PGD = new PropertyGroupDescription("", new ShortNameToCategory()); //PGD.GroupNames.Add(RZRestAPI.GetCategories(lAllSoftware)); foreach (var o in RZRestAPI.GetCategories(lAllSoftware)) { PGD.GroupNames.Add(o); } lcv.GroupDescriptions.Add(PGD); lvSW.ItemsSource = lcv; } else { tbSearch.Foreground = new SolidColorBrush(Colors.Black); tbSearch.Tag = null; try { var vResult = lAllSoftware.FindAll(t => t.ShortName.IndexOf(tbSearch.Text, 0, StringComparison.InvariantCultureIgnoreCase) >= 0).ToList(); vResult.AddRange(lAllSoftware.FindAll(t => t.ProductName.IndexOf(tbSearch.Text, 0, StringComparison.InvariantCultureIgnoreCase) >= 0).ToList()); vResult.AddRange(lAllSoftware.FindAll(t => t.Manufacturer.IndexOf(tbSearch.Text, 0, StringComparison.InvariantCultureIgnoreCase) >= 0).ToList()); if (vResult.Count <= 15) { vResult.AddRange(lAllSoftware.FindAll(t => (t.Description ?? "").IndexOf(tbSearch.Text, 0, StringComparison.InvariantCultureIgnoreCase) >= 0).ToList()); } lvSW.ItemsSource = vResult.Distinct().OrderBy(t => t.ShortName).ThenByDescending(t => t.ProductVersion).ThenByDescending(t => t.ProductName); } catch { } } Mouse.OverrideCursor = null; }
/// <summary> /// Check if RuckZuck Token is still valid or request a new token if last refresh was mor than an hour /// </summary> /// <param name="request"></param> private void _reAuthenticate(Request request) { //Check if there is a token.. Guid gToken; if (!Guid.TryParse(_AuthenticationToken, out gToken)) { dLastTokenRefresh = new DateTime(); } //Re-Authenticate after 30min if ((DateTime.Now - dLastTokenRefresh).TotalMinutes >= 30) { if (string.IsNullOrEmpty(Properties.Settings.Default.Location)) { //Properties.Settings.Default.Location = WebServiceURL; //Properties.Settings.Default.Save(); } //RZRestAPI.sURL = Properties.Settings.Default.Location; if (!string.IsNullOrEmpty(Properties.Settings.Default.Username)) { _AuthenticationToken = RZRestAPI.GetAuthToken(Properties.Settings.Default.Username, ToInsecureString(DecryptString(Properties.Settings.Default.Password))); dLastTokenRefresh = DateTime.Now; request.Debug("RZ Account: " + Properties.Settings.Default.Username); } else { _AuthenticationToken = RZRestAPI.GetAuthToken("FreeRZ", GetTimeToken()); dLastTokenRefresh = DateTime.Now; request.Debug("RZ Account: FreeRZ"); } if (!Guid.TryParse(_AuthenticationToken, out gToken)) { dLastTokenRefresh = new DateTime(); request.Warning(_AuthenticationToken); _AuthenticationToken = ""; return; } request.Debug("RZ Authentication Token:" + _AuthenticationToken); } }
private void btSettingsSave_Click(object sender, RoutedEventArgs e) { string sResponse = RZRestAPI.GetAuthToken(tbUsername.Text, tbPassword.Password); try { //Check if GUID came back.. Guid.Parse(sResponse); //Enable InternalURL //tbURL.IsEnabled = true; tbIPFSGW.IsEnabled = true; //Update and save new username and password Properties.Settings.Default.UserKey = tbUsername.Text; Properties.Settings.Default.UserPW = Encrypt(tbPassword.Password, Environment.UserName); //Properties.Settings.Default.InternalURL = tbURL.Text; Properties.Settings.Default.IPFSGW = tbIPFSGW.Text; RuckZuck_WCF.RZRestAPI.ipfs_GW_URL = tbIPFSGW.Text; Properties.Settings.Default.Save(); //oInstPanel.sInternalURL = tbURL.Text; //Back to Main //tabWizard.SelectedItem = tabMain; tbUsername.BorderBrush = Brushes.Green; oInstPanel.EnableFeedback = true; oInstPanel.EnableEdit = true; oInstPanel.EnableSupport = true; oSCAN.SoftwareRepository = new List <GetSoftware>(); oSCAN.GetSWRepository().ConfigureAwait(false); } catch { //Username or Password are wrong ! tbUsername.BorderBrush = Brushes.Red; tbPassword.BorderBrush = Brushes.Red; tbUsername.ToolTip = sResponse; tbPassword.ToolTip = sResponse; //oInstPanel.sInternalURL = ""; } }
private void tabWizard_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (tabWizard.SelectedItem != tabNewSWSMI & e.Source == tabWizard) { oNewPanel.unload(); } if (tabWizard.SelectedItem == tabNewSWARP & e.Source == tabWizard) { Mouse.OverrideCursor = Cursors.Wait; try { arpGrid2.AutoGenerateColumns = false; List <GetSoftware> lServer = new List <GetSoftware>(); if (oInstPanel.lvSW.ItemsSource == null) { lServer = RZRestAPI.SWResults("").OrderBy(t => t.Shortname).ThenByDescending(t => t.ProductVersion).ThenByDescending(t => t.ProductName).ToList(); } else { lServer = oInstPanel.lvSW.ItemsSource as List <GetSoftware>; } if (lServer == null) { lServer = RZRestAPI.SWResults("").OrderBy(t => t.Shortname).ThenByDescending(t => t.ProductVersion).ThenByDescending(t => t.ProductName).ToList(); } if (Keyboard.Modifiers == ModifierKeys.Shift) { arpGrid2.ItemsSource = lSoftware.OrderBy(t => t.ProductName).ThenBy(t => t.ProductVersion).ThenBy(t => t.Manufacturer).ToList(); } else { arpGrid2.ItemsSource = lSoftware.Where(t => lServer.Count(x => x.ProductName == t.ProductName & x.Manufacturer == t.Manufacturer & x.ProductVersion == t.ProductVersion) == 0).OrderBy(t => t.ProductName).ThenBy(t => t.ProductVersion).ThenBy(t => t.Manufacturer).ToList(); } } finally { Mouse.OverrideCursor = null; } } }
public async Task <bool> GetSWRepository() { //var tGetSWRepo = bool bResult = await Task.Run(() => { try { var oDB = RZRestAPI.SWResults("").Distinct().OrderBy(t => t.Shortname).ThenByDescending(t => t.ProductVersion).ThenByDescending(t => t.ProductName).ToList(); lock (SoftwareRepository) { SoftwareRepository = oDB.Select(item => new GetSoftware() { Categories = item.Categories ?? new List <string>(), Description = item.Description, Downloads = item.Downloads, IconId = item.IconId, SWId = item.SWId, Image = item.Image, Manufacturer = item.Manufacturer, ProductName = item.ProductName, ProductURL = item.ProductURL, ProductVersion = item.ProductVersion, Shortname = item.Shortname, IconHash = item.IconHash }).ToList(); } } catch (Exception ex) { Debug.WriteLine(ex.Message.ToString()); } OnSWRepoLoaded(this, new EventArgs()); return(true); }); return(bResult); }
private void PSCode_Load(object sender, EventArgs e) { string sCurrentDir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); try { ToolStripMenuItem tsm = new ToolStripMenuItem(); if (string.IsNullOrEmpty(sAuthToken)) { sAuthToken = RZRestAPI.GetAuthToken("FreeRZ", GetTimeToken()); } RZRestAPI.Token = sAuthToken; lAllSoftware = RZRestAPI.SWResults(""); dataGridView1.DataSource = lAllSoftware.ToList().OrderBy(t => t.Shortname).ToList(); } catch (Exception ex) { ex.Message.ToString(); } }
static void Main(string[] args) { MessagingFactory messageFactory; NamespaceManager namespaceManager; //TopicClient myTopicClient; System.Net.ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true; System.Net.ServicePointManager.CheckCertificateRevocationList = false; Console.Write("Connecting ServiceBus..."); string sConnString = Properties.Settings.Default.ConnectionString; messageFactory = MessagingFactory.CreateFromConnectionString(sConnString); namespaceManager = NamespaceManager.CreateFromConnectionString(sConnString); if (namespaceManager == null) { Console.WriteLine("\nUnexpected Error"); return; } string TopicName = Properties.Settings.Default.TopicName; if (!namespaceManager.TopicExists(TopicName)) { namespaceManager.CreateTopic(TopicName); } Console.WriteLine("... connected."); if (!namespaceManager.SubscriptionExists(TopicName, string.Format(Properties.Settings.Default.Filtername, Environment.MachineName))) { SqlFilter dashboardFilter = new SqlFilter(Properties.Settings.Default.SQLFilter); namespaceManager.CreateSubscription(TopicName, string.Format(Properties.Settings.Default.Filtername, Environment.MachineName), dashboardFilter); return; } string sLastPackage = ""; var Client = messageFactory.CreateSubscriptionClient(TopicName, string.Format(Properties.Settings.Default.Filtername, Environment.MachineName), ReceiveMode.PeekLock); Client.OnMessage((message) => { try { /*if (message.Label.Contains(@"Feedback/failure")) * Console.ForegroundColor = ConsoleColor.Red; * if (message.Label.Contains(@"Feedback/success")) * Console.ForegroundColor = ConsoleColor.Green;*/ //Console.WriteLine(message.EnqueuedTimeUtc.ToLocalTime().ToString("HH:mm") + " " + message.Properties["WorkerServiceHost"].ToString() + "(" + message.Properties["Queue"].ToString() + ") : " + message.Properties["TargetComputer"].ToString() + " : " + message.GetBody<string>()); //Console.WriteLine(message.EnqueuedTimeUtc.ToLocalTime().ToString("HH:mm") + " " + message.Label + " " + message.GetBody<string>()); try { /*if (message.Properties["IP"].ToString() == "193.5.178.34") * { * message.Abandon(); * return; * } * if (message.Properties["ProductName"].ToString() == "Adobe Acrobat Reader DC") * { * message.Abandon(); * return; * } * if (message.Properties["ProductName"].ToString() == "Adobe Acrobat Reader DC MUI") * { * message.Abandon(); * return; * }*/ RZUpdater oRZSW = new RZUpdater(); oRZSW.SoftwareUpdate = new SWUpdate(message.Properties["ProductName"].ToString(), message.Properties["ProductVersion"].ToString(), message.Properties["Manufacturer"].ToString()); //oRZSW.SoftwareUpdate = new SWUpdate(message.Properties["ProductName"].ToString()); if (sLastPackage != oRZSW.SoftwareUpdate.SW.Shortname) { oRZSW.SoftwareUpdate = new SWUpdate(oRZSW.SoftwareUpdate.SW.Shortname); oRZSW.SoftwareUpdate.SendFeedback = false; //we already process feedback... if (string.IsNullOrEmpty(oRZSW.SoftwareUpdate.SW.ProductName)) { Console.WriteLine("Error: ProductName not valid... " + message.Properties["ProductName"].ToString()); message.Abandon(); //Console.WriteLine("Error: Product not found in Repository..."); } else { Console.WriteLine(oRZSW.SoftwareUpdate.SW.Manufacturer + " " + oRZSW.SoftwareUpdate.SW.ProductName + " " + oRZSW.SoftwareUpdate.SW.ProductVersion); Console.Write("Downloading..."); foreach (string sPreReq in oRZSW.SoftwareUpdate.SW.PreRequisites) { RZUpdater oRZSWPreReq = new RZUpdater(); oRZSWPreReq.SoftwareUpdate = new SWUpdate(sPreReq); Console.WriteLine(); Console.Write("\tDownloading dependencies (" + oRZSWPreReq.SoftwareUpdate.SW.Shortname + ")..."); if (oRZSWPreReq.SoftwareUpdate.Download().Result) { Console.WriteLine("... done."); Console.Write("\tInstalling dependencies (" + oRZSWPreReq.SoftwareUpdate.SW.Shortname + ")..."); if (oRZSWPreReq.SoftwareUpdate.Install(false, true).Result) { Console.WriteLine("... done."); } else { Console.WriteLine("... Error. The installation failed."); } } } if (oRZSW.SoftwareUpdate.Download().Result) { Console.WriteLine("... done."); Console.Write("Installing..."); if (oRZSW.SoftwareUpdate.Install(false, true).Result) { Console.WriteLine("... done."); message.Complete(); RZRestAPI.Feedback(oRZSW.SoftwareUpdate.SW.ProductName, oRZSW.SoftwareUpdate.SW.ProductVersion, oRZSW.SoftwareUpdate.SW.Manufacturer, "true", "RZBot", "ok..").Wait(3000); sLastPackage = DateTime.Now.Ticks.ToString();; //return 0; } else { Console.WriteLine("... Error. Installation failed."); sLastPackage = oRZSW.SoftwareUpdate.SW.Shortname; message.Abandon(); //return 1603; } } else { Console.WriteLine("... Error. Download failed."); sLastPackage = oRZSW.SoftwareUpdate.SW.Shortname; message.Abandon(); //return 1602; } } } else { Console.WriteLine("... retry later.."); Thread.Sleep(5000); //message.Abandon(); // retry later.... } } catch { message.Abandon(); } Console.ResetColor(); } catch { } }); Console.ReadLine(); }
internal void _CheckUpdates(List <AddSoftware> aSWCheck) { 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(); //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, Manufacturer = item.Manufacturer, ProductName = item.ProductName, ProductURL = item.ProductURL, ProductVersion = item.ProductVersion, MSIProductID = item.MSIProductID, Shortname = item.Shortname, SWId = item.SWId }).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()); }
//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 _getInstalledPackages(string name, string requiredVersion, string minimumVersion, string maximumVersion, Request request) { _reAuthenticate(request); //Check if AuthToken is still valid try { List <AddSoftware> lResult = getInstalledSW().ToList(); List <GetSoftware> lServer = RZRestAPI.SWResults(name).OrderBy(t => t.Shortname).ToList(); request.Debug("Items Found: " + lServer.Count().ToString()); List <AddSoftware> lLocal = lResult.Where(t => lServer.Count(x => x.ProductName == t.ProductName & x.Manufacturer == t.Manufacturer & x.ProductVersion == t.ProductVersion) != 0).OrderBy(t => t.ProductName).ThenBy(t => t.ProductVersion).ThenBy(t => t.Manufacturer).ToList(); if (!string.IsNullOrEmpty(name)) { string sProdName = ""; try { sProdName = lServer.FirstOrDefault(p => string.Equals(p.Shortname, name, StringComparison.OrdinalIgnoreCase)).ProductName; } catch { } lLocal = lLocal.Where(p => String.Equals(p.ProductName, name, StringComparison.OrdinalIgnoreCase) | String.Equals(p.ProductName, sProdName, StringComparison.OrdinalIgnoreCase)).OrderBy(t => t.ProductName).ToList(); } if (requiredVersion != null) { lLocal = lLocal.Where(p => p.ProductVersion.ToLowerInvariant() == requiredVersion.ToLowerInvariant()).ToList(); } if (minimumVersion != null) { try { lLocal = lLocal.Where(p => Version.Parse(p.ProductVersion) >= Version.Parse(minimumVersion)).ToList(); } catch { lLocal = lLocal.Where(p => p.ProductVersion == minimumVersion).ToList(); } } if (maximumVersion != null) { try { lLocal = lLocal.Where(p => Version.Parse(p.ProductVersion) <= Version.Parse(maximumVersion)).ToList(); } catch { lLocal = lLocal.Where(p => p.ProductVersion == maximumVersion).ToList(); } } foreach (var SW in lLocal) { request.YieldSoftwareIdentity(SW.ProductName + ";" + SW.ProductVersion, SW.ProductName, SW.ProductVersion, "", "", RZRestAPI.sURL, name ?? "", "", SW.Shortname); //request.YieldSoftwareIdentity(SW.Shortname, SW.ProductName, SW.ProductVersion, "", SW.Description, "Local", "", SW.ProductURL, SW.ContentID.ToString()); } } catch { dLastTokenRefresh = new DateTime(); } }
private void _findPackage(string name, string requiredVersion, string minimumVersion, string maximumVersion, int id, Request request) { _reAuthenticate(request); //Check if AuthToken is still valid try { bool exactSearch = true; if (request.OptionKeys.Contains("Contains")) { name = request.GetOptionValue("Contains"); request.Message("exact search disabled."); exactSearch = false; } //Search all if no name is specified if (string.IsNullOrEmpty(name)) { exactSearch = false; } bool bUpdate = false; if (request.OptionKeys.Contains("Updates")) { request.Message("check updates for installed Software."); bUpdate = true; } List <GetSoftware> lResult = new List <GetSoftware>(); //Get all installed SW if (bUpdate) { oScan.CheckForUpdates = false; oScan.SWScan().Wait(); oScan.CheckUpdates(null).Wait(); lSoftware = oScan.InstalledSoftware; List <AddSoftware> RequiredUpdates = oScan.NewSoftwareVersions; // RZApi.CheckForUpdate(lSoftware.ToArray()).ToList().Where(t => t.Architecture != "new").ToList(); foreach (var SW in RequiredUpdates) { try { if (string.IsNullOrEmpty(name)) { lResult.Add(new GetSoftware() { ProductName = SW.ProductName, ProductVersion = SW.ProductVersion, Manufacturer = SW.Manufacturer, Shortname = SW.Shortname, Description = SW.Description, ProductURL = SW.ProductURL }); } else { if ((SW.ProductName.ToLowerInvariant() == name.ToLowerInvariant() | SW.Shortname.ToLowerInvariant() == name.ToLowerInvariant()) & exactSearch) { lResult.Add(new GetSoftware() { ProductName = SW.ProductName, ProductVersion = SW.ProductVersion, Manufacturer = SW.Manufacturer, Shortname = SW.Shortname, Description = SW.Description, ProductURL = SW.ProductURL }); } if ((SW.ProductName.ToLowerInvariant().Contains(name.ToLowerInvariant()) | SW.Shortname.ToLowerInvariant().Contains(name.ToLowerInvariant())) & !exactSearch) { lResult.Add(new GetSoftware() { ProductName = SW.ProductName, ProductVersion = SW.ProductVersion, Manufacturer = SW.Manufacturer, Shortname = SW.Shortname, Description = SW.Description, ProductURL = SW.ProductURL }); } } } catch { } } if (lResult.Count == 0) { request.Warning("No updates found..."); } } else { if (string.IsNullOrEmpty(requiredVersion)) { //Find by Shortname if (exactSearch) { lResult = RZRestAPI.SWGet(name).OrderBy(t => t.Shortname).ToList(); if (lResult.Count == 0) { //Find any lResult = RZRestAPI.SWResults(name).Where(t => t.ProductName == name).OrderBy(t => t.ProductName).ToList(); } } else { lResult = RZRestAPI.SWGet(name).OrderBy(t => t.Shortname).ToList(); if (lResult.Count == 0) { //Find any lResult = RZRestAPI.SWResults(name).OrderBy(t => t.Shortname).ToList(); } } } else { //Find by Shortname if (exactSearch) { lResult = RZRestAPI.SWGet(name, requiredVersion).OrderBy(t => t.Shortname).ToList(); } else { //Find any lResult = RZRestAPI.SWResults(name).Where(t => t.ProductVersion == requiredVersion).OrderBy(t => t.Shortname).ToList(); } } } if (minimumVersion != null) { try { lResult = lResult.Where(p => Version.Parse(p.ProductVersion) >= Version.Parse(minimumVersion)).ToList(); } catch { lResult = lResult.Where(p => p.ProductVersion == minimumVersion).ToList(); } } if (maximumVersion != null) { try { lResult = lResult.Where(p => Version.Parse(p.ProductVersion) <= Version.Parse(maximumVersion)).ToList(); } catch { lResult = lResult.Where(p => p.ProductVersion == maximumVersion).ToList(); } } foreach (var SW in lResult.OrderBy(t => t.Shortname)) { request.YieldSoftwareIdentity(SW.ProductName + ";" + SW.ProductVersion + ";" + SW.Manufacturer, SW.ProductName, SW.ProductVersion, "", SW.Description, Properties.Settings.Default.Location, name, SW.IconId.ToString(), SW.Shortname); //Trust the original RucKZuck source if (string.Equals(Properties.Settings.Default.Location, WebServiceURL, StringComparison.InvariantCultureIgnoreCase)) { request.AddMetadata("FromTrustedSource", "True"); } } } catch (Exception ex) { request.Debug("E334:" + ex.Message); dLastTokenRefresh = new DateTime(); } }
private void Button_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(tbDescription.Text)) { if (MessageBox.Show("Description is empty !", "Warning", MessageBoxButton.OKCancel, MessageBoxImage.Warning) != MessageBoxResult.OK) { return; } } if (tbPSInstall.Text.Contains("/?") || tbPSUnInstall.Text.Contains("/?")) { if (MessageBox.Show("Paremeter for silent In-Uninstall are missing or unknown ( \"/?\")", "Warning", MessageBoxButton.OKCancel, MessageBoxImage.Warning) != MessageBoxResult.OK) { return; } } if (((List <contentFiles>)dgSourceFiles.ItemsSource).Count(t => !string.IsNullOrEmpty(t.URL)) == 0) { if (MessageBox.Show("one File-URL is empty !", "Warning", MessageBoxButton.OKCancel, MessageBoxImage.Warning) != MessageBoxResult.OK) { return; } } AddSoftware oSoftware = new AddSoftware(); oSoftware.Architecture = tbArchitecture.Text; oSoftware.ContentID = tbContentId.Text; oSoftware.Description = tbDescription.Text; try { oSoftware.Files = ((List <contentFiles>)dgSourceFiles.ItemsSource).Where(t => !string.IsNullOrEmpty(t.URL)).ToList(); } catch { } try { List <contentFiles> lResult = new List <contentFiles>(); foreach (contentFiles oFile in dgSourceFiles.ItemsSource) { lResult.Add(new contentFiles() { FileHash = oFile.FileHash, FileName = oFile.FileName, HashType = oFile.HashType, URL = oFile.URL }); } oSoftware.Files = lResult; } catch { } oSoftware.Manufacturer = tbManufacturer.Text; oSoftware.MSIProductID = tbMSIId.Text; oSoftware.ProductName = tbProductName.Text; oSoftware.ProductVersion = tbVersion.Text; oSoftware.PSDetection = tbPSDetection.Text; oSoftware.PSInstall = tbPSInstall.Text; oSoftware.PSPreReq = tbPSPrereq.Text; oSoftware.PSUninstall = tbPSUnInstall.Text; oSoftware.ProductURL = tbProductURL.Text; oSoftware.Author = Properties.Settings.Default.UserKey; oSoftware.PSPreInstall = tbPSPreInstall.Text; oSoftware.PSPostInstall = tbPSPostInstall.Text; if (!string.IsNullOrEmpty(tbPreReq.Text)) { oSoftware.PreRequisites = tbPreReq.Text.Split(';'); } if (imgIcon.Tag != null) { oSoftware.Image = imgIcon.Tag as byte[]; } oSoftware.Category = tbCategories.Text.Trim(); oSoftware.ShortName = tbShortName.Text.Trim(); if (RZRestAPI.UploadSWEntry(oSoftware)) { btUpload.IsEnabled = false; } }
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, IconId = oSW.IconId, Manufacturer = oSW.Manufacturer, ProductName = oSW.ProductName, ProductURL = oSW.ProductURL, ProductVersion = oSW.ProductVersion, Quality = oSW.Quality, 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, IconId = oSW.IconId, Manufacturer = oSW.Manufacturer, ProductName = oSW.ProductName, ProductURL = oSW.ProductURL, ProductVersion = oSW.ProductVersion, Quality = oSW.Quality, 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, IconId = oSW.IconId, Manufacturer = oSW.Manufacturer, ProductName = oSW.ProductName, ProductURL = oSW.ProductURL, ProductVersion = oSW.ProductVersion, Quality = oSW.Quality, 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, IconId = oSW.IconId, Manufacturer = oSW.Manufacturer, ProductName = oSW.ProductName, ProductURL = oSW.ProductURL, ProductVersion = oSW.ProductVersion, Quality = oSW.Quality, ShortName = oSW.ShortName, IconHash = oSW.IconHash, 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); oInstPanel.lvSW.ItemsSource = lcv; oInstPanel.lSoftware = lSoftware; //var target = oSCAN.SoftwareRepository.Select(x => new GetSoftware() { Categories = x.Categories, Description = x.Description, Downloads = x.Downloads, IconId = x.IconId, Image = x.Image, Manufacturer = x.Manufacturer, ProductName = x.ProductName, ProductURL = x.ProductURL, ProductVersion = x.ProductVersion, Quality = x.Quality, ShortName = x.ShortName, isInstalled = false }).ToList(); 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; }