public override CoreServiceResponse <ApplicationRegistration.Application> LimitNotReachedAction()
        {
            string       ApplicationName = ProcessDescriptor.Application.Name;
            Organization org             = User.Organizations.Where(o => o.Name.Equals(OrganizationName)).FirstOrDefault();

            ApplicationRegistration.Application app = CoreRegistryRepository.OneApplicationWhere(c => c.Name == ApplicationName && c.OrganizationId == org.Id);
            if (app == null)
            {
                app = new ApplicationRegistration.Application {
                    Name = ApplicationName, OrganizationId = org.Id
                };
                app = CoreRegistryRepository.Save(app);
                ProcessDescriptor instance = new ProcessDescriptor {
                    InstanceIdentifier = $"{ClientIpAddress}-{app.Name}-{app.Cuid}"
                };
                app.Instances.Add(instance);
                app.Machines.Add(new Machine {
                    Name = HostName
                });
                app = CoreApplicationRegistryService.AddApiKey(CoreRegistryRepository, app);
                return(new CoreServiceResponse <ApplicationRegistration.Application>(app)
                {
                    Success = true, Message = $"Application {ApplicationName} created"
                });
            }
            else
            {
                return(new CoreServiceResponse <ApplicationRegistration.Application>(app)
                {
                    Success = true, Message = $"Application {ApplicationName} already registered for the organization {OrganizationName}"
                });
            }
        }
Exemple #2
0
 public virtual string GetApplicationApiKey(string applicationClientId, int index)
 {
     ApplicationRegistration.Application app = CoreRegistryRepository.OneApplicationWhere(c => c.Cuid == applicationClientId);
     if (app != null)
     {
         return(app.ApiKeys[index]?.SharedSecret);
     }
     return(string.Empty);
 }
Exemple #3
0
 public string GetApplicationClientId(IApplicationNameProvider nameProvider)
 {
     ApplicationRegistration.Application app = CoreRegistryRepository.OneApplicationWhere(c => c.Name == nameProvider.GetApplicationName());
     return(app?.Cuid);
 }