Exemplo n.º 1
0
        /// <summary>
        /// 新增员工,去除Token
        /// </summary>
        /// <param name="data"></param>
        /// <param name="companyId"></param>
        /// <returns></returns>
        public static int CreateUser(CreateUserData data, int companyId)
        {
            if (companyId == 0)
            {
                throw new ArgumentNullException("公司Id不能为空");
            }
            if (data == null)
            {
                throw new ArgumentException("data 参数不能为空");
            }


            using (var c = Sql.CreateConnection())
                using (var t = c.OpenTransaction())
                {
                    //TODO CompanyId 换成从token获取
                    int userId = t.SelectScalar <int>(Sql.CreateUserSql, new
                    {
                        data.UserName,
                        data.Tel,
                        data.Password,
                        data.DepartmentId,
                        companyId
                    });
                    // int bingGroup = t.SelectScalar<int>(Sql.BingGroup, new { data.RoleId, userId });
                    if (userId != 0)
                    {
                        t.Commit();
                        return(userId);
                    }
                    return(0);
                }
        }
Exemplo n.º 2
0
 void OnApplyData(CreateUserData data)
 {
     if (SignUp != null)
     {
         SignUp(data);
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// 新增员工
        /// </summary>
        /// <param name="data"></param>
        /// <param name="token"></param>
        /// <returns></returns>
        public static int CreateUser(CreateUserData data, string token)
        {
            if (string.IsNullOrWhiteSpace(token))
            {
                throw new ArgumentException("token不能为空");
            }
            if (data == null)
            {
                throw new ArgumentException("data 参数不能为空");
            }
            var companyId = DisassembleProtocol(token)["CompanyId"];

            using (var c = Sql.CreateConnection())
                using (var t = c.OpenTransaction())
                {
                    //TODO CompanyId 换成从token获取
                    int userId = t.SelectScalar <int>(Sql.CreateUserSql, new { data.UserName, data.Tel, data.Password, data.DepartmentId, companyId });
                    // int bingGroup = t.SelectScalar<int>(Sql.BingGroup, new { data.RoleId, userId });
                    if (userId != 0)
                    {
                        t.Commit();
                        return(userId);
                    }
                    return(0);
                }
        }
Exemplo n.º 4
0
        public async Task <ActionResult> Registration(RegistrationViewModel model)
        {
            if (ModelState.IsValid)                 //if registration data correct
            {
                var userData = new CreateUserData() //create new container for new user data
                {
                    UserName    = model.UserName,
                    Email       = model.Email,
                    NewPassword = model.Password,
                    Roles       = new string[] { "Users" }
                };

                var result = await UserService.CreateAsync(userData);               //try to add new user

                if (result.Succedeed)                                               //if user was added successfully
                {
                    var user = await UserService.GetByNameAsync(userData.UserName); //get new user data

                    var url = Url.Action("ConfirmEmail", "Account", null, Request.Url.Scheme);
                    await UserService.SendVerificationEmailAsync(user.Id, url); //send email confiramtion

                    return(View("RegistrationCompleted"));
                }
                ModelState.AddModelError("", result.Message); //add error to model
            }
            return(View(model));                              //return registration form
        }
Exemplo n.º 5
0
        public void SaveProfileChanges(CreateUserData profileChanges)
        {
            Device.BeginInvokeOnMainThread(() => UserDialogs.Instance.ShowLoading(AppResources.LoadingSavingProfileChanges));

            var saveProfileChanges = new RegisterUserBackgroundTask(profileChanges, false, AppModel.Instance.CurrentUser.User.Id);

            saveProfileChanges.ContinueWith((task, result) =>
            {
                //AppModel.Instance.ap
                UserDialogs.Instance.HideLoading();

                if (task.Exception != null)
                {
                    ServerException exception = (ServerException)task.Exception.InnerException;
                    var serverError           = JsonConvert.DeserializeObject <ServerError>(exception.ErrorMessage);
                    AppProvider.PopUpFactory.ShowMessage(serverError.ErrorMessage, AppResources.Warning);
                }
                else
                {
                    Device.BeginInvokeOnMainThread(
                        () => AppController.Instance.AppRootPage.NavigateTo(MainMenuItemData.ProfilePage, true));
                }
            });
            _backgroundWorkers[AppBackgroundWorkerType.UserPostData].Add(saveProfileChanges);
        }
Exemplo n.º 6
0
        public void RegisterUser(CreateUserData data)
        {
            UserDialogs.Instance.ShowLoading(AppResources.LoadingCreatingUser);

            var registerTask = new RegisterUserBackgroundTask(data);

            registerTask.ContinueWith((task, result) =>
            {
                UserDialogs.Instance.HideLoading();

                if (task.Exception != null)
                {
                    ServerException exception = (ServerException)task.Exception.InnerException;
                    var serverError           = JsonConvert.DeserializeObject <ServerError>(exception.ErrorMessage);

                    AppProvider.PopUpFactory.ShowMessage(serverError.ErrorMessage, AppResources.Warning);
                }
                else
                {
                    Device.BeginInvokeOnMainThread(
                        () => AppController.Instance.AppRootPage.NavigateTo(MainMenuItemData.LoginPage, true, result.Email, result.Password));
                }
            });
            _backgroundWorkers[AppBackgroundWorkerType.UserPostData].Add(registerTask);
        }
Exemplo n.º 7
0
        public EditProfilePage(User currentUser)
        {
            Title     = AppResources.EditProfile;
            Model     = currentUser;
            ImagePath = null;
            if (!string.IsNullOrEmpty(Model.ProfileImagePath))
            {
                ImageData imageData = AppModel.Instance.Images.Items.Find(temp => temp.ServerPath.Equals(Model.ProfileImagePath));
                ImagePath = imageData != null ? imageData.ImagePath : null;
            }

            CreateUserData data = new CreateUserData
            {
                Name         = currentUser.Name,
                Email        = currentUser.Email,
                Password     = null,
                UserType     = currentUser.Id,
                Job          = currentUser.Job,
                Phone        = currentUser.Phone,
                ProfileImage = ImagePath
            };
            FillUserDataView fillData = new FillUserDataView(data, AppResources.SaveProfileButton, false);

            fillData.Apply += OnSaveUserProfile;
            var layout = new ContentView {
                Content = fillData, Padding = new Thickness(0, 10, 0, 0)
            };

            BGLayoutView bgLayout = new BGLayoutView(AppResources.DefaultBgImage, layout, false, true);

            //Content = new ScrollView { Content = layout };
            //Content = new ScrollView { Content = bgLayout };

            Content = bgLayout;
        }
Exemplo n.º 8
0
        /// <summary>
        /// Method for creating new user and store it to database
        /// </summary>
        /// <param name="userData">Data that was stored to database as new user</param>
        /// <returns></returns>
        public async Task <OperationDetails> CreateAsync(CreateUserData userData)
        {
            UserAccount accountByEmail = await repo.AccountManager.FindByEmailAsync(userData.Email);  //find user with new user email

            UserAccount accountByName = await repo.AccountManager.FindByNameAsync(userData.UserName); //find user with new user name

            if (accountByEmail == null && accountByName == null)                                      //if users with new user email or name is not exist
            {
                var account = new UserAccount()                                                       //create new user account model object
                {
                    Email          = userData.Email,
                    UserName       = userData.UserName,
                    EmailConfirmed = false,
                };

                var profile = new UserProfile() //create new user profile model object
                {
                    AccountId        = account.Id,
                    Avatar           = userData.Avatar,
                    Gender           = (Model.Enums.Gender)userData.Gender,
                    RegistrationDate = DateTime.Now
                };

                account.Profile = profile;

                IdentityResult result = await repo.AccountManager.CreateAsync(account, userData.NewPassword);

                //add new user account to database
                if (!result.Succeeded)                                                                               //if user was not added successfully
                {
                    return(new OperationDetails(false, "Can`t create new account:" + string.Concat(result.Errors))); //return fail result with message
                }

                if (userData.Roles != null)                                                                               //if new user data have information about user roles
                {
                    foreach (string role in userData.Roles)                                                               //for each role name in user data roles
                    {
                        if (await repo.RoleManager.RoleExistsAsync(role))                                                 //if role with this name is exists
                        {
                            result = await repo.AccountManager.AddToRoleAsync(account.Id, role);                          //add user to this role

                            if (!result.Succeeded)                                                                        //if can`t add user to role
                            {
                                return(new OperationDetails(false, $"Can`t add role \"{role}\" to {userData.UserName}")); //return fail result with message
                            }
                        }
                        else
                        {
                            return(new OperationDetails(false, $"Can`t add role \"{role}\" to {userData.UserName}, because this role doesn't exist in database"));
                        }
                    }
                }
                return(new OperationDetails(true, "User account added suceessfully"));
            }
            else
            {
                return(new OperationDetails(false, "User with this email or username is already exists"));
            }
        }
Exemplo n.º 9
0
 public CreateUserRequest(
     CreateUserData data,
     IRestClient restClient,
     ValenceAuthenticator auth
     )
 {
     m_userData   = data;
     m_restClient = restClient;
     m_auth       = auth;
 }
Exemplo n.º 10
0
        static void Main(string[] args)
        {
            string appId   = ConfigurationManager.AppSettings["applicationId"];
            string appKey  = ConfigurationManager.AppSettings["applicationKey"];
            string userId  = ConfigurationManager.AppSettings["serviceUserId"];
            string userKey = ConfigurationManager.AppSettings["serviceUserKey"];
            string lmsUrl  = ConfigurationManager.AppSettings["lmsUrl"];

            ValenceAuthenticatorFactory authFactory = new ValenceAuthenticatorFactory(
                appId, appKey, userId, userKey, lmsUrl);
            ValenceAuthenticator auth = authFactory.CreateAuthenticator();

            RestClient restClient = new RestClient("https://" + lmsUrl);

            JsonSerializer     serializer = new JsonSerializer();
            CreateUserResponse userResponse;

            using (StreamReader file = File.OpenText("user.json")) {
                CreateUserData    userData    = (CreateUserData)serializer.Deserialize(file, typeof(CreateUserData));
                CreateUserRequest userRequest = new CreateUserRequest(
                    userData,
                    restClient,
                    auth
                    );
                userResponse = userRequest.SendRequest();
            }

            CreateCourseResponse courseResponse;

            using (StreamReader file = File.OpenText("course.json")) {
                CreateCourseData    courseData    = ( CreateCourseData )serializer.Deserialize(file, typeof(CreateCourseData));
                CreateCourseRequest courseRequest = new CreateCourseRequest(
                    courseData,
                    restClient,
                    auth
                    );
                courseResponse = courseRequest.SendRequest();
            }

            CreateEnrollData enrollData = new CreateEnrollData(
                userResponse.UserId,
                courseResponse.Identifier
                );
            CreateEnrollRequest enrollRequest = new CreateEnrollRequest(
                enrollData,
                restClient,
                auth
                );

            enrollRequest.SendRequest();

            Console.WriteLine("User, course, and enrollment created.");
            Console.ReadKey();
        }
Exemplo n.º 11
0
        public LinkedInLoginPage(CreateUserData data, String serverImagePath)
        {
            _newUserData     = data;
            _serverImagePath = serverImagePath;
            NavigationPage.SetHasNavigationBar(this, false);

            Title = " ";
            LinkedInLoginView loginView = new LinkedInLoginView();

            loginView.LogIn += OnLogIn;
            Content          = loginView;
        }
Exemplo n.º 12
0
        internal Result AddUser(string companyId, AddUserParams data)
        {
            var loggerManager = new LoggerManager();
            var operationGuid = Guid.NewGuid().ToString();

            try
            {
                loggerManager.InsertLogoRecord(nameof(AddUser), nameof(LogLevel.Info), null, data.TransactionId, JsonConvert.SerializeObject(data));

                var orderDemandManager = new OrderDemandManager();
                var addUser            = new CreateUserData
                {
                    Address            = data.Address,
                    Email              = data.Email,
                    FirstName          = data.FirstName,
                    LastName           = data.LastName,
                    OrderDemandGuid    = operationGuid,
                    ContactInfo        = data.ContactInfo,
                    ExternalCustomerId = companyId,
                    ExternalId         = data.UserId,
                    Username           = data.Username
                };

                var validator  = new AddUserValidator();
                var valResults = validator.Validate(addUser);

                var validationSucceeded = valResults.IsValid;
                if (!validationSucceeded)
                {
                    var failures = valResults.Errors;
                    var message  = failures.Aggregate(string.Empty, (current, failure) => current + (failure.ErrorMessage + "<br />"));
                    return(new Result {
                        IsCompleted = false, Success = false, Message = message
                    });
                }

                orderDemandManager.SaveOrderDemand(null, operationGuid, 0, (int)ProvisionType.CreateUser, (int)OrderDemandStates.Created, (int)OrderDemandType.Integrated, JsonConvert.SerializeObject(addUser), data.TransactionId);
                return(new Result {
                    IsCompleted = false, Success = true
                });
            }
            catch (Exception ex)
            {
                loggerManager.InsertLogoRecord(nameof(AddUser), nameof(LogLevel.Error), ex.Message + " " + ex.StackTrace, operationGuid, JsonConvert.SerializeObject(data));
                return(new Result {
                    IsCompleted = true, Success = false, Message = ex.Message
                });
            }
        }
Exemplo n.º 13
0
        public Playbook ToModel()
        {
            Playbook playbook = new Playbook(PlaybookSystemId);

            playbook.ChangePlaybookId(PlaybookId);
            playbook.ChangeCategory(CategoryData != null ? CategoryData.ToModel() : new Models.Category("0000"));
            playbook.ChangePlayName(new PlayName(PlayFullName, PlayShortName, PlayCallName));
            playbook.ChangeContext(new Context(Context));
            playbook.ChangeInstallStatus(IntroduceStatus);
            playbook.ChangePlayDesign(new PlayDesign(PlayDesignUrl));
            playbook.ChangeCreateUser(CreateUserData != null ? CreateUserData.ToModel() : new User(0, 0), CreateDate);
            playbook.ChangeLastUpdateUser(LastUpdateUserData != null ? LastUpdateUserData.ToModel() : new User(0, 0), LastUpdateDate);

            return(playbook);
        }
Exemplo n.º 14
0
        public void GetUserLinkedinPasswd(CreateUserData data, String serverImagePath)
        {
            if (Device.OS == TargetPlatform.iOS)
            {
                AppController.Instance.AppRootPage.CurrentPage.Navigation.PopModalAsync();
                LinkedInLoginPage linkedinLogPage = new LinkedInLoginPage(data, serverImagePath);
                //AppController.Instance.AppRootPage.NavigateTo(MainMenuItemData.LoginLinkedinPage,false);
                AppController.Instance.AppRootPage.CurrentPage.Navigation.PushAsync(linkedinLogPage);
            }
            else
            {
                LinkedInLoginPage linkedinLogPage = new LinkedInLoginPage(data, serverImagePath);
                AppController.Instance.AppRootPage.CurrentPage.Navigation.PushModalAsync(linkedinLogPage);
            }


            // AppController.Instance.AppRootPage.NavigateTo(MainMenuItemData.ProfilePage, true))
        }
Exemplo n.º 15
0
        private void OnSaveUserProfile(CreateUserData data)
        {
            if (SaveProfileChanges != null)
            {
                data.Name  = Model.Name.Equals(data.Name) ? data.Name : data.Name;
                data.Email = Model.Email.Equals(data.Email) ? data.Email : data.Email;
                //data.Password = Model.Passphrase;
                data.UserType     = Model.UserType;
                data.Job          = Model.Job.Equals(data.Job) ? data.Job : data.Job;
                data.ProfileImage = ImagePath != null && ImagePath.Equals(data.ProfileImage) ? data.ProfileImage : data.ProfileImage;
                if (Model.Phone != null)
                {
                    if (String.IsNullOrEmpty(Model.Phone))
                    {
                        data.Phone = " ";
                    }
                    else
                    {
                        data.Phone = Model.Phone.Equals(data.Phone) ? data.Phone : data.Phone;
                    }
                }
                data.ScorePoints = Model.ScorePoints;

                /* TODO Validar se não mudou nada EditProfilePage */
                SaveProfileChanges(data);

                /*
                 * if (data.Name == Model.Name &&
                 *  data.Email == Model.Email &&
                 *  data.Job == Model.Job &&
                 *  data.ProfileImage == Model.p &&
                 *  data.Phone == null &&
                 *  data.ScorePoints == null)
                 * {
                 *  AppProvider.PopUpFactory.ShowMessage(AppResources.EditProfileNoChanges, string.Empty);
                 * }
                 * else
                 * {
                 *  SaveProfileChanges(data);
                 * }
                 */
            }
        }
Exemplo n.º 16
0
        public override void DoJob(dynamic data)
        {
            var operationGuid = string.Empty;

            try
            {
                CreateUserData json = JsonConvert.DeserializeObject <CreateUserData>(data);
                operationGuid = json.OrderDemandGuid;

                _userRepository.SaveUser(json);

                _orderDemandRepository.ChangeOrderDemandState(operationGuid, (int)OrderDemandStates.Finished);
            }

            catch (Exception ex)
            {
                _orderDemandRepository.ChangeOrderDemandState(operationGuid, (int)OrderDemandStates.FinishedError);
                _logRepository.InsertLogoRecord(nameof(Create), nameof(LogLevel.Error), ex.Message + " " + ex.StackTrace, operationGuid, data);
            }
        }
Exemplo n.º 17
0
        public async Task <ActionResult> Create(CreateUserViewModel userData)
        {
            if (ModelState.IsValid)
            {
                CreateUserData userDto = new CreateUserData()
                {
                    UserName    = userData.UserName,
                    Email       = userData.Email,
                    NewPassword = userData.Password,
                    Roles       = userData.Roles.Where(r => r.Checked).Select(r => r.Name)
                };
                var result = await UserService.CreateAsync(userDto);

                if (result.Succedeed)
                {
                    return(RedirectToRoute(new { area = "Admin", controller = "Account", action = "List" }));
                }
                ModelState.AddModelError("", result.Message);
            }
            return(View(userData));
        }
Exemplo n.º 18
0
        public override void ViewDidAppear(bool animated)
        {
            if (!IsShown)
            {
                IsShown = true;

                udata = new CreateUserData();
                base.ViewDidAppear(animated);

                auth = new OAuth2Authenticator(
                    clientId: "77c1rz71bj79xe",
                    clientSecret: "ixk8ykW2zSTqYLes",
                    scope: "r_basicprofile r_emailaddress",
                    authorizeUrl: new Uri("https://www.linkedin.com/uas/oauth2/authorization"),
                    redirectUrl: new Uri("https://www.i9acao.com.br/"),
                    accessTokenUrl: new Uri("https://www.linkedin.com/uas/oauth2/accessToken")
                    );
                auth.Completed += authCompleted;
                PresentViewController(auth.GetUI(), true, PostSignUp);
            }
        }
Exemplo n.º 19
0
        public async Task <TenantUser> CreateUser(CreateUserData data)
        {
            var tenantUser = new TenantUserEntity
            {
                Email              = data.Email,
                UserName           = data.UserGuid.ToString(),
                DisplayName        = data.DisplayName,
                UserGuid           = data.UserGuid,
                ImageUrl           = data.ImageUrl,
                TenantId           = data.TenantId,
                SelectedAvatarType = data.AvatarType
            };

            var result = await _userManager.CreateAsync(tenantUser, data.Password);

            if (!result.Succeeded)
            {
                throw new RepositoryException(nameof(CreateUser), result.Errors.Select(x => x.Code));
            }

            return(_mapper.Map <TenantUser>(tenantUser));
        }
Exemplo n.º 20
0
        public HttpResponseMessage AddUsers(SearchString Info)
        {
            string strInfo = string.Empty;
            List <CreateUserData> Forms = new List <CreateUserData>();

            try
            {
                XmlNodeList xmlnode;
                string      xmlContent = Info.strSearchString;
                XmlDocument doc        = new XmlDocument();
                doc.LoadXml(xmlContent);
                xmlnode = doc.GetElementsByTagName("Info");
                var    random       = new Random(System.DateTime.Now.Millisecond);
                int    randomNumber = random.Next(1, 500000);
                string rndNumber    = randomNumber.ToString();
                string imageData    = xmlnode[0].ChildNodes.Item(1).InnerText.Trim();
                if (imageData != "")
                {
                    var strimage = imageData.Substring(imageData.LastIndexOf(',') + 1);
                    SaveImage(strimage, rndNumber + ".jpg");
                }
                Forms = CreateUserData.CreateUpdateUsers(Info);
            }
            catch (Exception ex)
            {
            }
            HttpResponseMessage response;

            if (string.IsNullOrEmpty(strInfo))
            {
                response = Request.CreateResponse(HttpStatusCode.OK, Forms);
            }
            else
            {
                response = Request.CreateResponse(strInfo);
            }
            return(response);
        }
Exemplo n.º 21
0
        public void RegisterUserLinkedin(CreateUserData data, String serverImagePath)
        {
            var popTask = AppController.Instance.AppRootPage.CurrentPage.Navigation.PopModalAsync();

            popTask.ContinueWith((_pTask) =>
            {
                // AppController.Instance.AppRootPage.NavigateTo(MainMenuItemData.LoginPage, true);


                UserDialogs.Instance.ShowLoading(AppResources.LoadingCreatingUser);
                var registerTask = new RegisterUserBackgroundTask(data);
                registerTask.ContinueWith((task, result) =>
                {
                    UserDialogs.Instance.HideLoading();

                    if (task.Exception != null)
                    {
                        ServerException exception = (ServerException)task.Exception.InnerException;
                        var serverError           = JsonConvert.DeserializeObject <ServerError>(exception.ErrorMessage);

                        AppProvider.PopUpFactory.ShowMessage(serverError.ErrorMessage, AppResources.Warning);
                    }
                    else
                    {
                        LoginUserData lud = new LoginUserData();
                        lud.Email         = result.Email;
                        lud.Password      = result.Password;
                        LoginUser(lud);

                        //Device.BeginInvokeOnMainThread(() => AppController.Instance.AppRootPage.NavigateTo(MainMenuItemData.ProfilePage, true));
                        // () => AppController.Instance.AppRootPage.NavigateTo(MainMenuItemData.LoginPage, true, result.Email, result.Password));
                    }
                });
                _backgroundWorkers[AppBackgroundWorkerType.UserPostData].Add(registerTask);
            });
        }
Exemplo n.º 22
0
        public void SaveUser(CreateUserData data)
        {
            using (var context = Context)
            {
                var company = context.Companys.FirstOrDefault(c => c.ExternalId == data.ExternalCustomerId);
                var user    = new User
                {
                    Company     = company,
                    CompanyId   = company.CompanyId,
                    Address     = data.Address,
                    ContactInfo = data.ContactInfo,
                    CreateDate  = DateTime.Now,
                    Email       = data.Email,
                    ExternalId  = data.ExternalId,
                    FirstName   = data.FirstName,
                    LastName    = data.LastName,
                    Username    = data.Username,
                    RoleId      = company.ExternalId.Equals(data.ExternalId) ? (int?)UserRoles.SSOAdmin : null
                };

                context.Users.Add(user);
                context.SaveChanges();
            }
        }
Exemplo n.º 23
0
        public void createUserLinkedin()
        {
            CreateUserData udata = new CreateUserData();
            var            auth  = new OAuth2Authenticator(
                clientId: "77c1rz71bj79xe",
                clientSecret: "ixk8ykW2zSTqYLes",
                scope: "r_basicprofile r_emailaddress",
                authorizeUrl: new Uri("https://www.linkedin.com/uas/oauth2/authorization"),
                redirectUrl: new Uri("http://www.i9acao.com.br/"),
                accessTokenUrl: new Uri("https://www.linkedin.com/uas/oauth2/accessToken")
                );



            var items = loginScreenVC.NavigationItem;



            auth.AllowCancel = true;
            //auth.GetUI();
            ViewController.PresentViewController(auth.GetUI(), true, null);
            //PresentViewController(auth.GetUI(), true, null);
            ///Forms.Context.StartActivity(auth.GetUI(Forms.Context));
            auth.Completed += (sender2, eventArgs) =>
            {
                if (eventArgs.IsAuthenticated)
                {
                    string dd = eventArgs.Account.Username;
                    string imageServerPath;
                    var    values = eventArgs.Account.Properties;

                    var access_token = values["access_token"];
                    try
                    {
                        var request = System.Net.HttpWebRequest.Create(string.Format(@"https://api.linkedin.com/v1/people/~:(firstName,lastName,headline,picture-url,positions,email-address )?oauth2_access_token=" + access_token + "&format=json", ""));
                        request.ContentType = "application/json";
                        request.Method      = "GET";

                        using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
                        {
                            System.Console.Out.WriteLine("Stautus Code is: {0}", response.StatusCode);

                            using (StreamReader reader = new StreamReader(response.GetResponseStream()))
                            {
                                var content = reader.ReadToEnd();
                                if (!string.IsNullOrWhiteSpace(content))
                                {
                                    System.Console.Out.WriteLine(content);
                                }


                                var result = JsonConvert.DeserializeObject <dynamic>(content);
                                udata.Job          = (string)result["headline"];
                                udata.Email        = (string)result["emailAddress"];
                                udata.Name         = (string)result["firstName"] + " " + (string)result["lastName"];
                                udata.Password     = access_token;
                                udata.Phone        = " ";
                                udata.ProfileImage = (string)result["pictureUrl"];
                                imageServerPath    = (string)result["pictureUrl"];
                                udata.ScorePoints  = 0;

                                UserController.Instance.RegisterUserLinkedin(udata, imageServerPath);
                            }
                        }
                    }
                    catch (Exception exx)
                    {
                        System.Console.WriteLine(exx.ToString());
                    }
                }
            };
        }
Exemplo n.º 24
0
 private void OnCreateUser(CreateUserData userData)
 {
     UserController.Instance.RegisterUser(userData);
 }
Exemplo n.º 25
0
        public FillUserDataView(CreateUserData userData, string buttonName, bool isPasswordEnabled)
        {
            _fakeProfileImagePath = Path.Combine(AppProvider.IOManager.DocumentPath, "fakeProfileImage.jpeg");
            Model = userData;
            var layout = new StackLayout {
                BackgroundColor = Color.Transparent,
                Padding         = new Thickness(0, 0, 10, 0)
            };

            var topLayout = new StackLayout {
                Orientation = StackOrientation.Horizontal,
                Padding     = new Thickness(10, 0, 0, 0)
            };

            string imagePath   = string.IsNullOrEmpty(userData.ProfileImage) ? AppResources.DefaultUserImage : userData.ProfileImage;
            var    imageLayout = new StackLayout {
            };

            _profileImage = new Image {
                WidthRequest  = 100,
                HeightRequest = 100,
                Source        = ImageLoader.Instance.GetImage(imagePath, false)
            };

            imageLayout.Children.Add(_profileImage);

            var btnUpdatePicture = new Button {
                WidthRequest    = 100,
                FontSize        = 15,
                Text            = AppResources.SignUpChooseImage,
                BackgroundColor = Color.Transparent,
                TextColor       = AppResources.SignUpChooseImageButtonColor,
                BorderRadius    = 0,
                BorderWidth     = 2,
                BorderColor     = AppResources.SignUpChooseImageButtonColor
            };

                        #if __ANDROID__
            btnUpdatePicture.TextColor       = Color.White;
            btnUpdatePicture.BackgroundColor = AppResources.SignUpChooseImageButtonColor;
                        #endif

            btnUpdatePicture.Clicked += OnImageClicked;
            imageLayout.Children.Add(btnUpdatePicture);

            topLayout.Children.Add(imageLayout);

            var nameSurnameLayout = new StackLayout();
            nameSurnameLayout.Children.Add(GetEntry(Keyboard.Create(KeyboardFlags.CapitalizeSentence), AppResources.GetName(Model.Name), AppResources.LoginNameDefaultEntry, 20, false, out _nameEntry, 140, 10));
            nameSurnameLayout.Children.Add(GetEntry(Keyboard.Create(KeyboardFlags.CapitalizeSentence), AppResources.GetSurname(Model.Name), AppResources.LoginSurnameDefaultEntry, 15, false, out _surnameEntry, 140, 10));

            topLayout.Children.Add(nameSurnameLayout);

            layout.Children.Add(topLayout);

            layout.Children.Add(GetEntry(Keyboard.Email, Model.Email, AppResources.LoginEmailDefaultEntry, 10, false, out _emailEntry));

            if (isPasswordEnabled)
            {
                layout.Children.Add(GetEntry(Keyboard.Text, Model.Password, AppResources.LoginPasswordDefaultEntry, 10, true, out _passwordEntry));
            }

            layout.Children.Add(GetEntry(Keyboard.Create(KeyboardFlags.CapitalizeSentence), Model.Job, AppResources.LoginJobDefaultEntry, 15, false, out _jobEntry));
            layout.Children.Add(GetEntry(Keyboard.Telephone, Model.Phone, AppResources.LoginPhoneDefaultEntry, 10, false, out _phoneEntry));

            var applyBtn = new Button {
                BorderRadius    = 5,
                WidthRequest    = AppProvider.Screen.Width,
                FontSize        = 14,
                TextColor       = Color.White,
                BackgroundColor = AppResources.LoginButtonColor,
                Text            = buttonName
            };
            applyBtn.Clicked += OnApplyClicked;
            layout.Children.Add(new ContentView {
                Padding = new Thickness(LeftBorder, 10, LeftBorder, 0), HorizontalOptions = LayoutOptions.Center, Content = applyBtn
            });

            var fs = new FormattedString();

            string firstPart  = "Ao clicar em cadastrar, você confirma estar de acordo com nossos";
            string secondPart = " Termos de Uso ";
            string thirdPart  = "e também está de acordo com a nossa ";


            fs.Spans.Add(new Span {
                Text = firstPart, ForegroundColor = Color.Black, FontSize = 14
            });
            fs.Spans.Add(new Span {
                Text = secondPart, ForegroundColor = Color.Blue, FontSize = 14
            });
            fs.Spans.Add(new Span {
                Text = thirdPart, ForegroundColor = Color.Black, FontSize = 14
            });
            string fourthPart = " Política de Privacidade";

            var labelTerms = new Label {
                FormattedText = fs
            };
            TapGestureRecognizer tap = new TapGestureRecognizer();
            tap.Tapped += OnClicked;
            labelTerms.GestureRecognizers.Add(tap);

            var fs2 = new FormattedString();

            fs2.Spans.Add(new Span {
                Text = fourthPart, ForegroundColor = Color.Blue, FontSize = 14
            });

            var labelPrivaPol = new Label
            {
                FormattedText = fs2
            };

            TapGestureRecognizer tap2 = new TapGestureRecognizer();
            tap2.Tapped += OnClicked2;
            labelPrivaPol.GestureRecognizers.Add(tap2);



            layout.Children.Add(new ContentView {
                Content = labelTerms, Padding = new Thickness(10, 10, 10, 0)
            });
            layout.Children.Add(new ContentView {
                Content = labelPrivaPol, Padding = new Thickness(10, 0, 10, 0)
            });


            Content = new ScrollView {
                Content = layout
            };

            _requiredFields = new List <InputFieldView> {
                _jobEntry,
                _emailEntry,
                _nameEntry,
                _passwordEntry,
                //_phoneEntry,
                _surnameEntry
            };
        }
Exemplo n.º 26
0
 void OnSaveProfileChanges(CreateUserData data)
 {
     UserController.Instance.SaveProfileChanges(data);
 }
Exemplo n.º 27
0
        public int CreateUser(CreateUserData user)
        {
            using (MooDB db = new MooDB())
            {
                User newUser = new User()
                {
                    BriefDescription = "我很懒,什么都没留下~",
                    Description = "我真的很懒,真的什么也没留下。",
                    Email = user.Email,
                    Name = user.Name,
                    Password = Converter.ToSHA256Hash(user.Password),
                    CreateTime = DateTime.Now,
                    Role = new SiteRoles(db).NormalUser,
                    Score = 0,
                };

                if (Security.Authenticated)
                {
                    Access.Required(db, newUser, Function.CreateUser);
                }

                db.Users.AddObject(newUser);
                db.SaveChanges();

                return newUser.ID;
            }
        }