//Could be serialized to a class that binds to the UI //Could use a json instad than XML private void DownloadUpdateComplete(object sender, DownloadStringCompletedEventArgs e) { try { if (e.Error == null) { var document = XDocument.Parse(e.Result); string version = document.Element("Bcfier").Element("Version").Value; if (System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.CompareTo(Version.Parse(version)) < 0) { var dialog = new NewVersion(); dialog.Description.Text = "Version " + version + " is available,\ndo you want to check it out now?"; dialog.NewFeatures.Text = document.Element("Bcfier").Element("Changelog").Element("NewFeatures").Value; dialog.BugFixes.Text = document.Element("Bcfier").Element("Changelog").Element("BugFixes").Value; dialog.WindowStartupLocation = WindowStartupLocation.CenterScreen; dialog.ShowDialog(); if (dialog.DialogResult.HasValue && dialog.DialogResult.Value) { Process.Start(document.Element("Bcfier").Element("URL").Value); } } } } catch (System.Exception ex1) { //warning suppressed Console.WriteLine("exception: " + ex1); } }
private async void GetReleaseNotes() { try { ReleaseNotes = "Loading..."; var originalLength = File.ReadAllLines("release_notes.txt").Length; var newVersion = NewVersion.ToString().Replace('.', '_'); var url = ApplicationDeployment.CurrentDeployment.UpdateLocation; var baseUrl = url.AbsoluteUri.Remove(url.AbsoluteUri.Length - url.Segments.Last().Length); var notesUri = $"{baseUrl}Application%20Files/ShadowClip_{newVersion}/release_notes.txt.deploy"; var client = new HttpClient(); var newReleaseNotes = await client.GetStringAsync(notesUri); var lines = newReleaseNotes.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); var newLineCount = lines.Length - originalLength; var notesSinceLastUpdate = string.Join(Environment.NewLine, lines.Take(newLineCount)); ReleaseNotes = notesSinceLastUpdate; } catch (Exception e) { ReleaseNotes = $"Error Loading Release Notes: {e.Message}"; } }
private void upDate(object source, NewVersion e) { this.Dispatcher.Invoke(() => updateDialog.IsOpen = true); FileUpdate = e.GetFileName(); //MessageBox.Show(e.GetFileName()); }
public static bool HasUpdate() { GetUpdate(); Assembly CurentAssembly = Assembly.LoadFrom("LSExtendedWarrenty.dll"); Version CurrentVersion = CurentAssembly.GetName().Version; Assembly NewAssembly; Version NewVersion; try { NewAssembly = Assembly.LoadFrom("Repository\\LSExtendedWarrenty.dll"); NewVersion = NewAssembly.GetName().Version; } catch (System.IO.FileNotFoundException) { return(false); } try { int CurrentVersionVal = Int32.Parse(CurrentVersion.ToString().Replace(".", "")); int NewVersionVal = Int32.Parse(NewVersion.ToString().Replace(".", "")); if (CurrentVersionVal < NewVersionVal) { return(true); } } catch (Exception) { return(false); } return(false); }
private async void CheckUpdates() { try { var cancel = new CancellationTokenSource(); var release = await GitHubRest.GetLatestRelease(cancel); if (release == null) { return; } string version = release.tag_name.Replace("v", ""); if (System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.CompareTo(Version.Parse(version)) < 0 && release.assets.Any()) { var dialog = new NewVersion(); dialog.WindowStartupLocation = WindowStartupLocation.CenterScreen; dialog.Description.Text = release.name + " has been released on " + release.published_at.ToLongDateString() + "\ndo you want to check it out now?"; //dialog.NewFeatures.Text = document.Element("Bcfier").Element("Changelog").Element("NewFeatures").Value; //dialog.BugFixes.Text = document.Element("Bcfier").Element("Changelog").Element("BugFixes").Value; //dialog.WindowStartupLocation = WindowStartupLocation.CenterScreen; dialog.ShowDialog(); if (dialog.DialogResult.HasValue && dialog.DialogResult.Value) { Process.Start(release.assets.First().browser_download_url); } } } catch (System.Exception ex1) { //warning suppressed Console.WriteLine("exception: " + ex1); } }
private async void RunInternal() { string manifestContent = await DownloadManifestContent(); if (manifestContent == null) { return; } JObject manifest = ParseManifestContent(manifestContent); if (manifest == null) { return; } if (DetermineVersionAndArchiveName(manifest, out Version version, out string archiveName) == false) { return; } if (version > App.Version) { await dispatcher.BeginInvoke((Action) delegate { var downloadUrl = new Uri(DownloadBaseUrl + archiveName, UriKind.Absolute); NewVersion?.Invoke(this, new NewVersionEventArgs(version, downloadUrl)); }); } }
private bool FindUpdate(HttpClient client, bool forced, out NewVersion newVersion) { try { var smallestVersion = FindSmallestExiledVersion(); Log.Info($"Found the smallest version of Exiled - {smallestVersion.Library.GetName().Name}:{smallestVersion.Version}"); // TODO: make it loop pages to find an update var releases = TagReleases(client.GetReleases(REPOID, new GetReleasesSettings(50, 1)).GetAwaiter().GetResult()); if (FindRelease(releases, out var targetRelease, smallestVersion, forced)) { if (!FindAsset(GetInstallerName(), targetRelease, out var asset)) { // Error: no asset Log.Warn("Couldn't find the asset, the update will not be installed"); } else { Log.Info($"Found asset - Name: {asset.Name} | Size: {asset.Size} Download: {asset.BrowserDownloadUrl}"); newVersion = new NewVersion(targetRelease, asset); return(true); } } else { // No errors Log.Info("No new versions found, you're using the most recent version of Exiled!"); } }
private static void AsyncCheckVersion(object foo) { Exception error = null; bool manual = (bool)foo; if (UrlManager.UpdateMain != null) { error = null; try { CheckSite(UrlManager.UpdateMain, manual); } //official https catch (Exception ex1) { error = ex1; if (UrlManager.UpdateMirror != null) { error = null; try { CheckSite(UrlManager.UpdateMirror, manual); } //http mirror catch (Exception ex2) { error = ex2; } } } } else if (UrlManager.UpdateMirror != null) //only mirror configured { error = null; try { CheckSite(UrlManager.UpdateMirror, manual); } //http mirror catch (Exception ex3) { error = ex3; } } if (error != null && manual) { NewVersion?.Invoke(null, null, error); } }
public bool HasNewVersion() { if (string.IsNullOrEmpty(NewVersion)) { return(false); } if (string.IsNullOrEmpty(Version)) { return(true); } var tempList = Version.Split('.'); var newTemplist = NewVersion.Split('.'); for (int i = 0; i < tempList.Length; i++) { var old = TypeParse.StrToInt(tempList[i]); var newValue = TypeParse.StrToInt(newTemplist[i]); if (newValue > old) { return(true); } if (newTemplist.Length - 1 <= i) { return(false); } } if (newTemplist.Length > tempList.Length) { return(true); } return(false); }
public VersionForm(NewVersion version) { InitializeComponent(); CurrentVersionLabel.Text = Assembly.GetExecutingAssembly().GetName().Version.ToString(); NewVersionLabel.Text = version.Version; UpdateMessageTextBox.Text = version.Message; }
/// <summary> /// Updates an existing setting for a role with the predetermined value /// </summary> public void UpdateSettingForRole(string settingName, string settingValue, string roleName) { NewVersion.Descendants(name: Namespaces.NsServiceManagement + "Role").FirstOrDefault( a => (string)a.Attribute("name") == roleName) .Descendants(Namespaces.NsServiceManagement + "Setting").FirstOrDefault( b => (string)b.Attribute("name") == settingName) .SetAttributeValue("value", settingValue); }
public override async void OnReceive(Context context, Intent intent) { try { if (!SimpleIoc.Default.IsRegistered <IApplicationService>()) { Log.Info("VERSION", "Application service not registered. Registering new instance..."); SimpleIoc.Default.Register <IApplicationService, ApplicationService>(); } NewVersion version = await VersionService.CheckForUpdates(); if (version != null) { string message = intent.GetStringExtra("message"); string title = intent.GetStringExtra("title"); Intent notificationIntent = new Intent(Intent.ActionView); notificationIntent.SetData(Android.Net.Uri.Parse(version.ReleaseUrl)); PendingIntent pending = PendingIntent.GetActivity(context, 0, notificationIntent, PendingIntentFlags.CancelCurrent | PendingIntentFlags.Immutable); NotificationManager manager = NotificationManager.FromContext(context); if (Build.VERSION.SdkInt >= BuildVersionCodes.O) { NotificationChannel notificationChannel = new NotificationChannel(CHANNEL_ID, "My Notifications", NotificationImportance.Max); // Configure the notification channel. notificationChannel.Description = "Channel description"; notificationChannel.EnableLights(true); notificationChannel.LightColor = Color.AliceBlue; notificationChannel.SetVibrationPattern(new long[] { 0, 1000, 500, 1000 }); notificationChannel.EnableVibration(true); manager.CreateNotificationChannel(notificationChannel); } Notification.Builder builder = new Notification.Builder(context, CHANNEL_ID) .SetContentTitle(title) .SetContentText(message) .SetSmallIcon(Resource.Drawable.icon); builder.SetContentIntent(pending); Notification notification = builder.Build(); manager.Notify(1337, notification); } } catch (Exception ex) { Log.Error("VERSION", ex.Message); } //PendingIntent pendingz = PendingIntent.GetBroadcast(context, 0, intent, PendingIntentFlags.UpdateCurrent); //AlarmManager alarmManager = context.GetSystemService(Context.AlarmService).JavaCast<AlarmManager>(); //alarmManager.SetExact(AlarmType.ElapsedRealtimeWakeup, SystemClock.ElapsedRealtime() + 10 * 1000, pendingz); }
public int CompareTo(ManifestVersionUpdate?other) { if (other == null) { return(1); } int ret = ManifestId.CompareTo(other.ManifestId); if (ret != 0) { return(ret); } if (ExistingVersion == null && other.ExistingVersion != null) { return(-1); } if (ExistingVersion != null && other.ExistingVersion == null) { return(1); } if (ExistingVersion != null) { ret = ExistingVersion.CompareTo(other.ExistingVersion); if (ret != 0) { return(ret); } } ret = string.Compare(ExistingFeatureBand, other.ExistingFeatureBand, StringComparison.Ordinal); if (ret != 0) { return(ret); } if (NewVersion == null && other.NewVersion != null) { return(-1); } if (NewVersion != null && other.NewVersion == null) { return(1); } if (NewVersion != null) { ret = NewVersion.CompareTo(other.NewVersion); if (ret != 0) { return(ret); } } ret = string.Compare(NewFeatureBand, other.NewFeatureBand, StringComparison.Ordinal); return(ret); }
private void BtnEdit_Click(object sender, RoutedEventArgs e) { Models.Version selectedVersion = Project.Versions.Single(version => version.Id == selectedVersionId); NewVersion dialog = new NewVersion(provider.GetDefaultVersionSettings(), selectedVersion); if (dialog.ShowDialog().Value) { Project.Versions[Project.Versions.IndexOf(selectedVersion)] = dialog.Version; LoadVersions(); } }
public Version CreateVersion(NewVersion newVersion) { var request = new RestRequest() { Resource = ResourceUrls.Version(), RequestFormat = DataFormat.Json, Method = Method.POST }; request.AddBody(newVersion); return(Execute <Version>(request, HttpStatusCode.Created)); }
private static void CheckSite(string site, bool manual) { using (System.Net.WebClient wc = new System.Net.WebClient()) { wc.Headers.Add("User-Agent: .Net WebClient"); string json = wc.DownloadString(site); List <OnlineVersion> versions = Tools.JSONParser.FromJson <List <OnlineVersion> >(json); bool build = Settings.GetObject("Auto Update Build", false) || manual; bool pre = Settings.GetObject("Auto Update Pre", false); Version current = typeof(GitHub).Assembly.GetName().Version; OnlineVersion found = null; foreach (OnlineVersion ov in versions) //version start with higher first { if (!ov.IsValid) //skip invalid { continue; } if (!pre && ov.IsPreRelease) //skip pre-release { continue; } if (!build && ov.Version.Build != 0) //skip build version (only update to minor number change) { continue; } if (found != null && ov.Version < found.Version) //already found a better match { continue; } if (ov.Version > current) { found = ov; } } if (found != null) { NewVersion?.Invoke(current, found, null); } else if (manual) //notify "no new version" { NewVersion?.Invoke(current, null, null); } } }
private static void CheckSite(string site) { using (System.Net.WebClient wc = new System.Net.WebClient()) { wc.Headers.Add("User-Agent: .Net WebClient"); string json = wc.DownloadString(site); string url = null; string versionstr = null; string name = null; foreach (Match m in Regex.Matches(json, @"""browser_download_url"":""([^""]+)""")) { if (url == null) { url = m.Groups[1].Value; } } foreach (Match m in Regex.Matches(json, @"""tag_name"":""v([^""]+)""")) { if (versionstr == null) { versionstr = m.Groups[1].Value; } } foreach (Match m in Regex.Matches(json, @"""name"":""([^""]+)""")) { if (name == null) { name = m.Groups[1].Value; } } Version current = typeof(GitHub).Assembly.GetName().Version; Version latest = new Version(versionstr); if (current < latest) { bool minor = Settings.GetObject("Auto Update", false); bool build = Settings.GetObject("Auto Update Build", false); if ((current.Major != latest.Major) || (current.Minor != latest.Minor && minor) || (current.Build != latest.Build && build)) { NewVersion?.Invoke(current, latest, name, url); } } } }
public static void NewVersion(this CloudShellContext context, NewVersionSettings settings) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (settings == null) { throw new ArgumentNullException(nameof(settings)); } var resolver = BuildResolver(context); var runner = new NewVersion(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools, resolver); runner.Execute(settings); }
public void CommandNewVersion(string version) { Version = version; NewVersion?.Invoke(this, null); }
public void IncrementAssemblyFileVersion(CommandLineArgs cmdArgs) { if (cmdArgs is null) { throw new ArgumentNullException(nameof(cmdArgs)); } if (!File.Exists(cmdArgs.FilePath)) { throw new OperationFailedException($"File {cmdArgs.FilePath} not found."); } this.CsprojFileName = Path.GetFileName(cmdArgs.FilePath); XName FileVersion = "FileVersion"; XElement csproj; try { csproj = System.Xml.Linq.XElement.Load(cmdArgs.FilePath); } catch (Exception e) { throw new OperationFailedException($"Unable to parse {CsprojFileName} as XML.", e); } if (csproj.Attribute("Sdk") is null) { throw new OperationFailedException($"{CsprojFileName} is not a Sdk-style project file."); } var propertyGroups = csproj.Elements().Where(x => x.Name == "PropertyGroup"); if (!propertyGroups.Any()) { throw new OperationFailedException($"{CsprojFileName} contains no <PropertyGroup>."); } XElement?fileVersion = propertyGroups.FirstOrDefault(x => x.Elements().Any(x => x.Name == FileVersion))?.Element(FileVersion); if (fileVersion is null) { //throw new OperationFailedException( // $"There is no <FileVersion>-Property in {CsprojFileName}. Open the project file and add <FileVersion>1.0.0.0</FileVersion> to the first <PropertyGroup>."); fileVersion = new XElement(FileVersion) { Value = "1.0.0.0" }; propertyGroups.First().Add(fileVersion); this.NewVersion = new Version(1, 0, 0, 0); } else if (fileVersion.Value.Length == 0) { fileVersion.Value = "1.0.0.0"; this.NewVersion = new Version(1, 0, 0, 0); this.OldVersion = new Version(); } else { try { string?[] parts = fileVersion.Value.Split('-', 2, StringSplitOptions.None); this.OldVersion = new Version(parts[0] !); if (cmdArgs.IncrementRevision) { this.NewVersion = new Version(OldVersion.Major, OldVersion.Minor, Math.Max(0, OldVersion.Build), OldVersion.Revision + 1); } else { this.NewVersion = new Version(OldVersion.Major, OldVersion.Minor, OldVersion.Build + 1, Math.Max(0, OldVersion.Revision)); } if (parts.Length == 2) { fileVersion.Value = $"{NewVersion.ToString(4)}-{parts[1]}"; } else { fileVersion.Value = NewVersion.ToString(4); } } catch (Exception e) { throw new OperationFailedException("Can't parse <FileVersion> as System.Version.", e); } } try { File.WriteAllText(cmdArgs.FilePath, csproj.ToString()); } catch (Exception e) { throw new OperationFailedException($"Can't write changes to {CsprojFileName}.", e); } }
private static async void AsyncCheckVersion(int retry = 0) { var http = new HttpClient { BaseAddress = new Uri(versionURI) }; var json = JsonSerializer.Create(); var cachedVersion = GetCachedVersion(out var notify); var req = string.Empty; try { req = await http.GetStringAsync(string.Empty); } catch (HttpRequestException e) { Console.WriteLine("[Updater] Failed to get current version. Caused by"); Console.WriteLine(e.ToString()); if (retry < netRetryCount) { AsyncCheckVersion(retry + 1); return; } } VersionUpdate update = new VersionUpdate(); try { using (JsonTextReader jsonReader = new JsonTextReader(new StringReader(req))) { update = json.Deserialize <VersionUpdate>(jsonReader); } } catch (Exception) { Console.WriteLine("Failed to read current version info."); return; } var currentVer = Version.Parse(update.Version); var cacheValidTo = DateTime.UtcNow + update.CacheDuration; if (currentVer == null || cachedVersion >= currentVer) { currentVer = cachedVersion; } if (currentVer > LauncherVersion) { var args = new VersionUpdateEventArgs(update); NewVersion?.Invoke(null, args); if (notify) { NotifyNewVersion?.Invoke(null, args); notify = false; } } WriteVersionCache(notify, currentVer, cacheValidTo); }
public VersionForm(NewVersion version) { InitializeComponent(); _version = version; }
/// <summary> /// Merges the data. /// </summary> public void MergeData( ) { IProcessingContext context = Context; OldVersion.Setup(context); NewVersion.Setup(context); Target.Setup(context); context.WriteInfo("Loading package..."); _oldApp = AppContents.Load(OldVersion, context); context.WriteInfo("Loading tenant data..."); _newApp = AppContents.Load(NewVersion, context); context.WriteInfo("Processing entities..."); // Entities that the application explicitly does not want to delete ISet <Guid> doNotRemove = _newApp.DoNotRemove; ///// // Detect entity changes ///// List <EntityEntry> addedEntities, removedEntities, changedEntities, unchangedEntities; HashSet <Guid> removedEntitiesSet; long tenantId = -1; TenantMergeTarget tenantMergeTarget = Target as TenantMergeTarget; if (tenantMergeTarget != null) { tenantId = tenantMergeTarget.TenantId; } Guid isTenantDisabled = new Guid("11209a07-9189-4099-b609-80ed1d4f3e56"); Func <EntityEntry, bool> removeEntityAction = e => { if (tenantId == 0 && e.EntityId == isTenantDisabled) { EventLog.Application.WriteWarning("Attempt to delete the entity 'isTenantDisabled' from the global tenant has been prevented."); return(false); } return(true); }; Diff.DetectChanges(_oldApp.Entities, _newApp.Entities, null, null, removeEntityAction, null, null, out addedEntities, out removedEntities, out changedEntities, out unchangedEntities); // Suppress removal of entites that are flagged as 'do not remove' // removedEntities contains list of entities that we will actually remove removedEntities.RemoveAll(entityEntry => doNotRemove.Contains(entityEntry.EntityId)); // Capture raw set of entities that are being removed (excluding the doNotRemove ones) removedEntitiesSet = new HashSet <Guid>(removedEntities.Select(entityEntry => entityEntry.EntityId)); Context.Report.AddedEntities = addedEntities; Context.Report.RemovedEntities = removedEntities; Context.Report.UpdatedEntities = changedEntities; if (_oldApp.Entities != null) { Context.Report.Counts.Add(new StatisticsCount("Previous Application Entities", _oldApp.Entities.Count, StatisticsCountType.PreviousApplication)); } if (_newApp.Entities != null) { Context.Report.Counts.Add(new StatisticsCount("Current Application Entities", _newApp.Entities.Count, StatisticsCountType.CurrentApplication)); } Context.Report.Counts.Add(new StatisticsCount("Added Entities", addedEntities.Count, StatisticsCountType.Added)); Context.Report.Counts.Add(new StatisticsCount("Removed Entities", removedEntities.Count, StatisticsCountType.Removed)); Context.Report.Counts.Add(new StatisticsCount("Updated Entities", changedEntities.Count, StatisticsCountType.Updated)); Context.Report.Counts.Add(new StatisticsCount("Unchanged Entities", unchangedEntities.Count, StatisticsCountType.Unchanged)); ///// // Apply entity changes // note: 'changedEntities' is always empty ///// Target.WriteEntities(addedEntities, context); context.WriteInfo("Processing relationships..."); ///// // Detect relationship changes ///// List <RelationshipEntry> addedRelationships, removedRelationships, changedRelationships, unchangedRelationships; var changeAction = new Func <RelationshipEntry, RelationshipEntry, bool>((o, n) => { if (n.Cardinality == CardinalityEnum_Enumeration.ManyToOne) { n.PreviousValue = o.ToId; return(true); } if (n.Cardinality == CardinalityEnum_Enumeration.OneToMany) { n.PreviousValue = o.FromId; return(true); } if (n.Cardinality == CardinalityEnum_Enumeration.OneToOne) { if (o.FromId == n.FromId) { n.PreviousValue = o.ToId; n.UpdateTo = true; n.UpdateFrom = false; } else { n.PreviousValue = o.FromId; n.UpdateTo = false; n.UpdateFrom = true; } } return(true); }); Func <RelationshipEntry, bool> removeRelationshipAction = e => { if (tenantId == 0) { if (e.FromId == isTenantDisabled) { EventLog.Application.WriteWarning("Attempt to delete relatiosnhip from 'isTenantDisabled' in the global tenant has been prevented."); return(false); } if (e.ToId == isTenantDisabled) { EventLog.Application.WriteWarning("Attempt to delete relationship to 'isTenantDisabled' in the global tenant has been prevented."); return(false); } } return(true); }; Diff.DetectChanges(_oldApp.Relationships, _newApp.Relationships, _oldApp.MissingRelationships, null, removeRelationshipAction, changeAction, null, out addedRelationships, out removedRelationships, out changedRelationships, out unchangedRelationships); // Don't remove relationship content for entities that are flagged as 'do not delete' (unless the other end is being deleted) removedRelationships.RemoveAll(relationshipEntry => { if (!(doNotRemove.Contains(relationshipEntry.ToId) || doNotRemove.Contains(relationshipEntry.FromId))) { return(false); // neither end is in the 'do not remove' list, so just carry on with the deletion (by leaving the row in the removal collection) } // Always allow apps to remove their association to an entity if (relationshipEntry.TypeId == Guids.InSolution || relationshipEntry.TypeId == Guids.IndirectInSolution) { return(false); } // If the other end of the relationship (or the relationship type) is being deleted, then delete the relationship instance anyway if (removedEntitiesSet.Contains(relationshipEntry.ToId)) { return(false); } if (removedEntitiesSet.Contains(relationshipEntry.FromId)) { return(false); } if (removedEntitiesSet.Contains(relationshipEntry.TypeId)) { return(false); } return(true); // the relationship is partly in the do-not-remove list, and the other end is not being removed, so don't delete this relationship }); Context.Report.AddedRelationships = addedRelationships; Context.Report.RemovedRelationships = removedRelationships; Context.Report.UpdatedRelationships = changedRelationships; if (_oldApp.Relationships != null) { Context.Report.Counts.Add(new StatisticsCount("Previous Application Relationships", _oldApp.Relationships.Count, StatisticsCountType.PreviousApplication)); } if (_newApp.Relationships != null) { Context.Report.Counts.Add(new StatisticsCount("Current Application Relationships", _newApp.Relationships.Count, StatisticsCountType.CurrentApplication)); } Context.Report.Counts.Add(new StatisticsCount("Added Relationships", addedRelationships.Count, StatisticsCountType.Added)); Context.Report.Counts.Add(new StatisticsCount("Removed Relationships", removedRelationships.Count, StatisticsCountType.Removed)); Context.Report.Counts.Add(new StatisticsCount("Updated Relationships", changedRelationships.Count, StatisticsCountType.Updated)); Context.Report.Counts.Add(new StatisticsCount("Unchanged Relationships", unchangedRelationships.Count, StatisticsCountType.Unchanged)); ///// // Apply relationship changes ///// Target.UpdateRelationships(changedRelationships, context); Target.WriteRelationships(addedRelationships, context); Target.PreDeleteEntities(removedEntities, context); Target.DeleteRelationships(removedRelationships, context); Target.DeleteEntities(removedEntities, context); ///// // Invalidate all per-tenant caches at this point. // This is to ensure caches that are holding onto type information are flushed. ///// InvalidatePerTenantCaches(tenantId); Func <DataEntry, bool> removedAction = de => { if (de != null) { if (tenantId == 0 && de.EntityId == isTenantDisabled) { EventLog.Application.WriteWarning("Attempt to delete field on entity 'isTenantDisabled' in the global tenant has been prevented."); return(false); } } return(true); }; Func <DataEntry, DataEntry, bool> changedAction = (oldVal, newVal) => { newVal.ExistingData = oldVal.Data; return(true); }; ///// // Detect and apply data changes ///// foreach (string dataTable in Helpers.FieldDataTables) { context.WriteInfo($"Processing '{dataTable}'..."); List <DataEntry> addedData, removedData, changedData, unchangedData; Dictionary <Tuple <Guid, Guid>, DataEntry> oldData = _oldApp.FieldData[dataTable]; Dictionary <Tuple <Guid, Guid>, DataEntry> missingData = _oldApp.MissingFieldData; Dictionary <Tuple <Guid, Guid>, DataEntry> newData = _newApp.FieldData[dataTable]; Diff.DetectChanges(oldData, newData, missingData, null, removedAction, changedAction, null, out addedData, out removedData, out changedData, out unchangedData); // Don't remove content for entities that are tagged as 'do not delete' removedData.RemoveAll(dataEntry => _newApp.DoNotRemove.Contains(dataEntry.EntityId)); context.Report.AddedEntityData[dataTable] = addedData; context.Report.RemovedEntityData[dataTable] = removedData; context.Report.UpdatedEntityData[dataTable] = changedData; if (oldData != null) { Context.Report.Counts.Add(new StatisticsCount($"Previous Application {dataTable} Data", oldData.Count, StatisticsCountType.PreviousApplication)); } if (newData != null) { Context.Report.Counts.Add(new StatisticsCount($"Current Application {dataTable} Data", newData.Count, StatisticsCountType.CurrentApplication)); } Context.Report.Counts.Add(new StatisticsCount($"Added {dataTable} Data", addedData.Count, StatisticsCountType.Added)); Context.Report.Counts.Add(new StatisticsCount($"Removed {dataTable} Data", removedData.Count, StatisticsCountType.Removed)); Context.Report.Counts.Add(new StatisticsCount($"Updated {dataTable} Data", changedData.Count, StatisticsCountType.Updated)); Context.Report.Counts.Add(new StatisticsCount($"Unchanged {dataTable} Data", unchangedData.Count, StatisticsCountType.Unchanged)); Target.WriteFieldData(dataTable, addedData, context); Target.DeleteFieldData(dataTable, removedData, context); Target.UpdateFieldData(dataTable, changedData, context); } context.WriteInfo("Processing binary data..."); ///// // Detect binary data changes ///// List <BinaryDataEntry> addedbinaryData, removedBinaryData, changedBinaryData, unchangedBinaryData; Diff.DetectChanges(_oldApp.BinaryData, _newApp.BinaryData, null, null, null, null, null, out addedbinaryData, out removedBinaryData, out changedBinaryData, out unchangedBinaryData); context.Report.AddedBinaryData = addedbinaryData; context.Report.RemovedBinaryData = removedBinaryData; context.Report.UpdatedBinaryData = changedBinaryData; if (_oldApp.BinaryData != null) { Context.Report.Counts.Add(new StatisticsCount("Previous Application Binary Data", _oldApp.BinaryData.Count, StatisticsCountType.PreviousApplication)); } if (_newApp.BinaryData != null) { Context.Report.Counts.Add(new StatisticsCount("Current Application Binary Data", _newApp.BinaryData.Count, StatisticsCountType.CurrentApplication)); } Context.Report.Counts.Add(new StatisticsCount("Added Binary Data", addedbinaryData.Count, StatisticsCountType.Added)); Context.Report.Counts.Add(new StatisticsCount("Removed Binary Data", removedBinaryData.Count, StatisticsCountType.Removed)); Context.Report.Counts.Add(new StatisticsCount("Updated Binary Data", changedBinaryData.Count, StatisticsCountType.Updated)); Context.Report.Counts.Add(new StatisticsCount("Unchanged Binary Data", unchangedBinaryData.Count, StatisticsCountType.Unchanged)); ///// // Apply binary changes ///// Target.WriteBinaryData(addedbinaryData, context); // Update before delete. This is to ensure that if any files have the IsReferencedExternally flag set // that they will not be deleted. Target.UpdateBinaryData(changedBinaryData, context); Target.DeleteBinaryData(removedBinaryData, context); context.WriteInfo("Processing document data..."); ///// // Detect binary data changes ///// List <DocumentDataEntry> addedDocumentData, removedDocumentData, changedDocumentData, unchangedDocumentData; Diff.DetectChanges(_oldApp.DocumentData, _newApp.DocumentData, null, null, null, null, null, out addedDocumentData, out removedDocumentData, out changedDocumentData, out unchangedDocumentData); context.Report.AddedDocumentData = addedDocumentData; context.Report.RemovedDocumentData = removedDocumentData; context.Report.UpdatedDocumentData = changedDocumentData; if (_oldApp.DocumentData != null) { Context.Report.Counts.Add(new StatisticsCount("Previous Application Document Data", _oldApp.DocumentData.Count, StatisticsCountType.PreviousApplication)); } if (_newApp.DocumentData != null) { Context.Report.Counts.Add(new StatisticsCount("Current Application Document Data", _newApp.DocumentData.Count, StatisticsCountType.CurrentApplication)); } Context.Report.Counts.Add(new StatisticsCount("Added Document Data", addedDocumentData.Count, StatisticsCountType.Added)); Context.Report.Counts.Add(new StatisticsCount("Removed Document Data", removedDocumentData.Count, StatisticsCountType.Removed)); Context.Report.Counts.Add(new StatisticsCount("Updated Document Data", changedDocumentData.Count, StatisticsCountType.Updated)); Context.Report.Counts.Add(new StatisticsCount("Unchanged Document Data", unchangedDocumentData.Count, StatisticsCountType.Unchanged)); ///// // Apply binary changes ///// Target.WriteDocumentData(addedDocumentData, context); Target.UpdateDocumentData(changedDocumentData, context); Target.DeleteDocumentData(removedDocumentData, context); Target.TearDown(context); NewVersion.TearDown(context); OldVersion.TearDown(context); }
private string GetDownloadFileName() { string ext = url.Split('/').Last().Split('.').Last(); return(NewVersion.ToString() + "." + ext); }
private void CSVDownloadComplete(object sender, EventArgs e) { Dictionary <string, string> values = new Dictionary <string, string>(); string[] lines = File.ReadAllLines(CSVFile); foreach (string line in lines) { var lineValues = line.Split(','); values.Add(lineValues[0], lineValues[1]); } File.Delete(CSVFile); string os = ""; OperatingSystem os_info = Environment.OSVersion; PlatformID pid = os_info.Platform; switch (pid) { case PlatformID.Unix: os = "lin"; break; case PlatformID.MacOSX: os = "mac"; break; case PlatformID.Win32NT: os = "win"; if (Utils.Is64BitOperatingSystem) { os += ".64"; } else { os += ""; } break; default: break; } TrailerURL = "dQw4w9WgXcQ"; foreach (KeyValuePair <string, string> item in values) { if (item.Key == "curVerNum." + os) { NewVersion = Version.CreateFromString(item.Value); values.TryGetValue("URL." + os, out DownloadURL); } if (item.Key == "trailerID") { TrailerURL = item.Value; } } pbTrailer.LoadAsync("http://img.youtube.com/vi/" + TrailerURL + "/0.jpg"); if (!string.IsNullOrEmpty(TrailerURL)) { pbTrailer.Cursor = Cursors.Hand; } updateUI(); if (hasUpdate()) { MessageBox.Show("New Update for " + GameName + "\nNew Version: " + NewVersion.ToString() + "\nCurrent Installed Version: " + getVersionInstalled().ToString()); } if (JeremieLauncher.instance.index == index) { if (UpToDate()) { JeremieLauncher.instance.pb_gif.Image = Properties.Resources.no_update; } else { JeremieLauncher.instance.pb_gif.Image = Properties.Resources.update; } } }
void CheckVersion() { NewVersionTask .ContinueWith(t => { var updateInfo = t.Result; if (updateInfo == null) return; linkLabelNewVersion.Invoke((Action)delegate { const string prefix = "New version available: "; linkLabelNewVersion.Text = prefix + updateInfo.Version; linkLabelNewVersion.Links.Add(prefix.Length, linkLabelNewVersion.Text.Length - prefix.Length, null); linkLabelNewVersion.LinkClicked -= ComposeFeedback; linkLabelNewVersion.LinkClicked += (s, e) => Process.Start(t.Result.DownloadUri.OriginalString); }); var changeLines = updateInfo.ChangeLog.Replace("\r\n", "\n").Replace("\n\r", "\n").Replace("\r", "\n").Split('\n'); try { var currentVersion = new SoftwareVersion.SoftwareVersion(ForcedProductVersion ?? ProductVersion); var verRx = @"^\s*" + string.Join("\\.", currentVersion.VersionComponents.Take(2).Select(c => c.Component)) + @"\s*$"; var rx = new Regex(verRx); changeLines = changeLines.TakeWhile(l => !rx.IsMatch(l)).ToArray(); } catch(Exception ex) { Logger.LogIt(ex.ToString()); } if (changeLines.Length > 50) changeLines = changeLines.Take(20).Concat(new [] { "\n", " ..." }).ToArray(); linkLabelNewVersion.Invoke((Action)(() => { toolTip.SetToolTip(linkLabelNewVersion, string.Join("\n", changeLines)); if (!string.IsNullOrWhiteSpace(Settings.Default.MutedVersion)) { var latestVersion = new SoftwareVersion.SoftwareVersion(updateInfo.Version); var mutedVersion = new SoftwareVersion.SoftwareVersion(Settings.Default.MutedVersion); if (mutedVersion.CompareTo(latestVersion) >= 0) return; } var dlg = new NewVersion(updateInfo.Version, t.Result.DownloadUri.OriginalString, changeLines); dlg.OnMute += mute => { Settings.Default.MutedVersion = mute ? updateInfo.Version : ""; Settings.Default.Save(); }; dlg.Show(this); })); }, TaskContinuationOptions.OnlyOnRanToCompletion); }
internal static void Run( Edition plasticEdition, string installerDestinationPath, ProgressControlsForViews progressControls) { ((IProgressControls)progressControls).ShowProgress("Downloading"); NewVersion plasticVersion = null; IThreadWaiter waiter = ThreadWaiter.GetWaiter(); waiter.Execute( /*threadOperationDelegate*/ delegate { plasticVersion = PlasticScmRestApiClient.GetLastVersion( PlasticWebApiUris.GetBaseUri(), plasticEdition); if (plasticVersion == null) { return; } string installerUrl = GetInstallerUrl( plasticVersion.Version, plasticEdition == Edition.Cloud); DownloadInstaller( installerUrl, installerDestinationPath, progressControls); if (!PlatformIdentifier.IsMac()) { return; } installerDestinationPath = UnZipMacOsPackage( installerDestinationPath); }, /*afterOperationDelegate*/ delegate { ((IProgressControls)progressControls).HideProgress(); if (waiter.Exception != null) { ((IProgressControls)progressControls).ShowError( waiter.Exception.Message); return; } if (plasticVersion == null) { ((IProgressControls)progressControls).ShowError( "There was an error connecting. Please check your internet."); return; } if (!File.Exists(installerDestinationPath)) { return; } RunInstaller( installerDestinationPath, progressControls); }); }
static bool RefreshSettings() { List <string> Sections = GetSections(Path.Combine(Environment.CurrentDirectory, "config.ini")); Support.iniManager iniEngine = new Support.iniManager(Path.Combine(Environment.CurrentDirectory, "config.ini")); foreach (string item in Sections) { int NewVersion; if (!Int32.TryParse(iniEngine.IniReadValue(item, "Version"), out NewVersion)) { return(false); } string EncryptionKey = iniEngine.IniReadValue(item, "EncryptionKey"); string EncryptionIV = iniEngine.IniReadValue(item, "EncryptionIV"); int PingTimer; if (!int.TryParse(iniEngine.IniReadValue(item, "PingTimer"), out PingTimer)) { return(false); } int LogLevel; if (!int.TryParse(iniEngine.IniReadValue(item, "LogLevel"), out LogLevel)) { return(false); } if (AppsRunning.Count > 0) { int FormerVersion = Classes.CCstData.GetInstance(AppsRunning[0].Application).LatestClientVersion; if (NewVersion != FormerVersion) { Classes.CCstData.GetInstance(AppsRunning[0].Application).LatestClientVersion = NewVersion; Console.WriteLine("CONFIG update: Using now version " + NewVersion.ToString()); } int FormerLogLevel = Classes.CCstData.GetInstance(AppsRunning[0].Application).Logger.LogLevel; if (LogLevel != FormerLogLevel) { Classes.CCstData.GetInstance(AppsRunning[0].Application).Logger.LogLevel = LogLevel; Console.WriteLine("CONFIG update: Using now LogLevel " + LogLevel.ToString()); } string FormerEncryptionKey = Classes.CCstData.GetInstance(AppsRunning[0].Application).EncryptionKey; if (FormerEncryptionKey != EncryptionKey) { Classes.CCstData.GetInstance(AppsRunning[0].Application).EncryptionKey = EncryptionKey; Console.WriteLine("CONFIG update: Using now encryption key " + EncryptionKey); } string FormerEncryptionIV = Classes.CCstData.GetInstance(AppsRunning[0].Application).EncryptionIV; if (FormerEncryptionIV != EncryptionIV) { Classes.CCstData.GetInstance(AppsRunning[0].Application).EncryptionIV = EncryptionIV; Console.WriteLine("CONFIG update: Using now encryption IV " + EncryptionIV); } int FormerPingTimer = Classes.CCstData.GetInstance(AppsRunning[0].Application).PingTimer; if (FormerEncryptionIV != EncryptionIV) { Classes.CCstData.GetInstance(AppsRunning[0].Application).PingTimer = PingTimer; Console.WriteLine("CONFIG update: Using now PingTimer " + PingTimer.ToString() + "ms"); } } } return(true); }
/// <summary> /// Saves the updated version of the Xml document /// </summary> public void SaveAs(string filePath) { NewVersion.Save(filePath); }
/// <summary> /// Stages the data. /// </summary> public void StageData( ) { IProcessingContext context = Context; NewVersion.Setup(context); OldVersion.Setup(context); _oldApp = AppContents.Load(OldVersion, context, true); _newApp = AppContents.Load(NewVersion, context); ///// // Detect entity changes ///// List <EntityEntry> addedEntities, removedEntities, changedEntities, unchangedEntities; Diff.DetectChanges(_oldApp.Entities, _newApp.Entities, null, AddAction, RemoveAction, UpdateAction, UnchangedAction, out addedEntities, out removedEntities, out changedEntities, out unchangedEntities); Context.Report.AddedEntities = addedEntities; Context.Report.RemovedEntities = removedEntities; Context.Report.UpdatedEntities = changedEntities; Context.Report.UnchangedEntities = unchangedEntities; if (_oldApp.Entities != null) { Context.Report.Counts.Add(new StatisticsCount("Previous Application Entities", _oldApp.Entities.Count, StatisticsCountType.PreviousApplication)); } if (_newApp.Entities != null) { Context.Report.Counts.Add(new StatisticsCount("Current Application Entities", _newApp.Entities.Count, StatisticsCountType.CurrentApplication)); } Context.Report.Counts.Add(new StatisticsCount("Added Entities", addedEntities.Count, StatisticsCountType.Added)); Context.Report.Counts.Add(new StatisticsCount("Removed Entities", removedEntities.Count, StatisticsCountType.Removed)); Context.Report.Counts.Add(new StatisticsCount("Updated Entities", changedEntities.Count, StatisticsCountType.Updated)); Context.Report.Counts.Add(new StatisticsCount("Unchanged Entities", unchangedEntities.Count, StatisticsCountType.Unchanged)); ///// // Detect relationship changes ///// List <RelationshipEntry> addedRelationships, removedRelationships, changedRelationships, unchangedRelationships; Diff.DetectChanges(_oldApp.Relationships, _newApp.Relationships, null, null, null, null, null, out addedRelationships, out removedRelationships, out changedRelationships, out unchangedRelationships); Context.Report.AddedRelationships = addedRelationships; Context.Report.RemovedRelationships = removedRelationships; Context.Report.UpdatedRelationships = changedRelationships; if (_oldApp.Relationships != null) { Context.Report.Counts.Add(new StatisticsCount("Previous Application Relationships", _oldApp.Relationships.Count, StatisticsCountType.PreviousApplication)); } if (_newApp.Relationships != null) { Context.Report.Counts.Add(new StatisticsCount("Current Application Relationships", _newApp.Relationships.Count, StatisticsCountType.CurrentApplication)); } Context.Report.Counts.Add(new StatisticsCount("Added Relationships", addedRelationships.Count, StatisticsCountType.Added)); Context.Report.Counts.Add(new StatisticsCount("Removed Relationships", removedRelationships.Count, StatisticsCountType.Removed)); Context.Report.Counts.Add(new StatisticsCount("Updated Relationships", changedRelationships.Count, StatisticsCountType.Updated)); Context.Report.Counts.Add(new StatisticsCount("Unchanged Relationships", unchangedRelationships.Count, StatisticsCountType.Unchanged)); Func <DataEntry, DataEntry, bool> changedAction = (oldVal, newVal) => { newVal.ExistingData = oldVal.Data; return(true); }; ///// // Detect and apply data changes ///// foreach (string dataTable in Helpers.FieldDataTables) { List <DataEntry> addedData, removedData, changedData, unchangedData; Dictionary <Tuple <Guid, Guid>, DataEntry> oldData = _oldApp.FieldData[dataTable]; Dictionary <Tuple <Guid, Guid>, DataEntry> newData = _newApp.FieldData[dataTable]; Diff.DetectChanges(oldData, newData, null, null, null, changedAction, null, out addedData, out removedData, out changedData, out unchangedData); context.Report.AddedEntityData[dataTable] = addedData; context.Report.RemovedEntityData[dataTable] = removedData; context.Report.UpdatedEntityData[dataTable] = changedData; if (oldData != null) { Context.Report.Counts.Add(new StatisticsCount($"Previous Application {dataTable} Data", oldData.Count, StatisticsCountType.PreviousApplication)); } if (newData != null) { Context.Report.Counts.Add(new StatisticsCount($"Current Application {dataTable} Data", newData.Count, StatisticsCountType.CurrentApplication)); } Context.Report.Counts.Add(new StatisticsCount($"Added {dataTable} Data", addedData.Count, StatisticsCountType.Added)); Context.Report.Counts.Add(new StatisticsCount($"Removed {dataTable} Data", removedData.Count, StatisticsCountType.Removed)); Context.Report.Counts.Add(new StatisticsCount($"Updated {dataTable} Data", changedData.Count, StatisticsCountType.Updated)); Context.Report.Counts.Add(new StatisticsCount($"Unchanged {dataTable} Data", unchangedData.Count, StatisticsCountType.Unchanged)); } ///// // Detect binary data changes ///// List <BinaryDataEntry> addedbinaryData, removedBinaryData, changedBinaryData, unchangedBinaryData; Diff.DetectChanges(_oldApp.BinaryData, _newApp.BinaryData, null, null, null, null, null, out addedbinaryData, out removedBinaryData, out changedBinaryData, out unchangedBinaryData); context.Report.AddedBinaryData = addedbinaryData; context.Report.RemovedBinaryData = removedBinaryData; context.Report.UpdatedBinaryData = changedBinaryData; if (_oldApp.BinaryData != null) { Context.Report.Counts.Add(new StatisticsCount("Previous Application Binary Data", _oldApp.BinaryData.Count, StatisticsCountType.PreviousApplication)); } if (_newApp.BinaryData != null) { Context.Report.Counts.Add(new StatisticsCount("Current Application Binary Data", _newApp.BinaryData.Count, StatisticsCountType.CurrentApplication)); } Context.Report.Counts.Add(new StatisticsCount("Added Binary Data", addedbinaryData.Count, StatisticsCountType.Added)); Context.Report.Counts.Add(new StatisticsCount("Removed Binary Data", removedBinaryData.Count, StatisticsCountType.Removed)); Context.Report.Counts.Add(new StatisticsCount("Updated Binary Data", changedBinaryData.Count, StatisticsCountType.Updated)); Context.Report.Counts.Add(new StatisticsCount("Unchanged Binary Data", unchangedBinaryData.Count, StatisticsCountType.Unchanged)); ///// // Detect binary data changes ///// List <DocumentDataEntry> addedDocumentData, removedDocumentData, changedDocumentData, unchangedDocumentData; Diff.DetectChanges(_oldApp.DocumentData, _newApp.DocumentData, null, null, null, null, null, out addedDocumentData, out removedDocumentData, out changedDocumentData, out unchangedDocumentData); context.Report.AddedDocumentData = addedDocumentData; context.Report.RemovedDocumentData = removedDocumentData; context.Report.UpdatedDocumentData = changedDocumentData; if (_oldApp.DocumentData != null) { Context.Report.Counts.Add(new StatisticsCount("Previous Application Document Data", _oldApp.DocumentData.Count, StatisticsCountType.PreviousApplication)); } if (_newApp.DocumentData != null) { Context.Report.Counts.Add(new StatisticsCount("Current Application Document Data", _newApp.DocumentData.Count, StatisticsCountType.CurrentApplication)); } Context.Report.Counts.Add(new StatisticsCount("Added Document Data", addedDocumentData.Count, StatisticsCountType.Added)); Context.Report.Counts.Add(new StatisticsCount("Removed Document Data", removedDocumentData.Count, StatisticsCountType.Removed)); Context.Report.Counts.Add(new StatisticsCount("Updated Document Data", changedDocumentData.Count, StatisticsCountType.Updated)); Context.Report.Counts.Add(new StatisticsCount("Unchanged Document Data", unchangedDocumentData.Count, StatisticsCountType.Unchanged)); OldVersion.TearDown(context); NewVersion.TearDown(context); }