2012-05-08 2 views
0

Sharepoint 데이터베이스 (WSS_Content)가 있지만 셰어 포인트가 설치되어 있지 않아 데이터가 필요합니다. 데이터를 검색하는 솔루션은 무엇입니까? 바이너리 배열에서 데이터로 파일/링크/사이트 데이터를 추출하는 변환기를 코딩해야하나요? 아니면 더 간단한 방법이 있습니까? 신선한 셰어 포인트를 설치하고이 데이터베이스를 사용할 수 있습니까?셰어 포인트 데이터 검색

+0

어떤 데이터가 필요하며 무엇을하고 있습니까? 사이트에서 문서를 추출하는 것만으로 간단하게 처리 할 수 ​​있습니다. –

+0

이 데이터베이스에 doc, docx, jpg, odc, pdf, pptx, zip, rar 파일이 있습니다. 파일을 추출하고 싶습니다. – Saber

답변

2

나는 이전에 콘텐츠 데이터베이스에서 모든 문서의 정말로 기본적인 추출을하는 동안 내가 가지고 있던 응용 프로그램을 파 냈다. 그것은 어떤 방식 으로든 선택적인 것이 아니며, 무엇이든간에 그저 잡을뿐입니다. 그런 다음 출력물을 선택하여 필요한 것을 얻을 수 있습니다.

나는 원래 코드가 다른 누군가로부터 왔다고 믿는다 (나는 신용 할 수없는 곳을 기억할 수 없다). 방금 해킹 했어. 자유롭게 한 발을 내줄 수 있습니다.

그냥 데이터베이스에 바로 액세스하므로 SQL Server에 탑재하면됩니다. SharePoint 서버가 필요하지 않습니다.

using System; 
using System.Data.SqlClient; 
using System.IO; 

namespace ContentDump 
{ 
    class Program 
    { 
     // Usage: ContentDump {server} {database} 
     // 
     static void Main(string[] args) 
     { 
      string server = args[0]; 
      string database = args[1]; 
      string dbConnString = String.Format("Server={0};Database={1};Trusted_Connection=True;", server, database); 

      // create a DB connection 
      SqlConnection con = new SqlConnection(dbConnString); 
      con.Open(); 

      // the query to grab all the files. 
      SqlCommand com = con.CreateCommand(); 
      com.CommandText = "SELECT ad.SiteId, ad.Id, ad.DirName," + 
       " ad.LeafName, ads.Content" + 
       " FROM AllDocs ad, AllDocStreams ads" + 
       " WHERE ad.SiteId = ads.SiteId" + 
       " AND ad.Id = ads.Id" + 
       " AND ads.Content IS NOT NULL" + 
       " Order by DirName"; 

      // execute query 
      SqlDataReader reader = com.ExecuteReader(); 

      while (reader.Read()) 
      { 
       // grab the file’s directory and name 
       string DirName = (database + "/" + (string)reader["DirName"]).Replace("//", "/"); 
       string LeafName = (string)reader["LeafName"]; 

       // create directory for the file if it doesn’t yet exist 
       if (!Directory.Exists(DirName)) 
       { 
        Directory.CreateDirectory(DirName); 
        Console.WriteLine("Creating directory: " + DirName); 
       } 

       // create a filestream to spit out the file 
       FileStream fs = new FileStream(DirName + "/" + LeafName, FileMode.Create, FileAccess.Write); 
       BinaryWriter writer = new BinaryWriter(fs); 

       int bufferSize = 1024; 
       long startIndex = 0; 
       long retval = 0; 
       byte[] outByte = new byte[bufferSize]; 

       // grab the file out of the db 
       do 
       { 
        retval = reader.GetBytes(4, startIndex, outByte, 0, bufferSize); 
        startIndex += bufferSize; 
        writer.Write(outByte, 0, (int)retval); 
        writer.Flush(); 
       } while (retval == bufferSize); 

       // finish writing the file 
       writer.Close(); 
       fs.Close(); 

       Console.WriteLine("Finished writing file: " + LeafName); 
      } 

      // close the DB connection and whatnots 
      reader.Close(); 
      con.Close(); 
     } 
    } 
}
+0

Nigel에게 감사드립니다. 그것은 내가 찾고 있었던 바로 그 것이다. – Saber

1

stsadm.exe -o addcontentdb -url -databasename 명령을 사용하여 새 sharepoint 환경과 webapp에 데이터베이스를 연결하려고 할 수 있습니다. 이 방법은 SharePoint 2007에서 2010 Farm으로 데이터베이스를 마이그레이션하는 데 사용됩니다. 그럼 당신은 webapp의 URL에 콘텐츠를 볼 수

+0

솔루션을 제공해 주셔서 감사합니다. 그러나 파일을 추출하는 것이 더 쉬웠습니다. – Saber

관련 문제