Esempio n. 1
0
 static void Main(string[] args)
 {
     using (var cli = new UserServiceClient())
     {
         cli.AddUser("user1", "1234", true, false);
         cli.AddUser("user2", "1234", true, false);
     }
 }
Esempio n. 2
0
 static void Main(string[] args)
 {
     // User user = GetUser("Fly");
     UserServiceClient client = new UserServiceClient();
     WCFUserService.UserServiceClient newClient = new WCFUserService.UserServiceClient();
     Service2Callback callback = new Service2Callback();
     InstanceContext context = new InstanceContext(callback);
     Service2.Service2Client service2 = new Service2.Service2Client(context);
     service2.DoWork();
     WCFUserService.User user = new WCFUserService.User();
     newClient.GetUser(1,out user);
     Console.WriteLine(user.Name);
     Console.WriteLine(newClient.AddUser(new WCFUserService.User { Name = "jinjin", NickName = "yezi" }));
     Console.WriteLine(client.AddUser(new User { Name = "jingjing", NickName = "yezi" }));
     var pro = new ChannelFactory<Wcf.IService1>("service1").CreateChannel();
     Console.WriteLine(pro.GetData(100));
     try
     {
         newClient.Div(10, 0);
     }
     catch (FaultException<Test.WCFUserService.CalculatorError> ex)
     {
         Console.WriteLine(ex.Detail.ErrorMessage);
         newClient.Abort();
     }
     client.Close();
     newClient.Close();
     Console.ReadKey();
 }
 public ActionResult Register(RegisterViewModel model, string role, string numberWallet)
 {
     try
     {
         if (ModelState.IsValid)
         {
             if (!_clientUser.CheckUserLogin(model.Login))
             {
                 _clientUser.AddUser(role, model.Login, model.Password, model.Name, model.LastName, model.Patronymic, numberWallet);
                 FormsAuthentication.SetAuthCookie(model.Login, true);
                 return(RedirectToAction("Index", "Home", new { role }));
             }
             else
             {
                 ModelState.AddModelError(String.Empty, "Такой пользователь уже существует");
             }
         }
     }
     catch (System.ServiceModel.EndpointNotFoundException ex)
     {
         ModelState.AddModelError(String.Empty, "Ошибка подключения к серверу. Сервер недоступен");
     }
     catch (Exception ex)
     {
         ModelState.AddModelError(String.Empty, ex.Message);
     }
     return(View(model));
 }
Esempio n. 4
0
        public MainWindow()
        {
            //     InitializeComponent();

            UserServiceClient serviceClient = new UserServiceClient();

            MessageBox.Show(serviceClient.AddUser());
        }
        public ActionResult Create(User user)
        {
            userServiceClient.AddUser(user);

            string firstName = Request.Form["FirstName"];

            var ident = new ClaimsIdentity(
                new[] {
                new Claim(ClaimTypes.NameIdentifier, firstName),
                new Claim("http://schemas.microsoft.com/accesscontrolservice/2010/07/claims/identityprovider", "ASP.NET Identity", "http://www.w3.org/2001/XMLSchema#string"),

                new Claim(ClaimTypes.Name, firstName),
            },
                DefaultAuthenticationTypes.ApplicationCookie);

            HttpContext.GetOwinContext().Authentication.SignIn(
                new AuthenticationProperties {
                IsPersistent = false
            }, ident);

            return(RedirectToAction("Index", "Home"));
        }
Esempio n. 6
0
        private User CollectUser()
        {
            var user = new User
            {
                UserId = Guid.NewGuid(),
                Name = Environment.UserName,
                DomainName = Environment.UserDomainName,
                LogTime = DateTime.Now
            };

            using (var userServiceClient = new UserServiceClient())
            {
                userServiceClient.AddUser(user);
                user = userServiceClient.GetUserById(user.UserId);
            }
            return user;
        }
Esempio n. 7
0
 public void RegisterUser(string username, string password)
 {
     UserServiceClient client = new UserServiceClient();
     User user = new User() { userName = username, userPassword = password };
     client.AddUser(user);
 }