コード例 #1
0
 private void AddPrompt(UserPrompt prompt)
 {
     _userPromptsLock.Enter();
     _userPrompts.Add(prompt);
     _userPromptsLock.Leave();
     _systemWait.Set();
 }
コード例 #2
0
        /// <summary>
        /// Prompt all user interfaces for an action (system wide)
        /// </summary>
        /// <param name="responseCallBack">The callback delegate for when someone responds</param>
        /// <param name="customSubPageJoin">Set to 0 for default</param>
        /// <param name="title">The title of the prompt</param>
        /// <param name="subTitle">The subtitle of the response</param>
        /// <param name="timeOutInSeconds">Timeout in seconds for the prompt. 0 is no timeout</param>
        /// <param name="userDefinedObject">User defined object to pass</param>
        /// <param name="promptActions">Array of actions to display (eg. buttons on actionsheet)</param>
        /// <returns>UserPrompt instance</returns>
        public UserPrompt PromptUsers(PromptUsersResponse responseCallBack, uint customSubPageJoin, string title, string subTitle,
                                      uint timeOutInSeconds, object userDefinedObject, params PromptAction[] promptActions)
        {
            var prompt = new UserPrompt
            {
                Actions           = promptActions.ToList(),
                CallBack          = responseCallBack,
                Title             = title,
                SubTitle          = subTitle,
                TimeOutInSeconds  = timeOutInSeconds,
                UserDefinedObject = userDefinedObject,
                CustomSubPageJoin = customSubPageJoin
            };

            AddPrompt(prompt);

            return(prompt);
        }
コード例 #3
0
        protected virtual void AutoUpdateOnAutoUpdateChange(AutoUpdateEventArgs args)
        {
            try
            {
                switch (args.EventId)
                {
                case AutoUpdateEventIds.UpdateIsAvailable:
                    Debug.WriteSuccess("AutoUpdate Available", "Showing postpont prompt on all UIs");
                    _auPrompt = PromptUsers(prompt =>
                    {
                        if (prompt.Response.Responded)
                        {
                            AutoUpdate.PerformUpdateInResponseToEvent(prompt.Response.Action.ActionType ==
                                                                      PromptActionType.Acknowledge);
                        }
                    }, "System Update", "The system is about to commence an auto system update", 30, null,
                                            new PromptAction
                    {
                        ActionName = "Update Now",
                        ActionType = PromptActionType.Acknowledge
                    },
                                            new PromptAction
                    {
                        ActionName = "Postpone",
                        ActionType = PromptActionType.Cancel
                    });
                    break;

                case AutoUpdateEventIds.UpdateConfirmed:
                    Debug.WriteSuccess("AutoUpdate allowed by user");
                    _auPrompt = PromptUsers(prompt => { }, "System Update In Progress", "The system may restart",
                                            500, null);
                    break;

                case AutoUpdateEventIds.UpdateConfirmedViaTimeout:
                    Debug.WriteWarn("AutoUpdate prompt timed out .... continuing with update");
                    if (_auPrompt != null)
                    {
                        _auPrompt.Cancel();
                    }
                    break;

                case AutoUpdateEventIds.UpdateDenied:
                    Debug.WriteWarn("AutoUpdate denied by user");
                    break;

                case AutoUpdateEventIds.UpdateStartedWithNoConfirmation:
                    Debug.WriteWarn("AutoUpdate Started With No Confirmation!");
                    _auPrompt = PromptUsers(prompt => { }, "System Update In Progress", "The system may restart",
                                            500, null);
                    break;

                case AutoUpdateEventIds.ErrorMessage:
                    if (AutoUpdate.LastErrorReceived.Length > 0)
                    {
                        CloudLog.Error("AutoUpdate error: {0}", AutoUpdate.LastErrorReceived);
                    }
                    break;

                case AutoUpdateEventIds.UpdateFinished:
                    Debug.WriteSuccess("AutoUpdate Complete");
                    if (_auPrompt != null && _auPrompt.State == PromptState.Shown)
                    {
                        _auPrompt.Cancel();
                    }
                    break;

                default:
                    Debug.WriteNormal("AutoUpdate State", "{0}  ({1})", AutoUpdate.AutoUpdateState, args.EventId);
                    break;
                }
            }
            catch (Exception e)
            {
                CloudLog.Exception(e);
            }
        }