private async Task <TimeSpan> LoadFromExternalDatabase() { var table = await _externalDb.FetchAllMembers(Settings.UserName); _logger.LogInfo("Found " + table.Count + " members in databse"); foreach (var member in table) { Members.Add(member.ProfileId, member); switch (member.Status) { case IEMember.MEMBER_NEW: NewItems.Add(member); break; case IEMember.MEMBER_REJECTED: RejectedItems.Add(member); break; default: ActiveItems.Add(member); break; } } NewItems.Sort(); RejectedItems.Sort(); ActiveItems.Sort(); TimeScheduler.GetTimeScheduler().AddTask(DS_TASK_NAME, TimeSpan.FromSeconds(INITIAL_DELAY), () => OnTimedEvent()); return(TimeScheduler.STOP_TIMER); // This stops us being re-scheduled }
void AddInternal(object value) { if (IsTrackingChanges) { if (DelItems.Contains(value)) { DelItems.Remove(value); } else { NewItems.Add(value); } } OnAdd(value); }
/* * This method is used to search for users who are currently logged in */ private async Task <bool> DoMatchFinder(bool byLogin) { List <IEProfile> profiles; bool newMemberFound = false; if (byLogin) { profiles = await _session.OnLine(Settings.SearchForFemales, Settings.MinAge, Settings.MinAge, Settings.Regions, Settings.FetchCount); } else { profiles = await _session.MatchFinder(Settings.SearchForFemales, Settings.MinAge, Settings.MaxAge, Settings.Regions, Settings.FetchCount); } if (profiles != null) { foreach (var profile in profiles) { // Do we know this profile already? IEMember member = GetMember(profile.ProfileId); if (member == null) { // We should add them.... member = new IEMember() { ProfileId = profile.ProfileId, Region = profile.Location, Status = IEMember.MEMBER_NEW }; NewItems.Add(member); NewItems.Sort(); newMemberFound = true; } member.Username = profile.Name; member.Age = profile.Age; member.ThumbnailUrl = profile.ThumbnailUrl; member.PartialSummary = profile.PartialSummary; SaveMember(member); } if (newMemberFound && OnNewMembersFound != null) { OnNewMembersFound(); } } return(newMemberFound); }
private void AddItemPricing() { //ItemPricing dummy = new ItemPricing(0, ItemId, Types.Days.Any, 0f, null, null, null, false); //ItemPricing newItem = ItemPricing.Add(ItemId, Types.Days.Any, 0f, null, null, null, false); ItemPricingModel newItem = new ItemPricingModel(ItemId, Days.Any, null, null, 0f); AddItemPricingToListBox(newItem); NewItems.Add(newItem); foreach (FormattedListBoxItem item in listBox1.Items) { item.IsSelected = Equals(item, listBox1.SelectedItem); } listBox1.ScrollIntoView(listBox1.SelectedItem); InitializeFields(newItem); SetReadOnly(false); buttonRemove.IsEnabled = true; DoChangedValueEvent(); //InitializeListBox(); }
public void ChangeMemberStatus(IEMember member, int newStatus) { switch (member.Status) { case IEMember.MEMBER_NEW: NewItems.Remove(member); break; case IEMember.MEMBER_REJECTED: RejectedItems.Remove(member); break; default: ActiveItems.Remove(member); break; } member.Status = newStatus; switch (member.Status) { case IEMember.MEMBER_NEW: NewItems.Add(member); break; case IEMember.MEMBER_REJECTED: RejectedItems.Add(member); break; default: ActiveItems.Add(member); break; } NewItems.Sort(); RejectedItems.Sort(); ActiveItems.Sort(); SaveMember(member); }
/// <summary> /// Update the container buffer and item snapshots. Old (removed) items will be added to /// <see cref="OldItems"/> and new items to <see cref="NewItems"/>. /// </summary> public void Update() { _container.TakeSnapshot(); _previousSegments = _currentSegments; if (_previousData.Length != _currentData.Length) { Array.Resize(ref _previousData, _currentData.Length); } Buffer.BlockCopy(_currentData, 0, _previousData, 0, _currentData.Length); _currentSegments = _container.GetAllocatedBytes(ref _currentData); if (_currentData.Length != _previousData.Length) // buffer was resized (and replaced), update underlying buffer for all items { for (int i = 0; i < _items.Length; i++) { if (_items[i] == null) { continue; } _items[i].SetSnapshot(_currentData, i * _container.ItemSize, _container.ItemSize); } } if (_previousMapping.Length != _currentMapping.Length) { Array.Resize(ref _previousMapping, _currentMapping.Length); } Buffer.BlockCopy(_currentMapping, 0, _previousMapping, 0, _currentMapping.Length * sizeof(int)); var count = _currentData.Length / _container.ItemSize; var mr = new BufferMemoryReader(_currentData); if (_currentMapping.Length != count) { Array.Resize(ref _currentMapping, count); } for (int i = 0; i <= _container.MaxIndex; i++) { _currentMapping[i] = mr.Read <int>(i * _container.ItemSize); } for (int i = _container.MaxIndex + 1; i < count; i++) { _currentMapping[i] = -1; } NewItems.Clear(); OldItems.Clear(); if (_items.Length != _container.Capacity) { Array.Resize(ref _items, _container.Capacity); } // Compare against previous where there is a value. for (int i = 0; i < Math.Min(_previousMapping.Length, _currentMapping.Length); i++) { if (_currentMapping[i] != _previousMapping[i]) { if (_previousMapping[i] != -1) { var item = CreatePreviousItem(i); OnItemRemoved(i, item); OldItems.Add(item); } if (_currentMapping[i] != -1 && _currentMapping[i] != 0) // NB: New item starts with ID 0 { var item = CreateCurrentItem(i); OnItemAdded(i, item); NewItems.Add(item); } } } // Check expanded area. for (int i = _previousMapping.Length; i < _currentMapping.Length; i++) { if (_currentMapping[i] != -1) { var item = CreateCurrentItem(i); OnItemAdded(i, item); NewItems.Add(item); } } // Check reduced area. for (int i = _currentMapping.Length; i < _previousMapping.Length; i++) { if (_previousMapping[i] != -1) { var item = CreatePreviousItem(i); OnItemRemoved(i, item); OldItems.Add(item); } } }
public void RegisterNew(object entity) { //_innerUnitOfWork.RegisterNew(entity); NewItems.Add(entity); }