Exemplo n.º 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);
        }
Exemplo n.º 2
0
 public void Add(StateModel p_entity)
 {
     using (var db = new MES_DATABASE())
     {
         db.STA_StateList.Add(MapperState.MapStateToSTA(p_entity));
         db.SaveChanges();
     }
 }
Exemplo n.º 3
0
 public void Add(TranslationModel p_entity)
 {
     using (var db = new MES_DATABASE())
     {
         db.TRA_TranslationState.Add(MapperTranslation.MapTranslationToTra(p_entity));
         db.SaveChanges();
     }
 }
Exemplo n.º 4
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);
 }
Exemplo n.º 5
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();
     }
 }
Exemplo n.º 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();
            }
        }
Exemplo n.º 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();
            }
        }
Exemplo n.º 8
0
        public IEnumerable <ComObjectModel> RetrieveModel()
        {
            List <ComObjectModel> Temp = new List <ComObjectModel>();

            using (var db = new MES_DATABASE())
            {
                Temp = db.PLC_PLCConnectorable
                       .Select(Mapper.Map <ComObjectModel>)
                       .ToList();
            }
            return(Temp);
        }
Exemplo n.º 9
0
        public IEnumerable <UserFull> Retrieve()
        {
            List <UserFull> Temp = new List <UserFull>();

            using (var db = new MES_DATABASE())
            {
                Temp = db.USR_UserList
                       .Select(MapperUserFull.MapUSREntityToUserFull)
                       .ToList();
            }
            return(Temp);
        }
Exemplo n.º 10
0
        public UserFull Retrieve(int p_id)
        {
            UserFull Temp = new UserFull();

            using (var db = new MES_DATABASE())
            {
                Temp = db.USR_UserList.Where(x => x.ID_USR == p_id)
                       .Select(MapperUserFull.MapUSREntityToUserFull)
                       .FirstOrDefault();
            }
            return(Temp);
        }
Exemplo n.º 11
0
        public IEnumerable <TranslationDetailModel> RetrieveDetail()
        {
            List <TranslationDetailModel> Temp = new List <TranslationDetailModel>();

            using (var db = new MES_DATABASE())
            {
                Temp = db.TRA_TranslationState
                       .Select(MapperTranslation.MapTraToTranslationDetail)
                       .ToList();
            }
            return(Temp);
        }
Exemplo n.º 12
0
        public ReceivedResult Retrieve(int p_id)
        {
            ReceivedResult Temp = new ReceivedResult();

            using (var db = new MES_DATABASE())
            {
                Temp = db.RES_ResultTable
                       .Where(x => x.ID_RES == p_id)
                       .Select(Mapper.Map <ReceivedResult>)
                       .SingleOrDefault();
            }
            return(Temp);
        }
Exemplo n.º 13
0
        public IEnumerable <TranslationDetailModel> RetrieveDetailByEntityId(int p_entityID)
        {
            List <TranslationDetailModel> Temp = new List <TranslationDetailModel>();

            using (var db = new MES_DATABASE())
            {
                Temp = db.TRA_TranslationState
                       .Where(id_ent => id_ent.ID_ENT == p_entityID)
                       .Select(MapperTranslation.MapTraToTranslationDetail)
                       .ToList();
            }
            return(Temp);
        }
Exemplo n.º 14
0
        public EntityDetailModel RetrieveDetail(int p_id)
        {
            EntityDetailModel Temp = new EntityDetailModel();

            using (var db = new MES_DATABASE())
            {
                Temp = db.ENT_Entity
                       .Where(x => x.ID_ENT == p_id)
                       .Select(Mapper.Map <EntityDetailModel>)
                       .SingleOrDefault();
            }
            return(Temp);
        }
Exemplo n.º 15
0
        public TranslationDetailModel RetrieveDetail(int p_id)
        {
            var Temp = new TranslationDetailModel();

            using (var db = new MES_DATABASE())
            {
                Temp = db.TRA_TranslationState
                       .Where(id => id.ID_TRA == p_id)
                       .Select(MapperTranslation.MapTraToTranslationDetail)
                       .SingleOrDefault();
            }
            return(Temp);
        }
Exemplo n.º 16
0
        public IEnumerable <EntityModel> Retrieve()
        {
            List <EntityModel> Temp = new List <EntityModel>();

            using (var db = new MES_DATABASE())
            {
                Temp = db.ENT_Entity
                       .Select(Mapper.Map <EntityModel>)
                       .ToList();
                //.Select(MapperEntity.MapENTToMapperEntity)
            }
            return(Temp);
        }
Exemplo n.º 17
0
        public ComObjectDetailModel RetrieveDetailModel(Guid p_id)
        {
            ComObjectDetailModel Temp = new ComObjectDetailModel();

            using (var db = new MES_DATABASE())
            {
                Temp = db.ComObjecTable
                       .Where(x => x.ID_COM == p_id)
                       .Select(Mapper.Map <ComObjectDetailModel>)
                       .SingleOrDefault();
            }
            return(Temp);
        }
Exemplo n.º 18
0
        public PLCConnectorDetailModel RetrieveDetailModel(Guid p_id)
        {
            PLCConnectorDetailModel Temp = new PLCConnectorDetailModel();

            using (var db = new MES_DATABASE())
            {
                Temp = db.PLC_PLCConnectorable
                       .Where(x => x.ID_PLC == p_id)
                       .Select(Mapper.Map <PLCConnectorDetailModel>)
                       .SingleOrDefault();
            }
            return(Temp);
        }
Exemplo n.º 19
0
        public StateDetailModel RetrieveDetail(int p_id)
        {
            var Temp = new StateDetailModel();

            using (var db = new MES_DATABASE())
            {
                Temp = db.STA_StateList
                       .Where(id => id.ID_STA == p_id)
                       .Select(MapperState.MapSTAToStateDetail)
                       .SingleOrDefault();
            }
            return(Temp);
        }
Exemplo n.º 20
0
        public IEnumerable <StateDetailModel> RetrieveDetail()
        {
            List <StateDetailModel> Temp = new List <StateDetailModel>();

            using (var db = new MES_DATABASE())
            {
                Temp = db.STA_StateList
                       .Select(MapperState.MapSTAToStateDetail)
                       .ToList();
            }

            return(Temp);
        }
Exemplo n.º 21
0
        public bool GetInformation(int p_Id)
        {
            ProfileFull = new UserFull();
            bool isFound = false;

            using (var db = new MES_DATABASE())
            {
                var result = db.USR_UserList.FirstOrDefault(x => x.ID_USR == p_Id);
                ProfileFull = MapperUserFull.MapUSREntityToUserFull(result);
                isFound     = true;
            }
            return(isFound);
        }
Exemplo n.º 22
0
        public IEnumerable <StateDetailModel> RetrieveDetailByEntityId(int p_EntityId)
        {
            List <StateDetailModel> Temp = new List <StateDetailModel>();

            using (var db = new MES_DATABASE())
            {
                Temp = db.STA_StateList
                       .Where(x => x.ENT_Entity.ID_ENT == p_EntityId)
                       .Select(MapperState.MapSTAToStateDetail)
                       .ToList();
            }

            return(Temp);
        }
Exemplo n.º 23
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();
            }
        }
Exemplo n.º 24
0
        public IEnumerable <TranslationModel> GetPossibleTranslations(int ID_ENT, int ID_STA)
        {
            List <TranslationModel> Temp = new List <TranslationModel>();

            using (var db = new MES_DATABASE())
            {
                Temp = db.TRA_TranslationState
                       .Where(id_ent => id_ent.ID_ENT == ID_ENT)
                       .Where(id_sta => id_sta.ID_STA_PICA_FROM == ID_STA)
                       .Select(MapperTranslation.MapTraToTranslation)
                       .ToList();
            }
            return(Temp);
        }
Exemplo n.º 25
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();
            }
        }
Exemplo n.º 26
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();
            }
        }
Exemplo n.º 27
0
        public static bool Authenticate(User p_user)
        {
            bool result = false;

            //Přihlášení -> komunikace s entity frameworkem -> přihlášení do systému
            using (var db = new MES_DATABASE())
            {
                var getUser = db.USR_UserList.Where(x => x.LOGIN == p_user.UserName).FirstOrDefault();


                if (getUser?.PASSWORD.Trim() == p_user.Password)
                {
                    p_user.ID = getUser.ID_USR;
                    result    = true;
                }
            }
            return(result); // Do authentication against database, web service, whatever
        }
Exemplo n.º 28
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);
        }