Ejemplo n.º 1
0
        public DataTable GetListItemAttachmentsList(SP.SPListDefinition list, int itemID, bool includeContent)
        {
            StringBuilder sbSQL = new StringBuilder();

            if (list.ListType == SharepointListType.DocumenLibrary)
            {
                sbSQL.Append("SELECT content.Id AS DocID, content.DirName AS Folder, content.LeafName AS [Filename], CheckoutDate %CONTENT_FIELD%");
                sbSQL.Append("FROM Docs content ");
                sbSQL.AppendFormat("WHERE content.ListId = '{0}' ", list.ID);
                sbSQL.AppendFormat("AND content.DocLibRowId = '{0}' ", itemID.ToString());
            }
            else
            {
                sbSQL.Append("SELECT content.Id AS DocID, content.DirName AS Folder, content.LeafName AS [Filename], CAST(NULL AS DATETIME) AS CheckoutDate %CONTENT_FIELD%");
                sbSQL.Append("FROM Docs location ");
                sbSQL.Append("INNER JOIN Docs content ON (content.ListId = location.ListId AND content.DirName = location.DirName + '/' + location.LeafName) ");
                sbSQL.AppendFormat("WHERE location.ListId = '{0}' ", list.ID);
                sbSQL.AppendFormat("AND location.LeafName = '{0}' ", itemID.ToString());
            }

            if (includeContent)
            {
                sbSQL.Replace("%CONTENT_FIELD%", ", content.Content ");
            }
            else
            {
                sbSQL.Replace("%CONTENT_FIELD%", string.Empty);
            }

            return(_DB.ExecuteDataSet(sbSQL.ToString(), "Files").Tables["Files"]);
        }
Ejemplo n.º 2
0
			public AttachmentListItem(string text, string filename, int itemID, SP.SPListDefinition parentList, string attachmentID, int versionNumber)
				: base(text)
			{
				ItemID = itemID;
				ParentList = parentList;
				AttachmentID = attachmentID;
				VersionNumber = versionNumber;
				Filename = filename;
			}
Ejemplo n.º 3
0
        public void Start(SP.ISPDatabase sharepointDatabase, SP.SPListDefinition list, UI.IProgressNotifier notifier)
        {
            notifier.Reset("Initializing...");
            _Formatter.Initialize();

            SP.SPFieldDefinitionCollection oFieldList = list.Fields;

            notifier.SetProgress("Retrieving records from Sharepoint database...", 0);

            System.Data.IDataReader oReader = sharepointDatabase.GetListItemsAsReader(list, true, false);

            oReader.Read();
            int nTotalRecords     = oReader.GetInt32(0);
            int nProcessedRecords = 0;

            notifier.SetProgress(string.Format("{0} records retrieved.  Now exporting...", nTotalRecords.ToString()), 10);

            oReader.NextResult();
            while (oReader.Read())
            {
                int nListItemID = Convert.ToInt32(oReader["ID"]);

                _Formatter.BeginExportRow(nListItemID.ToString());

                foreach (SP.SPFieldDefinition oField in oFieldList)
                {
                    _Formatter.ExportField(oField.InternalName, sharepointDatabase.GetFieldText(oField, oReader));
                }

                if (_Formatter.SupportAttachments && oReader.GetBoolean(oReader.GetOrdinal("HasAttachments")))
                {
                    DataTable oAttachmentList = sharepointDatabase.GetListItemAttachmentsList(list, nListItemID, true);
                    int       nCounter        = 1;

                    foreach (DataRow oAttachment in oAttachmentList.Rows)
                    {
                        _Formatter.ExportAttachment(nCounter, oAttachment["Folder"].ToString(), oAttachment["Filename"].ToString(), (byte[])oAttachment["Content"]);
                        nCounter++;
                    }
                }

                _Formatter.EndExportRow();
                nProcessedRecords++;

                if (nProcessedRecords % 100 == 0)
                {
                    notifier.SetProgress(null, (short)(10 + (nProcessedRecords * 90 / nTotalRecords)));
                }
            }

            _Formatter.Terminate();
            notifier.SetComplete(null);
        }
Ejemplo n.º 4
0
        public DataTable GetAttachmentHistoryList(SP.SPListDefinition list, string documentID)
        {
            StringBuilder sbSQL = new StringBuilder();

            sbSQL.Append("SELECT d.LeafName, v.Version AS VersionNumber, v.TimeCreated ");
            sbSQL.Append("FROM DocVersions v ");
            sbSQL.Append("INNER JOIN Docs d ON (d.id = v.id) ");
            sbSQL.AppendFormat("WHERE d.id = '{0}' ", documentID);
            sbSQL.Append("ORDER BY v.Version DESC ");

            return(_DB.ExecuteDataSet(sbSQL.ToString(), "History").Tables["History"]);
        }
Ejemplo n.º 5
0
        public DataTable GetAttachmentHistoryList(SP.SPListDefinition list, string documentID)
        {
            StringBuilder sbSQL = new StringBuilder();

            //2008-02-21:	Fix to better handle a file when checked-out.
            //				DocStreams.Level usually equals 1 for the last checked-in version.
            //				DocStreams.Level equals 255 for the "pending" checked-out version (saved but not checked-in).
            //
            //				When a document is pending (checked-out) there is 2 records in the Docs table
            //				with the same Id.  We can differentiate them by the version number (Version field) or by the
            //				IsCurrentVersion flag.
            sbSQL.Append("SELECT d.LeafName, v.Version AS VersionNumber, v.TimeCreated ");
            sbSQL.Append("FROM DocVersions v ");
            sbSQL.Append("INNER JOIN Docs d ON (d.id = v.id AND d.IsCurrentVersion = 1) ");
            sbSQL.AppendFormat("WHERE d.id = '{0}' ", documentID);
            sbSQL.Append("ORDER BY v.Version DESC ");

            return(_DB.ExecuteDataSet(sbSQL.ToString(), "History").Tables["History"]);
        }
Ejemplo n.º 6
0
        public DataTable GetListItemAttachmentsList(SP.SPListDefinition list, int itemID, bool includeContent)
        {
            StringBuilder sbSQL = new StringBuilder();

            if (list.ListType == SharepointListType.DocumenLibrary)
            {
                //2008-02-21:	Fix to better handle a file when checked-out.
                //				DocStreams.Level usually equals 1 for the last checked-in version.
                //				DocStreams.Level equals 255 for the "pending" checked-out version (saved but not checked-in).
                //
                //				When a document is pending (checked-out) there is 2 records in the Docs table
                //				with the same Id.  We can differentiate them by the version number (Version field) or by the
                //				IsCurrentVersion flag.
                sbSQL.Append("SELECT docs.Id AS DocID, docs.DirName AS Folder, docs.LeafName AS [Filename], CheckoutDate %CONTENT_FIELD%");
                sbSQL.Append("FROM Docs docs ");
                sbSQL.Append("INNER JOIN DocStreams content ON (content.Id = docs.Id AND content.Level < 255) ");
                sbSQL.AppendFormat("WHERE docs.ListId = '{0}' ", list.ID);
                sbSQL.AppendFormat("AND docs.DocLibRowId = '{0}' ", itemID.ToString());
                sbSQL.AppendFormat("AND docs.HasStream = CONVERT(bit, 1) ");
                sbSQL.AppendFormat("AND docs.IsCurrentVersion = CONVERT(bit, 1) ");
            }
            else
            {
                sbSQL.Append("SELECT docs.Id AS DocID, docs.DirName AS Folder, docs.LeafName AS [Filename], CAST(NULL AS DATETIME) AS CheckoutDate %CONTENT_FIELD%");
                sbSQL.Append("FROM Docs parentItem ");
                sbSQL.Append("INNER JOIN DocStreams content ON (content.ParentId = parentItem.Id) ");
                sbSQL.Append("INNER JOIN Docs docs ON (docs.Id = content.Id) ");
                sbSQL.AppendFormat("WHERE parentItem.ListId = '{0}' ", list.ID);
                sbSQL.AppendFormat("AND parentItem.LeafName = '{0}' ", itemID.ToString());
            }

            if (includeContent)
            {
                sbSQL.Replace("%CONTENT_FIELD%", ", content.Content ");
            }
            else
            {
                sbSQL.Replace("%CONTENT_FIELD%", string.Empty);
            }

            return(_DB.ExecuteDataSet(sbSQL.ToString(), "Files").Tables["Files"]);
        }
Ejemplo n.º 7
0
			public PreviewListItem(string text, int itemID, SP.SPListDefinition parentList)
				:base(text)
			{
				ItemID = itemID;
				ParentList = parentList;
			}
Ejemplo n.º 8
0
			public ListNode(SP.SPListDefinition list)
				: base(list.Title, list.ID)
			{
				SharepointList = list;
				int nImageIndex = 1;

				if (SharepointList.ListType == SP.SharepointListType.DocumenLibrary)
					nImageIndex = 2;

				this.ImageIndex = nImageIndex;
				this.SelectedImageIndex = nImageIndex;
			}