Re: FileStorage produce duplicated result

  •  10-18-2005, 2:46 PM

    Re: FileStorage produce duplicated result

    Hi,

    CMSFileStorage(HttpContext context):base(context)

    {

        apc = new CmsApplicationContext();

         apc.AuthenticateAsCurrentUser();

        c=context;

        setting=CuteEditor.EditorSetting.GetFromContext(c,true);

        //set the downloadfile RUL  

        downfile=setting["DownFile"];

    }

    public override CuteEditor.Impl.DirectoryItem[] GetDirectoryItems(string dirpath,bool getcount)

    {

        dirpath=CalcPath(VirtualRoot,dirpath);

        ArrayList arr=new ArrayList();

        if(dirpath == null || dirpath.Equals("") || dirpath == String.Empty)

        {

            dirpath = "/Resources";

        }

        ResourceGallery gallery = GetResourceGallery(dirpath); 

        foreach (ResourceGallery rg in gallery.ResourceGalleries)

        {

            CuteEditor.Impl.DirectoryItem item=new CuteEditor.Impl.DirectoryItem();

            item.Path=rg.Path;

            item.Name=rg.Name;

           if(getcount)

            {   

                item.ChildCount = rg.Resources.Count;

            }

            arr.Add(item);

        }

        return (CuteEditor.Impl.DirectoryItem[])arr.ToArray(typeof(CuteEditor.Impl.DirectoryItem));

    }

     

    public override CuteEditor.Impl.FileItem[] GetFileItems(string dirpath, string searchpattern)

    {

        dirpath=CalcPath(VirtualRoot,dirpath);

        ArrayList arr=new ArrayList();

        if(dirpath == null || dirpath.Equals("") || dirpath == String.Empty)

        {

            dirpath = "/Resources";

        }

        ResourceGallery gallery = ((ResourceGallery) apc.Searches.GetByPath(dirpath)); 

        foreach (Resource resource in gallery.Resources)

        {

            CuteEditor.Impl.FileItem item=new CuteEditor.Impl.FileItem();

            item.Path=resource.Path;

            item.Name=resource.Name;

            item.Length=resource.Size;

            item.CreationTime=item.LastWriteTime=resource.CreatedDate;

            item.Url=resource.Url;

            arr.Add(item);

        }

       return (CuteEditor.Impl.FileItem[])arr.ToArray(typeof(CuteEditor.Impl.FileItem));

    }

    private ResourceGallery GetResourceGallery(string dirpath)

    {

        return (ResourceGallery) apc.Searches.GetByPath(dirpath);

    }

    private Resource GetResource(string dirpath)

    {

        return (Resource) apc.Searches.GetByPath(dirpath);

    }

    GetDirectoryText(string dirpath)

    {

        dirpath=CalcPath(VirtualRoot,dirpath);

        if (dirpath == null || dirpath == "")

            return "/Resources";

        return dirpath;
    }  
    }
     

    public override string GetParentDirectory(string dirpath)

    {

        dirpath=CalcPath(VirtualRoot,dirpath);

        if(dirpath=="/" || dirpath=="/Resources")

            return null;


        try 
        {

            return GetResourceGallery(dirpath).Parent.Path;

        }

        catch 
        {

            throw(new Exception(dirpath));

        }

    }

    public override string GetFileName(string filepath)

    {

        filepath=CalcPath(VirtualRoot,filepath);

        return Path.GetFileName(filepath);

    }

     

    public override byte[] GetFileData(string filepath)

    {

        filepath=CalcPath(VirtualRoot,filepath);

        Resource resource = GetResource(filepath);

        object stream = resource.OpenReadStream();

        byte[] fileData = ((byte[]) stream);

        return fileData;

    }

    This is all the method that I have changed from the code that I downloaded for SQLFileStorage.  Let me know if there is anything that you would like to see. Thanks,

View Complete Thread