コード例 #1
0
        private void btCreateEXE_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                string sTempFile = Path.Combine(Environment.ExpandEnvironmentVariables("%TEMP%"), Path.GetRandomFileName() + ".json");
                SaveAsJSON(sTempFile);

                string jSW = File.ReadAllText(sTempFile);
                File.Delete(sTempFile);

                CreateExe oExe = new CreateExe(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, tbProductName.Text + "_" + tbVersion.Text + "_" + tbArchitecture.Text + "_setup.exe"));
                if (imgIcon.Tag != null)
                {
                    oExe.Icon = imgIcon.Tag as byte[];
                }
                oExe.Sources.Add(Properties.Resources.Source.Replace("RZRZRZ", tbProductName.Text));
                oExe.Sources.Add(Properties.Resources.RZUpdate);
                oExe.Sources.Add(Properties.Resources.RZRestApi);
                oExe.Sources.Add(Properties.Resources.Assembly.Replace("RZRZRZ", tbProductName.Text).Replace("[assembly: AssemblyFileVersion(\"1.0.0.0\")]", "[assembly: AssemblyFileVersion(\"" + tbVersion.Text + "\")]"));

                System.Resources.ResourceWriter writer = new System.Resources.ResourceWriter("Resources.resx");
                writer.AddResource("SW.json", jSW);
                writer.Generate();
                writer.Close();
                oExe.cp.EmbeddedResources.Add("Resources.resx");
                if (!oExe.Compile())
                {
                    MessageBox.Show("Failed to create .Exe", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                File.Delete("Resources.resx");
            }
            catch { }
        }
コード例 #2
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;
            }
        }
コード例 #3
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"));
                        oExe.Icon = oSW.SW.Image;
                        oExe.Sources.Add(Properties.Resources.Source.Replace("RZRZRZ", oSW.SW.ShortName));
                        oExe.Sources.Add(Properties.Resources.RZUpdate);
                        oExe.Sources.Add(Properties.Resources.RZRestApi);
                        oExe.Sources.Add(Properties.Resources.Assembly.Replace("RZRZRZ", oSW.SW.ShortName));

                        if (!oExe.Compile())
                        {
                            MessageBox.Show("Failed to create .Exe", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                        }

                        //Non authenticated Users can create one EXE
                        if (!EnableEdit)
                        {
                            miCreateExe.IsEnabled = false;
                            return;
                        }
                    }
                    catch { }
                }
            }
            finally
            {
                Mouse.OverrideCursor = null;
            }
        }
コード例 #4
0
        private void miCreateArtifact_Click(object sender, RoutedEventArgs e)
        {
            Mouse.OverrideCursor = Cursors.Wait;
            try
            {
                foreach (var oItem in lvSW.SelectedItems)
                {
                    try
                    {
                        SWUpdate oSW = null;
                        if (oItem.GetType() == typeof(GetSoftware))
                        {
                            GetSoftware dgr = oItem as GetSoftware;
                            //sPS = GetSWInstallPS(dgr.ProductName, dgr.ProductVersion, "");
                            oSW = new SWUpdate(dgr.ProductName, dgr.ProductVersion, dgr.Manufacturer);
                        }

                        if (oItem.GetType() == typeof(AddSoftware))
                        {
                            AddSoftware dgr = oItem as AddSoftware;
                            //sPS = GetSWInstallPS(dgr.ProductName, dgr.ProductVersion, "");
                            oSW = new SWUpdate(dgr);
                        }

                        string sDir = AppDomain.CurrentDomain.BaseDirectory;
                        sDir = Path.Combine(sDir, "windows-" + oSW.SW.Shortname.Replace(" ", "")).Trim();
                        Directory.CreateDirectory(sDir);
                        CreateExe oExe = new CreateExe(Path.Combine(sDir, oSW.SW.Shortname.Replace(" ", "") + "_setup.exe"));
                        oExe.Icon = oSW.SW.Image;
                        oExe.Sources.Add(Properties.Resources.Source.Replace("RZRZRZ", oSW.SW.Shortname));
                        oExe.Sources.Add(Properties.Resources.RZUpdate);
                        oExe.Sources.Add(Properties.Resources.RZRestApi);
                        oExe.Sources.Add(Properties.Resources.Assembly.Replace("RZRZRZ", oSW.SW.Shortname));

                        if (!oExe.Compile())
                        {
                            MessageBox.Show("Failed to create .Exe", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                        }

                        List <string> lLines = new List <string>();
                        lLines.Add("{");
                        lLines.Add("\t\"title\": \"" + oSW.SW.Shortname + "\",");
                        lLines.Add("\t\"description\": \"" + oSW.SW.Description + "\",");
                        lLines.Add("\t\"publisher\": \"" + oSW.SW.Manufacturer + "\",");
                        lLines.Add("\t\"tags\": [\"Windows\"");
                        if (((GetSoftware)oItem).Categories.Count > 0)
                        {
                            foreach (string sCat in ((GetSoftware)oItem).Categories)
                            {
                                lLines.Add("\t, \"" + sCat + "\"");
                            }
                            lLines.Add("\t],");
                        }
                        else
                        {
                            lLines.Add("\t],");
                        }
                        lLines.Add("\t\"iconUri\": \"https://ruckzuck.azurewebsites.net/wcf/RZService.svc/rest/GetIcon?id=" + ((GetSoftware)oItem).IconId + "\",");
                        lLines.Add("\t\"targetOsType\": \"Windows\",");
                        lLines.Add("\t\"runCommand\": { \"commandToExecute\": \"" + oSW.SW.Shortname.Replace(" ", "") + "_setup.exe" + "\" }");
                        lLines.Add("}");
                        System.IO.File.WriteAllLines(Path.Combine(sDir, "artifactfile.json"), lLines.ToArray());

                        //Non authenticated Users can create one EXE
                        if (!EnableEdit)
                        {
                            miCreateArtifact.IsEnabled = false;
                            return;
                        }
                    }
                    catch { }
                }
            }
            finally
            {
                Mouse.OverrideCursor = null;
            }
        }