public EnvironmentDto Post(EnvironmentDto request)
        {
            using (var session = DocumentStore.OpenSession())
            {
                session.Store(request);
                session.SaveChanges();

                return request;
            }
        }
Esempio n. 2
0
 internal static Environment FromDto(EnvironmentDto dto)
 {
     return(new Environment
     {
         Id = dto.Id.Value,
         Name = dto.Name,
         Description = dto.Description,
         Type = dto.Type.ToString(),
     });
 }
Esempio n. 3
0
 public static Environment FromDto(EnvironmentDto environmentDto)
 {
     return(new Environment
     {
         Name = environmentDto.Name,
         RemoteUrl = new Uri(environmentDto.RemoteUrl),
         Id = environmentDto.Id,
         Deploy = Models.Deploy.FromDto(environmentDto.Deploy)
     });
 }
Esempio n. 4
0
        public EnvironmentDto ConvertToDTO()
        {
            EnvironmentDto envDto = new EnvironmentDto();

            envDto.Id   = this.Id;
            envDto.Ip   = this.Ip;
            envDto.Url  = this.Url;
            envDto.Name = this.Name;
            return(envDto);
        }
Esempio n. 5
0
        public void CanBeConstructed()
        {
            //Arrange
            EnvironmentDto sut;

            //Act
            sut = new EnvironmentDto();

            //Assert
            Assert.NotNull(sut);
        }
        public EnvironmentDto Put(EnvironmentDto request)
        {
            using (var session = DocumentStore.OpenSession())
            {
                var environment = session.Load<Environment>("Environments/" + request.Id);
                environment.PopulateWith(request);

                session.SaveChanges();

                return environment.ToDto();
            }
        }
        public EnvironmentDto Put(EnvironmentDto request)
        {
            using (var session = DocumentStore.OpenSession())
            {
                var environment = session.Load <Environment>("Environments/" + request.Id);
                environment.PopulateWith(request);

                session.SaveChanges();

                return(environment.ToDto());
            }
        }
Esempio n. 8
0
        public async Task It_should_found()
        {
            using TestServer server = TestServer(UserRole.Administrator);
            using HttpClient client = server.CreateHttpClient();
            HttpResponseMessage result = await client.GetAsync($"features/application/{DataSeed.Application1.Code}/environment/Environment2");

            Assert.Equal(HttpStatusCode.OK, result.StatusCode);
            Log.WriteLine(result.Content.ReadAsStringAsync().Result);
            EnvironmentDto env = result.Deserialize <EnvironmentDto>();

            Assert.Equal("Environment2", env.Code);
        }
        public ActionResult Create([FromHeader] Guid apiKey, [FromBody] EnvironmentDto environment)
        {
            var id = Guid.NewGuid();

            if (environment is null)
            {
                return(BadRequest());
            }
            var env = Environment.FromDto(environment);

            env.Id = id;
            publisher.Add(env);
            return(Created($"/environment/{id}", env.ToDto()));
        }
Esempio n. 10
0
        private List <RuleDto> GetApplicableRules(
            RuleVersionDto ruleVersion,
            EnvironmentDto environment,
            string datacenter,
            string machine,
            string application,
            string instance)
        {
            if (ruleVersion == null || ruleVersion.Rules == null || ruleVersion.Rules.Count == 0)
            {
                return(new List <RuleDto>());
            }

            return(ruleVersion.Rules.Where(r => RuleApplies(r, environment, datacenter, machine, application, instance)).ToList());
        }
        protected override void ProcessRecord()
        {
            var environment = new EnvironmentDto
            {
                Name        = Name,
                Description = Description,
            };
            EnvironmentDtoType type;

            if (Enum.TryParse <EnvironmentDtoType>(Type, out type))
            {
                environment.Type = type;
            }
            var dto = HandleHttpOperationException(() => Api.Environments.Post(environment));

            WriteObject(Environment.FromDto(dto));
        }
Esempio n. 12
0
        public void CanBeSerialized()
        {
            //Arrange
            var sut = new EnvironmentDto()
            {
                Name   = "name",
                Status = "status"
            };

            //Act
            var payload = JsonSerializer.Serialize(sut, new JsonSerializerOptions {
                IgnoreNullValues = true
            });

            //Assert
            Assert.NotNull(JsonDocument.Parse(payload));
        }
Esempio n. 13
0
        private string LookupDatacenter(EnvironmentDto environment, string machine, string application, string instance)
        {
            var datacenterRules = _datacenterRules;

            if (datacenterRules == null)
            {
                return(null);
            }

            var datacenterName = string.Empty;

            foreach (var datacenterRule in datacenterRules)
            {
                if (RuleApplies(datacenterRule, environment, machine, application, instance))
                {
                    datacenterName = datacenterRule.DatacenterName;
                }
            }

            return(datacenterName);
        }
        public IActionResult Register([FromBody] EnvironmentDto envDto)
        {
            var app = this._mapper.Map <Domain.Models.Environment>(envDto);
            var listOfValidation = app.ValidateObj();

            if (listOfValidation.Count != 0)
            {
                return(BadRequest(listOfValidation));
            }

            try
            {
                this._environmentService.Create(app);
                return(Created("", "Environment Criada com Sucesso!"));
            }
            catch (Exception ex)
            {
                // return error message if there was an exception
                return(BadRequest(new { message = ex.Message }));
            }
        }
Esempio n. 15
0
        private async Task <bool> GetEnvironmentData()
        {
            EnvironmentDto environmentDto = await environment.GetEnvironment();

            FindViewById <TextView>(Resource.Id.resultJsonText).Text = wind.ReturnedJsonString;
            if (environmentDto == null)
            {
                FindViewById <TextView>(Resource.Id.stationNameText).Text = "GetEnvironment returned null.";
                return(false);
            }
            else
            {
                FindViewById <TextView>(Resource.Id.temperatureText).Text = environmentDto.Eat.ToSpeedUnit(Settings.TemperatureUnit).ToUiDashes3();
                FindViewById <TextView>(Resource.Id.airPressureText).Text = environmentDto.Eap.ToSpeedUnit(Settings.AirPressureUnit).ToUiDashes4();
                FindViewById <TextView>(Resource.Id.humidityText).Text    = environmentDto.Erh.ToUiDashes3();
                FindViewById <TextView>(Resource.Id.dewPointText).Text    = environmentDto.Edp.ToSpeedUnit(Settings.TemperatureUnit).ToUiDashes3();

                FindViewById <TextView>(Resource.Id.solarRadiationText).Text = environmentDto.Esr.ToUiDashes4();

                return(true);
            }
        }
Esempio n. 16
0
 private bool RuleApplies(RuleDto rule, EnvironmentDto environment, string datacenter, string machine, string application, string instance)
 {
     if (!string.IsNullOrEmpty(rule.Application))
     {
         if (!string.Equals(application, rule.Application, StringComparison.InvariantCultureIgnoreCase))
         {
             return(false);
         }
     }
     if (!string.IsNullOrEmpty(rule.Machine))
     {
         if (string.Compare(machine, rule.Machine, StringComparison.InvariantCultureIgnoreCase) != 0)
         {
             return(false);
         }
     }
     if (!string.IsNullOrEmpty(rule.Environment))
     {
         if (!string.Equals(environment.EnvironmentName, rule.Environment, StringComparison.InvariantCultureIgnoreCase))
         {
             return(false);
         }
     }
     if (!string.IsNullOrEmpty(rule.Instance))
     {
         if (!string.Equals(instance, rule.Instance, StringComparison.InvariantCultureIgnoreCase))
         {
             return(false);
         }
     }
     if (!string.IsNullOrEmpty(rule.Datacenter))
     {
         if (!string.Equals(datacenter, rule.Datacenter, StringComparison.InvariantCultureIgnoreCase))
         {
             return(false);
         }
     }
     return(true);
 }
Esempio n. 17
0
        public async Task <EnvironmentDto> GetEnvironment()
        {
            string queryString = GetLatestUrl();
            var    results     = await DataService.GetDataFromService(queryString).ConfigureAwait(false);

            ReturnedJsonString = results.ToString();

            // {"eid":54708,
            // "efl":null,"eapon":"2016-11-19T06:14:44.063Z",
            // "econ":"2016-11-19T06:14:44.063Z",
            // "edon":null,
            // "esid":"7fc30138-9d5c-e511-80cc-008cfa5abd0b",
            // "ets":null,"eapa":0,"edt":"2016-11-19T06:14:44.003Z",
            // "eat":null,"erh":null,"edp":null,"eap":null,"esr":null}
            if (results != null)
            {
                EnvironmentDto dto = new EnvironmentDto();
                dto.Eapon = (DateTime?)results["eapon"];
                dto.Econ  = (DateTime?)results["econ"];
                dto.Edon  = (DateTime?)results["edon"];
                dto.Efl   = (float?)results["efl"];

                dto.Eid  = (int)results["eid"];
                dto.Eap  = (float?)results["eap"];
                dto.Eapa = (int)results["eapa"];

                dto.Eat  = (float?)results["eat"];
                dto.Edp  = (float?)results["edp"];
                dto.Edt  = (DateTime)results["edt"];
                dto.Erh  = (float?)results["erh"];
                dto.Esid = (Guid)results["esid"];
                dto.Esr  = (float?)results["esr"];
                dto.Ets  = (DateTime?)results["ets"];

                return(dto);
            }

            return(null);
        }
Esempio n. 18
0
        public async Task <IActionResult> GetEnvInfo(Guid id)
        {
            // piggy back off the 'get all' use.
            var request = new DataAccessRequest <IEnvironment>
            {
                UserId   = _claimsCompat.ExtractFirstIdClaim(HttpContext.User),
                Strategy = DataAccessRequest <IEnvironment> .AcquisitionStrategy.All
            };

            var port    = new BasicPresenter <GenericDataResponse <IEnvironment> >();
            var success = await _getEnvironments.Handle(request, port);

            if (success)
            {
                var match = port.Response.Result.FirstOrDefault(e => e.Id == id);
                if (match != null)
                {
                    return(new OkObjectResult(EnvironmentDto.From(match)));
                }
                return(NotFound());
            }

            return(BadRequest());
        }
Esempio n. 19
0
 public void InsertOrUpdateEnvironment(EnvironmentDto environment)
 {
     DeleteEnvironment(environment.EnvironmentName);
     _environments.Add(environment);
 }
        public ActionResult RegisterEnvironment(EnvironmentDto dto)
        {
            var success = EnvironmentServices.AddNewEnvironment(dto);

            return(this.Direct(new { success, Environment = dto }));
        }
Esempio n. 21
0
 /// <summary>
 /// Post new environment
 /// </summary>
 /// <remarks>
 /// Required permissions: Environments.Create.
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='environmentDto'>
 /// The entity to post
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <EnvironmentDto> PostAsync(this IEnvironments operations, EnvironmentDto environmentDto, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
 {
     using (var _result = await operations.PostWithHttpMessagesAsync(environmentDto, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
Esempio n. 22
0
 public void Add(EnvironmentDto environmentDto)
 {
     environments.Add(Environment.FromDto(environmentDto));
 }
Esempio n. 23
0
 /// <summary>
 /// Updates an environment.
 /// </summary>
 /// <remarks>
 /// Required permissions: Environments.Edit.
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='id'>
 /// key: Id
 /// </param>
 /// <param name='environmentDto'>
 /// The entity to put
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task PutByIdAsync(this IEnvironments operations, long id, EnvironmentDto environmentDto, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
 {
     (await operations.PutByIdWithHttpMessagesAsync(id, environmentDto, null, cancellationToken).ConfigureAwait(false)).Dispose();
 }
 /// <summary>
 /// Post new environment
 /// </summary>
 /// <remarks>
 /// Required permissions: Environments.Create.
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='environmentDto'>
 /// The entity to post
 /// </param>
 public static EnvironmentDto Post(this IEnvironments operations, EnvironmentDto environmentDto)
 {
     return(operations.PostAsync(environmentDto).GetAwaiter().GetResult());
 }
 /// <summary>
 /// Updates an environment.
 /// </summary>
 /// <remarks>
 /// Required permissions: Environments.Edit.
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='id'>
 /// key: Id
 /// </param>
 /// <param name='environmentDto'>
 /// The entity to put
 /// </param>
 public static void PutById(this IEnvironments operations, long id, EnvironmentDto environmentDto)
 {
     operations.PutByIdAsync(id, environmentDto).GetAwaiter().GetResult();
 }
 /// <summary>
 /// Updates an environment.
 /// </summary>
 /// <remarks>
 /// Client Credentials Flow required permissions: Robots or Robots.Write.
 ///
 /// Required permissions: Environments.Edit.
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='key'>
 /// </param>
 /// <param name='body'>
 /// </param>
 /// <param name='xUIPATHOrganizationUnitId'>
 /// Folder/OrganizationUnit Id
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task PutByIdAsync(this IEnvironments operations, long key, EnvironmentDto body = default(EnvironmentDto), long?xUIPATHOrganizationUnitId = default(long?), CancellationToken cancellationToken = default(CancellationToken))
 {
     (await operations.PutByIdWithHttpMessagesAsync(key, body, xUIPATHOrganizationUnitId, null, cancellationToken).ConfigureAwait(false)).Dispose();
 }
 /// <summary>
 /// Updates an environment.
 /// </summary>
 /// <remarks>
 /// Client Credentials Flow required permissions: Robots or Robots.Write.
 ///
 /// Required permissions: Environments.Edit.
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='key'>
 /// </param>
 /// <param name='body'>
 /// </param>
 /// <param name='xUIPATHOrganizationUnitId'>
 /// Folder/OrganizationUnit Id
 /// </param>
 public static void PutById(this IEnvironments operations, long key, EnvironmentDto body = default(EnvironmentDto), long?xUIPATHOrganizationUnitId = default(long?))
 {
     operations.PutByIdAsync(key, body, xUIPATHOrganizationUnitId).GetAwaiter().GetResult();
 }
 /// <summary>
 /// Post new environment
 /// </summary>
 /// <remarks>
 /// Client Credentials Flow required permissions: Robots or Robots.Write.
 ///
 /// Required permissions: Environments.Create.
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='body'>
 /// </param>
 /// <param name='xUIPATHOrganizationUnitId'>
 /// Folder/OrganizationUnit Id
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <EnvironmentDto> PostAsync(this IEnvironments operations, EnvironmentDto body = default(EnvironmentDto), long?xUIPATHOrganizationUnitId = default(long?), CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.PostWithHttpMessagesAsync(body, xUIPATHOrganizationUnitId, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
 /// <summary>
 /// Post new environment
 /// </summary>
 /// <remarks>
 /// Client Credentials Flow required permissions: Robots or Robots.Write.
 ///
 /// Required permissions: Environments.Create.
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='body'>
 /// </param>
 /// <param name='xUIPATHOrganizationUnitId'>
 /// Folder/OrganizationUnit Id
 /// </param>
 public static EnvironmentDto Post(this IEnvironments operations, EnvironmentDto body = default(EnvironmentDto), long?xUIPATHOrganizationUnitId = default(long?))
 {
     return(operations.PostAsync(body, xUIPATHOrganizationUnitId).GetAwaiter().GetResult());
 }
Esempio n. 30
0
 /// <summary>
 /// Updates an environment.
 /// </summary>
 /// <remarks>
 /// Required permissions: Environments.Edit.
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='id'>
 /// key: Id
 /// </param>
 /// <param name='environmentDto'>
 /// The entity to put
 /// </param>
 /// <param name='xUIPATHOrganizationUnitId'>
 /// Folder/OrganizationUnit Id
 /// </param>
 public static void PutById(this IEnvironments operations, long id, EnvironmentDto environmentDto, long?xUIPATHOrganizationUnitId = default(long?))
 {
     operations.PutByIdAsync(id, environmentDto, xUIPATHOrganizationUnitId).GetAwaiter().GetResult();
 }