public static jUser GetUser(object user) { jUser objUser = new jUser(); Dictionary <string, object> tmp = (Dictionary <string, object>)user; object objUsername = null; object objEmail = null; object objPassword = null; object objIP = null; object objData = null; object objType = null; tmp.TryGetValue("Username", out objUsername); tmp.TryGetValue("Email", out objEmail); tmp.TryGetValue("Password", out objPassword); tmp.TryGetValue("IP", out objIP); tmp.TryGetValue("Data", out objData); tmp.TryGetValue("Type", out objType); objUser.Username = objUsername.ToString(); objUser.Email = objEmail.ToString(); objUser.Password = objPassword.ToString(); objUser.IP = objIP.ToString(); objUser.Data = objData.ToString(); objUser.Type = objType.ToString(); return(objUser); }
public static string webLogin(object jsonParam) { jUser objUser = GetUser(jsonParam); jUserAuthentication jUserAuth = new jUserAuthentication(); jUserAuth.jUser = objUser; jUserAuth.validate(); if (jUserAuth.Authencated) { FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(jUserAuth.jUser.Username, true, 12 * 60); string encryptedTicket = FormsAuthentication.Encrypt(authTicket); HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket); cookie.Expires = authTicket.Expiration; HttpContext.Current.Response.Cookies.Set(cookie); jUserAuthenticated objUserAuthed = JsonConvert.DeserializeObject <jUserAuthenticated>(jUserAuth.jUser.Data); return(JsonConvert.SerializeObject(objUserAuthed)); } else { jUserAuthenticated objUserAuthed = JsonConvert.DeserializeObject <jUserAuthenticated>(jUserAuth.jUser.Data); return(JsonConvert.SerializeObject(objUserAuthed)); // return "Logon attempt unsuccessful. Please try again."; } }
public NetEventPlugin_baseball(user_id_t pp_id, CmdEventManager gui, NetEventManager msg) { m_User = new jUser(this); //Debug.Log("NetEventPlugin_baseball create" + pp_id); m_UserID = pp_id; m_CMD = gui; m_MSG = msg; }
public async static Task <List <DateTimeOffset> > collectMessages(SocketUser user, SocketGuild guild) { jGuild g = await Globals.requestDataFindAsync(item => item.Id == guild.Id); jUser u = g.LookUp(user.Id); if (u == null || u.Timestamps == null) { return(new List <DateTimeOffset>()); } else { return(u.Timestamps); } }
public static void addMsg(IMessage msg, SocketCommandContext Context) { IMongoCollection <jGuild> storedGlobalData = Globals.db.GetCollection <jGuild>("globalData"); // Get current user, technically does the same thing as loopign through everytihng and is probably optimized by the system jUser u = requestDataFind(item => item.Id == Context.Guild.Id).Channels.Find(item => item.Id == Context.Channel.Id).Users.Find(item => item.Id == Context.User.Id); // add this single message to the user u.Timestamps.Add(msg.Timestamp); //Update user var update = Builders <jGuild> .Update // ---------------Get current user, again so it points to the on in the guild obj-------------------new user obj .Set(p => p.Channels.Find(item => item.Id == Context.Channel.Id).Users.Find(item => item.Id == Context.User.Id), u); storedGlobalData.FindOneAndUpdate(item => item.Id == Context.Guild.Id, update); }
public static void indexChannel(ISocketMessageChannel channel, jChannel outChannel) { Console.WriteLine("Starting " + channel.Name + " index"); if (outChannel == null) { outChannel = new jChannel(channel); } var messages = new List <IReadOnlyCollection <IMessage> >(); try { messages = channel.GetMessagesAsync(int.MaxValue).ToEnumerable().ToList(); } catch (Exception ex) { return; } Console.WriteLine("Got messages for " + channel.Name); int threadCount = 0; foreach (IReadOnlyCollection <IMessage> collection in messages) { foreach (IMessage m in collection) { if (!outChannel.Users.Exists(item => item.Id == m.Author.Id)) { jUser newU = new jUser() { Id = m.Author.Id, Name = m.Author.Username, Timestamps = new List <DateTimeOffset>() }; newU.Timestamps.Add(m.Timestamp); outChannel.Users.Add(newU); } else { outChannel.Users.Find(item => item.Id == m.Author.Id).Timestamps.Add(m.Timestamp); } } #region old_threaded //threadCount++; //Thread TTh = new Thread(async delegate () //{ // foreach (IMessage m in collection) // { // try // { // //if (m.Author.IsBot || m.Author.IsWebhook || m.Content == "" || m.Conten) // if (m == null || m.Author == null) { continue; } // if (outChannel.Users.Exists(item => item.Id == m.Author.Id)) // { // try // { // outChannel.Users.Find(item => item.Id == m.Author.Id).Timestamps.Add(m.Timestamp); // } // catch (Exception ex) // { // continue; // } // } // else // { // if (adding.Contains(m.Author.Id)) // { // while (adding.Contains(m.Author.Id)) // { // Thread.Sleep(5); // } // try // { // outChannel.Users.Find(item => item.Id == m.Author.Id).Timestamps.Add(m.Timestamp); // } // catch (Exception ex) // { // continue; // } // continue; // } // adding.Add(m.Author.Id); // jUser newU = new jUser() // { // Id = m.Author.Id, // Name = m.Author.Username, // Timestamps = new List<DateTimeOffset>() // }; // newU.Timestamps.Add(m.Timestamp); // outChannel.Users.Add(newU); // adding.RemoveAll(item => item == m.Author.Id); // } // } // catch (Exception ex) { // continue; // } // } //}); //TTh.Name = channel.Name + " | " + threadCount + " | " + channel.Id; //Globals.threads.Add(TTh); //Globals.waitForLessLoad(); //TTh.Start(); #endregion } Console.WriteLine("Finished " + channel.Name + " index"); }
public static void LogMessage(IMessage message) { if (message.Author.IsBot) { return; } if (message.Content == "" || message.Content == null) { return; } var Context = client.GetChannel(message.Channel.Id) as SocketGuildChannel; if (Globals.requestDataWhere(item => item.Id == Context.Guild.Id).Count() == 0) { //Globals.globalData.Add(new jGuild //{ // Name = Context.Guild.Name, // Id = Context.Guild.Id, // Channels = new List<jChannel>() //}); Globals.addGuild(Context.Guild); //Console.WriteLine("[" + DateTime.Now.ToLocalTime().ToShortTimeString() + "]: Guild created"); } jGuild currentGuild = Globals.requestDataWhere(item => item.Id == Context.Guild.Id).First(); if (currentGuild.Channels.Where(item => item.Id == message.Channel.Id).Count() == 0) { currentGuild.Channels.Add(new jChannel { Name = message.Channel.Name, Id = message.Channel.Id, Users = new List <jUser>() }); //Console.WriteLine("[" + DateTime.Now.ToLocalTime().ToShortTimeString() + "]: Channel created"); } jChannel currentChannel = currentGuild.Channels.Where(item => item.Id == message.Channel.Id).First(); if (currentChannel.Users.Where(item => item.Id == message.Author.Id).Count() == 0) { currentChannel.Users.Add(new jUser { Name = message.Author.Username, Id = message.Author.Id, Timestamps = new List <DateTimeOffset>() }); //Console.WriteLine("[" + DateTime.Now.ToLocalTime().ToShortTimeString() + "]: User created"); currentChannel.Users.Last().Timestamps.Add(message.Timestamp); //Console.WriteLine("[" + DateTime.Now.ToLocalTime().ToShortTimeString() + "]: Message Logged successfully"); return; } jUser currentUser = currentChannel.Users.Where(item => item.Id == message.Author.Id).First(); if (!currentUser.Timestamps.Contains(message.Timestamp)) { currentUser.Timestamps.Add(message.Timestamp); //Console.WriteLine("[" + DateTime.Now.ToLocalTime().ToShortTimeString() + "]: Message Logged successfully"); } else { //Console.WriteLine("[" + DateTime.Now.ToLocalTime().ToShortTimeString() + "]: Existing Message Already Logged"); } }