コード例 #1
0
        public static User RestToUser(RestUser restUser)
        {
            Dictionary <int, byte[]> fingerprints = new Dictionary <int, byte[]>();

            foreach (RestFingerPrint fp in restUser.FingerPrints)
            {
                byte[] print = null;
                if (fp.Print != null)
                {
                    print = fp.Print.ToArray();
                }
                fingerprints.Add(fp.PrintNumber, print);
            }

            byte[] password = null;
            if (restUser.Password != null)
            {
                password = restUser.Password.ToArray();
            }

            if (restUser.IsDefaultAdmin)
            {
                return(new DefaultAdminUser(password,
                                            restUser.PasswordChanged,
                                            restUser.NewPassword));
            }
            else
            {
                return(new User(restUser.UserID,
                                restUser.Description,
                                restUser.FullName,
                                password,
                                restUser.SecurityLevel,
                                fingerprints,
                                restUser.PasswordChanged,
                                restUser.NewPassword));
            }
        }
コード例 #2
0
        public static User RestToUser(RestUser restUser)
        {
            Dictionary<int, byte[]> fingerprints = new Dictionary<int, byte[]>();
            foreach (RestFingerPrint fp in restUser.FingerPrints)
            {
                byte[] print = null;
                if (fp.Print != null)
                {
                    print = fp.Print.ToArray();
                }
                fingerprints.Add(fp.PrintNumber, print);
            }

            byte[] password = null;
            if (restUser.Password != null)
            {
                password = restUser.Password.ToArray();
            }

            if (restUser.IsDefaultAdmin)
            {
                return new DefaultAdminUser(password,
                                            restUser.PasswordChanged,
                                            restUser.NewPassword);
            }
            else
            {
                return new User(restUser.UserID,
                                 restUser.Description,
                                 restUser.FullName,
                                 password,
                                 restUser.SecurityLevel,
                                 fingerprints,
                                 restUser.PasswordChanged,
                                 restUser.NewPassword);
            }
        }
コード例 #3
0
        public static RestUser UserToRest(User usr, bool usePassword)
        {
            if (usr == null) return null;
            RestUser restUser = new RestUser()
            {
                UserID = usr.ID,
                Description = usr.Description,
                FullName = usr.FullName,
                SecurityLevel = usr.SecurityLevel
            };

            if (usePassword)
            {
                if (usr.Password != null)
                {
                    restUser.Password = usr.Password.ToList();
                }
                restUser.PasswordChanged = usr.PasswordChanged;
                restUser.NewPassword = usr.NewPassword;
            }

            if (usr is DefaultAdminUser)
            {
                restUser.IsDefaultAdmin = true;
            }

            foreach (FingerPrint fp in usr.FingerPrints)
            {
                List<byte> print = null;
                if (fp.Print != null)
                {
                    print = fp.Print.ToList();
                }
                restUser.FingerPrints.Add(new RestFingerPrint() { PrintNumber = fp.PrintNumber, Print = print });
            }
            return restUser;
        }