Esempio n. 1
0
        public static SignupUser GetSignupUser(SignupUser user)
        {
            using (SqlConnection sqlCon = con)
            {
                sqlCon.Open();

                SqlCommand cmd = new SqlCommand("GetSignupUser", sqlCon);
                cmd.CommandType = System.Data.CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@Username", user.Username);
                cmd.Parameters.AddWithValue("@Password", SharedSupport.MD5Encrypt(user.Password));

                SqlDataReader dr = cmd.ExecuteReader();

                if (dr.HasRows)
                {
                    dr.Read();
                    return(new SignupUser
                    {
                        Id = Convert.ToInt32(dr[1]),
                        Username = dr[2].ToString(),
                        Gender = dr[4].ToString(),
                        Age = Convert.ToInt32(dr[5]),
                    });
                }
            }
            return(null);
        }
Esempio n. 2
0
        public static bool AddNewMod(Mod mod)
        {
            using (SqlConnection sqlCon = con)
            {
                sqlCon.Open();

                SqlCommand cmd = new SqlCommand("AddNewMod", sqlCon);
                cmd.CommandType = System.Data.CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@Username", mod.Username);
                cmd.Parameters.AddWithValue("@Password", SharedSupport.MD5Encrypt(mod.Password));

                return(Convert.ToInt32(cmd.ExecuteScalar()) == 1 ? true : false);
            }
        }
Esempio n. 3
0
        public static bool SignupNewUser(SignupUser user)
        {
            using (SqlConnection sqlCon = con)
            {
                sqlCon.Open();

                SqlCommand cmd = new SqlCommand("SignupNewUser", sqlCon);
                cmd.CommandType = System.Data.CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@ID", user.Id);
                cmd.Parameters.AddWithValue("@Username", user.Username);
                cmd.Parameters.AddWithValue("@Password", SharedSupport.MD5Encrypt(user.Password));
                cmd.Parameters.AddWithValue("@Gender", user.Gender);
                cmd.Parameters.AddWithValue("@Age", user.Age);

                return(Convert.ToInt32(cmd.ExecuteScalar()) == 1 ? true : false);
            }
        }
Esempio n. 4
0
        public static bool ValidateMod(Mod mod)
        {
            using (SqlConnection sqlCon = con)
            {
                sqlCon.Open();

                SqlCommand cmd = new SqlCommand("ValidateMod", sqlCon);
                cmd.CommandType = System.Data.CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@Username", mod.Username);
                cmd.Parameters.AddWithValue("@Password", SharedSupport.MD5Encrypt(mod.Password));

                SqlDataReader dr = cmd.ExecuteReader();
                if (dr.HasRows)
                {
                    return(true);
                }
            }
            return(false);
        }
Esempio n. 5
0
        public static void DeleteSignedOffUsers(Object source, System.Timers.ElapsedEventArgs e)
        {
            IEnumerable <ChatUser> users = GetUsers();

            List <string> bots = new List <string>()
            {
                "AaShQii", "Aliza", "AmirJoya", "Ayaan", "Baazigarr", "BholaBacha", "Blood_Seeker", "Diyyaa",
                "Eman", "FireCracker", "GreeN-Eyes", "Hamza26", "Iffi", "James", "Jazib", "JDee", "JohnSnow",
                "Khanaa", "Khoobsoorat", "King_of_Hrtzz", "LalaGujjar", "MamooJaan", "Manal", "Mubeen", "Mystic",
                "Namaloom", "Neha", "Peshawar_Man", "RaffatKhan", "Sara", "SarfarazJutt", "StevePapp", "Zain",
                "Uzair", "GaNdA_BaChA", "Dewana", "Bilal25", "Sehrish", "SpiderBoy", "Shahzad_akram"
            };

            if (users != null)
            {
                foreach (var item in users)
                {
                    if (bots.Where(x => x == item.Username).Count() == 0 && item.ConnectTime < DateTime.UtcNow.AddHours(5).AddMinutes(-20))
                    {
                        if (DeleteUser(item.Username))
                        {
                            if (!string.IsNullOrEmpty(item.Photo))
                            {
                                string image = SharedSupport.GetImageFolderPath() + item.Username + item.Photo.Substring(item.Photo.LastIndexOf("."));
                                if (System.IO.File.Exists(image))
                                {
                                    System.IO.File.Delete(image);
                                }
                            }

                            IHubContext hubContext = GlobalHost.ConnectionManager.GetHubContext <Chat>();
                            hubContext.Clients.AllExcept(item.ConnectionId).userLeft(item.Username);
                            hubContext.Clients.All.totalUsers(DBSupport.GetUsersCount());
                            hubContext.Clients.Client(item.ConnectionId).forceDisconnect();
                            hubContext.Clients.All.dcUserSessions(item.Username);
                        }
                    }
                }
            }
        }