Esempio n. 1
0
        /// <summary>
        /// Extract the content of a previous version of a file.
        /// </summary>
        /// <param name="documentId"></param>
        /// <param name="versionNumber"></param>
        /// <returns></returns>
        public byte[] GetFileContent(string documentId, int versionNumber)
        {
            string sSQL     = string.Format("SELECT Content FROM DocVersions WHERE Id = '{0}' AND Version = {1} ", documentId, versionNumber.ToString());
            object oContent = _DB.ExecuteScalar(sSQL);

            if (oContent is byte [])
            {
                return((byte [])oContent);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 2
0
        public static ISPDatabase CreateSPDatabase(Data.DatabaseConnector db)
        {
            string      sSQL       = "SELECT table_type FROM information_schema.tables WHERE table_name = 'Docs'";
            object      oTableType = db.ExecuteScalar(sSQL);
            ISPDatabase oDB        = null;

            if (oTableType == null || oTableType == DBNull.Value)
            {
                throw new ApplicationException("This database structure is not recognized as a Sharepoint 2003 or Sharepoint 2007 database.");
            }

            string sTableType = (string)oTableType;

            // in Sharepoint 2003, the Docs table is a BASE TABLE
            // in Sharepoint 2007, the Docs table is a VIEW
            if (sTableType == "BASE TABLE")
            {
                oDB = new SPDatabase2003(db);
            }
            else if (sTableType == "VIEW")
            {
                oDB = new SPDatabase2007(db);
            }
            else
            {
                throw new ApplicationException("This database structure is not recognized as a Sharepoint 2003 or Sharepoint 2007 database.");
            }

            return(oDB);
        }