コード例 #1
0
        public async Task Handle(OrganizationCreatedEvent notification, CancellationToken cancellationToken)
        {
            var systemRoleId = SystemRole.NormalUser.Id;

            if (notification.Organization.OrganizationTypeId == OrganizationType.ServiceProvider.Id)
            {
                systemRoleId = SystemRole.ApplicationManager.Id;
            }
            else if (notification.Organization.OrganizationTypeId == OrganizationType.Brand.Id)
            {
                systemRoleId = SystemRole.BrandOrganizationAdmin.Id;
            }
            else if (notification.Organization.OrganizationTypeId == OrganizationType.Partner.Id)
            {
                systemRoleId = SystemRole.PartnerOrganizationAdmin.Id;
            }
            else if (notification.Organization.OrganizationTypeId == OrganizationType.Supplier.Id)
            {
                systemRoleId = SystemRole.SupplierOrganizationAdmin.Id;
            }
            else
            {
            }

            var owner = new Account("Admin", "", MD5Gen.CalcString(DomainPasswordConst.NormalPassword), notification.Organization.Mail, notification.Organization.Phone, systemRoleId, notification.Organization.Id, DomainEntityDefaultIdConst.SoftwareProviderAdminId);

            owner.SignLegalPerson();

            //如果是软件供应商,设置一下管理员的id
            if (notification.Organization.Id == DomainEntityDefaultIdConst.SoftwareProviderOrganizationId)
            {
                owner.CustomizeId(DomainEntityDefaultIdConst.SoftwareProviderAdminId);
            }
            await accountRepository.AddAsync(owner);

            var organ = await organizationRepository.FindAsync(owner.OrganizationId);

            organ.SetOwner(owner.Id);
            await organizationRepository.UpdateAsync(organ);

            //var systemRoleId = SystemRole.BrandOrganizationAdmin.Id;
            ////如果是软件供应商,设置一下管理员的默认角色Id
            //if (notification.Organization.Id == DomainEntityDefaultIdConst.SoftwareProviderOrganizationId)
            //    systemRoleId = SystemRole.ApplicationManager.Id;

            //var owner = new Account("Admin", MD5Gen.CalcString(DomainPasswordConst.NormalPassword), notification.Organization.Mail, notification.Organization.Phone, systemRoleId, notification.Organization.Id, DomainEntityDefaultIdConst.SoftwareProviderAdminId);
            //owner.SignLegalPerson();
            ////如果是软件供应商,设置一下管理员的id
            //if (notification.Organization.Id == DomainEntityDefaultIdConst.SoftwareProviderOrganizationId)
            //    owner.CustomizeId(DomainEntityDefaultIdConst.SoftwareProviderAdminId);
            //await accountRepository.AddAsync(owner);

            //var organ = await organizationRepository.FindAsync(owner.OrganizationId);
            //organ.SetOwner(owner.Id);
            //await organizationRepository.UpdateAsync(organ);
        }
コード例 #2
0
 public Identity(string username, string password, string name, string email, string phone, string creator)
 {
     Id           = GuidGen.NewGUID();
     Username     = username;
     Password     = MD5Gen.CalcString(password);
     Name         = name;
     Email        = email;
     Phone        = phone;
     Creator      = creator;
     Modifier     = Creator;
     CreatedTime  = DateTime.UtcNow.ToUnixTimeSeconds();
     ModifiedTime = CreatedTime;
 }
コード例 #3
0
 public Identity(string username, string password, string name, string email, string phone, string organizationId, string creator)
 {
     Id             = GuidGen.NewGUID();
     Username       = username;
     Password       = MD5Gen.CalcString(password);
     Name           = name;
     Email          = email;
     Phone          = phone;
     OrganizationId = organizationId;
     Creator        = creator;
     Modifier       = Creator;
     CreatedTime    = DateTime.UtcNow;
     ModifiedTime   = CreatedTime;
 }
コード例 #4
0
        public GetIdentityByUsernameAndPassword(string username, string password)
        {
            var aaa = MD5Gen.CalcString(password);

            Criteria = m => (m.Username == username || m.Email == username || m.Phone == username) && m.Password == MD5Gen.CalcString(password);
        }