/// <summary>
        /// 系统注册
        /// </summary>
        /// <param name="dto"></param>
        /// <exception cref="BIStudio.Framework.DefinedException"></exception>
        public void SystemRegist(SYSSystemRegistDTO dto)
        {
            if (string.IsNullOrEmpty(dto.SystemName) || string.IsNullOrEmpty(dto.SystemCode))
            {
                throw CFException.Create(SYSSystemRegistResult.NameOrCodeNotFound);
            }
            try
            {
                var system = _systemRepository.Get(item => item.SystemCode == dto.SystemCode);
                if (system.ID.HasValue)
                {
                    if (system.GetVersion() > dto.GetVersion())
                    {
                        throw CFException.Create(SYSSystemRegistResult.CodeAlreadyExists);
                    }
                }
                else
                {
                    system = new SYSSystem(dto.SystemCode);
                }

                system = CFMapper.Map(dto, system);
                if (system.ID.HasValue)
                {
                    _systemRepository.Modify(system);
                }
                else
                {
                    _systemRepository.Add(system);
                }
                return;
            }
            catch (Exception ex)
            {
                throw CFException.Create(SYSSystemRegistResult.Fail, ex.Message, ex);
            }
        }
        /// <summary>
        /// 为指定系统颁发新证书
        /// </summary>
        /// <param name="dto"></param>
        /// <exception cref="BIStudio.Framework.DefinedException"></exception>
        public SYSSystemCertificate CertificateIssue(SYSSystemCertificateIssueDTO dto)
        {
            if (string.IsNullOrEmpty(dto.SystemCode) || string.IsNullOrEmpty(dto.ApiKey) || string.IsNullOrEmpty(dto.CertificateName))
            {
                throw CFException.Create(STDCertificateIssueResult.NameOrCodeNotFound);
            }

            try
            {
                SYSSystem system = _systemRepository.Get(item => item.SystemCode == dto.SystemCode);
                if (system.ID == null)
                {
                    throw CFException.Create(STDCertificateIssueResult.SystemCodeInvalid);
                }

                SYSSystemCertificate entity = dto.Map <SYSSystemCertificateIssueDTO, SYSSystemCertificate>();
                var prevCertificate         = _certificateRepository.Get(item => item.ApiKey == dto.ApiKey);
                if (prevCertificate.ID.HasValue)
                {
                    throw CFException.Create(STDCertificateIssueResult.CodeAlreadyExists);
                }

                entity.SystemID  = system.ID;
                entity.ApiKey    = entity.ApiKey;
                entity.Secret    = ALUtils.GetGUIDShort();
                entity.IsValid   = true;
                entity.InputTime = DateTime.Now;
                entity.Inputer   = CFContext.User.UserName;
                entity.InputerID = CFContext.User.ID;
                _certificateRepository.Add(entity);
                return(entity);
            }
            catch (Exception ex)
            {
                throw CFException.Create(STDCertificateIssueResult.Fail, ex.Message, ex);
            }
        }