Exemplo n.º 1
0
        public FluentControlLoop(IFluentPlant parent, string name)
        {
            try
            {

                Plant plant = parent.GetPlant();
                _parent = parent;
                _isnew = false;

                //_loop = contx.Plants.FirstOrDefault(g => g.PlantID == _plant.PlantID).PlantLoops.FirstOrDefault(g => g.EquipName == name);

                _loop = plant.PlantLoops.FirstOrDefault(g => g.EquipName == name);

                //if (_loop == null)
                //{
                //    _isnew = true;
                //    _loop = new EQControlLoop();
                //    _loop.EquipName = name;
                //    //_loop.PlantID = _plant.PlantID;
                //    _loop.PlantID = _parent.GetPlant().PlantID;
                //}
            }
            catch (Exception ex)
            {
                _message = _message + ex.ToString();

            }
        }
Exemplo n.º 2
0
        public IFluentControlLoop AddControlLoop(string s, string t)
        {
            Plant p = _parent.GetPlant();
            _loop = p.PlantLoops.FirstOrDefault(g => g.EquipName == s);
            _isnew = false;
            if (_loop == null)
            {
                try
                {
                    _isnew = true;

                    _loop = new EQControlLoop();
                    _loop.AssetTag = "111";
                    _loop.Description = "default";
                    _loop.EnableTrending = false;
                    _loop.EquipName = s;

                    _loop.EQType = contx.EQTypes.FirstOrDefault(f => f.TypeDescription == t);
                    _loop.Plant = _parent.GetPlant();
                }
                catch (Exception ex)
                {
                    _message = _message + ex.ToString();

                }
            }
            return this;
        }
Exemplo n.º 3
0
        public IFluentControlLoop ForControlLoop(string s)
        {
            _loop = contx.EQControlLoops.FirstOrDefault(g => g.EquipName == s);

            return this;
        }
Exemplo n.º 4
0
        //----------------------------------------------------------------------------------------------------
        //----------------------------------------------------------------------------------------------------
        //----------------------------------------------------------------------------------------------------
        //          Plant
        //----------------------------------------------------------------------------------------------------
        //----------------------------------------------------------------------------------------------------
        public List<EQControlLoop> AddEQControlLoopToPlant(int plantID, EQControlLoop loop)
        {
            BrewDBContext cont = new BrewDBContext();

            Plant plant = cont.Plants.FirstOrDefault(g => g.PlantID == plantID);

            plant.PlantLoops.Add(loop);

            cont.Plants.FirstOrDefault(g => g.PlantID == plantID).PlantLoops.Add(loop);
            cont.SaveChanges();

            return cont.EQControlLoops.SelectMany(g => EQControlLoops).Where(g => g.Plant.PlantID == plantID).ToList();
        }