Exemplo n.º 1
0
        internal Dictionary <string, BdcLobSysInst> GetLobSystemInstances()
        {
#if SP12
            return(ApplicationRegistry.GetLobSystemInstances());
#else
            INamedLobSystemDictionary          dict;
            Dictionary <string, BdcLobSysInst> result = new Dictionary <string, BdcLobSysInst> ();
            BdcLobSysInstDict tmp;
            if (bdcCat == null)
            {
                if (bdcService == null)
                {
                    bdcService = new BdcService();
                }
                bdcCat = bdcService.GetDatabaseBackedMetadataCatalog(SPServiceContext.Current);
            }
            if ((dict = bdcCat.GetLobSystems("*")) != null)
            {
                foreach (KeyValuePair <string, ILobSystem> kvp in dict)
                {
                    if ((tmp = kvp.Value.GetLobSystemInstances()) != null)
                    {
                        foreach (KeyValuePair <string, BdcLobSysInst> kvp2 in tmp)
                        {
                            result [kvp2.Key] = kvp2.Value;
                        }
                    }
                }
            }
            return(result);
#endif
        }
Exemplo n.º 2
0
        internal BdcLobSysInst GetLobSystemInstanceByName(string name)
        {
#if SP12
            return(ApplicationRegistry.GetLobSystemInstanceByName(name));
#else
            if (bdcCat == null)
            {
                if (bdcService == null)
                {
                    bdcService = new BdcService();
                }
                bdcCat = bdcService.GetDatabaseBackedMetadataCatalog(SPServiceContext.Current);
            }
            foreach (KeyValuePair <string, BdcLobSysInst> kvp in GetLobSystemInstances())
            {
                if ((kvp.Value != null) && (kvp.Value.Name == name))
                {
                    return(kvp.Value);
                }
            }
            return(null);
#endif
        }
Exemplo n.º 3
0
        static void ExecuteBcsEctMethods(string siteUrl)
        {
            using (SPSite site = new SPSite(siteUrl))
            {
                using (new SPServiceContextScope(SPServiceContext.GetContext(site)))
                {
                    BdcServiceApplicationProxy    proxy  = (BdcServiceApplicationProxy)SPServiceContext.Current.GetDefaultProxy(typeof(BdcServiceApplicationProxy));
                    DatabaseBackedMetadataCatalog model  = proxy.GetDatabaseBackedMetadataCatalog();
                    IEntity            entity            = model.GetEntity("EmployeeEntityModel.BdcModel1", "Entity1");     // Namespace, Entity name
                    ILobSystemInstance lobSystemInstance = entity.GetLobSystem().GetLobSystemInstances()[0].Value;
                    IMethodInstance    method            = entity.GetMethodInstance("ReadList", MethodInstanceType.Finder); // Finder method name
                    IView view = entity.GetFinderView(method.Name);

                    IFilterCollection         filterCollection         = entity.GetDefaultFinderFilters();
                    IEntityInstanceEnumerator entityInstanceEnumerator = entity.FindFiltered(filterCollection, method.Name, lobSystemInstance, OperationMode.Online);
                    Console.WriteLine("Employee Login ID | Job Title");
                    while (entityInstanceEnumerator.MoveNext())
                    {
                        Console.WriteLine(entityInstanceEnumerator.Current["LoginID"].ToString() + " - " + entityInstanceEnumerator.Current["JobTitle"].ToString()); // Column names
                    }
                    Console.ReadLine();
                }
            }
        }