public VolunteerAddViewModel GetMyInfos(SearchByVIDModel vidModel)
        {
            DEncrypt encrypt            = new DEncrypt();
            VolunteerAddViewModel model = new VolunteerAddViewModel();

            Volunteer_Info info = _IVolunteerInfoRepository.SearchInfoByID(vidModel.VID);



            if (info != null && info.ID != null)
            {
                model = _IMapper.Map <Volunteer_Info, VolunteerAddViewModel>(info);

                List <Volunteer_Relate_Type> Relate_Types = _IVolunteer_Relate_TypeRepository.GetMyTypeList(vidModel.VID);
                model.RelateUserIDandTypeIDList = _IMapper.Map <List <Volunteer_Relate_Type>, List <Volunteer_Relate_TypeMiddle> >(Relate_Types);

                List <VAttachment> VAttachmentList = _IVAttachmentRepository.GetMyList(vidModel.VID);
                model.VAttachmentAddList = _IMapper.Map <List <VAttachment>, List <VAttachmentAddViewModel> >(VAttachmentList);

                model.Name          = encrypt.Decrypt(model.Name);
                model.CertificateID = encrypt.Decrypt(model.CertificateID);
                model.Mobile        = encrypt.Decrypt(model.Mobile);
            }

            return(model);
        }
示例#2
0
        /// <summary>
        /// 获取数据库连接连接配置
        /// </summary>
        /// <param name="masterDb">是否访问主库,默认为是,否则访问从库即只读数据库</param>
        /// <returns></returns>
        public static DbConnectionOptions GeDbConnectionOptions(bool masterDb = true)
        {
            bool conStringEncrypt = Configs.GetConfigurationValue("AppSetting", "ConStringEncrypt").ToBool();

            if (string.IsNullOrEmpty(dbConfigName))
            {
                dbConfigName = Configs.GetConfigurationValue("AppSetting", "DefaultDataBase");
            }
            Dictionary <string, DbConnectionOptions> dictRead = Configs.GetSection("DbConnections:" + dbConfigName + ":ReadDb").Get <Dictionary <string, DbConnectionOptions> >();

            DbConnectionOptions dbConnectionOptions = new DbConnectionOptions();
            bool isDBReadWriteSeparate = Configs.GetConfigurationValue("AppSetting", "IsDBReadWriteSeparate").ToBool();

            if (masterDb || !isDBReadWriteSeparate)
            {
                dbConnectionOptions.ConnectionString = Configs.GetConfigurationValue("DbConnections:" + dbConfigName + ":MasterDB", "ConnectionString");
                dbConnectionOptions.DatabaseType     = (DatabaseType)Enum.Parse(typeof(DatabaseType), Configs.GetConfigurationValue("DbConnections:" + dbConfigName + ":MasterDB", "DatabaseType"));
            }
            else
            {
                dbConnectionOptions = GetReadConn(dictRead);
            }
            if (conStringEncrypt)
            {
                dbConnectionOptions.ConnectionString = DEncrypt.Decrypt(dbConnectionOptions.ConnectionString);
            }
            return(dbConnectionOptions);
        }
示例#3
0
        /// <summary>
        /// 发送邮件
        /// </summary>
        /// <param name="mailBodyEntity">邮件基础信息</param>
        public static SendResultEntity SendMail(MailBodyEntity mailBodyEntity)
        {
            var sendResultEntity = new SendResultEntity();

            if (mailBodyEntity == null)
            {
                throw new ArgumentNullException();
            }

            SendServerConfigurationEntity sendServerConfiguration = new SendServerConfigurationEntity();
            YuebonCacheHelper             yuebonCacheHelper       = new YuebonCacheHelper();
            AppSetting sysSetting = yuebonCacheHelper.Get <AppSetting>("SysSetting");

            if (sysSetting != null)
            {
                sendServerConfiguration.SmtpHost       = DEncrypt.Decrypt(sysSetting.Emailsmtp);
                sendServerConfiguration.SenderAccount  = sysSetting.Emailusername;
                sendServerConfiguration.SenderPassword = DEncrypt.Decrypt(sysSetting.Emailpassword);
                sendServerConfiguration.SmtpPort       = sysSetting.Emailport.ToInt();
                sendServerConfiguration.IsSsl          = sysSetting.Emailssl.ToBool();
                sendServerConfiguration.MailEncoding   = "utf-8";

                mailBodyEntity.Sender        = sysSetting.Emailnickname;
                mailBodyEntity.SenderAddress = sysSetting.Emailusername;
            }
            else
            {
                sendResultEntity.ResultInformation = "邮件服务器未配置";
                sendResultEntity.ResultStatus      = false;
                throw new ArgumentNullException();
            }
            sendResultEntity = SendMail(mailBodyEntity, sendServerConfiguration);
            return(sendResultEntity);
        }
示例#4
0
        private ActionResult LoginMethod(User model, MyDbContext db, string returnurl)
        {
            Token t = new Token
            {
                ExpTime  = DateTime.Now.AddMinutes(2),
                IsEnable = true,
                UserName = model.UserName
            };

            db.Token.Add(t);
            db.SaveChanges();

            string token = DEncrypt.Encrypt <Token>(t);
            //写入一个cookie,标识登陆成功
            HttpCookie c = new HttpCookie(CommonHelper.LoginCookieName, DEncrypt.Encrypt(model.UserName));

            c.Expires = DateTime.Now.AddDays(7);
            if (Request.Cookies[CommonHelper.LoginCookieName] == null)
            {
                Response.Cookies.Add(c);
            }
            else
            {
                Response.Cookies.Set(c);
            }

            string url = DEncrypt.Decrypt(returnurl);

            return(Redirect(url + "?token=" + Server.UrlEncode(token)));
        }
 /// <summary>
 /// 从cookie中拿到信息并解密
 /// </summary>
 /// <param name="accessor"></param>
 /// <returns></returns>
 public static string GetCookie(this HttpContext httpContext, string cookieKey = CookieKey)
 {
     if (string.IsNullOrWhiteSpace(cookieKey))
     {
         return("");
     }
     return(DEncrypt.Decrypt(httpContext.Request.Cookies[cookieKey]));
 }
示例#6
0
        /// <summary>
        /// 20200510 Easy 用户初次进入自愿者小程序验证用户是否是泰便利注册用户,如果是返回泰便利用户中心信息,如果不是返回空
        /// </summary>
        public Dtol.Easydtol.UserInfo GetEasyUserInfo(string code)
        {
            Dtol.Easydtol.UserInfo user_Info = _IWeChatClientRepository.EasyDecrypt(code, _IOptions.Value.appid, _IOptions.Value.secret);
            //判断 是否注册泰便利
            if (user_Info.ID != null)
            {
                DEncrypt encrypt       = new DEncrypt();
                string   Name          = encrypt.Decrypt(user_Info.Name);
                string   CertificateID = encrypt.Decrypt(user_Info.CertificateID);
                string   Mobile        = encrypt.Decrypt(user_Info.Mobile);

                user_Info.Name          = Name;
                user_Info.CertificateID = CertificateID;
                user_Info.Mobile        = Mobile;
            }
            return(user_Info);
        }
示例#7
0
        public void EncryptTest()
        {
            string original = "我是谁";
            string expected = string.Empty; // TODO: 初始化为适当的值
            string actual;

            actual = DEncrypt.Encrypt(original);
            var result = DEncrypt.Decrypt(actual);

            Assert.AreEqual(original, result);
        }
        public List <VScoreRankMiddle> GetScoreRanks()
        {
            DEncrypt encrypt = new DEncrypt();
            List <VScoreRankMiddle> result = _SqlRepository.GetScoreRank();

            foreach (var item in result)
            {
                item.Name = encrypt.Decrypt(item.Name);
            }
            return(result);
        }
示例#9
0
        public AliYunSMS()
        {
            YuebonCacheHelper yuebonCacheHelper = new YuebonCacheHelper();
            AppSetting        sysSetting        = yuebonCacheHelper.Get <AppSetting>("SysSetting");

            if (sysSetting != null)
            {
                this.Appkey    = DEncrypt.Decrypt(sysSetting.Smsusername);
                this.Appsecret = DEncrypt.Decrypt(sysSetting.Smspassword);
                this.SignName  = sysSetting.SmsSignName;
            }
        }
示例#10
0
        // GET: Account
        public ActionResult Login()
        {
            S_User s_user           = new S_User();
            var    memberValidation = Request.Cookies.Get("_token");//使用cookie

            if (memberValidation != null && memberValidation.HasKeys)
            {
                s_user          = JsonConvert.DeserializeObject <S_User>(memberValidation["name"]);
                s_user.Password = DEncrypt.Decrypt(s_user.Password, "zhang");
            }
            return(View(s_user));
        }
示例#11
0
        /// <summary>
        /// 20200629 用户初次进入自愿者小程序  判断是否能获取unionid,如果有unionid验证用户是否是泰便利注册用户,
        /// 如果是返回泰便利用户中心信息,如果不是返回空
        /// </summary>
        public UserInfoResModel GetEasyUserInfoByCode(string code)
        {
            UserInfoResModel resModel = new UserInfoResModel();

            resModel = _IWeChatClientRepository.EasyDecryptByCode(code, _IOptions.Value.appid, _IOptions.Value.secret);
            //判断 是否注册泰便利
            if (resModel.userInfo != null)
            {
                if (resModel.userInfo.ID != null)
                {
                    DEncrypt encrypt       = new DEncrypt();
                    string   Name          = encrypt.Decrypt(resModel.userInfo.Name);
                    string   CertificateID = encrypt.Decrypt(resModel.userInfo.CertificateID);
                    string   Mobile        = encrypt.Decrypt(resModel.userInfo.Mobile);

                    resModel.userInfo.Name          = Name;
                    resModel.userInfo.CertificateID = CertificateID;
                    resModel.userInfo.Mobile        = Mobile;
                }
            }
            return(resModel);
        }
        public List <VScoreRankMiddle> GetMyScoreRanks(SearchByVIDModel searchModel)
        {
            DEncrypt encrypt = new DEncrypt();
            List <VScoreRankMiddle> result = _SqlRepository.GetScoreRank();

            foreach (var item in result)
            {
                item.Name = encrypt.Decrypt(item.Name);
            }
            List <VScoreRankMiddle> middle = result.Where(o => o.VID.Equals(searchModel.VID)).ToList();

            return(middle);
        }
示例#13
0
        /// <summary>
        /// 根据被加密过的UserCode返回用户信息实体
        /// </summary>
        /// <param name="EnUSERCODE">被加密过的UserCode</param>
        /// <returns></returns>
        public static Psd.H5Show.Model.user_account GetUserCodeToUseraccountModel(string EnUSERCODE)
        {
            string UserCode = DEncrypt.Decrypt(EnUSERCODE);
            object obj      = new Psd.H5Show.BLL.user_account().GetModelList(string.Format("USERCODE='{0}'", UserCode))[0];

            if (obj != null)
            {
                return(obj as Psd.H5Show.Model.user_account);
            }
            else
            {
                return(null);
            }
        }
示例#14
0
        public IActionResult GetAllInfo()
        {
            CommonResult        result              = new CommonResult();
            YuebonCacheHelper   yuebonCacheHelper   = new YuebonCacheHelper();
            SysSetting          sysSetting          = yuebonCacheHelper.Get("SysSetting").ToJson().ToObject <SysSetting>();
            SysSettingOutputDto sysSettingOutputDto = new SysSettingOutputDto();

            if (sysSetting == null)
            {
                sysSetting = XmlConverter.Deserialize <SysSetting>("xmlconfig/sys.config");
            }

            //对关键信息解密
            if (!string.IsNullOrEmpty(sysSetting.Email))
            {
                sysSetting.Email = DEncrypt.Decrypt(sysSetting.Email);
            }
            if (!string.IsNullOrEmpty(sysSetting.Emailsmtp))
            {
                sysSetting.Emailsmtp = DEncrypt.Decrypt(sysSetting.Emailsmtp);
            }
            if (!string.IsNullOrEmpty(sysSetting.Emailpassword))
            {
                sysSetting.Emailpassword = DEncrypt.Decrypt(sysSetting.Emailpassword);
            }
            if (!string.IsNullOrEmpty(sysSetting.Smspassword))
            {
                sysSetting.Smspassword = DEncrypt.Decrypt(sysSetting.Smspassword);
            }
            if (!string.IsNullOrEmpty(sysSetting.Smsusername))
            {
                sysSetting.Smsusername = DEncrypt.Decrypt(sysSetting.Smsusername);
            }
            sysSettingOutputDto = sysSetting.MapTo <SysSettingOutputDto>();
            if (sysSettingOutputDto != null)
            {
                sysSettingOutputDto.CopyRight = UIConstants.CopyRight;
                result.ResData = sysSettingOutputDto;
                result.Success = true;
                result.ErrCode = ErrCode.successCode;
            }
            else
            {
                result.ErrMsg  = ErrCode.err60001;
                result.ErrCode = "60001";
            }
            return(ToJsonContent(result));
        }
示例#15
0
 public ActionResult Login(string returnurl)
 {
     if (string.IsNullOrEmpty(returnurl))
     {
         return(Content("请求异常!"));
     }
     if (Request.Cookies[CommonHelper.LoginCookieName] != null)
     {
         using (MyDbContext db = new MyDbContext())
         {
             var userName = DEncrypt.Decrypt(Request.Cookies[CommonHelper.LoginCookieName].Value);
             return(LoginMethod(db.User.Where(m => m.UserName == userName).First(), db, returnurl));
         }
     }
     return(View());
 }
示例#16
0
        public static string GetconnectionString(string ConnectionStringName)
        {
            try
            {
                string connString = ConfigHelper.GetconnectionStrings(ConnectionStringName);
                connString = DEncrypt.Decrypt(connString);
                return(connString);
            }
            catch (Exception ex)
            {
                logger.Error("GetconnectionString:" + ex.Message);
                return("");
            }

            //return @"data source=EVN-AIC50428\SQL2012;initial catalog=SpecialOrderDB;persist security info=True;user id=sa;password=123456;MultipleActiveResultSets=True;";
        }
    protected string validurl;  //验证URL

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            name = Request.QueryString["logname"];
            string email  = Request.QueryString["email"];
            string dname  = "";
            string demail = "";
            Tz888.BLL.Register.RegisterMail mail = new Tz888.BLL.Register.RegisterMail();
            try
            {
                try
                {
                    if ((name != null && email != null) ||
                        (!name.Equals(String.Empty) && !email.Equals(String.Empty)))
                    {
                        demail = DEncrypt.Decrypt(email);
                        dname  = DEncrypt.Decrypt(name);
                    }
                }
                catch (NullReferenceException ep)
                {
                    Tz888.Common.MessageBox.ShowBack("非法访问," + ep.Message);
                    return;
                }
            }
            catch (FormatException exp)
            {
                Tz888.Common.MessageBox.ShowBack("邮箱验证出错!" + exp.Message);
                return;
            }

            lblMail.Text = demail;
            //邮件模板URL
            string url = Server.MapPath(mail.GetMailTemplateUrl());
            domain   = "http://" + Request.ServerVariables["SERVER_NAME"].ToString();
            validurl = domain + Request.RawUrl.Replace("ValidEMailEnterprise.aspx", "ValidSuccessEnter.aspx");

            string isSend = mail.GetCookies(dname);
            if (isSend == "" || isSend == string.Empty)
            {
                mail.SendMail(url, dname, demail, validurl, domain);
                mail.CreateCookies(dname, email, "");
            }
        }
    }
示例#18
0
        public IActionResult ConnStrDecrypt(string strConn)
        {
            CommonResult result       = new CommonResult();
            DBConnResult dBConnResult = new DBConnResult();

            if (string.IsNullOrEmpty(strConn))
            {
                result.ErrMsg = "数据库名称不能为空";
            }
            else
            {
                dBConnResult.ConnStr = DEncrypt.Decrypt(strConn);
                result.Success       = true;
                result.ErrCode       = ErrCode.successCode;
            }
            result.ResData = dBConnResult;
            return(ToJsonContent(result));
        }
示例#19
0
        private void GetUserInfo()
        {
            string userId = Request.QueryString["UserID"];

            if (userId != null)
            {
                this.Title = "编辑用户";
                txtLoginName.Attributes.Add("readonly", "true");
                var user = bllTSUSER.GetModelByID(userId);
                txtLoginName.Text  = user.CN_LOGIN_NAME;
                txtPassword.Text   = DEncrypt.Decrypt(user.CN_PASSWORD);
                txtEmployeeNo.Text = user.CN_EMPLOYEE_NO;
                txtReallyName.Text = user.CN_REALLY_NAME;
            }
            else
            {
                this.Title = "新增用户";
                txtLoginName.Attributes.Remove("readonly");
            }
        }
示例#20
0
        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            string conStringEncrypt = Configs.GetConfigurationValue("AppSetting", "ConStringEncrypt");

            this.isMultiTenant = Configs.GetConfigurationValue("AppSetting", "IsMultiTenant").ToBool();
            if (string.IsNullOrEmpty(dbConfigName))
            {
                dbConfigName = Configs.GetConfigurationValue("AppSetting", "DefaultDataBase");
            }
            string defaultSqlConnectionString = Configs.GetConnectionString(dbConfigName);

            if (conStringEncrypt == "true")
            {
                defaultSqlConnectionString = DEncrypt.Decrypt(defaultSqlConnectionString);
            }
            string dbType = dbConfigName.ToUpper();

            if (dbType.Contains("NPGSQL"))
            {
                optionsBuilder.UseNpgsql(defaultSqlConnectionString);
            }
            base.OnConfiguring(optionsBuilder);
        }
示例#21
0
        public async System.Threading.Tasks.Task <ActionResult> YanZhengToken(string token)
        {
            try
            {
                var tokenObj = DEncrypt.Decrypt <Token>(token);
                using (MyDbContext db = new MyDbContext())
                {
                    Token tokenObj2 = null;
                    Task  t1        = Task.Factory.StartNew(() =>
                    {
                        tokenObj2 = db.Token.FirstOrDefault(m => m.Id == tokenObj.Id && m.IsEnable == true);
                    });
                    await t1;
                    if (tokenObj2 == null || tokenObj2.IsEnable == false)
                    {
                        return(Content("0"));
                    }

                    tokenObj2.IsEnable = false;
                    db.SaveChanges();
                    if (tokenObj2.ExpTime > DateTime.Now)
                    {
                        return(Content("1"));
                    }
                    else
                    {
                        return(Content("0"));
                    }
                }
            }
            catch (Exception ex)
            {
                string msg = ex.Message;
                throw;
            }
        }
示例#22
0
        public void PwdTest(string pwd)
        {
            var d = DEncrypt.Decrypt(pwd);

            OutPut.WriteLine(d);
        }
示例#23
0
        //值班认领 签到、签退
        public int HandleAdd(VA_HandleAddViewModel AddViewModel)
        {
            int count = 0;
            MydutyClaim_Sign model = new MydutyClaim_Sign();
            //是否注册
            var VolunteerInfo = _IVolunteerInfoRepository.SearchInfoByID(AddViewModel.VID);

            if (VolunteerInfo == null)
            {
                count = 6;
                return(count);
            }

            double points = 0;
            ////认领得 值班信息
            MydutyClaim_Info claim_Info = _IMydutyClaimInfoRepository.GetByUidandID(AddViewModel.VID, AddViewModel.ContentID);

            if (claim_Info != null)
            {
                //判断是否在值班区间内进行打卡 20200622  值班时间前后15 分钟均可签到签退
                DateTime start = DateTime.Parse(claim_Info.StartDutyTime.ToString());
                DateTime end   = DateTime.Parse(claim_Info.EndDutyTime.ToString());

                if ((DateTime.Now >= start.AddMinutes(-15) && DateTime.Now <= start.AddMinutes(15) && AddViewModel.type == "in") ||
                    (DateTime.Now >= end && DateTime.Now <= end.AddMinutes(15) && AddViewModel.type == "out"))
                {
                    OndutyClaims_Info ondutyClaims = _claimsInfoRepository.GetByID(claim_Info.OndutyClaims_InfoId);
                    if (ondutyClaims != null)
                    {
                        Normalization_Info Normalization = _normalizationInfo.NormalizationByID(ondutyClaims.Normalization_InfoId);
                        if (Normalization != null)
                        {
                            points = double.Parse(Normalization.PointsEarned);
                        }

                        model.OndutyClaims_InfoId = ondutyClaims.id;
                        model.MydutyClaim_InfoID  = AddViewModel.ContentID;
                        //获取小区经纬度信息
                        List <User_Depart> departAll = _IVolunteerInfoRepository.GetDepartAll();

                        var departList = _IMapper.Map <List <User_Depart>, List <UserDepartSearchMidModel> >(departAll);

                        List <UserDepartSearchMidModel> result = new List <UserDepartSearchMidModel>();
                        result.AddRange(departList.Where(p => p.Code == ondutyClaims.SubdistrictID).ToList());
                        UserDepartSearchMidModel depart = new UserDepartSearchMidModel();
                        if (result.Count > 0)
                        {
                            depart = result.First();
                        }


                        //获取 经纬度
                        if (!String.IsNullOrEmpty(AddViewModel.Checklongitude) && !String.IsNullOrEmpty(AddViewModel.Checklatitude))
                        {
                            //进行地址判断 活动地址方圆1000米可以签到
                            if (!String.IsNullOrEmpty(depart.longitude) && !String.IsNullOrEmpty(depart.latitude))
                            {
                                var checks = CheckAddress(double.Parse(depart.longitude), double.Parse(depart.latitude), double.Parse(AddViewModel.Checklongitude), double.Parse(AddViewModel.Checklatitude), 1);
                                if (!checks)
                                {
                                    count = 9;
                                    return(count);
                                }
                            }
                            else
                            {
                                count = 8;
                                return(count);
                            }
                        }
                        else
                        {
                            count = 7;
                            return(count);
                        }
                    }
                }
                else
                {
                    count = 5;
                    return(count);
                }
            }
            else
            {
                count = 4;
                return(count);
            }

            DEncrypt encrypt = new DEncrypt();

            //保存签到签退信息
            model.id             = Guid.NewGuid().ToString();
            model.Userid         = AddViewModel.VID;
            model.UserName       = encrypt.Decrypt(VolunteerInfo.Name);
            model.CheckTime      = DateTime.Now;
            model.type           = AddViewModel.type;
            model.CreateUser     = VolunteerInfo.ID;
            model.CreateDate     = DateTime.Now;
            model.CheckAddress   = AddViewModel.CheckAddress;
            model.Checklongitude = AddViewModel.Checklongitude;
            model.Checklatitude  = AddViewModel.Checklatitude;


            _mydutyClaim_Sign.Add(model);
            count = _mydutyClaim_Sign.SaveChanges();
            if (count == 1)
            {
                string id = Guid.NewGuid().ToString();

                //签退 时按时长积分继续计算
                if (AddViewModel.type == "out")
                {
                    Volunteer_Score score = new Volunteer_Score();
                    score.ID         = id;
                    score.ContentID  = AddViewModel.ContentID;
                    score.tableName  = "MydutyClaim_Info";
                    score.VID        = AddViewModel.VID;
                    score.type       = "out";
                    score.Score      = points;
                    score.CreateUser = AddViewModel.VID;
                    score.CreateDate = DateTime.Now;

                    _IVolunteer_ScoreRepository.Add(score);
                    int b = _IVolunteer_ScoreRepository.SaveChanges();
                    if (b > 0)
                    {
                        //插入到  泰便利积分表  20200622
                        ET_points ipointMiddle = new ET_points();

                        ipointMiddle.ID         = id;
                        ipointMiddle.uid        = AddViewModel.VID;
                        ipointMiddle.points     = score.Score;
                        ipointMiddle.type       = "MydutySign";
                        ipointMiddle.tableName  = "TedaVolunteerDB.dbo.Volunteer_Score";
                        ipointMiddle.CreateUser = AddViewModel.VID;
                        ipointMiddle.CreateDate = DateTime.Now;
                        eT_PointsRepository.Add(ipointMiddle);
                        int j = eT_PointsRepository.SaveChanges();
                    }
                }
            }

            return(count);
        }