Ejemplo n.º 1
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);
            }
        }