예제 #1
0
        public InLineTag VirtualDelete(long idTag, Boolean delete)
        {
            InLineTag item = null;

            try {
                litePerson person = Manager.GetLitePerson(UC.CurrentUserID);
                item = Manager.Get <InLineTag>(idTag);
                if (item != null && person != null && person.TypeID != (int)UserTypeStandard.Guest && person.TypeID != (int)UserTypeStandard.PublicUser)
                {
                    Manager.BeginTransaction();
                    item.Deleted = (delete) ? BaseStatusDeleted.Manual : BaseStatusDeleted.None;
                    item.UpdateMetaInfo(person, UC.IpAddress, UC.ProxyIpAddress);

                    Manager.SaveOrUpdate(item);
                    Manager.Commit();
                    if (item.IdCommunity > 0)
                    {
                        CacheHelper.PurgeCacheItems(CacheKeys.ComunityTags(item.IdCommunity));
                    }
                    else if (item.IdPerson > 0)
                    {
                        CacheHelper.PurgeCacheItems(CacheKeys.UserTags(item.IdPerson));
                    }
                    else
                    {
                        CacheHelper.PurgeCacheItems(CacheKeys.AllTags);
                    }
                }
            }
            catch (Exception ex)
            {
                item = null;
                Manager.RollBack();
            }
            return(item);
        }
예제 #2
0
        //public int ServiceModuleID()
        //{
        //    return this.Manager.GetModuleID(ModuleTags.UniqueCode);
        //}
        //public ModuleTags GetPermission(Int32 idCommunity)
        //{
        //    Person person = Manager.GetPerson(UC.CurrentUserID);
        //    if (idCommunity <= 0)
        //    {
        //        if (person == null)
        //            return ModuleTags.CreatePortalmodule((int)UserTypeStandard.Guest);
        //        else
        //            return ModuleTags.CreatePortalmodule(person.TypeID);
        //    }
        //    else {
        //        return new ModuleTags(this.Manager.GetModulePermission(UC.CurrentUserID, idCommunity, ServiceModuleID()));
        //    }
        //}

        #endregion

        #region "Manage"
        public List <InLineTag> SaveTags(litePerson person, Int32 idCommunity, Int32 idModule, String moduleCode, List <String> tags)
        {
            Boolean          clearCache      = false;
            Boolean          isInTransaction = Manager.IsInTransaction();
            List <InLineTag> items           = new List <InLineTag>();

            if (person != null)
            {
                foreach (String t in tags.Where(t => !String.IsNullOrEmpty(t)))
                {
                    String    name = t.ToLower();
                    InLineTag tag  = GetTag(name, person.Id, idCommunity, idModule, moduleCode);
                    if (tag != null && tag.Deleted == BaseStatusDeleted.None)
                    {
                        items.Add(tag);
                    }
                    else if (tag != null && tag.Deleted != BaseStatusDeleted.None)
                    {
                        if (!isInTransaction)
                        {
                            Manager.BeginTransaction();
                        }
                        tag.Name     = name;
                        tag.IdPerson = person.Id;
                        tag.Deleted  = BaseStatusDeleted.None;
                        tag.UpdateMetaInfo(person, UC.IpAddress, UC.ProxyIpAddress);
                        Manager.SaveOrUpdate(tag);
                        if (!isInTransaction)
                        {
                            Manager.Commit();
                        }
                        clearCache = true;
                    }
                    else
                    {
                        tag = new InLineTag();
                        tag.CreateMetaInfo(person, UC.IpAddress, UC.ProxyIpAddress);
                        tag.IdCommunity = idCommunity;
                        tag.IdModule    = idModule;
                        tag.IdPerson    = person.Id;
                        tag.ModuleCode  = moduleCode;
                        tag.Name        = name;
                        if (!isInTransaction)
                        {
                            Manager.BeginTransaction();
                        }
                        Manager.SaveOrUpdate(tag);
                        if (!isInTransaction)
                        {
                            Manager.Commit();
                        }
                        clearCache = true;
                    }
                }
                if (clearCache)
                {
                    if (idCommunity > 0)
                    {
                        CacheHelper.PurgeCacheItems(CacheKeys.ComunityTags(idCommunity));
                    }
                    else if (person.Id > 0)
                    {
                        CacheHelper.PurgeCacheItems(CacheKeys.UserTags(person.Id));
                    }
                    else
                    {
                        CacheHelper.PurgeCacheItems(CacheKeys.AllTags);
                    }
                }
            }
            return(items);
        }