/// <summary>
        /// 重置密码
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public bool forgetPassword(forgetPassword request)
        {
            using (var db = DbFactory.Open())
            {
                var info = db.Single <UserInfo>(x => x.UserName == request.UserName);
                if (info == null)
                {
                    throw new Exception("用户不存在");
                }

                var success = db.UpdateOnly(new UserInfo {
                    PassWord = DESHelper.DESEncrypt(request.Password)
                },
                                            onlyFields: x => x.PassWord,
                                            where : x => x.Id == info.Id) == 1;
                if (success)
                {
                    var logInfo = new LogInfo();
                    logInfo.UserName = request.UserName;
                    logInfo.tm       = DateTime.Now;
                    logInfo.adcd     = info.adcd;
                    var log = new operateLog();
                    log.operateMsg  = "重置密码成功";
                    log.operateTime = DateTime.Now;
                    log.userName    = request.UserName;

                    logInfo.Operation     = JsonTools.ObjectToJson(log);
                    logInfo.RealName      = info.RealName;
                    logInfo.OperationType = GrassrootsFloodCtrlEnums.OperationTypeEnums.更新;
                    db.Insert(logInfo);
                }
                return(success);
            }
        }
Beispiel #2
0
        /// <summary>
        /// login
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void LoginClickEven(object sender, EventArgs e)
        {
            txtName = FindViewById <EditText>(Resource.Id.txt_name);
            txtPwd  = FindViewById <EditText>(Resource.Id.txt_pwd);

            string domain = this.GetString(Resource.String.domain);
            string url    = domain + "user/login";
            IDictionary <string, string> routeParames = new Dictionary <string, string>();

            routeParames.Add("userName", DESHelper.DESEncrypt(this.txtName.Text));
            routeParames.Add("userPassword", DESHelper.DESEncrypt(HMACMD5Encrypt.GetEncryptResult(this.txtPwd.Text)));

            var test = HMACMD5Encrypt.GetEncryptResult(this.txtPwd.Text);

            var result = await EasyWebRequest.SendPostRequestBasedOnHttpClient(url, routeParames);

            //var result = await EasyWebRequest.SendPostHttpRequestBaseOnHttpWebRequest(url, routeParames);
            var data = (JsonObject)result;

            if (data["Code"] == "0000")
            {
                var share  = GetSharedPreferences("finance", FileCreationMode.Private);
                var editor = share.Edit();
                editor.PutString("name", txtName.Text).Commit();

                Intent intent = new Intent(this, typeof(MainActivity));
                StartActivity(intent);
                Finish();
            }
            else
            {
                Toast.MakeText(this, "Login fail,please check your name and password", ToastLength.Long).Show();
            }
        }
Beispiel #3
0
        /// <summary>
        /// user registrate button click even
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void RegistrateEven(object sender, EventArgs e)
        {
            txtName     = FindViewById <EditText>(Resource.Id.et_name);
            txtPwd      = FindViewById <EditText>(Resource.Id.et_pwd);
            txtEmail    = FindViewById <EditText>(Resource.Id.et_email);
            _userGender = rg.CheckedRadioButtonId == Resource.Id.rbtn_man ? "male" : "female";

            string domain = this.GetString(Resource.String.domain);
            string url    = domain + "user/register";
            IDictionary <string, string> routeParames = new Dictionary <string, string>();

            routeParames.Add("userName", DESHelper.DESEncrypt(this.txtName.Text));
            routeParames.Add("userPassword", DESHelper.DESEncrypt(HMACMD5Encrypt.GetEncryptResult(this.txtPwd.Text)));
            routeParames.Add("gender", DESHelper.DESEncrypt(this._userGender));
            routeParames.Add("email", DESHelper.DESEncrypt(this.txtEmail.Text));

            var result = await EasyWebRequest.SendPostRequestBasedOnHttpClient(url, routeParames);

            var data = (JsonObject)result;

            if (data["Code"] == "0000")
            {
                Intent intent = new Intent(this, typeof(MainActivity));
                StartActivity(intent);
                Finish();
            }
            else
            {
                Toast.MakeText(this, "Register fail", ToastLength.Long).Show();
            }
        }
Beispiel #4
0
        public void encrypt_and_decrypt_should_success()
        {
            string data = "123";

            string str = DESHelper.DESEncrypt(data);

            Assert.Equal(data, DESHelper.DESDecrypt(str));
        }
 /// <summary>
 /// 保存用户
 /// </summary>
 /// <param name="request"></param>
 /// <returns></returns>
 public bool SaveUserInfo(SaveUserInfo request)
 {
     using (var db = DbFactory.Open())
     {
         var info = new UserInfo();
         info.adcd     = request.adcd;
         info.RealName = request.RealName;
         info.UserName = request.UserName;
         info.PassWord = DESHelper.DESEncrypt(request.PassWord);
         //if(!ValidatorHelper.IsMobile(request.Mobile))
         //    throw new Exception("手机号码错误");
         //info.Mobile = request.Mobile;
         info.isEnable     = request.isEnable;
         info.UserRealName = request.UserRealName;
         info.Unit         = request.Unit;
         info.Position     = request.Position;
         var result = 0;
         if (request.id != 0)
         {
             info.Id = request.id;
             result  = db.Update(info);
             if (result >= 1)
             {
                 var urInfo = new UserRoleInfo();
                 urInfo.UserID = request.id;
                 urInfo.RoleID = request.role;
                 urInfo.Id     = db.Single <UserRoleInfo>(x => x.UserID == request.id).Id;
                 db.Update(urInfo);
             }
         }
         else
         {
             var modle = GetUserInfoByUserName(request.UserName, request.adcd);
             if (modle == null)
             {
                 result = (int)db.Insert(info, true);
                 if (result >= 1)
                 {
                     var urInfo = new UserRoleInfo();
                     urInfo.UserID = result;
                     urInfo.RoleID = request.role;
                     db.Insert(urInfo);
                 }
             }
             else
             {
                 throw new Exception("用户名已存在");
             }
         }
         return(result >= 1);
     }
 }
        /// <summary>
        /// 登陆
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="passWord"></param>
        /// <returns></returns>
        public UserInfo Login(string userName, string passWord)
        {
            using (var db = DbFactory.Open())
            {
                if (string.IsNullOrEmpty(userName))
                {
                    throw  new Exception("用户名不能为空");
                }
                if (string.IsNullOrEmpty(passWord))
                {
                    throw new Exception("密码不能为空");
                }
                var builder = db.From <UserInfo>();
                builder.Where(x => x.UserName == userName.Trim() && x.PassWord == DESHelper.DESEncrypt(passWord.Trim()) && x.isEnable);
                var list = db.Select(builder);
                if (list.Count == 1)
                {
                    var info = list[0];
                    db.UpdateOnly(new UserInfo {
                        loginNum = info.loginNum + 1
                    },
                                  onlyFields: x => x.loginNum,
                                  where : x => x.Id == info.Id);
                    var log = new operateLog();
                    var IP  = WebUtils.Get_ClientIP();
                    log.operateMsg  = "登录系统,登录IP地址为:" + IP;
                    log.operateTime = DateTime.Now;
                    log.userName    = userName.Trim();
                    var operation = JsonTools.ObjectToJson(log);
                    AddLog(new AddLog()
                    {
                        adcd = info.adcd, UserName = userName, Operation = operation, OperationType = GrassrootsFloodCtrlEnums.OperationTypeEnums.登陆
                    });

                    return(info);
                }
                else
                {
                    return(null);
                }
            }
        }
 /// <summary>
 /// 更改密码
 /// </summary>
 /// <param name="request"></param>
 /// <returns></returns>
 public bool changePassword(changePassword request)
 {
     using (var db = DbFactory.Open())
     {
         var info = db.Single <UserInfo>(x => x.Id == request.Id);
         if (info == null)
         {
             throw new Exception("用户不存在");
         }
         var model = Login(info.UserName, request.oldPassword);
         if (model == null)
         {
             throw new Exception("原密码输入错误.");
         }
         return(db.UpdateOnly(new UserInfo {
             PassWord = DESHelper.DESEncrypt(request.newPassword)
         },
                              onlyFields: x => x.PassWord,
                              where : x => x.Id == info.Id) == 1);
     }
 }
Beispiel #8
0
        public ActionResult md5(string txtkey)
        {
            ViewBag.txt    = txtkey;
            ViewBag.md5_16 = MD5Helper.MD5_16(txtkey);
            ViewBag.md5_32 = MD5Helper.MD5_32(txtkey);

            string des = DESHelper.DESEncrypt(txtkey, DESHelper.GetKey());

            ViewBag.des_E = des;
            ViewBag.des_D = DESHelper.DESDecrypt(des, DESHelper.GetKey());

            //LoginLog one = new LoginLog();
            //one.belong_to_company = "ecobio";
            //one.login_time = DateTime.Now;
            //one.login_user_alias = txtkey;
            //string xml = XmlSerializerHelper.SaveXmlFromObj<LoginLog>(one);


            string mdc = Image64Base.GetImageStr("d:\\a.jpg");

            ViewBag.xml = mdc;
            return(View());
        }
Beispiel #9
0
        private void InitTables(Container container)
        {
            var connFactory = container.Resolve <IDbConnectionFactory>();

            var schemaManager = container.Resolve <ISchemaManager>();

            using (var db = connFactory.Open())
            {
                //创建和用户表
                db.CreateTableIfNotExists <UserInfo>();
                //重新创建用户相关表
                //var authRepo = (OrmLiteAuthRepository)container.Resolve<IUserAuthRepository>();
                //authRepo.InitSchema();   //Create only the missing tables
                //authRepo.InitApiKeySchema();

                //创建表
                db.CreateTableIfNotExists <LogInfo>();                 //系统日志表
                db.CreateTableIfNotExists <UserInfo>();                //用户信息表
                db.CreateTableIfNotExists <Role>();                    //角色信息表
                db.CreateTableIfNotExists <UserRoleInfo>();            //用户角色关系表
                db.CreateTableIfNotExists <ADCDInfo>();                //行政区划信息表
                db.CreateTableIfNotExists <ADCDDisasterInfo>();        //受灾害影响的行政区划信息表
                db.CreateTableIfNotExists <VillageWorkingGroup>();     //村防汛防台工作组
                db.CreateTableIfNotExists <VillageGridPersonLiable>(); //村网格责任人
                db.CreateTableIfNotExists <VillageTransferPerson>();   //村危险区转移人员
                db.CreateTableIfNotExists <Post>();                    //岗位管理
                db.CreateTableIfNotExists <TownPersonLiable>();        //镇级防汛防台责任人
                db.CreateTableIfNotExists <VillagePic>();              //村防汛防台形势图
                db.CreateTableIfNotExists <Grid>();
                db.CreateTableIfNotExists <DangerZone>();              //危险区转移人员清单
                db.CreateTableIfNotExists <Column>();                  //栏目管理
                db.CreateTableIfNotExists <RoleDetail>();              //角色权限
                db.CreateTableIfNotExists <CountryPerson>();           //县级人员
                db.CreateTableIfNotExists <Audit>();                   //县市审核
                db.CreateTableIfNotExists <AuditCounty>();             //县市审核
                db.CreateTableIfNotExists <AuditDetails>();
                db.CreateTableIfNotExists <AuditCountyDetails>();
                db.CreateTableIfNotExists <SmsMessage>();//短信
                db.CreateTableIfNotExists <Model.Position.Position>();
                db.CreateTableIfNotExists <SpotCheck>();
                db.CreateTableIfNotExists <ADCDQRCode>();    //二维码
                db.CreateTableIfNotExists <AppLoginVCode>(); //
                db.CreateTableIfNotExists <AppRecord>();     //
                db.CreateTableIfNotExists <DatashareUser>(); //数据共享
                db.CreateTableIfNotExists <AppGetReg>();
                db.CreateTableIfNotExists <AppAlluserView>();
                db.CreateTableIfNotExists <CountyTransInfo>();                       //县级转移人数数据表
                //加字段
                schemaManager.AddColumnIfNotExist(typeof(ADCDDisasterInfo), "Year"); //受灾害影响的行政区划信息表---年度字段
                schemaManager.AddColumnIfNotExist(typeof(ADCDDisasterInfo), "operateLog");
                schemaManager.AddColumnIfNotExist(typeof(ADCDDisasterInfo), "CreateTime");
                schemaManager.AddColumnIfNotExist(typeof(ADCDInfo), "operateLog");
                schemaManager.AddColumnIfNotExist(typeof(ADCDInfo), "CreateTime");
                schemaManager.AddColumnIfNotExist(typeof(VillageWorkingGroup), "EditTime");
                schemaManager.AddColumnIfNotExist(typeof(VillageTransferPerson), "Remark");//创建管理员角色及账号
                schemaManager.AddColumnIfNotExist(typeof(VillageGridPersonLiable), "EditTime");
                schemaManager.AddColumnIfNotExist(typeof(VillageGridPersonLiable), "VillageGridName");
                schemaManager.AddColumnIfNotExist(typeof(VillageGridPersonLiable), "GridName");
                schemaManager.AddColumnIfNotExist(typeof(UserInfo), "loginNum");
                schemaManager.AddColumnIfNotExist(typeof(UserInfo), "UserRealName");
                schemaManager.AddColumnIfNotExist(typeof(UserInfo), "Unit");
                schemaManager.AddColumnIfNotExist(typeof(UserInfo), "Position");
                schemaManager.AddColumnIfNotExist(typeof(Model.Audit.Audit), "AuditNums");
                schemaManager.AddColumnIfNotExist(typeof(AuditDetails), "AuditNums");
                schemaManager.AddColumnIfNotExist(typeof(VillageGridPersonLiable), "AuditNums");
                schemaManager.AddColumnIfNotExist(typeof(VillageGridPersonLiable), "OldData");
                schemaManager.AddColumnIfNotExist(typeof(VillageGridPersonLiable), "NewData");
                schemaManager.AddColumnIfNotExist(typeof(VillagePic), "AuditNums");
                schemaManager.AddColumnIfNotExist(typeof(VillagePic), "OldData");
                schemaManager.AddColumnIfNotExist(typeof(VillagePic), "NewData");
                schemaManager.AddColumnIfNotExist(typeof(VillageTransferPerson), "AuditNums");
                schemaManager.AddColumnIfNotExist(typeof(VillageTransferPerson), "OldData");
                schemaManager.AddColumnIfNotExist(typeof(VillageTransferPerson), "NewData");
                schemaManager.AddColumnIfNotExist(typeof(VillageTransferPerson), "IfTransfer");
                schemaManager.AddColumnIfNotExist(typeof(VillageWorkingGroup), "AuditNums");
                schemaManager.AddColumnIfNotExist(typeof(VillageWorkingGroup), "OldData");
                schemaManager.AddColumnIfNotExist(typeof(VillageWorkingGroup), "NewData");
                schemaManager.AddColumnIfNotExist(typeof(ADCDDisasterInfo), "FXFTRW");
                schemaManager.AddColumnIfNotExist(typeof(CountryPerson), "adcd");
                schemaManager.AddColumnIfNotExist(typeof(CountryPerson), "OldData");
                schemaManager.AddColumnIfNotExist(typeof(CountryPerson), "NewData");
                schemaManager.AddColumnIfNotExist(typeof(CountryPerson), "AuditNums");
                schemaManager.AddColumnIfNotExist(typeof(TownPersonLiable), "OldData");
                schemaManager.AddColumnIfNotExist(typeof(TownPersonLiable), "NewData");
                schemaManager.AddColumnIfNotExist(typeof(TownPersonLiable), "AuditNums");
                schemaManager.AddColumnIfNotExist(typeof(AuditCounty), "CityAuditTime");
                schemaManager.AddColumnIfNotExist(typeof(AppRecord), "adcd");
                schemaManager.AddColumnIfNotExist(typeof(AppRecord), "token");
                schemaManager.AddColumnIfNotExist(typeof(AppRecord), "postTime");
                schemaManager.AddColumnIfNotExist(typeof(AppRecord), "stepItem");
                schemaManager.AddColumnIfNotExist(typeof(AppRecord), "valuesItem");

                var role = db.Single <Role>(x => x.RoleName == "系统管理员");
                if (role == null)
                {
                    db.Insert(new Role()
                    {
                        RoleName = "系统管理员"
                    });
                }

                var info = db.Single <UserInfo>(x => x.UserName == "admin");
                if (info == null)
                {
                    var id = (int)db.Insert(new UserInfo()
                    {
                        UserName = "******",
                        PassWord = DESHelper.DESEncrypt("abc123"),
                        RealName = "系统管理员",
                        adcd     = "330000000000000",
                        isEnable = true
                    }, true);
                    var roleID = db.Single <Role>(x => x.RoleName == "系统管理员").Id;
                    db.Insert(new UserRoleInfo()
                    {
                        UserID = id,
                        RoleID = roleID
                    });
                }
                //
                var userPosition = db.Select <UserPostionList>();
                CachHelper.CacheHelper.SetCache("UserPostionList", userPosition, System.DateTime.Now.AddSeconds(86400000), TimeSpan.Zero);
            }
        }