示例#1
0
        public async Task <bool> AddAppStatus(string appKey, AppStatusType appStatusType)
        {
            var result = false;

            if (AppStatusDic.ContainsKey(appKey))
            {
                AppStatusType statusType;
                if (AppStatusDic.TryGetValue(appKey, out statusType))
                {
                    if (AppStatusDic.TryUpdate(appKey, appStatusType, statusType))
                    {
                        result = true;
                    }
                }
            }
            else
            {
                if (AppStatusDic.TryAdd(appKey, appStatusType))
                {
                    result = true;
                }
            }
            await _notificationVm.AddAppStatus(appKey, appStatusType);

            return(result);
        }
示例#2
0
        public async Task <bool> AddAppStatus(string appKey, AppStatusType appStatusType)
        {
            var result = await SendCommand(async() =>
            {
                await DispatcherHelper.RunAsync(() =>
                {
                    Messenger.Default.Send(new NotificationMessage(string.Format("{0} 正在添加App状态命令。", appKey)));
                    var notificationInfo = _notificationInfos.FirstOrDefault(s => s.AppKey == appKey);
                    if (notificationInfo == null)
                    {
                        var newNotificationInfo = new NotificationInfo(appKey)
                        {
                            AppStatusType = appStatusType
                        };
                        newNotificationInfo.Removed += NewNotificationInfo_Removed;
                        _notificationInfos.Add(newNotificationInfo);
                    }
                    else
                    {
                        notificationInfo.AppStatusType = appStatusType;
                    }
                });
                return(true);
            });

            return(result);
        }
 /// <summary>
 /// 直近のアプリ状態を設定する。
 /// </summary>
 /// <param name="statusType">状態種別。</param>
 /// <param name="statusText">状態テキスト。</param>
 /// <param name="subStatusType">オプショナルなサブ状態種別。</param>
 /// <param name="subStatusText">オプショナルなサブ状態テキスト。</param>
 /// <param name="subStatusCommand">オプショナルなサブ状態コマンド。</param>
 /// <param name="subStatusCommandTip">
 /// オプショナルなサブ状態コマンドのチップテキスト。
 /// </param>
 private void SetLastStatus(
     AppStatusType statusType    = AppStatusType.None,
     string statusText           = "",
     AppStatusType subStatusType = AppStatusType.None,
     string subStatusText        = "",
     ICommand subStatusCommand   = null,
     string subStatusCommandTip  = "")
 =>
 this.LastStatus.Value =
     new AppStatus
 {
     StatusType          = statusType,
     StatusText          = statusText ?? "",
     SubStatusType       = subStatusType,
     SubStatusText       = subStatusText ?? "",
     SubStatusCommand    = subStatusCommand,
     SubStatusCommandTip =
         string.IsNullOrEmpty(subStatusCommandTip) ?
         null : subStatusCommandTip,
 };
示例#4
0
 /// <summary>
 /// コマンド戻り値を作成する。
 /// </summary>
 /// <param name="parameter">コマンドパラメータ。</param>
 /// <param name="statusType">状態種別。</param>
 /// <param name="statusText">状態テキスト。</param>
 /// <param name="subStatusType">オプショナルなサブ状態種別。</param>
 /// <param name="subStatusText">オプショナルなサブ状態テキスト。</param>
 /// <param name="subStatusCommand">オプショナルなサブ状態コマンド。</param>
 /// <param name="subStatusCommandTip">
 /// オプショナルなサブ状態コマンドのチップテキスト。
 /// </param>
 private static CommandResult MakeResult(
     CommandParameter parameter,
     AppStatusType statusType    = AppStatusType.None,
     string statusText           = "",
     AppStatusType subStatusType = AppStatusType.None,
     string subStatusText        = "",
     ICommand subStatusCommand   = null,
     string subStatusCommandTip  = "")
 =>
 new CommandResult(
     new AppStatus
 {
     StatusType          = statusType,
     StatusText          = statusText ?? "",
     SubStatusType       = subStatusType,
     SubStatusText       = subStatusText ?? "",
     SubStatusCommand    = subStatusCommand,
     SubStatusCommandTip =
         string.IsNullOrEmpty(subStatusCommandTip) ?
         null : subStatusCommandTip,
 },
     parameter);
示例#5
0
 public async Task <bool> AddAppStatus(string appKey, AppStatusType appStatusType)
 {
     return(await NotificationSourceService.AddAppStatus(appKey, appStatusType));
 }