public async Task NotifyAsync(NotifyTypes notificationType, string notification) { foreach (var notifier in Notifiers.Where(x => x.Type == notificationType)) { await notifier.NotifyAsync(notification); } }
public UserNotifySetting(long uid, Tgnet.FootChat.Data.UserSetting setting, bool isSingle) { _Uid = uid; if (setting == null) { setting = new FootChat.Data.UserSetting { isOpenNightQuiet = true, isOpenShake = true, isOpenVoice = true, isPushNotify = true }; } if (setting.isOpenNightQuiet && (DateTime.Now.Hour > 22 || DateTime.Now.Hour < 8)) { _Type = NotifyTypes.Mute; } if (setting.isOpenVoice && setting.isOpenShake) { _Type = NotifyTypes.SoundAndVibration; } else if (setting.isOpenVoice && !setting.isOpenShake) { _Type = NotifyTypes.Sound; } else if (!setting.isOpenVoice && setting.isOpenShake) { _Type = NotifyTypes.Vibration; } else { _Type = NotifyTypes.Mute; } }
public void CheckCacheValidAndGo <T>(ECacheData type, NotifyTypes notify) where T : class { foreach (KeyValuePair <ECacheData, DataWrapper> pair in this._cacheDataUtilDic) { if (((ECacheData)pair.Key) == type) { CacheData <T> data = pair.Value._data as CacheData <T>; if (data.CacheValid) { Singleton <NotifyManager> .Instance.FireNotify(new Notify(notify, null)); return; } pair.Value._notify = notify; pair.Value._req(); } } }
public Notify(NotifyTypes type, object body = null) { this.type = type; this.body = body; }
/// <summary> /// Record notification results in the database /// </summary> /// <param name="logText"></param> /// <param name="notificationID"></param> /// <param name="status"></param> /// <param name="notificationType"></param> public void RecordNotification(string logText, int notificationID, int transactionID, NotifyStatus status, NotifyTypes notificationType) { RecordNotification recordNotification = null; try { recordNotification = new RecordNotification(); /*Error or Notification response is recorded*/ recordNotification.LogText = logText; recordNotification.NotificationID = notificationID; recordNotification.TransID = transactionID; recordNotification.Status = status; recordNotification.NotifyType = notificationType; recordNotification.Execute(); } catch (Exception ex) { /*Debug Object values for reference*/ LogBook.Debug(recordNotification, this); /*Write exception log*/ LogBook.Write("Error has occurred while inserting record notification parameters into 'ttNotificationLog' table", ex, "CooperAtkins.NotificationClient.NotificationComposer.EmailNotificationComposer"); } finally { recordNotification.Dispose(); } }
public virtual void NotifyStep(NotifyTypes notifyType) { Singleton <NotifyManager> .Instance.FireNotify(new Notify(notifyType, this)); }
/// <summary> /// 阿里云推送 /// </summary> /// <param name="request"></param> /// <param name="message"></param> /// <param name="receivers"></param> private void Push(NotifyMessageRequest request, Tgnet.FootChat.Push.MessageModel message, long[] receivers, bool remind, NotifyTypes notifyType) { ExceptionHelper.ThrowIfNull(message, "message"); receivers = (receivers ?? Enumerable.Empty <long>()).Where(id => id > 0).Distinct().ToArray(); PushService.PushSetting setting = null; if (request.MessageType != MessageType.Online) { setting = new PushService.PushSetting { ExpireTime = TimeSpan.FromDays(1), StoreOffline = true, NotifyType = (PushService.PushSettingNotifyTypes)notifyType.To <byte>(), }; } List <PushService.TargetsAppKinds> apps = new List <PushService.TargetsAppKinds>() { PushService.TargetsAppKinds.FootChatAndroid, PushService.TargetsAppKinds.FootChatiOS }; _PushManager.PushJsonMessage(new PushService.PushJsonMessageRequest { Content = message.Content, ContentType = message.ContentType, Extensions = message.Extensions, MessageId = message.MessageId, Sender = message.Sender, SenderName = message.SenderName, SessionId = message.SessionId, SessionType = message.SessionType, Timestamp = message.Timestamp, Remind = WrapperRemind(message, remind) }, new PushService.Targets { Uids = receivers, Apps = apps.ToArray(), Testing = false, }, setting); }