예제 #1
0
        public async Task CreateAsync(ComponentDto componentDto)
        {
            var component = _mapper.Map <Component>(componentDto);

            component.Id = Guid.NewGuid();
            await _repository.CreateAsync(component);
        }
예제 #2
0
 private static ComponentStatusDto Transform(
     ComponentDto component, bool isComponentWorking)
 {
     return(new ComponentStatusDto(
                component,
                GetComponentHealthStatus(isComponentWorking)));
 }
예제 #3
0
        public void Update(ComponentDto data)
        {
            using (var ctx = DbContextManager <Reco3Xml2DbContext> .GetManager(_dbName)) {
                var item = (from r in ctx.DbContext.Components
                            where r.ComponentId == data.ComponentId
                            select r).FirstOrDefault();
                if (item == null)
                {
                    throw new DataNotFoundException("Component not found exception.");
                }
                if (!item.DownloadedTimestamp.Matches(data.DownloadedTimestamp))
                {
                    throw new ConcurrencyException("ConcurrencyException: DownloadedTimeStamp mismatch.");
                }

                item.Description    = data.Description;
                item.PD_Status      = data.PDStatus;
                item.Component_Type = data.ComponentType;
                item.XML            = data.Xml;
                item.PD_Source      = data.PDSource;

                var count = ctx.DbContext.SaveChanges();
                if (count == 0)
                {
                    throw new UpdateFailureException("Failed to save Component.");
                }
            }
        }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="component">The component</param>
 /// <param name="healthStatus">Component health status</param>
 public ComponentStatusDto(
     ComponentDto component,
     ComponentHealthStatus healthStatus = ComponentHealthStatus.Unknown)
     : base(component)
 {
     HealthStatus = healthStatus;
 }
예제 #5
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="component">The component</param>
 /// <param name="total">The counter</param>
 public CounterResultDto(
     ComponentDto component,
     long total = -1)
     : base(component)
 {
     Total = total;
 }
예제 #6
0
        public void DtoToModelEntityTest()
        {
            var componentTypeDto = new ComponentTypeDto
            {
                Id   = 1,
                Name = "CPU"
            };

            var brandDto = new BrandDto
            {
                Id   = 1,
                Name = "Intel"
            };

            var componentDto = new ComponentDto
            {
                Id            = 1,
                Name          = "Intel 6600k",
                ComponentType = componentTypeDto,
                Brand         = brandDto,
                Price         = 100
            };

            var model = _componentMapper.ToEntityModel(componentDto);

            Assert.Equal(componentDto.Id, model.Id);
            Assert.Equal(componentDto.Name, model.Name);
            Assert.Equal(componentDto.Price, model.Price);
            Assert.Equal(componentDto.Brand.Id, model.Brand.Id);
            Assert.Equal(componentDto.Brand.Name, model.Brand.Name);
            Assert.Equal(componentDto.ComponentType.Id, model.ComponentType.Id);
            Assert.Equal(componentDto.ComponentType.Name, model.ComponentType.Name);
        }
예제 #7
0
 public static ComponentInfo GetComponentInfo(ComponentDto dto)
 {
     if (dto == null)
     {
         return(null);
     }
     return(new ComponentInfo(dto));
 }
예제 #8
0
        public ComponentDto Add(ComponentDto dto)
        {
            var entity = new Component()
            {
                Name = dto.Name
            };

            this.uow.Components.Add(entity);
            this.uow.SaveChanges();
            return(new ComponentDto(entity));
        }
예제 #9
0
 private void Child_Fetch(ComponentDto item)
 {
     ComponentId         = item.ComponentId;
     PDNumber            = item.PDNumber;
     DownloadedTimestamp = item.DownloadedTimestamp;
     Description         = item.Description;
     PDStatus            = item.PDStatus;
     ComponentType       = item.ComponentType;
     Xml               = item.Xml;
     PDSource          = item.PDSource;
     SourceComponentId = item.SourceComponentId;
 }
예제 #10
0
        public async Task UpdateAsync(ComponentDto componentDto)
        {
            var component = await _repository.GetAsync(componentDto.Id);

            if (component == null)
            {
                throw new GreenFieldNotFoundException();
            }

            component = _mapper.Map <Component>(componentDto);
            await _repository.UpdateAsync(component);
        }
예제 #11
0
        public async Task <IActionResult> AddComponent(ComponentDto componentDto)
        {
            Component component = new Component()
            {
                Created    = DateTime.Now,
                CategoryId = componentDto.CategoryId,
                Name       = componentDto.Name,
                Icon       = componentDto.Icon,
            };

            await _repo.Add(component);

            return(Ok(component));
        }
예제 #12
0
 public ComponentInfo(ComponentDto dto)
 {
     if (dto == null)
     {
         throw new ArgumentNullException("dto");
     }
     Id          = dto.Id;
     ParentId    = dto.ParentId;
     Type        = new ComponentTypeInfo(dto.Type);
     SystemName  = dto.SystemName;
     DisplayName = dto.DisplayName;
     CreatedDate = dto.CreatedDate;
     Version     = dto.Version;
     Properties  = DataConverter.GetExtentionPropertyCollection(dto.Properties);
 }
예제 #13
0
        public void UpdateComponents(ComponentDto model, int equipmentId)
        {
            //add new relations between component and equipment
            //Entity is not null if relation already exists
            //var Entity = _context.EquipmentComponents.Find(model.ComponentId, equipmentId);

            //create new relation

            _context.EquipmentComponents.Add(new EquipmentComponent()
            {
                ComponentID   = model.ComponentId,
                EquipmentID   = equipmentId,
                ComponentName = model.ComponentName
            });
        }
예제 #14
0
        public async Task <IActionResult> UpdateComponent(int id, ComponentDto componentDto)
        {
            Component component = await _repo.Find <Component>(id);

            if (component == null)
            {
                return(BadRequest("Component not found"));
            }

            component.Icon       = componentDto.Icon;
            component.CategoryId = componentDto.CategoryId;

            await _repo.SaveAllChangesAsync();

            return(Ok(component));
        }
예제 #15
0
        /// <summary>
        /// Routes to a dynamically generated "Component Show" Page. Gathers information from the database.
        /// </summary>
        /// <param name="id">Id of the Component</param>
        /// <returns>A dynamic "Component Show" webpage which provides detailes for a selected component.</returns>
        /// <example>GET : /Component/Show/5</example>
        public ActionResult Show(int id)
        {
            ShowComponent       ViewModel = new ShowComponent();
            string              url       = "componentdata/findcomponent/" + id;
            HttpResponseMessage response  = client.GetAsync(url).Result;

            if (response.IsSuccessStatusCode)
            {
                ComponentDto SelectedComponent = response.Content.ReadAsAsync <ComponentDto>().Result;
                ViewModel.component = SelectedComponent;

                return(View(ViewModel));
            }
            else
            {
                return(RedirectToAction("Error"));
            }
        }
예제 #16
0
        /// <summary>
        /// Fonction permettant la création de nouveaux composant à l'aide de l'API Gemini
        /// </summary>
        /// <remarks>JClaud 2015-07-27 Création</remarks>
        public void CreateComposant(ParamCreationComposantDTO pParam)
        {
            //jc - Déclaration des variables
            //ServiceManager lService = LanceAuthentification(pParam.User);
            ServiceManager lServiceData = LanceAuthentification(CopyUserAsAPI(pParam.User));
            ComponentDto   lComponent   = new ComponentDto();

            //jc- affectation des variables au composant
            lComponent.Entity.Name        = pParam.Composant.NomComposant;
            lComponent.Entity.Description = pParam.Composant.DescrComposant;
            lComponent.Entity.ProjectId   = pParam.Ticket.Projet.IdProjet;
            lComponent.Entity.ReadOnly    = false;
            //jc- affectation des constantes au nouveau composant
            lComponent.Entity.Created = System.DateTime.Now;
            lComponent.Entity.Revised = System.DateTime.Now;

            //jc- on enregistre la nouvelle cause
            lServiceData.Projects.CreateComponent(lComponent.Entity);
        }
예제 #17
0
        public List <ComponentDto> FetchAllWSamePDNumber(string pdNumber)
        {
            using (var ctx = ConnectionManager <SqlConnection> .GetManager(_dbName)) {
                using (var cm = ctx.Connection.CreateCommand()) {
                    cm.CommandType = CommandType.Text;
                    cm.CommandText = "SELECT * FROM Reco3Component WHERE PDNumber = @pdNumber";
                    cm.Parameters.AddWithValue("@pdNumber", pdNumber);

                    using (var dr = cm.ExecuteReader()) {
                        if (dr.HasRows)
                        {
                            var result = new List <ComponentDto>();
                            while (dr.Read())
                            {
                                var component = new ComponentDto {
                                    ComponentId         = dr.GetInt32(0),
                                    PDNumber            = dr.GetString(1),
                                    DownloadedTimestamp = dr.GetDateTime(2),
                                    Description         = dr.GetString(3),
                                    PDStatus            = dr.GetInt32(4),
                                    ComponentType       = dr.GetInt32(5),
                                    Xml      = dr.GetString(6),
                                    PDSource = dr.GetInt32(7)
                                };

                                if (!dr.IsDBNull(8))
                                {
                                    component.SourceComponentId = dr.GetInt32(8);
                                }

                                result.Add(component);
                            }

                            return(result);
                        }
                        else
                        {
                            return(null);
                        }
                    }
                }
            }
        }
예제 #18
0
 private void Update()
 {
     using (var ctx = DalFactory.GetManager(DalManagerTypes.DalManagerDb)) {
         var dal = ctx.GetProvider <IComponentDal>();
         using (BypassPropertyChecks) {
             var item = new ComponentDto {
                 ComponentId         = ComponentId,
                 PDNumber            = PDNumber,
                 DownloadedTimestamp = DownloadedTimestamp,
                 Description         = Description,
                 PDStatus            = PDStatus,
                 ComponentType       = ComponentType,
                 Xml               = Xml,
                 PDSource          = PDSource,
                 SourceComponentId = SourceComponentId
             };
             dal.Update(item);
         }
     }
 }
예제 #19
0
        public void Insert(ComponentDto data)
        {
            using (var ctx = DbContextManager <Reco3Xml2DbContext> .GetManager(_dbName)) {
                var item = new Reco3Component {
                    ComponentId         = data.ComponentId,
                    PDNumber            = data.PDNumber,
                    DownloadedTimestamp = data.DownloadedTimestamp,
                    Description         = data.Description,
                    PD_Status           = data.PDStatus,
                    Component_Type      = data.ComponentType,
                    XML               = data.Xml,
                    PD_Source         = data.PDSource,
                    SourceComponentId = data.SourceComponentId
                };

                ctx.DbContext.Components.Add(item);
                ctx.DbContext.SaveChanges();
                data.ComponentId = item.ComponentId;
            }
        }
        public IHttpActionResult FindComponent(int id)
        {
            Component Component = db.Components.Find(id);

            if (Component == null)
            {
                return(NotFound());
            }

            ComponentDto ComponentDto = new ComponentDto
            {
                ComponentId       = Component.ComponentId,
                ComponentName     = Component.ComponentName,
                ComponentValue    = Component.ComponentValue,
                ModuleId          = Component.ModuleId,
                ComponentQuantity = Component.ComponentQuantity
            };

            return(Ok(ComponentDto));
        }
예제 #21
0
        public static ComponentDto ConvertToApi(Zidium.Core.Api.ComponentInfo info)
        {
            if (info == null)
            {
                return(null);
            }
            var result = new ComponentDto
            {
                CreatedDate = info.CreatedDate,
                DisplayName = info.DisplayName,
                Id          = info.Id,
                ParentId    = info.ParentId,
                SystemName  = info.SystemName,
                Type        = ConvertToApi(info.Type),
                Version     = info.Version,
                Properties  = ConvertToApi(info.Properties)
            };

            return(result);
        }
        public IHttpActionResult GetComponents()
        {
            List <Component>    Components    = db.Components.ToList();
            List <ComponentDto> ComponentDtos = new List <ComponentDto> {
            };

            foreach (var Component in Components)
            {
                ComponentDto NewComponent = new ComponentDto
                {
                    ComponentId       = Component.ComponentId,
                    ComponentName     = Component.ComponentName,
                    ComponentValue    = Component.ComponentValue,
                    ModuleId          = Component.ModuleId,
                    ComponentQuantity = Component.ComponentQuantity
                };
                ComponentDtos.Add(NewComponent);
            }

            return(Ok(ComponentDtos));
        }
예제 #23
0
        public IActionResult PerformAction([FromBody] ComponentDto component)
        {
            var comp = _repository.Component.GetComponentById(component.id);
            var cat  = _repository.Category.GetCategoryById(comp.Categoryid);

            ArduinoConnector connection = new ArduinoConnector();

            bool succes = false;

            succes = connection.Send_Data(comp, cat);

            if (succes)
            {
                comp.value = comp.value == 0?1:0;
                _repository.Component.UpdateComponent(comp);
                _repository.Save();

                return(Ok("action succesfull"));
            }

            return(StatusCode(500, "Internal server error"));
        }
예제 #24
0
        public IHttpActionResult GetComponentsForModules(int id)
        {
            List <Component> Components = db.Components
                                          .Where(p => p.ModuleId == id.ToString())
                                          .ToList();
            List <ComponentDto> ComponentDtos = new List <ComponentDto> {
            };

            foreach (var Component in Components)
            {
                ComponentDto NewComponent = new ComponentDto
                {
                    ComponentId       = Component.ComponentId,
                    ComponentName     = Component.ComponentName,
                    ComponentValue    = Component.ComponentValue,
                    ModuleId          = Component.ModuleId,
                    ComponentQuantity = Component.ComponentQuantity
                };
                ComponentDtos.Add(NewComponent);
            }
            return(Ok(ComponentDtos));
        }
예제 #25
0
파일: ComponentDal.cs 프로젝트: pecen/Reco4
        public IList <ComponentDto> Fetch()
        {
            using (var ctx = ConnectionManager <SqlConnection> .GetManager(_dbName)) {
                using (var cm = ctx.Connection.CreateCommand()) {
                    cm.CommandType = CommandType.Text;
                    cm.CommandText = "SELECT * FROM Reco3Component";

                    using (var dr = new SafeDataReader(cm.ExecuteReader())) {
                        //if (dr.HasRows) {
                        var result = new List <ComponentDto>();

                        while (dr.Read())
                        {
                            var component = new ComponentDto {
                                ComponentId         = dr.GetInt32(0),
                                PDNumber            = dr.GetString(1),
                                DownloadedTimestamp = dr.GetDateTime(2),
                                Description         = dr.GetString(3),
                                PDStatus            = dr.GetInt32(4),
                                ComponentType       = dr.GetInt32(5),
                                Xml               = dr.GetString(6),
                                PDSource          = dr.GetInt32(7),
                                SourceComponentId = dr.GetInt32(8)
                            };

                            result.Add(component);
                        }
                        ;

                        return(result);
                        //}
                        //else {
                        //  return null;
                        //}
                    }
                }
            }
        }
예제 #26
0
        public void Insert(ComponentDto data)
        {
            using (var ctx = ConnectionManager <SqlConnection> .GetManager(_dbName)) {
                using (var cm = ctx.Connection.CreateCommand()) {
                    cm.CommandType = CommandType.Text;

                    if (data.SourceComponentId != null)
                    {
                        cm.CommandText = "INSERT INTO Reco3Component (PDNumber, DownloadedTimestamp, Description, PD_Status, Component_Type, XML, PD_Source, SourceComponentId) " +
                                         "VALUES (@pdNumber,@downloadedTimestamp, @description, @pdStatus, @componentType, @xml, @pdSource, @sourceComponentId)";

                        cm.Parameters.AddWithValue("@sourceComponentId", data.SourceComponentId);
                    }
                    else
                    {
                        cm.CommandText = "INSERT INTO Reco3Component (PDNumber, DownloadedTimestamp, Description, PD_Status, Component_Type, XML, PD_Source) " +
                                         "VALUES (@pdNumber,@downloadedTimestamp, @description, @pdStatus, @componentType, @xml, @pdSource)";
                    }

                    cm.Parameters.AddWithValue("@pdNumber", data.PDNumber);
                    cm.Parameters.AddWithValue("@downloadedTimestamp", data.DownloadedTimestamp);
                    cm.Parameters.AddWithValue("@description", data.Description);
                    cm.Parameters.AddWithValue("@pdStatus", data.PDStatus);
                    cm.Parameters.AddWithValue("@componentType", data.ComponentType);
                    cm.Parameters.AddWithValue("@xml", data.Xml);
                    cm.Parameters.AddWithValue("@pdSource", data.PDSource);

                    cm.ExecuteNonQuery();
                    cm.Parameters.Clear();
                    cm.CommandText = "SELECT @@identity";
                    var r     = cm.ExecuteScalar();
                    var newId = int.Parse(r.ToString());
                    data.ComponentId = newId;
                }
            }
        }
예제 #27
0
 private static CounterResultDto Transform(
     ComponentDto component, long counter)
 {
     return(new CounterResultDto(component, counter));
 }
 public static int CalculateColumnWidth(ComponentDto componentData)
 {
     return(componentData?.Width ?? MaxColumnWidth);
 }
 public static string GetComponentColumnCssClasses(ComponentDto componentData)
 {
     return($@"col-{CalculateColumnWidth(componentData)}");
 }
예제 #30
0
 protected override async Task OnInitializedAsync()
 {
     component = await _componentService.GetComponentByIdAsync(Id);
 }