public List <TagDTO> GetTags()
        {
            using (TagEFRepository TagRep = new TagEFRepository(""))
            {
                List <Tag>    Tags      = TagRep.Context.Tags.ToList();
                List <TagDTO> LstTagDto = new List <TagDTO>();
                var           config    = new MapperConfiguration(cfg =>
                {
                    cfg.CreateMap <Tag, TagDTO>()
                    .ForMember(dest => dest.IdTag, opt => opt.MapFrom(src => src.IdTag))
                    .ForMember(dest => dest.Description, opt => opt.MapFrom(src => (((bool)(src.Description == "")) ? src.Description : ((bool)(src.Description.Length < 200)) ? src.Description : src.Description.Substring(0, 200) + "...")))
                    .ForMember(dest => dest.Enabled, opt => opt.MapFrom(src => (((bool)src.Enabled) ? "YES" : "NO")));
                });
                //var config = new MapperConfiguration(cfg =>
                //{
                //    cfg.CreateMap<Tag, TagDTO>()
                //     .ForMember(dest => dest.IdTag, opt => opt.MapFrom(src => src.Id))
                //      .ForMember(dest => dest.Description, opt => opt.MapFrom(src => src.Description))
                //     .ForMember(dest => dest.Enabled, opt => opt.MapFrom(src => (((bool)src.Enabled) ? "YES" : "NO")));
                //});
                IMapper mapper = config.CreateMapper();

                LstTagDto = mapper.Map <List <Tag>, List <TagDTO> >(Tags);

                //foreach (User Usr in Users)
                //{
                //  List<Audit> LstAud = Usr.Audits.ToList();
                //    Role Rol = Usr.Role;
                //}

                return(LstTagDto);
            }
        }
 public void DeleteEntity(Int32 IdEntity)
 {
     using (TagEFRepository TagRep = new TagEFRepository(""))
     {
         var entity = new Tag {
             IdTag = IdEntity
         };
         TagRep.Context.Entry(entity).State = EntityState.Deleted;
         TagRep.Context.SaveChanges();
     }
 }
Beispiel #3
0
        public Tag GetSelectedTag(int IdEntity)
        {
            Tag Ent = null;

            using (TagEFRepository Rep = new TagEFRepository(""))
            {
                Ent = Rep.Context.Tags.Where(x => x.IdTag == IdEntity).FirstOrDefault();
            }

            return(Ent);
        }
Beispiel #4
0
        public Tag InsertTag()
        {
            Tag NewTag = new Tag();


            NewTag.TagName     = TxtNomeTag.Text;
            NewTag.Machine     = TxtMachine.Text;
            NewTag.Enabled     = Convert.ToBoolean(CboEnable.SelectedValue);
            NewTag.Description = TxtDescription.Text;
            NewTag.Node        = TxtNode.Text;
            NewTag.Device      = TxtDevice.Text;
            NewTag.ValueType   = TxtValueType.Text;
            NewTag.IdTagValue  = Convert.ToInt32(CboTagValue.SelectedValue);
            NewTag.Alarm       = Convert.ToInt32(CboAlarm.SelectedValue);

            using (TagEFRepository TagRep = new TagEFRepository(""))
            {
                TagRep.Context.Tags.Add(NewTag);
                TagRep.Context.SaveChanges();
            }

            return(NewTag);
        }
        public Tag InsertTag(Tag CurrTag)
        {
            Tag NewTag = new Tag();


            NewTag.TagName     = CurrTag.TagName;
            NewTag.Machine     = CurrTag.Machine;
            NewTag.Enabled     = true;
            NewTag.Description = CurrTag.Description;
            NewTag.Node        = CurrTag.Node;
            NewTag.Device      = CurrTag.Device;
            NewTag.ValueType   = CurrTag.ValueType;
            NewTag.IdTagValue  = Convert.ToInt32(CurrTag.IdTagValue);
            NewTag.Alarm       = Convert.ToInt32(CurrTag.Alarm);

            using (TagEFRepository TagRep = new TagEFRepository(""))
            {
                TagRep.Context.Tags.Add(NewTag);
                TagRep.Context.SaveChanges();
            }

            return(NewTag);
        }
Beispiel #6
0
        public Tag UpdateTag(int Id)
        {
            Tag result = null;

            using (TagEFRepository TagRep = new TagEFRepository(""))
            {
                result = TagRep.Context.Tags.SingleOrDefault(x => x.IdTag == Id);
                if (result != null)
                {
                    result.TagName     = TxtNomeTag.Text;
                    result.Machine     = TxtMachine.Text;
                    result.Enabled     = Convert.ToBoolean(CboEnable.SelectedValue);
                    result.Description = TxtDescription.Text;
                    result.Node        = TxtNode.Text;
                    result.Device      = TxtDevice.Text;
                    result.ValueType   = TxtValueType.Text;
                    result.IdTagValue  = Convert.ToInt32(CboTagValue.SelectedValue);
                    result.Alarm       = Convert.ToInt32(CboAlarm.SelectedValue);

                    TagRep.Context.SaveChanges();
                }
            }
            return(result);
        }
Beispiel #7
0
        protected void BtnConfirmDeleting_Click(object sender, EventArgs e)
        {
            try
            {
                Int32 IdToDelete = Convert.ToInt32(HydIdToDelete.Value);

                TagEFRepository rep = new TagEFRepository("");
                Tag             TagToStoreInAudit = rep.SelectEntity(IdToDelete);

                DeleteEntity(IdToDelete);

                AuditPageManager ObjPageManager = new AuditPageManager();
                ObjPageManager.InsertAudit(LoginUsr, "Tag deleted: " + TagToStoreInAudit.TagName + ", Machine: " + TagToStoreInAudit.Machine);


                BindRepeater();

                DivDelete.Attributes.Add("Class", "ParentDivDeleting Disattivato");
            }
            catch (Exception ex)
            {
                PrintError(ex);
            }
        }