Ejemplo n.º 1
0
 public MainForm(ReleaseInformation _releaseInformation, string metaFile)
 {
     InitializeComponent();
     this.ReleaseInformation = _releaseInformation;
     this.MetaFile           = metaFile;
     LoadToUI(_releaseInformation);
 }
Ejemplo n.º 2
0
        private void LoadToUI(ReleaseInformation _releaseInformation)
        {
            btnMajor.Value    = _releaseInformation.Version.Major;
            btnMinor.Value    = _releaseInformation.Version.Minor;
            btnBuild.Value    = _releaseInformation.Version.Build;
            btnRevision.Value = _releaseInformation.Version.Revision;

            txtFriendlyVersion.Text = _releaseInformation.FriendlyVersion;
            txtReleaseNotes.Text    = _releaseInformation.ReleaseNotes;
        }
Ejemplo n.º 3
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            var newReleaseInformation = new ReleaseInformation();

            newReleaseInformation.Version         = new Version(btnMajor.Value, btnMinor.Value, btnBuild.Value, btnRevision.Value);
            newReleaseInformation.FriendlyVersion = txtFriendlyVersion.Text.Trim();
            newReleaseInformation.ReleaseDate     = ReleaseInformation.ReleaseDate;
            newReleaseInformation.ReleaseNotes    = txtReleaseNotes.Text;
            if (newReleaseInformation.Version.CompareTo(ReleaseInformation.Version) <= 0)
            {
                if (MessageBox.Show(this, "You should increase the version number for this release.",
                                    Text, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                {
                    return;
                }
            }
            ReleaseInformationHelper.Save(newReleaseInformation, MetaFile);
            Close();
        }
Ejemplo n.º 4
0
        private void ApplyFilter_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            bool       activate   = ActivateFilter.IsChecked ?? false;
            MainWindow mainWindow = Application.Current.MainWindow as MainWindow;

            if (activate == true && Status.SelectedItem != null && Release.SelectedItem != null && PlatformRelease.SelectedItem != null)
            {
                EnvironmentState           environmentstate           = Status.SelectedItem as EnvironmentState;
                ReleaseInformation         releaseInformation         = Release.SelectedItem as ReleaseInformation;
                PlatformReleaseInformation platformReleaseInformation = PlatformRelease.SelectedItem as PlatformReleaseInformation;
                mainWindow.SetFilter(activate, environmentstate, releaseInformation, platformReleaseInformation);
            }
            else
            {
                mainWindow.SetFilter(activate, null, null, null);
            }

            this.Close();
        }
Ejemplo n.º 5
0
        public CloudHostedViewModel()
        {
            RDPTerminals = new System.Collections.ObjectModel.ObservableCollection <Model.RDPTerminal>();

            MainWindow mainWindow = Application.Current.MainWindow as MainWindow;
            List <CloudHostedInstance> cloudHostedTerminals = mainWindow.CloudHosted;
            List <InstanceAttribute>   instanceAttributes   = mainWindow.InstanceAttributes;

            mainWindow.EnableCloudHosted(false);


            FilterValues filterValues = mainWindow.GetFilter();

            NumberOfMachines = cloudHostedTerminals.Count;

            if (cloudHostedTerminals != null)
            {
                foreach (CloudHostedInstance instance in cloudHostedTerminals)
                {
                    InstanceAttribute instanceAttribute = instanceAttributes.Find(x => x.EnvironmentId == instance.EnvironmentId);

                    string imageSource = "/Resources/DefaultVM.png";
                    if (instanceAttribute != null)
                    {
                        imageSource = instanceAttribute.ImageSource;
                    }

                    EnvironmentState envState = new EnvironmentState()
                    {
                        StateDescription = instance.DeploymentStatus,
                        StateNum         = instance.DeploymentState
                    };
                    mainWindow.AddEnvironmentState(envState);

                    PlatformReleaseInformation platformReleaseInformation = new PlatformReleaseInformation()
                    {
                        PlatformRelease = instance.CurrentPlatformReleaseName
                    };

                    ReleaseInformation releaseinformation = new ReleaseInformation()
                    {
                        Release = instance.CurrentApplicationReleaseName
                    };

                    if (platformReleaseInformation.PlatformRelease != null && releaseinformation.Release != null)
                    {
                        mainWindow.AddReleaseInformation(releaseinformation, platformReleaseInformation);
                    }

                    bool okToAdd = false;
                    if (filterValues.Active == true)
                    {
                        if (instance.DeploymentStatus == filterValues.environmentState.StateDescription &&
                            instance.CurrentApplicationReleaseName == filterValues.releaseInformation.Release &&
                            instance.CurrentPlatformReleaseName == filterValues.platformReleaseInformation.PlatformRelease)
                        {
                            okToAdd = true;
                        }
                    }
                    else
                    {
                        okToAdd = true;
                    }

                    if (okToAdd == true)
                    {
                        RDPTerminals.Add(new Model.RDPTerminal()
                        {
                            InstanceId                 = instance.InstanceId,
                            DeploymentStatus           = instance.DeploymentStatus,
                            ApplicationRelease         = instance.CurrentApplicationReleaseName,
                            CurrentPlatformReleaseName = instance.CurrentPlatformReleaseName,
                            TopologyType               = instance.TopologyType,
                            DisplayName                = instance.DisplayName,
                            EnvironmentId              = instance.EnvironmentId,
                            Instances           = instance.Instances,
                            SqlAzureCredentials = instance.SqlAzureCredentials,
                            NavigationLinks     = instance.NavigationLinks,
                            ImageSource         = imageSource
                        });
                    }
                }
                if (RDPTerminals.Count > 0)
                {
                    RDPTerminals.BubbleSort();
                    SelectedRDPTerminal = RDPTerminals[0];
                    mainWindow.EnableCloudHosted(true);
                }
            }
        }
        public void TestGetReleaseInfo()
        {
            //Setup
            ReleaseInformation expectedReleaseInfo;

            expectedReleaseInfo = new ReleaseInformation
            {
                ReleaseDate = new DateTime(2020, 02, 10),

                ReleaseNotes = new ReleaseNotes
                {
                    Changes = new Dictionary <CultureInfo, List <ChangeSet> >
                    {
                        { new CultureInfo("de"), new List <ChangeSet>
                          {
                              new ChangeSet
                              {
                                  Platforms = new List <string> {
                                      "windows/any", "linux/rpi"
                                  },
                                  Added = new List <string> {
                                      "added de 1", "added de 2"
                                  },
                                  Fixed = new List <string> {
                                      "fix de 1", "fix de 2"
                                  },
                                  Breaking = new List <string> {
                                      "breaking de 1", "breaking de 2"
                                  },
                                  Deprecated = new List <string> {
                                      "deprecated de 1", "deprecated de 2"
                                  }
                              }
                          } },
                        { new CultureInfo("en"), new List <ChangeSet>
                          {
                              new ChangeSet
                              {
                                  Platforms = new List <string> {
                                      "windows/any", "linux/rpi"
                                  },
                                  Added = new List <string> {
                                      "added en 1", "added en 2"
                                  },
                                  Fixed = new List <string> {
                                      "fix en 1", "fix en 2"
                                  },
                                  Breaking = new List <string> {
                                      "breaking en 1", "breaking en 2"
                                  },
                                  Deprecated = new List <string> {
                                      "deprecated en 1", "deprecated en 2"
                                  }
                              },
                              new ChangeSet
                              {
                                  Platforms = null,
                                  Added     = new List <string> {
                                      "added en 3"
                                  },
                                  Fixed = new List <string> {
                                      "fix en 3"
                                  },
                                  Breaking = new List <string> {
                                      "breaking en 3"
                                  },
                                  Deprecated = new List <string> {
                                      "deprecated en 3"
                                  }
                              }
                          } }
                    }
                }
            };

            //Act
            var testReleaseInfo = fsReleaseArtifactRepository.GetReleaseInfo("productx", "ubuntu",
                                                                             "amd64", "1.1");

            //Assert
            testReleaseInfo.Should().BeEquivalentTo(expectedReleaseInfo);
        }
Ejemplo n.º 7
0
 /// <summary>
 /// 添加约会记录
 /// </summary>
 /// <param name="release"></param>
 internal bool addRelease(ReleaseInformation release)
 {
     _context.ReleaseInformations.Add(release);
     _context.SaveChanges();
     return(true);
 }
Ejemplo n.º 8
0
    internal static void CheckForUpdates()
    {
        try
        {
            using WebClientOptimized webClient = new(10, false);
            String result;
            try
            {
                result = webClient.DownloadString("https://api.github.com/repos/GieltjE/MSM/releases/latest");
            }
            catch (WebException exception)
            {
                if (exception.Status == WebExceptionStatus.ProtocolError)
                {
                    if (exception.Response is HttpWebResponse response)
                    {
                        if ((Int32)response.StatusCode == 404)
                        {
                            return;
                        }
                    }
                }

                UI.ShowWarning(Variables.MainForm, "Could not perform update check!", "Update check", MessageBoxIcon.Asterisk);
                return;
            }

            ReleaseInformation resultDeserialized  = Statics.NewtonsoftJsonSerializer.Deserialize <ReleaseInformation>(result);
            FileVersionInfo    fileVersionInfo     = FileVersionInfo.GetVersionInfo(FileOperations.GetCurrentExecutable());
            Version            currentVersion      = Version.Parse(fileVersionInfo.FileVersion);
            String             architecturePostFix = "-x86";
            if (Environment.Is64BitProcess)
            {
                architecturePostFix = "-x64";
            }
            Asset asset = resultDeserialized.assets.FirstOrDefault(x => x.browser_download_url.EndsWith(architecturePostFix + ".zip", StringComparison.Ordinal));

#if !DEBUG
            if (resultDeserialized.tag_name < currentVersion)
            {
                UI.ShowWarning(Variables.MainForm, "An older version (" + resultDeserialized.tag_name + ") is currently the latest release, please consider downgrading", "Update check", MessageBoxIcon.Asterisk);
            }
#endif

            if (resultDeserialized.tag_name <= currentVersion || asset == null)
            {
                return;
            }

            String updateDirectory = Path.Combine(FileOperations.GetRunningDirectory(), "update");
            if (Directory.Exists(updateDirectory))
            {
                while (FileOperations.DeleteDirectory(updateDirectory, true).Any())
                {
                    Thread.Sleep(500);
                }
            }

            if (UI.AskQuestion(Variables.MainForm, "A new version (" + resultDeserialized.tag_name + ") is available, would you like to upgrade?", "Upgrade available", MessageBoxButtons.YesNo, MessageBoxDefaultButton.Button1, MessageBoxIcon.Question) != DialogResult.Yes)
            {
                return;
            }

            if (!FileOperations.CreateDirectory(updateDirectory))
            {
                return;
            }

            MemoryStream stream  = new(webClient.DownloadData(asset.browser_download_url));
            FastZip      fastZip = new();
            fastZip.ExtractZip(stream, updateDirectory, FastZip.Overwrite.Always, null, null, null, true, true);

            ProcessStartInfo procInfo = new(Path.Combine(updateDirectory, Path.GetFileName(FileOperations.GetCurrentExecutable())))
            {
                WorkingDirectory = updateDirectory,
                Arguments        = "--update",
                CreateNoWindow   = true,
                WindowStyle      = ProcessWindowStyle.Maximized,
                UseShellExecute  = false
            };
            Process.Start(procInfo);

            // Prevent closing our updated version......
            Statics.InformationObjectManager?.Dispose();

            Events.ShutDown();
            Environment.Exit(1001);
        }
        catch (Exception exception)
        {
            Logger.Log(Enumerations.LogTarget.General, Enumerations.LogLevel.Error, "Could not check for updates", exception);
        }
    }