protected void Page_Load(object sender, EventArgs e) { if (Session["establishment"] == null) { Server.Transfer("CommonLogin.aspx"); } else { List <Chat> clist = ChatDB.getallChat(); foreach (Chat ch in clist) { Users s = UsersDB.getUserbyID(ch.by); if (s.email == null) { Establishment es = EstablishmentDB.getEstablishmentByID(ch.by); if (ch.status == "allow") { tbxChat.Text += es.Name + " @ " + ch.time + " : " + ch.message + "\r\n"; } } else { if (ch.status == "allow") { tbxChat.Text += s.username + " @ " + ch.time + " : " + ch.message + "\r\n"; } } } } }
public async Task <IActionResult> Edit(int id, [Bind("id")] ChatDB chatDB) { if (id != chatDB.id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(chatDB); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ChatDBExists(chatDB.id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(chatDB)); }
public IActionResult Index(string message) { var userId = User.FindFirstValue(ClaimTypes.NameIdentifier); ChatDB.SendMessage(message, userId); return(RedirectToAction(nameof(Index))); }
public facWarMgr(ChatDB chatDB, CharacterDB characterDB, CacheStorage cacheStorage, ItemFactory itemFactory, NotificationManager notificationManager) { this.ChatDB = chatDB; this.CharacterDB = characterDB; this.CacheStorage = cacheStorage; this.ItemFactory = itemFactory; this.NotificationManager = notificationManager; }
protected void BtnSentMessage_Click(object sender, EventArgs e) { Users s = UsersDB.getUserbyEmail(Session["email"].ToString()); Chat c = new Chat(tbxMessage.Text, s.UserId, System.DateTime.Now, "allow"); ChatDB.insertChat(c); tbxMessage.Text = ""; Server.Transfer("Dashboard.aspx"); }
public LSC(ChatDB db, MessagesDB messagesDB, CharacterDB characterDB, ItemManager itemManager, NodeContainer nodeContainer, Logger logger) { this.DB = db; this.MessagesDB = messagesDB; this.CharacterDB = characterDB; this.ItemManager = itemManager; this.NodeContainer = nodeContainer; this.Log = logger.CreateLogChannel("LSC"); }
protected void BtnSentMessage_Click(object sender, EventArgs e) { Establishment es = (Establishment)Session["establishment"]; Chat c = new Chat(tbxMessage.Text, es.ID, System.DateTime.Now, "allow"); ChatDB.insertChat(c); tbxMessage.Text = ""; Server.Transfer("EstForum.aspx"); }
public void SaveNodeLocations(Dictionary <string, Point> nodeLocations) { if (nodeLocations.Count > 0) { var coll = ChatDB.GetCollection <Dictionary <string, LayoutPoint> >(_connection.LayoutCollectionName); coll.DeleteMany(new BsonDocument()); //Clear All coll.InsertOne(nodeLocations.ToDictionary(x => x.Key, x => new LayoutPoint { X = x.Value.X, Y = x.Value.Y })); } }
public static void InsertActivityEvent(ChatActivityEvent activityEvent) { if (activityEvent != null && string.IsNullOrWhiteSpace(activityEvent._id)) { activityEvent._id = ObjectId.GenerateNewId().ToString(); } var coll = ChatDB.GetCollection <ChatActivityEvent>(Settings.ActivityEventLogCollectionName); coll.InsertOne(activityEvent); }
public async Task <IActionResult> Create([Bind("id")] ChatDB chatDB) { if (ModelState.IsValid) { _context.Add(chatDB); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(chatDB)); }
public LSC(ChatDB db, MessagesDB messagesDB, CharacterDB characterDB, ItemFactory itemFactory, NodeContainer nodeContainer, Logger logger, NotificationManager notificationManager, MachoNet machoNet, MailManager mailManager) { this.DB = db; this.MessagesDB = messagesDB; this.CharacterDB = characterDB; this.ItemFactory = itemFactory; this.NodeContainer = nodeContainer; this.NotificationManager = notificationManager; this.MachoNet = machoNet; this.MailManager = mailManager; this.Log = logger.CreateLogChannel("LSC"); }
public character(CacheStorage cacheStorage, CharacterDB db, ChatDB chatDB, ItemManager itemManager, TypeManager typeManager, Logger logger, Configuration.Character configuration, NodeContainer container) { this.Log = logger.CreateLogChannel("character"); this.mConfiguration = configuration; this.DB = db; this.ChatDB = chatDB; this.ItemManager = itemManager; this.TypeManager = typeManager; this.CacheStorage = cacheStorage; this.Container = container; this.mBloodlineCache = this.DB.GetBloodlineInformation(); this.mAncestriesCache = this.DB.GetAncestryInformation(this.mBloodlineCache); }
public static void InsertActivityEvent(ChatActivityEvent activityEvent) { try { if (activityEvent != null && string.IsNullOrWhiteSpace(activityEvent._id)) { activityEvent._id = ObjectId.GenerateNewId().ToString(); } var coll = ChatDB.GetCollection <ChatActivityEvent>(Settings.ActivityEventLogCollectionName); coll.InsertOne(activityEvent); } catch (Exception ex) { Logger.LogError(new EventId((int)LoggerEventId.MONGO_HELPER_ERROR), ex, "InsertActivityEvent: {0}", ex.Message); } }
public void SaveChatContent() { if (Contents.Count > 0) { var coll = ChatDB.GetCollection <BaseContent>(_connection.ContentCollectionName); coll.DeleteMany(new BsonDocument()); //Clear All coll.InsertMany(Contents); try { if (!Directory.Exists("backup")) { Directory.CreateDirectory("backup"); } File.WriteAllText("backup/nodes-content-" + ObjectId.GenerateNewId().ToString() + ".json", JsonConvert.SerializeObject(Contents, new StringEnumConverter())); } catch { } } }
public onlineStatus(ChatDB chatDB, CharacterDB characterDB, ItemManager itemManager) { this.ChatDB = chatDB; this.CharacterDB = characterDB; this.ItemManager = itemManager; }
public IActionResult Index() { var history = ChatDB.GetChatHistory(); return(View(history)); }
public static List <ChatNode> RetrieveRecordsFromChatNode() { try { var nodeTemplateCollection = ChatDB.GetCollection <BsonDocument>(Settings.TemplateCollectionName); // Creating Filter for Date Range Greater than Equal to Start Date and Less than End Date FilterDefinitionBuilder <BsonDocument> builder = Builders <BsonDocument> .Filter; var filter = new BsonDocument(); List <BsonDocument> nodeList; // Retrieving records, if no/invalid limit is specified then all records are retrieved otherwise records as per specified limit and offset are retrieved nodeList = nodeTemplateCollection.Find(filter).Project(Builders <BsonDocument> .Projection.Exclude("Sections._t").Exclude("Buttons._t")).ToList(); List <ChatNode> chatNodes = new List <ChatNode>(); foreach (BsonDocument node in nodeList) { try { var chatNode = BsonSerializer.Deserialize <ChatNode>(node); chatNode.Sections = new List <Section>(); chatNode.Buttons = new List <Button>(); //Adding Header Text Content nodeContent = Contents.GetFor(chatNode); BsonArray sectionBsonArray = node.GetValue("Sections").AsBsonArray; foreach (BsonDocument sectionBsonDocument in sectionBsonArray) { Section sectObj = GetSection(sectionBsonDocument); chatNode.Sections.Add(sectObj); } BsonArray buttonBsonArray = node.GetValue("Buttons").AsBsonArray; foreach (BsonDocument buttonBsonDocument in buttonBsonArray) { Button btn = BsonSerializer.Deserialize <Button>(buttonBsonDocument); Content buttonContent = Contents.GetFor(btn); btn.ButtonName = buttonContent?.ButtonName; btn.ButtonText = buttonContent?.ButtonText; chatNode.Buttons.Add(btn); } if (node.Contains("IsStartNode") && node["IsStartNode"] != null && (bool)node["IsStartNode"]) { chatNodes.Insert(0, chatNode); } else { chatNodes.Add(chatNode); } } catch (Exception e) { Debug.WriteLine(e); } } return(chatNodes); } catch (Exception e) { Debug.WriteLine(e.Message + "\n" + e.StackTrace); } return(null); }
public static List <Content> GetContentCollection() => ChatDB.GetCollection <Content>(Settings.ContentCollectionName).Find(new BsonDocument()).ToList();
public onlineStatus(ChatDB chatDB, CharacterDB characterDB, ItemFactory itemFactory) { this.ChatDB = chatDB; this.CharacterDB = characterDB; this.ItemFactory = itemFactory; }
public static List <ChatNode> RetrieveRecordsFromChatNode() { try { if (!Settings.CacheContent) { RefreshContentInMemory(); } var nodeTemplateCollection = ChatDB.GetCollection <BsonDocument>(Settings.TemplateCollectionName); // Retrieving records, if no/invalid limit is specified then all records are retrieved otherwise records as per specified limit and offset are retrieved var nodeList = nodeTemplateCollection.Find(new BsonDocument()).Project(Builders <BsonDocument> .Projection.Exclude("Sections._t").Exclude("Buttons._t")).ToList(); var chatNodes = new ConcurrentBag <ChatNode>(); Parallel.ForEach(nodeList, node => { try { var chatNode = BsonSerializer.Deserialize <ChatNode>(node); chatNode.Sections = new List <Section>(); chatNode.Buttons = new List <Button>(); BsonArray sectionBsonArray = node.GetValue("Sections").AsBsonArray; foreach (BsonDocument sectionBsonDocument in sectionBsonArray) { Section sectObj = GetSection(sectionBsonDocument); chatNode.Sections.Add(sectObj); } BsonArray buttonBsonArray = node.GetValue("Buttons").AsBsonArray; foreach (BsonDocument buttonBsonDocument in buttonBsonArray) { Button btn = BsonSerializer.Deserialize <Button>(buttonBsonDocument); Content buttonContent = Contents.GetFor(btn); btn.ButtonName = buttonContent?.ButtonName; btn.ButtonText = buttonContent?.ButtonText; chatNode.Buttons.Add(btn); } chatNodes.Add(chatNode); } catch (Exception ex) { Logger.LogError(new EventId((int)LoggerEventId.MONGO_HELPER_ERROR), ex, "RetrieveRecordsFromChatNode Error: {0}", ex.Message); } }); var startNode = chatNodes.FirstOrDefault(x => x.IsStartNode); if (startNode != null) //If start chat node is present, move it up { var result = chatNodes.Where(x => x != startNode).ToList(); result.Insert(0, startNode); return(result); } return(chatNodes.ToList()); } catch (Exception ex) { Logger.LogError(new EventId((int)LoggerEventId.MONGO_HELPER_ERROR), ex, "RetrieveRecordsFromChatNode Error: {0}", ex.Message); } return(null); }
protected void Page_Load(object sender, EventArgs e) { if (Session["establishment"] == null) { Server.Transfer("Login.aspx"); } else { tbxChat.Text = ""; List <Chat> clist = ChatDB.getallChat(); foreach (Chat ch in clist) { Users s = UsersDB.getUserbyID(ch.by); if (s.email == null) { Establishment es = EstablishmentDB.getEstablishmentByID(ch.by); if (ch.status == "allow") { tbxChat.Text += es.Name + " @ " + ch.time + " : " + ch.message + "\r\n"; } } else { if (ch.status == "allow") { tbxChat.Text += s.username + " @ " + ch.time + " : " + ch.message + "\r\n"; } } } cnum = clist.Count; currente = (Establishment)(Session["establishment"]); lblOutputPost.Text = ""; List <ForumUser> flist = ForumUserDB.getAllForumUserbyStatus(); if (flist.Count == 0) { Panel1.Visible = false; lblGVOutput.Text = "There is no forum posted by user right now!"; } else { Panel1.Visible = true; gvUser.DataSource = flist; gvUser.DataBind(); lblGVOutput.Text = ""; } List <ForumEstablishment> elist = ForumEstablishmentDB.getAllForumEstbyStatus(); if (elist.Count == 0) { Panel2.Visible = false; lblGVEstOutput.Text = "There is no forum posted by establishment right now!"; } else { lblGVEstOutput.Text = ""; Panel2.Visible = true; gvEst.DataSource = elist; gvEst.DataBind(); } } }