Exemplo n.º 1
0
        public void OnUpdateGameSession(string rawUpdateGameSession, IAck ack)
        {
            log.DebugFormat("ServerState got the updateGameSession signal. rawGameSession : {0}", rawUpdateGameSession);

            if (!processReady)
            {
                log.Debug("Got an updated game session on inactive process. Sending false ack.");
                ack.Call(false);
                return;
            }
            log.Debug("Sending true ack.");
            ack.Call(true);

            Task.Run(() =>
            {
                Com.Amazon.Whitewater.Auxproxy.Pbuffer.UpdateGameSession updateGameSession =
                    JsonConvert.DeserializeObject <Com.Amazon.Whitewater.Auxproxy.Pbuffer.UpdateGameSession>(rawUpdateGameSession);
                GameSession gameSession   = GameSession.ParseFromBufferedGameSession(updateGameSession.GameSession);
                gameSessionId             = gameSession.GameSessionId;
                UpdateReason updateReason = UpdateReasonMapper.GetUpdateReasonForName(updateGameSession.UpdateReason);

                processParameters.OnUpdateGameSession(
                    new UpdateGameSession(gameSession, updateReason, updateGameSession.BackfillTicketId));
            });
        }
        public override async Task <bool> UpdateItemsAsync(int maxItems, UpdateReason updateReason)
        {
            if (!TryInitTvHandler())
            {
                return(false);
            }

            if (!updateReason.HasFlag(UpdateReason.Forced) && !updateReason.HasFlag(UpdateReason.PlaybackComplete))
            {
                return(true);
            }

            IList <IChannel> channels = await GetUserChannelList(maxItems, UserDataKeysKnown.KEY_CHANNEL_PLAY_COUNT);

            lock (_allItems.SyncRoot)
            {
                if (_currentChannels.Select(c => c.ChannelId).SequenceEqual(channels.Select(c => c.ChannelId)))
                {
                    return(true);
                }
                _currentChannels = channels;
                _allItems.Clear();
                foreach (IChannel channel in channels)
                {
                    _allItems.Add(CreateChannelItem(channel));
                }
            }
            _allItems.FireChange();
            return(true);
        }
 public InsertOrUpdateStudyCommand(StudyLocation location, StudyXml xml, UpdateReason reason) : base("Insert or Update Study Command")
 {
     _studyInstanceUid = xml.StudyInstanceUid;
     _studyXml = xml;
     _reason = reason;
     _location = location;
 }
Exemplo n.º 4
0
        // This kinda code is a trip down memory lane.
        // Filled with nightmares and horrors...
        public async Task UpdateUserAsync(UpdateReason updateReason, IUpdateUser userInfo)
        {
            User?user = await repository.FindByEmailAsync(userInfo.OriginalEmail);

            if (user is null)
            {
                return;
            }

            if (updateReason == UpdateReason.EmailChanged)
            {
                user.ChangeEmail(userInfo.UpdatedEmail);
                // Generate new security stamp
                // Notify marketing
            }
            else if (updateReason == UpdateReason.UsernameChanged)
            {
                user.ChangeUsername(userInfo.UpdatedUsername);
                // Update profile slug
                // Notify user's followers about the username change
            }
            else
            {
                throw new ArgumentException();
            }

            await repository.UpdateAsync(user);
        }
Exemplo n.º 5
0
        public override async Task <bool> UpdateItemsAsync(int maxItems, UpdateReason updateReason)
        {
            IProgramInfoAsync programInfo = null;

            if (!TryInitTvHandler() || (programInfo = _tvHandler?.ProgramInfo) == null)
            {
                return(false);
            }

            if (!updateReason.HasFlag(UpdateReason.Forced) && !updateReason.HasFlag(UpdateReason.PlaybackComplete) && !updateReason.HasFlag(UpdateReason.PeriodicMinute))
            {
                return(true);
            }

            ICollection <IChannel> channels;

            if (_currentChannels == null || updateReason.HasFlag(UpdateReason.Forced) || updateReason.HasFlag(UpdateReason.PlaybackComplete))
            {
                channels = _currentChannels = await GetUserChannelList(maxItems, UserDataKeysKnown.KEY_CHANNEL_PLAY_COUNT, true);
            }
            else
            {
                channels = _currentChannels;
            }

            IList <Tuple <IProgram, IChannel> > programs = new List <Tuple <IProgram, IChannel> >();

            foreach (IChannel channel in channels)
            {
                var result = await programInfo.GetNowNextProgramAsync(channel);

                if (!result.Success)
                {
                    continue;
                }

                IProgram currentProgram = result.Result[0];

                if (currentProgram != null)
                {
                    programs.Add(new Tuple <IProgram, IChannel>(currentProgram, channel));
                }
            }

            lock (_allItems.SyncRoot)
            {
                if (_currentPrograms.Select(p => p.Item1.ProgramId).SequenceEqual(programs.Select(p => p.Item1.ProgramId)))
                {
                    return(true);
                }
                _currentPrograms = programs;
                _allItems.Clear();
                foreach (var program in programs)
                {
                    _allItems.Add(CreateProgramItem(program.Item1, program.Item2));
                }
            }
            _allItems.FireChange();
            return(true);
        }
Exemplo n.º 6
0
 public InsertOrUpdateStudyCommand(StudyLocation location, StudyXml xml, UpdateReason reason) : base("Insert or Update Study Command")
 {
     _studyInstanceUid = xml.StudyInstanceUid;
     _studyXml         = xml;
     _reason           = reason;
     _location         = location;
 }
Exemplo n.º 7
0
        public override async Task <bool> UpdateItemsAsync(int maxItems, UpdateReason updateReason)
        {
            if (!TryInitTvHandler())
            {
                return(false);
            }
            var tvHandlerScheduleControl = _tvHandler.ScheduleControl;

            if (tvHandlerScheduleControl == null)
            {
                return(false);
            }

            if (!updateReason.HasFlag(UpdateReason.Forced) && !updateReason.HasFlag(UpdateReason.PeriodicMinute))
            {
                return(true);
            }

            var scheduleResult = await tvHandlerScheduleControl.GetSchedulesAsync();

            if (!scheduleResult.Success)
            {
                return(false);
            }

            var schedules        = scheduleResult.Result;
            var scheduleSortList = new List <Tuple <ISchedule, ProgramProperties> >();

            foreach (ISchedule schedule in schedules)
            {
                var programResult = await tvHandlerScheduleControl.GetProgramsForScheduleAsync(schedule);

                if (!programResult.Success || programResult.Result.Count == 0)
                {
                    continue;
                }
                ProgramProperties programProperties = new ProgramProperties();
                programProperties.SetProgram(programResult.Result.OrderBy(p => p.StartTime).First());
                scheduleSortList.Add(new Tuple <ISchedule, ProgramProperties>(schedule, programProperties));
            }
            scheduleSortList.Sort(ChannelAndProgramStartTimeComparison);

            var scheduleList = new List <Tuple <ISchedule, ProgramProperties> >(scheduleSortList.Take(maxItems));

            if (_currentSchedules.Select(s => s.Item1.ScheduleId).SequenceEqual(scheduleList.Select(s => s.Item1.ScheduleId)))
            {
                return(true);
            }

            ListItem[] items = scheduleList.Select(s => CreateScheduleItem(s.Item1, s.Item2)).ToArray();
            lock (_allItems.SyncRoot)
            {
                _currentSchedules = scheduleList;
                _allItems.Clear();
                CollectionUtils.AddAll(_allItems, items);
            }
            _allItems.FireChange();
            return(true);
        }
Exemplo n.º 8
0
 public HistoryPoint(Control control, object value, DependencyProperty property, UpdateReason updateReason)
 {
     Timestamp = DateTime.UtcNow;
     Control = control;
     Value = value;
     Property = property;
     UpdateReason = updateReason;
 }
Exemplo n.º 9
0
 public UndoData(UndoOperation Operation, object Data)
 {
     this.operation   = Operation;
     this.data        = Data;
     this.reason      = UpdateReason.Other;
     this.updateCount = 0;
     this.undoFlag    = false;
     this.position    = Point.Empty;
 }
Exemplo n.º 10
0
        public async Task <bool> UpdateAllProvidersAsync()
        {
            try
            {
                var contentDirectory = ServiceRegistration.Get <IServerConnectionManager>().ContentDirectory;
                if (contentDirectory == null)
                {
                    _updatePending = true;
                    return(false);
                }

                UpdateReason updateReason = UpdateReason.None;
                if (_updatePending)
                {
                    updateReason |= UpdateReason.Forced;
                }
                if (_importUpdatePending)
                {
                    updateReason |= UpdateReason.ImportComplete;
                }
                if (_playbackUpdatePending)
                {
                    updateReason |= UpdateReason.PlaybackComplete;
                }
                if (_nextMinute < DateTime.Now)
                {
                    updateReason |= UpdateReason.PeriodicMinute;
                }
                if (_mediaItemUpdatePending)
                {
                    updateReason |= UpdateReason.MediaItemChanged;
                }
                if (updateReason == UpdateReason.None)
                {
                    return(false);
                }

                _updatePending          = false;
                _importUpdatePending    = false;
                _playbackUpdatePending  = false;
                _mediaItemUpdatePending = false;
                _nextMinute             = DateTime.Now.AddMinutes(1);

                int maxItems = Limit;
                foreach (var provider in _listProviders.EnabledProviders)
                {
                    await UpdateProviderAsync(provider, maxItems, updateReason);
                }

                return(true);
            }
            catch (Exception ex)
            {
                ServiceRegistration.Get <ILogger>().Error("Error updating Media List", ex);
                return(false);
            }
        }
Exemplo n.º 11
0
 /// <summary>Sets pos, err & revision from parameters, and sets NEW RefreshTime</summary>
 private RevisedTrackerState(
     LocationLib.Data.Position position,
     LocationLib.Data.Error error,
     string tag,
     int? revision,
     UpdateReason updatedPart
     )
     : base(position, error, tag)
 {
     DataRevision = revision;
       UpdatedPart = updatedPart;
 }
        public bool Execute(UpdateReason update)
        {
            this.SqlParams.Clear();
            this.SqlParams.Add("@requestId", update.requestId);
            this.SqlParams.Add("@intDsn", update.dsn);
            this.SqlParams.Add("@intReason", update.reason);

            DataTable   dt           = base.Execute();
            List <bool> responseList = base.MapBool(dt);

            return((responseList?.Count > 0)? responseList[0] : false);
        }
        public void OnUpdateGameSession(GameSession gameSession, UpdateReason updateReason, string backfillTicketId)
        {
            Log.DebugFormat("ServerState got the updateGameSession signal. GameSession : {0}", gameSession);

            if (!processReady)
            {
                Log.Warn("Got an updated game session on inactive process.");
                return;
            }

            Task.Run(() => {
                processParameters.OnUpdateGameSession(new UpdateGameSession(gameSession, updateReason, backfillTicketId));
            });
        }
        public override async Task <bool> UpdateItemsAsync(int maxItems, UpdateReason updateReason)
        {
            if (!TryInitTvHandler() || _tvHandler.ScheduleControl == null)
            {
                return(false);
            }

            if (!updateReason.HasFlag(UpdateReason.Forced) && !updateReason.HasFlag(UpdateReason.PeriodicMinute))
            {
                return(true);
            }

            var scheduleResult = await _tvHandler.ScheduleControl.GetSchedulesAsync();

            if (!scheduleResult.Success)
            {
                return(false);
            }

            var schedules        = scheduleResult.Result;
            var scheduleSortList = new List <Tuple <ISchedule, IChannel> >();

            foreach (ISchedule schedule in schedules.Take(maxItems))
            {
                var channelResult = await _tvHandler.ChannelAndGroupInfo.GetChannelAsync(schedule.ChannelId);

                var channel = channelResult.Success ? channelResult.Result : null;
                scheduleSortList.Add(new Tuple <ISchedule, IChannel>(schedule, channel));
            }
            scheduleSortList.Sort(ChannelAndProgramStartTimeComparison);

            var scheduleList = new List <Tuple <ISchedule, IChannel> >(scheduleSortList.Take(maxItems));

            if (_currentSchedules.Select(s => s.Item1.ScheduleId).SequenceEqual(scheduleList.Select(s => s.Item1.ScheduleId)))
            {
                return(true);
            }

            // Async calls need to be outside of locks
            ListItem[] items = await Task.WhenAll(scheduleList.Select(s => CreateScheduleItem(s.Item1, s.Item2)));

            lock (_allItems.SyncRoot)
            {
                _currentSchedules = scheduleList;
                _allItems.Clear();
                CollectionUtils.AddAll(_allItems, items);
            }
            _allItems.FireChange();
            return(true);
        }
Exemplo n.º 15
0
        public StatusCodeResult UpdateRequestReason(UpdateReason update)
        {
            string authToken = Request.Headers["x-access-token"];

            SessionService.SESSION_STATE state = sessionService.CheckSession(authToken, Convert.ToInt32(update.cid));

            // TODO: Validate status vs session
            if (state == SessionService.SESSION_STATE.INVALID)
            {
                return(StatusCode(401));
            }

            bool success = this.deactivationService.UpdateRequestReason(update);

            return((success)? StatusCode(200) : StatusCode(400));
        }
        public override Task <bool> UpdateItemsAsync(int maxItems, UpdateReason updateReason)
        {
            if (!updateReason.HasFlag(UpdateReason.Forced))
            {
                return(Task.FromResult(false));
            }

            var apps = Helper.LoadApps(false);
            IEnumerable <ListItem> listItems = apps.AppsList.Where(a => a.LastUsed > default(DateTime)).OrderByDescending(a => a.LastUsed).Select(a => CreateAppItem(a));

            _allItems.Clear();
            foreach (var item in listItems.Take(maxItems))
            {
                _allItems.Add(item);
            }
            _allItems.FireChange();
            return(Task.FromResult(true));
        }
        public static string GetNameForUpdateReason(UpdateReason value)
        {
            switch (value)
            {
            case UpdateReason.MATCHMAKING_DATA_UPDATED:
                return(MATCHMAKING_DATA_UPDATED_REASON);

            case UpdateReason.BACKFILL_FAILED:
                return(BACKFILL_FAILED_REASON);

            case UpdateReason.BACKFILL_TIMED_OUT:
                return(BACKFILL_TIMED_OUT_REASON);

            case UpdateReason.BACKFILL_CANCELLED:
                return(BACKFILL_CANCELLED_REASON);

            default:
                return(UNKNOWN_REASON);
            }
        }
        public void OnUpdateGameSession(string rawUpdateGameSession, IAck ack)
        {
            log.DebugFormat("ServerState got the updateGameSession.  rawGameSessionUpdate : {0}", rawUpdateGameSession);
            if (!processReady)
            {
                log.Debug("Got a update game session call on inactive process. Sending false ack.");
                ack.Call(false);
                return;
            }
            log.Debug("OnUpdateGameSession: Sending true ack.");
            ack.Call(true);

            Task.Run(() =>
            {
                Protobuf.UpdateGameSession updateGameSession =
                    JsonConvert.DeserializeObject <Protobuf.UpdateGameSession>(rawUpdateGameSession);
                GameSession gameSession   = GameSession.ParseFromBufferedGameSession(updateGameSession.GameSession);
                UpdateReason updateReason = UpdateReasonMapper.GetUpdateReasonForName(updateGameSession.UpdateReason);

                processParameters.OnUpdateGameSession(
                    new UpdateGameSession(gameSession, updateReason, updateGameSession.BackfillTicketId));
            });
        }
 public UpdateGameSession(GameSession gameSession, UpdateReason updateReason, string backfillTicketId)
 {
     this.GameSession      = gameSession;
     this.UpdateReason     = updateReason;
     this.BackfillTicketId = backfillTicketId;
 }
 protected override bool ShouldUpdate(UpdateReason updateReason)
 {
     return(updateReason.HasFlag(UpdateReason.MediaItemChanged) || updateReason.HasFlag(UpdateReason.ImportComplete) || updateReason.HasFlag(UpdateReason.UserChanged) || base.ShouldUpdate(updateReason));
 }
Exemplo n.º 21
0
 private async void TSB_UpdateReason_Click(object sender, EventArgs e)
 {
     await UpdateReason?.Invoke();
 }
Exemplo n.º 22
0
 public void Update(Control control, object value, DependencyProperty property, UpdateReason reason)
 {
     var textBoxBase = control as TextBoxBase;
     if(textBoxBase!=null)
         Update(new TextBoxHistoryPoint(textBoxBase,value,property,reason));
     else
         Update(new HistoryPoint(control, value, property, reason));
 }
Exemplo n.º 23
0
 public UpdateUserNameDialogOptions(UpdateReason reason)
 {
     Reason = reason;
 }
Exemplo n.º 24
0
        void Provider_SearchResultsUpdated(ISearchProvider provider, UpdateReason Reason, string ErrorMessage)
        {
            this.Cursor = Cursors.Default;

            if (_BusyMessage != null)
            {
                _BusyMessage.Dispose();
                _BusyMessage = null;
            }

            //using (new LockWindowUpdate(NzbResultList.Handle))
            {
                BuildFilteredListIfNeeded();
                NzbResultList.Refresh();
            }

            switch (Reason)
            {
                case UpdateReason.NewSearch:
                    _ListCache.Clear();
                    NzbResultList.Refresh();
                    if (ErrorMessage == null && provider.SearchResultItemCount == 0)
                        ErrorMessage = "No items found with current search criteria";
                    if (ErrorMessage == null)
                        NzbResultList.Focus(); //move focus to list
                    break;

                case UpdateReason.MoreSearch:
                    //no refreshing of any kind
                    break;

                case UpdateReason.Sorting:
                    _ListCache.Clear();
                    NzbResultList.Refresh();
                    break;
            }

            if (ErrorMessage != null && ErrorMessage.Length > 0)
                MessageBox.Show(ErrorMessage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
        }
Exemplo n.º 25
0
 public TextBoxHistoryPoint(TextBoxBase textbox, object value, DependencyProperty property, UpdateReason updateReason)
     : base(textbox, value, property, updateReason)
 {
 }
 public UpdateDateTimeDialogOptions(UpdateReason reason)
 {
     Reason = reason;
 }
Exemplo n.º 27
0
 /// <summary>
 /// Creates the event argument object
 /// </summary>
 /// <param name="element"></param>
 /// <param name="reason"></param>
 public UpdateUIEventArgs(IElement element, UpdateReason reason)
     : base()
 {
     CurrentElement = element;
     Reason         = reason;
 }
Exemplo n.º 28
0
 public async Task <bool> UpdateProviderAsync(IMediaListProvider provider, int maxItems, UpdateReason updateReason)
 {
     try
     {
         return(await provider.UpdateItemsAsync(maxItems, updateReason));
     }
     catch (Exception ex)
     {
         ServiceRegistration.Get <ILogger>().Error("Error updating Media List {0}", provider.GetType().Name, ex);
         return(false);
     }
 }
 protected virtual async Task <bool> UpdateProviderAsync(IContentListProvider provider, int maxItems, UpdateReason updateReason)
 {
     try
     {
         return(await provider.UpdateItemsAsync(maxItems, updateReason));
     }
     catch (Exception ex)
     {
         ServiceRegistration.Get <ILogger>().Error("Error updating Content List {0}", ex, provider.GetType().Name);
         return(false);
     }
 }
        protected virtual async Task <bool> UpdateAllProvidersAsync()
        {
            try
            {
                var contentDirectory = ServiceRegistration.Get <IServerConnectionManager>().ContentDirectory;
                if (ServerConnectionRequired && contentDirectory == null)
                {
                    //Server not connected. Request update when it does
                    _updatePending = true;
                    return(false);
                }

                IUserManagement userProfileDataManagement = ServiceRegistration.Get <IUserManagement>(false);

                UpdateReason updateReason = UpdateReason.None;
                if (_updatePending || UpdateRequired)
                {
                    updateReason |= UpdateReason.Forced;
                }
                if (_importUpdatePending)
                {
                    updateReason |= UpdateReason.ImportComplete;
                }
                if (_playbackUpdatePending)
                {
                    updateReason |= UpdateReason.PlaybackComplete;
                }
                if (_nextMinute < DateTime.UtcNow)
                {
                    updateReason |= UpdateReason.PeriodicMinute;
                }
                if (_mediaItemUpdatePending)
                {
                    updateReason |= UpdateReason.MediaItemChanged;
                }
                if (userProfileDataManagement?.CurrentUser != null && _currentUserId != userProfileDataManagement.CurrentUser.ProfileId)
                {
                    updateReason |= UpdateReason.UserChanged;
                }
                if (updateReason == UpdateReason.None)
                {
                    return(false);
                }

                _updatePending          = false;
                _importUpdatePending    = false;
                _playbackUpdatePending  = false;
                _mediaItemUpdatePending = false;
                if (userProfileDataManagement?.CurrentUser != null)
                {
                    _currentUserId = userProfileDataManagement.CurrentUser.ProfileId;
                }
                _nextMinute = DateTime.UtcNow.AddMinutes(1);

                int maxItems = Limit;
                foreach (var provider in _listProviders.EnabledProviders)
                {
                    await UpdateProviderAsync(provider, maxItems, updateReason);
                }

                return(true);
            }
            catch (Exception ex)
            {
                ServiceRegistration.Get <ILogger>().Error("Error updating Content List", ex);
                return(false);
            }
        }
Exemplo n.º 31
0
 protected override bool ShouldUpdate(UpdateReason updateReason)
 {
     return(updateReason.HasFlag(UpdateReason.ImportComplete) || base.ShouldUpdate(updateReason));
 }
Exemplo n.º 32
0
        public virtual async Task <bool> UpdateItemsAsync(int maxItems, UpdateReason updateReason)
        {
            if (!ShouldUpdate(updateReason))
            {
                return(false);
            }

            if (_playableConverterAction == null && _playableContainerConverterAction == null)
            {
                return(false);
            }

            var contentDirectory = ServiceRegistration.Get <IServerConnectionManager>().ContentDirectory;

            if (contentDirectory == null)
            {
                return(false);
            }

            MediaItemQuery query = await CreateQueryAsync();

            if (query == null)
            {
                return(false);
            }
            query.Limit = (uint)maxItems;

            Guid?userProfile = CurrentUserProfile?.ProfileId;
            bool showVirtual = VirtualMediaHelper.ShowVirtualMedia(_necessaryMias);

            var items = await contentDirectory.SearchAsync(query, true, userProfile, showVirtual);

            lock (_allItems.SyncRoot)
            {
                if (_currentMediaItems != null && _currentMediaItems.Select(m => m.MediaItemId).SequenceEqual(items.Select(m => m.MediaItemId)))
                {
                    return(false);
                }
                _currentMediaItems = items;
                IEnumerable <ListItem> listItems;
                if (_playableConverterAction != null)
                {
                    listItems = items.Select(mi =>
                    {
                        PlayableMediaItem listItem = _playableConverterAction(mi);
                        listItem.Command           = new MethodDelegateCommand(() => PlayItemsModel.CheckQueryPlayAction(listItem.MediaItem));
                        return(listItem);
                    });
                }
                else
                {
                    listItems = items.Select(mi => _playableContainerConverterAction(mi));
                }

                _allItems.Clear();
                CollectionUtils.AddAll(_allItems, listItems);
            }

            _allItems.FireChange();
            return(true);
        }
Exemplo n.º 33
0
 public UpdateUserDialogOptions(UpdateReason reason)
 {
     this.Reason = reason;
 }
Exemplo n.º 34
0
 protected virtual bool ShouldUpdate(UpdateReason updateReason)
 {
     return(updateReason.HasFlag(UpdateReason.Forced));
 }
 public UpdateAddressDialogOptions(UpdateReason reason)
 {
     Reason = reason;
 }
Exemplo n.º 36
0
 protected override bool ShouldUpdate(UpdateReason updateReason)
 {
     return(updateReason.HasFlag(UpdateReason.MediaItemChanged) || base.ShouldUpdate(updateReason));
 }