Ejemplo n.º 1
0
        /// <summary>
        /// 创建项目,当名字不存在时
        /// </summary>
        /// <param name="projectName">项目名字</param>
        /// <returns>项目信息</returns>
        public Task <ProjectInfo> AddWhenNotExistAsync(string projectName)
        {
            projectName.NotNull("项目名称不能为空");
            var projectInfo = new ProjectInfo
            {
                FCreateTime   = DateTimeUtil.Now,
                FIsDeleted    = false,
                FName         = projectName,
                FCreateUserID = -1
            };

            return(LockUtil.ExecuteWithLockAsync(Lock_ProjectModify, projectName, TimeSpan.FromMinutes(2), async() =>
            {
                var existProjectInfo = await _projectRepository.GetInfoAsync(m => m.FIsDeleted == false && m.FName == projectName);
                if (existProjectInfo != null)
                {
                    return existProjectInfo;
                }
                else
                {
                    int projectID = (await _projectRepository.InsertOneAsync(projectInfo, keyName: "FID", ignoreFields: IgnoreConstant.FID)).ToSafeInt32(0);
                    projectInfo.FID = projectID;
                    ProjectChanged(OperateType.Add, projectID);
                    return projectInfo;
                }
            }));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 添加数据库信息,当数据库信息不存在时
        /// </summary>
        /// <param name="dbName">数据库名字</param>
        /// <param name="dbType">数据库类型</param>
        /// <returns>数据库信息</returns>
        public Task <DatabaseInfo> AddWhenNotExistAsync(string dbName, string dbType)
        {
            dbName.NotNull("数据库名称不能为空");
            dbType.NotNull("数据库类型不能为空");
            var databaseInfo = new DatabaseInfo
            {
                FCreateTime   = DateTimeUtil.Now,
                FIsDeleted    = false,
                FName         = dbName,
                FCreateUserID = -1,
                FDbType       = dbType ?? string.Empty
            };

            return(LockUtil.ExecuteWithLockAsync(Lock_DatabaseModify, dbName, TimeSpan.FromMinutes(2), async() =>
            {
                var existDbInfo = await _databaseRepository.GetInfoAsync(m => m.FIsDeleted == false && m.FName == dbName && m.FDbType == databaseInfo.FDbType);
                if (existDbInfo != null)
                {
                    return existDbInfo;
                }
                else
                {
                    int dbID = (await _databaseRepository.InsertOneAsync(databaseInfo, keyName: "FID", ignoreFields: IgnoreConstant.FID)).ToSafeInt32(0);
                    databaseInfo.FID = dbID;
                    DatabaseChanged(OperateType.Add, dbID);
                    return databaseInfo;
                }
            }));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 创建服务器,当名字不存在时
        /// </summary>
        /// <param name="servicerMac">Mac地址</param>
        /// <returns>项目信息</returns>
        public Task <ServicerInfo> AddWhenNotExistAsync(string servicerMac)
        {
            servicerMac.NotNull("Mac地址不能为空");
            var servicerInfo = new ServicerInfo
            {
                FCreateTime   = DateTimeUtil.Now,
                FIsDeleted    = false,
                FMacAddress   = servicerMac,
                FCreateUserID = -1
            };

            return(LockUtil.ExecuteWithLockAsync(Lock_ServicerModify, servicerMac, TimeSpan.FromMinutes(2), async() =>
            {
                var existServicerInfo = await _servicerRepository.GetInfoAsync(m => m.FIsDeleted == false && m.FMacAddress == servicerMac);
                if (existServicerInfo != null)
                {
                    return existServicerInfo;
                }
                else
                {
                    int servicerID = (await _servicerRepository.InsertOneAsync(servicerInfo, keyName: "FID", ignoreFields: IgnoreConstant.FID)).ToSafeInt32(0);
                    servicerInfo.FID = servicerID;
                    ServicerChanged(OperateType.Add, servicerID);
                    return servicerInfo;
                }
            }));
        }
Ejemplo n.º 4
0
 /// <summary>
 /// 添加项目信息
 /// </summary>
 /// <param name="projectModel">项目信息</param>
 /// <returns>操作结果</returns>
 public Task <OperateResult> AddProjectAsync(ProjectModel projectModel)
 {
     return(OperateUtil.ExecuteAsync(async() =>
     {
         var projectInfo = _projectDomainService.Create(projectModel);
         int id = await LockUtil.ExecuteWithLockAsync(Lock_ProjectModify, projectInfo.FName, TimeSpan.FromMinutes(2), async() =>
         {
             await _projectDomainService.CheckAsync(projectInfo);
             int projectID = (await _projectRepository.InsertOneAsync(projectInfo, keyName: "FID", ignoreFields: FID)).ToSafeInt32(0);
             _operateLogDomainService.AddOperateLog(projectModel.OperateUserID.Value, OperateModule.Project, OperateModuleNode.Add, $"添加:{projectInfo.GetOperateDesc()}");
             _projectDomainService.ProjectChanged(OperateType.Add, projectID);
             return projectID;
         }, defaultValue: -1);
         if (id <= 0)
         {
             throw new BizException("添加失败");
         }
     }, callMemberName: "ProjectApplication-AddProjectAsync"));
 }
Ejemplo n.º 5
0
 /// <summary>
 /// 修改项目信息
 /// </summary>
 /// <param name="projectModel">项目信息</param>
 /// <returns>操作结果</returns>
 public Task <OperateResult> EditProjectAsync(ProjectModel projectModel)
 {
     return(OperateUtil.ExecuteAsync(async() =>
     {
         var projectInfo = _projectDomainService.Create(projectModel);
         var flag = await LockUtil.ExecuteWithLockAsync(Lock_ProjectModify, projectInfo.FName, TimeSpan.FromMinutes(2), async() =>
         {
             await _projectDomainService.CheckAsync(projectInfo);
             await _projectRepository.UpdateAsync(projectInfo, m => m.FID == projectInfo.FID, ignoreFields: IDAndCreate);
             _operateLogDomainService.AddOperateLog(projectModel.OperateUserID.Value, OperateModule.SysConfig, OperateModuleNode.Edit, $"{projectInfo.GetOperateDesc()}");
             _projectDomainService.ProjectChanged(OperateType.Modify, projectInfo.FID);
             return true;
         }, defaultValue: false);
         if (!flag)
         {
             throw new BizException("修改失败");
         }
     }, callMemberName: "ProjectApplication-EditProjectAsync"));
 }
Ejemplo n.º 6
0
 /// <summary>
 /// 添加数据库信息
 /// </summary>
 /// <param name="databaseModel">数据库信息</param>
 /// <returns>操作结果</returns>
 public Task <OperateResult> AddDatabaseAsync(DatabaseModel databaseModel)
 {
     return(OperateUtil.ExecuteAsync(async() =>
     {
         var dbInfo = _databaseDomainService.Create(databaseModel);
         int id = await LockUtil.ExecuteWithLockAsync(Lock_DatabaseModify, dbInfo.FName, TimeSpan.FromMinutes(2), async() =>
         {
             await _databaseDomainService.CheckAsync(dbInfo);
             int dbID = (await _databaseRepository.InsertOneAsync(dbInfo, keyName: "FID", ignoreFields: FID)).ToSafeInt32(0);
             _operateLogDomainService.AddOperateLog(databaseModel.OperateUserID.Value, OperateModule.Database, OperateModuleNode.Add, $"添加:{dbInfo.GetOperateDesc()}");
             _databaseDomainService.DatabaseChanged(OperateType.Add, dbID);
             return dbID;
         }, defaultValue: -1);
         if (id <= 0)
         {
             throw new BizException("添加失败");
         }
     }, callMemberName: "DatabaseApplication-AddDatabaseAsync"));
 }
Ejemplo n.º 7
0
 /// <summary>
 /// 添加配置信息
 /// </summary>
 /// <param name="sysConfigModel">配置信息</param>
 /// <returns>操作结果</returns>
 public Task <OperateResult> AddConfigAsync(SysConfigModel sysConfigModel)
 {
     return(OperateUtil.ExecuteAsync(async() =>
     {
         var sysConfigInfo = _sysConfigDomainService.Create(sysConfigModel);
         int id = await LockUtil.ExecuteWithLockAsync(Lock_SysConfigModify, sysConfigInfo.FKey, TimeSpan.FromMinutes(2), async() =>
         {
             await _sysConfigDomainService.CheckAsync(sysConfigInfo);
             var configID = (await _sysConfigRepository.InsertOneAsync(sysConfigInfo, keyName: "FID", ignoreFields: FID)).ToSafeInt32(0);
             _operateLogDomainService.AddOperateLog(sysConfigModel.OperateUserID.Value, OperateModule.SysConfig, OperateModuleNode.Add, $"{sysConfigInfo.GetOperateDesc()}");
             _sysConfigDomainService.ConfigChanged(OperateType.Add, configID);
             return configID;
         }, defaultValue: -1);
         if (id <= 0)
         {
             throw new BizException("添加失败");
         }
     }, callMemberName: "SysConfigApplication-AddConfigAsync"));
 }
Ejemplo n.º 8
0
 /// <summary>
 /// 修改服务器信息
 /// </summary>
 /// <param name="servicerModel">服务器信息</param>
 /// <returns>操作结果</returns>
 public Task <OperateResult> EditServicerAsync(ServicerModel servicerModel)
 {
     return(OperateUtil.ExecuteAsync(async() =>
     {
         var servicerInfo = _servcerDomainService.Create(servicerModel);
         var flag = await LockUtil.ExecuteWithLockAsync(Lock_ServicerModify, servicerInfo.FMacAddress, TimeSpan.FromMinutes(2), async() =>
         {
             await _servcerDomainService.CheckAsync(servicerInfo);
             await _servcerRepository.UpdateAsync(servicerInfo, m => m.FID == servicerInfo.FID, ignoreFields: IDAndCreate);
             _operateLogDomainService.AddOperateLog(servicerModel.OperateUserID, OperateModule.Servicer, OperateModuleNode.Edit, $"修改:{servicerInfo.GetOperateDesc()}");
             _servcerDomainService.ServicerChanged(OperateType.Modify, servicerInfo.FID);
             return true;
         }, defaultValue: false);
         if (!flag)
         {
             throw new BizException("修改失败");
         }
     }, callMemberName: "ServicerApplication-AddServicerAsync"));
 }
Ejemplo n.º 9
0
 /// <summary>
 /// 添加服务器信息
 /// </summary>
 /// <param name="servicerModel">服务器信息</param>
 /// <returns>操作结果</returns>
 public Task <OperateResult> AddServicerAsync(ServicerModel servicerModel)
 {
     return(OperateUtil.ExecuteAsync(async() =>
     {
         var servicerInfo = _servcerDomainService.Create(servicerModel);
         int id = await LockUtil.ExecuteWithLockAsync(Lock_ServicerModify, servicerInfo.FMacAddress, TimeSpan.FromMinutes(2), async() =>
         {
             await _servcerDomainService.CheckAsync(servicerInfo);
             int servicerID = (await _servcerRepository.InsertOneAsync(servicerInfo, keyName: "FID", ignoreFields: FID)).ToSafeInt32(0);
             _operateLogDomainService.AddOperateLog(servicerModel.OperateUserID, OperateModule.Servicer, OperateModuleNode.Add, $"添加:{servicerInfo.GetOperateDesc()}");
             _servcerDomainService.ServicerChanged(OperateType.Add, servicerID);
             return servicerID;
         }, defaultValue: -1);
         if (id <= 0)
         {
             throw new BizException("添加失败");
         }
     }, callMemberName: "ServicerApplication-AddServicerAsync"));
 }