Exemplo n.º 1
0
        private void CheckIfUpdated()
        {
            var currentVersion = VersionUtil.GetVersion();

            Log.Info($"Application Started | currentVersion:{currentVersion} | lastVersion:{Config.LastVersion}");
            if (currentVersion == Config.LastVersion)
            {
                return;
            }
            Settings.Default.Upgrade();

            var serviceTask = string.IsNullOrEmpty(Config.LastVersion)
                ? (Func <Task>)(async() => await new ServiceClient(Config.ServiceAddress).InstallationCompleted(currentVersion))
                : (Func <Task>)(async() => await new ServiceClient(Config.ServiceAddress).UpdateCompleted(currentVersion));

            Task.Factory.StartNew(async() =>
            {
                try
                {
                    Log.Info($"Calling service: {Config.ServiceAddress}");
                    await serviceTask();
                    Config.LastVersion = currentVersion;
                    Config.Save();
                }
                catch (Exception ex)
                {
                    Log.Error(ex);
                }
            });
        }
Exemplo n.º 2
0
        private async void AboutWindow_OnLoaded(object sender, RoutedEventArgs e)
        {
            if (_pendingRestart)
            {
                UpdateStatusSuccess("Update completed. Restart the application.");
                return;
            }

            try
            {
                var updateInfo = await ClickOnceHelper.CheckNewVersion();

                if (updateInfo.UpdateAvailable)
                {
                    Telemetry.Instance.Native?.TrackEvent("About.UpdateAvailable", new Dictionary <string, string>
                    {
                        { "currentVersion", VersionUtil.GetVersion() },
                        { "newVersion", updateInfo.AvailableVersion.ToString(4) }
                    });
                    UpdateStatusMessage($"New version '{updateInfo.AvailableVersion.ToString(4)}' is available.", true);
                    ucUpdateButton.Visibility = Visibility.Visible;
                }
                else
                {
                    UpdateStatusMessage("Application is up to date.");
                }
            }
            catch (Exception ex)
            {
                UpdateStatusError("Could not check updates, try again later.", ex);
            }
        }
Exemplo n.º 3
0
        public MainWindow()
        {
            InitializeComponent();
            this.Title  = "SmartCAML [v. " + VersionUtil.GetVersion() + "]";
            this.Width  = Config.WindowWidth;
            this.Height = Config.WindowHeight;
            if (Config.WasMaximazed)
            {
                this.WindowState = WindowState.Maximized;
            }

            ((RoutedCommand)ConnectCommand.Command).InputGestures.Add(new KeyGesture(Key.O, ModifierKeys.Control));
            Telemetry.Instance.Native.TrackPageView("Main");
        }
Exemplo n.º 4
0
        private void CheckIfUpdated()
        {
            var currentVersion = VersionUtil.GetVersion();

            Log.Info($"Application Started | currentVersion:{currentVersion} | lastVersion:{Config.LastVersion}");

            if (currentVersion != Config.LastVersion)
            {
                Settings.Default.Upgrade();
                Config.LastVersion           = currentVersion;
                Config.InstallationCompleted = false;
                Config.Save();
            }

            if (!Config.InstallationCompleted)
            {
                CompleteInstallation(currentVersion);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// edits certain project based values for c# and visual studio projects
        /// </summary>
        /// <param name="activeProject">the active project that is to be deployed</param>
        /// <param name="project">project configuration to use</param>
        /// <returns>null if all edits were down, otherwise the error string</returns>
        private void ChangeNuSpec(Project activeProject, PackageInformation packageInfo)
        {
            LoggingManager.Instance.Logger.Debug("changing project started");

            //-----edit values here
            if (!string.IsNullOrEmpty(packageInfo.NuSpecPackage.Metadata.Version) && packageInfo.ProjectOptions.GeneralOptions.VersionComponent.HasValue)
            {
                LoggingManager.Instance.Logger.Debug(string.Format("changing version [{0}]", packageInfo.NuSpecPackage.Metadata.Version));

                HashSet <VersionComponentInfo> version = VersionUtil.GetVersion(packageInfo.NuSpecPackage.Metadata.Version, null, packageInfo.ProjectOptions.GeneralOptions.AssemblyInfoVersionInformationalSeparator);

                VersionUtil.IncreaseVersion(version, packageInfo.ProjectOptions.GeneralOptions.VersionComponent.Value, null, packageInfo.ProjectOptions.GeneralOptions.HandleIncrementOverflow);

                packageInfo.NuSpecPackage.Metadata.Version = VersionUtil.CreateVersion(version, null, packageInfo.ProjectOptions.GeneralOptions.AssemblyInfoVersionInformationalSeparator);

                LoggingManager.Instance.Logger.Debug(string.Format("new version [{0}]", packageInfo.NuSpecPackage.Metadata.Version));
            }

            LoggingManager.Instance.Logger.Debug("changing project finished");
        }
Exemplo n.º 6
0
        /// <summary>
        /// callback to be invoked when a line is to be read and written back to the assembly info of a c++ project
        /// </summary>
        /// <param name="line">line that has been read</param>
        /// <param name="objs">object containing the deployment info and the Configuration project</param>
        /// <returns>new line to be written</returns>
        private string AssemblyInfoReadCallback(string line, object[] objs)
        {
            PackageInformation packageInfo        = (PackageInformation)objs[0];
            ProjectInformation projectInformation = (ProjectInformation)objs[1];

            LoggingManager.Instance.Logger.Debug(string.Format("changing line: {0}", line));

            int index = line.IndexOf(projectInformation.AssemblyInfoIdentifier);

            if (index != -1)
            {
                string lineContent = line.Substring(projectInformation.AssemblyInfoIdentifier.Length, line.Length - projectInformation.AssemblyInfoIdentifier.Length).Trim();

                bool hasContent = false;

                string content = null;

                if (packageInfo.ProjectOptions.NuGetOptions.NuSpecOptions.Metadata.Version.Save &&
                    (lineContent.StartsWith(StringUtil.Join(Definitions.Constants.AssemblyInfoVersionIdentifierNames[AssemblyVersionIdentifier.AssemblyVersion],
                                                            Definitions.Constants.AssemblyContentStart)) ||
                     lineContent.StartsWith(StringUtil.Join(Definitions.Constants.AssemblyInfoVersionIdentifierNames[AssemblyVersionIdentifier.AssemblyVersion],
                                                            Definitions.Constants.AssemblyAttributeAddition,
                                                            Definitions.Constants.AssemblyContentStart)) ||
                     lineContent.StartsWith(StringUtil.Join(Definitions.Constants.AssemblyInfoVersionIdentifierNames[AssemblyVersionIdentifier.AssemblyFileVersion],
                                                            Definitions.Constants.AssemblyContentStart)) ||
                     lineContent.StartsWith(StringUtil.Join(Definitions.Constants.AssemblyInfoVersionIdentifierNames[AssemblyVersionIdentifier.AssemblyFileVersion],
                                                            Definitions.Constants.AssemblyAttributeAddition,
                                                            Definitions.Constants.AssemblyContentStart)) ||
                     lineContent.StartsWith(StringUtil.Join(Definitions.Constants.AssemblyInfoVersionIdentifierNames[AssemblyVersionIdentifier.AssemblyInformationalVersion],
                                                            Definitions.Constants.AssemblyContentStart)) ||
                     lineContent.StartsWith(StringUtil.Join(Definitions.Constants.AssemblyInfoVersionIdentifierNames[AssemblyVersionIdentifier.AssemblyInformationalVersion],
                                                            Definitions.Constants.AssemblyAttributeAddition,
                                                            Definitions.Constants.AssemblyContentStart))))
                {
                    string version = VersionUtil.CreateVersion(VersionUtil.GetVersion(packageInfo.NuSpecPackage.Metadata.Version), VersionUtil.VersionComponentOrderWithOutInformational);

                    string versionWithInformational = VersionUtil.CreateVersion(VersionUtil.GetVersion(packageInfo.NuSpecPackage.Metadata.Version),
                                                                                null,
                                                                                packageInfo.ProjectOptions.GeneralOptions.AssemblyInfoVersionInformationalSeparator);

                    string versionToUse = version;

                    if (packageInfo.ProjectOptions.GeneralOptions.AssemblyInfoVersionIdentifier == AssemblyVersionIdentifier.AssemblyInformationalVersion)
                    {
                        versionToUse = versionWithInformational;
                    }

                    if (packageInfo.ProjectOptions.GeneralOptions.SaveBackVersionInAllIdentifiers &&
                        (lineContent.StartsWith(StringUtil.Join(Definitions.Constants.AssemblyInfoVersionIdentifierNames[AssemblyVersionIdentifier.AssemblyVersion],
                                                                Definitions.Constants.AssemblyContentStart)) ||
                         lineContent.StartsWith(StringUtil.Join(Definitions.Constants.AssemblyInfoVersionIdentifierNames[AssemblyVersionIdentifier.AssemblyVersion],
                                                                Definitions.Constants.AssemblyAttributeAddition,
                                                                Definitions.Constants.AssemblyContentStart))))
                    {
                        content    = version;
                        hasContent = true;
                    }
                    if (packageInfo.ProjectOptions.GeneralOptions.SaveBackVersionInAllIdentifiers &&
                        (lineContent.StartsWith(StringUtil.Join(Definitions.Constants.AssemblyInfoVersionIdentifierNames[AssemblyVersionIdentifier.AssemblyFileVersion],
                                                                Definitions.Constants.AssemblyContentStart)) ||
                         lineContent.StartsWith(StringUtil.Join(Definitions.Constants.AssemblyInfoVersionIdentifierNames[AssemblyVersionIdentifier.AssemblyFileVersion],
                                                                Definitions.Constants.AssemblyAttributeAddition,
                                                                Definitions.Constants.AssemblyContentStart))))
                    {
                        content    = version;
                        hasContent = true;
                    }
                    if (packageInfo.ProjectOptions.GeneralOptions.SaveBackVersionInAllIdentifiers &&
                        (lineContent.StartsWith(StringUtil.Join(Definitions.Constants.AssemblyInfoVersionIdentifierNames[AssemblyVersionIdentifier.AssemblyInformationalVersion],
                                                                Definitions.Constants.AssemblyContentStart)) ||
                         lineContent.StartsWith(StringUtil.Join(Definitions.Constants.AssemblyInfoVersionIdentifierNames[AssemblyVersionIdentifier.AssemblyInformationalVersion],
                                                                Definitions.Constants.AssemblyAttributeAddition,
                                                                Definitions.Constants.AssemblyContentStart))))
                    {
                        content    = versionWithInformational;
                        hasContent = true;
                    }
                    else if (lineContent.StartsWith(StringUtil.Join(Definitions.Constants.AssemblyInfoVersionIdentifierNames[packageInfo.ProjectOptions.GeneralOptions.AssemblyInfoVersionIdentifier],
                                                                    Definitions.Constants.AssemblyContentStart)) ||
                             lineContent.StartsWith(StringUtil.Join(Definitions.Constants.AssemblyInfoVersionIdentifierNames[packageInfo.ProjectOptions.GeneralOptions.AssemblyInfoVersionIdentifier],
                                                                    Definitions.Constants.AssemblyAttributeAddition,
                                                                    Definitions.Constants.AssemblyContentStart)))
                    {
                        content    = versionToUse;
                        hasContent = true;
                    }
                }
                else if (packageInfo.ProjectOptions.NuGetOptions.NuSpecOptions.Metadata.Title.Save &&
                         (lineContent.StartsWith(StringUtil.Join(projectInformation.Title,
                                                                 Definitions.Constants.AssemblyContentStart)) ||
                          lineContent.StartsWith(StringUtil.Join(projectInformation.Title,
                                                                 Definitions.Constants.AssemblyAttributeAddition,
                                                                 Definitions.Constants.AssemblyContentStart))))
                {
                    content    = packageInfo.NuSpecPackage.Metadata.Title;
                    hasContent = true;
                }
                else if (packageInfo.ProjectOptions.NuGetOptions.NuSpecOptions.Metadata.Authors.Save &&
                         (lineContent.StartsWith(StringUtil.Join(projectInformation.Authors,
                                                                 Definitions.Constants.AssemblyContentStart)) ||
                          lineContent.StartsWith(StringUtil.Join(projectInformation.Authors,
                                                                 Definitions.Constants.AssemblyAttributeAddition,
                                                                 Definitions.Constants.AssemblyContentStart))))
                {
                    content    = packageInfo.NuSpecPackage.Metadata.Authors;
                    hasContent = true;
                }
                else if (packageInfo.ProjectOptions.NuGetOptions.NuSpecOptions.Metadata.Description.Save &&
                         (lineContent.StartsWith(StringUtil.Join(projectInformation.Description,
                                                                 Definitions.Constants.AssemblyContentStart)) ||
                          lineContent.StartsWith(StringUtil.Join(projectInformation.Description,
                                                                 Definitions.Constants.AssemblyAttributeAddition,
                                                                 Definitions.Constants.AssemblyContentStart))))
                {
                    content    = packageInfo.NuSpecPackage.Metadata.Description;
                    hasContent = true;
                }
                else if (packageInfo.ProjectOptions.NuGetOptions.NuSpecOptions.Metadata.Language.Save &&
                         (lineContent.StartsWith(StringUtil.Join(projectInformation.Language,
                                                                 Definitions.Constants.AssemblyContentStart)) ||
                          lineContent.StartsWith(StringUtil.Join(projectInformation.Language,
                                                                 Definitions.Constants.AssemblyAttributeAddition,
                                                                 Definitions.Constants.AssemblyContentStart))))
                {
                    content    = packageInfo.NuSpecPackage.Metadata.Language;
                    hasContent = true;
                }
                else if (packageInfo.ProjectOptions.NuGetOptions.NuSpecOptions.Metadata.Copyright.Save &&
                         (lineContent.StartsWith(StringUtil.Join(projectInformation.Copyright,
                                                                 Definitions.Constants.AssemblyContentStart)) ||
                          lineContent.StartsWith(StringUtil.Join(projectInformation.Copyright,
                                                                 Definitions.Constants.AssemblyAttributeAddition,
                                                                 Definitions.Constants.AssemblyContentStart))))
                {
                    content    = packageInfo.NuSpecPackage.Metadata.Copyright;
                    hasContent = true;
                }

                //use the content we created here
                if (hasContent)
                {
                    return(string.Format("{0}{1}{2}",
                                         StringUtil.Substring(line, 0, line.IndexOf(Definitions.Constants.AssemblyContentStart) + Definitions.Constants.AssemblyContentStart.Length - 1),
                                         content,
                                         StringUtil.Substring(line, line.LastIndexOf(Definitions.Constants.AssemblyContentEnd), line.Length - 1)));
                }

                return(line);
            }
            else
            {
                return(line);
            }
        }
Exemplo n.º 7
0
 /**版本号 t 可选为 0,1,2, 3 分别表示获得 v1, v2, v3, v4 版号*/
 public static string GetVersion(string ver, int t = 0)
 {
     return(VersionUtil.GetVersion(ver, t));
 }
Exemplo n.º 8
0
        public void Generate()
        {
            // header
            Output.WriteLine(
                "<p>This page contains the API documentation for this MPExtended service, as automatically generated on {0} for version {1} (build {2}). " +
                "Please do not edit, as your changes will be overwritten.</p>",
                DateTime.Now.ToString("dd MMM yyy HH:mm", System.Globalization.CultureInfo.InvariantCulture),
                VersionUtil.GetVersion(Assembly),
                VersionUtil.GetBuildVersion(Assembly));

            UserStream.WriteLine("Generating documentation for assembly {0}", Assembly.GetName().Name);

            // get all items
            IEnumerable <DocGenItem> typesToDocument = new List <DocGenItem>();

            if (JsonAPI != null)
            {
                typesToDocument = JsonAPI.GetMethods().Select(x => new DocGenItem()
                {
                    URLPrefix = "/json",
                    Reflected = x,
                    Name      = x.Name,
                    Order     = GenerateSortOrder(x.Name)
                });
            }
            if (StreamAPI != null)
            {
                typesToDocument = typesToDocument.Union(StreamAPI.GetMethods().Select(x => new DocGenItem()
                {
                    URLPrefix = "/stream",
                    Reflected = x,
                    Name      = x.Name,
                    Order     = GenerateSortOrder(x.Name)
                }));
            }
            if (Enumerations != null)
            {
                typesToDocument = typesToDocument.Union(Enumerations.Select(x => new DocGenItem()
                {
                    URLPrefix = "",
                    Reflected = x,
                    Name      = x.Name,
                    Order     = GenerateSortOrder(x.Name),
                }));
            }

            // sort all types
            typesToDocument = typesToDocument
                              .OrderBy(x => x.Order)
                              .ThenBy(x => x.Name);

            // print navigation
            int lastOrder = -1;

            UserStream.WriteLine("=> Generating documentation header");
            Output.WriteLine("<h3>Navigation</h3>");
            foreach (var item in typesToDocument)
            {
                if (lastOrder != item.Order)
                {
                    if (lastOrder != -1)
                    {
                        Output.WriteLine("</ul>");
                    }
                    Output.WriteLine("<h4>{0}</h4><ul>", GetHeadings()[item.Order]);
                    lastOrder = item.Order;
                }
                Output.WriteLine("<li><a href=\"#{0}\">{0}</a></li>", item.Name);
            }
            Output.WriteLine("</ul>");

            // generate all documentation
            lastOrder = -1;
            foreach (var item in typesToDocument)
            {
                if (lastOrder != item.Order)
                {
                    Output.WriteLine(String.Format("<h3>{0}</h3>", GetHeadings()[item.Order]));
                    lastOrder = item.Order;
                }

                if (item.Reflected is MethodInfo)
                {
                    GenerateMethodDocumentation(item.Reflected as MethodInfo, item.URLPrefix);
                }
                else if (item.Reflected is Type)
                {
                    GenerateEnumDocumentation(item.Reflected as Type);
                }
            }
            UserStream.WriteLine("=> Done");

            Output.Flush();
            Output.Close();
        }
Exemplo n.º 9
0
 public AboutWindow()
 {
     Telemetry.Instance.Native?.TrackPageView("About");
     InitializeComponent();
     ucVersion.Text = VersionUtil.GetVersion();
 }
 public override string GetVersion() => VersionUtil.GetVersion <ToggleableBindings>();
Exemplo n.º 11
0
 public override string GetVersion() => VersionUtil.GetVersion <QoL>();