Example #1
0
        /// <summary>
        /// Initializes the Catalog
        /// </summary>
        private void InitializeMetadataStore()
        {
            // Open the shared metadatacatalog cache on the client to
            // read LOB information. This class represnts the Office
            // client shared storage for BCS metadata. Once on client,
            // this metadata can be accessed from any Office application
            catalog = new RemoteSharedFileBackedMetadataCatalog();

            // Get the SalesOrderHeader entity instance using
            // namespace and name
            entitySalesOrderHeader = catalog.GetEntity(
                SalesOrderHeaderNamespace,
                SalesOrderHeader);

            // Get the SalesOrderLine entity instance using
            // namespace and name
            entitySalesOrderLine = catalog.GetEntity(
                SalesOrderHeaderNamespace,
                SalesOrderLine);

            salesOrderLineEntityIds =
                entitySalesOrderLine.GetIdentifiers();

            // Get the handle to LobSystem
            lobInstance =
                catalog.GetLobSystem(SalesOrderLobSystemName).
                GetLobSystemInstances()[SalesOrderLobSystemInstanceName];

            // Create list to hold changed rows
            changedSalesLineRows = new List <DataRow>();
        }
        /// <summary>
        /// Populates the Combo box with the available ECTs.
        /// </summary>
        public void PopulateControls()
        {
            RemoteSharedFileBackedMetadataCatalog Catalog            = new RemoteSharedFileBackedMetadataCatalog();
            IEntityInstanceEnumerator             InstanceEnumerator = null;
            INamespacedEntityDictionaryDictionary entDictDict        = Catalog.GetEntities("*");

            foreach (INamedEntityDictionary entDict in entDictDict.Values)
            {
                foreach (IEntity entity in entDict.Values)
                {
                    EntityLookup[entity.Name] = entity;
                    ectList.Items.Add(entity.Name);
                }
            }
            //Fill the ECT combobox
            if (EntityLookup != null && EntityLookup.Count > 0)
            {
                foreach (IEntity entity in EntityLookup.Values)
                {
                    InstanceEnumerator = entity.FindFiltered(
                        entity.GetDefaultFinderFilters(),
                        entity.GetMethodInstances(MethodInstanceType.Finder)[0].Value.Name,
                        entity.GetLobSystem().GetLobSystemInstances()[0].Value,
                        OperationMode.Online);
                    System.Data.DataTable dt = Catalog.Helper.CreateDataTable(InstanceEnumerator);
                    //System.Data.DataTable dt = Globals.ThisAddIn.GetBCSDataTest();
                    if (dt != null)
                    {
                        EntityDataLookup[entity] = dt;
                    }
                }
                //ectList.DataSource = EntityCollection;
                ectList.SelectedIndex = 0;
                //ectList.SelectedItem = EntityCollection[0];
                ectList.SelectedIndexChanged += new EventHandler(comboBox1_SelectedIndexChanged);
            }
        }