示例#1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: protected void executeCustomStrategy(org.camunda.bpm.engine.impl.interceptor.CommandContext commandContext, org.camunda.bpm.engine.impl.persistence.entity.JobEntity job, org.camunda.bpm.engine.impl.pvm.process.ActivityImpl activity) throws Exception
        protected internal virtual void executeCustomStrategy(CommandContext commandContext, JobEntity job, ActivityImpl activity)
        {
            FailedJobRetryConfiguration retryConfiguration = getFailedJobRetryConfiguration(job, activity);

            if (retryConfiguration == null)
            {
                executeStandardStrategy(commandContext);
            }
            else
            {
                if (isFirstJobExecution(job))
                {
                    // then change default retries to the ones configured
                    initializeRetries(job, retryConfiguration.Retries);
                }
                else
                {
                    LOG.debugDecrementingRetriesForJob(job.Id);
                }

                IList <string> intervals       = retryConfiguration.RetryIntervals;
                int            intervalsCount  = intervals.Count;
                int            indexOfInterval = Math.Max(0, Math.Min(intervalsCount - 1, intervalsCount - (job.Retries - 1)));
                DurationHelper durationHelper  = getDurationHelper(intervals[indexOfInterval]);
                job.LockExpirationTime = durationHelper.DateAfter;

                logException(job);
                decrementRetries(job);
                notifyAcquisition(commandContext);
            }
        }
示例#2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotExceedNumberWithStartDate() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        public virtual void shouldNotExceedNumberWithStartDate()
        {
            DurationHelper dh = new DurationHelper("R2/PT10S", new DateTime());

            assertEquals(20000, dh.getDateAfter(new DateTime(15000)).Ticks);
            assertNull(dh.getDateAfter(new DateTime(30000)));
        }
示例#3
0
        private void Test17()
        {
            var transform = new CompositeTransform();

            TestBorder.RenderTransform = transform;

            var story           = GetNewStoryBoard(transform, "CenterX");
            var animationCenter = (DoubleAnimation)story.Children.First();

            animationCenter.From = 0;
            animationCenter.To   = 100;

            var animation = new DoubleAnimation();

            animation.From     = 0;
            animation.To       = 360;
            animation.Duration = DurationHelper.FromTimeSpan(TimeSpan.FromSeconds(3));
            animation.EnableDependentAnimation = true;

            Storyboard.SetTarget(animation, transform);
            Storyboard.SetTargetProperty(animation, "Rotation");

            story.Children.Add(animation);

            story.Begin();
        }
示例#4
0
        public PlayerToViewModelMappingProfile()
        {
            CreateMap <Player, PlayerProfileViewModel>();

            CreateMap <List <PlayerSession>, PlayerSessionListViewModel>()
            .ForMember(g => g.Items, map => map.MapFrom(vm => Mapper.Map <List <PlayerSessionItemViewModel> >(vm)))
            .ForMember(g => g.AvgDuration, map => map.MapFrom(vm => DurationHelper.GetDuration(vm.Sum(c => c.End.Subtract(c.Begin).Ticks / vm.Count))))
            .ForMember(g => g.DayCount, map => map.MapFrom(vm => vm.Count))
            .ForMember(g => g.AvgInput, map => map.MapFrom(vm => (vm.Sum(c => c.Input) / vm.Count).ToString(true)))
            .ForMember(g => g.AvgOutput, map => map.MapFrom(vm => (vm.Sum(c => c.Output) / vm.Count).ToString(true)))
            .ForMember(g => g.Profit, map => map.MapFrom(vm => (vm.Sum(c => c.Output) - vm.Sum(c => c.Input)).ToString(true)));

            CreateMap <PlayerItem, PlayerProfileItemViewModel>()
            .ForMember(g => g.LastGameDate, map => map.MapFrom(vm => vm.LastGameDate.ToString("dd.MM")))
            .ForMember(g => g.Input, map => map.MapFrom(vm => vm.Input.ToString(true)))
            .ForMember(g => g.Output, map => map.MapFrom(vm => vm.Output.ToString(true)))
            .ForMember(g => g.Total, map => map.MapFrom(vm => vm.Total.ToString(true)))
            .ForMember(g => g.Phone, map => map.MapFrom(vm => String.Format("{0:+# (###) ###-##-##}", vm.Phone)))
            .ForMember(g => g.Time, map => map.MapFrom(vm => vm.Time.GetDuration()));

            CreateMap <PlayerSession, PlayerSessionItemViewModel>()
            .ForMember(g => g.DateTime, map => map.MapFrom(vm => vm.Begin.ToString("dd.MM")))
            .ForMember(g => g.Input, map => map.MapFrom(vm => vm.Input.ToString(true)))
            .ForMember(g => g.Output, map => map.MapFrom(vm => vm.Output.ToString(true)))
            .ForMember(g => g.Duration, map => map.MapFrom(vm => DurationHelper.GetDuration(vm.Begin, vm.End)));
        }
示例#5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotExceedNumberPeriodsWithStartDate() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        public virtual void shouldNotExceedNumberPeriodsWithStartDate()
        {
            DurationHelper dh = new DurationHelper("R2/1970-01-01T00:00:00/1970-01-01T00:00:10", parse("19700101-00:00:00"));

            assertEquals(parse("19700101-00:00:20"), dh.getDateAfter(parse("19700101-00:00:15")));
            assertNull(dh.getDateAfter(parse("19700101-00:00:30")));
        }
        async public Task GetDuratioinTest_1()
        {
            var api      = new EtaSDK.v3.EtaApi();
            var response = await api.GetCatalogListAsync(null);

            if (response.HasErrors)
            {
                TestCompleteWithErrorsUISafe("Catalog error: " + response.Error.Message);
            }
            else
            {
                var catalogs = response.Result;
                if (catalogs == null || !catalogs.Any())
                {
                    TestCompleteWithErrorsUISafe("Catalog null or Empty");
                }
                else
                {
                    var catalog       = catalogs.First();
                    var durationLabel = DurationHelper.GetDurationLabel(catalog.RunFrom, catalog.RunTill);
                    if (string.IsNullOrWhiteSpace(durationLabel))
                    {
                        TestCompleteWithErrorsUISafe("durationLabel null or Empty");
                    }
                    TestCompleteUISafe();
                }
            }
        }
示例#7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotExceedNumberNegativeWithStartDate() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        public virtual void shouldNotExceedNumberNegativeWithStartDate()
        {
            DurationHelper dh = new DurationHelper("R2/PT10S/1970-01-01T00:00:50", parse("19700101-00:00:00"));

            assertEquals(parse("19700101-00:00:30"), dh.getDateAfter(parse("19700101-00:00:20")));

            assertEquals(parse("19700101-00:00:40"), dh.getDateAfter(parse("19700101-00:00:35")));
        }
        public static NSAttributedString AttributedStringFor(string durationText, UIFont font)
        {
            var prefixLength = DurationHelper.LengthOfDurationPrefix(durationText);
            var result       = new NSMutableAttributedString(durationText, font: font.GetMonospacedDigitFont(), foregroundColor: UIColor.Black);

            result.AddAttribute(UIStringAttributeKey.ForegroundColor, placeHolderColor, new NSRange(0, prefixLength));
            return(result);
        }
示例#9
0
        public virtual void ShouldNotExceedNumberPeriods()
        {
            ClockUtil.CurrentTime = Parse("19700101-00:00:00");
            var dh = new DurationHelper("R2/1970-01-01T00:00:00/1970-01-01T00:00:10");

            ClockUtil.CurrentTime = Parse("19700101-00:00:15");
            Assert.AreEqual(Parse("19700101-00:00:20"), dh.DateAfter);


            ClockUtil.CurrentTime = Parse("19700101-00:00:30");
            Assert.IsNull(dh.DateAfter);
        }
示例#10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotExceedNumber() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        public virtual void shouldNotExceedNumber()
        {
            ClockUtil.CurrentTime = new DateTime();
            DurationHelper dh = new DurationHelper("R2/PT10S");

            ClockUtil.CurrentTime = new DateTime(15000);
            assertEquals(20000, dh.DateAfter.Ticks);


            ClockUtil.CurrentTime = new DateTime(30000);
            assertNull(dh.DateAfter);
        }
示例#11
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotExceedNumberPeriods() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        public virtual void shouldNotExceedNumberPeriods()
        {
            ClockUtil.CurrentTime = parse("19700101-00:00:00");
            DurationHelper dh = new DurationHelper("R2/1970-01-01T00:00:00/1970-01-01T00:00:10");

            ClockUtil.CurrentTime = parse("19700101-00:00:15");
            assertEquals(parse("19700101-00:00:20"), dh.DateAfter);


            ClockUtil.CurrentTime = parse("19700101-00:00:30");
            assertNull(dh.DateAfter);
        }
示例#12
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotExceedNumberNegative() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        public virtual void shouldNotExceedNumberNegative()
        {
            ClockUtil.CurrentTime = parse("19700101-00:00:00");
            DurationHelper dh = new DurationHelper("R2/PT10S/1970-01-01T00:00:50");

            ClockUtil.CurrentTime = parse("19700101-00:00:20");
            assertEquals(parse("19700101-00:00:30"), dh.DateAfter);


            ClockUtil.CurrentTime = parse("19700101-00:00:35");

            assertEquals(parse("19700101-00:00:40"), dh.DateAfter);
        }
示例#13
0
        public bool DecreaseDuration()
        {
            var newDuration = DurationHelper.Decrease(Duration);

            bool isSuccess = newDuration != Duration;

            if (isSuccess)
            {
                Duration = newDuration;
            }

            return(isSuccess);
        }
示例#14
0
 protected PhoneLocalPlayer()
 {
     Playlist = new PhoneLocalPlaylist();
     player.PlayStateChanged += (s, e) => {
         UpdatePlayerState();
     };
     UpdatePlayerState();
     TrackChanged += async track => {
         if (track != null && track.IsSourceLocal && track.Duration.TotalSeconds == 0)
         {
             track.Duration = await DurationHelper.GetDuration(track);
         }
     };
 }
示例#15
0
        public virtual void ShouldNotExceedNumber()
        {
            ClockUtil.CurrentTime = new DateTime(1970, 1, 1);
            var dh = new DurationHelper("R2/PT10S");

            ClockUtil.CurrentTime = new DateTime(1970, 1, 1).AddSeconds(15);
            var test = dh.DateAfter;

            Assert.AreEqual(20, dh.DateAfter.Value.TimeOfDay.Seconds);


            ClockUtil.CurrentTime = new DateTime(1970, 1, 1).AddSeconds(30);
            Assert.IsNull(dh.DateAfter);
        }
示例#16
0
        private void LaunchAnimation2(object sender, TappedRoutedEventArgs e)
        {
            var animation = new DoubleAnimation
            {
                To       = 0,
                Duration = DurationHelper.FromTimeSpan(TimeSpan.FromSeconds(10))
            };

            Storyboard.SetTargetProperty(animation, nameof(TranslateTransform.Y));
            Storyboard.SetTarget(animation, _transform);

            new Storyboard
            {
                Children = { animation }
            }.Begin();
        }
示例#17
0
        private Storyboard GetNewStoryBoard(DependencyObject target, string property = "Height")
        {
            var storyBoard = new Storyboard();

            var animation = new DoubleAnimation();

            animation.From     = 0;
            animation.To       = 100;
            animation.Duration = DurationHelper.FromTimeSpan(TimeSpan.FromSeconds(3));
            animation.EnableDependentAnimation = true;

            Storyboard.SetTarget(animation, target);
            Storyboard.SetTargetProperty(animation, property);

            storyBoard.Children.Add(animation);

            return(storyBoard);
        }
        private void Animate(UIElement element, string targetProperty, double to)
        {
            var anim = new DoubleAnimation()
            {
                To             = to,
                Duration       = DurationHelper.FromTimeSpan(DURATION),
                EasingFunction = new CubicEase()
                {
                    EasingMode = EasingMode.EaseInOut
                }
            };

            var storyboard = new Storyboard();

            Storyboard.SetTarget(anim, element);
            Storyboard.SetTargetProperty(anim, targetProperty);

            storyboard.Children.Add(anim);
            storyboard.Begin();
        }
        private Storyboard CreateAnimation(UIElement target, FillBehavior fill)
        {
            var animation = new DoubleAnimation
            {
                To           = 0,
                Duration     = DurationHelper.FromTimeSpan(_duration),
                FillBehavior = fill
            };

            if (UseFromValue.IsChecked.GetValueOrDefault())
            {
                animation.From = .75;
            }

            Storyboard.SetTarget(animation, target);
            Storyboard.SetTargetProperty(animation, nameof(UIElement.Opacity));

            return(new Storyboard
            {
                Children = { animation }
            });
        }
示例#20
0
        public static FailedJobRetryConfiguration parseRetryIntervals(string retryIntervals)
        {
            if (!string.ReferenceEquals(retryIntervals, null) && retryIntervals.Length > 0)
            {
                if (StringUtil.isExpression(retryIntervals))
                {
                    ExpressionManager expressionManager = Context.ProcessEngineConfiguration.ExpressionManager;
                    Expression        expression        = expressionManager.createExpression(retryIntervals);
                    return(new FailedJobRetryConfiguration(expression));
                }

                string[] intervals = StringUtil.Split(retryIntervals, ",");
                int      retries   = intervals.Length + 1;

                if (intervals.Length == 1)
                {
                    try
                    {
                        DurationHelper durationHelper = new DurationHelper(intervals[0]);

                        if (durationHelper.Repeat)
                        {
                            retries = durationHelper.Times;
                        }
                    }
                    catch (Exception e)
                    {
                        LOG.logParsingRetryIntervals(intervals[0], e);
                        return(null);
                    }
                }
                return(new FailedJobRetryConfiguration(retries, Arrays.asList(intervals)));
            }
            else
            {
                return(null);
            }
        }
示例#21
0
        public virtual object Execute(ICommandContext commandContext)
        {
            IJobEntity job = commandContext.JobEntityManager.FindById <IJobEntity>(new KeyValuePair <string, object>("id", jobId));

            if (job == null)
            {
                return(null);
            }

            ProcessEngineConfiguration processEngineConfig = commandContext.ProcessEngineConfiguration;

            IExecutionEntity executionEntity    = fetchExecutionEntity(commandContext, job.ExecutionId);
            FlowElement      currentFlowElement = executionEntity != null ? executionEntity.CurrentFlowElement : null;

            string failedJobRetryTimeCycleValue = null;

            if (currentFlowElement is ServiceTask)
            {
                failedJobRetryTimeCycleValue = ((ServiceTask)currentFlowElement).FailedJobRetryTimeCycleValue;
            }

            IAbstractJobEntity newJobEntity = null;

            if (currentFlowElement == null || ReferenceEquals(failedJobRetryTimeCycleValue, null))
            {
                log.LogDebug("activity or FailedJobRetryTimerCycleValue is null in job " + jobId + ". only decrementing retries.");

                if (job.Retries <= 1)
                {
                    newJobEntity = commandContext.JobManager.MoveJobToDeadLetterJob(job);
                }
                else
                {
                    newJobEntity = commandContext.JobManager.MoveJobToTimerJob(job);
                }

                newJobEntity.Retries = job.Retries - 1;
                if (!job.Duedate.HasValue || JobFields.JOB_TYPE_MESSAGE.Equals(job.JobType))
                {
                    // add wait time for failed async job
                    newJobEntity.Duedate = calculateDueDate(commandContext, processEngineConfig.AsyncFailedJobWaitTime, null);
                }
                else
                {
                    // add default wait time for failed job
                    newJobEntity.Duedate = calculateDueDate(commandContext, processEngineConfig.DefaultFailedJobWaitTime, job.Duedate);
                }
            }
            else
            {
                try
                {
                    DurationHelper durationHelper = new DurationHelper(failedJobRetryTimeCycleValue, processEngineConfig.Clock);
                    int            jobRetries     = job.Retries;
                    if (ReferenceEquals(job.ExceptionMessage, null))
                    {
                        // change default retries to the ones configured
                        jobRetries = durationHelper.Times;
                    }

                    if (jobRetries <= 1)
                    {
                        newJobEntity = commandContext.JobManager.MoveJobToDeadLetterJob(job);
                    }
                    else
                    {
                        newJobEntity = commandContext.JobManager.MoveJobToTimerJob(job);
                    }

                    newJobEntity.Duedate = durationHelper.DateAfter;

                    if (ReferenceEquals(job.ExceptionMessage, null))
                    {
                        // is it the first exception
                        log.LogDebug("Applying JobRetryStrategy '" + failedJobRetryTimeCycleValue + "' the first time for job " + job.Id + " with " + durationHelper.Times + " retries");
                    }
                    else
                    {
                        log.LogDebug("Decrementing retries of JobRetryStrategy '" + failedJobRetryTimeCycleValue + "' for job " + job.Id);
                    }

                    newJobEntity.Retries = jobRetries - 1;
                }
                catch (Exception)
                {
                    throw new ActivitiException("failedJobRetryTimeCylcle has wrong format:" + failedJobRetryTimeCycleValue, exception);
                }
            }

            if (exception != null)
            {
                newJobEntity.ExceptionMessage    = exception.Message;
                newJobEntity.ExceptionStacktrace = ExceptionStacktrace;
            }

            // Dispatch both an update and a retry-decrement event
            IActivitiEventDispatcher eventDispatcher = commandContext.EventDispatcher;

            if (eventDispatcher.Enabled)
            {
                eventDispatcher.DispatchEvent(ActivitiEventBuilder.CreateEntityEvent(ActivitiEventType.ENTITY_UPDATED, newJobEntity));
                eventDispatcher.DispatchEvent(ActivitiEventBuilder.CreateEntityEvent(ActivitiEventType.JOB_RETRIES_DECREMENTED, newJobEntity));
            }

            return(null);
        }
示例#22
0
 protected override Task EnsureHasDuration(MusicItem track)
 {
     return(DurationHelper.SetDuration(track));
 }
示例#23
0
 public void Dotify(string dots, string direction)
 {
     Length = DurationHelper.Dotify(Length, dots, direction);
 }
示例#24
0
 protected internal virtual void SetLockExpirationTime(JobEntity job, string failedJobRetryTimeCycle,
                                                       DurationHelper durationHelper)
 {
     job.LockExpirationTime = durationHelper.DateAfter;
 }
示例#25
0
            public void CalculatesTheLengthOfPrefixCorrectly(string duration, int expectedPrefixLength)
            {
                var prefixLength = DurationHelper.LengthOfDurationPrefix(duration);

                prefixLength.Should().Be(expectedPrefixLength);
            }
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            try
            {
                if (convertView == null)
                {
                    if (_activity != null)
                    {
                        convertView = _activity.LayoutInflater.Inflate(Resource.Layout.MusicPlayListTrackListItem, parent, false);
                    }
                    else if (parent != null)
                    {
                        LayoutInflater inflater = (LayoutInflater)parent.Context.GetSystemService(Context.LayoutInflaterService);
                        convertView = inflater.Inflate(Resource.Layout.MusicPlayListTrackListItem, parent, false);
                    }
                    else
                    {
                        return(convertView);
                    }
                }

                if (convertView != null)
                {
                    GetFieldComponents(convertView);

                    if (_trackTitle != null)
                    {
                        _trackTitle.Text = _tracksList[position].TrackName.Trim();
                    }
                    if (_artist != null)
                    {
                        _artist.Text = _tracksList[position].TrackArtist.Trim();
                    }
                    if (_duration != null)
                    {
                        DurationHelper.Duration duration = DurationHelper.ConvertMillisToDuration((long)_tracksList[position].TrackDuration);
                        _duration.Text = string.Format("{0:00}:{1:00}:{2:00}", duration.Hours, duration.Minutes, duration.Seconds);
                    }

                    if (((MusicPlayListTracksActivity)_activity).GetSelectedListItemIndex() == position)
                    {
                        Log.Info(TAG, "GetView: Determined selected track at position - " + position.ToString());
                        convertView.SetBackgroundColor(Color.Argb(255, 19, 75, 127));
                        if (_trackTitle != null)
                        {
                            _trackTitle.SetBackgroundColor(Color.Argb(255, 19, 75, 127));
                        }
                        if (_artist != null)
                        {
                            _artist.SetBackgroundColor(Color.Argb(255, 19, 75, 127));
                        }
                        if (_duration != null)
                        {
                            _duration.SetBackgroundColor(Color.Argb(255, 19, 75, 127));
                        }
                        if (_mainLayout != null)
                        {
                            _mainLayout.SetBackgroundColor(Color.Argb(255, 19, 75, 127));
                        }
                        Log.Info(TAG, "GetView: Detected selected item, set background dark");
                    }
                    else
                    {
                        convertView.SetBackgroundDrawable(null);
                        if (_trackTitle != null)
                        {
                            _trackTitle.SetBackgroundDrawable(null);
                        }
                        if (_artist != null)
                        {
                            _artist.SetBackgroundDrawable(null);
                        }
                        if (_duration != null)
                        {
                            _duration.SetBackgroundDrawable(null);
                        }
                        if (_mainLayout != null)
                        {
                            _mainLayout.SetBackgroundDrawable(null);
                        }
                    }

                    var isPlaying    = ((MusicPlayListTracksActivity)_activity).IsPlaying;
                    var isPaused     = ((MusicPlayListTracksActivity)_activity).IsPaused;
                    var playingIndex = ((MusicPlayListTracksActivity)_activity).GetCurrentlyPlayingIndex;
                    if (isPlaying || isPaused)
                    {
                        Log.Info(TAG, "GetView: Playing or paused, position - " + position.ToString() + ", playingIndex - " + playingIndex.ToString());
                        if (playingIndex == position)
                        {
                            if (_wave != null)
                            {
                                Log.Info(TAG, "GetView: Setting animation...");
                                _wave.SetBackgroundResource(Resource.Drawable.wave);
                                AnimationDrawable background = (AnimationDrawable)_wave.Background;
                                _wave.Visibility = ViewStates.Visible;
                                if (isPaused)
                                {
                                    Log.Info(TAG, "GetView: Paused, stopping animation playback");
                                    background.Stop();
                                }
                                if (isPlaying && !isPaused)
                                {
                                    Log.Info(TAG, "GetView: Playing, starting animation playback");
                                    background.Stop();
                                    background.Start();
                                }
                            }
                        }
                        else
                        {
                            if (_wave != null)
                            {
                                _wave.Visibility = ViewStates.Invisible;
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Log.Error(TAG, "GetView: Exception - " + e.Message);
                if (GlobalData.ShowErrorDialog)
                {
                    ErrorDisplay.ShowErrorAlert(_activity, e, _activity.GetString(Resource.String.ErrorMusicPlayListTracksGetView), "MusicPlayListTracksListAdapter.GetView");
                }
            }
            return(convertView);
        }
示例#27
0
 protected internal virtual void InitializeRetries(JobEntity job, string failedJobRetryTimeCycle,
                                                   DurationHelper durationHelper)
 {
     Log.DebugInitiallyAppyingRetryCycleForJob(job.Id, durationHelper.Times);
     job.Retries = durationHelper.Times;
 }