Microsoft Content Management Server - Re: Importing Resources

This is Interesting: Free IT Magazines  
Home > Archive > Microsoft Content Management Server > July 2004 > Re: Importing Resources





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Re: Importing Resources
Stefan [MSFT]

2004-07-28, 6:10 pm

Hi Mark,

the main problem is that there is no API to create a resource gallery.
And a single resource gallerie should not hold more than 300 items. So you
would have to create the resource galleries manually.
I'm not sure why using SiteManager is a problem for you - You can add the
items by drag and drop to SiteManager which works fine.
But you can also use the API to import if you like:

using System;
using System.IO;
using Microsoft.ContentManagement.Publishing;

namespace BulkUploadConsoleApp
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class BulkResourceUpload
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
// TODO: Add code to start application here
//
// Get the CMS application context
if (args.Length < 2)
{
Console.WriteLine("Syntax: BulkUpload.exe <ResourceGallery>
<directory>");
return;
}
string ResourceGalleryPath = args[0];
string PathContainingResource = args[1];

CmsApplicationContext cmsContext = new CmsApplicationContext();

// Logon to CMS:
// Make sure to set the context to be in the Update mode (which means you
can write
// back to CMS using PAPI.
cmsContext. AuthenticateAsCurrentUser(PublishingMode
.Update);

ResourceGallery rsg = cmsContext.Searches.GetByPath(ResourceGalleryPath)
as ResourceGallery;

//Import all items in given Directory
DirectoryInfo dir = new DirectoryInfo( PathContainingResource );
int i=0;
foreach(FileSystemInfo fsi in dir.GetFileSystemInfos())
{
FileInfo f = (FileInfo)fsi;
rsg.CreateResource(f.FullName);
i++;
}

// Commit Changes back to CMS.
rsg.Resources.SortByName();
cmsContext.CommitAll();
}
}
}


Cheers,
Stefan.

--
This posting is provided "AS IS" with no warranties, and confers no rights.

MCMS FAQ:
http://download.microsoft.com/downl...6a/MCMS+2002+-+(complete)+FAQ.htm
MCMS Blog: http://blogs.msdn.com/stefan_gossner/category/4983.aspx
MCMS Sample Code:
http://www.gotdotnet.com/community/...t+S
erver

MCMS Whitepapers and other docs:
http://blogs.msdn.com/stefan_gossne...2/07/41859.aspx
--------------------------------


"Mark Goles" <MarkGoles@discussions.microsoft.com> wrote in message
news:7F7BBE7F-0B17-484B-B83D-19ADFA47BC55@microsoft.com...
> The site we are developing requires large numbers of PDF files (between

1000 and 5000 as an approximate) to be added to the Content Management
database for MCMS 2002. Because of an issue I am exploring with indexing
and searching these PDF files, it may be necessary to add all PDF files to
the site's Resource Gallery.
>
> The documentation on importing resources discusses a manual method using

Site Mangler. Obviously, this is impractical for a large-capacity load,
especially since new documents on a similar scale must be loaded once per
year (the site is connected with taxation law).
>
> How do I load large numbers of documents under program control (i.e. using

code, such as the Resource and ResourceGallery classes)?
>
> Thanks in advance for any help!
> --
> MGG



Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com