public Task getNumber(User player) { var dbChar = Utils.Utils.GetDatabaseCharacter(player); NotifyHandler.SendNotification(player, "Deine Telefonnummer: " + dbChar.Number); return(Task.CompletedTask); }
public async Task aduty_CMDAsync(User player) { Users dbUser = Main.database.UserCollection.AsQueryable().FirstOrDefault(x => x.Username == player.Username); var dbChar = Main.database.CharacterCollection.AsQueryable().FirstOrDefault(x => x.ownerObjId == dbUser.id); if (player.adminLevel == 0) { await NotifyHandler.SendNotification(player, "Keine Rechte!"); return; } if (player.isAduty) { player.Emit("player:aduty:leave"); await Utils.Utils.LoadClothes(player, dbChar); Discord.Webhookhandler.sendMessage($"[{dbChar.firstName} {dbChar.lastName} / {dbUser.Username}] Aduty verlassen. `{DateTime.Now.ToLocalTime():dd.MM.yyyy HH:mm:ss}`"); player.isAduty = false; return; } if (!player.isAduty) { player.Emit("player:aduty:enter", player.sex, player.adminLevel); Discord.Webhookhandler.sendMessage($"[{dbChar.firstName} {dbChar.lastName} / {dbUser.Username}] Aduty betreten. `{DateTime.Now.ToLocalTime():dd.MM.yyyy HH:mm:ss}`"); player.isAduty = true; } }
internal async Task <bool> addItem(int id, int amount) { var dbChar = Main.database.CharacterCollection.AsQueryable().FirstOrDefault(c => c.ownerObjId == this.uid); var dbInv = dbChar.Inventar; var Item = new Item() { itemId = id, amount = amount }; var dbInvItem = dbInv.FirstOrDefault(i => i.itemId == id); if (dbInvItem != null) { dbInvItem.amount += amount; } else { Console.WriteLine("ADD: " + id + " " + amount); dbInv.Add(Item); } double invWeight = 0; foreach (var item in dbInv) { var dbItem = Main.database.ItemCollection.AsQueryable().FirstOrDefault(i => i.itemId == item.itemId); invWeight += dbItem.weight * item.amount; } if (invWeight >= 50) { await NotifyHandler.SendNotification(this, "Dein Inventar ist voll!", 3000); return(false); } Main.database.CharacterCollection.ReplaceOne(c => c.ownerObjId == this.uid, dbChar); return(true); }
public void TestModuleManager() { var manager = (IAppModuleManager)AppInstance; var testHandler = new NotifyHandler(null); // ReSharper disable once JoinDeclarationAndInitializer IAddinModuleManagerNotifyHandler oldHandler; // just read CurrentModule Assert.IsTrue(manager.CurrentModule != null, "Unassigned CurrentModule"); // test BeforeCurrentModuleChange oldHandler = manager.BeforeCurrentModuleChange; manager.BeforeCurrentModuleChange = testHandler; Assert.IsTrue(manager.BeforeCurrentModuleChange == testHandler, "Cannot Set BeforeCurrentModuleChange"); manager.BeforeCurrentModuleChange = null; Assert.IsTrue(manager.BeforeCurrentModuleChange == null, "Cannot Set BeforeCurrentModuleChange"); manager.BeforeCurrentModuleChange = oldHandler; Assert.IsTrue(manager.BeforeCurrentModuleChange == oldHandler, "Cannot restore BeforeCurrentModuleChange"); Assert.IsTrue(BeforeCurrentModuleChangeCount > 0, "BeforeCurrentModuleChange handler has not been executed"); // test AfterCurrentModuleChange oldHandler = manager.AfterCurrentModuleChange; manager.AfterCurrentModuleChange = testHandler; Assert.IsTrue(manager.AfterCurrentModuleChange == testHandler, "Cannot Set AfterCurrentModuleChange"); manager.AfterCurrentModuleChange = null; Assert.IsTrue(manager.AfterCurrentModuleChange == null, "Cannot Set AfterCurrentModuleChange"); manager.AfterCurrentModuleChange = oldHandler; Assert.IsTrue(manager.AfterCurrentModuleChange == oldHandler, "Cannot estore AfterCurrentModuleChange"); Assert.IsTrue(AfterCurrentModuleChangeCount > 0, "AfterCurrentModuleChange handler has not been executed"); }
public BaseInfo() { _InfoType = InfoType.None; //_ErrorList = new List<ErrorInfo>(); _NotifyHandler = this.NotifyBase; }
public SleepBonusNotify(ILogger logger, ISoundManager soundManager, ITrayPopups trayPopups, string popupTitle, string popupMessage, bool popupPersistent = false) { handler = new NotifyHandler(logger, soundManager, trayPopups) { PopupPersistent = popupPersistent, Message = (popupMessage ?? ""), Title = (popupTitle ?? "") }; }
/// <summary> /// 接收指定类型消息,并注册消息触发事件 /// </summary> /// <param name="message"> 消息类型 </param> /// <param name="call"> 事件方法 </param> public void Register(Enum message, NotifyHandler call) { if (_messageDic.ContainsKey(message)) { _messageDic[message] += call; } else { _messageDic.Add(message, call); } }
public async Task ausparken(User player, string model, string license, string objId) { var dbCar = Main.database.CarCollection.AsQueryable().FirstOrDefault(c => c.numPlate == license); var ausparkPunkte = Main.database.GarageCollection.AsQueryable().FirstOrDefault(g => g.garageId == dbCar.garageId).Ausparkpunkte; for (int i = 0; i < ausparkPunkte.Count; i++) { var ausparkPunkt = ATMS.atmInteraction.toAltPos(ausparkPunkte.ElementAt(i).position); var ausparkRotation = ausparkPunkte.ElementAt(i).rotation; var ausparkBlocked = Alt.GetAllVehicles().ToList().FirstOrDefault(v => v.Position.IsInRange(ausparkPunkt, 1.5f)); var dbModifiers = Main.database.VehicleModiferCollection.AsQueryable().FirstOrDefault(c => c.ModelName.ToLower() == dbCar.carmodel.ToLower()); if (ausparkBlocked != null) { } else { Car spawnCar = (Car)Alt.CreateVehicle(model, ausparkPunkt, new Rotation(0, 0, (float)ausparkRotation)); spawnCar.NumberplateText = license; spawnCar.ownerId = dbCar.ownerId; spawnCar.allowedIds = dbCar.allowedIds; spawnCar.carmodel = model; spawnCar.numPlate = license; spawnCar.fuel = dbCar.fuel; spawnCar.kilometer = dbCar.kilometer; spawnCar.carId = dbCar.carId; spawnCar.ManualEngineControl = true; spawnCar.LockState = VehicleLockState.Locked; dbCar.parkedIn = false; await Main.database.CarCollection.ReplaceOneAsync(c => c.numPlate == license, dbCar); if (dbModifiers != null && dbModifiers.VehSpeedModifier != 0) { Alt.EmitAllClients("vehicle:setSpeed", spawnCar, dbModifiers.VehSpeedModifier); } break; } if (i != ausparkPunkte.Count || !ausparkBlocked.Exists) { continue; } await NotifyHandler.SendNotification(player, "Es sind keine Ausparkpunkte frei!"); break; } }
public async Task carinfo_CMD(User player) { var carinrange = (Car)Alt.GetAllVehicles().FirstOrDefault(x => x.Position.IsInRange(player.Position, 1.5f)); if (!carinrange.Exists) { return; } var dbCar = Main.database.CarCollection.AsQueryable().FirstOrDefault(c => c.carId == carinrange.carId); var dbcarOwner = Main.database.CharacterCollection.AsQueryable().FirstOrDefault(c => c.playerId == dbCar.ownerId); await NotifyHandler.SendNotification(player, $"Model: {dbCar.carmodel} CarID: {dbCar.carId} Owner: {dbcarOwner.firstName} {dbcarOwner.lastName}"); }
public Task jailtime_CMD(User player) { var dbChar = Utils.Utils.GetDatabaseCharacter(player.playerId); if (dbChar.jailTime > 1) { NotifyHandler.SendNotification(player, $"Du hast noch {dbChar.jailTime} Hafteinheiten!"); return(Task.CompletedTask); } NotifyHandler.SendNotification(player, $"Du befindest dich nicht im Gefängnis!"); return(Task.CompletedTask); }
public static NotifyHandler InstanceCreation() { if (_scoreHandlerObject == null) { lock (lockingObject) { if (_scoreHandlerObject == null) { _scoreHandlerObject = new NotifyHandler(); } } } return(_scoreHandlerObject); }
public async Task ooc_Chat(User player, params string[] args) { var playerPool = Alt.GetAllPlayers(); var dbChar = Utils.Utils.GetDatabaseCharacter(player); var chatMessage = ""; foreach (var x in args) { chatMessage += $"{x} "; } foreach (User p in playerPool.Where(x => x.Position.IsInRange(player.Position, 10f))) { await NotifyHandler.SendNotification(p, $"OOC: {dbChar.firstName} {dbChar.lastName} ({dbChar.playerId}) {chatMessage}"); } }
public static void LoadFromJson() { string obj = File.ReadAllText(@"..\\..\\Shop\\Shop.json"); TempShopValue temp = JsonConvert.DeserializeObject <TempShopValue>(obj); nh = NotifyHandler.InstanceCreation(); nh.VBombCount = temp.VBombCount; nh.Apokalypsecount = temp.Apokalypsecount; nh.GoldAmount = temp.GoldAmount; nh.SupernovaCount = temp.SupernovaCount; nh.HighestScore = temp.HighestScore; _highscore = temp.HighestScore; nh.WaveHighScore = temp.WaveHighScore; _waveScore = temp.WaveHighScore; nh.LivesExceed = temp.Lives; }
/// <summary> /// 移除指定类型消息的指定事件 /// </summary> /// <param name="message"> 消息类型 </param> /// <param name="call"> 事件方法 </param> public void Remove(Enum message, NotifyHandler call) { if (!_messageDic.ContainsKey(message)) { return; } if (_messageDic[message] != call && _messageDic[message] != null) { _messageDic[message] -= call; } else { _messageDic.Remove(message); } }
public async Task Leave(User player) { if (player.paintballArena == 0) { return; } await NotifyHandler.SendNotification(player, "Du hast Paintball verlassen!"); await Utils.Utils.LoadClothes(player, Utils.Utils.GetDatabaseCharacter(player)); Main.database.PaintballCollection.AsQueryable().FirstOrDefault(p => p.arenaId == player.paintballArena).playerCount -= 1; player.RemoveAllWeapons(); player.paintballArena = 0; player.Dimension = 0; await Utils.Utils.LoadPlayerWeapons(player); }
public ActionResult PayNotifyUrl() { try { string[] strs = Request.RawUrl.ToString().Split("/".ToCharArray()); string userID = strs[strs.Length - 1]; LogerHelper.DefaultInfo(strs[strs.Length - 1]); NotifyHandler resHandler = new NotifyHandler(Request.InputStream); Hashtable table = resHandler.Parameters; ArrayList akeys = new ArrayList(table.Keys); akeys.Sort(); foreach (string k in akeys) { string v = (string)table[k]; LogerHelper.DefaultInfo(v); } string openid = resHandler.GetParameter("openid"); string total_fee = resHandler.GetParameter("total_fee"); string out_trade_no = resHandler.GetParameter("out_trade_no"); LogerHelper.DefaultInfo("total_fee: " + total_fee); LogerHelper.DefaultInfo("out_trade_no: " + out_trade_no); resHandler.SetKey(Mch_Id); //验证请求是否从微信发过来(安全) // if (resHandler.IsTenpaySign()) // { //正确的订单处理 LogerHelper.DefaultInfo("nofify ok"); //此处userid是回调url最后一个参数 if (paymentbll.chargePayment(userID, Convert.ToInt32(total_fee), out_trade_no, (int)Commons.PayType.RECHARGE)) { LogerHelper.debug("微信支付成功!"); } // WebHelper.Post(LocalContext.platformUrl + "/Pay/Recharge", "UserID=" + (Common.GlobalMap[openid] as UserInformation).userid + "Amount=" + total_fee + "PayOrderID=" + out_trade_no + "Type=1"); // } // else // { //错误的订单处理 // LogerHelper.DefaultInfo("nofify no"); // } } catch (Exception ex) { LogerHelper.DefaultInfo("ex: " + ex.ToString()); } return(Content("success")); }
public void InitializeNotifyHandler() { if (string.IsNullOrEmpty(BotSettings.Token)) { throw new InvalidOperationException($"{nameof(BotSettings.Token)} property must be specified"); } if (UpdatesHandler == null) { throw new InvalidOperationException($"{nameof(UpdatesHandler)} property must be initialized first."); } if (Authorizer == null) { throw new InvalidOperationException($"{nameof(Authorizer)} property must be initialized first."); } NotifyHandler = new NotifyHandler(); }
public async Task medicDuty_CMD(User player) { Console.WriteLine("Call Medic CMD" + "Jobduty: " + player.IsJobDuty); if (player.IsJobDuty) { await NotifyHandler.SendNotification(player, "Du bist nun nichtmehr im Medic-Dienst!"); player.IsJobDuty = false; return; } else { await NotifyHandler.SendNotification(player, "Du bist nun im Medic-Dienst!"); player.IsJobDuty = true; return; } }
void NotifyCallback(IntPtr handle, IntPtr pspec, IntPtr gch) { try { GLib.Signal sig = ((GCHandle)gch).Target as GLib.Signal; if (sig == null) { throw new Exception("Unknown signal GC handle received " + gch); } NotifyArgs args = new NotifyArgs(); args.Args = new object[1]; args.Args[0] = pspec; NotifyHandler handler = (NotifyHandler)sig.Handler; handler(GLib.Object.GetObject(handle), args); } catch (Exception e) { ExceptionManager.RaiseUnhandledException(e, false); } }
public void TestUTC() { ObservationLocation.Reset(); ObservationLocation theLocation = ObservationLocation.Location; Assert.That(theLocation.UTC, Is.EqualTo(DateTime.UtcNow)); NotifyHandler theHandler = new NotifyHandler(theLocation); DateTime theDate = DateTime.UtcNow; theLocation.UTC = theDate.AddHours(2); DateTime theNewDate = theLocation.UTC; Assert.That(theNewDate.Date, Is.EqualTo(theDate.Date)); Assert.That(theNewDate.Hour, Is.EqualTo(theDate.Hour + 2)); Assert.That(theNewDate.Second, Is.EqualTo(theDate.Second)); Assert.That(theNewDate.Minute, Is.EqualTo(theDate.Minute)); Assert.That(theHandler.nUtcChanges, Is.EqualTo(1)); }
internal async Task <bool> removeMoneyAsync(int price) { var dbChar = Main.database.CharacterCollection.AsQueryable().FirstOrDefault(c => c.ownerObjId == this.uid); var oldMoney = dbChar.moneyHand; dbChar.moneyHand -= price; if (dbChar.moneyHand < 0) { dbChar.moneyHand = oldMoney; await NotifyHandler.SendNotification(this, "Du hast nicht genug Geld!"); return(false); } await Main.database.CharacterCollection.ReplaceOneAsync(c => c.ownerObjId == this.uid, dbChar); await this.UpdateMoneyHud(dbChar.moneyHand); return(true); }
public FavorTimerNotify(PrayerTimer timer, string player, string serverGroupId, ILogger logger, ISoundManager soundManager, ITrayPopups trayPopups, [NotNull] SkillEntryParser skillEntryParser) { if (skillEntryParser == null) { throw new ArgumentNullException("skillEntryParser"); } this.serverGroupId = serverGroupId; this.skillEntryParser = skillEntryParser; Settings = timer.favorSettings; favorHandler = new NotifyHandler( logger, soundManager, trayPopups, Settings.FavorNotifySoundId, player, "", Settings.FavorNotifyPopupPersist); }
public void TestLongitude() { Utilities.Profile theProfile = new Utilities.Profile(); theProfile.DeviceType = "Telescope"; theProfile.WriteValue(Telescope.ProgId, "Longitude", Convert.ToString(4.12345), ""); ObservationLocation.Reset(); ObservationLocation theLocation = ObservationLocation.Location; Assert.That(theLocation.Longitude, Is.EqualTo(4.12345).Within(0.00001)); NotifyHandler theHandler = new NotifyHandler(theLocation); theLocation.Longitude = 12.54321; double storedLongitude = Convert.ToDouble(theProfile.GetValue(Telescope.ProgId, "Longitude", "")); Assert.That(theLocation.Longitude, Is.EqualTo(12.54321).Within(0.00001)); Assert.That(storedLongitude, Is.EqualTo(12.54321).Within(0.00001)); Assert.That(theHandler.nLongitudeChanges, Is.EqualTo(1)); }
public Task OnColShape(IColShape colShape, IEntity entity, bool state) { if (state == false) { return(Task.CompletedTask); } if (entity is IPlayer) { var player = entity as User; if (!player.IsInVehicle) { return(Task.CompletedTask); } NotifyHandler.SendNotification(player, "Verlasse dieses Gebiet innerhalb von 10 Sekunden", 10000); } if (entity is IVehicle) { var veh = entity as Car; Console.WriteLine("Create Timer"); var EmpTimer = new Timer(); EmpTimer.Interval = 10000; EmpTimer.Enabled = true; EmpTimer.Elapsed += (sender, args) => { Console.WriteLine("Timer elapsed"); if (!veh.Position.IsInRange(colShape.Position, 200f)) { EmpTimer.Dispose(); return; } ; Console.WriteLine("Veh inside!"); EmpTimer.Dispose(); veh.SetNetworkOwner(veh.Driver, false); veh.Driver.Emit("NetOwner:DestroyVehicle", veh); }; } return(Task.CompletedTask); }
public async Task Support_CMD(User player, params string[] args) { var playerpool = Alt.GetAllPlayers(); var dbChar = Utils.Utils.GetDatabaseCharacter(player); var supportText = $"{dbChar.firstName} {dbChar.lastName} ({dbChar.playerId}) "; foreach (var t in args) { supportText += $"{t} "; } foreach (var x in playerpool) { var tempPlayer = x as User; if (tempPlayer.adminLevel >= 1) { await NotifyHandler.SendSupportMessage(tempPlayer, supportText, 30000); } } }
public Task revive_CMD(User player, int targetId) { if (!player.isAduty || player.adminLevel < 5) { return(Task.CompletedTask); } var playerpool = Alt.GetAllPlayers(); foreach (User p in playerpool) { if (p.playerId != targetId) { continue; } p.Spawn(p.Position, 0); NotifyHandler.SendNotification(p, "Du wurdest von einem Admin wiederbelebt!"); } return(Task.CompletedTask); }
public async Task pwset_CMD(User player, string username, string password) { if (!player.isAduty) { return; } var dbUser = Utils.Utils.GetDatabasePlayer(player); if (dbUser.adminLevel != 9) { return; } var wantedUser = Main.database.UserCollection.AsQueryable().FirstOrDefault(u => u.Username.ToLower() == username.ToLower()); if (wantedUser == null) { return; } wantedUser.Password = BCrypt.Net.BCrypt.HashString(password); Main.database.UserCollection.ReplaceOne(u => u.Username.ToLower() == username.ToLower(), wantedUser); await NotifyHandler.SendNotification(player, "Du hast das Passwort von " + username + " erfolgreich geändert!"); }
/// <summary> /// 注册相应类型的回调 /// </summary> /// <param name="handler">回调函数</param> /// <param name="msgType">消息类型</param> public void Register(NotifyHandler handler, EnumMsgType msgType) { try { //判断消息类型是否存在,为消息类型添加回调函数 if (_callbackDic.ContainsKey(msgType)) { _callbackDic[msgType].Add(handler); } else { _callbackDic[msgType] = new List <NotifyHandler> { handler }; } Logger.WriteInfoFmt(Log.ReceiverRegister, "消息类型:{0}", new object[] { msgType.ToString() }); } catch (Exception ex) { Logger.WriteError(Log.ReceiverRegister, "注册消息接收组件时出现异常", ex); } }
public async Task givekey_CMD(User player, string str_playerid) { int playerid = int.Parse(str_playerid); if (!player.Vehicle.Exists) { await NotifyHandler.SendNotification(player, "Du sitzt in keinem Auto!"); return; } var playerVehicle = (Car)player.Vehicle; var dbCar = Main.database.CarCollection.AsQueryable().ToList().FirstOrDefault(c => c.carId == playerVehicle.carId); if (dbCar.allowedIds.Contains(playerid)) { await NotifyHandler.SendNotification(player, "Dieser Spieler hat bereits einen Schlüssel!"); return; } dbCar.allowedIds.Add(playerid); playerVehicle.allowedIds.Add(playerid); await Main.database.CarCollection.ReplaceOneAsync(c => c.carId == playerVehicle.carId, dbCar); }
static void DisconnectNotification (GLib.Object w, string signal, NotifyHandler handler) { var sig = GLib.Signal.Lookup (w, signal, delegateInstance); sig.RemoveDelegate (handler); }
public static void AddNotification (GLib.Object w, NotifyHandler handler) { ConnectNotification (w, "notify", handler); }
public static void AddNotification (GLib.Object w, string property, NotifyHandler handler) { ConnectNotification (w, "notify::" + property, handler); }
public void RemoveNotification(NotifyHandler handler) { DisconnectNotification ("notify", handler); }
void DisconnectNotification(string signal, NotifyHandler handler) { Signal sig = Signal.Lookup (this, signal, new NotifyDelegate (NotifyCallback)); sig.RemoveDelegate (handler); }
public void RemoveNotification(NotifyHandler handler) { RemoveSignalHandler ("notify", handler); }
public void TestLongitude() { Utilities.Profile theProfile = new Utilities.Profile(); theProfile.DeviceType = "Telescope"; theProfile.WriteValue(Telescope.ProgId, "Longitude", Convert.ToString(4.12345), ""); ObservationLocation.Reset(); ObservationLocation theLocation = ObservationLocation.Location; Assert.That(theLocation.Longitude, Is.EqualTo(4.12345).Within(0.00001)); NotifyHandler theHandler = new NotifyHandler(theLocation); theLocation.Longitude = 12.54321; double storedLongitude = Convert.ToDouble(theProfile.GetValue(Telescope.ProgId, "Longitude", "")); Assert.That(theLocation.Longitude, Is.EqualTo(12.54321).Within(0.00001)); Assert.That(storedLongitude,Is.EqualTo(12.54321).Within(0.00001)); Assert.That(theHandler.nLongitudeChanges, Is.EqualTo(1)); }
public void AddNotification(NotifyHandler handler) { AddSignalHandler ("notify", handler, typeof(NotifyArgs)); }
public static void RemoveNotification (GLib.Object w, NotifyHandler handler) { DisconnectNotification (w, "notify", handler); }
public void TestUTC() { ObservationLocation.Reset(); ObservationLocation theLocation = ObservationLocation.Location; Assert.That(theLocation.UTC, Is.EqualTo(DateTime.UtcNow)); NotifyHandler theHandler = new NotifyHandler(theLocation); DateTime theDate = DateTime.UtcNow; theLocation.UTC = theDate.AddHours(2); DateTime theNewDate = theLocation.UTC; Assert.That(theNewDate.Date, Is.EqualTo(theDate.Date)); Assert.That(theNewDate.Hour, Is.EqualTo(theDate.Hour + 2)); Assert.That(theNewDate.Second, Is.EqualTo(theDate.Second)); Assert.That(theNewDate.Minute, Is.EqualTo(theDate.Minute)); Assert.That(theHandler.nUtcChanges, Is.EqualTo(1)); }
static void DisconnectNotification (GLib.Object w, string signal, NotifyHandler handler) { var sig = GLib.Signal.Lookup (w, signal, new NotifyDelegate (NotifyCallback)); sig.RemoveDelegate (handler); }
// // Construction/finalisation // /// <summary> /// Constructeur /// </summary> /// <param name="notifyHandler">délégué de notification des changements</param> public Locker( NotifyHandler notifyHandler ) : this() { this.notifyHandler = notifyHandler; }
public void AddNotification(string property, NotifyHandler handler) { AddSignalHandler ("notify::" + property, handler, typeof(NotifyArgs)); }
public void AddNotification(string property, NotifyHandler handler) { ConnectNotification ("notify::" + property, handler); }
public void RemoveNotification(string property, NotifyHandler handler) { RemoveSignalHandler ("notify::" + property, handler); }
public void AddNotification(NotifyHandler handler) { ConnectNotification ("notify", handler); }
public void RemoveNotification(NotifyHandler handler) { RemoveSignalHandler("notify", handler); }
public void RemoveNotification(string property, NotifyHandler handler) { DisconnectNotification ("notify::" + property, handler); }