Aracılığıyla paylaş


İzlenecek yol: SharePoint proje öğesi türü genişletme

Kullanabileceğiniz İş Verileri Bağlantısı modeli SharePoint'te Business veri bağlantısı (bdc) hizmeti için bir model oluşturmak için proje öğesi.Bu proje öğesi kullanılarak bir model oluştururken, varsayılan olarak, veri modeli kullanıcılara görüntülenmez.Ayrıca kullanıcıların verileri görüntülemek SharePoint Dış liste oluşturmanız gerekir.

Bu izlenecek yolda, bir uzantı için oluşturacağınız İş Verileri Bağlantısı modeli proje öğesi.Geliştiriciler uzantısı İVB modelindeki verileri görüntüler onların projedeki dış liste oluşturmak için kullanabilirsiniz.Bu izlenecek yolda aşağıdaki görevler gösterilir:

  • Visual Studio uzantısı oluşturma iki ana görevleri gerçekleştirir:

    • Bu dış liste verileri görüntüleyen bir İVB Modeli oluşturur.Uzantı listesi tanımlayan bir Elements.xml dosyası oluşturmak için SharePoint proje sistemi nesne modeli kullanır.İVB Modeli ile birlikte dağıtılan olduğunu da projeye dosya ekler.

    • Bir kısayol menü öğesi ekler İş Verileri Bağlantısı modeli proje öğelerini Çözüm Gezgini.Geliştiriciler İVB Modeli için bir dış liste oluşturmak için bu menü öğesini tıklatabilirsiniz.

  • Uzantısı derleme dağıtmak için Visual Studio Uzantısı (VSIX) paket oluşturma.

  • Test uzantısı.

Önkoşullar

Geliştirme bilgisayarında Bu izlenecek yolu tamamlamak için aşağıdaki bileşenler gerekmektedir:

Yararlı, ancak gerekli değildir, izlenecek yolu tamamlamak için aşağıdaki kavramları hakkında bilgi:

  • İVB Hizmeti Microsoft SharePoint Server 2010.Daha fazla bilgi için bkz: İVB mimari.

  • İVB modellerini xml şeması.Daha fazla bilgi için bkz: İVB modelini altyapı.

Proje Oluşturma

Bu izlenecek yolu tamamlamak için iki proje oluşturmanız gerekir:

  • Proje öğesi uzantısı dağıtmak için VSIX paketi oluşturmak için bir VSIX proje.

  • Proje öğesi uzantısı uygulayan bir sınıf kitaplığı projesi.

İzlenecek yol, projeler oluşturmaya başlayın.

VSIX projesi oluşturmak için

  1. Visual Studio uygulamasını başlatın.

  2. Menü çubuğunda Seç Dosya, Yeni, Proje.

  3. İçinde Yeni Proje iletişim kutusunda, genişletme Visual C# veya Visual Basic düğümler ve sonra seçin genişletilebilirlik düğümü.

    [!NOT]

    Genişletilebilirlik düğüm, Visual Studio sdk yüklüyorsanız kullanılabilir.Daha fazla bilgi için bu konudaki Önkoşullar bölümüne bakın.

  4. Üst kısmındaki listeden Yeni bir proje iletişim kutusunda, seçim .net Framework 4.5.

    Özellikleri .NET Framework'ün bu sürümünde SharePoint Araçları uzantılarını isteyebilir.

  5. Seçim VSIX projesi şablonu.

  6. İçinde adı kutusuna girin GenerateExternalDataListsve sonra Tamam düğmesi.

    Visual Studioekler GenerateExternalDataLists için proje Çözüm Gezgini.

  7. Source.extension.vsixmanifest dosya otomatik olarak açılmazsa, GenerateExternalDataLists projesinde kısayol menüsünü açmak ve sonra seçin açın

  8. Source.extension.vsixmanifest dosya boş olmayan girdi olduğunu doğrulayın (Contoso girin) yazar alan için dosyayı kaydedin ve kapatın.

Uzantı projesi oluşturmak için

  1. İçinde Çözüm Gezgini, kısayol menüsünü açma GenerateExternalDataLists çözüm düðümünü seçin Ekleve sonra seçin Yeni Proje.

    [!NOT]

    Visual Basic projesinde, çözüm düğümüne görünür Çözüm Gezgini sadece her zaman çözümü Göster onay kutusu seçildiğinde, General, Projects and Solutions, Options Dialog Box.

  2. İçinde Yeni Proje Ekle iletişim kutusunda, genişletme Visual C# veya Visual Basic düğümleri ve seçin Windows düğüm.

  3. İletişim kutusunun en üstündeki listeden seçin .net Framework 4.5.

  4. Proje şablonları listesinde seçim Class Library.

  5. İçinde adı kutusuna girin BdcProjectItemExtensionve sonra Tamam düğmesi.

    Visual Studioekler BdcProjectItemExtension projesi çözüme ve varsayılan Class1 kod dosyasını açar.

  6. Projeden Class1 kod dosyasını silin.

Uzantı projesi yapılandırma

Proje öğesi uzantısı oluşturmak için kod yazmadan önce kod dosyaları ve uzantı projesi derleme başvurularını ekleyin.

Projeyi Yapılandırma

  1. BdcProjectItemExtension projesinde aşağıdaki adlara sahip iki kod dosyaları ekleyin:

    • ProjectItemExtension

    • GenerateExternalDataLists

  2. BdcProjectItemExtension projeyi seçin ve sonra menü çubuğunda Proje, Add Reference.

  3. Altında derlemeleri düğümü seçin Framework düğümü ve her biri aşağıdaki derlemeler için onay kutusunu seçin:

    • System.ComponentModel.Composition

    • WindowsBase

  4. Altında derlemeleri düğümü seçin uzantıları düğümünü ve sonra onay kutusunu seçin aşağıdaki derleme:

    • Microsoft.VisualStudio.SharePoint
  5. Tamam düğmesini seçin.

Proje öğesi uzantısı tanımlama

Uzantı için tanımlayan bir sınıf oluşturmak İş Verileri Bağlantısı modeli proje öğesi.Sınıf uygular uzantısı tanımlamak için ISharePointProjectItemTypeExtension arabirim.Varolan bir proje öğesi türünü genişletmek istediğinizde bu arabirimi uygulayın.

Proje öğesi uzantısı tanımlamak için

  • Aşağıdaki kodu yapıştırın ProjectItemExtension kod dosyası.

    [!NOT]

    Bu kodu ekledikten sonra projenin bazı derleme hataları olacaktır.Sonraki adımda kod eklediğinizde, bu hatalar kaybolacak.

    Imports Microsoft.VisualStudio.SharePoint
    Imports System.ComponentModel.Composition
    
    Namespace Contoso.SharePointProjectItemExtensions.GenerateExternalDataLists
    
        ' Export attribute: Enables Visual Studio to discover and load this extension.
        ' SharePointProjectItemType attribute: Specifies the ID of the project item to extend.
        ' GenerateExternalDataListsExtension class: Defines the extension for the BDC project item.
        '     The other part of the partial class contains the logic for generating the external data lists. 
        <Export(GetType(ISharePointProjectItemTypeExtension))> _
        <SharePointProjectItemType("Microsoft.VisualStudio.SharePoint.BusinessDataConnectivity")> _
        Partial Friend Class GenerateExternalDataListsExtension
            Implements ISharePointProjectItemTypeExtension
    
            ' Creates the new shortcut menu item that the user clicks to generate the external data lists.
            Private Sub Initialize(ByVal SharePointProjectItemType As ISharePointProjectItemType) _
                Implements ISharePointProjectItemTypeExtension.Initialize
                AddHandler SharePointProjectItemType.ProjectItemMenuItemsRequested,
                    AddressOf SharePointProjectItemMenuItemsRequested
            End Sub
    
            Private Sub SharePointProjectItemMenuItemsRequested(ByVal Sender As Object, _
                ByVal e As SharePointProjectItemMenuItemsRequestedEventArgs)
                Dim generateListMenuItem As IMenuItem = e.ViewMenuItems.Add("Generate External Data List")
                AddHandler generateListMenuItem.Click, AddressOf GenerateExternalDataLists_Execute
            End Sub
        End Class
    End Namespace
    
    using Microsoft.VisualStudio.SharePoint;
    using System.ComponentModel.Composition;
    
    namespace Contoso.SharePointProjectItemExtensions.GenerateExternalDataLists
    {
        // Enables Visual Studio to discover and load this extension.
        [Export(typeof(ISharePointProjectItemTypeExtension))]
    
        // Specifies the ID of the project item to extend.
        [SharePointProjectItemType("Microsoft.VisualStudio.SharePoint.BusinessDataConnectivity")]
    
        // Defines the extension for the BDC project item. The other part of the partial class contains
        // the logic for generating the external data lists. 
        internal partial class GenerateExternalDataListsExtension : ISharePointProjectItemTypeExtension
        {
            // Implements IProjectItemTypeExtension.Initialize. Creates the new shortcut menu item that
            // the user clicks to generate the external data lists.
            public void Initialize(ISharePointProjectItemType projectItemType)
            {
                projectItemType.ProjectItemMenuItemsRequested += ProjectItemMenuItemsRequested;
            }
    
            private void ProjectItemMenuItemsRequested(object sender, SharePointProjectItemMenuItemsRequestedEventArgs e)
            {
                e.ViewMenuItems.Add("Generate External Data List").Click += GenerateExternalDataLists_Execute;
            }
        }
    }
    

Dış veri listeleri oluşturma

Kısmi tanımlaması Ekle GenerateExternalDataListsExtension sınıfı İVB modelindeki her varlık için bir dış veri listesi oluşturur.Dış veri listesi oluşturmak için bu kodu ilk varlık bdc Modeli verileri İVB Modeli dosyası xml verilerinin ayrıştırarak okur.Daha sonra İVB modelini temel alır ve bu liste örnek projeye ekler liste örneğini oluşturur.

Dış veri listeleri oluşturmak için

  • GenerateExternalDataLists kod dosyasına aşağıdaki kodu yapıştırın.

    Imports Microsoft.VisualStudio.SharePoint
    Imports Microsoft.VisualBasic
    Imports System
    Imports System.Collections.Generic
    Imports System.IO
    Imports System.Linq
    Imports System.Text
    Imports System.Xml.Linq
    
    Namespace Contoso.SharePointProjectItemExtensions.GenerateExternalDataLists
    
        ' Creates the external data lists for the BDC item. The other part of the partial class 
        ' defines the BDC project item extension.
        Partial Friend Class GenerateExternalDataListsExtension
    
            Private Const ModelFileNameString As String = "ModelFileName"
            Private Const EXTENSION_BDCM As String = ".bdcm"
            Private Const NamespaceString As String = "https://schemas.microsoft.com/windows/2007/BusinessDataCatalog"
            Private Shared ReadOnly BdcNamespace As XNamespace = XNamespace.Get(NamespaceString)
    
            ' Generates an external data list for each Entity in the BDC model. This event handler is called
            ' when the developer clicks the shortcut menu item that the extension adds to the BDC project item.
            Private Sub GenerateExternalDataLists_Execute(ByVal Sender As Object, ByVal e As MenuItemEventArgs)
    
                Dim projectItem As ISharePointProjectItem = CType(e.Owner, ISharePointProjectItem)
                Dim bdcmFile As ISharePointProjectItemFile = GetModelFile(projectItem)
    
                Dim doc As XDocument = XDocument.Load(bdcmFile.FullPath)
                Dim skippedEntities As List(Of XElement) = New List(Of XElement)()
    
                ' Try to generate an external data list for each entity defined in the BDC model file.
                For Each entity As XElement In doc.Root.Elements(BdcNamespace + "LobSystems").Elements( _
                    BdcNamespace + "LobSystem").Elements(BdcNamespace + "Entities").Elements(BdcNamespace + "Entity")
    
                    If False = GenerateExternalDataList(projectItem, entity) Then
                        skippedEntities.Add(entity)
                    End If
                Next
    
                ' Report skipped entities.
                If skippedEntities.Count <> 0 Then
                    Dim entityNameList As StringBuilder = Nothing
                    skippedEntities.ForEach(Function(entity As XElement)
                                                If (entityNameList Is Nothing) Then
                                                    entityNameList = New StringBuilder()
                                                Else
                                                    entityNameList.AppendLine(",")
                                                End If
                                                entityNameList.Append(entity.Attribute("Name").Value)
                                            End Function)
    
                    Dim message As String = String.Format("The following Entities were skipped because " &
                        "either a LobSystemInstance, SpecificFinder, or Finder was not found for them. \r\n{0}", _
                        entityNameList)
                    projectItem.Project.ProjectService.Logger.WriteLine(message, LogCategory.Warning)
                End If
            End Sub
    
            ' Gets the ISharePointProjectItemFile object for the BDC model file.
            Private Function GetModelFile(ByVal projectItem As ISharePointProjectItem) As ISharePointProjectItemFile
    
                Dim modelFileName As String = Nothing
                If projectItem.FeatureProperties.TryGetValue(ModelFileNameString, modelFileName) Then
                    modelFileName = Path.GetFileName(modelFileName)
                    Return (From file In projectItem.Files _
                            Where String.Compare(file.Name, modelFileName, StringComparison.OrdinalIgnoreCase) = 0 _
                            Select file).FirstOrDefault()
                Else
                    ' If we can't find the ModelFileName through the FeatureProperties, 
                    ' get the first file that has a '.bdcm' extension
                    Return (From file In projectItem.Files _
                            Where file.Name.EndsWith(EXTENSION_BDCM, StringComparison.OrdinalIgnoreCase) _
                            Select file).FirstOrDefault()
                End If
            End Function
    
            ' Boilerplate XML for the new list instance that is based on the BDC model.
            Private Const externalDataListContent As String = _
                "<?xml version=""1.0"" encoding=""utf-8""?>" & vbCrLf & _
                "        <Elements https://schemas.microsoft.com/sharepoint/"">" & vbCrLf & _
                "          <ListInstance Title=""$EntityName$DataList""" & vbCrLf & _
                "                        OnQuickLaunch=""TRUE""" & vbCrLf & _
                "                        TemplateType=""104""" & vbCrLf & _
                "                        FeatureId=""$SharePoint.Feature.Id$""" & vbCrLf & _
                "                        Url=""Lists/$EntityName$DataList""" & vbCrLf & _
                "                        Description=""Default List for $EntityName$."">" & vbCrLf & _
                "            <DataSource>" & vbCrLf & _
                "              <Property Name=""LobSystemInstance"" Value=""$LobSystemInstance$"" />" & vbCrLf & _
                "              <Property Name=""EntityNamespace"" Value=""$EntityNamespace$"" />" & vbCrLf & _
                "              <Property Name=""Entity"" Value=""$EntityName$"" />" & vbCrLf & _
                "              <Property Name=""SpecificFinder"" Value=""$SpecificFinder$"" />" & vbCrLf & _
                "              <Property Name=""Finder"" Value=""$Finder$"" />" & vbCrLf & _
                "            </DataSource>" & vbCrLf & _
                "          </ListInstance>" & vbCrLf & _
                "        </Elements>"
    
            ' Tries to generate an external data list for the specified BDC model project item and entity.
            Private Function GenerateExternalDataList(ByVal projectItem As ISharePointProjectItem, ByVal entity As XElement) As Boolean
    
                Dim lobSystemInstanceName As String = GetLobSystemInstanceName(entity)
                Dim specificFinderName As String = GetSpecificFinderName(entity)
                Dim finderName As String = GetFinderName(entity)
                Dim entityName As String = entity.Attribute("Name").Value
    
                If String.IsNullOrEmpty(lobSystemInstanceName) Or String.IsNullOrEmpty(specificFinderName) Or _
                    String.IsNullOrEmpty(finderName) Then
                    Return False
                End If
    
                Dim newExternalDataListName As String = entityName & "DataList"
                Dim existingProjectItem As ISharePointProjectItem = (From existingItem As ISharePointProjectItem In projectItem.Project.ProjectItems
                                                    Where existingItem.Name = newExternalDataListName
                                                    Select existingItem).FirstOrDefault()
    
                ' Add a new list instance and populate it with data from the BDC model.
                If existingProjectItem Is Nothing Then
                    Dim newExternalDataList As ISharePointProjectItem = projectItem.Project.ProjectItems.Add(newExternalDataListName, _
                        "Microsoft.VisualStudio.SharePoint.ListInstance")
    
                    Dim newExternalDataListString As String = externalDataListContent
                    newExternalDataListString = newExternalDataListString.Replace("$EntityName$", entityName)
                    newExternalDataListString = newExternalDataListString.Replace("$LobSystemInstance$", lobSystemInstanceName)
                    newExternalDataListString = newExternalDataListString.Replace("$EntityNamespace$", entity.Attribute("Namespace").Value)
                    newExternalDataListString = newExternalDataListString.Replace("$SpecificFinder$", specificFinderName)
                    newExternalDataListString = newExternalDataListString.Replace("$Finder$", finderName)
    
                    Dim elementsXmlPath As String = Path.Combine(newExternalDataList.FullPath, "Elements.xml")
                    File.WriteAllText(elementsXmlPath, newExternalDataListString)
                    Dim elementsFile As ISharePointProjectItemFile = newExternalDataList.Files.AddFromFile(elementsXmlPath)
                    elementsFile.DeploymentType = DeploymentType.ElementManifest
                End If
    
                Return True
            End Function
    
            Private Function GetLobSystemInstanceName(ByVal entity As XElement) As String
    
                Dim lobSystemInstances As XElement = entity.Parent.Parent.Element(BdcNamespace + "LobSystemInstances")
                If lobSystemInstances IsNot Nothing Then
                    Dim lobSystemInstance As XElement = lobSystemInstances.Elements(BdcNamespace + "LobSystemInstance").FirstOrDefault()
                    If lobSystemInstance IsNot Nothing Then
                        Return lobSystemInstance.Attribute("Name").Value
                    End If
                End If
                Return Nothing
            End Function
    
            Private Function GetSpecificFinderName(ByVal entity As XElement) As String
                Return GetMethodInstance(entity, "SpecificFinder")
            End Function
    
            Private Function GetFinderName(ByVal entity As XElement) As String
                Return GetMethodInstance(entity, "Finder")
            End Function
    
            Private Function GetMethodInstance(ByVal entity As XElement, ByVal methodInstanceType As String) As String
                Dim methods As XElement = entity.Element(BdcNamespace + "Methods")
                If methods IsNot Nothing Then
                    For Each method As XElement In methods.Elements(BdcNamespace + "Method")
                        Dim methodInstances As XElement = method.Element(BdcNamespace + "MethodInstances")
                        If methodInstances IsNot Nothing Then
                            For Each methodInstance As XElement In methodInstances.Elements(BdcNamespace + "MethodInstance")
                                If methodInstance.Attribute("Type").Value = methodInstanceType Then
                                    Return methodInstance.Attribute("Name").Value
                                End If
                            Next
                        End If
                    Next
                End If
                Return Nothing
            End Function
    
        End Class
    End Namespace
    
    using Microsoft.VisualStudio.SharePoint;
    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    using System.Text;
    using System.Xml.Linq;
    
    namespace Contoso.SharePointProjectItemExtensions.GenerateExternalDataLists
    {
        // Creates the external data lists for the BDC item. The other part of the partial class 
        // defines the BDC project item extension.
        internal partial class GenerateExternalDataListsExtension
        {
            private const string ModelFileNameString = "ModelFileName";
            private const string EXTENSION_BDCM = ".bdcm";
            private const string NamespaceString = "https://schemas.microsoft.com/windows/2007/BusinessDataCatalog";
            private static readonly XNamespace BdcNamespace = XNamespace.Get(NamespaceString);
    
            // Generates an external data list for each Entity in the BDC model. This event handler is called
            // when the developer clicks the shortcut menu item that the extension adds to the BDC project item.
            private void GenerateExternalDataLists_Execute(object sender, MenuItemEventArgs e)
            {
                ISharePointProjectItem projectItem = (ISharePointProjectItem)e.Owner;
                ISharePointProjectItemFile bdcmFile = GetModelFile(projectItem);
    
                XDocument doc = XDocument.Load(bdcmFile.FullPath);
                List<XElement> skippedEntities = new List<XElement>();
    
                // Try to generate an external data list for each entity defined in the BDC model file.
                foreach (XElement entity in doc.Root.Elements(BdcNamespace + "LobSystems").Elements(
                    BdcNamespace + "LobSystem").Elements(BdcNamespace + "Entities").Elements(BdcNamespace + "Entity"))
                {
                    if (!GenerateExternalDataList(projectItem, entity))
                    {
                        skippedEntities.Add(entity);
                    }
                }
    
                // Report skipped entities.
                if (skippedEntities.Count != 0)
                {
                    StringBuilder entityNameList = null;
                    skippedEntities.ForEach(delegate(XElement entity)
                    {
                        if (entityNameList == null)
                        {
                            entityNameList = new StringBuilder();
                        }
                        else
                        {
                            entityNameList.AppendLine(",");
                        }
                        entityNameList.Append(entity.Attribute("Name").Value);
                    });
    
                    string message = string.Format("The following Entities were skipped because either a LobSystemInstance, " +
                        "SpecificFinder, or Finder was not found for them. \r\n{0}", entityNameList);
                    projectItem.Project.ProjectService.Logger.WriteLine(message, LogCategory.Warning);
                }
            }
    
            // Gets the ISharePointProjectItemFile object for the BDC model file.
            private ISharePointProjectItemFile GetModelFile(ISharePointProjectItem projectItem)
            {
                string modelFileName;
                if (projectItem.FeatureProperties.TryGetValue(ModelFileNameString, out modelFileName))
                {
                    modelFileName = Path.GetFileName(modelFileName);
                    return (from file in projectItem.Files
                            where string.Compare(file.Name, modelFileName, StringComparison.OrdinalIgnoreCase) == 0
                            select file).FirstOrDefault();
                }
                else
                {
                    // if we can't find the ModelFileName through the FeatureProperties, 
                    // get the first file that has a '.bdcm' extension
                    return (from file in projectItem.Files
                            where file.Name.EndsWith(EXTENSION_BDCM, StringComparison.OrdinalIgnoreCase)
                            select file).FirstOrDefault();
                }
            }
    
            // Boilerplate XML for the new list instance that is based on the BDC model.
            private const string externalDataListContent =
                @"<?xml version=""1.0"" encoding=""utf-8""?>
                <Elements https://schemas.microsoft.com/sharepoint/"">
                  <ListInstance Title=""$EntityName$DataList""
                                OnQuickLaunch=""TRUE""
                                TemplateType=""104""
                                FeatureId=""$SharePoint.Feature.Id$""
                                Url=""Lists/$EntityName$DataList""
                                Description=""Default List for $EntityName$."">
                    <DataSource>
                      <Property Name=""LobSystemInstance"" Value=""$LobSystemInstance$"" />
                      <Property Name=""EntityNamespace"" Value=""$EntityNamespace$"" />
                      <Property Name=""Entity"" Value=""$EntityName$"" />
                      <Property Name=""SpecificFinder"" Value=""$SpecificFinder$"" />
                      <Property Name=""Finder"" Value=""$Finder$"" />
                    </DataSource>
                  </ListInstance>
                </Elements>";
    
            // Tries to generate an external data list for the specified BDC model project item and entity.
            private bool GenerateExternalDataList(ISharePointProjectItem projectItem, XElement entity)
            {
                string lobSystemInstanceName = GetLobSystemInstanceName(entity);
                string specificFinderName = GetSpecificFinderName(entity);
                string finderName = GetFinderName(entity);
                string entityName = entity.Attribute("Name").Value;
    
                if (string.IsNullOrEmpty(lobSystemInstanceName) || string.IsNullOrEmpty(specificFinderName) || 
                    string.IsNullOrEmpty(finderName))
                {
                    return false;
                }
    
                string newExternalDataListName = entityName + "DataList";
                ISharePointProjectItem existingProjectItem = (from ISharePointProjectItem existingItem in projectItem.Project.ProjectItems
                                                    where existingItem.Name == newExternalDataListName
                                                    select existingItem).FirstOrDefault();
    
                // Add a new list instance and populate it with data from the BDC model.
                if (existingProjectItem == null)
                {
                    ISharePointProjectItem newExternalDataList = projectItem.Project.ProjectItems.Add(newExternalDataListName, 
                        "Microsoft.VisualStudio.SharePoint.ListInstance");
    
                    string newExternalDataListString = externalDataListContent;
                    newExternalDataListString = newExternalDataListString.Replace("$EntityName$", entityName);
                    newExternalDataListString = newExternalDataListString.Replace("$LobSystemInstance$", lobSystemInstanceName);
                    newExternalDataListString = newExternalDataListString.Replace("$EntityNamespace$", entity.Attribute("Namespace").Value);
                    newExternalDataListString = newExternalDataListString.Replace("$SpecificFinder$", specificFinderName);
                    newExternalDataListString = newExternalDataListString.Replace("$Finder$", finderName);
    
                    string elementsXmlPath = Path.Combine(newExternalDataList.FullPath, "Elements.xml");
                    File.WriteAllText(elementsXmlPath, newExternalDataListString);
                    ISharePointProjectItemFile elementsFile = newExternalDataList.Files.AddFromFile(elementsXmlPath);
                    elementsFile.DeploymentType = DeploymentType.ElementManifest;
                }
    
                return true;
            }
    
            private string GetLobSystemInstanceName(XElement entity)
            {
                XElement lobSystemInstances = entity.Parent.Parent.Element(BdcNamespace + "LobSystemInstances");
                if (lobSystemInstances != null)
                {
                    XElement lobSystemInstance = lobSystemInstances.Elements(BdcNamespace + "LobSystemInstance").FirstOrDefault();
                    if (lobSystemInstance != null)
                    {
                        return lobSystemInstance.Attribute("Name").Value;
                    }
                }
                return null;
            }
    
            private string GetSpecificFinderName(XElement entity)
            {
                return GetMethodInstance(entity, "SpecificFinder");
            }
    
            private string GetFinderName(XElement entity)
            {
                return GetMethodInstance(entity, "Finder");
            }
    
            private string GetMethodInstance(XElement entity, string methodInstanceType)
            {
                XElement methods = entity.Element(BdcNamespace + "Methods");
                if (methods != null)
                {
                    foreach (XElement method in methods.Elements(BdcNamespace + "Method"))
                    {
                        XElement methodInstances = method.Element(BdcNamespace + "MethodInstances");
                        if (methodInstances != null)
                        {
                            foreach (XElement methodInstance in methodInstances.Elements(BdcNamespace + "MethodInstance"))
                            {
                                if (methodInstance.Attribute("Type").Value == methodInstanceType)
                                {
                                    return methodInstance.Attribute("Name").Value;
                                }
                            }
                        }
                    }
                }
    
                return null;
            }
        }
    }
    

Checkpoint

Bu noktada izlenecek yolda, tüm proje öğe uzantısı artık projede kodudur.Projenin hatasız derlendiğinden emin olmak için bir çözüm oluşturun.

Çözümü oluşturmak için

  • Menü çubuğunda Seç Yapı, Build Solution.

Proje öğesi uzantısı dağıtmak için VSIX paketi oluşturma

Uzantıyı dağıtmak için VSIX paketi oluşturmak için çözümünüzdeki VSIX projesi kullanın.İlk olarak, VSIX projesinde bulunan source.extension.vsixmanifest dosyasını değiştirerek VSIX paketi yapılandırın.Ardından, çözüm oluşturma tarafından VSIX paketi oluşturun.

VSIX paketi oluşturmak ve yapılandırmak için

  1. İçinde Çözüm GezginiGenerateExternalDataLists projesinde source.extension.vsixmanifest dosya için kısayol menüsünü açın ve sonra seçin açık.

    Visual Studio, dosya bildirim düzenleyicisinde açılır.Source.extension.vsixmanifest extension.vsixmanifest dosya temelini tüm VSIX paketleri tarafından gereken dosyadır.Bu dosya hakkında daha fazla bilgi için bkz: VSIX uzantı Şeması Başvurusu.

  2. İçinde Product Name kutusuna girin Dış veri listesi Generator.

  3. İçinde Yazar kutusuna girin Contoso.

  4. İçinde Açıklama kutusuna girin uzantısı için dış verileri oluşturmak için kullanılabilir iş verileri bağlantısı modeli proje öğeleri listeler.

  5. Üzerinde varlıklarını sekmesini seçin Düzenleyicisi ' Yeni düğmesi.

    Yeni kıymet eklemek iletişim kutusu görüntülenir.

  6. İçinde türü listesinde, seçim Microsoft.VisualStudio.MefComponent.

    [!NOT]

    Bu değeri karşılık gelen MefComponent extension.vsixmanifest dosyasındaki öğesi.Bu öğe, VSIX paketinde uzantısı derlemenin adını belirtir.Daha fazla bilgi için bkz. MEFComponent Element.

  7. İçinde kaynak listesinde, seçim Geçerli çözümde bir proje.

  8. İçinde Proje listesinde, seçim BdcProjectItemExtensionve sonra seçin Tamam düğmesi.

  9. Menü çubuğunda Seç Yapı, Build Solution.

  10. Proje derlenir ve hatasız olduğundan emin olun.

  11. GenerateExternalDataLists projenin yapı çıktı klasörüne şimdi GenerateExternalDataLists.vsix dosyası içerdiğinden emin olun.

    Varsayılan olarak, yapı çıktı klasörüne değil...Proje dosyanızı içeren klasörü altındaki \bin\Debug klasörünü.

Proje öğesi uzantısı sınama

Proje öğesi uzantısı sınamak artık hazırsınız.İlk olarak, deneysel örneğinde, Visual Studio Uzantı projesi hata ayıklamayı Başlat.Daha sonra Visual Studio'nun deneysel örneği uzantı İVB Modeli için bir dış liste oluşturmak için kullanın.Son olarak, dış liste SharePoint sitesinde beklendiği gibi çalıştığını doğrulamak için açın.

Hata ayıklama uzantı başlatmak için

  1. Gerekirse, yönetici kimlik bilgileriyle Visual Studio'yu yeniden başlatın ve sonra GenerateExternalDataLists çözümü açın.

  2. BdcProjectItemExtension proje ProjectItemExtension kod dosyasını açın ve sonra kod satırı için bir kesme noktası ekleyebilir Initialize yöntem.

  3. GenerateExternalDataLists kod dosyasını açın ve sonra kodu ilk satırı için bir kesme noktası ekleyebilir GenerateExternalDataLists_Execute yöntem.

  4. Seçme, F5 tuşunu seçerek veya menü çubuğunda hata ayıklama Başlat Debug, Start Debugging komutunu.

    Visual Studio uzantısı %UserProfile%\AppData\Local\Microsoft\VisualStudio\10.0Exp\Extensions\Contoso\External veri listesi Generator\1.0 yükler ve Visual Studio'nun deneysel örneği başlar.Bu örnekte, Visual Studio proje öğesi test edecek.

Uzantı sınamak için

  1. Visual Studio'nun deneysel örneği menü çubuğunda seçin Dosya, Yeni, Proje.

  2. İçinde Yeni Proje iletişim kutusunda, genişletin şablonları düğümü genişletin Visual C# düğümü, genişletin SharePoint düğümü ve sonra seçin 2010.

  3. İletişim kutusunun en üstündeki listesinde olduğundan emin olun .net Framework 3.5 seçilir.Projeler için Microsoft SharePoint Server 2010 .NET Framework'ün bu sürümü gerektirir.

  4. Proje şablonları listesinde seçim SharePoint 2010 proje.

  5. İçinde adı kutusuna girin SharePointProjectTestBDCve sonra Tamam düğmesi.

  6. SharePoint Özelleştirme Sihirbazı'nda seçin hata ayıklama için kullanmak istediğiniz sitenin url adresini girin dağıtma grubu çözümü olarakve sonra seçin Sondüğmesi.

  7. SharePointProjectTestBDC projesi için kısayol menüsünü açın, seçim Ekleve sonra Yeni madde.

  8. İçinde Eklemek NewItem – SharePointProjectTestBDC iletişim kutusunda, yüklü dil düğümünü genişletin, genişletme SharePoint düğümü.

  9. Seçin 2010 düğümü ve sonra İş Verileri Bağlantısı modeli (yalnızca Grup çözümü) şablonu.

  10. İçinde adı kutusuna girin TestBDCModelve sonra Ekle düğmesi.

  11. Kod, Visual Studio örneği içinde ayarladığınız kesme durduðunu doðrulamak Initialize ProjectItemExtension kod dosyasının yöntemi.

  12. Visual Studio durdurulmuş örneğini seçin F5 anahtar veya menü çubuğunda Seç Debug, devam projede hata ayıklamaya devam etmek için.

  13. Visual Studio'nun deneysel örneği seçin F5 anahtar veya menü çubuğunda Seç Debug, Start Debugging komutunu oluşturmak, dağıtmak ve çalıştırmak TestBDCModel proje.

    Hata ayıklama için belirtilen SharePoint sitesinin varsayılan sayfa web tarayıcısında açılır.

  14. Doğrulayın listeler bölümünde Hızlı Başlat alanında projedeki varsayılan İVB modelini temel alan bir liste içeren henüz yoktur.Öncelikle, SharePoint kullanıcı arabirimini kullanarak veya proje öğe uzantısı kullanarak bir dış veri listesi oluşturmanız gerekir.

  15. Web tarayıcısını kapatın.

  16. TestBDCModel proje açık olduğu Visual Studio örneğini açmak için kısayol menüsünü TestBDCModel düğümünde Çözüm Gezginive sonra Dış veri listesi oluşturmak.

  17. Kod, Visual Studio örneği içinde ayarladığınız kesme durduðunu doðrulamak GenerateExternalDataLists_Execute yöntem.Seçim F5 anahtar veya menü çubuğunda Seç Debug, devam projede hata ayıklamaya devam etmek için.

  18. Visual Studio'nun deneysel örneği adlı bir liste örneği ekler Entity1DataList TestBDCModel için proje ve örneği de üretir adlı bir özellik Feature2 listesi örneği için.

  19. Seçim F5 anahtar veya menü çubuğunda Seç Debug, Start Debugging komutunu oluşturmak, dağıtmak ve TestBDCModel projeyi çalıştırın.

    SharePoint sitesinin hata ayıklama amacıyla kullanılan varsayılan sayfa web tarayıcısında açılır.

  20. İçinde listeler bölüm seçin Hızlı Başlat alanında Entity1DataList listesi.

  21. Identifier1 ve ileti, Identifier1 değeri 0 ve Hello World iletisi değeri olan bir öğe ek olarak adlandırılmış sütunlar listenin içerdiğini doğrulayın.

    İş Verileri Bağlantısı modeli bu verileri sağlayan varsayılan İVB Modeli proje şablonu oluşturur.

  22. Web tarayıcısını kapatın.

Geliştirme bilgisayarı temizleme

Proje öğesi uzantısı testi tamamladıktan sonra dış liste ve İVB Modeli SharePoint sitesinden ve proje öğe uzantısı Visual Studio'dan kaldırın.

SharePoint sitesinden dış veri listesini kaldırmak için

  1. SharePoint sitesi Hızlı Başlat alanında seçin Entity1DataList listesi.

  2. SharePoint sitesinde Şeritte seçin listesi sekme.

  3. Üzerinde listesi sekmesini ayarları grup, seçim Liste ayarları.

  4. Altında İzinler ve yönetim, seçim Bu listeyi Silve sonra seçin Tamam listesi Geri Dönüşüm Kutusu'na göndermek istediğinizi onaylamak için.

  5. Web tarayıcısını kapatın.

İVB Modeli SharePoint sitesinden kaldırmak için

  • Visual Studio'nun deneysel örneği menü çubuğunda seçin Yapı, Retract.

    Visual Studio SharePoint sitesinden İVB Modeli kaldırır.

Visual Studio proje öğesi uzantıyı kaldırmak için

  1. Visual Studio'nun deneysel örneği menü çubuğunda seçin araçları, uzantıları ve güncelleştirmeleri.

    Uzantıları ve güncelleştirmeleri iletişim kutusunu açar.

  2. Uzantılar listesinde seçin Dış veri listesi Generatorve sonra seçin kaldırma düğmesi.

  3. Görüntülenen iletişim kutusunda seçtiğiniz Evet uzantıyı kaldırmak istediğinizi onaylamak için.

  4. Seçim Şimdi yeniden kaldırma işlemi tamamlamak için.

  5. Visual Studio (deneysel örneği ve GenerateExternalDataLists çözüm açık örneği) her iki örneğini kapatın.

Ayrıca bkz.

Kavramlar

SharePoint proje sistem genişletme

Diğer Kaynaklar

İş veri bağlantısı modeli oluşturma

İş veri bağlantısı Model tasarlama