Esempio n. 1
0
        public static ClientsDetailsPackage getClientsDetailsPackage(LoginPackage lp)
        {
            if (!isClientExist(lp.Username, lp.Password))
            {
                return new ClientsDetailsPackage {
                           Exist = false
                }
            }
            ;

            setLogOn(lp);
            Client c = new Client();

            c.getClient(lp.Username);

            foreach (var item in lp.FileList)
            {
                int id = item.insertFile();

                ClientFile cf = new ClientFile(lp.Username, id);
                cf.insertClientFile();
            }

            return(new ClientsDetailsPackage {
                Exist = true, Username = c.Username, UpPath = c.UpPath, DownPath = c.DownPath, IP = c.Ip, Port = c.Port
            });
        }
Esempio n. 2
0
        public static void setLogOut(string username)
        {
            string connectionString = ConfigurationManager.ConnectionStrings["MiniTorrentLibrary.Properties.Settings.MiniTorrentDBConnectionString"].ConnectionString;
            string query            = "UPDATE Clients SET Active = @active where Username = @username";

            using (SqlConnection connection = new SqlConnection(connectionString))
                using (SqlCommand command = new SqlCommand(query, connection))
                {
                    connection.Open();

                    command.Parameters.AddWithValue("@username", username);
                    command.Parameters.AddWithValue("@active", false);

                    command.ExecuteScalar();
                }

            ClientFile.removeAllFilesByUsername(username);
        }