async void btnRegistrar_Clicked(object sender, EventArgs e)
        {
            UserServiceClient client = new UserServiceClient();

            try
            {
                Loading(true);
                UserInsertRequest request = new UserInsertRequest
                {
                    id           = txtCedula.Text,
                    direccion    = txtDireccion.Text,
                    eTag         = txtNombre.Text,
                    nombre       = txtNombre.Text,
                    partitionKey = txtCedula.Text,
                    rowKey       = txtNombre.Text,
                    telefono     = txtTelefono.Text,
                    timestamp    = DateTime.Now
                };

                await client.InsertUser(request);
                await DisplayAlert("Correcto", "Usuario registrado Correctamente", "OK");

                Loading(false);
                await Navigation.PushAsync(new MovementRegister(request));
            }
            catch (Exception ex)
            {
                await DisplayAlert("Incorrecto", ex.Message, "OK");
            }
        }
        private static bool FindUserServiceServer()
        {
            string[] serviceRootUrls = ConfigurationManager.AppSettings["LicenseHost"].Split(';');
            foreach (string serviceRootUrl in serviceRootUrls)
            {
                string serviceUrl = serviceRootUrl + "/Services/UserService.svc";
                System.ServiceModel.BasicHttpBinding binding = new System.ServiceModel.BasicHttpBinding(System.ServiceModel.BasicHttpSecurityMode.None);

                binding.MaxReceivedMessageSize = 10485760; //1Gig

                System.ServiceModel.EndpointAddress endPointAddress = new System.ServiceModel.EndpointAddress(serviceUrl);

                BitSite.UserServiceReference.UserServiceClient client = new BitSite.UserServiceReference.UserServiceClient(binding, endPointAddress);
                try
                {
                    client.HandShake();
                    userServiceClient = client;
                    return(true);
                }
                catch
                {
                }
            }
            return(false);
        }
        public ContactProfileWindowVM(IView view, User user) : base()
        {
            try
            {
                _view   = view;
                Profile = user;

                UserName     = Profile.FirstName;
                UserLastName = Profile.LastName;
                UserPhone    = Profile.Phone;
                UserEmail    = Profile.Email;
                UserBio      = Profile.Bio;
                bool contact;

                SetAvatarForUI();

                contact = UserServiceClient.IsExistsInContacts(GlobalBase.CurrentUser.Id, Profile.Id);

                if (contact)
                {
                    IsContact    = true;
                    IsNonContact = false;
                }
                else
                {
                    IsContact    = false;
                    IsNonContact = true;
                }
            }
            catch (Exception)
            {
            }
        }
Example #4
0
        static void Main(string[] args)
        {
            Console.Title = Assembly.GetExecutingAssembly().FullName;
            string input  = string.Empty;
            var    client = new UserServiceClient();

            do
            {
                Console.Write("Your age: ");
                input = Console.ReadLine();
                switch (input)
                {
                case "i":
                    break;

                case "Q":
                case "q":
                    break;

                default:
                    client.MethodThatWillChangeData(int.Parse(input));
                    break;
                }
                Console.WriteLine();
            } while (input.ToLower() != "q");
        }
Example #5
0
 public string GetTestString()
 {
     string result = "";
     UserServiceClient usc = new UserServiceClient();
     result = usc.GetHello();
     return result;
 }
Example #6
0
        public void TestMethod1()
        {
            var users = new UserServiceClient();
            var u     = users.ByEmail("[email protected]");

            Assert.AreNotEqual(u, null);
        }
 public ActionResult EditUserAccount(string id)
 {
     using (var proxy = new UserServiceClient())
     {
         var user  = proxy.GetUserByKey(new Guid(id));
         var model = UserAccountModel.CreateFromDto(user);
         var roles = proxy.GetRoles();
         if (roles == null)
         {
             roles = new List <RoleDto>().ToArray();
         }
         roles.ToList().Insert(0, new RoleDto()
         {
             Id = Guid.Empty.ToString(), Name = "(未指定)", Description = "(未指定)"
         });
         if (model.Role != null)
         {
             ViewData["roles"] = new SelectList(roles, "Id", "Name", model.Role.Id);
         }
         else
         {
             ViewData["roles"] = new SelectList(roles, "Id", "Name", Guid.Empty.ToString());
         }
         return(View(model));
     }
 }
Example #8
0
        public async Task <GetUserLoginResponseType> GetUserInfo(UserInfoRequest userInfoRequest)
        {
            try
            {
                var response = await UserServiceClient.UserGetuserloginAsync(userInfoRequest.DomainName,
                                                                             userInfoRequest.DomainUserGuid,
                                                                             userInfoRequest.DomainUserId,
                                                                             userInfoRequest.DeviceName,
                                                                             userInfoRequest.IpAddress,
                                                                             userInfoRequest.TemporaryAccessGuid);

                if (response.ResponseCd != "1")
                {
                    response.UserDefaultAgencyCd = string.IsNullOrEmpty(response.UserDefaultAgencyCd) ? SupremeAgencyId: response.UserDefaultAgencyCd;
                    Logger.LogDebug($"SMGOV_USERGUID: {userInfoRequest.DomainUserGuid}, UserAgencyCd: {response.UserDefaultAgencyCd}, UserPartId: {response.UserPartId}");
                    return(response);
                }
                Logger.LogInformation("Returned responseCd = 1 (failed) from getUserLogin");
                return(null);
            }
            catch (Exception e)
            {
                Logger.LogError(e, e.Message);
                return(null);
            }
        }
Example #9
0
 public static void loadPictures(UserServiceClient userServiceClient, List <UiInfo> uiInfos)
 {
     foreach (UiInfo uiInfo in uiInfos)
     {
         loadPicture(userServiceClient, uiInfo);
     }
 }
Example #10
0
        private bool ValidateOnLogin()
        {
            try
            {
                var message = string.Empty;

                if (string.IsNullOrWhiteSpace(LoginText))
                {
                    message = Translations.GetTranslation()["EmptyLogin"].ToString();
                }
                else if (Password.Length < 8 || string.IsNullOrWhiteSpace(Password) || Password == string.Empty || !Regex.IsMatch(Password, @"^[a-zA-Z0-9]{8,}$"))
                {
                    message = Translations.GetTranslation()["PassValidation"].ToString();
                }
                else if (UserServiceClient.GetUser(LoginText, AESEncryptor.encryptPassword(Password)) == null)
                {
                    message = Translations.GetTranslation()["LogPassValid"].ToString();
                }

                if (message != string.Empty)
                {
                    Application.Current.Dispatcher.Invoke(new Action((() => { CustomMessageBox.Show(Translations.GetTranslation()["Error"].ToString(), message); })));
                    return(false);
                }

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Example #11
0
        /// <summary>
        /// Initialises a new instance of the <see cref="MainForm"/> class.
        /// </summary>
        public MainForm()
        {
            this.InitializeComponent();

            var catalog = new AggregateCatalog();
            catalog.Catalogs.Add(new DirectoryCatalog("..\\..\\Crypto", "*.dll"));
            var batch = new CompositionBatch();
            batch.AddPart(this);
            this.compositionContainer = new CompositionContainer(catalog);
            ////get all the exports and load them into the appropriate list tagged with the importmany
            this.compositionContainer.Compose(batch);

            this.CryptoAlgorithmComboBox.DataSource = (new List<CryptoAlgorithm> { CryptoAlgorithm.None }).Union(
                this.CryptoProviders.Select(c => c.Metadata.Algorithm).Distinct()).ToList();

            this.JoinedUsers = new BindingList<User>();

            this.ConnectedUsersDataGridView.DataSource = this.JoinedUsers;
            this.userProxy = new UserServiceClient(new InstanceContext(this));

            this.userProxy.Open();
            this.messagingProxy = new MessagingServiceClient(new InstanceContext(this));
            this.messagingProxy.Open();

            this.userProxy.Subscribe();
            foreach (var u in this.userProxy.GetJoinedUsers())
            {
                this.AddUser(u);
            }

            this.uiSyncContext = SynchronizationContext.Current;
        }
Example #12
0
        public Task <List <User> > GetAll()
        {
            var users = new UserServiceClient();

            users.Open();
            return(users.GetAllAsync());
        }
Example #13
0
        public HttpResponseMessage Get(int id)
        {
            using (var client = new UserServiceClient())
            {
                var result = client.GetById(id);

                if (result == null)
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "UserId is not found"));
                }

                var user = new User
                {
                    Id            = result.Id,
                    Firstname     = result.FirstName,
                    Lastname      = result.LastName,
                    Email         = result.Email,
                    Subscriptions = result.Subscriptions.Select(z => new Subscription
                    {
                        Id                = z.Identifier,
                        Name              = z.Name,
                        Price             = z.Price,
                        Priceincvatamount = z.PriceIncVatAmount,
                        Callminutes       = z.CallMinutes
                    }).ToList(),

                    Totalcallminutes       = result.Subscriptions.Sum(t => t.CallMinutes),
                    Totalpriceincvatamount = result.Subscriptions.Sum(t => t.PriceIncVatAmount)
                };

                return(Request.CreateResponse(user));
            }
        }
Example #14
0
        public static void Main(string[] args)
        {
            const int port   = 9000;
            var       cacert = File.ReadAllText("Keys/ca.crt");
            var       cert   = File.ReadAllText("Keys/client.crt");
            var       key    = File.ReadAllText("Keys/client.key");

            var keypair  = new KeyCertificatePair(cert, key);
            var sslCreds = new SslCredentials(cacert, keypair);

            var channel = new Channel("Alexiss-MacBook-Pro.local", port, sslCreds);

            var client = new UserServiceClient(channel);

            Console.WriteLine("--- UNARY CALL ---------------------");
            GetByUserIdAsync(client).Wait();
            Console.WriteLine("------------------------------------");
            Console.WriteLine("--- SERVER STREAMING CALL ----------");
            GetAllAsync(client).Wait();
            Console.WriteLine("------------------------------------");
            Console.WriteLine("--- CLIENT STREAMING CALL ----------");
            AddImageAsync(client).Wait();
            Console.WriteLine("------------------------------------");
            Console.WriteLine("--- BIDIRECTIONAL STREAMING CALL ---");
            SaveAllAsync(client).Wait();
            Console.WriteLine("------------------------------------");
        }
Example #15
0
        public static void Main(string[] args)
        {
            var userServiceClient = new UserServiceClient(NET_NAMED_PIPE_ENDPOINT_NAME);

            var userListItemDtos = userServiceClient.GetAll();

            var userCreateDto = new UserCreateDto
            {
                UserName  = Guid.NewGuid().ToString().Substring(0, 10),
                FirstName = "b",
                Lastname  = "c",
                Notes     = new List <NoteCreateDto>
                {
                    new NoteCreateDto
                    {
                        Text  = "Salala",
                        Title = Guid.NewGuid().ToString().Substring(0, 10)
                    },
                    new NoteCreateDto
                    {
                        Text  = "Salala",
                        Title = Guid.NewGuid().ToString().Substring(0, 10)
                    }
                }
            };

            var userDto      = userServiceClient.Create(userCreateDto);
            var userDtoagain = userServiceClient.Get(userDto.Id);
        }
Example #16
0
        /// <summary>
        /// Generate new unique user login name.
        /// </summary>
        /// <param name="sender">Generate button.</param>
        /// <param name="e">Routed event data.</param>
        private void GenerateButtonClick(object sender, RoutedEventArgs e)
        {
            EnableUI(false);

            try
            {
                UpdateStatus("Generating unique user login...");

                userСlient = new UserServiceClient(
                    new BasicHttpBinding(),
                    new EndpointAddress(ServiceUrlTextBox.Text.Trim() + UserServiceUrlPostfix));

                UsernameTextBox.Text = userСlient.GenerateUniqueLogin();

                UpdateStatus("Ready");
            }
            catch (Exception exception)
            {
#if DEBUG
                throw;
#endif
#pragma warning disable 162
                ShowError(exception);
#pragma warning restore 162
            }

            EnableUI(true);
        }
        public ActionResult Create(UserViewModel pvm)
        {
            UserServiceClient usc = new UserServiceClient();

            usc.Create(pvm.user);
            return(RedirectToAction("Index"));
        }
        private async Task <List <User> > UserService()
        {
            UserServiceClient _userService = new UserServiceClient();
            var list = await _userService.GetAllAsync();

            return(JsonConvert.DeserializeObject <List <User> >(list));
        }
Example #19
0
 static void Main(string[] args)
 {
     foreach (var i in ServiceBridge.helper.Com.Range(100))
     {
         while (sub.Value.Resolve <Wcf.Contract.IUserService>() == null)
         {
             System.Threading.Thread.Sleep(1000);
             Console.WriteLine("等待服务上线");
         }
         try
         {
             System.Threading.Thread.Sleep(1000);
             //使用客户端调用,不用wcf相关配置
             using (var client = new UserServiceClient())
             {
                 var name = client.Instance.GetUserName("123");
                 Console.WriteLine($"服务返回数据:{name}");
             }
         }
         catch (Exception e)
         {
             Console.WriteLine(e.Message);
         }
     }
     //取消监听
     sub.Value.Dispose();
 }
Example #20
0
        public async Task <ActionResult> SaveUser(UserViewModel model)
        {
            using (UserServiceClient client = new UserServiceClient())
            {
                User u = new User()
                {
                    UserName    = model.UserName,
                    Description = model.Description,
                    Editor      = User.Identity.Name,
                    EditTime    = DateTime.Now,
                    IsActive    = model.IsActive,
                    IsApproved  = model.IsApproved,
                    IsLocked    = model.IsLocked,
                    Email       = model.Email,
                    MobilePhone = model.MobilePhone,
                    OfficePhone = model.OfficePhone,
                    Password    = model.Password,
                    CreateTime  = DateTime.Now,
                    Creator     = User.Identity.Name,
                    Key         = model.LoginName
                };
                MethodReturnResult rst = await client.AddAsync(u);

                if (rst.Code == 0)
                {
                    rst.Message = string.Format(StringResource.User_SaveUser_Success, u.Key);
                }
                return(Json(rst));
            }
        }
Example #21
0
        public Task <BaseResult> Delete(User user)
        {
            var users = new UserServiceClient();

            users.Open();
            return(users.DeleteAsync(user));
        }
Example #22
0
 public override bool ValidateUser(string username, string password)
 {
     using (var proxy = new UserServiceClient())
     {
         return(proxy.ValidateUser(username, password));
     }
 }
Example #23
0
        public static MvcHtmlString ActionLinkWithPermission(this HtmlHelper helper, string linkText, string action, string controller, PermissionKeys required)
        {
            if (helper == null ||
                helper.ViewContext == null ||
                helper.ViewContext.RequestContext == null ||
                helper.ViewContext.RequestContext.HttpContext == null ||
                helper.ViewContext.RequestContext.HttpContext.User == null ||
                helper.ViewContext.RequestContext.HttpContext.User.Identity == null)
            {
                return(MvcHtmlString.Empty);
            }

            using (var proxy = new UserServiceClient())
            {
                var role = proxy.GetRoleByUserName(helper.ViewContext.HttpContext.User.Identity.Name);
                if (role == null)
                {
                    return(MvcHtmlString.Empty);
                }
                var keyName       = role.Name;
                var permissionKey = (PermissionKeys)Enum.Parse(typeof(PermissionKeys), keyName);

                // 通过用户的角色和对应对应的权限进行与操作
                // 与结果等于用户角色时,表示用户角色与所需要的权限一样,则创建对应权限的链接
                //permissionKey & required 按位与运算 (required 权限按位或结果,比如权限 1或2 = 0011 )
                return((permissionKey & required) == permissionKey?
                       MvcHtmlString.Create(HtmlHelper.GenerateLink(helper.ViewContext.RequestContext, helper.RouteCollection,
                                                                    linkText, null, action, controller, null, null)) : MvcHtmlString.Empty);
            }
        }
Example #24
0
        public async Task <BaseResult> CreateOrUpdate(User user)
        {
            var users = new UserServiceClient();

            users.Open();
            return(await users.CreateOrUpdateAsync(user));
        }
        public void Test_GetUsersList_SuccessResponse()
        {
            var userServiceClient         = new UserServiceClient();
            var userServiceClientResponse = userServiceClient.GetUsers().ToList();

            Assert.AreEqual(userServiceClientResponse.Any(), true);
        }
        public ActionResult Edit(UserViewModel uvm)
        {
            UserServiceClient usc = new UserServiceClient();

            usc.Edit(uvm.user);
            return(RedirectToAction("Index"));
        }
        public ActionResult Delete(string id)
        {
            UserServiceClient usc = new UserServiceClient();

            usc.Delete(usc.Find(id));
            return(RedirectToAction("Index"));
        }
Example #28
0
        public ActionResult Contact(int?page)
        {
            UserServiceClient userClient = new UserServiceClient();
            var usersList = userClient.GetUsers(page ?? 1, PageSize);

            return(View(usersList.ToPagedList(page ?? 1, PageSize)));
        }
Example #29
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();
 }
Example #30
0
 public ShowProfileForm(ChatChoiceForm chform_ref)
 {
     InitializeComponent();
     userService = new UserServiceClient("BasicHttpBinding_IUserService");
     loadControlValues();
     chref = chform_ref;
 }
Example #31
0
        public HttpResponseMessage Get()
        {
            using (var client = new UserServiceClient())
            {
                var result = client.GetList().Select(x => new User
                {
                    Id            = x.Id,
                    Firstname     = x.FirstName,
                    Lastname      = x.LastName,
                    Email         = x.Email,
                    Subscriptions = x.Subscriptions.Select(z => new Subscription
                    {
                        Id                = z.Identifier,
                        Name              = z.Name,
                        Price             = z.Price,
                        Priceincvatamount = z.PriceIncVatAmount,
                        Callminutes       = z.CallMinutes
                    }).ToList(),

                    Totalcallminutes       = x.Subscriptions.Sum(t => t.CallMinutes),
                    Totalpriceincvatamount = x.Subscriptions.Sum(t => t.PriceIncVatAmount)
                }).ToList();

                return(Request.CreateResponse(result));
            }
        }
Example #32
0
        public async Task <ActionResult> Login(LoginViewModel model, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                using (UserAuthenticateServiceClient client = new UserAuthenticateServiceClient())
                {
                    MethodReturnResult <User> result = await client.AuthenticateAsync(model.UserName, model.Password);

                    if (result.Code == 0 && result.Data != null)
                    {
                        result.Data.LastLoginTime = DateTime.Now;
                        result.Data.LastLoginIP   = HttpContext.Request.UserHostAddress;
                        using (UserServiceClient usclient = new UserServiceClient())
                        {
                            MethodReturnResult rstl = await usclient.ModifyAsync(result.Data);

                            if (rstl.Code > 0)
                            {
                                AddErrors(result);
                            }
                        }

                        SignIn(result.Data, model.RememberMe);

                        return(RedirectToLocal(returnUrl));
                    }
                    else
                    {
                        AddErrors(result);
                    }
                }
            }
            // 如果我们进行到这一步时某个地方出错,则重新显示表单
            return(View(model));
        }
Example #33
0
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                User u = new User()
                {
                    Key      = model.LoginName,
                    Password = model.Password,
                    UserName = model.UserName
                };

                using (UserServiceClient client = new UserServiceClient())
                {
                    MethodReturnResult result = await client.AddAsync(u);

                    if (result.Code == 0)
                    {
                        SignIn(u, isPersistent: false);
                        return(RedirectToAction("Index", "Home"));
                    }
                    else
                    {
                        AddErrors(result);
                    }
                }
            }
            // 如果我们进行到这一步时某个地方出错,则重新显示表单
            return(View(model));
        }
Example #34
0
 public User CeckUser(string username, string password)
 {
     UserServiceClient client = new UserServiceClient();
     User user = new User() { userName = username, userPassword = password };
     user = client.GetClient(user);
     return user;
 }
Example #35
0
        private void loadUserTypes()
        {
            UserServiceClient userService = new UserServiceClient();
            cmbUserRole.DataSource = userService.GetAllUserTypes();
            cmbUserRole.DisplayMember = "UsersType";
            cmbUserRole.ValueMember = "UserTypeCode";

        }
 public UserController(IAuthProvider authProvider)
 {
     _postService = new PostServiceClient();
     _friendService = new FriendServiceClient();
     _userService = new UserServiceClient();
     _authProvider = authProvider;
     _commentService = new CommentServiceClient();
 }
Example #37
0
 public ViewResult messageBoardShow(string messageGuid)
 {
     using (UserServiceClient client = new UserServiceClient())
     {
         OM_MessageBoard msgBoard = client.GetMessageBoardModel(Cipher, messageGuid);
         return View("~/Views/log/messageBoardShow.cshtml", msgBoard);
     }
 }
 public SettingsController(IUserService userService, IAuthProvider authProvider, 
     ILocationService locationService, IHash hash)
 {
     _userService = new UserServiceClient();
     _authProvider = authProvider;
     _locationService = new LocationServiceClient();
     _hash = hash;
 }
Example #39
0
        private void butLogin_Click(object sender, EventArgs e)
        {
            UserServiceClient userService = new UserServiceClient();
            string message = String.Empty;
            if (txtPassword.Text.Equals("Enter Password")||txtPassword.Text.Equals(String.Empty) || txtUsername.Text.Equals("Enter Username")|| txtUsername.Text.Equals(String.Empty))
            {
                MessageBox.Show(this, "Username and Password is Required", "Required Fields");

            }
            else
            {
                if (userService.AuthenticateUser(txtUsername.Text, txtPassword.Text, ref message))
                {
                    //try
                    //{
                        eSAR.UserServiceRef.User u = new eSAR.UserServiceRef.User();
                        u = userService.GetUser(txtUsername.Text);
                        LoggedUser lu = new LoggedUser();

                        lu.UserId = u.UserId;
                        lu.UserName = u.UserName;
                        lu.LastName = u.LastName;
                        lu.FirstName = u.FirstName;
                        lu.MiddleName = u.MiddleName;
                        lu.UserType = u.UserTypeCode;

                        GlobalClass.UserLoggedIn = true;
                        GlobalClass.user = lu;
                        GlobalClass.currentsy = userService.GetCurrentSy();
                    GlobalClass.userTypeCode = lu.UserType;

                    LogServiceClient logService = new LogServiceClient();
                    string json = JsonConvert.SerializeObject(lu);
                    Log log = new Log
                    {
                        CLUD = "L",
                        LogDate = DateTime.Now,
                        TableName = "Users",
                        UserId = GlobalClass.user.UserId,
                        UserName = GlobalClass.user.UserName,
                        PassedData = json
                    };
                    logService.AddLogs(log);
                    Close();
                    //}
                    //catch (Exception ex)
                    //{
                    //    Console.WriteLine("Login Failed");
                    //}
                }
                else MessageBox.Show(this, message, "Login Failed");
                //frmLogIn FrmLogin = new frmLogIn();
                //FrmLogin.Show();
            }
            //this.Show();
            //frmLogIn FrmLogin = new frmLogIn();
            //FrmLogin.Show();
        }
Example #40
0
        static void Main(string[] args) {

            using (WCF.UserService.UserServiceClient client = new UserServiceClient()) {
                bool success = client.Insert(new User_MODEL());
                Console.WriteLine(success);
            }

            Console.Read();
        }
Example #41
0
 static void Main(string[] args)
 {
     using (UserServiceClient cs = new UserServiceClient())
     {
         var p = cs.GetUserByEmail("*****@*****.**");
         var c = p;
     }
     Console.ReadLine();
 }
Example #42
0
        //public ActionResult Login(User user){
        //    UserServiceClient service = new UserServiceClient();
        //    User userSign = new User();
        //    //Arrumar no webservice !!!
        //    userSign = service.findByEmailAndPassword(user);
        //    //userSign = service.find(user);
        //    //service.signIn(userSign);
        //    return View("_RegisterUser");
        //}
        public ActionResult SignIn(User user)
        {
            UserServiceClient service = new UserServiceClient();
            try{
                Session["currentUser"] = service.signIn(user);
            }catch(Exception ex) {
                throw new FaultException("Usuario ou senha invalido |" +ex);
            }

            return RedirectToAction("Index","Post");
        }
Example #43
0
        public static UserServiceClient GetUserServiceClient()
        {
            if (_userServiceClient != null && _userServiceClient.State == CommunicationState.Faulted)
            {
                RecreateAllChannels();
            }

            if (_userServiceClient == null)
                _userServiceClient = new UserServiceClient(_defaultBinding, new EndpointAddress(Host + "User"));
            return _userServiceClient;
        }
        public void CreateNewUser()
        {
            var user = new User();
            user.Login = "******";
            user.Password = "******";
            user.CreatedDate = DateTime.Now;
            user.UpdateDate = DateTime.Now;

            var userService = new UserServiceClient();
            userService.Add(user);
        }
Example #45
0
        public ActionResult ConfirmEmail(string tolken)
        {
            UserServiceClient service = new UserServiceClient();
            try{

               // Session["currentUser"] = service.confirmEmail(tolken);
            }
            catch (Exception ex)
            {
                throw new FaultException("Usuario nao possui sessao ativa |" + ex);
            }

            return View("_Login");
        }
Example #46
0
        public ActionResult SignOut(User user)
        {
            UserServiceClient service = new UserServiceClient();
            try
            {
                Session["currentUser"] = null;
            }
            catch (Exception ex)
            {
                throw new FaultException("Usuario nao possui sessao ativa |" + ex);
            }

            return RedirectToAction("Index", "Home");
        }
Example #47
0
 public ActionResult Approved(string id, string approvedID)
 {
     bool ok;
     using (UserServiceClient svc = new UserServiceClient()) {
         ok = svc.UserApproved(id, approvedID);
     }
     if (ok) {
         TempData["WhiteTitle"] = "验证成功!感谢注册!";
     } else {
         TempData["WhiteTitle"] = MvcHtmlString.Create("验证失败。请 <a href='/Account/ReSendApproved'>点击这里</a> 重新申请验证邮件。");
         TempData["WhiteContent"] = MvcHtmlString.Create("您的注册邮箱:" + id.EmailLinkBtn());
         TempData["WhiteColor"] = "c_red";
     }
     return RedirectToAction("White", "Home");
 }
Example #48
0
        static void Main(string[] args)
        {
            UserServiceClient client = new UserServiceClient();
            WebServiceClient client1 = new WebServiceClient();

            package p = new package();
            p.packageName = "sdsdsds";
            client1.addPackage(p);

               // Users user = new Users();
               // user.userName = "******";
               // client.GetClient();

            Console.WriteLine("de");
        }
 private void BtnLogin_Click(object sender, EventArgs e)
 {
     try
     {
         IUserService service = new UserServiceClient();
         string userName = txtUserName.Text;
         string passWord = txtPassWord.Text;
         DemoUserDto user = service.Login(userName, passWord);
         MessageBox.Show(user.ToString());
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Example #50
0
        private void butLogin_Click(object sender, EventArgs e)
        {
            UserServiceClient userService = new UserServiceClient();
            string message = String.Empty;

            if (userService.AuthenticateUser(txtUsername.Text, txtPassword.Text, ref message))
            {
                User u = new User();
                u=userService.GetUser(txtUsername.Text);
                GlobalClass g = new GlobalClass();
                g.GetUser(u);

                Close();
            }
                else MessageBox.Show(this, message, "Login Failed");
        }
Example #51
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (userSelected != null)
            {
                UserServiceClient userService = new UserServiceClient();
                string message = String.Empty;

                if (!userService.DeleteUser(userSelected.UserId, ref message))
                {
                    message = "Deletion of User Failed";
                }
                else
                {
                    MessageBox.Show("Deleted succesfully!");
                }
            }
        }
Example #52
0
        /// <summary>
        /// Action lorsqu'on clique sur "Connexion"
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnConnexion_Click(object sender, RoutedEventArgs e)
        {
            IsEnabled = false;

            string sErreurs = "";

            // Vérifications de bases...
            if (txtUtilisateur.Text.Trim().Length < 3)
                sErreurs += "-Le nom d'utilisateur doit être minimalement 3 caractères de long.\n";

            if (txtPasse.Password.Trim().Length < 3)
                sErreurs += "-Le mot de passe doit être minimalement 3 caractères de long.\n";

            if (sErreurs.Length <= 0)
            {
                using (var svcClient = new UserServiceClient())
                {
                    Guid? guid = null;

                    try
                    {
                        guid = svcClient.Login(txtUtilisateur.Text.Trim(), txtPasse.Password);
                    }
                    catch
                    {
                        sErreurs += "-Le serveur est hors-ligne.\n"; 
                    }

                    if (guid == null)
                        sErreurs += "-Les identifiants sont erronés\n";

                    UserSessionSingleton.Instance.UserToken = guid;
                    UserSessionSingleton.Instance.Name = txtUtilisateur.Text;
                }
            }

            if (sErreurs.Length > 0)
            {
                MessageBox.Show(sErreurs, "Erreur");
                IsEnabled = true;
            }
            else
            {
                OpenLobby();
            }
        }
Example #53
0
        //留言板
        public ViewResult MessageBoard(string key, int? pageIndex = 0, int? pageSize = 10)
        {
            using (UserServiceClient client = new UserServiceClient())
            {
                List<OM_MessageBoard> list = client.GetCurrentUserMessageBoard(Cipher, CurrentUser.User.Guid);

                if (!string.IsNullOrWhiteSpace(key))
                {
                    list = list.Where(s => s.Name.Contains(key)).ToList();
                    ViewBag.Key = key;
                }
                ViewBag.PageSize = pageSize;
                ViewBag.PageIndex = pageIndex;
                ViewBag.TotalPages = Math.Ceiling(Convert.ToDouble(list.Count) / Convert.ToDouble(pageSize));
                var result = list.Skip(Convert.ToInt32(pageIndex * pageSize)).Take((int)pageSize).ToList();
                return View("~/views/log/messageBoard.cshtml", result);
            }
        }
Example #54
0
        //日记  Randy want to modify
        public ViewResult Index(string key, int? pageIndex = 0, int? pageSize = 10)
        {
            string userId = CurrentUser.User.Guid;
            UserServiceClient client = new UserServiceClient();
            List<OM_LogDataObject> list = client.GetCurrentUserLogs(Cipher, userId);

            if (!string.IsNullOrWhiteSpace(key))
            {
                list = list.Where(s => s.User_Name.Contains(key)).ToList();
                ViewBag.Key = key;
            }
            ViewBag.PageSize = pageSize;
            ViewBag.PageIndex = pageIndex;
            ViewBag.TotalPages = Math.Ceiling(Convert.ToDouble(list.Count) / Convert.ToDouble(pageSize));
            var result = list.Skip(Convert.ToInt32(pageIndex * pageSize)).Take((int)pageSize).ToList();
            client.Close();
            return View("~/views/log/index.cshtml", result);
        }
Example #55
0
 public async void Login()
 {
     using (var service = new UserServiceClient())
     {
         try
         {
             var result = await service.LoginAsync(Username, Helper.Hash(_passwordBox.Password));
             AppData.User = result;
             Success = true;
             TryClose();
         }
         catch (FaultException<BadLoginCredentialsException>)
         {
             _passwordBox.Password = "";
             Message = LocalizationHelper.GetString("BadLogin");
         }
     }
 }
        /// <summary>
        /// Lorsqu'on veut s'enregistrer.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnRegister_Click(object sender, RoutedEventArgs e)
        {
            IsEnabled = false;

            string sErreurs = "";

            // Vérifications de bases...
            if (txtUtilisateur.Text.Trim().Length < 3)
                sErreurs += "-Le nom d'utilisateur doit être minimalement 3 caractères de long.\n";

            if (txtPasse.Password.Trim().Length < 3)
                sErreurs += "-Le mot de passe doit être minimalement 3 caractères de long.\n";

            if (txtEmail.Text.Trim().Length < 7)
                sErreurs += "-L'adresse email est invalide :^(\n";

            using (var svcClient = new UserServiceClient())
            {
                CreateUserInfo cui = new CreateUserInfo();
                cui.Email = txtEmail.Text;
                cui.Password = txtPasse.Password;
                cui.Username = txtUtilisateur.Text;

                bool ok = svcClient.CreateUser(cui);

                if (!ok)
                    sErreurs += "-Utilisateur existant ou email déjà en utilisation.\n" +
                                "-Serveur peut-être hors-ligne?";
            }

            if (sErreurs.Length > 0)
            {
                MessageBox.Show(sErreurs, "Erreur");
                IsEnabled = true;
                return;
            }
            else
            {
                MessageBox.Show("Inscription réussie! vous pouvez désormais vous connecter.");
                Close();
            }
        }
        private void BtnRegister_Click(object sender, EventArgs e)
        {
            try
            {
                IUserService service = new UserServiceClient();
                DemoUserDto userData = new DemoUserDto
                    {
                        UserName = txtUserName.Text,
                        PassWord = txtPassWord.Text,
                        Email = "*****@*****.**"
                    };

                DemoUserDto user = service.RegisterUserByDto(userData);
                MessageBox.Show(user.ToString());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Example #58
0
 public async void Register()
 {
     if (_passwordBox.Password != _passwordBox2.Password)
     {
         Message = LocalizationHelper.GetString("PasswordMatchFail");
         return;
     }
     using (var svc = new UserServiceClient())
     {
         try
         {
             await svc.RegisterUserAsync(Username, Helper.Hash(_passwordBox.Password));
             TryClose();
         }
         catch (FaultException<AlreadyRegisteredException>)
         {
             Message = LocalizationHelper.GetString("AlreadyRegistered");
         }
     }
 }
Example #59
0
        public void LoadUsers()
        {
            UserServiceClient userService = new UserServiceClient();
            string message = String.Empty;
            try
            {
                var users = userService.GetAllUsers();
                userList = new List<User>(users);
                gvUser.DataSource = users;
                gvUser.Refresh();

                if (gvUser.RowCount != 0)
                    gvUser.Rows[0].IsSelected = true;
            }
            catch (Exception ex)
            {
                message = "Error Loading UserList";
                MessageBox.Show(ex.ToString());
            }
        }
Example #60
0
        /// <summary>
        /// Petit hacks pour préloader les connexions et certains symboles.
        /// </summary>
        private async void LoadConnections()
        {
            await Task.Delay(1000);

            try
            {
                LobbyService.LobbyServiceClient ddd = new LobbyService.LobbyServiceClient();
                ddd.Open();
                UserServiceClient ccc = new UserServiceClient();
                ccc.Open();

                using (var gsc = new GameProxy.GameServiceClient())
                {
                    gsc.Open();
                }
            }
            catch
            {
                MessageBox.Show("Il semble que la connexion est inexistante...");
            }
        }