// returns true if an update was found, false otherwise private bool DoCheckForUpdates(UpdateSource source) { logger.Info("Running update check from " + source); lock (this) { if (updating) { logger.Info("Already in update: skipping"); return false; } updating = true; } bool res; try { res = DoCheckForUpdatesInternal(); } catch (Exception ex) { LoggingHelper.LogError(logger, ex); throw; } finally { lock (this) { updating = false; } } logger.Info("Done"); return res; }
private void DoUpdateProjects(UpdateSource source) { logger.Info("Running update from " + source); lock (this) { if (updating) { logger.Info("Already in update: skipping"); return; } updating = true; } try { DoUpdateProjectsInternal(); HudsonService.RecycleCache(); } catch (Exception ex) { LoggingHelper.LogError(logger, ex); throw; } finally { lock (this) { updating = false; } } logger.Info("Done"); }
private void DoUpdateProjects(UpdateSource source) { logger.Info("Running update from " + source); lock (this) { if (updating) { logger.Info("Already in update: skipping"); return; } updating = true; } try { DoUpdateProjectsInternal(); JenkinsService.RecycleCache(); } catch (Exception ex) { LoggingHelper.LogError(logger, ex); throw; } finally { lock (this) { updating = false; } } logger.Info("Done"); }
public void Update(GuildSyncModel model, UpdateSource source, DataStore dataStore) { if (source == UpdateSource.Rest && IsAttached) { return; } var members = new ConcurrentDictionary <ulong, SocketGuildUser>(1, (int)(model.Presences.Length * 1.05)); { DownloadedMemberCount = 0; for (int i = 0; i < model.Members.Length; i++) { AddOrUpdateUser(model.Members[i], dataStore, members); } var _ = _syncPromise.TrySetResultAsync(true); if (!model.Large) { _ = _downloaderPromise.TrySetResultAsync(true); } for (int i = 0; i < model.Presences.Length; i++) { AddOrUpdateUser(model.Presences[i], dataStore, members); } } _members = members; }
public static bool NeedUpdate(UpdateSource source) { Version currentVersion = GetCurrentVersion(); Version actualVersion = GetVersion(source); return(actualVersion > currentVersion); }
public void CheckForUpdates_Asynchronous(UpdateSource source) { var worker = new BackgroundWorker(); worker.DoWork += delegate { DoCheckForUpdates(source); }; worker.RunWorkerAsync(); }
private void RemoveInternal(T item, UpdateSource source, int index) { CheckNotLocked(); UndoLogRemove(item, index); m_list.RemoveAt(index); ItemRemoved(item, source, index); }
public void CheckForUpdates_Asynchronous(UpdateSource source) { BackgroundWorker worker = new BackgroundWorker(); worker.DoWork += delegate { DoCheckForUpdates(source); }; worker.RunWorkerAsync(); }
public SetClauseImpl(SQLVendorImpl vendor, String target, UpdateSource source) : base(vendor) { ArgumentValidator.ValidateNotNull(nameof(target), target); ArgumentValidator.ValidateNotNull(nameof(source), source); this._target = target; this._source = source; }
public void Update(Model model, UpdateSource source) { if (/*source == UpdateSource.Rest && */ IsAttached) { return; } (Recipient as User).Update(model.Recipients.Value[0], source); }
public object Clone() => new SetupData() { Arguments = Arguments, Executable = (SetupFile)Executable.Clone(), Files = new List <SetupFile>(Files), JustOneInstance = JustOneInstance, UpdateSource = (UpdateSource)UpdateSource.Clone(), UpdateType = UpdateType };
public override void Update(Model model, UpdateSource source) { if (source == UpdateSource.Rest && IsAttached) { return; } base.Update(model, source); }
private void ItemRemoved(T item, UpdateSource source, int index) { if (Removed != null) { Removed(this, new QuestListUpdatedEventArgs <T> { UpdatedItem = item, Index = index, Source = source }); } }
public async Task ShouldRequireSourceTitle() { var module = await AddAsync(new Module { Title = "New Module", Key = "module-key", Description = "New Module Description", Paths = new List <Path> { new Path { Title = "Some Path", Key = "some-path", Description = "Some Path Description" } } }); var theme = await AddAsync(new Theme { Title = "New Theme", Description = "New Theme Description", Tags = new List <string> { "Tag1", "Tag2", "Tag3" }, ModuleId = module.Id }); var source = await AddAsync(new Source { ThemeId = theme.Id, Title = "Source 1", Description = "Some description", Url = "https://source1.com", Order = 0, Type = SourceType.Documentation, Availability = Availability.Free, Relevance = Relevance.Relevant, Tags = new List <string> { "Tag1", "Tag2", "Tag3" } }); var command = new UpdateSource { Id = source.Id, ModuleId = module.Id, ThemeId = theme.Id, Title = "", Url = "https://source1.com" }; FluentActions.Invoking(() => SendAsync(command)) .Should().ThrowAsync <ValidationException>().Where(ex => ex.Errors.ContainsKey("Title")) .Result.And.Errors["Title"].Should().Contain("Title is required."); }
public async Task ShouldDisallowLongTitle() { var module = await AddAsync(new Module { Title = "New Module", Key = "module-key", Description = "New Module Description", Paths = new List <Path> { new Path { Title = "Some Path", Key = "some-path", Description = "Some Path Description" } } }); var theme = await AddAsync(new Theme { Title = "New Theme", Description = "New Theme Description", Tags = new List <string> { "Tag1", "Tag2", "Tag3" }, ModuleId = module.Id }); var source = await AddAsync(new Source { ThemeId = theme.Id, Title = "Source 1", Description = "Some description", Url = "https://source1.com", Order = 0, Type = SourceType.Documentation, Availability = Availability.Free, Relevance = Relevance.Relevant, Tags = new List <string> { "Tag1", "Tag2", "Tag3" } }); var command = new UpdateSource { Id = source.Id, ModuleId = module.Id, ThemeId = theme.Id, Title = "This source title is too long and exceeds two hundred characters allowed for theme titles by CreateSourceCommandValidator. And this source title in incredibly long and ugly. I imagine no one would create a title this long but just in case", Url = "https://source1.com" }; FluentActions.Invoking(() => SendAsync(command)) .Should().ThrowAsync <ValidationException>().Where(ex => ex.Errors.ContainsKey("Title")) .Result.And.Errors["Title"].Should().Contain("Title must not exceed 200 characters."); }
public void Update(EmbedModel model, UpdateSource source) { if (source == UpdateSource.Rest && IsAttached) { return; } IsEmbeddable = model.Enabled; EmbedChannelId = model.ChannelId; }
public override void Update(PresenceModel model, UpdateSource source) { base.Update(model, source); var game = model.Game != null ? new Game(model.Game) : null; //Presence = new Presence(game, model.Status); User.Update(model, source); }
public void Update(PresenceModel model, UpdateSource source) { //Race conditions are okay here. Multiple shards racing already cant guarantee presence in order. //lock (_lockObj) //{ var game = model.Game != null ? new Game(model.Game) : null; Presence = new Presence(game, model.Status); //} }
public void Update(Model model, UpdateSource source) { if (source == UpdateSource.Rest && IsAttached) { return; } AFKChannelId = model.AFKChannelId; EmbedChannelId = model.EmbedChannelId; AFKTimeout = model.AFKTimeout; IsEmbeddable = model.EmbedEnabled; _iconId = model.Icon; Name = model.Name; OwnerId = model.OwnerId; VoiceRegionId = model.Region; _splashId = model.Splash; VerificationLevel = model.VerificationLevel; MfaLevel = model.MfaLevel; DefaultMessageNotifications = model.DefaultMessageNotifications; if (model.Emojis != null) { var emojis = ImmutableArray.CreateBuilder <Emoji>(model.Emojis.Length); for (int i = 0; i < model.Emojis.Length; i++) { emojis.Add(new Emoji(model.Emojis[i])); } Emojis = emojis.ToImmutableArray(); } else { Emojis = ImmutableArray.Create <Emoji>(); } if (model.Features != null) { Features = model.Features.ToImmutableArray(); } else { Features = ImmutableArray.Create <string>(); } var roles = new ConcurrentDictionary <ulong, Role>(1, model.Roles?.Length ?? 0); if (model.Roles != null) { for (int i = 0; i < model.Roles.Length; i++) { roles[model.Roles[i].Id] = new Role(this, model.Roles[i]); } } _roles = roles; }
internal void UpdateUsers(UserModel[] models, UpdateSource source, DataStore dataStore) { var users = new ConcurrentDictionary <ulong, GroupUser>(1, models.Length); for (int i = 0; i < models.Length; i++) { var globalUser = Discord.GetOrAddUser(models[i], dataStore); users[models[i].Id] = new SocketGroupUser(this, globalUser); } _users = users; }
public async Task <ActionResult <Source> > Update(int pathId, int moduleId, int themeId, int sourceId, [FromBody] UpdateSource command) { if (pathId != command.PathId || moduleId != command.ModuleId || themeId != command.ThemeId || sourceId != command.Id) { return(BadRequest()); } return(Ok(await Mediator.Send(command))); }
public override void Update(Model model, UpdateSource source) { if (source == UpdateSource.Rest && IsAttached) { return; } base.Update(model, source); Bitrate = model.Bitrate.Value; UserLimit = model.UserLimit.Value; }
private void ItemAdded(T item, UpdateSource source, int index) { UndoLogAdd(item, index); if (Added != null) { Added(this, new QuestListUpdatedEventArgs <T> { UpdatedItem = item, Index = index, Source = source }); } }
public void Update(Model model, UpdateSource source) { if (source == UpdateSource.Rest && IsAttached) { return; } _iconId = model.Icon; IsOwner = model.Owner; Name = model.Name; Permissions = new GuildPermissions(model.Permissions); }
public void Update(Model model, UpdateSource source) { if (source == UpdateSource.Rest && IsAttached) { return; } GuildId = model.Guild.Id; ChannelId = model.Channel.Id; GuildName = model.Guild.Name; ChannelName = model.Channel.Name; }
internal virtual void UpdateUsers(API.User[] models, UpdateSource source) { if (!IsAttached) { var users = new ConcurrentDictionary <ulong, GroupUser>(1, (int)(models.Length * 1.05)); for (int i = 0; i < models.Length; i++) { users[models[i].Id] = new GroupUser(this, new User(models[i])); } _users = users; } }
public void ShouldRequireValidThemeId() { var command = new UpdateSource { Id = 1, ModuleId = 1, ThemeId = 99999, Title = "New Title", Url = "https://www.ww.ww" }; FluentActions.Invoking(() => SendAsync(command)).Should().ThrowAsync <NotFoundException>(); }
internal void Update(Model model, UpdateSource source) { if (source == UpdateSource.Rest && IsAttached) { return; } Description = model.Description; RPCOrigins = model.RPCOrigins; Name = model.Name; Flags = model.Flags; Owner = new User(model.Owner); _iconId = model.Icon; }
public void Update(Model model, UpdateSource source) { if (source == UpdateSource.Rest && IsAttached) { return; } Name = model.Name; IsHoisted = model.Hoist; IsManaged = model.Managed; Position = model.Position; Color = new Color(model.Color); Permissions = new GuildPermissions(model.Permissions); }
private void AddInternal(T item, UpdateSource source, int?index = null) { CheckNotLocked(); if (index == null) { m_list.Add(item); index = m_list.Count - 1; } else { m_list.Insert(index.Value, item); } ItemAdded(item, source, index.Value); }
private void ItemRemoved(T item, UpdateSource source, int index) { if (Config.StorageLog) { System.Diagnostics.Debug.WriteLine("LIST REMOVE ({0}) @{1}", Owner == null ? "none" : Owner.Name, index); } if (Removed != null) { Removed(this, new QuestListUpdatedEventArgs <T> { UpdatedItem = item, Index = index, Source = source }); } }
public void Start(IPriceProvider provider) { // Set up topic details var builder = topicControl.CreateDetailsBuilder <ISingleValueTopicDetailsBuilder>(); var details = builder.Metadata(Diffusion.Metadata.Decimal("Price")).Build(); // Declare a custom update source implementation. When the source is set as active, start a periodic task // to poll the provider every second and update the topic. When the source is closed, stop the scheduled // task. var source = new UpdateSource(provider, updateCallback); // Create the topic. When the callback indicates that the topic has been created, register the topic // source for the topic topicControl.AddTopicFromValue(TopicName, details, new AddCallback(updateControl, source)); }
public void Update(Model model, UpdateSource source) { if (source == UpdateSource.Rest && IsAttached) { return; } Inviter = new User(model.Inviter); IsRevoked = model.Revoked; IsTemporary = model.Temporary; MaxAge = model.MaxAge != 0 ? model.MaxAge : (int?)null; MaxUses = model.MaxUses; Uses = model.Uses; _createdAtTicks = model.CreatedAt.UtcTicks; }
public AddCallback( ITopicUpdateControl updater, UpdateSource source ) { updateControl = updater; updateSource = source; }
public bool CheckForUpdates_Synchronous(UpdateSource source) { return DoCheckForUpdates(source); }
// returns true if an update was found, false otherwise private bool DoCheckForUpdates(UpdateSource source) { bool result = false; if (source == ApplicationUpdateService.UpdateSource.Timer && ConfigurationService.GeneralSettings.CheckForUpdates == false) { logger.Info("Update check is already disabled in settings; stopping timer, from " + source); // Methods should only have 1 return point! EnableTimer(false); } else { logger.Info("Running update check from " + source); lock (this) { if (updating) { logger.Info("Already in update: skipping"); return false; } updating = true; } try { result = DoCheckForUpdatesInternal(); } catch (Exception ex) { LoggingHelper.LogError(logger, ex); throw; } finally { lock (this) { updating = false; } } logger.Info("Done"); } return result; }
private IEnumerable<UpdateSource> GetUpdateSources() { var dir = System.IO.Path.GetDirectoryName(typeof(Editor).Assembly.Location); if (dir == null) yield break; var file = System.IO.Path.Combine(dir, "UpdateSources.txt"); if (!File.Exists(file)) yield break; var lines = File.ReadAllLines(file); foreach (var line in lines) { if (String.IsNullOrWhiteSpace(line) || line.StartsWith("#")) continue; var split = line.Split(':'); if (split.Length < 2) continue; var us = new UpdateSource { Name = split[0], Url = String.Join(":", split.Skip(1)) }; yield return us; } }
private UpdateCheckResult GetUpdateCheckResult(UpdateSource source, string version) { try { using (var downloader = new WebClient()) { var str = downloader.DownloadString(source.GetUrl(version)).Split('\n', '\r'); if (str.Length < 3 || String.IsNullOrWhiteSpace(str[0])) { return null; } return new UpdateCheckResult { Version = str[0], Date = DateTime.Parse(str[1]), DownloadUrl = str[2] }; } } catch { return null; } }
public void Start( IPriceProvider provider ) { // Set up topic details var builder = topicControl.CreateDetailsBuilder<ISingleValueTopicDetailsBuilder>(); var details = builder.Metadata( Diffusion.Metadata.Decimal( "Price" ) ).Build(); // Declare a custom update source implementation. When the source is set as active, start a periodic task // to poll the provider every second and update the topic. When the source is closed, stop the scheduled // task. var source = new UpdateSource( provider, updateCallback ); // Create the topic. When the callback indicates that the topic has been created, register the topic // source for the topic. topicControl.AddTopicFromValue( TopicName, details, new AddCallback( updateControl, source ) ); }
/// <summary> /// update wurm date time if new data is more up to date /// </summary> /// <param name="stamp"></param> /// <param name="value"></param> /// <param name="source"></param> internal void SetWurmDateTime(DateTime stamp, WurmDateTime value, UpdateSource source) { lock (lock_obj) { if (source == UpdateSource.WebFeed) { if (stamp > WDT_web.Stamp) { WDT_web = new WurmDateTimeInfoPair(stamp, value); } } else if (source == UpdateSource.WurmLogs) { if (stamp > WDT_logs.Stamp) { WDT_logs = new WurmDateTimeInfoPair(stamp, value); } } } }
/// <summary> /// update uptime if new data is more up to date /// </summary> /// <param name="stamp"></param> /// <param name="value"></param> /// <param name="source"></param> internal void SetUptime(DateTime stamp, TimeSpan value, UpdateSource source) { Logger.LogDebug(String.Format("{0} ; {1} ; {2} ; {3}", stamp, value, source, lock_obj)); lock (lock_obj) { if (source == UpdateSource.WebFeed) { if (stamp > Uptime_web.Stamp) { Uptime_web = new WurmUptimeInfoPair(stamp, value); } } else if (source == UpdateSource.WurmLogs) { if (stamp > Uptime_logs.Stamp) { Uptime_logs = new WurmUptimeInfoPair(stamp, value); } } } }