예제 #1
0
        /// <inheritdoc/>
        public async Task UpdateAttribute(AttributeDto input)
        {
            var attributeTemplate = await _attributeRepository.GetAsync(input.Id);

            input.MapTo(attributeTemplate);
            await attributeManager.UpdateAttributeTempateAsync(attributeTemplate);
        }
예제 #2
0
        private static void WavesofPulses(object sender, ElapsedEventArgs e)
        {
            for (int i = 0; i < 750000; i++)
            {
                PulsesRQ request;

                PulsesRQ pulses = new PulsesRQ();

                //var demoProcessedPulses = DemoProcessedPulses(pulses);
                var demoPruebas = DemoPruebasCLientes(pulses);

                List <AttributeDto> attributedto = new List <AttributeDto>();
                List <string>       listAttrb    = new List <string>();
                listAttrb.Add("attrLong");
                listAttrb.Add("newattrLong");
                AttributeDto adto = new AttributeDto("bpulse_demo_PruebasClientes", listAttrb);

                attributedto.Add(adto);

                List <string> listAttrb2 = new List <string>();
                listAttrb2.Add("Long");
                listAttrb2.Add("newLong");
                AttributeDto adto2 = new AttributeDto("bpulse_bpulse_processedPulses", listAttrb2);
                attributedto.Add(adto2);

                request = demoPruebas;
                BPulseCsharpClient client = new BPulseCsharpClient().GetInstance();

                client.SendPulseWithLong(pulses, attributedto);
            }
        }
예제 #3
0
        private CreateEntityCommand CreateCreateEntityCommand(string entityName, bool addElement)
        {
            var attributeModel = new AttributeDto()
            {
                Name      = "Id",
                DataType  = EnumDataTypes.String,
                AllowNull = false,
                Length    = 32
            };

            var command = new CreateEntityCommand()
            {
                Name       = entityName,
                Attributes = new List <AttributeDto>()
                {
                    attributeModel
                }
            };

            if (addElement)
            {
                var elementEntityCommand = CreateCreateEntityCommand("ElementChild", false);
                var elementDto           = new ElementDto()
                {
                    Entity   = elementEntityCommand,
                    DataType = EnumDataTypes.Object
                };
                command.Elements = new List <ElementDto>()
                {
                    elementDto
                };
            }

            return(command);
        }
예제 #4
0
        private ReportLayoutItemViewModel CreateMeasure(AttributeDto measure)
        {
            var item = _reportLayoutItemViewModelFactory();

            item.Name = measure.Name;
            item.Type = AttributeType.Measure;
            return(item);
        }
예제 #5
0
        public async Task <ApiResult <List <PriceSelectDto> > > CalculatePrice(AttributeDto dto, CancellationToken cancellationToken)
        {
            var attribute = dto.ToEntity(_mapper);

            var resultDto = await _priceCalculation.CalculatePrice(attribute, dto.CategoryId, cancellationToken);

            return(resultDto);
        }
예제 #6
0
        private ReportLayoutItemViewModel CreateDimension(AttributeDto dimension)
        {
            var item = _reportLayoutItemViewModelFactory();

            item.Name = dimension.Name;
            item.Type = AttributeType.Dimension;
            return(item);
        }
예제 #7
0
        public async Task <ActionResult> UpdateAsync([FromBody] AttributeDto attribute)
        {
            _service.Token = await getAccessToken();

            await _service.UpdateAsync(_mapper.Map <Attribute>(attribute));

            return(Ok());
        }
예제 #8
0
        public async Task <ActionResult> InsertAsync([FromBody] AttributeDto attribute)
        {
            _service.Token = await getAccessToken();

            var inserted = await _service.InsertAsync(_mapper.Map <Attribute>(attribute));

            return(CreatedAtAction("GetAttributeById", new { id = inserted.Id }, inserted));;
        }
예제 #9
0
        // Attribute Mapping
        public static AttributeDto MapToAttributeDto(Models.Attribute attribute)
        {
            var attributeDto = new AttributeDto
            {
                AttrId             = attribute.AttrId,
                AttrName           = attribute.AttrName,
                AttrValue          = attribute.AttrValue,
                EmployeeAttributes = new Collection <EmployeeAttributeDto>()         // at this point we are ok with new Collection, lateer need to modify
            };

            return(attributeDto);
        }
예제 #10
0
        public static Models.Attribute MapToAttribute(AttributeDto attributeDto)
        {
            var attribute = new Models.Attribute
            {
                AttrId             = attributeDto.AttrId,
                AttrName           = attributeDto.AttrName,
                AttrValue          = attributeDto.AttrValue,
                EmployeeAttributes = new Collection <EmployeeAttribute>()
            };

            return(attribute);
        }
예제 #11
0
        public async Task <ActionResult> PutAttribute(Guid id, [FromBody] AttributeDto attributeDto)
        {
            if (id != attributeDto.AttrId)
            {
                return(BadRequest());
            }

            //var attribute = MyMapper.MapToAttribute(attributeDto);
            var attribute = _mapper.Map <Models.Attribute>(attributeDto);
            await _attributeRepository.Update(attribute);

            return(NoContent());
        }
예제 #12
0
        public async Task <ActionResult <AttributeDto> > PostAttribute([FromBody] AttributeDto attributeDto) //  should i exclude Guid from model binder?  8a bgalei error h modelstate?
        {                                                                                                    //  ti 8a ginotan stin put ??
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            //var attribute = MyMapper.MapToAttribute(attributeDto);
            var attribute = _mapper.Map <Models.Attribute>(attributeDto);
            await _attributeRepository.Create(attribute);

            return(CreatedAtAction("GetAttribute", new { id = attributeDto.AttrId }, attributeDto));
        }
예제 #13
0
        /// <inheritdoc />
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            var result = new AttributeDto();

            if (reader.Read() && reader.TokenType == JsonToken.PropertyName)
            {
                var key   = AttributeKeyCache.Cache.StringToKey(reader.Value.ToString());
                var value = reader.ReadAsString();

                result = new AttributeDto(key, value);
            }

            return(result);
        }
        private List <AttributeDto> GetAttributes()
        {
            var list = new List <AttributeDto>();

            foreach (DataGridViewRow item in lstAttributes.Rows)
            {
                if (item.Cells[0].Value != null && item.Cells[1].Value != null && item.Cells[2].Value != null)
                {
                    var attribute = new AttributeDto {
                        Name = item.Cells[0].Value.ToString(), FriendlyName = item.Cells[1].Value.ToString(), NameFormat = item.Cells[2].Value.ToString()
                    };
                    list.Add(attribute);
                }
            }
            return(list);
        }
예제 #15
0
        public async Task AddAttributeAsync(AttributeDto attribute, CancellationToken cancellationToken = default(CancellationToken))
        {
            var a = new Domain.Core.Attribute
            {
                Name   = attribute.Name,
                UnitId = attribute.UnitId
            };

            try
            {
                _dbContext.Add(a);
                await _dbContext.SaveChangesAsync(cancellationToken);
            }
            catch (DbUpdateException ex)
            {
                throw new InvalidItemException(a, ex);
            }
        }
예제 #16
0
        public async Task UpdateAttributeAsync(int attributeId, AttributeDto attribute, CancellationToken cancellationToken = default(CancellationToken))
        {
            var b = new Domain.Core.Attribute
            {
                Id     = attributeId,
                Name   = attribute.Name,
                UnitId = attribute.UnitId
            };

            _dbContext.Attach(b).State = EntityState.Modified;

            try
            {
                await _dbContext.SaveChangesAsync(cancellationToken);
            }
            catch (DbUpdateConcurrencyException ex)
            {
                throw new ItemNotFoundException(attributeId, "Attribute unit", ex);
            }
            catch (DbUpdateException ex)
            {
                throw new InvalidItemException(b, ex);
            }
        }
예제 #17
0
 public CreateAttributeCommand(AttributeDto attribute)
 {
     Attribute = attribute;
 }
예제 #18
0
 /// <inheritdoc/>
 public async Task CreateAttribute(AttributeDto input)
 {
     var attributeTemplate = input.MapTo <ProductAttribute>();
     await attributeManager.CreateAttributeTempateAsync(attributeTemplate);
 }
예제 #19
0
        public List <IAttribute> FindAllParametricsWithValues(IUser currentUser)
        {
            // Find the list of products
            string url = "ProductService.svc/rest/ListParametricInfo?format=json";

            url += addUserUrlDetails(currentUser);
            var parametricsList = _connectionManager.GetResult <List <StormParametricInfo> >(url);

            url  = "ProductService.svc/rest/ListParametricValues2?format=json";
            url += addUserUrlDetails(currentUser);
            var parametricsValueList = _connectionManager.GetResult <List <StormParametric> >(url);
            Dictionary <int, StormParametric> valueIds = new Dictionary <int, StormParametric>();

            foreach (var value in parametricsValueList)
            {
                valueIds[value.Id] = value;
            }


            List <IAttribute> list = new List <IAttribute>();

            foreach (var parm in parametricsList)
            {
                AttributeDto attributeDto = new AttributeDto();
                attributeDto.ExternalId = parm.Id.ToString();
                attributeDto.Code       = parm.Code;
                attributeDto.Uom        = parm.Uom;
                attributeDto.Name       = parm.Name;

                list.Add(attributeDto);

                // List value type
                if (parm.Type == 1)
                {
                    attributeDto.Values = new List <AttributeValueDto>();
                    AddParametricChildren(parm.Id, parm.Name, "L" + parm.Id, parm.Type.Value, attributeDto.Values, valueIds, currentUser);
                }  // Multi value type
                else if (parm.Type == 2)
                {
                    attributeDto.Values = new List <AttributeValueDto>();
                    AddParametricChildren(parm.Id, parm.Name, "L" + parm.Id, parm.Type.Value, attributeDto.Values, valueIds, currentUser);
                } // Boolean
                else if (parm.ValueType == 4)
                {
                    attributeDto.Values = new List <AttributeValueDto>();

                    {
                        AttributeValueDto dto = new AttributeValueDto();
                        dto.Name       = parm.Name + " Ja";
                        dto.ExternalId = parm.Id.ToString();
                        dto.Hidden     = parm.IsHidden ?? false;

                        dto.QueryCode = "V" + parm.Id + "_1-1";
                        attributeDto.Values.Add(dto);
                    }

                    {
                        AttributeValueDto dto = new AttributeValueDto();
                        dto.Name       = parm.Name + " Nej";
                        dto.ExternalId = parm.Id.ToString();
                        dto.Hidden     = parm.IsHidden ?? false;

                        dto.QueryCode = "V" + parm.Id + "_0-0";
                        attributeDto.Values.Add(dto);
                    }
                }
            }

            return(list);
        }
예제 #20
0
        public override void AwakeFromNib()
        {
            base.AwakeFromNib();
            IsUpdated = false;
            //Events
            this.BtnAdd.Activated += (object sender, EventArgs e) => {
                if (string.IsNullOrEmpty(TxtName.StringValue))
                {
                    UIErrorHelper.ShowAlert("Name has invalid value", "Alert");
                }
                else if (string.IsNullOrEmpty(TxtIndex.StringValue))
                {
                    UIErrorHelper.ShowAlert("Index has invalid value", "Alert");
                }
                else if (ChDefault.StringValue == "1" && DefaultSet && (AttributeConsumerServiceDto != null && !AttributeConsumerServiceDto.IsDefault))
                {
                    UIErrorHelper.ShowAlert("Multiple attribute consumer services chosen as default", "Alert");
                }
                else
                {
                    AttributeConsumerServiceDto = new AttributeConsumerServiceDto
                    {
                        Name       = TxtName.StringValue,
                        Index      = TxtIndex.IntValue,
                        IsDefault  = ChDefault.StringValue == "1",
                        Attributes = (AttributeTableView.DataSource as AttributeDataSource).Entries
                    };
                    IsUpdated = true;
                    this.Close();
                    NSApplication.SharedApplication.StopModalWithCode(0);
                }
            };
            this.BtnAddAttribute.Activated += (object sender, EventArgs e) => {
                if (string.IsNullOrEmpty(TxtAttributeName.StringValue))
                {
                    UIErrorHelper.ShowAlert("Attribute name cannot be empty", "Alert");
                    return;
                }
                if (string.IsNullOrEmpty(TxtFriendlyName.StringValue))
                {
                    UIErrorHelper.ShowAlert("Attribute friendly name cannot be empty", "Alert");
                    return;
                }
                if (string.IsNullOrEmpty(TxtNameFormat.StringValue))
                {
                    UIErrorHelper.ShowAlert("Attribute name format cannot be empty", "Alert");
                    return;
                }
                var attributeDto = new AttributeDto
                {
                    Name         = TxtAttributeName.StringValue,
                    FriendlyName = TxtFriendlyName.StringValue,
                    NameFormat   = TxtNameFormat.StringValue
                };
                TxtAttributeName.StringValue = string.Empty;
                TxtFriendlyName.StringValue  = string.Empty;
                TxtNameFormat.StringValue    = string.Empty;
                _attributes.Add(attributeDto);
                AttributeTableView.DataSource = new AttributeDataSource {
                    Entries = _attributes
                };
                AttributeTableView.ReloadData();
            };
            this.BtnRemoveAttribute.Activated += (object sender, EventArgs e) => {
                if (AttributeTableView.SelectedRow > -1)
                {
                    _attributes.RemoveAt((int)AttributeTableView.SelectedRow);
                    AttributeTableView.DataSource = new AttributeDataSource {
                        Entries = _attributes
                    };
                    AttributeTableView.ReloadData();
                }
            };
            this.BtnClose.Activated += (object sender, EventArgs e) => {
                this.Close();
                NSApplication.SharedApplication.StopModalWithCode(0);
            };

            if (AttributeConsumerServiceDto != null)
            {
                TxtName.StringValue   = AttributeConsumerServiceDto.Name;
                _attributes           = AttributeConsumerServiceDto.Attributes;
                ChDefault.StringValue = AttributeConsumerServiceDto.IsDefault ? "1" : "0";
                TxtIndex.IntValue     = AttributeConsumerServiceDto.Index;
            }
            InitializeAttributes();
        }
예제 #21
0
 public Task Post([FromBody] AttributeDto attribute)
 {
     return(_attributesService.AddAttributeAsync(attribute, HttpContext.RequestAborted));
 }
예제 #22
0
        public async Task <IActionResult> CreateAttribute([FromBody] AttributeDto dto)
        {
            var result = await _mediator.Send(new CreateAttributeCommand(dto));

            return(result.StatusCode == 200 ? Ok(result.Result) : StatusCode(result.StatusCode, result.Errors));
        }
예제 #23
0
 public Task Put(int attributeId, [FromBody] AttributeDto attribute)
 {
     return(_attributesService.UpdateAttributeAsync(attributeId, attribute, HttpContext.RequestAborted));
 }