예제 #1
0
        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(), Properties.Settings.Default.CustomerID, oFeedBack.tbFeedback.Text).ConfigureAwait(false);;
                                }
                            };
                            Dispatcher.Invoke(update);
                        }
                        catch { }
                    });
                }
                catch { }
            }
        }
예제 #2
0
        private void btNew_Click(object sender, RoutedEventArgs e)
        {
            Mouse.OverrideCursor = Cursors.Wait;
            try
            {
                tSearch.Stop();
                var badSW = RZRestAPIv2.GetCatalog("--new--");
                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;
            }
        }
예제 #3
0
        private List <GetSoftware> GetRZSoftware(string ProdName, string ProdVersion, string Manufacturer)
        {
            List <GetSoftware> oResult = new List <GetSoftware>();

            oResult.AddRange(RZRestAPIv2.GetCatalog().Where(t => t.ProductName == ProdName && t.Manufacturer == Manufacturer && t.ProductVersion == ProdVersion));

            return(oResult);
        }
예제 #4
0
        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;
            }
        }
예제 #5
0
        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);
        }
예제 #6
0
 private void tbSearch_MouseDoubleClick(object sender, MouseButtonEventArgs e)
 {
     tSearch.Stop();
     lAllSoftware = RZRestAPIv2.GetCatalog().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;
                                          }
                                   });
 }
예제 #7
0
        private void MenuItem_Click_1(object sender, RoutedEventArgs e)
        {
            try
            {
                List <GetSoftware> oSW = RZRestAPIv2.GetCatalog().Where(t => t.ShortName == tbProductName.Text).ToList();
                //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 { }
        }
예제 #8
0
        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 RZRestAPIv2.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;
        }
예제 #9
0
        static void Main(string[] args)
        {
            tStart = DateTime.Now;
            RZRestAPIv2.CustomerID       = "swtesting";
            RZRestAPIv2.DisableBroadcast = true;
            RZRestAPIv2.GetURL(RZRestAPIv2.CustomerID);

#if !DEBUG
            RZScan oScan = new RZScan(false, false);
            oScan.SWScanAsync().Wait();
            if (oScan.InstalledSoftware.Count >= 5)
            {
                Console.WriteLine("Please run RZ.Bot.exe on a clean Machine !!!");
                Console.ReadLine();
                return;
            }
#endif
            bool bLoop = true;
            while (bLoop)
            {
                int iCount = ProcessBotQueue();
                //Console.WriteLine(iCount.ToString() + " processed");
                if (iCount == 0)
                {
                    Console.WriteLine("no failed installations in the queue.... Waiting 5min...");
#if !DEBUG
                    Thread.Sleep(300000); //sleep 5min
#endif
#if DEBUG
                    Thread.Sleep(60000); //sleep 60s
#endif
                }

                if (iCount > 0)
                {
                    Thread.Sleep(15000);
                }

                if (iCount < 0)
                {
                    bLoop = false;
                }
            }
            return;
        }
예제 #10
0
        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 = RZRestAPIv2.GetCatalog().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 = RZRestAPIv2.GetCatalog().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;
                }
            }
        }
예제 #11
0
        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();
                    var oDB = RZRestAPIv2.GetCatalog().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);
        }
예제 #12
0
        private void btOldFeedback_Click(object sender, RoutedEventArgs e)
        {
            Mouse.OverrideCursor = Cursors.Wait;
            try
            {
                var oldSW = RZRestAPIv2.GetCatalog("--old--"); //.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...
                oldSW.ForEach(x => { if (lSoftware.FirstOrDefault(t => (t.ProductName == x.ProductName && t.ProductVersion == x.ProductVersion)) != null)
                                     {
                                         x.isInstalled = true;
                                     }
                              });

                ListCollectionView lcv = new ListCollectionView(oldSW.ToList());

                lvSW.ItemsSource = lcv;
            }
            finally
            {
                Mouse.OverrideCursor = null;
            }
        }
예제 #13
0
        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();
                                        RZRestAPIv2.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();
        }
예제 #14
0
        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, FileSize = oFile.FileSize
                    });
                }
                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         = tbAuthor.Text;;
            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 (RZRestAPIv2.UploadSWEntry(oSoftware))
            {
                btUpload.IsEnabled = false;
            }
        }
예제 #15
0
        private static int ProcessBotQueue()
        {
            Console.WriteLine("Get failed installations from queue...");
            List <GetSoftware> lCat = RZRestAPIv2.GetCatalog();

            string sURL     = "https://ruckzuck.queue.core.windows.net/rzbot/messages";
            string sasToken = Properties.Settings.Default.SASToken;

            List <string> DLQueue  = new List <string>();
            List <string> BotQueue = new List <string>();
            Dictionary <string, string> IDQueue = new Dictionary <string, string>();
            int iMessageCount = 33;
            int iResult       = 0;
            int icount        = 0;

            //Get bulk of 32 Messages
            while (iMessageCount >= 32 && icount <= 20 && iResult <= 20)
            {
#if !DEBUG
                if ((DateTime.Now - tStart).TotalHours >= 2)
                {
                    Console.WriteLine("Max. runtime of 2h exceeded...");

                    return(-1);
                }
#endif

                using (HttpClient oClient = new HttpClient())
                {
                    string url  = $"{sURL}?numofmessages=32&{sasToken}";
                    var    oRes = oClient.GetStringAsync(url);
                    oRes.Wait();
                    string      sXML   = oRes.Result.ToString();
                    XmlDocument xmlDoc = new XmlDocument();
                    xmlDoc.LoadXml(sXML);
                    iMessageCount = xmlDoc.SelectNodes("QueueMessagesList/QueueMessage").Count;
                    icount++;
                    foreach (XmlNode xNode in xmlDoc.SelectNodes("QueueMessagesList/QueueMessage"))
                    {
                        iResult++;
                        //if (iResult > 10)
                        //    continue;
                        try
                        {
                            string sMessageID  = xNode["MessageId"].InnerText;
                            string Shortname   = xNode["MessageText"].InnerText;
                            string sPopReceipt = xNode["PopReceipt"].InnerText;

                            if (lDelete.Contains(Shortname.ToLower()))
                            {
                                IDQueue.Add(sMessageID, sPopReceipt);
                                continue;
                            }

                            if (lDone.Contains(Shortname.ToLower()))
                            {
                                continue;
                            }

                            try
                            {
                                try
                                {
                                    RZUpdater oRZSW = new RZUpdater();
                                    oRZSW.SoftwareUpdate = new SWUpdate(Shortname);

                                    oRZSW.SoftwareUpdate.SendFeedback = false; //we already process feedback...
                                    if (string.IsNullOrEmpty(oRZSW.SoftwareUpdate.SW.PSInstall))
                                    {
                                        oRZSW.SoftwareUpdate.GetInstallType();
                                    }

                                    if (string.IsNullOrEmpty(oRZSW.SoftwareUpdate.SW.ProductName))
                                    {
                                        Console.ForegroundColor = ConsoleColor.Red;
                                        Console.WriteLine("Error: Product not valid... " + Shortname);
                                        Console.ResetColor();
                                        continue;
                                    }
                                    else
                                    {
                                        Console.ForegroundColor = ConsoleColor.Blue;
                                        Console.WriteLine(oRZSW.SoftwareUpdate.SW.Manufacturer + " " + oRZSW.SoftwareUpdate.SW.ProductName + " " + oRZSW.SoftwareUpdate.SW.ProductVersion);
                                        Console.ResetColor();

                                        Console.Write("Downloading...");
                                        foreach (string sPreReq in oRZSW.SoftwareUpdate.SW.PreRequisites)
                                        {
                                            RZUpdater oRZSWPreReq = new RZUpdater();
                                            oRZSWPreReq.SoftwareUpdate = new SWUpdate(sPreReq);
                                            oRZSWPreReq.SoftwareUpdate.SendFeedback = false;
                                            Console.WriteLine();
                                            Console.Write("\tDownloading dependencies (" + oRZSWPreReq.SoftwareUpdate.SW.ShortName + ")...");
                                            if (oRZSWPreReq.SoftwareUpdate.Download().Result)
                                            {
                                                Console.ForegroundColor = ConsoleColor.Green;
                                                Console.WriteLine("... done.");
                                                Console.ResetColor();
                                                Console.Write("\tInstalling dependencies (" + oRZSWPreReq.SoftwareUpdate.SW.ShortName + ")...");
                                                if (oRZSWPreReq.SoftwareUpdate.Install(false, true).Result)
                                                {
                                                    Console.ForegroundColor = ConsoleColor.Green;
                                                    Console.WriteLine("... done.");
                                                    Console.ResetColor();
                                                    //lPackages.Add(oRZSWPreReq.SoftwareUpdate.SW.ShortName);
                                                }
                                                else
                                                {
                                                    Console.ForegroundColor = ConsoleColor.Red;
                                                    Console.WriteLine("... Error. The installation failed.");
                                                    Console.ResetColor();
                                                    continue;
                                                }
                                            }
                                        }
                                        if (oRZSW.SoftwareUpdate.Download().Result)
                                        {
                                            Console.ForegroundColor = ConsoleColor.Green;
                                            Console.WriteLine("... done.");
                                            Console.ResetColor();

                                            Console.Write("Installing...");
                                            if (oRZSW.SoftwareUpdate.Install(false, true).Result)
                                            {
                                                Console.ForegroundColor = ConsoleColor.Green;
                                                Console.WriteLine("... done.");
                                                DeleteFromQueueAsync(sURL, sasToken, sMessageID, sPopReceipt).Wait(2000);
                                                lDone.Add(Shortname.ToLower());
                                                lDelete.Add(Shortname.ToLower());
                                                Console.ResetColor();
                                            }
                                            else
                                            {
                                                Console.ForegroundColor = ConsoleColor.Red;
                                                Console.WriteLine("... Error. Installation failed.");
                                                Console.ResetColor();
                                                lDone.Add(Shortname.ToLower());
                                                continue;
                                            }
                                        }
                                        else
                                        {
                                            Console.ForegroundColor = ConsoleColor.Red;
                                            Console.WriteLine("... Error. Download failed.");
                                            Console.ResetColor();
                                            lDone.Add(Shortname.ToLower());
                                            continue;
                                        }
                                    }
                                }
                                catch (Exception ex)
                                {
                                    Console.ForegroundColor = ConsoleColor.Red;
                                    Console.WriteLine("ERROR(1): " + ex.Message);
                                    Console.ResetColor();
                                    lDone.Add(Shortname.ToLower());
                                    continue;
                                }

                                Console.ResetColor();

                                //lDone.Add(Shortname.ToLower());
                                //IDQueue.Add(sMessageID, sPopReceipt);
                            }
                            catch { }
                        }
                        catch (Exception ex)
                        {
                            Console.ForegroundColor = ConsoleColor.Red;
                            Console.WriteLine("ERROR(2): " + ex.Message);
                            Console.ResetColor();
                        }
                    }
                }
            }

            foreach (var sID in IDQueue)
            {
                DeleteFromQueueAsync(sURL, sasToken, sID.Key, sID.Value).Wait(2000);
            }

            return(iResult);
        }
예제 #16
0
        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> lCatalog = RZRestAPIv2.GetCatalog();

                //List<GetSoftware> lServer = RZRestAPI.SWResults(name).OrderBy(t => t.Shortname).ToList();

                List <AddSoftware> lLocal = lResult.Where(t => lCatalog.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();
                request.Debug("Items Found: " + lLocal.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 = lCatalog.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)
                {
                    var oCAT = lCatalog.FirstOrDefault(t => t.ProductName == SW.ProductName && t.ProductVersion == SW.ProductVersion && t.Manufacturer == SW.Manufacturer);
                    if (oCAT != null)
                    {
                        request.YieldSoftwareIdentity(SW.ProductName + ";" + SW.ProductVersion, SW.ProductName, SW.ProductVersion, "", oCAT.Description, RZRestAPIv2.sURL, (name ?? ""), oCAT.SWId.ToString(), oCAT.ShortName);
                    }
                    else
                    {
                        request.YieldSoftwareIdentity(SW.ProductName + ";" + SW.ProductVersion, SW.ProductName, SW.ProductVersion, "", "", RZRestAPIv2.sURL, (name ?? ""), "", SW.ShortName);
                    }
                    request.AddMetadata("FromTrustedSource", "True");
                }
            }
            catch
            {
                //dLastTokenRefresh = new DateTime();
            }
        }
예제 #17
0
        /// <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 _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.GetSWRepository().Wait(6000);
                    oScan.bCheckUpdates = 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)
                        {
                            if (!string.IsNullOrEmpty(name))
                            {
                                lResult = RZRestAPIv2.GetCatalog().Where(t => t.ShortName.ToLower() == name.ToLower()).OrderBy(t => t.ShortName).ToList();
                            }

                            if (lResult.Count == 0)
                            {
                                //Find any
                                lResult = RZRestAPIv2.GetCatalog().Where(t => t.ProductName.ToLower() == name.ToLower()).OrderBy(t => t.ProductName).ToList();
                            }
                        }
                        else
                        {
                            if (!string.IsNullOrEmpty(name))
                            {
                                lResult = RZRestAPIv2.GetCatalog().Where(t => t.ShortName.ToLower().Contains(name.ToLower())).OrderBy(t => t.ShortName).ToList();
                            }

                            if (lResult.Count == 0)
                            {
                                //Find any
                                lResult = RZRestAPIv2.GetCatalog().Where(t => t.ProductName.ToLower().Contains(name.ToLower())).OrderBy(t => t.ShortName).ToList();
                            }
                            if (lResult.Count == 0)
                            {
                                //Find any
                                lResult = RZRestAPIv2.GetCatalog().Where(t => t.Manufacturer.ToLower().Contains(name.ToLower())).OrderBy(t => t.ShortName).ToList();
                            }
                        }
                    }
                    else
                    {
                        //Find by Shortname
                        if (exactSearch)
                        {
                            lResult = RZRestAPIv2.GetCatalog().Where(t => t.ShortName.ToLower() == name.ToLower() && t.ProductVersion.ToLower() == requiredVersion.ToLower()).OrderBy(t => t.ShortName).ToList();
                        }
                        else
                        {
                            //Find any
                            lResult = RZRestAPIv2.GetCatalog().Where(t => t.ShortName.ToLower().Contains(name.ToLower()) && t.ProductVersion.ToLower() == requiredVersion.ToLower()).OrderBy(t => t.ShortName).ToList();

                            if (lResult.Count == 0)
                            {
                                lResult = RZRestAPIv2.GetCatalog().Where(t => t.ProductName.ToLower().Contains(name.ToLower()) && t.ProductVersion.ToLower() == requiredVersion.ToLower()).OrderBy(t => t.ShortName).ToList();
                            }

                            if (lResult.Count == 0)
                            {
                                lResult = RZRestAPIv2.GetCatalog().Where(t => t.Manufacturer.ToLower().Contains(name.ToLower()) && t.ProductVersion.ToLower() == requiredVersion.ToLower()).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.SWId.ToString(), SW.ShortName);
                    //Trust the original RucKZuck source
                    if (string.Equals(Properties.Settings.Default.Location, RZRestAPIv2.sURL, StringComparison.InvariantCultureIgnoreCase))
                    {
                        request.AddMetadata("FromTrustedSource", "True");
                    }
                }
            }
            catch (Exception ex)
            {
                request.Debug("E334:" + ex.Message);
            }
        }
예제 #18
0
        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;
        }
예제 #19
0
        static int Main(string[] args)
        {
            bool bError = false;

            //Get Proxy from IE
            WebRequest.DefaultWebProxy = WebRequest.GetSystemWebProxy();

            if (!string.IsNullOrEmpty(Properties.Settings.Default.Customerid))
            {
                RZRestAPIv2.CustomerID = Properties.Settings.Default.Customerid;
            }

            RZRestAPIv2.DisableBroadcast = Properties.Settings.Default.DisableBroadcast;

            List <string> lArgs = args.ToList();

            if (lArgs.Contains("-?") | lArgs.Contains("/?") | lArgs.Count < 1)
            {
                Console.WriteLine("RuckZuck CommandLine Tool (c) 2020 by Roger Zander");
                Console.WriteLine("Install:");
                Console.WriteLine("Install a Software from Shortname : RZGet.exe install \"<Shortname>\"[;\"<Shortname2>\"]");
                Console.WriteLine("Install a Software from JSON File : RZGet.exe install \"<JSON full path>\"[;\"<JSON full path>\"]");
                Console.WriteLine("Install a Sepcific Version : RZGet.exe install --name \"<ProductName>\" --vendor \"<Manufacturer>\" --version \"<ProductVersion>\"");
                Console.WriteLine("");
                Console.WriteLine("Update:");
                Console.WriteLine("Update all missing updates : RZGet.exe update --all");
                Console.WriteLine("Show all missing updates : RZGet.exe update --list --all");
                Console.WriteLine("check if a Software requires an update : RZGet.exe update --list \"<Shortname>\"");
                Console.WriteLine("Update a Software from Shortname : RZGet.exe update \"<Shortname>\"[;\"<Shortname2>\"]");
                Console.WriteLine("");
                Console.WriteLine("Show:");
                Console.WriteLine("Show Metadata : RZGet.exe show \"<Shortname>\"");
                Console.WriteLine("Show Metadata for a specific Version : RZGet.exe show --name \"<ProductName>\" --vendor \"<Manufacturer>\" --version \"<ProductVersion>\"");
                Console.WriteLine("");
                Console.WriteLine("Search:");
                Console.WriteLine("Show full Catalog JSON: RZGet.exe search");
                Console.WriteLine("Search for a Keyword: RZGet.exe search zip");
                Console.WriteLine("Search SW in a Category: RZGet.exe search --categories compression");
                Console.WriteLine("Search for installed SW: RZGet.exe search --isinstalled true");
                Console.WriteLine("Search for a manufacturer: RZGet.exe search --manufacturer zander");
                Console.WriteLine("Search for a shortname and return PowerShell Object: RZGet.exe search --shortname ruckzuck | convertfrom-json");
                return(0);
            }

            if (lArgs[0].ToLower() == "install")
            {
                if (lArgs.Contains("--name", StringComparer.CurrentCultureIgnoreCase) || lArgs.Contains("--vendor", StringComparer.CurrentCultureIgnoreCase) || lArgs.Contains("--version", StringComparer.CurrentCultureIgnoreCase))
                {
                    try
                    {
                        RZUpdater oRZSW        = new RZUpdater();
                        string    ProductName  = lArgs[lArgs.FindIndex(t => t.IndexOf("--name", StringComparison.CurrentCultureIgnoreCase) >= 0) + 1];
                        string    Manufacturer = lArgs[lArgs.FindIndex(t => t.IndexOf("--vendor", StringComparison.CurrentCultureIgnoreCase) >= 0) + 1];

                        if (string.IsNullOrEmpty(Manufacturer))
                        {
                            Manufacturer = lArgs[lArgs.FindIndex(t => t.IndexOf("--manufacturer", StringComparison.CurrentCultureIgnoreCase) >= 0) + 1];
                        }

                        string ProductVersion = lArgs[lArgs.FindIndex(t => t.IndexOf("--version", StringComparison.CurrentCultureIgnoreCase) >= 0) + 1];
                        oRZSW.SoftwareUpdate = new SWUpdate(ProductName, ProductVersion, Manufacturer);

                        if (string.IsNullOrEmpty(oRZSW.SoftwareUpdate.SW.ProductName))
                        {
                            Console.WriteLine("'" + ProductName + "' is NOT available in RuckZuck...!");
                            return(99);
                        }

                        if (string.IsNullOrEmpty(oRZSW.SoftwareUpdate.SW.PSInstall))
                        {
                            oRZSW.SoftwareUpdate.GetInstallType();
                            if (string.IsNullOrEmpty(oRZSW.SoftwareUpdate.SW.PSInstall))
                            {
                                Console.WriteLine("PreRequisites not valid for '" + oRZSW.SoftwareUpdate.SW.ShortName + "'...!");
                                return(91);
                            }
                        }

                        if (Install(oRZSW))
                        {
                            return(0);
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Error: " + ex.Message);
                        return(1);
                    }
                }

                foreach (string sArg in args.Skip(1))
                {
                    if (File.Exists(sArg))
                    {
                        RZUpdater oRZSW = new RZUpdater(sArg);

                        if (string.IsNullOrEmpty(oRZSW.SoftwareUpdate.SW.ProductName))
                        {
                            Console.WriteLine("'" + sArg + "' is NOT available in RuckZuck...!");
                            bError = true;
                            continue;
                        }

                        if (string.IsNullOrEmpty(oRZSW.SoftwareUpdate.SW.PSInstall))
                        {
                            oRZSW.SoftwareUpdate.GetInstallType();
                            if (string.IsNullOrEmpty(oRZSW.SoftwareUpdate.SW.PSInstall))
                            {
                                Console.WriteLine("PreRequisites not valid for '" + sArg + "'...!");
                                bError = false;
                                continue;
                            }
                        }

                        if (Install(oRZSW))
                        {
                            continue;
                        }
                    }
                    else
                    {
                        try
                        {
                            RZUpdater oRZSW = new RZUpdater();
                            oRZSW.SoftwareUpdate = new SWUpdate(sArg.Trim('"').Trim());

                            if (string.IsNullOrEmpty(oRZSW.SoftwareUpdate.SW.ProductName))
                            {
                                Console.WriteLine("'" + sArg + "' is NOT available in RuckZuck...!");
                                bError = true;
                                continue;
                            }

                            if (string.IsNullOrEmpty(oRZSW.SoftwareUpdate.SW.PSInstall))
                            {
                                oRZSW.SoftwareUpdate.GetInstallType();
                                if (string.IsNullOrEmpty(oRZSW.SoftwareUpdate.SW.PSInstall))
                                {
                                    Console.WriteLine("PreRequisites not valid for '" + sArg + "'...!");
                                    bError = false;
                                    continue;
                                }
                            }

                            if (Install(oRZSW))
                            {
                                continue;
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("Error: " + ex.Message);
                            bError = true;
                        }
                    }
                }

                if (bError)
                {
                    return(1);
                }
                else
                {
                    return(0);
                }
            }

            if (lArgs[0].ToLower() == "update")
            {
                bool bUpdateAll = false;
                bool bList      = false;

                if (lArgs.Contains("--all", StringComparer.CurrentCultureIgnoreCase))
                {
                    bUpdateAll = true;
                }
                if (lArgs.Contains("--list", StringComparer.CurrentCultureIgnoreCase))
                {
                    bList = true;
                }

                RZScan oScan = new RZScan(false);
                oScan.GetSWRepository().Wait(10000);
                oScan.SWScanAsync().Wait(10000);
                oScan._CheckUpdates(null);

                List <string> lUpdate = new List <string>();
                if (!bUpdateAll)
                {
                    foreach (string sArg in args.Skip(1))
                    {
                        if (oScan.NewSoftwareVersions.Count(t => t.ShortName.ToLower() == sArg.ToLower()) > 0)
                        {
                            lUpdate.Add(sArg);
                        }
                    }
                }
                else
                {
                    lUpdate = oScan.NewSoftwareVersions.Select(t => t.ShortName).ToList();
                }

                foreach (string sArg in lUpdate)
                {
                    if (bList)
                    {
                        Console.WriteLine(sArg);
                        continue;
                    }
                    if (File.Exists(sArg))
                    {
                        RZUpdater oRZSW = new RZUpdater(sArg);

                        if (string.IsNullOrEmpty(oRZSW.SoftwareUpdate.SW.ProductName))
                        {
                            Console.WriteLine("'" + sArg + "' is NOT available in RuckZuck...!");
                            bError = true;
                            continue;
                        }

                        if (string.IsNullOrEmpty(oRZSW.SoftwareUpdate.SW.PSInstall))
                        {
                            oRZSW.SoftwareUpdate.GetInstallType();
                            if (string.IsNullOrEmpty(oRZSW.SoftwareUpdate.SW.PSInstall))
                            {
                                Console.WriteLine("PreRequisites not valid for '" + sArg + "'...!");
                                bError = false;
                                continue;
                            }
                        }

                        if (Install(oRZSW))
                        {
                            continue;
                        }
                    }
                    else
                    {
                        try
                        {
                            RZUpdater oRZSW = new RZUpdater();
                            oRZSW.SoftwareUpdate = new SWUpdate(sArg.Trim('"').Trim());

                            if (string.IsNullOrEmpty(oRZSW.SoftwareUpdate.SW.ProductName))
                            {
                                Console.WriteLine("'" + sArg + "' is NOT available in RuckZuck...!");
                                bError = true;
                                continue;
                            }

                            if (string.IsNullOrEmpty(oRZSW.SoftwareUpdate.SW.PSInstall))
                            {
                                oRZSW.SoftwareUpdate.GetInstallType();
                                if (string.IsNullOrEmpty(oRZSW.SoftwareUpdate.SW.PSInstall))
                                {
                                    Console.WriteLine("PreRequisites not valid for '" + sArg + "'...!");
                                    bError = false;
                                    continue;
                                }
                            }

                            if (Install(oRZSW))
                            {
                                continue;
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("Error: " + ex.Message);
                            bError = true;
                        }
                    }
                }

                if (bError)
                {
                    return(1);
                }
                else
                {
                    return(0);
                }
            }

            //if (lArgs[0].ToLower() == "hash")
            //{
            //    Console.WriteLine("hash");
            //    Console.WriteLine(string.Join(";", args.Skip(1)));
            //    return 0;
            //}

            if (lArgs[0].ToLower() == "search")
            {
                if (lArgs[1] != null)
                {
                    if (lArgs[1].StartsWith("--"))
                    {
                        string sProp   = lArgs[1].ToLower().TrimStart('-');
                        string sSearch = lArgs[2].ToLower();

                        if (sProp == "shortname")
                        {
                            Console.WriteLine(JsonConvert.SerializeObject(RZRestAPIv2.GetCatalog().Where(t => t.ShortName.ToLower().Contains(sSearch)), Formatting.Indented).ToString());
                        }

                        if (sProp == "manufacturer")
                        {
                            Console.WriteLine(JsonConvert.SerializeObject(RZRestAPIv2.GetCatalog().Where(t => t.Manufacturer.ToLower().Contains(sSearch)), Formatting.Indented).ToString());
                        }

                        if (sProp == "productname" || sProp == "name")
                        {
                            Console.WriteLine(JsonConvert.SerializeObject(RZRestAPIv2.GetCatalog().Where(t => t.ProductName.ToLower().Contains(sSearch)), Formatting.Indented).ToString());
                        }

                        if (sProp == "description")
                        {
                            Console.WriteLine(JsonConvert.SerializeObject(RZRestAPIv2.GetCatalog().Where(t => t.Description.ToLower().Contains(sSearch)), Formatting.Indented).ToString());
                        }

                        if (sProp == "categories" || sProp == "category")
                        {
                            Console.WriteLine(JsonConvert.SerializeObject(RZRestAPIv2.GetCatalog().Where(t => string.Join(";", t.Categories.ToArray()).ToLower().Contains(sSearch)), Formatting.Indented).ToString());
                        }

                        if (sProp == "producturl" || sProp == "url")
                        {
                            Console.WriteLine(JsonConvert.SerializeObject(RZRestAPIv2.GetCatalog().Where(t => t.ProductURL.ToLower().Contains(sSearch)), Formatting.Indented).ToString());
                        }

                        if (sProp == "productversion" || sProp == "version")
                        {
                            Console.WriteLine(JsonConvert.SerializeObject(RZRestAPIv2.GetCatalog().Where(t => t.ProductVersion.ToLower().Contains(sSearch)), Formatting.Indented).ToString());
                        }

                        if (sProp == "isinstalled")
                        {
                            oScan = new RZScan(false, false);
                            oScan.SWScanAsync().Wait();
                            oScan.GetSWRepository().Wait();
                            foreach (var osw in oScan.InstalledSoftware)
                            {
                                var oItem = oScan.SoftwareRepository.FirstOrDefault(t => t.ProductName == osw.ProductName && t.Manufacturer == osw.Manufacturer && t.ProductVersion == osw.ProductVersion);
                                if (oItem != null)
                                {
                                    oItem.isInstalled = true;
                                }
                            }

                            Console.WriteLine(JsonConvert.SerializeObject(oScan.SoftwareRepository.Where(t => t.isInstalled.ToString().ToLower().Contains(sSearch)), Formatting.Indented).ToString());
                        }
                    }
                    else
                    {
                        string sSearch = lArgs[1].ToLower();
                        Console.WriteLine(JsonConvert.SerializeObject(RZRestAPIv2.GetCatalog().Where(t => t.ProductName.ToLower().Contains(sSearch) || t.Manufacturer.ToLower().Contains(sSearch) || t.ShortName.ToLower().Contains(sSearch)), Formatting.Indented).ToString());
                    }
                }
                else
                {
                    Console.WriteLine(JsonConvert.SerializeObject(RZRestAPIv2.GetCatalog(), Formatting.Indented).ToString());
                }
                return(0);
            }

            if (lArgs[0].ToLower() == "show")
            {
                if (lArgs.Contains("--name", StringComparer.CurrentCultureIgnoreCase) || lArgs.Contains("--vendor", StringComparer.CurrentCultureIgnoreCase) || lArgs.Contains("--version", StringComparer.CurrentCultureIgnoreCase))
                {
                    try
                    {
                        RZUpdater oRZSW        = new RZUpdater();
                        string    ProductName  = lArgs[lArgs.FindIndex(t => t.IndexOf("--name", StringComparison.CurrentCultureIgnoreCase) >= 0) + 1];
                        string    Manufacturer = lArgs[lArgs.FindIndex(t => t.IndexOf("--vendor", StringComparison.CurrentCultureIgnoreCase) >= 0) + 1];

                        if (string.IsNullOrEmpty(Manufacturer))
                        {
                            Manufacturer = lArgs[lArgs.FindIndex(t => t.IndexOf("--manufacturer", StringComparison.CurrentCultureIgnoreCase) >= 0) + 1];
                        }

                        string ProductVersion = lArgs[lArgs.FindIndex(t => t.IndexOf("--version", StringComparison.CurrentCultureIgnoreCase) >= 0) + 1];
                        oRZSW.SoftwareUpdate = new SWUpdate(ProductName, ProductVersion, Manufacturer);

                        if (string.IsNullOrEmpty(oRZSW.SoftwareUpdate.SW.ProductName))
                        {
                            Console.WriteLine("'" + ProductName + "' is NOT available in RuckZuck...!");
                            return(99);
                        }

                        Console.WriteLine(JsonConvert.SerializeObject(oRZSW.SoftwareUpdate.SW, Formatting.Indented).ToString());

                        return(0);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Error: " + ex.Message);
                        return(1);
                    }
                }

                foreach (string sArg in args.Skip(1))
                {
                    if (File.Exists(sArg))
                    {
                        RZUpdater oRZSW = new RZUpdater(sArg);

                        Console.WriteLine(JsonConvert.SerializeObject(oRZSW.SoftwareUpdate.SW, Formatting.Indented).ToString());
                    }
                    else
                    {
                        try
                        {
                            RZUpdater oRZSW = new RZUpdater();
                            oRZSW.SoftwareUpdate = new SWUpdate(sArg.Trim('"').Trim());

                            if (string.IsNullOrEmpty(oRZSW.SoftwareUpdate.SW.ProductName))
                            {
                                Console.WriteLine("'" + sArg + "' is NOT available in RuckZuck...!");
                                bError = true;
                                continue;
                            }

                            Console.WriteLine(JsonConvert.SerializeObject(oRZSW.SoftwareUpdate.SW, Formatting.Indented).ToString());

                            return(0);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("Error: " + ex.Message);
                            return(1);
                        }
                    }
                }

                return(0);
            }

            //if (lArgs[0].ToLower() == "source")
            //{
            //    Console.WriteLine("source");
            //    Console.WriteLine(string.Join(";", args.Skip(1)));
            //    return 0;
            //}

            //if (lArgs[0].ToLower() == "validate")
            //{
            //    Console.WriteLine("validate");
            //    Console.WriteLine(string.Join(";", args.Skip(1)));
            //    return 0;
            //}

            //if (lArgs.Count == 1)
            //{
            //    if (File.Exists(lArgs[0]))
            //    {
            //        RZUpdater oRZSW = new RZUpdater(lArgs[0]);

            //        Console.WriteLine(oRZSW.SoftwareUpdate.SW.ProductName + " " + oRZSW.SoftwareUpdate.SW.ProductVersion + " :");
            //        Console.Write("Downloading...");
            //        if (oRZSW.SoftwareUpdate.Download().Result)
            //        {
            //            Console.WriteLine("... done.");
            //            Console.Write("Installing...");
            //            if (oRZSW.SoftwareUpdate.Install(false,true).Result)
            //            {
            //                Console.WriteLine("... done.");
            //            }
            //            else
            //            {
            //                Console.WriteLine("... Error. The installation failed.");
            //            }
            //        }
            //    }
            //    else
            //    {
            //        if (lArgs[0].ToLower() == "/update" | lArgs[0].ToLower() == "-update")
            //        {
            //            oUpdate = new RZUpdater();
            //            oScan = new RZScan(true, true);
            //            Console.Write("Detecting updates...");
            //            oScan.OnUpdScanCompleted += OScan_OnUpdScanCompleted;

            //            while (bRunning)
            //            {
            //                System.Threading.Thread.Sleep(100);
            //            }
            //        }
            //        else
            //        {
            //            foreach (string sArg in lArgs[0].Split(';'))
            //            {
            //                try
            //                {
            //                    RZUpdater oRZSW = new RZUpdater();
            //                    oRZSW.SoftwareUpdate = new SWUpdate(sArg.Trim('"').Trim());

            //                    if (string.IsNullOrEmpty(oRZSW.SoftwareUpdate.SW.ProductName))
            //                    {
            //                        Console.WriteLine("'" + sArg + "' is NOT available in RuckZuck...!");
            //                        bError = true;
            //                        continue;
            //                    }
            //                    Console.WriteLine("PS:" + oRZSW.SoftwareUpdate.SW.PSInstall);
            //                    if (string.IsNullOrEmpty(oRZSW.SoftwareUpdate.SW.PSInstall))
            //                    {
            //                        oRZSW.SoftwareUpdate.GetInstallType();
            //                        if (string.IsNullOrEmpty(oRZSW.SoftwareUpdate.SW.PSInstall))
            //                        {
            //                            Console.WriteLine("PreRequisites not valid for '" + sArg + "'...!");
            //                            bError = false;
            //                            continue;
            //                        }
            //                    }


            //                    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)
            //                    {
            //                        if (!string.IsNullOrEmpty(sPreReq))
            //                        {
            //                            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.");
            //                                    bError = true;
            //                                }
            //                            }
            //                        }

            //                    }
            //                    if (oRZSW.SoftwareUpdate.Download().Result)
            //                    {
            //                        Console.WriteLine("... done.");
            //                        Console.Write("Installing...");
            //                        if (oRZSW.SoftwareUpdate.Install(false, true).Result)
            //                        {
            //                            Console.WriteLine("... done.");
            //                        }
            //                        else
            //                        {
            //                            Console.WriteLine("... Error. The installation failed.");
            //                            bError = true;
            //                        }
            //                    }
            //                }
            //                catch (Exception ex)
            //                {
            //                    Console.WriteLine("Error: " + ex.Message);
            //                    bError = true;
            //                }
            //            }


            //        }
            //    }
            //}

            //if (lArgs.Count == 3)
            //{
            //    RZUpdater oRZUpdate = new RZUpdater();
            //    oRZUpdate.SoftwareUpdate = new SWUpdate(lArgs[0], lArgs[1], lArgs[2]);
            //    if (oRZUpdate.SoftwareUpdate != null)
            //    {
            //        Console.WriteLine("New Version: " + oRZUpdate.SoftwareUpdate.SW.ProductVersion);
            //        Console.Write("Downloading...");

            //        if (oRZUpdate.SoftwareUpdate.Download().Result)
            //        {
            //            Console.WriteLine("... done.");
            //            Console.Write("Installing...");
            //            if (oRZUpdate.SoftwareUpdate.Install(false, true).Result)
            //            {
            //                Console.WriteLine("... done.");
            //                return 0;
            //            }
            //            else
            //            {
            //                Console.WriteLine("... Error. The update installation failed.");
            //                return 1;
            //            }
            //        }

            //        return 99;
            //    }
            //    else
            //    {
            //        Console.WriteLine("No Update found...");
            //        return 0;
            //    }
            //}

            //System.Threading.Thread.Sleep(500);
            //if(bError)
            //    return 2;

            return(0);
        }
예제 #20
0
파일: Program.cs 프로젝트: stijni/ruckzuck
        static void Main(string[] args)
        {
            MessagingFactory messageFactory;
            NamespaceManager namespaceManager;

            //TopicClient myTopicClient;
            //lPackages.Add("AdobeReader DC MUI");
            tStart = DateTime.Now;
            RZRestAPIv2.CustomerID       = "swtesting";
            RZRestAPIv2.DisableBroadcast = true;
            RZRestAPIv2.GetURL(RZRestAPIv2.CustomerID);

#if !DEBUG
            RZScan oScan = new RZScan(false, false);
            oScan.SWScan().Wait();
            if (oScan.InstalledSoftware.Count >= 2)
            {
                Console.WriteLine("Please run RZ.Bot.exe on a clean Machine !!!");
                Console.ReadLine();
                return;
            }
#endif
            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 ((DateTime.Now - tStart).TotalHours >= 6)
                    {
                        Console.WriteLine("Max. runtime of 6h exceeded...");
                        return;
                    }
                    try
                    {
                        if (lPackages.IndexOf(message.Properties["ProductName"].ToString() + message.Properties["ProductVersion"].ToString() + message.Properties["Manufacturer"].ToString()) >= 0)
                        {
                            message.Complete();
                            return;
                        }
                        List <GetSoftware> lCat = RZRestAPIv2.GetCatalog();

                        RZUpdater oRZSW = new RZUpdater();

                        var CatItem = lCat.Find(t => t.ProductName.ToLower() == message.Properties["ProductName"].ToString().ToLower() && t.ProductVersion.ToLower() == message.Properties["ProductVersion"].ToString().ToLower() && t.Manufacturer.ToLower() == message.Properties["Manufacturer"].ToString().ToLower());

                        if (CatItem != null)
                        {
                            oRZSW.SoftwareUpdate = new SWUpdate(CatItem.ShortName);
                            if (oRZSW.SoftwareUpdate.SW.ShortName == null)
                            {
                                oRZSW.SoftwareUpdate = new SWUpdate(message.Properties["ProductName"].ToString(), message.Properties["ProductVersion"].ToString(), message.Properties["Manufacturer"].ToString());
                            }
                        }
                        else
                        {
                            oRZSW.SoftwareUpdate = new SWUpdate(message.Properties["ProductName"].ToString(), message.Properties["ProductVersion"].ToString(), message.Properties["Manufacturer"].ToString());
                            oRZSW.SoftwareUpdate = new SWUpdate(oRZSW.SoftwareUpdate.SW.ShortName);
                        }

                        if (lPackages.IndexOf(oRZSW.SoftwareUpdate.SW.ShortName) >= 0) //check if there was a previous success
                        {
                            message.Complete();
                            return;
                        }

                        //if(message.Properties["ProductVersion"].ToString() != oRZSW.SoftwareUpdate.SW.ProductVersion)
                        //{
                        //    oRZSW.SoftwareUpdate = new SWUpdate(oRZSW.SoftwareUpdate.SW.ShortName);
                        //}

                        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.PSInstall))
                            {
                                oRZSW.SoftwareUpdate.GetInstallType();

                                //Console.WriteLine("PreRequisites not valid ...!");
                                //message.Abandon();
                                //return;
                            }

                            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);
                                    oRZSWPreReq.SoftwareUpdate.SendFeedback = false;
                                    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.");
                                            lPackages.Add(oRZSWPreReq.SoftwareUpdate.SW.ShortName);
                                        }
                                        else
                                        {
                                            Console.WriteLine("... Error. The installation failed.");
                                            message.Abandon();
                                        }
                                    }
                                }
                                if (oRZSW.SoftwareUpdate.Download().Result)
                                {
                                    Console.WriteLine("... done.");

                                    Console.Write("Installing...");
                                    if (oRZSW.SoftwareUpdate.Install(false, true).Result)
                                    {
                                        Console.WriteLine("... done.");
                                        message.Complete();
                                        //RZRestAPIv2.Feedback(oRZSW.SoftwareUpdate.SW.ProductName, oRZSW.SoftwareUpdate.SW.ProductVersion, oRZSW.SoftwareUpdate.SW.Manufacturer, "true", "RZBot", "ok..").Wait(3000);
                                        sLastPackage = oRZSW.SoftwareUpdate.SW.ShortName;
                                        lPackages.Add(oRZSW.SoftwareUpdate.SW.ShortName);
                                        lPackages.Add(message.Properties["ProductName"].ToString() + message.Properties["ProductVersion"].ToString() + message.Properties["Manufacturer"].ToString());
                                        //return 0;
                                    }
                                    else
                                    {
                                        Console.WriteLine("... Error. Installation failed.");
                                        sLastPackage = oRZSW.SoftwareUpdate.SW.ShortName;
                                        message.DeadLetter();
                                        //return 1603;
                                    }
                                }
                                else
                                {
                                    Console.WriteLine("... Error. Download failed.");
                                    sLastPackage = oRZSW.SoftwareUpdate.SW.ShortName;
                                    message.DeadLetter();
                                    //return 1602;
                                }
                            }
                        }
                        else
                        {
                            //Console.WriteLine("... retry later..");
                            sLastPackage = oRZSW.SoftwareUpdate.SW.ShortName;

                            Thread.Sleep(1000);
                            //message.Abandon(); // retry later....
                            message.DeadLetter();
                            return;
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("ERROR: " + ex.Message);
                        message.Abandon();
                    }

                    Console.ResetColor();
                }
                catch { }
            });

            Console.ReadLine();
        }
예제 #21
0
        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 RZRestAPIv2.GetSoftwares(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)
                                            {
                                                RZRestAPIv2.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;
            }
        }
예제 #22
0
        //public event ChangedEventHandler onEdit;

        public InstallSwPanel()
        {
            InitializeComponent();
            tSearch.Elapsed  += TSearch_Elapsed;
            tSearch.Enabled   = false;
            tSearch.AutoReset = false;

            Mouse.OverrideCursor = Cursors.Wait;
            try
            {
                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, IconHash = oSW.IconHash, SWId = oSW.SWId, Manufacturer = oSW.Manufacturer, ProductName = oSW.ProductName, ProductURL = oSW.ProductURL, ProductVersion = oSW.ProductVersion, ShortName = oSW.ShortName, isInstalled = true
                                        };
                                        oDBCat.Add(oNew);
                                    }
                                    else
                                    {
                                        GetSoftware oNew = new GetSoftware()
                                        {
                                            Categories = new List <string> {
                                                sCAT
                                            }, Description = oSW.Description, Downloads = oSW.Downloads, IconHash = oSW.IconHash, SWId = oSW.SWId, Manufacturer = oSW.Manufacturer, ProductName = oSW.ProductName, ProductURL = oSW.ProductURL, ProductVersion = oSW.ProductVersion, 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, IconHash = oSW.IconHash, SWId = oSW.SWId, Manufacturer = oSW.Manufacturer, ProductName = oSW.ProductName, ProductURL = oSW.ProductURL, ProductVersion = oSW.ProductVersion, ShortName = oSW.ShortName, isInstalled = true
                                });
                            }
                            else
                            {
                                oDBCat.Add(new GetSoftware()
                                {
                                    Categories = oSW.Categories, Description = oSW.Description, Downloads = oSW.Downloads, IconHash = oSW.IconHash, SWId = oSW.SWId, Manufacturer = oSW.Manufacturer, ProductName = oSW.ProductName, ProductURL = oSW.ProductURL, ProductVersion = oSW.ProductVersion, ShortName = oSW.ShortName, 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);

                lvSW.ItemsSource = lcv;
            }
            catch { }
            Mouse.OverrideCursor = null;
        }
예제 #23
0
        static int Main(string[] args)
        {
            bool bError = false;

            //Get Proxy from IE
            WebRequest.DefaultWebProxy = WebRequest.GetSystemWebProxy();

            if (!string.IsNullOrEmpty(Properties.Settings.Default.Customerid))
            {
                RZRestAPIv2.CustomerID = Properties.Settings.Default.Customerid;
            }

            RZRestAPIv2.DisableBroadcast = Properties.Settings.Default.DisableBroadcast;

            List <string> lArgs = args.ToList();

            if (lArgs.Contains("-?") | lArgs.Contains("/?") | lArgs.Count < 1)
            {
                Console.WriteLine("RuckZuck CommandLine Tool (c) 2021 by Roger Zander");
                Console.WriteLine("Install:");
                Console.WriteLine("Install a Software from Shortname : RZGet.exe install \"<Shortname>\"[;\"<Shortname2>\"]");
                Console.WriteLine("Install a Software from JSON File : RZGet.exe install \"<JSON full path>\"[;\"<JSON full path>\"]");
                Console.WriteLine("Install a Sepcific Version : RZGet.exe install --name \"<ProductName>\" --vendor \"<Manufacturer>\" --version \"<ProductVersion>\"");
                Console.WriteLine("");
                Console.WriteLine("Update:");
                Console.WriteLine("Update all missing updates : RZGet.exe update --all [--retry]");
                Console.WriteLine("Update all missing updates : RZGet.exe update --all --exclude \"<Shortname>\"[;\"<Shortname2>\"] [--retry]");
                Console.WriteLine("Show all missing updates : RZGet.exe update --list --all");
                Console.WriteLine("check if a Software requires an update : RZGet.exe update --list \"<Shortname>\"");
                Console.WriteLine("Update a Software from Shortname : RZGet.exe update \"<Shortname>\"[;\"<Shortname2>\"] [--retry]");
                Console.WriteLine("");
                Console.WriteLine("Show:");
                Console.WriteLine("Show Metadata : RZGet.exe show \"<Shortname>\"");
                Console.WriteLine("Show Metadata for a specific Version : RZGet.exe show --name \"<ProductName>\" --vendor \"<Manufacturer>\" --version \"<ProductVersion>\"");
                Console.WriteLine("");
                Console.WriteLine("Search:");
                Console.WriteLine("Show full Catalog JSON: RZGet.exe search");
                Console.WriteLine("Search for a Keyword: RZGet.exe search zip");
                Console.WriteLine("Search SW in a Category: RZGet.exe search --categories compression");
                Console.WriteLine("Search for installed SW: RZGet.exe search --isinstalled true");
                Console.WriteLine("Search for a manufacturer: RZGet.exe search --manufacturer zander");
                Console.WriteLine("Search for a shortname and return PowerShell Object: RZGet.exe search --shortname ruckzuck | convertfrom-json");
                return(0);
            }

            if (lArgs[0].ToLower() == "install")
            {
                if (lArgs.Contains("--name", StringComparer.CurrentCultureIgnoreCase) || lArgs.Contains("--vendor", StringComparer.CurrentCultureIgnoreCase) || lArgs.Contains("--version", StringComparer.CurrentCultureIgnoreCase))
                {
                    try
                    {
                        RZUpdater oRZSW        = new RZUpdater();
                        string    ProductName  = lArgs[lArgs.FindIndex(t => t.IndexOf("--name", StringComparison.CurrentCultureIgnoreCase) >= 0) + 1];
                        string    Manufacturer = lArgs[lArgs.FindIndex(t => t.IndexOf("--vendor", StringComparison.CurrentCultureIgnoreCase) >= 0) + 1];

                        if (string.IsNullOrEmpty(Manufacturer))
                        {
                            Manufacturer = lArgs[lArgs.FindIndex(t => t.IndexOf("--manufacturer", StringComparison.CurrentCultureIgnoreCase) >= 0) + 1];
                        }

                        string ProductVersion = lArgs[lArgs.FindIndex(t => t.IndexOf("--version", StringComparison.CurrentCultureIgnoreCase) >= 0) + 1];
                        oRZSW.SoftwareUpdate = new SWUpdate(ProductName, ProductVersion, Manufacturer);

                        if (string.IsNullOrEmpty(oRZSW.SoftwareUpdate.SW.ProductName))
                        {
                            Console.WriteLine("'" + ProductName + "' is NOT available in RuckZuck...!");
                            return(99);
                        }

                        if (string.IsNullOrEmpty(oRZSW.SoftwareUpdate.SW.PSInstall))
                        {
                            oRZSW.SoftwareUpdate.GetInstallType();
                            if (string.IsNullOrEmpty(oRZSW.SoftwareUpdate.SW.PSInstall))
                            {
                                Console.WriteLine("PreRequisites not valid for '" + oRZSW.SoftwareUpdate.SW.ShortName + "'...!");
                                return(91);
                            }
                        }

                        if (Install(oRZSW))
                        {
                            return(0);
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Error: " + ex.Message);
                        return(1);
                    }
                }

                if (lArgs.Contains("--retry"))
                {
                    bRetry = true;
                }

                if (lArgs.Contains("--noretry"))
                {
                    bRetry = false;
                }


                foreach (string sArg in args.Skip(1))
                {
                    if (!sArg.StartsWith("--"))
                    {
                        if (File.Exists(sArg) || File.Exists(Path.Combine(Environment.ExpandEnvironmentVariables("%TEMP%"), sArg)) || File.Exists(Path.Combine(Environment.ExpandEnvironmentVariables("%TEMP%"), sArg + ".json")))
                        {
                            string sJFile = sArg;
                            if (!File.Exists(sJFile))
                            {
                                sJFile = Path.Combine(Environment.ExpandEnvironmentVariables("%TEMP%"), sArg);
                            }

                            if (!File.Exists(sJFile))
                            {
                                sJFile = Path.Combine(Environment.ExpandEnvironmentVariables("%TEMP%"), sArg + ".json");
                            }

                            RZUpdater oRZSW = new RZUpdater(sJFile);

                            if (string.IsNullOrEmpty(oRZSW.SoftwareUpdate.SW.ProductName))
                            {
                                Console.WriteLine("'" + sArg + "' is NOT available in RuckZuck...!");
                                bError = true;
                                continue;
                            }

                            if (string.IsNullOrEmpty(oRZSW.SoftwareUpdate.SW.PSInstall))
                            {
                                oRZSW.SoftwareUpdate.GetInstallType();
                                if (string.IsNullOrEmpty(oRZSW.SoftwareUpdate.SW.PSInstall))
                                {
                                    Console.WriteLine("PreRequisites not valid for '" + sArg + "'...!");
                                    bError = false;
                                    continue;
                                }
                            }

                            if (Install(oRZSW))
                            {
                                continue;
                            }
                        }
                        else
                        {
                            try
                            {
                                RZUpdater oRZSW = new RZUpdater();
                                oRZSW.SoftwareUpdate = new SWUpdate(sArg.Trim('"').Trim());

                                if (string.IsNullOrEmpty(oRZSW.SoftwareUpdate.SW.ProductName))
                                {
                                    Console.WriteLine("'" + sArg + "' is NOT available in RuckZuck...!");
                                    bError = true;
                                    continue;
                                }

                                if (string.IsNullOrEmpty(oRZSW.SoftwareUpdate.SW.PSInstall))
                                {
                                    oRZSW.SoftwareUpdate.GetInstallType();
                                    if (string.IsNullOrEmpty(oRZSW.SoftwareUpdate.SW.PSInstall))
                                    {
                                        Console.WriteLine("PreRequisites not valid for '" + sArg + "'...!");
                                        bError = false;
                                        continue;
                                    }
                                }

                                if (Install(oRZSW))
                                {
                                    continue;
                                }
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine("Error: " + ex.Message);
                                bError = true;
                            }
                        }
                    }
                }

                if (bError)
                {
                    return(1);
                }
                else
                {
                    return(0);
                }
            }

            if (lArgs[0].ToLower() == "update")
            {
                if (lArgs.Contains("--retry"))
                {
                    bRetry = true;
                }

                if (lArgs.Contains("--noretry"))
                {
                    bRetry = false;
                }

                bool          bUpdateAll = false;
                bool          bList      = false;
                bool          bExclude   = false;
                List <string> lExclude   = new List <string>();

                if (lArgs.Contains("--all", StringComparer.CurrentCultureIgnoreCase))
                {
                    bUpdateAll = true;
                }
                if (lArgs.Contains("--list", StringComparer.CurrentCultureIgnoreCase))
                {
                    bList = true;
                }
                if (lArgs.Contains("--exclude", StringComparer.CurrentCultureIgnoreCase))
                {
                    bExclude = true;
                }

                RZScan oScan = new RZScan(false);
                oScan.GetSWRepository().Wait(10000);
                oScan.SWScanAsync().Wait(10000);
                oScan._CheckUpdates(null);

                List <string> lUpdate = new List <string>();
                if (!bUpdateAll)
                {
                    foreach (string sArg in args.Skip(1))
                    {
                        if (oScan.NewSoftwareVersions.Count(t => t.ShortName.ToLower() == sArg.ToLower()) > 0)
                        {
                            lUpdate.Add(sArg);
                        }
                    }
                }
                else
                {
                    if (!bExclude)
                    {
                        lUpdate = oScan.NewSoftwareVersions.Select(t => t.ShortName).ToList();
                    }
                    else
                    {
                        int    iex = lArgs.IndexOf("--exclude", 0);
                        string scl = lArgs[iex + 1];
                        lExclude = scl.ToLower().Split(';').ToList();
                        lUpdate  = oScan.NewSoftwareVersions.Where(r => !lExclude.Contains(r.ShortName.ToLower())).Select(t => t.ShortName.ToLower()).ToList();
                    }
                }

                foreach (string sArg in lUpdate)
                {
                    if (bList)
                    {
                        Console.WriteLine(sArg);
                        continue;
                    }
                    if (File.Exists(sArg))
                    {
                        RZUpdater oRZSW = new RZUpdater(sArg);

                        if (string.IsNullOrEmpty(oRZSW.SoftwareUpdate.SW.ProductName))
                        {
                            Console.WriteLine("'" + sArg + "' is NOT available in RuckZuck...!");
                            bError = true;
                            continue;
                        }

                        if (string.IsNullOrEmpty(oRZSW.SoftwareUpdate.SW.PSInstall))
                        {
                            oRZSW.SoftwareUpdate.GetInstallType();
                            if (string.IsNullOrEmpty(oRZSW.SoftwareUpdate.SW.PSInstall))
                            {
                                Console.WriteLine("PreRequisites not valid for '" + sArg + "'...!");
                                bError = false;
                                continue;
                            }
                        }

                        if (Install(oRZSW))
                        {
                            continue;
                        }
                    }
                    else
                    {
                        try
                        {
                            RZUpdater oRZSW = new RZUpdater();
                            oRZSW.SoftwareUpdate = new SWUpdate(sArg.Trim('"').Trim());

                            if (string.IsNullOrEmpty(oRZSW.SoftwareUpdate.SW.ProductName))
                            {
                                Console.WriteLine("'" + sArg + "' is NOT available in RuckZuck...!");
                                bError = true;
                                continue;
                            }

                            if (string.IsNullOrEmpty(oRZSW.SoftwareUpdate.SW.PSInstall))
                            {
                                oRZSW.SoftwareUpdate.GetInstallType();
                                if (string.IsNullOrEmpty(oRZSW.SoftwareUpdate.SW.PSInstall))
                                {
                                    Console.WriteLine("PreRequisites not valid for '" + sArg + "'...!");
                                    bError = false;
                                    continue;
                                }
                            }

                            if (Install(oRZSW))
                            {
                                continue;
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("Error: " + ex.Message);
                            bError = true;
                        }
                    }
                }

                if (bError)
                {
                    return(1);
                }
                else
                {
                    return(0);
                }
            }

            //if (lArgs[0].ToLower() == "hash")
            //{
            //    Console.WriteLine("hash");
            //    Console.WriteLine(string.Join(";", args.Skip(1)));
            //    return 0;
            //}

            if (lArgs[0].ToLower() == "search")
            {
                if (lArgs.Count > 1)
                {
                    if (lArgs[1].StartsWith("--"))
                    {
                        string sProp   = lArgs[1].ToLower().TrimStart('-');
                        string sSearch = lArgs[2].ToLower();

                        if (sProp == "shortname")
                        {
                            Console.WriteLine(JsonConvert.SerializeObject(RZRestAPIv2.GetCatalog().Where(t => t.ShortName.ToLower().Contains(sSearch)), Formatting.Indented).ToString());
                        }

                        if (sProp == "manufacturer")
                        {
                            Console.WriteLine(JsonConvert.SerializeObject(RZRestAPIv2.GetCatalog().Where(t => t.Manufacturer.ToLower().Contains(sSearch)), Formatting.Indented).ToString());
                        }

                        if (sProp == "productname" || sProp == "name")
                        {
                            Console.WriteLine(JsonConvert.SerializeObject(RZRestAPIv2.GetCatalog().Where(t => t.ProductName.ToLower().Contains(sSearch)), Formatting.Indented).ToString());
                        }

                        if (sProp == "description")
                        {
                            Console.WriteLine(JsonConvert.SerializeObject(RZRestAPIv2.GetCatalog().Where(t => t.Description.ToLower().Contains(sSearch)), Formatting.Indented).ToString());
                        }

                        if (sProp == "categories" || sProp == "category")
                        {
                            Console.WriteLine(JsonConvert.SerializeObject(RZRestAPIv2.GetCatalog().Where(t => string.Join(";", t.Categories.ToArray()).ToLower().Contains(sSearch)), Formatting.Indented).ToString());
                        }

                        if (sProp == "producturl" || sProp == "url")
                        {
                            Console.WriteLine(JsonConvert.SerializeObject(RZRestAPIv2.GetCatalog().Where(t => t.ProductURL.ToLower().Contains(sSearch)), Formatting.Indented).ToString());
                        }

                        if (sProp == "productversion" || sProp == "version")
                        {
                            Console.WriteLine(JsonConvert.SerializeObject(RZRestAPIv2.GetCatalog().Where(t => t.ProductVersion.ToLower().Contains(sSearch)), Formatting.Indented).ToString());
                        }

                        if (sProp == "isinstalled")
                        {
                            oScan = new RZScan(false, false);
                            oScan.SWScanAsync().Wait();
                            oScan.GetSWRepository().Wait();
                            foreach (var osw in oScan.InstalledSoftware)
                            {
                                var oItem = oScan.SoftwareRepository.FirstOrDefault(t => t.ProductName == osw.ProductName && t.Manufacturer == osw.Manufacturer && t.ProductVersion == osw.ProductVersion);
                                if (oItem != null)
                                {
                                    oItem.isInstalled = true;
                                }
                            }

                            Console.WriteLine(JsonConvert.SerializeObject(oScan.SoftwareRepository.Where(t => t.isInstalled.ToString().ToLower().Contains(sSearch)), Formatting.Indented).ToString());
                        }
                    }
                    else
                    {
                        string sSearch = lArgs[1].ToLower();
                        Console.WriteLine(JsonConvert.SerializeObject(RZRestAPIv2.GetCatalog().Where(t => t.ProductName.ToLower().Contains(sSearch) || t.Manufacturer.ToLower().Contains(sSearch) || t.ShortName.ToLower().Contains(sSearch)), Formatting.Indented).ToString());
                    }
                }
                else
                {
                    Console.WriteLine(JsonConvert.SerializeObject(RZRestAPIv2.GetCatalog(), Formatting.Indented).ToString());
                }
                return(0);
            }

            if (lArgs[0].ToLower() == "show")
            {
                if (lArgs.Contains("--name", StringComparer.CurrentCultureIgnoreCase) || lArgs.Contains("--vendor", StringComparer.CurrentCultureIgnoreCase) || lArgs.Contains("--version", StringComparer.CurrentCultureIgnoreCase))
                {
                    try
                    {
                        RZUpdater oRZSW        = new RZUpdater();
                        string    ProductName  = lArgs[lArgs.FindIndex(t => t.IndexOf("--name", StringComparison.CurrentCultureIgnoreCase) >= 0) + 1];
                        string    Manufacturer = lArgs[lArgs.FindIndex(t => t.IndexOf("--vendor", StringComparison.CurrentCultureIgnoreCase) >= 0) + 1];

                        if (string.IsNullOrEmpty(Manufacturer))
                        {
                            Manufacturer = lArgs[lArgs.FindIndex(t => t.IndexOf("--manufacturer", StringComparison.CurrentCultureIgnoreCase) >= 0) + 1];
                        }

                        string ProductVersion = lArgs[lArgs.FindIndex(t => t.IndexOf("--version", StringComparison.CurrentCultureIgnoreCase) >= 0) + 1];
                        oRZSW.SoftwareUpdate = new SWUpdate(ProductName, ProductVersion, Manufacturer);

                        if (string.IsNullOrEmpty(oRZSW.SoftwareUpdate.SW.ProductName))
                        {
                            Console.WriteLine("'" + ProductName + "' is NOT available in RuckZuck...!");
                            return(99);
                        }

                        Console.WriteLine(JsonConvert.SerializeObject(oRZSW.SoftwareUpdate.SW, Formatting.Indented).ToString());

                        return(0);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Error: " + ex.Message);
                        return(1);
                    }
                }

                foreach (string sArg in args.Skip(1))
                {
                    if (File.Exists(sArg))
                    {
                        RZUpdater oRZSW = new RZUpdater(sArg);

                        Console.WriteLine(JsonConvert.SerializeObject(oRZSW.SoftwareUpdate.SW, Formatting.Indented).ToString());
                    }
                    else
                    {
                        try
                        {
                            RZUpdater oRZSW = new RZUpdater();
                            oRZSW.SoftwareUpdate = new SWUpdate(sArg.Trim('"').Trim());

                            if (string.IsNullOrEmpty(oRZSW.SoftwareUpdate.SW.ProductName))
                            {
                                Console.WriteLine("'" + sArg + "' is NOT available in RuckZuck...!");
                                bError = true;
                                continue;
                            }

                            Console.WriteLine(JsonConvert.SerializeObject(oRZSW.SoftwareUpdate.SW, Formatting.Indented).ToString());

                            return(0);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("Error: " + ex.Message);
                            return(1);
                        }
                    }
                }

                return(0);
            }

            return(0);
        }