コード例 #1
0
        public Person Read(uint id)
        {
            List <string[]> data = Persistence.ReadEntryByPrimaryKey(path, id.ToString());

            if (data.Count == 0)
            {
                return(null);
            }
            //Person data
            string[] line        = data[0];
            uint     personId    = uint.Parse(line[PeopleConstants.ID_COLUMN]);
            UserType personType  = (UserType)int.Parse(line[PeopleConstants.USER_TYPE_COLUMN]);
            string   jmbg        = line[PeopleConstants.JMBG_COLUMN];
            string   name        = line[PeopleConstants.NAME_COLUMN];
            string   surname     = line[PeopleConstants.SURNAME_COLUMN];
            string   phone       = line[PeopleConstants.PHONE_COLUMN];
            string   email       = line[PeopleConstants.EMAIL_COLUMN];
            Sex      sex         = (Sex)int.Parse(line[PeopleConstants.SEX_COLUMN]);
            string   username    = line[PeopleConstants.USERNAME_COLUMN];
            string   password    = line[PeopleConstants.PASSWORD_COLUMN];
            uint     medRecordId = line[PeopleConstants.MEDICAL_RECORD_ID_COLUMN].Equals("")? 0: uint.Parse(line[PeopleConstants.MEDICAL_RECORD_ID_COLUMN]);
            string   address     = line[PeopleConstants.ADDRESS_COLUMN];

            //StaffData
            long   dateTicks      = line[PeopleConstants.BIRTH_DATE_COLUMN].Equals("") ? 0 : long.Parse(line[PeopleConstants.BIRTH_DATE_COLUMN]);
            bool   decased        = line[PeopleConstants.DECASED_COLUMN].Equals("") ? false : bool.Parse(line[PeopleConstants.DECASED_COLUMN]);
            string parentName     = line[PeopleConstants.PARENT_NAME_COLUMN];
            string alergenIdsText = line[PeopleConstants.ALERGENS_IDS_COLUMN];
            //string contract = line[PeopleRepositoryConstants.CONTRACT_COLUMN];
            bool   active         = line[PeopleConstants.IS_ACTIVE_COLUMN].Equals("") ? false : bool.Parse(line[PeopleConstants.IS_ACTIVE_COLUMN]);
            string specialization = line[PeopleConstants.SPECIALIZATION_COLUMN];

            if (personType.Equals(UserType.Patient))
            {
                return(new Patient(personId, name, surname, phone, email, sex, jmbg, username, password, personType, address, new DateTime(dateTicks), decased, parentName, medRecordId, getAlergens(alergenIdsText)));
            }
            else if (personType.Equals(UserType.Secretary))
            {
                return(new Secretary(personId, name, surname, phone, email, sex, jmbg, username, password, personType, null, active));
            }
            else if (personType.Equals(UserType.Doctor))
            {
                return(new Doctor(personId, name, surname, phone, email, sex, jmbg, username, password, personType, null, active));
            }
            else if (personType.Equals(UserType.Manager))
            {
                return(new Manager(personId, name, surname, phone, email, sex, jmbg, username, password, personType, null, active));
            }
            else if (personType.Equals(UserType.Specialist))
            {
                return(new Specialist(personId, name, surname, phone, email, sex, jmbg, username, password, personType, null, active, specialization));
            }
            else
            {
                return(null);
            }
        }
        public IEnumerable <NotificationPreference> GetNotificationPreferencesForUser(UserType userType, int?userId)
        {
            if (userType.Equals(UserType.AdminUser))
            {
                return(notificationPreferencesDataService.GetNotificationPreferencesForAdmin(userId));
            }

            if (userType.Equals(UserType.DelegateUser))
            {
                return(notificationPreferencesDataService.GetNotificationPreferencesForDelegate(userId));
            }

            throw new Exception($"No code path for getting notification preferences for user type {userType}");
        }
 public void SetNotificationPreferencesForUser(UserType userType, int?userId, IEnumerable <int> notificationIds)
 {
     if (userType.Equals(UserType.AdminUser))
     {
         notificationPreferencesDataService.SetNotificationPreferencesForAdmin(userId, notificationIds);
     }
     else if (userType.Equals(UserType.DelegateUser))
     {
         notificationPreferencesDataService.SetNotificationPreferencesForDelegate(userId, notificationIds);
     }
     else
     {
         throw new Exception($"No code path for setting notification preferences for user type {userType}");
     }
 }
        public async Task Can_Create_And_Find_A_Password_Reset_For_User(UserType userType)
        {
            using var transactionScope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled);

            // Given
            var createTime       = new DateTime(2021, 1, 1);
            var testDelegateUser = userType.Equals(UserType.AdminUser)
                ? (User)UserTestHelper.GetDefaultAdminUser()
                : UserTestHelper.GetDefaultDelegateUser();
            var resetPasswordCreateModel = new ResetPasswordCreateModel(
                createTime,
                "ResetPasswordHash",
                testDelegateUser.Id,
                userType
                );

            // When
            service.CreatePasswordReset(resetPasswordCreateModel);
            var matches = await service.FindMatchingResetPasswordEntitiesWithUserDetailsAsync(
                testDelegateUser.EmailAddress !,
                resetPasswordCreateModel.Hash
                );

            // Then
            matches.Count.Should().Be(1);
            var match = matches.Single();

            match.UserId.Should().Be(testDelegateUser.Id);
            match.Email.Should().Be(testDelegateUser.EmailAddress);
            match.UserType.Should().Be(userType);

            match.Id.Should().BeGreaterThan(0);
            match.ResetPasswordHash.Should().Be(resetPasswordCreateModel.Hash);
            match.PasswordResetDateTime.Should().Be(resetPasswordCreateModel.CreateTime);
        }
コード例 #5
0
ファイル: User.cs プロジェクト: LayCraft/pssg-cscp-cpu
        // /// <summary>
        // /// Returns the string presentation of the object
        // /// </summary>
        // /// <returns>String presentation of the object</returns>
        // public override string ToString()
        // {
        //  var sb = new StringBuilder();

        //  sb.Append("class User {\n");
        //  sb.Append("  Id: ").Append(ContactId).Append("\n");
        //  sb.Append("  GivenName: ").Append(GivenName).Append("\n");
        //  sb.Append("  Surname: ").Append(Surname).Append("\n");
        //  sb.Append("  Active: ").Append(Active).Append("\n");
        //  sb.Append("  Initials: ").Append(Initials).Append("\n");
        //  sb.Append("  Email: ").Append(Email).Append("\n");
        //  sb.Append("  SmUserId: ").Append(SmUserId).Append("\n");
        //  sb.Append("  Guid: ").Append(AccountId).Append("\n");
        //  sb.Append("  SmAuthorizationDirectory: ").Append(UserType).Append("\n");
        //  sb.Append("  UserRoles: ").Append(UserRoles).Append("\n");
        //  sb.Append("}\n");

        //  return sb.ToString();
        // }

        // /// <summary>
        // /// Returns the JSON string presentation of the object
        // /// </summary>
        // /// <returns>JSON string presentation of the object</returns>
        // public string ToJson()
        // {
        //  return JsonConvert.SerializeObject(this, Formatting.Indented);
        // }

        // /// <summary>
        // /// Returns true if objects are equal
        // /// </summary>
        // /// <param name="obj">Object to be compared</param>
        // /// <returns>Boolean</returns>
        // public override bool Equals(object obj)
        // {
        //  if (obj is null) { return false; }
        //  if (ReferenceEquals(this, obj)) { return true; }
        //  return obj.GetType() == GetType() && Equals((User)obj);
        // }

        /// <summary>
        /// Returns true if User instances are equal
        /// </summary>
        /// <param name="other">Instance of User to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(User other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return((
                       ContactId == other.ContactId ||
                       ContactId.Equals(other.ContactId)
                       ) &&
                   (
                       GivenName == other.GivenName ||
                       GivenName != null &&
                       GivenName.Equals(other.GivenName)
                   ) &&
                   (
                       Surname == other.Surname ||
                       Surname != null &&
                       Surname.Equals(other.Surname)
                   ) &&
                   (
                       Active == other.Active ||
                       Active.Equals(other.Active)
                   ) &&
                   (
                       Initials == other.Initials ||
                       Initials != null &&
                       Initials.Equals(other.Initials)
                   ) &&
                   (
                       Email == other.Email ||
                       Email != null &&
                       Email.Equals(other.Email)
                   ) &&
                   (
                       SmUserId == other.SmUserId ||
                       SmUserId != null &&
                       SmUserId.Equals(other.SmUserId)
                   ) &&
                   (
                       AccountId == other.AccountId ||
                       AccountId != null &&
                       AccountId.Equals(other.AccountId)
                   ) &&
                   (
                       UserType == other.UserType ||
                       UserType != null &&
                       UserType.Equals(other.UserType)
                   ) &&
                   (
                       UserRoles == other.UserRoles ||
                       UserRoles != null &&
                       UserRoles.SequenceEqual(other.UserRoles)
                   ));
        }
コード例 #6
0
        /// <summary>
        /// Инициализирует новый экземпляр <see cref="RegistrationViewModel" />.
        /// </summary>
        public RegistrationViewModel()
        {
            Register = new RelayCommand(obj =>
            {
                if (string.IsNullOrEmpty(Password) ||
                    string.IsNullOrEmpty(ConfirmPassword) ||
                    string.IsNullOrEmpty(PhoneNumber) ||
                    UserType.Equals("Юридическое") && string.IsNullOrEmpty(Organization) ||
                    UserType.Equals("Физическое") && string.IsNullOrEmpty(Name))
                {
                    Application.Current.MainPage.DisplayAlert("Уведомление", "Пожалуйста, внимательно заполните все поля формы.", "ОK");
                    return;
                }

                var user = new User
                {
                    PhoneNumber = PhoneNumber
                };

                if (UserType.Equals("Юридическое"))
                {
                    user.Organization = Organization;
                    user.UserType     = Models.UserType.Entity;
                }
                else if (UserType.Equals("Физическое"))
                {
                    user.Name     = Name;
                    user.UserType = Models.UserType.Individual;
                }

                OnRegister(user, Password, ConfirmPassword);
            }, obj => !IsBusy && Connectivity.NetworkAccess == NetworkAccess.Internet);
        }
コード例 #7
0
        /// <summary>
        /// Returns true if ModelUser instances are equal
        /// </summary>
        /// <param name="other">Instance of ModelUser to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(User other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Username == other.Username ||
                     Username != null &&
                     Username.Equals(other.Username)
                     ) &&
                 (
                     Password == other.Password ||
                     Password != null &&
                     Password.Equals(other.Password)
                 ) &&
                 (
                     Guid == other.Guid ||
                     Guid != null &&
                     Guid.Equals(other.Guid)
                 ) &&
                 (
                     UserType == other.UserType ||
                     UserType.Equals(other.UserType)
                 ) &&
                 (
                     Name == other.Name ||
                     Name != null &&
                     Name.Equals(other.Name)
                 ) &&
                 (
                     Surname == other.Surname ||
                     Surname != null &&
                     Surname.Equals(other.Surname)
                 ) &&
                 (
                     PhoneNumber == other.PhoneNumber ||
                     PhoneNumber != null &&
                     PhoneNumber.Equals(other.PhoneNumber)
                 ) &&
                 (
                     Email == other.Email ||
                     Email != null &&
                     Email.Equals(other.Email)
                 ) &&
                 (
                     Discount == other.Discount ||
                     Discount != null &&
                     Discount.Equals(other.Discount)
                 ));
        }
コード例 #8
0
        public static string FromUserType(UserType userType)
        {
            foreach (var userTypeValues in Values)
            {
                if (userType.Equals(userTypeValues.UserType))
                {
                    return(userTypeValues.Name);
                }
            }

            throw new ArgumentOutOfRangeException($"No user type found with user type '{userType}'");
        }
コード例 #9
0
        public bool IsPatientAlreadyExist(string jmbg)
        {
            List <uint> peoples_ids = PeopleRepository.GetInstance().GetIdsByJMBG(jmbg);

            foreach (uint id in peoples_ids)
            {
                UserType tipKorisnika = PeopleRepository.GetInstance().GetRole(id);
                if (tipKorisnika.Equals(UserType.Patient))
                {
                    return(true);
                }
            }
            return(false);
        }
コード例 #10
0
    private IEnumerator GetFriendsFacebookUserInfo(List <object> responseDataObjects, UserType userType)
    {
        int numFriends = responseDataObjects.Count;

        foreach (object friendDataObject in responseDataObjects)
        {
            Dictionary <string, object> friendDataObjectDict = friendDataObject as Dictionary <string, object>;
            if (userType.Equals(UserType.Friend))
            {
                var request = string.Format("/{0}{1}", friendDataObjectDict["id"], "?fields=id,name,picture.width(64).height(64)");
                yield return(StartCoroutine(GetFacebookUserInfo(graphURL: request, userType: userType)));
            }
            if (userType.Equals(UserType.Invitable))
            {
                yield return(StartCoroutine(GetFacebookUserInfo(data: friendDataObject, userType: userType)));
            }

            if (FriendUserFacebookInfos.Count == numFriends)
            {
                if (OnFriendsInfoDownloadedEvent != null)
                {
                    OnFriendsInfoDownloadedEvent.Invoke();
                }

                GetFriendRequests();
            }

            if (InventableFriendsList.Count == numFriends)
            {
                if (OnInvintableFriendsInfoDownloadedEvent != null)
                {
                    OnInvintableFriendsInfoDownloadedEvent.Invoke();
                }
            }
        }
    }
コード例 #11
0
 public bool IsStaff()
 {
     return(UserType.Equals(UserType.Doctor) || UserType.Equals(UserType.Manager) || UserType.Equals(UserType.Secretary) || UserType.Equals(UserType.Specialist));
 }
コード例 #12
0
ファイル: IdentityProviderTest.cs プロジェクト: TobiasEh/Uni
        public void getUserPriorityTest()
        {
            UserType type = IdentityProvider.getUserPriority(email);

            Assert.IsTrue(type.Equals(UserType.PLANER));
        }
コード例 #13
0
		/**
		 * Determines if the user has the necessary permission
		 * Admin->Operator->Coremember->Member->Fan
		 */
		public bool isAtLeast(UserType ut, UserType necessaryUT) {
			switch(necessaryUT) {
			case UserType.Admin:
				if(ut.Equals(UserType.Admin))
					return true;
				return false;
			case UserType.Operator:
				if(ut.Equals(UserType.Admin) || ut.Equals(UserType.Operator))
					return true;
				return false;
			case UserType.Coremember:
				if(ut.Equals(UserType.Admin) || ut.Equals(UserType.Operator) || ut.Equals(UserType.Coremember))
					return true;
				return false;
			case UserType.Member:
				if(ut.Equals(UserType.Admin) || ut.Equals(UserType.Operator) || ut.Equals(UserType.Coremember) || ut.Equals(UserType.Member))
					return true;
				return false;
			case UserType.Fan:
				if(ut.Equals(UserType.Admin) || ut.Equals(UserType.Operator) || ut.Equals(UserType.Coremember) || ut.Equals(UserType.Member) || ut.Equals(UserType.Fan))
					return true;
				return false;
			default :
				return false;
			}
		}
コード例 #14
0
 private int EnumToint(UserType type)
 {
     if (type.Equals(UserType.Guest))
     {
         return 1;
     }
     else if (type.Equals(UserType.User))
     {
         return 2;
     }
     else if (type.Equals(UserType.Administrator))
     {
         return 3;
     }
     return 0;
 }
コード例 #15
0
 private bool Equals(UserReference?other)
 {
     return(other != null && Id == other.Id && UserType.Equals(other.UserType));
 }
コード例 #16
0
    private void DisplayControls()
    {
        this.tbxreason.InnerText    = string.Empty;
        SwipePanel.Visible          = true;
        btndisplay.Visible          = false;
        this.btnDelete.Visible      = false;
        this.tblswipedetail.Visible = true;
        popupClickOk.Visible        = false;
        this.chkRemove.Visible      = false;
        this.btnOk.Visible          = true;

        //Check the action
        if (Action.Equals("CheckIn", StringComparison.InvariantCultureIgnoreCase))
        {
            //check usertype

            if (UserType.Equals("Self", StringComparison.InvariantCultureIgnoreCase))
            {
                this.txtSwipeTime.Visible       = false;
                this.LblSwipeTime.Visible       = false;
                this.ddlTimeZoneList.Visible    = true;
                this.ddlTimeZoneList.Disabled   = false;
                this.ddlShift.Enabled           = true;
                this.ddWFH.Enabled              = true;
                this.ddlShift.SelectedItem.Text = "--Select--";
                this.LabTimeZone.Visible        = false;

                reasonGridView.Visible = false;
                if (WarningMessage != "")
                {
                    DisplayWarningMsg(WarningMessage);
                }
            }
            else
            {
                if (UserType != "Self" && UserSwipe.Id != 0)
                {
                    if (this.UserSwipe.CheckInTime.HasValue)
                    {
                        this.ddlTimeSpan.SelectedValue = UserSwipe.CheckInTime.Value.ToString("tt");
                        this.txtSwipeTime.Text         = UserSwipe.CheckInTime.Value.ToString("hh:mm");
                        this.txtSwipeDate.Text         = UserSwipe.CheckInTime.Value.ToString("MM/dd/yyyy");
                    }

                    this.ddlTimeZoneList.Visible  = true;
                    this.LabTimeZone.Visible      = false;
                    this.ddlTimeZoneList.Disabled = false;
                    ddlTimeZoneList.Items.FindByValue(UserSwipe.TimeZoneId.ToString()).Selected = true;
                    ddlShift.SelectedValue = UserSwipe.Shift.ToString();
                    ddWFH.SelectedValue    = UserSwipe.UserworktypeId.ToString();
                    // ddlShift.Items.FindByValue(UserSwipe.Shift.ToString()).Selected = true;
                    this.txtSwipeTime.Visible = true;
                    this.LblSwipeTime.Visible = true;
                    reasonGridView.Visible    = true;
                    this.ddlShift.Enabled     = true;
                    this.ddWFH.Enabled        = true;
                    this.chkRemove.Visible    = true;
                    this.chkRemove.Checked    = false;
                    this.btnOk.Visible        = true;
                }

                else
                {
                    this.ddlTimeZoneList.Visible  = true;
                    this.ddlTimeZoneList.Disabled = false;
                    this.LabTimeZone.Visible      = false;
                    this.txtSwipeTime.Visible     = true;
                    this.LblSwipeTime.Visible     = true;
                    reasonGridView.Visible        = true;
                    if (ddlTimeZoneList.Items.Count > 0)
                    {
                        ddlTimeZoneList.Items.FindByValue("0").Selected = true;
                    }
                    this.ddlShift.Enabled           = true;
                    this.ddWFH.Enabled              = true;
                    this.ddlShift.SelectedItem.Text = "--Select--";
                }
            }
        }
        else if (Action.Equals("CheckOut", StringComparison.InvariantCultureIgnoreCase) && UserSwipe.Id != 0)
        {
            this.ddlTimeZoneList.Visible = false;
            this.LabTimeZone.Visible     = true;
            this.LblSwipeTime.Visible    = false;
            this.txtSwipeTime.Visible    = false;
            this.ddlShift.Enabled        = false;
            this.ddWFH.Enabled           = false;
            this.LabTimeZone.InnerText   = mTimeZones.Where(x => x.Id == UserSwipe.TimeZoneId).FirstOrDefault().Name.ToString();
            this.ddlShift.SelectedValue  = UserSwipe.Shift.ToString();
            this.ddWFH.SelectedValue     = UserSwipe.UserworktypeId.ToString();

            //  this.ddlShift.Items.FindByValue(UserSwipe.Shift.ToString()).Selected=true;
            if (UserType != "Self")
            {
                this.ddlTimeSpan.Visible = true;

                if (UserSwipe.CheckOutTime.HasValue)
                {
                    this.txtSwipeTime.Text         = UserSwipe.CheckOutTime.Value.ToString("hh:mm");
                    this.ddlTimeSpan.SelectedValue = UserSwipe.CheckOutTime.Value.ToString("tt");
                    this.txtSwipeDate.Text         = UserSwipe.CheckOutTime.Value.ToString("MM/dd/yyyy");
                }
                else if (UserSwipe.CheckInTime.HasValue)
                {
                    this.txtSwipeDate.Text = UserSwipe.CheckInTime.Value.ToString("MM/dd/yyyy");
                }
                else
                {
                    this.txtSwipeTime.Text = currentDateTime.ToString("hh:mm");
                }

                this.LblSwipeTime.Visible = true;
                this.txtSwipeTime.Visible = true;
                this.chkRemove.Visible    = true;
                this.chkRemove.Checked    = false;
                this.btnOk.Visible        = true;
            }
            else
            {
                reasonGridView.Visible    = false;
                this.txtSwipeTime.Visible = false;
                this.LblSwipeTime.Visible = false;
            }
        }
        else
        {
            //this.ddlTimeZoneList.Visible = true;
            //this.ddlTimeZoneList.Disabled = true;
            //this.LabTimeZone.Visible = false;
            //this.ddlShift.Enabled = false;
            //this.lblreason.Style.Add("display", "none");
            //this.tbxreason.Visible = false;
            //this.txtSwipeTime.Visible = false;
            //this.LblSwipeTime.Visible = false;
            SwipePanel.Visible   = false;
            popupClickOk.Visible = true;


            MessagePanel.InnerHtml = lblCheckinFirst;
        }
    }
コード例 #17
0
    private void CheckOut()
    {
        IUserSwipeService service = null;

        try
        {
            DateTime checkoutTime;
            string   checkoutDateTime;

            this.ValidateCheckOutTime();
            // Assign values.

            if (UserType.Equals("Self", StringComparison.InvariantCultureIgnoreCase))
            {
                checkoutDateTime = string.Format("{0} {1}",
                                                 spnSwipeDate.InnerText.ToString(),
                                                 txtSwipeTime.Text);
                checkoutTime = DateTime.Parse(checkoutDateTime);
            }
            else
            {
                //checkout time


                checkoutDateTime = string.Format("{0} {1} {2}",
                                                 txtSwipeDate.Text.ToString(),
                                                 txtSwipeTime.Text,
                                                 ddlTimeSpan.SelectedValue);
                checkoutTime = DateTime.Parse(checkoutDateTime);
            }

            //Validate in CheckOutTime
            this.ValidateCheckOutTime(checkoutTime, this.UserSwipe);
            this.UserSwipe.CheckOutTime = checkoutTime;
            //this.UserSwipe.TimeZoneId = Int32.Parse(ddlTimeZoneList.Items[ddlTimeZoneList.SelectedIndex].Value);
            this.UserSwipe.CreateUserId     = this.AppManager.LoginUser.Id;
            this.UserSwipe.LastUpdateUserId = this.AppManager.LoginUser.Id;
            this.UserSwipe.Shift            = Int32.Parse(this.ddlShift.SelectedItem.Value);
            this.UserSwipe.Reason           = this.tbxreason.InnerText;
            if (!this.UserSwipe.CustomData.ContainsKey("EditBy"))
            {
                this.UserSwipe.CustomData.Add("EditBy", UserType);
            }

            // Create the service and invoke method.
            service            = AppService.Create <IUserSwipeService>();
            service.AppManager = this.AppManager;

            // Invoke method.
            service.CheckIn(this.UserSwipe);


            //Close the Dialog.
            this.CloseDialogControl();
        }
        catch (ValidationException ve)
        {
            throw ve;
        }
        catch { throw; }
        finally
        {
            if (service != null)
            {
                service.Dispose();
            }
        }
    }
コード例 #18
0
    private IEnumerator GetFacebookUserInfo(string graphURL = null, object data = null, UserType userType = UserType.Current)
    {
        bool finishedGettingInfo = false;

        FacebookUserInfo userInfo = new FacebookUserInfo();

        if (!string.IsNullOrEmpty(graphURL))
        {
            FB.API(graphURL, HttpMethod.GET, userInfoResult => {
                if (userInfoResult.Error != null)
                {
                    Debug.LogError("Error getting FB user info: " + userInfoResult.Error);
                }
                else
                {
                    Dictionary <string, object> userInfoObjects = Facebook.MiniJSON.Json.Deserialize(userInfoResult.RawResult) as Dictionary <string, object>;
                    userInfo.id         = userInfoObjects["id"].ToString();
                    var userFullName    = userInfoObjects["name"].ToString();
                    var s               = userFullName.Split(new char[] { ' ' });
                    userInfo.firstName  = s[0];
                    userInfo.lastName   = s[1];
                    var pictureData     = userInfoObjects["picture"] as Dictionary <string, object>;
                    var p               = pictureData["data"] as Dictionary <string, object>;
                    userInfo.pictureUrl = p["url"].ToString();
                }
                finishedGettingInfo = true;
            });
        }

        if (data != null)
        {
            var dictionaryDataObject = data as Dictionary <string, object>;
            userInfo.id = dictionaryDataObject["id"].ToString();
            var userFullName = dictionaryDataObject["name"].ToString();
            var s            = userFullName.Split(new char[] { ' ' });
            userInfo.firstName = s[0];
            userInfo.lastName  = s[1];

            var pictureData = dictionaryDataObject["picture"] as Dictionary <string, object>;
            var p           = pictureData["data"] as Dictionary <string, object>;
            userInfo.pictureUrl = p["url"].ToString();

            finishedGettingInfo = true;
        }

        while (!finishedGettingInfo)
        {
            yield return(null);
        }

        if (userInfo.pictureUrl != null)
        {
            yield return(StartCoroutine(CheckAndLoadImage(userInfo.id, userInfo.pictureUrl, !userType.Equals(UserType.Invitable), (texture) =>
            {
                userInfo.ProfilePicture = Sprite.Create(texture, new Rect(0, 0, 64, 64), new Vector2(0.5f, 0.5f));
            })));
        }

        if (userType.Equals(UserType.Current))
        {
            CurrentUserFacebookUserInfo = userInfo;
            if (OnUserInfoDownloadedEvent != null)
            {
                OnUserInfoDownloadedEvent.Invoke();
            }

            UpdateFriendsList();
            UpdateInventableFriendsList();
        }
        else if (userType.Equals(UserType.Friend))
        {
            FriendUserFacebookInfos.Add(userInfo);
        }
        else
        {
            InventableFriendsList.Add(userInfo);
        }
    }
コード例 #19
0
        public override void Display()
        {
            base.Display();

            /*
             * Reset the Session (when the User go back in the pages)
             */
            SessionManager.Reset();

            /*
             * Choose the type of Registration (User - Admin)
             */
            UserType input = Input.ReadEnum <UserType>("Select the type of user you want to register: ");

            if (input.Equals(UserType.Back))
            {
                Program.NavigateHome();
            }
            SessionManager.SetAdmin(input);
            Output.WriteLine(ConsoleColor.Green, "\n{0} Sign In: ", input);

            /*
             * Registration Form
             *
             * Every input must be valid and checked. The password is hashed with
             * a MD5 algorithm before to be stored in the database, for a security reason.
             */
            Output.WriteLine("--------- REGISTRATION ----------");
            string username = Input.ReadString("Username (max 30 characters): ");

            // Navigate back if User type "\\" on first input
            if (username.Contains("\\"))
            {
                Program.NavigateBack();
            }
            username = Controls.CheckUserInput("Username", username);
            string password       = Input.ReadString("Password (max 32 characters): ");
            string hashedPassword = EasyEncryption.MD5.ComputeMD5Hash(Controls.CheckUserInput("Password", password));
            string name           = Input.ReadString("Name (max 20 characters): ");

            name = Controls.CheckUserInput("Nome", name);
            string surname = Input.ReadString("Surname (max 20 characters): ");

            surname = Controls.CheckUserInput("Cognome", surname);

            /*
             * Send data to Database
             */
            try
            {
                if (SessionManager.GetServiceClient().Registration(SessionManager.IsAdmin(), username, hashedPassword, name, surname))
                {
                    Output.WriteLine("REGISTRATION SUCCESS!\n Come back to login\n");
                }
                else
                {
                    Output.WriteLine("REGISTRATION ERROR\n Retry!\n");
                }
            }
            catch {
                Console.WriteLine("Error! Retry later!");
            }

            /*
             * Navigate back
             */
            Input.ReadString("Press [Enter] to navigate home");
            Program.NavigateHome();
        }
コード例 #20
0
        public override void Display()
        {
            base.Display();

            /*
             * Reset the Session (when the User go back in the pages)
             */
            SessionManager.Reset();

            /*
             * Choose the type of Login (User - Admin)
             */
            UserType input = Input.ReadEnum <UserType>("Select the type of user you want to login: "******"\n{0} Login: "******"--------- LOGIN ----------");
            string username = Input.ReadString("Username: "******"\\" on first input
            if (username.Contains("\\"))
            {
                Program.NavigateBack();
            }
            username = Controls.CheckUserInput("Username", username);
            Console.Write("Password: "******"Password", password));

            /*
             * Send data to Database
             */
            try
            {
                if (SessionManager.GetServiceClient().Login(SessionManager.IsAdmin(), username, hashedPassword))
                {
                    SessionManager.SetUser(SessionManager.GetServiceClient().GetUser(SessionManager.IsAdmin(), username));
                    SessionManager.SetSubscription(SessionManager.GetServiceClient().GetSubscription(SessionManager.GetUser().Username));
                }
            } catch {
                Console.WriteLine("Error! Retry later!");
            }


            /*
             * Go to the Menu
             */
            if (SessionManager.GetUser() != null)                           // Check Login
            {
                Output.WriteLine("\nLogin Successful");
                Input.ReadString("Press [Enter] to navigate to your menu");
                switch (SessionManager.IsAdmin())                           // Check User Type
                {
                case true:
                    Program.NavigateTo <AdminPage>();
                    break;

                case false:
                    Program.NavigateTo <UserPage>();
                    break;
                }
            }
            Output.WriteLine("\nLogin Failed\n");

            /*
             * Navigate back
             */
            Input.ReadString("Press [Enter] to navigate back");
            Program.NavigateHome();
        }