using System; using System.Collections.Generic; using HeuristicLab.Services.Authentication.DataTransfer; namespace HeuristicLab.Services.Authentication.TestClient { class TestClient { static void Main(string[] args) { AuthenticationService auth = new AuthenticationService(); try { //Console.WriteLine("Insert new application"); //Application app1 = new Application() { ApplicationName="SPR Application", Description="SPR Application"}; //app1 = auth.InsertApplication(app1); //if (app1 != null) //{ // Console.WriteLine("okay"); //} //else //{ // Console.WriteLine("error"); //} //Console.WriteLine("--------------------------"); //Console.WriteLine("Insert user SPRTEST"); //Membership membership = new Membership() { Email="aaa@bbb.com", Password="aaa", PasswordAnswer="bar", PasswordQuestion="foo?", PasswordSalt="aaa"}; //User user1 = new User(){ UserName="SPRTEST", IsAnonymous=false, LastActivityDate=DateTime.Now, ApplicationId=app1.ApplicationId, Membership=membership}; //auth.InsertUser(user1); //Console.WriteLine("--------------------------"); //Console.WriteLine("Get user SPRTEST"); //User user2 = auth.GetUser(app1.ApplicationId, "SPRTEST"); //if (user2 != null) //{ // Console.WriteLine("id=" + user2.UserId); //} //else //{ // Console.WriteLine("not found!"); //} //Console.WriteLine("--------------------------"); //Console.WriteLine("Get user Einstein"); //User user3 = auth.GetUser(app1.ApplicationId, "Einstein"); //if (user3 != null) //{ // Console.WriteLine("id=" + user2.UserId); //} //else //{ // Console.WriteLine("not found!"); //} //Console.WriteLine("--------------------------"); //Console.WriteLine("Insert role Role1"); //Role role1 = new Role() { RoleName = "Role1", Description = "first test role", ApplicationId = app1.ApplicationId }; //if (auth.InsertRole(role1)) //{ // Console.WriteLine("okay"); //} //else //{ // Console.WriteLine("error"); //} //Console.WriteLine("--------------------------"); //Console.WriteLine("Get Role Role1"); //Role role2 = auth.GetRole(app1.ApplicationId, "Role1"); //if (role2 != null) //{ // Console.WriteLine("id=" + role2.RoleId); //} //else //{ // Console.WriteLine("not found!"); //} //Console.WriteLine("--------------------------"); //Console.WriteLine("Get Role Role2"); //Role role3 = auth.GetRole(app1.ApplicationId, "Role2"); //if (role3 != null) //{ // Console.WriteLine("id=" + role3.RoleId); //} //else //{ // Console.WriteLine("not found!"); //} //Console.WriteLine("--------------------------"); //Console.WriteLine("GetRoles"); //IEnumerable list3 = auth.GetRoles(app1.ApplicationId); //foreach (Role role in list3) //{ // Console.WriteLine(role.RoleName); //} //Console.WriteLine("--------------------------"); //Console.WriteLine("Is User SPRTEST In Role1"); //if (auth.IsUserInRole(role2.RoleId, user2.UserId)) //{ // Console.WriteLine("true"); //} //else //{ // Console.WriteLine("false"); //} //Console.WriteLine("--------------------------"); //Console.WriteLine("Add User SPRTEST To Role1"); //if (auth.AddUserToRole(role2.RoleId, user2.UserId)) //{ // Console.WriteLine("okay"); //} //else //{ // Console.WriteLine("error"); //} //Console.WriteLine("--------------------------"); //Console.WriteLine("Is User SPRTEST In Role1"); //if (auth.IsUserInRole(role2.RoleId, user2.UserId)) //{ // Console.WriteLine("true"); //} //else //{ // Console.WriteLine("false"); //} //Console.WriteLine("--------------------------"); //Console.WriteLine("Add User SPRTEST To Role2"); //if (role3 != null && auth.AddUserToRole(role3.RoleId, user2.UserId)) //{ // Console.WriteLine("okay"); //} //else //{ // Console.WriteLine("error"); //} //Console.WriteLine("--------------------------"); //IEnumerable list1 = auth.GetUsers(app1.ApplicationId); //Console.WriteLine("Get Users"); //foreach (var item in list1) //{ // Console.WriteLine( item.UserName); //} //Console.WriteLine("--------------------------"); //User user4 = auth.GetUser(app1.ApplicationId, "SPRTEST"); //if (user4 != null) //{ // IEnumerable roles = auth.GetRolesForUser(user4.UserId); // Console.WriteLine("Get Roles for user SPRTEST"); // foreach (Role r in roles) // { // Console.WriteLine(r.RoleName); // } //} ///* //Console.WriteLine("--------------------------"); //Console.WriteLine("Remove SPRTEST From Role1"); //if (auth.RemoveUserFromRole(role2.RoleId, user4.UserId)) //{ // Console.WriteLine("okay"); //} //else //{ // Console.WriteLine("error"); //} //*/ //Console.WriteLine("--------------------------"); //User user5 = auth.GetUser(app1.ApplicationId, "SPRTEST"); //if (user5 != null) //{ // IEnumerable roles = auth.GetRolesForUser(user5.UserId); // Console.WriteLine("Get Roles for user SPRTEST"); // foreach (Role r in roles) // { // Console.WriteLine(r.RoleName); // } //} ///* //Console.WriteLine("--------------------------"); //Console.WriteLine("Delete User SPRTEST"); //if (auth.DeleteUser(user4.UserId)) //{ // Console.WriteLine("okay"); //} //else //{ // Console.WriteLine("error"); //} //Console.WriteLine("--------------------------"); //*/ //IEnumerable list2 = auth.GetUsers(app1.ApplicationId); //Console.WriteLine("Get Users"); //foreach (var item in list2) //{ // Console.WriteLine(item.UserName); //} //Console.WriteLine("--------------------------"); //Console.WriteLine("Update user SPRTEST"); //User user6 = auth.GetUser(app1.ApplicationId,"SPRTEST"); //if (user6 != null) //{ // user6.LoweredUserName = "new lowered name"; // user6.Membership.Email = "new email"; // auth.UpdateUser(user6); //} } catch (Exception e) { Console.WriteLine(e.Message); } // User form System.Windows.Forms.Application.Run(new UserManagement()); } } }