Exemple #1
0
 public void DeleteItem(String path)
 {
     try
     {
         Manager.BeginTransaction();
         Person p      = Manager.GetPerson(UC.CurrentUserID);
         long?  itemId = GetItemIdFromPath(path);
         if (itemId.HasValue && p != null)
         {
             EditorRepositoryItem item = Manager.Get <EditorRepositoryItem>(itemId.Value);
             if (item != null && item.IsDirectory)
             {
                 item.UpdateMetaInfo(p, UC.IpAddress, UC.ProxyIpAddress);
                 item.Deleted = BaseStatusDeleted.Manual;
                 Manager.SaveOrUpdate(item);
             }
             else if (item != null)
             {
                 item.UpdateMetaInfo(p, UC.IpAddress, UC.ProxyIpAddress);
                 item.Deleted = BaseStatusDeleted.Manual;
                 Manager.SaveOrUpdate(item);
             }
         }
         Manager.Commit();
     }
     catch (Exception ex) {
         Manager.RollBack();
     }
 }
Exemple #2
0
        public void UpdateItem(String path, String newPath)
        {
            String oldName = this.GetName(path);
            String newName = this.GetName(newPath);


            long?idItem = GetItemIdFromPath(path);

            if (idItem.HasValue && idItem.Value > 0)
            {
                try
                {
                    Manager.BeginTransaction();
                    EditorRepositoryItem item = Manager.Get <EditorRepositoryItem>(idItem.Value);
                    Person p = Manager.GetPerson(UC.CurrentUserID);
                    if (p != null && item != null)
                    {
                        item.UpdateMetaInfo(p, UC.IpAddress, UC.ProxyIpAddress);
                        if (oldName == newName)
                        {
                            EditorRepositoryItem newParent = this.GetParentFromPath(newPath);
                            if (newParent != null && newParent.Id > 0)
                            {
                                item.Folder = newParent;
                            }
                            else
                            {
                                item.Folder = null;
                            }
                        }
                        else
                        {
                            item.Name = newName;
                        }
                        Manager.SaveOrUpdate(item);
                    }
                    Manager.Commit();
                }
                catch (Exception ex) {
                    Manager.RollBack();
                }
            }
        }