public override void EditList(Noti item, EditType type) { switch (type) { case EditType.Add: item.NotiId = IdPreIndex + Notis.Count; Notis.Add(item); Notis.Sort(SortNotis); break; case EditType.Remove: Notis.Remove(Notis.Find(x => x.NotiId == item.NotiId)); break; case EditType.Edit: int index = Notis.FindIndex(x => x.NotiId == item.NotiId); Notis[index] = item; Notis[index].UpdateTime(); break; case EditType.EditOnlyTime: Notis[Notis.FindIndex(x => x.NotiId == item.NotiId)] = item; break; default: break; } SaveNotis(); UpdateScheduledNoti <GardeningNoti>(); }
public override void EditList(Noti item, EditType type) { var noti = item as RealmFriendshipNoti; switch (type) { case EditType.Add: if (Notis.FindAll(x => (x as RealmFriendshipNoti).Percentage.Equals(noti.Percentage)).Count == 0) { Notis.Add(item); Notis.Sort(SortNotis); } else { DependencyService.Get <IToast>().Show(AppResources.NotiSettingPage_AlreadyExistToast_Message); } break; case EditType.Remove: Notis.Remove(Notis.Find(x => (x as RealmFriendshipNoti).Percentage.Equals(noti.Percentage))); break; case EditType.Edit: (Notis[Notis.FindIndex(x => (x as RealmFriendshipNoti).Percentage.Equals(noti.Percentage))] as RealmFriendshipNoti).Percentage = noti.Percentage; break; default: break; } SaveNotis(); UpdateScheduledNoti <RealmFriendshipNoti>(); }
public async Task <IActionResult> Create(Message message) { if (ModelState.IsValid) { string rec = HttpContext.Session.GetString("reciever"); message.UserName = User.Identity.Name; message.RcreiverName = rec; var sender = await _userManger.GetUserAsync(User); message.UserID = sender.Id; Noti noti = new Noti() { UserID = sender.Id, FromUserName = User.Identity.Name, ToUserName = rec, NotiBody = message.Text, NotiHeader = message.Text, }; await _context.Notis.AddAsync(noti); await _context.Messages.AddAsync(message); await _context.SaveChangesAsync(); return(Ok()); } return(Error()); }
public override void EditList(Noti item, EditType type) { switch (type) { case EditType.Add: item.NotiId = ID_PREINDEX + Notis.Count; Notis.Add(item); Notis.Sort(SortNotis); break; case EditType.Remove: Notis.Remove(Notis.Find(x => x.NotiId.Equals(item.NotiId))); break; case EditType.Edit: var index = Notis.FindIndex(x => x.NotiId.Equals(item.NotiId)); Notis[index] = item; Notis[index].UpdateTime(); break; default: break; } SaveNotis(); UpdateScheduledNoti <GadgetNoti>(); }
public async Task <IActionResult> Add(List <string> Texts, string Link) { List <Language> languages = await db.Languages.ToListAsync(); if (Checker.CheckList(Texts)) { Noti noti = new Noti(); noti.Link = Link; db.Noti.Add(noti); for (int i = 0; i < languages.Count; i++) { NotiLanguage notiLanguage = new NotiLanguage(); notiLanguage.Text = Texts[i]; notiLanguage.LanguageId = languages[i].Id; notiLanguage.NotiId = noti.Id; db.NotiLanguage.Add(notiLanguage); } await db.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } else { ModelState.AddModelError("", "Fill all Blanks"); return(View()); } }
public TimeEditView(Noti noti, NotiManager notiManager) { this.noti = noti; this.notiManager = notiManager; maxHour = GetMaxHour(); InitializeComponent(); InitValue(); }
private void ResetTimer(Intent intent) { int id = intent.GetIntExtra("NotiId", -1); NotiManager.NotificationType type = (NotiManager.NotificationType)intent.GetIntExtra("NotiType", 0); NotiManager notiManager = type switch { NotiManager.NotificationType.Expedition => new ExpeditionNotiManager(), NotiManager.NotificationType.GatheringItem => new GatheringItemNotiManager(), NotiManager.NotificationType.Gadget => new GadgetNotiManager(), NotiManager.NotificationType.Furnishing => new FurnishingNotiManager(), NotiManager.NotificationType.Gardening => new GardeningNotiManager(), _ => null }; if ((notiManager is null) || (id == -1)) { return; } Noti noti = notiManager.Notis.Find(x => x.NotiId.Equals(id)); NotiScheduleAndroid.Cancel(noti); noti.UpdateTime(); notiManager.SaveNotis(); switch (type) { case NotiManager.NotificationType.Expedition: NotiScheduleAndroid.Schedule <ExpeditionNoti>(noti); break; case NotiManager.NotificationType.GatheringItem: NotiScheduleAndroid.Schedule <GatheringItemNoti>(noti); break; case NotiManager.NotificationType.Gadget: NotiScheduleAndroid.Schedule <GadgetNoti>(noti); break; case NotiManager.NotificationType.Furnishing: NotiScheduleAndroid.Schedule <FurnishingNoti>(noti); break; case NotiManager.NotificationType.Gardening: NotiScheduleAndroid.Schedule <GardeningNoti>(noti); break; default: break; } } }
public async Task <ActionResult> Get(Noti model) { await this._hubNotification.Send(model.gondericiId, model.aliciId, model.message); //gelen verileri hub gönderip veritabanına kaydet sonra Clienta gönder. this._notificationService.Add(new Notification { Id = new Guid(), UserId = model.gondericiId, TriggerUserId = model.aliciId, NotificationDescription = model.message }); return(StatusCode(200, "Test başarılı")); }
/* Select group by count(*) from SGNotiInfo of CategoryId */ public Dictionary <LSIDEBAR, int> SelectNotiInfoCategoryCount(int groupId) { Dictionary <LSIDEBAR, int> NotiDic; NotiDic = DBCtx.Notis .Where(Noti => Noti.GroupId == groupId) .GroupBy(Noti => Noti.CategoryId) .Select(Noti => new { CategoryId = Noti.Key, CategoryCount = Noti.Count() } ) .OrderBy(Noti => Noti.CategoryId) .ToDictionary(Noti => Noti.CategoryId, Noti => Noti.CategoryCount); return(NotiDic); }
public IActionResult Delete(int?id) { if (id == null) { return(RedirectToAction("error", "home")); } List <NotiLanguage> notiLanguage = db.NotiLanguage.Where(nl => nl.NotiId == id).ToList(); Noti noti = db.Noti.FirstOrDefault(n => n.Id == id); if (notiLanguage == null || noti == null) { return(RedirectToAction("error", "home")); } db.Noti.Remove(noti); db.NotiLanguage.RemoveRange(notiLanguage); db.SaveChanges(); return(RedirectToAction("index", "noti")); }
public static void Schedule <T>(Noti noti) where T : Noti { NotifierAndroid notifier = new(); DateTime now = DateTime.Now; if (noti.NotiTime > now) { Notification notification = new() { Title = noti.GetNotiTitle(), Text = noti.GetNotiText(), Id = noti.NotiId, NotifyTime = noti.NotiTime }; notification.SetType <T>(); notifier.Notify(notification); } }
internal int SortNotis(Noti x, Noti y) { return(x.NotiId.CompareTo(y.NotiId)); }
public virtual void EditList(Noti item, EditType editType) { }
public static void Cancel(Noti noti) { NotifierAndroid notifier = new(); notifier.Cancel(noti.NotiId); }
public void UpdateData() { Client.Headers.Add("User-Agent", "OrionBot"); while (true) { try { string tabName = GetCurrentTabName(); if (tabName == "Page3") { string s = Client.DownloadString(Properties.Settings.Default.GateLocation + "files"); ArrayList a = ParseFiles(s); Invoke((MethodInvoker) delegate { int i = (fileView.SelectedItems.Count == 1) ? fileView.SelectedIndices[0] : -1; fileView.Items.Clear(); foreach (string[] v in a) { fileView.Items.Add(new ListViewItem(v)); } if ((fileView.Items.Count > i) && (i > -1)) { fileView.Items[i].Selected = true; } }); } else { string s = Client.DownloadString(Properties.Settings.Default.GateLocation + "bots"); sys = true; int t = 0, o = 0; //Total, Online ServerData Data = ParseXml(s, ref t, ref o); Invoke((MethodInvoker) delegate { for (int j = 0; j < botGrid.Rows.Count; j++) { DataGridViewRow row = botGrid.Rows[j]; int i = BotIndex(Data.Bots, row.Cells["idCol"].Value.ToString()); if (i > -1) { var bot = (Dictionary <string, string>)Data.Bots[i]; bool r = row.Cells["ipCol"].Value.ToString() != bot["ip"]; r = r || row.Cells["statusCol"].Value != StatusImgs[Boolean.Parse(bot["last"]) ? 0 : 1]; if (r) { row.Cells["statusCol"].Value = StatusImgs[Boolean.Parse(bot["last"]) ? 0 : 1]; row.Cells["ipCol"].Value = bot["ip"]; } Data.Bots.RemoveAt(i); } else { botGrid.Rows.RemoveAt(j); j--; } } foreach (Dictionary <string, string> bot in Data.Bots) { int i = botGrid.Rows.Add(); DataGridViewRow row = botGrid.Rows[i]; row.Cells["statusCol"].Value = StatusImgs[Boolean.Parse(bot["last"]) ? 0 : 1]; row.Cells["idCol"].Value = bot["id"]; row.Cells["nameCol"].Value = bot["name"]; row.Cells["ipCol"].Value = bot["ip"]; row.Cells["compCol"].Value = bot["comp"]; row.Cells["sysCol"].Value = bot["sys"]; } if (Data.Bots.Count != 0) { Notification Noti; if (Data.Bots.Count == 1) { var bot = (Dictionary <string, string>)Data.Bots[0]; Noti = new Notification("New bot", "Name: " + bot["name"] + "\n" + "Computer: " + bot["comp"] + "\n" + "System: " + bot["sys"]); } else { Noti = new Notification("New bots", Data.Bots.Count.ToString() + " new bots have been discovered."); } Noti.Show(); } botsLabel.Text = "Number of bots: " + t.ToString(); onlineLabel.Text = o.ToString(); offlineLabel.Text = (t - o).ToString(); uptimeLabel.Text = "Server uptime: " + TimeSpan.FromMilliseconds(Data.Stats["uptime"]).ToString("%h'h '%m'm '%s's'"); usersLabel.Text = "Number of users: " + Data.Stats["users"]; systemProgressBar.MaxValue = Math.Max(1, t); systemProgressBar.Value = o; systemProgressBar.LabelVisible = true; int x = NetworkAvailability(t, o); networkLabel.Text = "Network availability\n"; switch (x) { case 0: networkLabel.Text += "Poor"; networkLabel.ForeColor = Color.FromArgb(255, 60, 0); break; case 1: networkLabel.Text += "Average"; networkLabel.ForeColor = Color.FromArgb(255, 132, 0); break; default: networkLabel.Text += "Great"; networkLabel.ForeColor = Color.FromArgb(77, 230, 0); break; } x = activityChart.Series[0].Points.Count; bool refresh = true;//(x < 6); if (refresh) { activityChart.Series[0].Points.Clear(); x = 0; foreach (KeyValuePair <string, uint> k in Data.Stats) { if (x < 2) { x++; continue; } DateTime np = new DateTime(1970, 1, 1).AddMilliseconds(double.Parse(k.Key)).ToLocalTime(); activityChart.Series[0].Points.AddXY(np, k.Value); } } updateLabel.Text = DateTime.Now.ToString("dd/MM/yyy HH:mm:ss"); }); } } catch (WebException e) when(e.Response is HttpWebResponse res) { switch (res.StatusCode) { case HttpStatusCode.Unauthorized: MessageBox.Show("Your session has expired."); Invoke((MethodInvoker) delegate { Application.Restart(); }); break; } } catch (WebException) { sys = false; } Invoke((MethodInvoker) delegate { systemLabel.Text = sys ? "All systems operational" : "Systems down"; systemLabel.ForeColor = sys ? Color.FromArgb(77, 230, 0) : Color.FromArgb(255, 60, 0); }); Thread.Sleep(Properties.Settings.Default.UpdateInterval * 1000); } }
private void RemoveItem(Noti noti) { notiManager.EditList(noti, NotiManager.EditType.Remove); Utils.RefreshCollectionView(ListCollectionView, Notis); }