示例#1
0
        private void BtLogin_Click(object sender, RoutedEventArgs e)
        {
            if (tbLoginName.Text == "")
            {
                MessageBox.Show("Login Name must not be empty.", "EasyAppointment", MessageBoxButton.OK, MessageBoxImage.Stop);
                return;
            }
            if (tbLoginPwd.Password == "")
            {
                MessageBox.Show("Login password must not be empty.", "EasyAppointment", MessageBoxButton.OK, MessageBoxImage.Stop);
                return;
            }
            try
            {
                EnumUserType eu = Globals.Db.GetLoginUserInfo(tbLoginName.Text, tbLoginPwd.Password);
                if (eu == EnumUserType.Admin)
                {
                    (new AdminMainWindow()).Show();


                    Close();
                }

                else if (eu == EnumUserType.Doctor)
                {
                    (new DoctorMainWindow()).Show();
                    Close();
                }
            }
            catch (SqlException ex)
            {
                MessageBox.Show("Error in fetch login user info.", "EasyAppointment", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
 public User(string name, string login, string password, EnumUserType userType, int userCreationId)
 {
     Name           = name;
     Login          = login;
     Password       = password;
     UserCreationId = userCreationId;
     TypeId         = userType;
 }
示例#3
0
        public HttpResponseMessage SearchBrokers(EnumUserType userType, EnumBrokerSearchOrderBy orderByAll = EnumBrokerSearchOrderBy.OrderById, bool isDes = true, string phone = null, string name = null, int page = 1, int pageSize = 10, int state = 2)
        {
            //var phones = new int[1];

            var brokerSearchCondition = new BrokerSearchCondition
            {
                Brokername   = name,
                Phone1       = phone,
                Page         = Convert.ToInt32(page),
                PageCount    = 10,
                UserType     = userType,
                State        = state,
                OrderBy      = orderByAll,
                isDescending = isDes
            };

            var brokersList = _brokerService.GetBrokersByCondition(brokerSearchCondition).Select(p => new
            {
                p.Id,
                p.Nickname,
                p.Brokername,
                p.Realname,
                p.Phone,
                p.Sfz,
                p.Amount,
                p.Agentlevel,
                p.Regtime,
                p.Headphoto,
                p.State,
                p.Usertype,
                btnVisibleDel = true,
                btnVisibleCan = true,
                btnname       = "注销",
                btncolor      = "",
                backcolor     = ""
            }).ToList().Select(b => new
            {
                b.Id,
                b.Nickname,
                b.Brokername,
                b.Realname,
                b.Phone,
                b.Sfz,
                b.Amount,
                b.Agentlevel,
                Regtime = b.Regtime.ToString("yyyy-MM-dd"),
                b.Headphoto,
                b.State,
                b.Usertype,
                btnVisibleDel = true,
                btnVisibleCan = true
            });
            var brokerListCount = _brokerService.GetBrokerCount(brokerSearchCondition);

            return(PageHelper.toJson(new { List = brokersList, Condition = brokerSearchCondition, totalCount = brokerListCount }));
        }
示例#4
0
        /// <summary>
        /// 帐号唯一性检查,包含用户类型维度
        /// </summary>
        /// <param name="userAccount"></param>
        /// <returns></returns>
        public bool ExistsMobile(string Mobile, EnumUserType userType)
        {
            bool result = false;

            using (DBEntities db = new DBEntities())
            {
                result = db.Users.Where(o => (o.Mobile == Mobile) && o.UserType == userType && o.IsDeleted == false).Count() > 0;
            }
            return(result);
        }
示例#5
0
        /// <summary>
        /// 帐号唯一性检查
        /// </summary>
        /// <param name="userAccount"></param>
        /// <returns></returns>
        public bool ExistMobileExcludeMySelf(string Mobile, string userId, EnumUserType userType = EnumUserType.Doctor)
        {
            bool result = false;

            using (DBEntities db = new DBEntities())
            {
                result = db.Users.Where(o => o.Mobile == Mobile && o.UserID != userId && o.UserType == userType && o.IsDeleted == false).Count() > 0;
            }
            return(result);
        }
示例#6
0
 /// <summary>
 /// ComboBox赋值
 /// </summary>
 /// <param name="userType"></param>
 private void ComboBox_UserType_Set(EnumUserType userType)
 {
     foreach (ListItem item in comboBox_UserType.Items)
     {
         if (Convert.ToInt32(item.Value) == userType.GetHashCode())
         {
             comboBox_UserType.SelectedItem = item;
             return;
         }
     }
 }
示例#7
0
        public string GetKMSDUserID(EnumUserType UserType, string OrgID, string Mobile, string OuterID)
        {
            if (string.IsNullOrWhiteSpace(Mobile) && string.IsNullOrWhiteSpace(OuterID))
            {
                throw new Exception("Mobile,OuterID至少需指定一个");
            }
            if (!string.IsNullOrWhiteSpace(OuterID) && string.IsNullOrWhiteSpace(OrgID))
            {
                throw new Exception("OrgID不能为空");
            }
            string UserID = "";

            StringCacheKey GetUserIDByCreateUserID_CacheKey = null;

            if (!string.IsNullOrEmpty(OuterID))
            {
                GetUserIDByCreateUserID_CacheKey = new StringCacheKey(
                    StringCacheKeyType.MAP_GetUserIDByCreateUserIDAndOrgID, $"{OrgID}&{OuterID}");
            }
            else
            {
                GetUserIDByCreateUserID_CacheKey = new StringCacheKey(
                    StringCacheKeyType.MAP_GetUserIDByCreateUserIDAndOrgID, $"{Mobile}");
            }

            UserID = GetUserIDByCreateUserID_CacheKey.FromCache <string>();
            if (string.IsNullOrEmpty(UserID))
            {
                using (DBEntities db = new DBEntities())
                {
                    var q = from m in db.Users
                            where m.UserType == UserType && m.IsDeleted == false
                            select new { m.UserID, m.Mobile, m.OrgCode, m.CreateUserID };

                    if (!string.IsNullOrWhiteSpace(OuterID))// OuterID + OrgCode确定一个用户
                    {
                        q = q.Where(w => w.CreateUserID == OuterID);
                        if (!string.IsNullOrWhiteSpace(OrgID))
                        {
                            q = q.Where(w => w.OrgCode == OrgID);
                        }
                    }
                    else if (!string.IsNullOrWhiteSpace(Mobile))//手机号确定一个帐号
                    {
                        q = q.Where(w => w.Mobile == Mobile && string.IsNullOrEmpty(w.CreateUserID));
                    }

                    var u = q.FirstOrDefault();
                    UserID = u?.UserID;
                    UserID.ToCache(GetUserIDByCreateUserID_CacheKey, TimeSpan.FromMinutes(_GetUserInfoExpireMinutes()));
                }
            }
            return(UserID);
        }
示例#8
0
        /// <summary>
        /// 根据手机号码查询用户编号
        /// </summary>
        /// <param name="UserID"></param>
        /// <returns></returns>
        public string GetUserIDByMobile(string Mobile, EnumUserType userType)
        {
            var GetUserIDByMobile_CacheKey = new XuHos.Common.Cache.Keys.StringCacheKey(XuHos.Common.Cache.Keys.StringCacheKeyType.MAP_GetUserIDByMobile, $"{Mobile}:{userType}");

            var UserID = GetUserIDByMobile_CacheKey.FromCache <string>();

            //缓存没有命中,则查询数据库获取医生编号并设置缓存(缓存不过期)
            if (string.IsNullOrEmpty(UserID))
            {
                using (var db = new DBEntities())
                {
                    //TODO:这里需要优惠如果不是手机号码类型不需要这样查询
                    string currentUserID = "";

                    if (userType == EnumUserType.User)
                    {
                        currentUserID = db.Users.Where(p => p.IsDeleted == false && (p.Mobile == Mobile) &&
                                                       (p.UserType == EnumUserType.User || p.UserType == EnumUserType.Drugstore)).Select(t => t.UserID).FirstOrDefault();

                        //避免使用Or条件而采用次查询
                        if (string.IsNullOrEmpty(currentUserID))
                        {
                            currentUserID = db.Users.Where(p => p.IsDeleted == false && (p.UserAccount == Mobile) &&
                                                           (p.UserType == EnumUserType.User || p.UserType == EnumUserType.Drugstore)).Select(t => t.UserID).FirstOrDefault();
                        }
                    }
                    else
                    {
                        currentUserID = db.Users.Where(p => p.IsDeleted == false && (p.Mobile == Mobile) && p.UserType == userType).Select(t => t.UserID).FirstOrDefault();

                        //避免使用Or条件而采用次查询
                        if (string.IsNullOrEmpty(currentUserID))
                        {
                            currentUserID = db.Users.Where(p => p.IsDeleted == false && (p.UserAccount == Mobile) && p.UserType == userType).Select(t => t.UserID).FirstOrDefault();
                        }
                    }

                    if (!string.IsNullOrEmpty(currentUserID))
                    {
                        UserID = currentUserID;
                    }
                    else
                    {
                        //避免缓存穿透问题,有新用户注册时需要更新此缓存
                        UserID = "";
                    }

                    UserID.ToCache(GetUserIDByMobile_CacheKey, TimeSpan.FromMinutes(_GetUserInfoExpireMinutes()));
                }
            }

            return(UserID);
        }
示例#9
0
        /// <summary>
        /// 检查是否已经登录
        /// </summary>
        /// <returns></returns>
        public static bool IsLogin(EnumUserType userType = EnumUserType.Default)
        {
            var user = LoginUser;

            if (user != null &&
                user.UserID != "" &&
                (user.UserType == userType || userType == EnumUserType.Default))     //没有设置用户角色,则通过
            {
                return(true);
            }
            return(false);
        }
示例#10
0
        public void SetAppHeartBeat(string UserID, bool flag = true, EnumUserType userType = EnumUserType.User)
        {
            var cacheKey_HeartbeatApp = new XuHos.Common.Cache.Keys.StringCacheKey(XuHos.Common.Cache.Keys.StringCacheKeyType.Heartbeat_App, $"{UserID}");

            if (flag)
            {
                //加入到在线用户set
                Manager.Instance.SetAdd(new XuHos.Common.Cache.Keys.StringCacheKey(StringCacheKeyType.Heartbeat_App, $"OnlineSet:{userType:G}").KeyName, UserID);
                Manager.UseDb(getDbNum(userOnLineStateDbNum)).StringSet(cacheKey_HeartbeatApp.KeyName, DateTime.Now);
            }
            else
            {
                Manager.Instance.SetRemove(new XuHos.Common.Cache.Keys.StringCacheKey(StringCacheKeyType.Heartbeat_App, $"OnlineSet:{userType:G}").KeyName, UserID);
                Manager.UseDb(getDbNum(userOnLineStateDbNum)).RemoveCache(cacheKey_HeartbeatApp.KeyName);
            }
        }
示例#11
0
 public ApiResult IsLogin(EnumUserType userType = EnumUserType.Default)
 {
     if (XuHos.Service.Infrastructure.SecurityHelper.IsLogin(userType))
     {
         return(new ApiResult()
         {
             Data = true, Status = 0, Msg = "操作成功"
         });
     }
     else
     {
         return(new ApiResult()
         {
             Data = false, Status = 0, Msg = "操作成功"
         });
     }
 }
示例#12
0
        /// <summary>
        /// 获取用户类型
        /// </summary>
        /// <param name="typeID"></param>
        /// <returns></returns>
        private EnumUserType GetUserType(int typeID)
        {
            EnumUserType userType = EnumUserType.Formal;

            switch (typeID)
            {
            case 0: userType = EnumUserType.TrialPeriod; break;

            case 1: userType = EnumUserType.Temporary; break;

            case 2: userType = EnumUserType.Formal; break;

            case 3: userType = EnumUserType.HasLeft; break;

            case 4: userType = EnumUserType.Disable; break;
            }

            return(userType);
        }
示例#13
0
        /// <summary>
        /// 获取用户类型
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static EnumUserType GetUserType(int value)
        {
            EnumUserType userType = EnumUserType.TrialPeriod;

            switch (value)
            {
            case 0: userType = EnumUserType.TrialPeriod; break;

            case 1: userType = EnumUserType.Temporary; break;

            case 2: userType = EnumUserType.Formal; break;

            case 3: userType = EnumUserType.HasLeft; break;

            case 4: userType = EnumUserType.Disable; break;
            }

            return(userType);
        }
示例#14
0
        public void SetWebHeartBeat(string UserID, string type, bool flag = true, EnumUserType userType = EnumUserType.User)
        {
            var cacheKey_HeartbeatWeb      = new XuHos.Common.Cache.Keys.StringCacheKey(XuHos.Common.Cache.Keys.StringCacheKeyType.Heartbeat_Web, $"{UserID}");
            var cacheKey_HeartbeatWeb_Type = new XuHos.Common.Cache.Keys.StringCacheKey(XuHos.Common.Cache.Keys.StringCacheKeyType.Heartbeat_Web, $"{UserID}:{type}");

            if (flag)
            {
                //加入到在线用户set
                Manager.Instance.SetAdd(new XuHos.Common.Cache.Keys.StringCacheKey(StringCacheKeyType.Heartbeat_Web, $"OnlineSet:{userType:G}").KeyName, UserID);
                Manager.UseDb(getDbNum(userOnLineStateDbNum)).StringSet(cacheKey_HeartbeatWeb.KeyName, DateTime.Now, TimeSpan.FromSeconds(15));
                Manager.UseDb(getDbNum(userTypeStateDbNum)).StringSet(cacheKey_HeartbeatWeb_Type.KeyName, DateTime.Now, TimeSpan.FromSeconds(15));
            }
            else
            {
                Manager.Instance.SetRemove(new XuHos.Common.Cache.Keys.StringCacheKey(StringCacheKeyType.Heartbeat_Web, $"OnlineSet:{userType:G}").KeyName, UserID);
                Manager.UseDb(getDbNum(userOnLineStateDbNum)).RemoveCache(cacheKey_HeartbeatWeb.KeyName);
                Manager.UseDb(getDbNum(userTypeStateDbNum)).RemoveCache(cacheKey_HeartbeatWeb_Type.KeyName);
            }
        }
示例#15
0
        /// <summary>
        /// RSA 加密,解密,签名和验签
        /// </summary>
        public static void RSASignFunc(string privateKey, string publicKey, EnumUserType enumUserType)
        {
            Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
            switch (enumUserType)
            {
            case EnumUserType.xml:
                RsaXmlUtil rsaXmlUtil   = new RsaXmlUtil(Encoding.UTF8, publicKey, privateKey);
                var        encrypt      = rsaXmlUtil.Encrypt("123456789", RSAEncryptionPadding.Pkcs1);
                var        encryptInput = rsaXmlUtil.Decrypt(encrypt, RSAEncryptionPadding.Pkcs1);
                Console.Write("XML加解密是否成功:");
                Console.WriteLine(encryptInput is "123456789");
                var sign       = rsaXmlUtil.SignData("987654321", HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1);
                var verifyData = rsaXmlUtil.VerifyData("987654321", sign, HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1);
                Console.Write("XML签名是否成功");
                Console.WriteLine(verifyData);
                break;

            case EnumUserType.pkcs1:
                RsaPkcs1Util rsaPkcs1Util  = new RsaPkcs1Util(Encoding.UTF8, publicKey, privateKey);
                var          encrypt2      = rsaPkcs1Util.Encrypt("123456789", RSAEncryptionPadding.Pkcs1);
                var          encryptInput2 = rsaPkcs1Util.Decrypt(encrypt2, RSAEncryptionPadding.Pkcs1);
                Console.Write("PKCS1加解密是否成功:");
                Console.WriteLine(encryptInput2 is "123456789");
                var sign2       = rsaPkcs1Util.SignData("987654321", HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1);
                var verifyData2 = rsaPkcs1Util.VerifyData("987654321", sign2, HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1);
                Console.Write("PKCS1签名是否成功");
                Console.WriteLine(verifyData2);
                break;

            default:
                RsaPkcs8Util rsaPkcs8Util  = new RsaPkcs8Util(Encoding.UTF8, publicKey, privateKey);
                var          encrypt3      = rsaPkcs8Util.Encrypt("123456789", RSAEncryptionPadding.Pkcs1);
                var          encryptInput3 = rsaPkcs8Util.Decrypt(encrypt3, RSAEncryptionPadding.Pkcs1);
                Console.Write("PKCS8加解密是否成功:");
                Console.WriteLine(encryptInput3 is "123456789");
                var sign3       = rsaPkcs8Util.SignData("987654321", HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1);
                var verifyData3 = rsaPkcs8Util.VerifyData("987654321", sign3, HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1);
                Console.Write("PKCS8签名是否成功");
                Console.WriteLine(verifyData3);
                break;
            }
        }
示例#16
0
 /// <summary>
 /// 不同格式加解密以及验签和签名
 /// </summary>
 public static void RSASign(string privateKey, string publicKey, EnumUserType enumUserType, Action <string, string, EnumUserType> rsaSign)
 {
     rsaSign(privateKey, publicKey, enumUserType);
 }
示例#17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EnumTypeInstance"/> class.
 /// </summary>
 /// <param name="enumUserType">The enumeration user type.</param>
 public EnumTypeInstance(EnumUserType enumUserType)
     : base(enumUserType)
 {
 }
示例#18
0
 public User()
 {
     UserType = EnumUserType.Admin;
 }
示例#19
0
        /// <summary>
        ///  根据用户手机号获取用户信息
        /// </summary>
        /// <param name="mobile"></param>
        public ResponseUserDTO GetUserInfoByMobile(string Mobile, EnumUserType userType = EnumUserType.Default)
        {
            var UserID = GetUserIDByMobile(Mobile, userType);

            return(GetUserInfoByUserId(UserID));
        }
示例#20
0
 public User(JToken jt)
 {
     Username = (string)jt["Username"];
     Password = (string)jt["Password"];
     UserType = (EnumUserType)(int)jt["Usertype"];
 }
        public HttpResponseMessage SearchBrokers( EnumUserType userType,EnumBrokerSearchOrderBy orderByAll = EnumBrokerSearchOrderBy .OrderById, bool isDes = true,string phone = null, string name = null, int page = 1, int pageSize = 10, int state = 2)
        {
            //var phones = new int[1];

            var brokerSearchCondition = new BrokerSearchCondition
            {
                Brokername = name,
                Phone1 = phone,
                Page = Convert.ToInt32(page),
                PageCount = 10,
                UserType = userType,
                State = state,
                OrderBy = orderByAll,
                isDescending =isDes 

            };

            var brokersList = _brokerService.GetBrokersByCondition(brokerSearchCondition).Select(p => new
            {
                p.Id,
                p.Nickname,
                p.Brokername,
                p.Realname,
                p.Phone,
                p.Sfz,
                p.Amount,
                p.Agentlevel,
                p.Regtime,
                p.Headphoto,
                p.State,
                p.Usertype,
                btnVisibleDel = true,
                btnVisibleCan = true,
                btnname = "注销",
                btncolor = "",
                backcolor = ""
            }).ToList().Select(b => new
            {
                b.Id,
                b.Nickname,
                b.Brokername,
                b.Realname,
                b.Phone,
                b.Sfz,
                b.Amount,
                b.Agentlevel,
                Regtime = b.Regtime.ToString("yyyy-MM-dd"),
                b.Headphoto,
                b.State,
                b.Usertype,
                btnVisibleDel = true,
                btnVisibleCan = true
            });
            var brokerListCount = _brokerService.GetBrokerCount(brokerSearchCondition);
            return PageHelper.toJson(new { List = brokersList, Condition = brokerSearchCondition, totalCount = brokerListCount });
        }
示例#22
0
 public record User(EnumUserType Type, string Email, string Name, string Password);
示例#23
0
 public List <string> GetOnlineUserList(EnumUserType userType)
 {
     return(Manager.Instance.SetMembers <string>(new XuHos.Common.Cache.Keys.StringCacheKey(StringCacheKeyType.Heartbeat_Web, $"OnlineSet:{userType:G}").KeyName));
 }
示例#24
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EnumTreeType"/> class.
 /// </summary>
 /// <param name="enumUserType">The enumeration user type.</param>
 public EnumTreeType(EnumUserType enumUserType)
     : base(enumUserType)
 {
 }