コード例 #1
0
        public PlcConnectorModule Add(PLCConnectorModuleConfigure p_configure)
        {
            PlcConnectorModule objTemp = new PlcConnectorModule(p_configure);

            PlcConnectorModulesList.Add(objTemp);


            using (var db = new MES_DATABASE())
            {
                db.PLC_PLCConnectorable.Add(new PLC_PLCConnector()
                {
                    ID_PLC       = objTemp.Id,
                    Status       = (int)objTemp.EModuleState,
                    IP           = objTemp.PlcModuleConfigure.IpString,
                    Port         = objTemp.PlcModuleConfigure.PortString,
                    Rack         = objTemp.PlcModuleConfigure.Rack,
                    Slot         = objTemp.PlcModuleConfigure.Slot,
                    TimeCreated  = DateTime.Now,
                    TimeModified = DateTime.Now,
                    P_Created    = "Honza",
                    P_Modified   = "Honza"
                });
                db.SaveChanges();
            }


            return(objTemp);
        }
コード例 #2
0
 public void Add(StateModel p_entity)
 {
     using (var db = new MES_DATABASE())
     {
         db.STA_StateList.Add(MapperState.MapStateToSTA(p_entity));
         db.SaveChanges();
     }
 }
コード例 #3
0
 public void Add(TranslationModel p_entity)
 {
     using (var db = new MES_DATABASE())
     {
         db.TRA_TranslationState.Add(MapperTranslation.MapTranslationToTra(p_entity));
         db.SaveChanges();
     }
 }
コード例 #4
0
 public void Add(EntityModel p_entity)
 { //musi se vytvořit také základní translation a state
     using (var db = new MES_DATABASE())
     {
         // db.ENT_Entity.Add(MapperEntity.MapEntityToENT(p_entity));
         db.ENT_Entity.Add(Mapper.Map <ENT_Entity>(p_entity));
         db.SaveChanges();
     }
 }
コード例 #5
0
 public ReceivedResult Add(ReceivedResult p_entity)
 {
     using (var db = new MES_DATABASE())
     {
         db.RES_ResultTable.Add(Mapper.Map <RES_ResultTable>(p_entity));
         db.SaveChanges();
     }
     return(null);
 }
コード例 #6
0
        public void Add(UserFull p_userFull)
        {
            var Temp = MapperUserFull.MapUserFullToUSREntity(p_userFull);

            using (var db = new MES_DATABASE())
            {
                db.USR_UserList.Add(Temp);
                db.SaveChanges();
            }
        }
コード例 #7
0
        public void Edit(UserFull p_userFull)
        {
            var Temp = MapperUserFull.MapUserFullToUSREntity(p_userFull);

            using (var db = new MES_DATABASE())
            {
                db.USR_UserList.Attach(Temp);
                db.Entry(Temp).State = EntityState.Modified;
                db.SaveChanges();
            }
        }
コード例 #8
0
        public void Edit(TranslationModel p_entity)
        {
            var Temp = MapperTranslation.MapTranslationToTra(p_entity);

            using (var db = new MES_DATABASE())
            {
                if (!db.TRA_TranslationState.Local.Any(c => c.ID_TRA == p_entity.ID_TRA))
                {
                    db.TRA_TranslationState.Attach(Temp);
                    db.Entry(Temp).State = EntityState.Modified;
                }
                db.SaveChanges();
            }
        }
コード例 #9
0
        public void Edit(StateModel p_entity)
        {
            var Temp = MapperState.MapStateToSTA(p_entity);

            using (var db = new MES_DATABASE())
            {
                if (!db.STA_StateList.Local.Any(c => c.ID_STA == p_entity.ID_STA))
                {
                    db.STA_StateList.Attach(Temp);
                    db.Entry(Temp).State = EntityState.Modified;
                }

                db.SaveChanges();
            }
        }
コード例 #10
0
        public void Edit(EntityDetailModel p_entity)
        {
//            var Temp = MapperEntity.MapEntityDetilToENT(p_entity);
            var Temp = Mapper.Map <ENT_Entity>(p_entity);;

            using (var db = new MES_DATABASE())
            {
                if (!db.ENT_Entity.Local.Any(c => c.ID_ENT == p_entity.ID_ENT))
                {
                    db.ENT_Entity.Attach(Temp);
                    db.Entry(Temp).State = EntityState.Modified;
                }
                db.SaveChanges();
            }
        }
コード例 #11
0
        // bude použito ve vyšší třídě
        public int AddComobject(int p_area, int p_wordLen, int p_start, int p_iPeriod, int p_iDbNumber = 1,
                                int p_rw = 0)
        {
            var tempConfiguration = new ComObjectConfigure()
            {
                AreaOfMemory  = p_area,
                WorldLen      = p_wordLen,
                StartOffset   = p_start,
                PeriodOfCheck = p_iPeriod,
                DbNumber      = p_iDbNumber,
                ERW           = p_rw
            };
            var instance = ComObjectRepository.Instance.Add(tempConfiguration);

            CommunicationObjects.Add(instance);
            instance.StateChanged += OnChangeState;



            //tohle musí být mimo v tom prostředí
            using (var db = new MES_DATABASE())
            {
                db.ComObjecTable.Add(new COM_ComObject()
                {
                    ID_COM       = instance.Id,
                    Status       = (int)instance.EModuleState,
                    AreaMemory   = instance.ObjectConfigure.AreaOfMemory,
                    StartOffSet  = instance.ObjectConfigure.StartOffset,
                    Period       = instance.ObjectConfigure.PeriodOfCheck,
                    ReadWrite    = instance.ObjectConfigure.ERW,
                    DBnumber     = instance.ObjectConfigure.DbNumber,
                    WorldLen     = instance.ObjectConfigure.WorldLen,
                    ID_PLC       = Id,
                    P_Created    = "Honza",
                    P_Modified   = "Honza",
                    TimeCreated  = DateTime.Now,
                    TimeModified = DateTime.Now,
                });
                db.SaveChanges();
            }
            GetMinPeriod();
            return(0);
        }