12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- using Prism.Mvvm;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace LampInspectionMachine.Model
- {
- public class Users : BindableBase
- {
- public Users()
- {
- }
- private int id;
- private Roles role= Roles.操作员;
- private string password;
- public int Id { get => id; set { SetProperty(ref id, value); } }
- public Roles Role { get => role; set { SetProperty(ref role, value); } }
- public string Password { get => password; set { SetProperty(ref password, value); } }
- public string CheckPwd(string pwd)
- {
- bool flag = false;
- StringBuilder pwdstr1 = new StringBuilder();
- StringBuilder pwdstr2 = new StringBuilder();
- for ( int i = 0; i < pwd.Length; i++ )
- {
- if ( flag )
- {
- pwdstr1.Append(pwd[ i ]);
- flag = false;
- }
- else
- {
- pwdstr2.Append(pwd[ i ]);
- flag = true;
- }
- }
- return pwdstr1.ToString() + pwdstr2.ToString();
- }
- public bool CheckUserLogin(Users user, AppData appData)
- {
- Users users = new Users()
- {
- Id=0,
- Role= user.Role,
- Password=this.CheckPwd(user.Password),
- };
- appData.CurrentUser = appData.DefaultUsers.Find(t => t.Role == users.Role && t.Password == users.Password);
- if ( appData.CurrentUser != null )
- {
- return true;
- }
- return false;
- }
- }
- public enum Roles
- {
- 操作员,
- 工程师,
- 管理员
- }
- }
|