Ejemplo n.º 1
0
 /// <summary>
 /// 获取当前登录用户的数据访问权限
 /// </summary>
 /// <param name="blDeptCondition">是否开启,默认开启</param>
 /// <returns></returns>
 protected virtual string GetDataPrivilege(bool blDeptCondition = true)
 {
     string where = "1=1";
     //开权限数据过滤
     if (blDeptCondition)
     {
         var               identities        = HttpContextHelper.HttpContext.User.Identities;
         var               claimsIdentity    = identities.First <ClaimsIdentity>();
         List <Claim>      claimlist         = claimsIdentity.Claims as List <Claim>;
         YuebonCacheHelper yuebonCacheHelper = new YuebonCacheHelper();
         if (claimlist[1].Value != "admin")
         {
             //如果公司过滤条件不为空,那么需要进行过滤
             List <String> list = JsonSerializer.Deserialize <List <String> >(yuebonCacheHelper.Get("User_RoleData_" + claimlist[0].Value).ToJson());
             if (list.Count() > 0)
             {
                 string DataFilterCondition = String.Join(",", list.ToArray());
                 if (!string.IsNullOrEmpty(DataFilterCondition))
                 {
                     where += string.Format(" and (DeptId in ('{0}') or CreatorUserId='{1}')", DataFilterCondition.Replace(",", "','"), claimlist[0].Value);
                 }
             }
             else
             {
                 where += string.Format(" and CreatorUserId='{0}'", claimlist[0].Value);
             }
             bool isMultiTenant = Configs.GetConfigurationValue("AppSetting", "IsMultiTenant").ToBool();
             if (isMultiTenant)
             {
                 where += string.Format(" and TenantId='{0}'", claimlist[3].Value);
             }
         }
     }
     return(where);
 }
Ejemplo n.º 2
0
        public async Task <IActionResult> GetListByParentEnCode(string enCode)
        {
            CommonResult result = new CommonResult();

            try
            {
                if (CurrentUser != null)
                {
                    YuebonCacheHelper    yuebonCacheHelper = new YuebonCacheHelper();
                    List <MenuOutputDto> functions         = new List <MenuOutputDto>();
                    functions = yuebonCacheHelper.Get("User_Function_" + CurrentUser.UserId).ToJson().ToObject <List <MenuOutputDto> >();
                    MenuOutputDto        functionOutputDto = functions.Find(s => s.EnCode == enCode);
                    List <MenuOutputDto> nowFunList        = new List <MenuOutputDto>();
                    if (functionOutputDto != null)
                    {
                        nowFunList = functions.FindAll(s => s.ParentId == functionOutputDto.Id && s.IsShow && s.MenuType.Equals("F")).OrderBy(s => s.SortCode).ToList();
                    }
                    result.ErrCode = ErrCode.successCode;
                    result.ResData = nowFunList;
                }
                else
                {
                    result.ErrCode = "40008";
                    result.ErrMsg  = ErrCode.err40008;
                }
            }
            catch (Exception ex)
            {
                Log4NetHelper.Error("根据父级功能编码查询所有子集功能,主要用于页面操作按钮权限,代码生成异常", ex);
                result.ErrCode = ErrCode.failCode;
                result.ErrMsg  = "获取模块功能异常";
            }
            return(ToJsonContent(result));
        }
Ejemplo n.º 3
0
        public void UpdateCacheAllowApp()
        {
            YuebonCacheHelper yuebonCacheHelper = new YuebonCacheHelper();
            IEnumerable <APP> appList           = repository.GetAllByIsNotDeleteAndEnabledMark();

            yuebonCacheHelper.Add("AllowAppId", appList);
        }
Ejemplo n.º 4
0
        public IActionResult YuebonConnecSys(string systype)
        {
            CommonResult result = new CommonResult();

            try
            {
                if (!string.IsNullOrEmpty(systype))
                {
                    SystemType        systemType        = iService.GetByCode(systype);
                    string            openmf            = MD5Util.GetMD5_32(DEncrypt.Encrypt(CurrentUser.UserId + systemType.Id, GuidUtils.NewGuidFormatN())).ToLower();
                    YuebonCacheHelper yuebonCacheHelper = new YuebonCacheHelper();
                    TimeSpan          expiresSliding    = DateTime.Now.AddSeconds(20) - DateTime.Now;
                    yuebonCacheHelper.Add("openmf" + openmf, CurrentUser.UserId, expiresSliding, false);
                    result.ErrCode = ErrCode.successCode;
                    result.ResData = systemType.Url + "?openmf=" + openmf;
                }
                else
                {
                    result.ErrCode = ErrCode.failCode;
                    result.ErrMsg  = "切换子系统参数错误";
                }
            }
            catch (Exception ex)
            {
                Log4NetHelper.Error("切换子系统异常", ex);
                result.ErrMsg  = ErrCode.err40110;
                result.ErrCode = "40110";
            }
            return(ToJsonContent(result));
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 初始化
        /// </summary>
        public virtual void Initial()
        {
            YuebonCacheHelper yuebonCacheHelper = new YuebonCacheHelper();
            SysSetting        sysSetting        = XmlConverter.Deserialize <SysSetting>("xmlconfig/sys.config");

            if (sysSetting != null)
            {
                yuebonCacheHelper.Add("SysSetting", sysSetting);
            }
        }
Ejemplo n.º 7
0
        public async Task <IActionResult> CreateDBConn(DbConnInfo dbConnInfo)
        {
            CommonResult result       = new CommonResult();
            DBConnResult dBConnResult = new DBConnResult();

            if (dbConnInfo != null)
            {
                if (string.IsNullOrEmpty(dbConnInfo.DbName))
                {
                    dbConnInfo.DbName = "master";
                }
                else if (string.IsNullOrEmpty(dbConnInfo.DbAddress))
                {
                    result.ErrMsg = "访问地址不能为空";
                }
                else if (string.IsNullOrEmpty(dbConnInfo.DbUserName))
                {
                    result.ErrMsg = "访问用户不能为空";
                }
                else if (string.IsNullOrEmpty(dbConnInfo.DbPassword))
                {
                    result.ErrMsg = "访问密码不能为空";
                }
                if (string.IsNullOrEmpty(dbConnInfo.DbPort.ToString()))
                {
                    if (dbConnInfo.DbType == "SqlServer")
                    {
                        dbConnInfo.DbPort = 1433;
                    }
                    else if (dbConnInfo.DbType == "MySql")
                    {
                        dbConnInfo.DbPort = 3306;
                    }
                }
                if (dbConnInfo.DbType == "SqlServer")
                {
                    dBConnResult.ConnStr = string.Format("Server={0},{1};Database={2};User id={3}; password={4};MultipleActiveResultSets=True;", dbConnInfo.DbAddress, dbConnInfo.DbPort, dbConnInfo.DbName, dbConnInfo.DbUserName, dbConnInfo.DbPassword);
                }
                else if (dbConnInfo.DbType == "MySql")
                {
                    dBConnResult.ConnStr = string.Format("server={0};database={1};uid={2}; pwd={3};port={4};Allow User Variables=True;", dbConnInfo.DbAddress, dbConnInfo.DbName, dbConnInfo.DbUserName, dbConnInfo.DbPassword, dbConnInfo.DbPort);
                }
                YuebonCacheHelper yuebonCacheHelper = new YuebonCacheHelper();
                TimeSpan          expiresSliding    = DateTime.Now.AddMinutes(30) - DateTime.Now;
                yuebonCacheHelper.Add("CodeGeneratorDbConn", dBConnResult.ConnStr, expiresSliding, false);
                yuebonCacheHelper.Add("CodeGeneratorDbType", dbConnInfo.DbType, expiresSliding, false);
                yuebonCacheHelper.Add("CodeGeneratorDbName", dbConnInfo.DbName, expiresSliding, false);
                DbExtractor         dbExtractor = new DbExtractor();
                List <DataBaseInfo> listTable   = dbExtractor.GetAllDataBases();
                result.ResData = listTable;
                result.Success = true;
                result.ErrCode = ErrCode.successCode;
            }
            return(ToJsonContent(result));
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 根据相关信息,写入用户的操作日志记录
        /// </summary>
        /// <param name="tableName">操作表名称</param>
        /// <param name="operationType">操作类型</param>
        /// <param name="note">操作详细表述</param>
        /// <returns></returns>
        public bool OnOperationLog(string tableName, string operationType, string note)
        {
            try
            {
                //虽然实现了这个事件,但是我们还需要判断该表是否在配置表里面,如果不在,则不记录操作日志。
                //var identities = _httpContextAccessor.HttpContext.User.Identities;
                if (HttpContextHelper.HttpContext == null)
                {
                    return(false);
                }
                var               identities        = HttpContextHelper.HttpContext.User.Identities;
                var               claimsIdentity    = identities.First <ClaimsIdentity>();
                List <Claim>      claimlist         = claimsIdentity.Claims as List <Claim>;
                string            userId            = claimlist[0].Value;
                YuebonCacheHelper yuebonCacheHelper = new YuebonCacheHelper();
                YuebonCurrentUser CurrentUser       = new YuebonCurrentUser();
                var               user = yuebonCacheHelper.Get("login_user_" + userId).ToJson().ToObject <YuebonCurrentUser>();
                if (user != null)
                {
                    CurrentUser = user;
                    bool insert     = operationType == DbLogType.Create.ToString();;    //&& settingInfo.InsertLog;
                    bool update     = operationType == DbLogType.Update.ToString();     // && settingInfo.UpdateLog;
                    bool delete     = operationType == DbLogType.Delete.ToString();     // && settingInfo.DeleteLog;
                    bool deletesoft = operationType == DbLogType.DeleteSoft.ToString(); // && settingInfo.DeleteLog;
                    bool exception  = operationType == DbLogType.Exception.ToString();  // && settingInfo.DeleteLog;
                    bool sql        = operationType == DbLogType.SQL.ToString();        // && settingInfo.DeleteLog;

                    if (insert || update || delete || deletesoft || exception || sql)
                    {
                        Log info = new Log();
                        info.ModuleName    = tableName;
                        info.Type          = operationType;
                        info.Description   = note;
                        info.Date          = info.CreatorTime = DateTime.Now;
                        info.CreatorUserId = CurrentUser.UserId;
                        info.Account       = CurrentUser.Account;
                        info.NickName      = CurrentUser.NickName;
                        info.OrganizeId    = CurrentUser.OrganizeId;
                        info.IPAddress     = CurrentUser.CurrentLoginIP;
                        info.IPAddressName = CurrentUser.IPAddressName;
                        info.Result        = true;
                        long lg = _iLogRepository.Insert(info);
                        if (lg > 0)
                        {
                            return(true);
                        }
                    }
                }
            }catch (Exception ex)
            {
                Log4NetHelper.Error("", ex);
                return(false);
            }
            return(false);
        }
Ejemplo n.º 9
0
        public async Task <IActionResult> ContentWxAppletQrCode([FromBody] ContentPlayBillModel info)
        {
            CommonResult      result            = new CommonResult();
            YuebonCacheHelper yuebonCacheHelper = new YuebonCacheHelper();

            try
            {
                if (info == null)
                {
                    return(ToJsonContent(result));
                }
                string page  = info.Page;   //此接口不可以带参数,如果需要加参数,必须加到scene中
                string scene = info.Scene;; //id=xxxxxx,scene最多允许32个字符
                int    width = string.IsNullOrEmpty(info.Width.ToString()) ? 480 : info.Width.ToInt();

                //图片名称
                string picname       = "ref" + width + GuidUtils.CreateNo() + ".png";
                var    _tempfilepath = "/upload/contentqrcode/";
                var    uploadPath    = _filePath + _tempfilepath;
                if (!Directory.Exists(uploadPath))
                {
                    Directory.CreateDirectory(uploadPath);
                }
                string       qrcodePicPath = uploadPath + picname;//小程序二维码图片
                MemoryStream ms            = new MemoryStream();
                if (!System.IO.File.Exists(qrcodePicPath))
                {
                    var resultImg = await WxAppApi.GetWxaCodeUnlimitAsync(WxOpenAppId, qrcodePicPath, scene, page, width, false, null, true);

                    if (resultImg.errcode == ReturnCode.请求成功)
                    {
                        result.Success = true;
                        result.ErrCode = ErrCode.successCode;
                        result.ResData = _tempfilepath + picname;
                    }
                    else
                    {
                        result.ErrCode = resultImg.errcode.ToString();
                        result.ErrMsg  = resultImg.errmsg;
                    }
                }
                else
                {
                    result.ErrCode = ErrCode.successCode;
                    result.ErrMsg  = _tempfilepath + picname;
                }
            }
            catch (Exception ex)
            {
                Log4NetHelper.Error("代码生成异常", ex);
                result.ErrMsg  = "代码生成异常:" + ex.Message;
                result.ErrCode = ErrCode.failCode;
            }
            return(ToJsonContent(result));
        }
Ejemplo n.º 10
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;
            }
        }
Ejemplo n.º 11
0
        public async Task <IActionResult> GetSysInfo()
        {
            CommonResult result = new CommonResult();

            try
            {
                SysSetting        sysSetting        = XmlConverter.Deserialize <SysSetting>("xmlconfig/sys.config");
                YuebonCacheHelper yuebonCacheHelper = new YuebonCacheHelper();
                yuebonCacheHelper.Add("SysSetting", sysSetting);
                DashboardOutModel dashboardOutModel = new DashboardOutModel();
                dashboardOutModel.CertificatedCompany = sysSetting.CompanyName;
                dashboardOutModel.WebUrl               = sysSetting.WebUrl;
                dashboardOutModel.Title                = sysSetting.SoftName;
                dashboardOutModel.MachineName          = Environment.MachineName;
                dashboardOutModel.ProcessorCount       = Environment.ProcessorCount;
                dashboardOutModel.SystemPageSize       = Environment.SystemPageSize;
                dashboardOutModel.WorkingSet           = Environment.WorkingSet;
                dashboardOutModel.TickCount            = Environment.TickCount;
                dashboardOutModel.RunTimeLength        = (Environment.TickCount / 1000).ToBrowseTime();
                dashboardOutModel.FrameworkDescription = RuntimeInformation.FrameworkDescription;
                dashboardOutModel.OSName               = RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? "Linux" : RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "OSX" : "Windows";
                dashboardOutModel.OSDescription        = RuntimeInformation.OSDescription + " " + RuntimeInformation.OSArchitecture;
                dashboardOutModel.OSArchitecture       = RuntimeInformation.OSArchitecture.ToString();
                dashboardOutModel.ProcessArchitecture  = RuntimeInformation.ProcessArchitecture.ToString();

                dashboardOutModel.Directory = AppContext.BaseDirectory;
                Version version = Environment.Version;
                dashboardOutModel.SystemVersion = version.Major + "." + version.Minor + "." + version.Build;
                dashboardOutModel.Version       = AppVersionHelper.Version;
                dashboardOutModel.Manufacturer  = AppVersionHelper.Manufacturer;
                dashboardOutModel.WebSite       = AppVersionHelper.WebSite;
                dashboardOutModel.UpdateUrl     = AppVersionHelper.UpdateUrl;
                dashboardOutModel.IPAdress      = Request.HttpContext.Connection.LocalIpAddress.ToString();
                dashboardOutModel.Port          = Request.HttpContext.Connection.LocalPort.ToString();
                dashboardOutModel.TotalUser     = await userService.GetCountByWhereAsync("1=1");

                dashboardOutModel.TotalModule = await menuService.GetCountByWhereAsync("1=1");

                dashboardOutModel.TotalRole = await roleService.GetCountByWhereAsync("1=1");

                dashboardOutModel.TotalTask = await taskManagerService.GetCountByWhereAsync("1=1");

                result.ResData = dashboardOutModel;
                result.ErrCode = ErrCode.successCode;
            }
            catch (Exception ex)
            {
                Log4NetHelper.Error("获取系统信息异常", ex);
                result.ErrMsg  = ErrCode.err60001;
                result.ErrCode = "60001";
            }
            return(ToJsonContent(result));
        }
Ejemplo n.º 12
0
        /// <summary>
        /// 数据库连接,根据数据库类型自动识别,类型区分用配置名称是否包含主要关键字
        /// MSSQL、MYSQL、ORACLE、SQLITE、MEMORY、NPGSQL
        /// </summary>
        /// <returns></returns>
        public DbConnection OpenSharedConnection()
        {
            YuebonCacheHelper   yuebonCacheHelper   = new YuebonCacheHelper();
            object              connCode            = yuebonCacheHelper.Get("CodeGeneratorDbConn");
            DbConnectionOptions dbConnectionOptions = DBServerProvider.GeDbConnectionOptions();
            DatabaseType        dbType = DatabaseType.SqlServer;

            if (connCode != null)
            {
                defaultSqlConnectionString = connCode.ToString();
                string dbTypeCache = yuebonCacheHelper.Get("CodeGeneratorDbType").ToString();
                dbType = (DatabaseType)Enum.Parse(typeof(DatabaseType), dbTypeCache);
            }
            else
            {
                defaultSqlConnectionString = dbConnectionOptions.ConnectionString;

                dbType = dbConnectionOptions.DatabaseType;
                TimeSpan expiresSliding = DateTime.Now.AddMinutes(30) - DateTime.Now;
                yuebonCacheHelper.Add("CodeGeneratorDbConn", defaultSqlConnectionString, expiresSliding, false);
                yuebonCacheHelper.Add("CodeGeneratorDbType", dbType, expiresSliding, false);
            }
            if (dbType == DatabaseType.SqlServer)
            {
                dbConnection = new SqlConnection(defaultSqlConnectionString);
            }
            else if (dbType == DatabaseType.MySql)
            {
                dbConnection = new MySqlConnection(defaultSqlConnectionString);
            }
            else if (dbType == DatabaseType.Oracle)
            {
                dbConnection = new OracleConnection(defaultSqlConnectionString);
            }
            else if (dbType == DatabaseType.SQLite)
            {
                dbConnection = new SqliteConnection(defaultSqlConnectionString);
            }
            else if (dbType == DatabaseType.Npgsql)
            {
                dbConnection = new NpgsqlConnection(defaultSqlConnectionString);
            }
            else
            {
                throw new NotSupportedException("The database is not supported");
            }
            if (dbConnection.State != ConnectionState.Open)
            {
                dbConnection.Open();
            }
            return(dbConnection);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 获取省可用的地区,用于select2下拉选项
        /// </summary>
        /// <returns></returns>
        public List <AreaSelect2OutDto> GetProvinceAll()
        {
            List <AreaSelect2OutDto> list = new List <AreaSelect2OutDto>();
            YuebonCacheHelper        yuebonCacheHelper = new YuebonCacheHelper();

            list = JsonConvert.DeserializeObject <List <AreaSelect2OutDto> >(yuebonCacheHelper.Get("Area_ProvinceToArea_Select2").ToJson());
            if (list == null || list.Count <= 0)
            {
                list = service.GetAllByIsNotDeleteAndEnabledMark("Layers =1").OrderBy(t => t.Id).ToList().MapTo <AreaSelect2OutDto>();

                yuebonCacheHelper.Add("Area_ProvinceToArea_Select2", list);
            }
            return(list);
        }
Ejemplo n.º 14
0
        public async Task <IActionResult> GetListDataBase()
        {
            YuebonCacheHelper yuebonCacheHelper = new YuebonCacheHelper();

            yuebonCacheHelper.Remove("CodeGeneratorDbConn");
            yuebonCacheHelper.Remove("CodeGeneratorDbName");
            CommonResult        result      = new CommonResult();
            DbExtractor         dbExtractor = new DbExtractor();
            List <DataBaseInfo> listTable   = dbExtractor.GetAllDataBases();

            result.ResData = listTable;
            result.ErrCode = ErrCode.successCode;
            return(ToJsonContent(result));
        }
Ejemplo n.º 15
0
        /// <summary>
        /// 获取所有可用的地区,用于uniapp下拉选项
        /// </summary>
        /// <returns></returns>
        public List <AreaPickerOutputDto> GetAllByEnable()
        {
            List <AreaPickerOutputDto> list = new List <AreaPickerOutputDto>();
            YuebonCacheHelper          yuebonCacheHelper = new YuebonCacheHelper();

            list = JsonConvert.DeserializeObject <List <AreaPickerOutputDto> >(yuebonCacheHelper.Get("Area_Enable_Uniapp").ToJson());
            if (list == null || list.Count <= 0)
            {
                List <Area> listFunction = _repository.GetAllByIsNotDeleteAndEnabledMark("Layers in (0,1,2)").OrderBy(t => t.SortCode).ToList();
                list = UniappViewJson(listFunction, "");
                yuebonCacheHelper.Add("Area_Enable_Uniapp", list);
            }
            return(list);
        }
Ejemplo n.º 16
0
        public IActionResult Save(SysSetting info)
        {
            CommonResult result = new CommonResult();

            info.LocalPath = _hostingEnvironment.WebRootPath;
            SysSetting sysSetting = XmlConverter.Deserialize <SysSetting>("xmlconfig/sys.config");

            sysSetting = info;
            //对关键信息加密
            if (!string.IsNullOrEmpty(info.Email))
            {
                sysSetting.Email = DEncrypt.Encrypt(info.Email);
            }
            if (!string.IsNullOrEmpty(info.Emailsmtp))
            {
                sysSetting.Emailsmtp = DEncrypt.Encrypt(info.Emailsmtp);
            }
            if (!string.IsNullOrEmpty(info.Emailpassword))
            {
                sysSetting.Emailpassword = DEncrypt.Encrypt(info.Emailpassword);
            }
            if (!string.IsNullOrEmpty(info.Smspassword))
            {
                sysSetting.Smspassword = DEncrypt.Encrypt(info.Smspassword);
            }
            if (!string.IsNullOrEmpty(info.Smsusername))
            {
                sysSetting.Smsusername = DEncrypt.Encrypt(info.Smsusername);
            }
            string uploadPath = _hostingEnvironment.WebRootPath + "/" + sysSetting.Filepath;

            if (!Directory.Exists(uploadPath))
            {
                Directory.CreateDirectory(uploadPath);
            }
            YuebonCacheHelper yuebonCacheHelper = new YuebonCacheHelper();

            if (yuebonCacheHelper.Exists("SysSetting"))
            {
                yuebonCacheHelper.Replace("SysSetting", sysSetting);
            }
            else
            {
                //写入缓存
                yuebonCacheHelper.Add("SysSetting", sysSetting);
            }
            XmlConverter.Serialize <SysSetting>(sysSetting, "xmlconfig/sys.config");
            result.ErrCode = ErrCode.successCode;
            return(ToJsonContent(result));
        }
Ejemplo n.º 17
0
        public override async Task <IActionResult> DeleteBatchAsync(DeletesInputDto info)
        {
            CommonResult result = new CommonResult();

            string where = string.Empty;
            where        = "id in ('" + info.Ids.Join(",").Trim(',').Replace(",", "','") + "')";

            if (!string.IsNullOrEmpty(where))
            {
                dynamic[] jobsId = info.Ids;
                foreach (var item in jobsId)
                {
                    if (string.IsNullOrEmpty(item.ToString()))
                    {
                        continue;
                    }
                    UploadFile        uploadFile        = new UploadFileApp().Get(item.ToString());
                    YuebonCacheHelper yuebonCacheHelper = new YuebonCacheHelper();
                    SysSetting        sysSetting        = yuebonCacheHelper.Get("SysSetting").ToJson().ToObject <SysSetting>();
                    if (uploadFile != null)
                    {
                        if (System.IO.File.Exists(sysSetting.LocalPath + "/" + uploadFile.FilePath))
                        {
                            System.IO.File.Delete(sysSetting.LocalPath + "/" + uploadFile.FilePath);
                        }
                        if (!string.IsNullOrEmpty(uploadFile.Thumbnail))
                        {
                            if (System.IO.File.Exists(sysSetting.LocalPath + "/" + uploadFile.Thumbnail))
                            {
                                System.IO.File.Delete(sysSetting.LocalPath + "/" + uploadFile.Thumbnail);
                            }
                        }
                    }
                }
                bool bl = await iService.DeleteBatchWhereAsync(where).ConfigureAwait(false);

                if (bl)
                {
                    result.ErrCode = ErrCode.successCode;
                    result.ErrMsg  = ErrCode.err0;
                }
                else
                {
                    result.ErrMsg  = ErrCode.err43003;
                    result.ErrCode = "43003";
                }
            }
            return(ToJsonContent(result));
        }
Ejemplo n.º 18
0
        /// <summary>
        /// 获取县区,用于select2下拉选项
        /// </summary>
        /// <param name="id">城市Id</param>
        /// <returns></returns>
        public List <AreaSelect2OutDto> GetDistrictByCityId(string id)
        {
            List <AreaSelect2OutDto> list = new List <AreaSelect2OutDto>();
            YuebonCacheHelper        yuebonCacheHelper = new YuebonCacheHelper();

            list = JsonConvert.DeserializeObject <List <AreaSelect2OutDto> >(yuebonCacheHelper.Get("Area_DistrictToArea_Enable_Select2" + id).ToJson());
            if (list == null || list.Count <= 0)
            {
                string sqlWhere = string.Format("ParentId='{0}'", id);
                list = service.GetAllByIsNotDeleteAndEnabledMark(sqlWhere).OrderBy(t => t.Id).ToList().MapTo <AreaSelect2OutDto>();

                yuebonCacheHelper.Add("Area_DistrictToArea_Enable_Select2" + id, list);
            }
            return(list);
        }
Ejemplo n.º 19
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));
        }
Ejemplo n.º 20
0
        public CommonResult <PageResult <DbTableInfo> > FindListTable(SearchModel search)
        {
            CommonResult <PageResult <DbTableInfo> > result = new CommonResult <PageResult <DbTableInfo> >();

            if (!string.IsNullOrEmpty(search.EnCode))
            {
                YuebonCacheHelper yuebonCacheHelper = new YuebonCacheHelper();
                object            connCode          = yuebonCacheHelper.Get("CodeGeneratorDbConn");
                if (connCode != null)
                {
                    string   SqlConnectionString = connCode.ToString();
                    string[] sqlconn             = SqlConnectionString.Split(";");
                    string[] dataName            = sqlconn[1].Split("=");
                    dataName[1] = search.EnCode;
                    sqlconn[1]  = dataName.Join("=");
                    string   newConnStr     = sqlconn.Join(";");
                    TimeSpan expiresSliding = DateTime.Now.AddMinutes(30) - DateTime.Now;
                    yuebonCacheHelper.Add("CodeGeneratorDbConn", newConnStr, expiresSliding, false);
                    yuebonCacheHelper.Add("CodeGeneratorDbName", search.EnCode, expiresSliding, false);
                }
            }
            string orderByDir = search.Order;
            string orderFlied = string.IsNullOrEmpty(search.Sort)? "TableName": search.Sort;
            bool   order      = orderByDir == "asc" ? false : true;

            string where = "1=1";
            if (!string.IsNullOrEmpty(search.Keywords))
            {
                where += " and TableName like '%" + search.Keywords + "%'";
            }
            PagerInfo pagerInfo = new PagerInfo {
                PageSize          = search.PageSize,
                CurrenetPageIndex = search.CurrenetPageIndex
            };
            DbExtractor        dbExtractor = new DbExtractor();
            List <DbTableInfo> listTable   = dbExtractor.GetTablesWithPage(search.Keywords, orderFlied, order, pagerInfo);

            PageResult <DbTableInfo> pageResult = new PageResult <DbTableInfo>();

            pageResult.CurrentPage  = pagerInfo.CurrenetPageIndex;
            pageResult.Items        = listTable;
            pageResult.ItemsPerPage = pagerInfo.PageSize;
            pageResult.TotalItems   = pagerInfo.RecordCount;
            result.ResData          = pageResult;
            result.ErrCode          = ErrCode.successCode;
            return(result);
        }
Ejemplo n.º 21
0
        /// <summary>
        /// 验证appId是否被允许
        /// </summary>
        /// <param name="appId"></param>
        /// <returns></returns>
        private static AllowCacheApp VerifyAppId(string appId)
        {
            AllowCacheApp allowCacheApp = new AllowCacheApp();

            if (string.IsNullOrEmpty(appId))
            {
                return(allowCacheApp);
            }
            YuebonCacheHelper    yuebonCacheHelper = new YuebonCacheHelper();
            List <AllowCacheApp> list = yuebonCacheHelper.Get("AllowAppId").ToJson().ToList <AllowCacheApp>();

            if (list.Count > 0)
            {
                allowCacheApp = list.Where(s => s.AppId == appId).FirstOrDefault();
            }
            return(allowCacheApp);
        }
Ejemplo n.º 22
0
        public IActionResult Logout()
        {
            CommonResult      result            = new CommonResult();
            YuebonCacheHelper yuebonCacheHelper = new YuebonCacheHelper();

            yuebonCacheHelper.Remove("login_user_" + CurrentUser.UserId);
            yuebonCacheHelper.Remove("User_Function_" + CurrentUser.UserId);
            UserLogOn userLogOn = _userLogOnService.GetWhere("UserId='" + CurrentUser.UserId + "'");

            userLogOn.UserOnLine = false;
            _userLogOnService.Update(userLogOn, userLogOn.Id);
            CurrentUser    = null;
            result.Success = true;
            result.ErrCode = ErrCode.successCode;
            result.ErrMsg  = "成功退出";
            return(ToJsonContent(result));
        }
Ejemplo n.º 23
0
        public DbExtractor()
        {
            MssqlExtractor mssqlExtractor = new MssqlExtractor();

            mssqlExtractor.OpenSharedConnection();
            YuebonCacheHelper yuebonCacheHelper = new YuebonCacheHelper();
            string            dbTypeCache       = yuebonCacheHelper.Get("CodeGeneratorDbType").ToString();

            if (dbTypeCache != null)
            {
                dbType = (DatabaseType)Enum.Parse(typeof(DatabaseType), dbTypeCache);
            }
            object odbn = yuebonCacheHelper.Get("CodeGeneratorDbName");

            if (odbn != null)
            {
                dbName = odbn.ToString();
            }
        }
Ejemplo n.º 24
0
        public async Task <IActionResult> ContentWxAppletQrCodeRes([FromQuery] ContentPlayBillModel info)
        {
            CommonResult      result            = new CommonResult();
            YuebonCacheHelper yuebonCacheHelper = new YuebonCacheHelper();
            MemoryStream      ms = new MemoryStream();

            try
            {
                if (info == null)
                {
                    return(ToJsonContent(result));
                }
                string page      = info.Page;   //此接口不可以带参数,如果需要加参数,必须加到scene中
                string scene     = info.Scene;; //id=xxxxxx,scene最多允许32个字符
                int    width     = string.IsNullOrEmpty(info.Width.ToString()) ? 480 : info.Width.ToInt();
                var    resultImg = await WxAppApi.GetWxaCodeUnlimitAsync(WxOpenAppId, ms, scene, page, width);

                ms.Position = 0;
                if (resultImg.errcode == ReturnCode.请求成功)
                {
                    var imgBase64 = Convert.ToBase64String(ms.GetBuffer());
                    result.Success = true;
                    result.ErrCode = ErrCode.successCode;
                    result.ResData = imgBase64;
                }
                else
                {
                    result.ErrCode = resultImg.errcode.ToString();
                    result.ErrMsg  = resultImg.errmsg;
                }
            }
            catch (Exception ex)
            {
                Log4NetHelper.Error("代码生成异常", ex);
                result.ErrMsg  = "代码生成异常:" + ex.Message;
                result.ErrCode = ErrCode.failCode;
            }
            finally{
                ms.Dispose();
            }
            return(ToJsonContent(result));
        }
Ejemplo n.º 25
0
        public IActionResult DeleteFile(string id)
        {
            CommonResult result = new CommonResult();

            try
            {
                UploadFile uploadFile = new UploadFileApp().Get(id);

                YuebonCacheHelper yuebonCacheHelper = new YuebonCacheHelper();
                SysSetting        sysSetting        = yuebonCacheHelper.Get("SysSetting").ToJson().ToObject <SysSetting>();
                string            localpath         = _hostingEnvironment.WebRootPath;
                if (uploadFile != null)
                {
                    string filepath = (localpath + "/" + uploadFile.FilePath).ToFilePath();
                    if (System.IO.File.Exists(filepath))
                    {
                        System.IO.File.Delete(filepath);
                    }
                    string filepathThu = (localpath + "/" + uploadFile.Thumbnail).ToFilePath();
                    if (System.IO.File.Exists(filepathThu))
                    {
                        System.IO.File.Delete(filepathThu);
                    }

                    result.ErrCode = ErrCode.successCode;
                    result.Success = true;
                }
                else
                {
                    result.ErrCode = ErrCode.failCode;
                    result.Success = false;
                }
            }
            catch (Exception ex)
            {
                Log4NetHelper.Error("", ex);
                result.ErrCode = "500";
                result.ErrMsg  = ex.Message;
            }
            return(ToJsonContent(result));
        }
Ejemplo n.º 26
0
        public async Task <CommonResult <AuthGetVerifyCodeOutputDto> > CaptchaAsync()
        {
            Captcha captcha = new Captcha();
            var     code    = await captcha.GenerateRandomCaptchaAsync().ConfigureAwait(false);

            var result = await captcha.GenerateCaptchaImageAsync(code);

            YuebonCacheHelper yuebonCacheHelper = new YuebonCacheHelper();
            TimeSpan          expiresSliding    = DateTime.Now.AddMinutes(5) - DateTime.Now;

            yuebonCacheHelper.Add("ValidateCode" + result.Timestamp.ToString("yyyyMMddHHmmssffff"), code, expiresSliding, false);
            AuthGetVerifyCodeOutputDto authGetVerifyCodeOutputDto = new AuthGetVerifyCodeOutputDto();

            authGetVerifyCodeOutputDto.Img = Convert.ToBase64String(result.CaptchaMemoryStream.ToArray());
            authGetVerifyCodeOutputDto.Key = result.Timestamp.ToString("yyyyMMddHHmmssffff");
            CommonResult <AuthGetVerifyCodeOutputDto> commonResult = new CommonResult <AuthGetVerifyCodeOutputDto>();

            commonResult.ErrCode = ErrCode.successCode;
            commonResult.ResData = authGetVerifyCodeOutputDto;
            return(commonResult);
        }
Ejemplo n.º 27
0
        /// <summary>
        /// 判断当前用户是否拥有某功能点的权限
        /// </summary>
        /// <param name="functionCode">功能编码code</param>
        /// <param name="userId">用户id</param>
        /// <returns></returns>
        public static bool HasFunction(string functionCode, string userId)
        {
            bool hasFunction = false;

            if (!string.IsNullOrEmpty(userId))
            {
                if (string.IsNullOrEmpty(functionCode))
                {
                    hasFunction = true;
                }
                else
                {
                    List <MenuOutputDto> listFunction = new YuebonCacheHelper().Get("User_Function_" + userId).ToJson().ToList <MenuOutputDto>();
                    if (listFunction != null && listFunction.Count(t => t.EnCode == functionCode) > 0)
                    {
                        hasFunction = true;
                    }
                }
            }
            return(hasFunction);
        }
Ejemplo n.º 28
0
        public IActionResult GetInfo()
        {
            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");
            }
            sysSetting.Email         = "";
            sysSetting.Emailsmtp     = "";
            sysSetting.Emailpassword = "";
            sysSetting.Smspassword   = "";
            sysSetting.SmsSignName   = "";
            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";
            }

            IEnumerable <APP> appList = aPPService.GetAllByIsNotDeleteAndEnabledMark();

            yuebonCacheHelper.Add("AllowAppId", appList);
            return(ToJsonContent(result));
        }
Ejemplo n.º 29
0
        /// <summary>
        /// 获取省、市、县/区三级可用的地区,用于uniapp下拉选项
        /// </summary>
        /// <returns></returns>
        public List <AreaPickerOutputDto> GetProvinceToAreaByEnable()
        {
            List <AreaPickerOutputDto> list = new List <AreaPickerOutputDto>();
            YuebonCacheHelper          yuebonCacheHelper = new YuebonCacheHelper();

            list = JsonConvert.DeserializeObject <List <AreaPickerOutputDto> >(yuebonCacheHelper.Get("Area_ProvinceToArea_Enable_Uniapp").ToJson());
            if (list == null || list.Count <= 0)
            {
                List <Area> listFunctionTemp = _repository.GetAllByIsNotDeleteAndEnabledMark("Layers in (1,2,3)").OrderBy(t => t.Id).ToList();
                List <Area> listFunction     = new List <Area>();
                foreach (Area item in listFunctionTemp)
                {
                    if (item.Layers == 1)
                    {
                        item.ParentId = "";
                    }
                    listFunction.Add(item);
                }

                list = UniappViewJson(listFunction, "");
                yuebonCacheHelper.Add("Area_ProvinceToArea_Enable_Uniapp", list);
            }
            return(list);
        }
Ejemplo n.º 30
0
        public async Task <IActionResult> RegisterAsync(RegisterViewModel tinfo)
        {
            CommonResult      result            = new CommonResult();
            YuebonCacheHelper yuebonCacheHelper = new YuebonCacheHelper();
            var    vCode = yuebonCacheHelper.Get("ValidateCode" + tinfo.VerifyCodeKey);
            string code  = vCode != null?vCode.ToString() : "11";

            if (code != tinfo.VerificationCode.ToUpper())
            {
                result.ErrMsg = "验证码错误";
                return(ToJsonContent(result));
            }
            if (!string.IsNullOrEmpty(tinfo.Account))
            {
                if (string.IsNullOrEmpty(tinfo.Password) || tinfo.Password.Length < 6)
                {
                    result.ErrMsg = "密码不能为空或小于6位";
                    return(ToJsonContent(result));
                }
                User user = await iService.GetByUserName(tinfo.Account);

                if (user != null)
                {
                    result.ErrMsg = "登录账号不能重复";
                    return(ToJsonContent(result));
                }
            }
            else
            {
                result.ErrMsg = "登录账号不能为空";
                return(ToJsonContent(result));
            }
            User info = new User();

            info.Id              = GuidUtils.CreateNo();
            info.Account         = tinfo.Account;
            info.Email           = tinfo.Email;
            info.CreatorTime     = DateTime.Now;
            info.CreatorUserId   = info.Id;
            info.OrganizeId      = "";
            info.EnabledMark     = true;
            info.IsAdministrator = false;
            info.IsMember        = true;
            info.RoleId          = roleService.GetRole("usermember").Id;
            info.DeleteMark      = false;
            info.SortCode        = 99;

            UserLogOn userLogOn = new UserLogOn();

            userLogOn.UserPassword   = tinfo.Password;
            userLogOn.AllowStartTime = userLogOn.LockEndDate = userLogOn.LockStartDate = userLogOn.ChangePasswordDate = DateTime.Now;
            userLogOn.AllowEndTime   = DateTime.Now.AddYears(100);
            userLogOn.MultiUserLogin = userLogOn.CheckIPAddress = false;
            userLogOn.LogOnCount     = 0;
            result.Success           = await iService.InsertAsync(info, userLogOn);

            if (result.Success)
            {
                yuebonCacheHelper.Remove("ValidateCode");
                result.ErrCode = ErrCode.successCode;
                result.ErrMsg  = ErrCode.err0;
            }
            else
            {
                result.ErrMsg  = ErrCode.err43001;
                result.ErrCode = "43001";
            }
            return(ToJsonContent(result));
        }