Ejemplo n.º 1
0
        protected override void LoadComplete()
        {
            base.LoadComplete();

            MaxAttempts.BindValueChanged(_ => updateAttempts());
            UserScore.BindValueChanged(_ => updateAttempts(), true);
        }
Ejemplo n.º 2
0
        protected override void LoadComplete()
        {
            base.LoadComplete();

            MaxAttempts.BindValueChanged(attempts =>
            {
                attemptDisplay.Text = attempts.NewValue == null
                    ? string.Empty
                    : $"Maximum attempts: {attempts.NewValue:N0}";
            }, true);
        }
Ejemplo n.º 3
0
 public IWorkflow Complete()
 {
     return(new Workflow(
                Domain,
                Name,
                Description,
                Version,
                TaskList.AsOption(string.IsNullOrWhiteSpace),
                ListModule.OfSeq(stages).AsOption(),
                TaskStartToCloseTimeout.AsOption(),
                ExecutionStartToCloseTimeout.AsOption(),
                GetChildPolicy(ChildPolicy).AsOption(),
                Identity.AsOption(string.IsNullOrWhiteSpace),
                MaxAttempts.AsOption(),
                Input.AsOption(string.IsNullOrWhiteSpace)));
 }
Ejemplo n.º 4
0
 public IActivity Complete()
 {
     return(new Activity <TInput, TOutput>(
                Name,
                Description,
                TaskHeartbeatTimeout,
                TaskScheduleToStartTimeout,
                TaskStartToCloseTimeout,
                TaskScheduleToCloseTimeout,
                Version.AsOption(string.IsNullOrWhiteSpace),
                TaskList.AsOption(string.IsNullOrWhiteSpace),
                MaxAttempts.AsOption(),
                Input.AsOption(string.IsNullOrWhiteSpace),
                Processor != null
             ? FuncConvert.ToFSharpFunc(new Converter <TInput, TOutput>(Processor)).AsOption()
             : FSharpOption <FSharpFunc <TInput, TOutput> > .None
                ));
 }
Ejemplo n.º 5
0
        private void ActionFailed(NativeActivityFaultContext faultContext, Exception propagatedexception, ActivityInstance propagatedfrom)
        {
            Int32 currentAttemptCount = _attemptCount.Get(faultContext);
            Int32 maxAttempts         = MaxAttempts.Get(faultContext);

            Type[] exceptionType = ExceptionType.Get(faultContext);

            //Increment and track the count
            currentAttemptCount++;
            _attemptCount.Set(faultContext, currentAttemptCount);

            if (currentAttemptCount >= maxAttempts)
            {
                // There are no further attempts to make
                return;
            }

            if (ShouldRetryAction(exceptionType, propagatedexception) == false)
            {
                _log.Error("Will only retry exception of type '" + exceptionType.ToCSV() + "'. Unhandled type of '" + propagatedexception.GetType().FullName + "' was found.", propagatedexception);
                return;
            }

            faultContext.CancelChild(propagatedfrom);
            faultContext.HandleFault();

            TimeSpan retryInterval = _delayOverrideForUnitTests == null?RetryInterval.Get(faultContext) : _delayOverrideForUnitTests.Value;

            _log.Debug("Retrying in " + retryInterval.TotalSeconds + " seconds due to " + propagatedexception.GetType().FullName + ". " + currentAttemptCount + " of " + maxAttempts);

            if (retryInterval == TimeSpan.Zero)
            {
                ExecuteAttempt(faultContext);
            }
            else
            {
                // We are going to wait before trying again
                _delayDuration.Set(faultContext, retryInterval);
                faultContext.ScheduleActivity(
                    _internalDelay,
                    DelayCompleted);
            }
        }
Ejemplo n.º 6
0
        private void ActionFailed(NativeActivityFaultContext faultcontext, Exception propagatedexception, ActivityInstance propagatedfrom)
        {
            Int32 currentAttemptCount = _attemptCount.Get(faultcontext);

            currentAttemptCount++;

            _attemptCount.Set(faultcontext, currentAttemptCount);

            Int32 maxAttempts = MaxAttempts.Get(faultcontext);

            if (currentAttemptCount >= maxAttempts)
            {
                // There are no further attempts to make
                return;
            }

            if (ShouldRetryAction(ExceptionType, propagatedexception) == false)
            {
                return;
            }

            faultcontext.CancelChild(propagatedfrom);
            faultcontext.HandleFault();

            TimeSpan retryInterval = RetryInterval.Get(faultcontext);

            if (retryInterval == TimeSpan.Zero)
            {
                ExecuteAttempt(faultcontext);
            }
            else
            {
                // We are going to wait before trying again
                _delayDuration.Set(faultcontext, retryInterval);

                faultcontext.ScheduleActivity(_internalDelay, DelayCompleted);
            }
        }
Ejemplo n.º 7
0
            private void load(OverlayColourProvider colourProvider, OsuColour colours)
            {
                InternalChildren = new Drawable[]
                {
                    new Box
                    {
                        RelativeSizeAxes = Axes.Both,
                        Colour           = colourProvider.Background4
                    },
                    new GridContainer
                    {
                        RelativeSizeAxes = Axes.Both,
                        RowDimensions    = new[]
                        {
                            new Dimension(),
                            new Dimension(GridSizeMode.AutoSize),
                        },
                        Content = new[]
                        {
                            new Drawable[]
                            {
                                new OsuScrollContainer
                                {
                                    Padding = new MarginPadding
                                    {
                                        Horizontal = OsuScreen.HORIZONTAL_OVERFLOW_PADDING,
                                        Vertical   = 10
                                    },
                                    RelativeSizeAxes = Axes.Both,
                                    Children         = new[]
                                    {
                                        new Container
                                        {
                                            Padding = new MarginPadding {
                                                Horizontal = WaveOverlayContainer.WIDTH_PADDING
                                            },
                                            RelativeSizeAxes = Axes.X,
                                            AutoSizeAxes     = Axes.Y,
                                            Children         = new Drawable[]
                                            {
                                                new SectionContainer
                                                {
                                                    Padding = new MarginPadding {
                                                        Right = FIELD_PADDING / 2
                                                    },
                                                    Children = new[]
                                                    {
                                                        new Section("Room name")
                                                        {
                                                            Child = NameField = new OsuTextBox
                                                            {
                                                                RelativeSizeAxes         = Axes.X,
                                                                TabbableContentContainer = this,
                                                                LengthLimit = 100
                                                            },
                                                        },
                                                        new Section("Duration")
                                                        {
                                                            Child = DurationField = new DurationDropdown
                                                            {
                                                                RelativeSizeAxes = Axes.X,
                                                                Items            = new[]
                                                                {
                                                                    TimeSpan.FromMinutes(30),
                                                                    TimeSpan.FromHours(1),
                                                                    TimeSpan.FromHours(2),
                                                                    TimeSpan.FromHours(4),
                                                                    TimeSpan.FromHours(8),
                                                                    TimeSpan.FromHours(12),
                                                                    //TimeSpan.FromHours(16),
                                                                    TimeSpan.FromHours(24),
                                                                    TimeSpan.FromDays(3),
                                                                    TimeSpan.FromDays(7)
                                                                }
                                                            }
                                                        },
                                                        new Section("Allowed attempts (across all playlist items)")
                                                        {
                                                            Child = MaxAttemptsField = new OsuNumberBox
                                                            {
                                                                RelativeSizeAxes         = Axes.X,
                                                                TabbableContentContainer = this,
                                                                PlaceholderText          = "Unlimited",
                                                            },
                                                        },
                                                        new Section("Room visibility")
                                                        {
                                                            Alpha = disabled_alpha,
                                                            Child = AvailabilityPicker = new RoomAvailabilityPicker
                                                            {
                                                                Enabled = { Value = false }
                                                            },
                                                        },
                                                        new Section("Max participants")
                                                        {
                                                            Alpha = disabled_alpha,
                                                            Child = MaxParticipantsField = new OsuNumberBox
                                                            {
                                                                RelativeSizeAxes         = Axes.X,
                                                                TabbableContentContainer = this,
                                                                ReadOnly = true,
                                                            },
                                                        },
                                                        new Section("Password (optional)")
                                                        {
                                                            Alpha = disabled_alpha,
                                                            Child = new OsuPasswordTextBox
                                                            {
                                                                RelativeSizeAxes         = Axes.X,
                                                                TabbableContentContainer = this,
                                                                ReadOnly = true,
                                                            },
                                                        },
                                                    },
                                                },
                                                new SectionContainer
                                                {
                                                    Anchor  = Anchor.TopRight,
                                                    Origin  = Anchor.TopRight,
                                                    Padding = new MarginPadding {
                                                        Left = FIELD_PADDING / 2
                                                    },
                                                    Children = new[]
                                                    {
                                                        new Section("Playlist")
                                                        {
                                                            Child = new GridContainer
                                                            {
                                                                RelativeSizeAxes = Axes.X,
                                                                Height           = 448,
                                                                Content          = new[]
                                                                {
                                                                    new Drawable[]
                                                                    {
                                                                        playlist = new DrawableRoomPlaylist(true, true)
                                                                        {
                                                                            RelativeSizeAxes = Axes.Both
                                                                        }
                                                                    },
                                                                    new Drawable[]
                                                                    {
                                                                        playlistLength = new OsuSpriteText
                                                                        {
                                                                            Margin = new MarginPadding {
                                                                                Vertical = 5
                                                                            },
                                                                            Colour = colours.Yellow,
                                                                            Font   = OsuFont.GetFont(size: 12),
                                                                        }
                                                                    },
                                                                    new Drawable[]
                                                                    {
                                                                        editPlaylistButton = new PurpleTriangleButton
                                                                        {
                                                                            RelativeSizeAxes = Axes.X,
                                                                            Height           = 40,
                                                                            Text             = "Edit playlist",
                                                                            Action           = () => EditPlaylist?.Invoke()
                                                                        }
                                                                    }
                                                                },
                                                                RowDimensions = new[]
                                                                {
                                                                    new Dimension(),
                                                                    new Dimension(GridSizeMode.AutoSize),
                                                                    new Dimension(GridSizeMode.AutoSize),
                                                                }
                                                            }
                                                        },
                                                    },
                                                },
                                            },
                                        }
                                    },
                                },
                            },
                            new Drawable[]
                            {
                                new Container
                                {
                                    Anchor           = Anchor.BottomLeft,
                                    Origin           = Anchor.BottomLeft,
                                    Y                = 2,
                                    RelativeSizeAxes = Axes.X,
                                    AutoSizeAxes     = Axes.Y,
                                    Children         = new Drawable[]
                                    {
                                        new Box
                                        {
                                            RelativeSizeAxes = Axes.Both,
                                            Colour           = colourProvider.Background5
                                        },
                                        new FillFlowContainer
                                        {
                                            RelativeSizeAxes = Axes.X,
                                            AutoSizeAxes     = Axes.Y,
                                            Direction        = FillDirection.Vertical,
                                            Spacing          = new Vector2(0, 20),
                                            Margin           = new MarginPadding {
                                                Vertical = 20
                                            },
                                            Padding = new MarginPadding {
                                                Horizontal = OsuScreen.HORIZONTAL_OVERFLOW_PADDING
                                            },
                                            Children = new Drawable[]
                                            {
                                                ApplyButton = new CreateRoomButton
                                                {
                                                    Anchor  = Anchor.BottomCentre,
                                                    Origin  = Anchor.BottomCentre,
                                                    Size    = new Vector2(230, 55),
                                                    Enabled = { Value = false },
                                                    Action  = apply,
                                                },
                                                ErrorText = new OsuSpriteText
                                                {
                                                    Anchor = Anchor.BottomCentre,
                                                    Origin = Anchor.BottomCentre,
                                                    Alpha  = 0,
                                                    Depth  = 1,
                                                    Colour = colours.RedDark
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    },
                    loadingLayer = new LoadingLayer(true)
                };

                RoomName.BindValueChanged(name => NameField.Text = name.NewValue, true);
                Availability.BindValueChanged(availability => AvailabilityPicker.Current.Value = availability.NewValue, true);
                MaxParticipants.BindValueChanged(count => MaxParticipantsField.Text            = count.NewValue?.ToString(), true);
                MaxAttempts.BindValueChanged(count => MaxAttemptsField.Text       = count.NewValue?.ToString(), true);
                Duration.BindValueChanged(duration => DurationField.Current.Value = duration.NewValue ?? TimeSpan.FromMinutes(30), true);

                playlist.Items.BindTo(Playlist);
                Playlist.BindCollectionChanged(onPlaylistChanged, true);
            }
Ejemplo n.º 8
0
 /// <summary>
 /// Returns <c>true</c> if we have not hit our execution limit.
 /// </summary>
 /// <param name="context"></param>
 /// <returns></returns>
 bool ExecuteAgain(NativeActivityContext context)
 {
     return(state.Get(context).Attempts.Count() < MaxAttempts.Get(context));
 }
Ejemplo n.º 9
0
        internal Dictionary <string, string> GeneratePostData(string[] keys, Dictionary <string, string> seedParams = null)
        {
            Dictionary <string, string> postData = new Dictionary <string, string>();

            if (seedParams != null)
            {
                seedParams.Keys.ToList().ForEach(key => postData.Add(key, seedParams[key]));
            }

            foreach (string key in keys)
            {
                if (postData.ContainsKey(key))
                {
                    continue;
                }
                switch (key.ToLower())
                {
                case "jvmroute":
                    postData.Add(key, JvmRoute);
                    break;

                case "balancer":
                    if (!string.IsNullOrEmpty(Balancer))
                    {
                        postData.Add(key, Balancer);
                    }
                    break;

                case "domain":
                    if (!string.IsNullOrEmpty(Domain))
                    {
                        postData.Add(key, Domain);
                    }
                    break;

                case "host":
                    if (!string.IsNullOrEmpty(Host))
                    {
                        postData.Add(key, Host);
                    }
                    break;

                case "port":
                    postData.Add(key, Port.ToString());
                    break;

                case "type":
                    if (!string.IsNullOrEmpty(Type))
                    {
                        postData.Add(key, Type);
                    }
                    break;

                case "alias":
                    if (!string.IsNullOrEmpty(Alias))
                    {
                        postData.Add(key, Alias);
                    }
                    break;

                case "stickysession":
                    postData.Add(key, (StickySession ? "yes" : "no"));
                    break;

                case "stickysessionforce":
                    postData.Add(key, (StickySessionForce ? "yes" : "no"));
                    break;

                case "stickysessionremove":
                    postData.Add(key, (StickySessionRemove ? "yes" : "no"));
                    break;

                case "flushpackets":
                    postData.Add(key, (FlushPackets ? "on" : "off"));
                    break;

                case "waitworker":
                    postData.Add(key, WaitWorker.ToString());
                    break;

                case "flushwait":
                    postData.Add(key, Math.Floor(FlushWait.TotalSeconds).ToString());
                    break;

                case "maxattempts":
                    postData.Add(key, MaxAttempts.ToString());
                    break;

                case "stickysessioncookie":
                    if (!string.IsNullOrEmpty(StickySessionCookie))
                    {
                        postData.Add(key, StickySessionCookie);
                    }
                    break;

                case "stickysessionpath":
                    if (!string.IsNullOrEmpty(StickySessionPath))
                    {
                        postData.Add(key, StickySessionPath);
                    }
                    break;

                case "ping":
                    postData.Add("ping", Math.Floor(Ping.TotalSeconds).ToString());
                    break;

                case "smax":
                    if (Smax.HasValue)
                    {
                        postData.Add(key, Smax.ToString());
                    }
                    break;

                case "ttl":
                    postData.Add(key, Math.Floor(Ttl.TotalSeconds).ToString());
                    break;

                case "timeout":
                    postData.Add(key, Math.Floor(Timeout.TotalSeconds).ToString());
                    break;

                default:
                    throw new InvalidProgramException("Cannot map value " + key);
                }
            }
            return(postData);
        }