public ActionResult Create([Bind(Include = "AdminMessageID,Title,Text,Active")] AdminMessage adminMessage) { adminMessage.Date = DateTime.Now; if (ModelState.IsValid) { if (adminMessage.Active == true) { var am = db.AdminMessages.ToList(); foreach (var a in am) { if (a.Active == true) { a.Active = false; } } db.SaveChanges(); } db.AdminMessages.Add(adminMessage); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(adminMessage)); }
public async Task <IActionResult> Edit(int id, [Bind("ID,DateCreated,Name,Email,MessageText")] AdminMessage adminMessage) { if (id != adminMessage.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(adminMessage); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AdminMessageExists(adminMessage.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); } return(View(adminMessage)); }
/// <summary> /// Konstruktor /// </summary> public AdminArea() { InitializeComponent(); List <IAdminMessage> messages = new List <IAdminMessage>(); foreach (Tank tank in GasStation.GetInstance().TankList) { //Schaut ob genügend Treibstoff im Tank ist if (!TankService.HasEnoughInTank(tank)) { IAdminMessage message = new AdminMessage(); message.Status = MessageStatus.Warning; message.Description = "Das Tank minimum wurde im Tank " + tank.Name + " erreicht"; messages.Add(message); } //Vergleicht mit dem letzten Jahr und schaut ob genügend Treibstoff im Tank ist if (TankService.AdjustTankMinimum(tank)) { IAdminMessage message = new AdminMessage(); message.Status = MessageStatus.Warning; message.Description = "Letztes Jahr wurde im Tank: " + tank.Name + " der Treibstoff sehr knapp"; messages.Add(message); } } messageList.ItemsSource = messages; }
/// <summary> /// /// </summary> /// <param name="Message"></param> protected override void HandleAdminMessage(AdminMessage Message) { base.HandleAdminMessage(Message); // no proper message text? if (Message.Message == null || String.Equals(Message.Message, String.Empty)) { return; } // check if irc is available if (IrcClient.IsRegistered && IrcChannel != null) { // IRC does not allow \r \n \0 // so we remove \0 and remove \r\n by splitting up into lines string[] lines = SplitLinebreaks(Message.Message.Replace("\0", String.Empty)); // forward line by line foreach (string line in lines) { // forward this line to each admin foreach (string admin in Config.Admins) { // try get channeluser by name IrcChannelUser usr = GetChannelUser(admin); // online? send! if (usr != null) { IrcClient.LocalUser.SendMessage(admin, line); } } } } }
public ActionResult Edit([Bind(Include = "AdminMessageID,Title,Text,Date,Active")] AdminMessage adminMessage) { if (ModelState.IsValid) { if (adminMessage.Active == true) { ApplicationDbContext db2 = new ApplicationDbContext(); var am = db2.AdminMessages.ToList(); foreach (var a in am) { if (a.Active == true) { a.Active = false; db2.SaveChanges(); } } } db.Entry(adminMessage).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(adminMessage)); }
/// <summary> /// Отправка сообщения всем пользователям в некотором павильоне /// </summary> /// <param name="message"> сообщение</param> /// <param name="pavilion"> павильон, в котором оно рассылается</param> private void SendMessageToClients(AdminMessage message, string pavilion) { for (int i = 0; i < users[pavilion].Count; i++) { SendMessage(message, users[pavilion][i].HostId, users[pavilion][i].ConnectionId); } }
private void RecieveAdminMessage(AdminMessage back) { Message messageToRemove = GetMessageById(back.IdMessage); messages.Remove(messageToRemove); uiController.RemoveMessage(messageToRemove); }
/// <summary> /// Prepares the Email and Sends to the Corresponding User /// </summary> /// <param name="message"></param> public static int PrepareAndSendEmail(AdminMessage message) { String template = AppUtil.ReadEmailTemplate(AppConstants.EmailTemplate.GENERAL_EMAIL_TEMPLATE); if (template.Length > 0) { message.FromEmail = String.Format("{0} {1}<{2}>", AppUtil.Encode(SessionCache.CurrentUser.FirstName), AppUtil.Encode(SessionCache.CurrentUser.LastName), SessionCache.CurrentUser.Author_email); message.Subject = AppUtil.Encode(message.Subject); message.MessageBody = AppUtil.FormatText(message.MessageBody); int sentMessageCounter = 0; foreach (PlanningPrepUser user in SessionCache.SelectedUsersForEmail) { String body = String.Format("Dear {0}, <br/><br/>{1}", AppUtil.Encode(user.Username), message.MessageBody); StringBuilder orgMessage = new StringBuilder(template); orgMessage.Replace(AppConstants.ETConstants.MESSAGE, body); try { MailManager.SendMail(user.Author_email, String.Empty, String.Empty, message.FromEmail, message.Subject, orgMessage.ToString()); sentMessageCounter++; } catch { } } return sentMessageCounter; } return 0; }
public EatResponse OnEvent(EventId id, object cookie) { if (id != EventId.WorldInTransitionComplete) { if (id == EventId.ServerAdminMessage) { AdminMessage adminMessage = cookie as AdminMessage; for (int i = 0; i < adminMessage.Messages.Count; i++) { AdminMessageData adminMessageData = adminMessage.Messages[i]; if (!this.seenMessages.Contains(adminMessageData.Uid)) { this.seenMessages.Add(adminMessageData.Uid); this.queuedMessages.Enqueue(adminMessageData); if (Service.Get <GameStateMachine>().CurrentState is HomeState || Service.Get <GameStateMachine>().CurrentState is EditBaseState) { this.DisplayAdminMessagesOnQueue(false); } } } } } else if (Service.Get <GameStateMachine>().CurrentState is HomeState) { if (!this.haveShownLoginNotification) { SetPrefsCommand command = new SetPrefsCommand(false); Service.Get <ServerAPI>().Enqueue(command); } this.DisplayAdminMessagesOnQueue(Service.Get <CurrentPlayer>().CampaignProgress.FueInProgress); } return(EatResponse.NotEaten); }
private void OnPoweOffClick() { AdminMessage msg = new AdminMessage(); msg.Type = DataType.AdminEvent; msg.Data.Control = ControlState.TurnOff; NetManager.SendMessage(Util.ObjectToJson(msg)); }
private void OnRestartClick() { AdminMessage msg = new AdminMessage(); msg.Type = DataType.AdminEvent; msg.Data.Control = ControlState.Reboot; NetManager.SendMessage(Util.ObjectToJson(msg)); }
public ActionResult DeleteConfirmed(int id) { AdminMessage adminMessage = db.AdminMessages.Find(id); db.AdminMessages.Remove(adminMessage); db.SaveChanges(); return(RedirectToAction("Index")); }
public MessageDetailViewModel(AdminMessage a) { IsLoading = true; this.Message = a; LoadMessageDataCommand = new Command(async async => await TotalMessageDataCommand()); LoadMessageDataCommand.Execute(null); }
public ActionResult Edit([Bind(Include = "AdminMessageID,Title,Content")] AdminMessage adminMessage) { if (ModelState.IsValid) { db.Entry(adminMessage).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(adminMessage)); }
public ActionResult Edit([Bind(Include = "Id,text")] AdminMessage adminMessage) { if (ModelState.IsValid) { db.Entry(adminMessage).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Id = new SelectList(db.Users, "userId", "login", adminMessage.Id); return(View(adminMessage)); }
public async Task <IActionResult> Create([Bind("ID,DateCreated,Name,Email,MessageText")] AdminMessage adminMessage) { if (ModelState.IsValid) { _context.Add(adminMessage); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(adminMessage)); }
public ActionResult Create([Bind(Include = "AdminMessageID,Title,Content")] AdminMessage adminMessage) { if (ModelState.IsValid) { db.AdminMessages.Add(adminMessage); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(adminMessage)); }
private static AdminMessage CreateAdminMessage(string message, ErrorStatus status) { var adminMessage = new AdminMessage() { Body = message, Read = false, TimeStamp = DateTime.Now, Status = status }; return(adminMessage); }
void OnClickBack() { AdminMessage msg = new AdminMessage(); msg.Type = DataType.AdminEvent; msg.Data.Control = ControlState.Stop; NetManager.SendMessage(Util.ObjectToJson(msg)); mediaPlayer.Stop(); videoPLayerRoot.gameObject.SetActive(false); PanManager.AllOpenWithout(PanelName.VideoPlayPanel); PanManager.ClosePanel(PanelName.VideoPlayPanel); }
/// <summary> /// /// </summary> /// <param name="Message"></param> protected override void HandleAdminMessage(AdminMessage Message) { base.HandleAdminMessage(Message); // no proper message text? if (Message.Message == null || String.Equals(Message.Message, String.Empty)) { return; } // check if irc is available if (IrcClient.IsRegistered && IrcChannel != null) { // IRC does not allow \r \n \0 // so we remove \0 and remove \r\n by splitting up into lines string[] lines = Util.SplitLinebreaks(Message.Message.Replace("\0", String.Empty)); // Only want to send to any admins who've sent a command since last GC. // Other admins don't need to know about GC. List <string> recipients; bool clearRecent = false; if (Util.IsGarbageCollectMessage(lines[0])) { recipients = RecentAdmins; clearRecent = true; } else { recipients = Config.Admins; } // forward line by line foreach (string line in lines) { // forward this line to each admin foreach (string admin in recipients) { // try get channeluser by name IrcChannelUser usr = GetChannelUser(admin); // online? send! if (usr != null) { IrcClient.LocalUser.SendMessage(admin, line); } } } if (clearRecent) { RecentAdmins.Clear(); } } }
public ActionResult Create([Bind(Include = "Id,text")] AdminMessage adminMessage) { if (ModelState.IsValid) { db.AdminMessages.Add(adminMessage); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Id = new SelectList(db.Users, "userId", "login", adminMessage.Id); return(View(adminMessage)); }
public static int SendMessage(AdminMessage message) { //throw new Exception("App.Dll does have the registration information."); if (message == null || String.IsNullOrEmpty(message.Subject) || String.IsNullOrEmpty(message.MessageBody)) return -1; else { int noOfEmail = PrepareAndSendEmail(message); ///Clear the Session SessionCache.SelectedUsersForEmail = null; return noOfEmail; } }
/// <summary> /// Непосредственная отправка сообщения некоторому клиенту /// </summary> /// <param name="message"> сообщение</param> /// <param name="hostId"> идентификатор хоста клиента</param> /// <param name="connectionId"> идентификатор соединения клиента</param> private void SendMessage(AdminMessage message, int hostId, int connectionId) { IFormatter formatter = new BinaryFormatter(); byte[] buffer; using (MemoryStream stream = new MemoryStream()) { formatter.Serialize(stream, message); buffer = stream.ToArray(); } NetworkTransport.Send(hostId, connectionId, reliableChannelId, buffer, buffer.Length, out error); }
public async Task <IActionResult> Index(IFormCollection values) { AdminMessage msg = new AdminMessage(); msg.Name = values["name"]; msg.Email = values["email"]; msg.MessageText = values["msg"]; _context.Add(msg); await _context.SaveChangesAsync(); return(View()); }
// 暂停 private void OnPauseButton() { if (mediaPlayer) { mediaPlayer.Pause(); } playBtn.gameObject.SetActive(true); pauseBtn.gameObject.SetActive(false); AdminMessage msg = new AdminMessage(); msg.Type = DataType.AdminEvent; msg.Data.Control = ControlState.Pause; NetManager.SendMessage(Util.ObjectToJson(msg)); }
// GET: AdminMessages/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } AdminMessage adminMessage = db.AdminMessages.Find(id); if (adminMessage == null) { return(HttpNotFound()); } return(View(adminMessage)); }
// GET: AdminMessages/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } AdminMessage adminMessage = db.AdminMessages.Find(id); if (adminMessage == null) { return(HttpNotFound()); } ViewBag.Id = new SelectList(db.Users, "userId", "login", adminMessage.Id); return(View(adminMessage)); }
// 拖动进度 private void OnVideoSeekSliderOnVideoSeekSlider(float point) { if (IsVoluntary) { IsVoluntary = false; return; } mediaPlayer.Position = videoSeekSlider.value; AdminMessage msg = new AdminMessage(); msg.Type = DataType.AdminEvent; msg.Data.Control = ControlState.Play; msg.Data.Progress = mediaPlayer.Time; NetManager.SendMessage(Util.ObjectToJson(msg)); }
void OnRestartButton(bool isOn) { if (isOn) { isLoop = true; mediaPlayer.Loop = true; AdminMessage msg = new AdminMessage(); msg.Type = DataType.AdminEvent; msg.Data.Control = ControlState.Loop; NetManager.SendMessage(Util.ObjectToJson(msg)); } else { isLoop = false; mediaPlayer.Loop = false; AdminMessage msg = new AdminMessage(); msg.Type = DataType.AdminEvent; msg.Data.Control = ControlState.NoLoop; NetManager.SendMessage(Util.ObjectToJson(msg)); } }
private void PlayAllNet() { if (currentChooseVideoUrl == null) { PanManager.ShowToast("您还没选择视频"); return; } AdminMessage msg = new AdminMessage(); msg.Type = DataType.AdminEvent; msg.Data.Control = ControlState.Play; msg.Data.Progress = 0; msg.Data.Resource.Id = currentChooseVideoId; msg.Data.Resource.Uri = currentChooseVideoUrl; msg.Data.Resource.FileType.Id = currentChooseFileType; msg.Data.Resource.Md5 = currentChooseMd5; NetManager.SendMessage(Util.ObjectToJson(msg)); PanManager.OpenPanel <VideoPlayPanel>(PanelName.VideoPlayPanel, currentChooseVideoUrl); currentChooseItem.isOn = false; currentChooseVideoUrl = null; PanManager.AllHidenWithout(PanelName.VideoPlayPanel); }
/// <summary> /// Обработка сообщения с информацией об удалении\редактировании некоторого текстового сообщения /// </summary> /// <param name="outHostId"> идентификатор хоста</param> /// <param name="outConnectionId"> идентификатор соединения</param> /// <param name="outChannelId"> идентификатор канала</param> /// <param name="mess"> сообщение с данными</param> private void RecieveAdminMessage(int outHostId, int outConnectionId, int outChannelId, AdminMessage mess) { messageID += 1; Debug.Log(outHostId + " Data from " + outConnectionId + " through the channel " + outChannelId + " message is " + mess.ToString()); uiController.AddLog(outHostId + " Data from " + outConnectionId + " through the channel " + outChannelId + " message is " + mess.ToString()); Message message = FindMessageById(mess.IdMessage); if (message != null && mess.Delete) { messages.Remove(message); if (message.IsPrivate) { ChatUser sender = GetUserByLogin(message.Userlogin); ChatUser recepient = GetUserByLogin(message.Recipient); if (sender != null) { SendMessage(message, sender.HostId, sender.ConnectionId); } if (recepient != null) { SendMessage(message, recepient.HostId, recepient.ConnectionId); } } else { ChatUser sender = GetUserByLogin(message.Userlogin); SendMessageToClients(mess, sender.Pavilion); } } if (message != null && !mess.Delete) { int ind = messages.IndexOf(message); messages.Remove(message); message.Text = mess.Edit; messages.Insert(ind, message); if (message.IsPrivate) { ChatUser sender = GetUserByLogin(message.Userlogin); ChatUser recepient = GetUserByLogin(message.Recipient); if (sender != null) { SendMessage(message, sender.HostId, sender.ConnectionId); } if (recepient != null) { SendMessage(message, recepient.HostId, recepient.ConnectionId); } } else { ChatUser sender = GetUserByLogin(message.Userlogin); SendMessageToClients(mess, sender.Pavilion); } } if (message != null && message.IsPrivate) { SendMessage(mess, outHostId, outConnectionId); } }
string AdminMessageRichText (AdminMessage message) { return "<color=#" + SendBirdTheme.ToHex (uiTheme.systemMessageColor) + ">" + message.Message + "</color>"; }
public ChatPage(AdminMessage a) { InitializeComponent(); this.BindingContext = new MessageDetailViewModel(a); }