예제 #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
        }
        public void ProductsCanBeFound()
        {
            SqlSessionProvider.Instance().SetSharedResourceProviderToUse("ContosoSSP");
            NamedLobSystemInstanceDictionary sysInstances = ApplicationRegistry.GetLobSystemInstances();
            LobSystemInstance     lobSystemInstance       = sysInstances["ContosoProductCatalogService"];
            NamedEntityDictionary entities = lobSystemInstance.GetEntities();
            Entity productEntity           = entities["Product"];

            IEntityInstance productInstance = productEntity.FindSpecific("1000000000", lobSystemInstance);

            Assert.AreEqual("Blood Pressure Kit", productInstance["Name"]);
            Assert.AreEqual("Blood pressure kit includes cuff with velcro adhesive and easy to read glow in the dark dial.", productInstance["LongDescription"]);
            Assert.AreEqual("Blood pressure kit includes cuff and easy to read dial.", productInstance["ShortDescription"]);
            Assert.AreEqual("1000000000", productInstance["Sku"]);
            Assert.AreEqual("8", productInstance["CategoryId"]);
            Assert.IsTrue(productInstance["ImagePath"].ToString().EndsWith("images/bloodpressure.jpg"));
            Assert.IsTrue(productInstance["ThumbnailImagePath"].ToString().EndsWith("images/bloodpressure.jpg"));

            productInstance = productEntity.FindSpecific("2000000000", lobSystemInstance);

            Assert.AreEqual("Gurney", productInstance["Name"]);
            Assert.AreEqual("Gurney includes rubber wheels and extra padding. Meets most federal safety requirements.", productInstance["LongDescription"]);
            Assert.AreEqual("Gurney includes rubber wheels and extra padding.", productInstance["ShortDescription"]);
            Assert.AreEqual("2000000000", productInstance["Sku"]);
            Assert.AreEqual("10", productInstance["CategoryId"]);
            Assert.IsTrue(productInstance["ImagePath"].ToString().EndsWith("images/gurney.jpg"));
            Assert.IsTrue(productInstance["ThumbnailImagePath"].ToString().EndsWith("images/gurney.jpg"));
        }
        void GetLob(String slob)
        {
            if (!_lobs.ContainsKey(slob))
            {
                NamedLobSystemInstanceDictionary sysInstances = ApplicationRegistry.GetLobSystemInstances();
                LobSystemInstance l = sysInstances[slob];

                IEnumerator it = _cfg.lobCollection.GetEnumerator();
                while (it.MoveNext())
                {
                    Lob lob = (Lob)it.Current;
                    if (lob.name.Equals(slob))
                    {
                        _lobInsts.Add(slob, l); //the real lob
                        _lobs.Add(slob, lob);   //the config of lob
                        break;
                    }
                }
            }
            _lobInst = (LobSystemInstance)_lobInsts[slob];
            _lob     = (Lob)_lobs[slob];
            if (_lobInst == null)
            {
                throw new Exception(slob + " does not exist in this service provider, check the name to make sure it's correct.");
            }
            if (_lob == null)
            {
                throw new Exception(slob + " is not found in bdc.xml");
            }
            return;
        }
        public void ContosoProductCatalogServiceIsRegistered()
        {
            SqlSessionProvider.Instance().SetSharedResourceProviderToUse("ContosoSSP");

            NamedLobSystemInstanceDictionary sysInstances = ApplicationRegistry.GetLobSystemInstances();

            Assert.AreEqual(1, sysInstances.Count);
            Assert.IsNotNull(sysInstances["ContosoProductCatalogService"]);
        }
예제 #5
0
        private static void IterateLOBSystems()
        {
            NamedLobSystemInstanceDictionary sysInstances = ApplicationRegistry.GetLobSystemInstances();

            Console.WriteLine("Listing system instances...");
            foreach (String name in sysInstances.Keys)
            {
                Console.WriteLine(name);
            }

            NamedLobSystemDictionary lobSystems = ApplicationRegistry.GetLobSystems();

            foreach (LobSystem lobSystem in lobSystems.Values)
            {
                Console.WriteLine("Application: " + lobSystem.Name);
                NamedDataClassDictionary lobClasses = lobSystem.GetDataClasses();
                foreach (DataClass dataClass in lobClasses.Values)
                {
                    Console.WriteLine(" Entities: " + dataClass.Name);
                }


                if (lobSystem.Name == "AdventureWorksSample")
                {
                    // work on a specific class
                    DataClass             customers = lobClasses["Customer"];
                    NamedMethodDictionary methods   = customers.GetMethods();
                    foreach (Method meth in methods.Values)
                    {
                        Console.WriteLine(" Method: " + meth.Name);
                    }
                }

                if (lobSystem.Name == "AdventureWorksLOBSystem")
                {
                    // filter all femalce Employees

                    Entity employees = lobSystem.GetEntities()["HumanResources.Employee"];

                    FilterCollection filtered = employees.GetFinderFilters();
                    (filtered[0] as ComparisonFilter).Value = 10;

                    IEntityInstanceEnumerator empEnum = employees.FindFiltered(filtered,
                                                                               ApplicationRegistry.GetLobSystemInstances
                                                                                   ()["AdventureWorksInstance"]);

                    while (empEnum.MoveNext())
                    {
                        DataTable dt = (empEnum.Current as DbEntityInstance).EntityAsDataTable;
                        PrintDataRow(dt.Rows[0]);
                    }
                }
            }
        }
        public void ContosoProductCatalogServiceHasCatalogAndProductEntities()
        {
            SqlSessionProvider.Instance().SetSharedResourceProviderToUse("ContosoSSP");
            NamedLobSystemInstanceDictionary sysInstances = ApplicationRegistry.GetLobSystemInstances();
            LobSystemInstance lobSystemInstance           = sysInstances["ContosoProductCatalogService"];

            NamedEntityDictionary entities = lobSystemInstance.GetEntities();

            Assert.AreEqual(3, entities.Count);
            Assert.IsNotNull(entities["Category"]);
            Assert.IsNotNull(entities["Product"]);
            Assert.IsNotNull(entities["Part"]);
        }
        public void CategoryCanBeFound()
        {
            SqlSessionProvider.Instance().SetSharedResourceProviderToUse("ContosoSSP");
            NamedLobSystemInstanceDictionary sysInstances = ApplicationRegistry.GetLobSystemInstances();
            LobSystemInstance     lobSystemInstance       = sysInstances["ContosoProductCatalogService"];
            NamedEntityDictionary entities = lobSystemInstance.GetEntities();
            Entity categoryEntity          = entities["Category"];

            IEntityInstance categoryInstance = categoryEntity.FindSpecific("0", lobSystemInstance);

            Assert.AreEqual("Root Category", categoryInstance["Name"]);
            Assert.AreEqual("0", categoryInstance["CategoryId"]);
            Assert.AreEqual(string.Empty, categoryInstance["ParentId"]);

            categoryInstance = categoryEntity.FindSpecific("1", lobSystemInstance);

            Assert.AreEqual("Medical Supplies", categoryInstance["Name"]);
            Assert.AreEqual("1", categoryInstance["CategoryId"]);
            Assert.AreEqual("0", categoryInstance["ParentId"]);
        }
예제 #8
0
        public override void UpdatePanel(Panel panel)
        {
            string baseOptions = string.Format(FORMAT_LISTOPTION, string.Empty, string.Empty, string.Empty), options = baseOptions, tmp;
            bool   isSel = false;
            string valueID, formatDisabledTextBox = FORMAT_TEXTBOX.Replace("<input ", "<input disabled=\"disabled\" "), formatDisabledList = FORMAT_LIST.Replace("<select ", "<select disabled=\"disabled\" "), formatDisabledCheckBox = FORMAT_CHECKBOX.Replace("<input ", "<input disabled=\"disabled\" "), formatDisabledTextArea = FORMAT_TEXTAREA.Replace("<textarea ", "<textarea disabled=\"disabled\" ");

            panel.Controls.Add(new LiteralControl("<div class=\"roxsectionlink\"><a onclick=\"jQuery('#roxfilterspecial').slideToggle();\" href=\"#noop\">" + this ["FilterProps", GetFilterTypeTitle(GetType())] + "</a></div><fieldset style=\"padding: 4px; background-color: InfoBackground; color: InfoText;\" id=\"roxfilterspecial\" style=\"display: none;\">"));
            if (parentWebPart != null)
            {
                try {
                    try {
                        foreach (KeyValuePair <string, LobSystemInstance> kvpLob in ApplicationRegistry.GetLobSystemInstances())
                        {
                            try {
                                foreach (KeyValuePair <string, Entity> kvpEntity in kvpLob.Value.GetEntities())
                                {
                                    try {
                                        if ((kvpEntity.Value.GetIdentifierCount() == 1) && kvpEntity.Value.HasSpecificFinder())
                                        {
                                            options += string.Format(FORMAT_LISTOPTION, tmp = kvpLob.Key + SEPARATOR + kvpEntity.Key, (kvpLob.Value.ContainsLocalizedDisplayName() ? kvpLob.Value.GetLocalizedDisplayName() : kvpLob.Value.GetDefaultDisplayName()) + ": " + (kvpEntity.Value.ContainsLocalizedDisplayName() ? kvpEntity.Value.GetLocalizedDisplayName() : kvpEntity.Value.GetDefaultDisplayName()), (isSel = tmp.Equals(Get <string> ("BdcEntity"))) ? " selected=\"selected\"" : string.Empty);
                                            if (isSel)
                                            {
                                                lobInstance = kvpLob.Value;
                                                entity      = kvpEntity.Value;
                                                view        = entity.GetSpecificFinderView();
                                            }
                                        }
                                    } catch (Exception ex) {
                                        Report(ex);
                                    }
                                }
                            } catch (Exception ex) {
                                Report(ex);
                            }
                        }
                    } catch (Exception ex) {
                        Report(ex);
                    }
                    panel.Controls.Add(CreateControl(Le(4, false) ? FORMAT_LIST : formatDisabledList, "BdcEntity", " onchange=\"roxRefreshFilters();\"", options));
                    options = baseOptions;
                    if (view != null)
                    {
                        try {
                            foreach (Field field in view.Fields)
                            {
                                try {
                                    options += string.Format(FORMAT_LISTOPTION, field.Name, field.ContainsLocalizedDisplayName ? field.LocalizedDisplayName : field.DefaultDisplayName, (isSel = field.Name.Equals(Get <string> ("BdcValueField"))) ? " selected=\"selected\"" : string.Empty);
                                    if (isSel)
                                    {
                                        valueField = field;
                                    }
                                } catch (Exception ex) {
                                    Report(ex);
                                }
                            }
                        } catch (Exception ex) {
                            Report(ex);
                        }
                    }
                    panel.Controls.Add(CreateControl(Le(4, false) ? FORMAT_LIST : formatDisabledList, "BdcValueField", " onchange=\"roxRefreshFilters();\"", options));
                    options = baseOptions;
                    if (view != null)
                    {
                        try {
                            foreach (Field field in view.Fields)
                            {
                                try {
                                    options += string.Format(FORMAT_LISTOPTION, field.Name, field.ContainsLocalizedDisplayName ? field.LocalizedDisplayName : field.DefaultDisplayName, (isSel = field.Name.Equals(Get <string> ("BdcDisplayField"))) ? " selected=\"selected\"" : string.Empty);
                                    if (isSel)
                                    {
                                        dispField = field;
                                    }
                                } catch (Exception ex) {
                                    Report(ex);
                                }
                            }
                        } catch (Exception ex) {
                            Report(ex);
                        }
                    }
                    panel.Controls.Add(CreateControl(Le(4, false) ? FORMAT_LIST : formatDisabledList, "BdcDisplayField", " onchange=\"roxRefreshFilters();\"", options));
                    options = string.Format(FORMAT_LISTOPTION, string.Empty, this ["Empty"], string.Empty);
                    if ((entity != null) && (view != null))
                    {
                        if (valueField == null)
                        {
                            valueField = view.Fields [0];
                        }
                        if (valueField != null)
                        {
                            if (dispField == null)
                            {
                                dispField = valueField;
                            }
                            using (IEntityInstanceEnumerator values = entity.FindFiltered(new FilterCollection(), lobInstance))
                                while (values.MoveNext())
                                {
                                    if ((values.Current != null) && !string.IsNullOrEmpty(valueID = ProductPage.Serialize <object> (values.Current.GetIdentifierValues())))
                                    {
                                        options += string.Format(FORMAT_LISTOPTION, valueID, values.Current [dispField], valueID.ToString().Equals(Get <string> ("BdcInstanceID")) ? " selected=\"selected\"" : string.Empty);
                                    }
                                }
                        }
                    }
                    panel.Controls.Add(CreateControl(Le(4, false) ? FORMAT_LIST : formatDisabledList, "BdcInstanceID", " onchange=\"" + scriptCheckDefault + "\"", options));
                } catch (Exception ex) {
                    Report(ex);
                } finally {
                    try {
                        if ((lobInstance != null) && (lobInstance.CurrentConnection != null))
                        {
                            lobInstance.CloseConnection();
                        }
                    } catch (Exception ex) {
                        Report(ex);
                    }
                }
            }
            panel.Controls.Add(new LiteralControl("</fieldset>"));
            try {
                panel.Controls.Add(CreateControl(Le(4, false) ? FORMAT_CHECKBOX : formatDisabledCheckBox, "SendNull", GetChecked(Get <bool> ("SendNull"))));
                base.UpdatePanel(panel);
                panel.Controls.Add(CreateScript(scriptCheckDefault));
            } catch (Exception ex) {
                Report(ex);
            }
        }
 internal Dictionary <string, LobSystemInstance> GetLobSystemInstances()
 {
     return(ApplicationRegistry.GetLobSystemInstances());
 }