public Cabinet(int height, int width, int depth, int sizeElement, int backSize, string name, IConfig config) { Logger.Info("Start cabinet constructor"); Logger.Trace("Start Automapper created"); _mapperConfiguration = new MapperConfiguration(cfg => { cfg.AddCollectionMappers(); cfg.ShouldMapProperty = pi => pi.GetMethod != null && (pi.GetMethod.IsPublic || pi.GetMethod.IsPrivate); cfg.CreateMap <ElementModelDTO, ElementModel>().EqualityComparison((dto, o) => dto.GetGuid() == o.GetGuid()); cfg.CreateMap <ElementModel, ElementModelDTO>().EqualityComparison((dto, o) => dto.GetGuid() == o.GetGuid()); cfg.CreateMap <CabinetModel, CabinetModelDTO>(); }); _mapperConfiguration.AssertConfigurationIsValid(); _mapper = _mapperConfiguration.CreateMapper(); Logger.Trace("Stop AutoMapper created"); _config = config; _height = height; _width = width; _depth = depth; _sizeElement = sizeElement; BackSize = backSize; Back = EnumBack.Brak; _name = name; CabinetType = EnumCabinetType.Standard; Logger.Trace("Start GlobalCabinetElemen in cabinet constructor"); GlobalCabinetElement(); HorizontalBarrierFactory = new HorizontalBarrierFactory(this); VerticalBarrierFactory = new VerticalBarrierFactory(this); FrontFactory = new FrontFactory(this, _config); }
public void Redraw() { Logger.Info("Redraw in Cabinet"); RedrawCabinetElements(); // TODO dodac wszelkie przeliczenia w klasie cabinet VerticalBarrier = _mapper.Map <List <ElementModel> >(VerticalBarrierFactory.ReCount()); HorizontalBarrier = _mapper.Map <List <ElementModel> >(HorizontalBarrierFactory.ReCount()); FrontList = _mapper.Map <List <ElementModel> >(FrontFactory.ReCount()); }
public void NewCabinet() { Height(_config.CabinetHeight()).Width(_config.CabinetWidth()).Depth(_config.CabinetDepth()).SizeElement(_config.CabinetSizeElement()) .Name(_config.CabinetName()); HorizontalBarrierFactory = new HorizontalBarrierFactory(this); VerticalBarrierFactory = new VerticalBarrierFactory(this); FrontFactory = new FrontFactory(this, _config); Redraw(); }
public void DeleteElementHorizontalBarrier(ElementModel elementModel) { Logger.Info("Delete Element Horizontal Barrier in Cabinet"); Logger.Debug("Delete Element Horizontal Barrier count: {0}", elementModel.ToString()); try { HorizontalBarrier = _mapper.Map <List <ElementModel> >(HorizontalBarrierFactory.Delete(_mapper.Map <ElementModelDTO>(elementModel))); } catch (Exception ex) { Logger.Error(ex, "Error Delete Element Horizontal Barrier in Cabinet"); } }
public List <ElementModel> GetAllHorizontalBarrier() { Logger.Info("Get All Horizontal Barrier in Cabinet"); try { return(_mapper.Map <List <ElementModel> >(HorizontalBarrierFactory.GetAll())); } catch (Exception ex) { Logger.Error(ex, "Error Get All Horizontal Barrier in Cabinet"); return(new List <ElementModel>()); } }
public void RemoveHorizontalBarrier() { Logger.Info("Remove Horizontal Barrier in Cabinet"); try { HorizontalBarrier = _mapper.Map <List <ElementModel> >(HorizontalBarrierFactory.Remove()); } catch (Exception ex) { Logger.Error(ex, "Error Remove Delete Horizontal Barrier"); } }
public void DeleteHorizontalBarrier(int delete) { Logger.Info("Delete Horizontal Barrier in Cabinet"); Logger.Debug("Delete Horizontal Barrier count: {0}", delete); try { HorizontalBarrier = _mapper.Map <List <ElementModel> >(HorizontalBarrierFactory.Delete(delete)); } catch (Exception ex) { Logger.Error(ex, "Error Delete Horizontal Barrier"); } }
public void AddHorizonatlBarriery(List <ElementModel> elementModels) { Logger.Info("AddHorizonatlBarriery(List<ElementModel> elementModels) in Cabinet"); Logger.Debug("List<ElementModel>: {0}", elementModels); try { HorizontalBarrier = _mapper.Map <List <ElementModel> >(HorizontalBarrierFactory.Add(_mapper.Map <List <ElementModelDTO> >(elementModels))); } catch (Exception ex) { Logger.Error(ex, "Error AddHorizonatlBarriery(List<ElementModel> elementModels)"); } }
public void AddHorizontalBarrierByEvery(int size) { Logger.Info("AddHorizontalBarrierByEvery(int size) in Cabinet"); Logger.Debug("size: {0}", size); try { HorizontalBarrier = _mapper.Map <List <ElementModel> >(HorizontalBarrierFactory.AddEvery(size)); } catch (Exception ex) { Logger.Error(ex, "Error AddHorizontalBarrierByEvery(int size)"); } }
public void AddHorizontalBarrier(int count) { Logger.Info("AddHorizontalBarrier(int i) in Cabinet"); Logger.Debug("count: {0}", count); try { HorizontalBarrier = _mapper.Map <List <ElementModel> >(HorizontalBarrierFactory.Add(count)); } catch (Exception ex) { Logger.Error(ex, "Error AddHorizontalBarrier(int i)"); } }
public void NewHorizontalBarrier(BarrierParameter barrierParameter) { Logger.Info("New Horizontal Barrier in Cabinet"); Logger.Debug("BarrierParameter Number: {0}, Back: {1}, Height: {2} ", barrierParameter.Number, barrierParameter.Back, string.Join(";", barrierParameter.Height)); if (barrierParameter == null) { return; } HorizontalBarrierParameter = barrierParameter; try { HorizontalBarrier = _mapper.Map <List <ElementModel> >(HorizontalBarrierFactory.NewBarrier(HorizontalBarrierParameter)); } catch (Exception ex) { Logger.Error(ex, "Error New Horizontal Barrier"); } }
// TODO dodac dodatkowe logowanie i prawidłowe - w fabryce zmiany elementow public ElementModel ChangeElemenet(ElementModel element, EnumElementParameter parameter, string text) { Logger.Info("ChangeElemenet(ElementModel element, EnumElementParameter parameter, string text) in Cabinet"); if (int.TryParse(text, out int result) || parameter == EnumElementParameter.Description) { bool find = false; foreach (var item in CabinetElements) { if (item.GetGuid() == element.GetGuid()) { find = true; SwitchChange(parameter, text, result, item); if (element.GetEnumName() == EnumCabinetElement.Leftside && parameter == EnumElementParameter.Width) { CabinetElements.Find(x => x.GetEnumName() == EnumCabinetElement.Top).SetHeight(_width - CabinetElements.Find(x => x.GetEnumName() == EnumCabinetElement.Leftside).Width - CabinetElements.Find(x => x.GetEnumName() == EnumCabinetElement.Rightside).Width, false); CabinetElements.Find(x => x.GetEnumName() == EnumCabinetElement.Bottom).SetHeight(_width - CabinetElements.Find(x => x.GetEnumName() == EnumCabinetElement.Leftside).Width - CabinetElements.Find(x => x.GetEnumName() == EnumCabinetElement.Rightside).Width, false); CabinetElements.Find(x => x.GetEnumName() == EnumCabinetElement.Top).SetX(CabinetElements.Find(x => x.GetEnumName() == EnumCabinetElement.Leftside).Width, false); CabinetElements.Find(x => x.GetEnumName() == EnumCabinetElement.Bottom).SetX(CabinetElements.Find(x => x.GetEnumName() == EnumCabinetElement.Leftside).Width, false); } if (element.GetEnumName() == EnumCabinetElement.Rightside && parameter == EnumElementParameter.Width) { CabinetElements.Find(x => x.GetEnumName() == EnumCabinetElement.Top).SetHeight(_width - CabinetElements.Find(x => x.GetEnumName() == EnumCabinetElement.Leftside).Width - CabinetElements.Find(x => x.GetEnumName() == EnumCabinetElement.Rightside).Width, false); CabinetElements.Find(x => x.GetEnumName() == EnumCabinetElement.Bottom).SetHeight(_width - CabinetElements.Find(x => x.GetEnumName() == EnumCabinetElement.Leftside).Width - CabinetElements.Find(x => x.GetEnumName() == EnumCabinetElement.Rightside).Width, false); CabinetElements.Find(x => x.GetEnumName() == EnumCabinetElement.Rightside).SetX(_width - CabinetElements.Find(x => x.GetEnumName() == EnumCabinetElement.Rightside).Width, false); } if (element.GetEnumName() == EnumCabinetElement.Top && parameter == EnumElementParameter.Width) { CabinetElements.Find(x => x.GetEnumName() == EnumCabinetElement.Top).SetY(_height - CabinetElements.Find(x => x.GetEnumName() == EnumCabinetElement.Top).Width, false); } HorizontalBarrier = _mapper.Map <List <ElementModel> >(HorizontalBarrierFactory.ReCount()); VerticalBarrier = _mapper.Map <List <ElementModel> >(VerticalBarrierFactory.ReCount()); FrontList = _mapper.Map <List <ElementModel> >(FrontFactory.ReCount()); } if (find) { break; } } foreach (var item in VerticalBarrier) { if (item.GetGuid() == element.GetGuid()) { find = true; VerticalBarrier = _mapper.Map <List <ElementModel> >(VerticalBarrierFactory.Update(parameter, text, result, _mapper.Map <ElementModelDTO>(item))); element = VerticalBarrier.Find(x => x.GetGuid() == element.GetGuid()); } } foreach (var item in HorizontalBarrier) { if (item.GetGuid() == element.GetGuid()) { find = true; HorizontalBarrier = _mapper.Map <List <ElementModel> >(HorizontalBarrierFactory.Update(parameter, text, result, _mapper.Map <ElementModelDTO>(item))); element = HorizontalBarrier.Find(x => x.GetGuid() == element.GetGuid()); } } foreach (var item in FrontList) { if (item.GetGuid() == element.GetGuid()) { find = true; FrontList = _mapper.Map <List <ElementModel> >(FrontFactory.Update(parameter, text, result, _mapper.Map <ElementModelDTO>(item))); element = FrontList.Find(x => x.GetGuid() == element.GetGuid()); break; } } } return(element); }
private void RecalculateHorizontalBarrier() { Logger.Info("Recalculate Horizontal Barrier in Cabinet"); HorizontalBarrier = _mapper.Map <List <ElementModel> >(HorizontalBarrierFactory.ReCount()); }