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 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")); }
public ArtDevBCS LobSystemInit(string name) { this.lobSystemName = name; // Make a new Employee LobSystem // NOTE: Assume that the "LobSystemName" LobSystem // does not already exist. this.lobSystem = this.Model.OwnedReferencedLobSystems.Create(name, true, SystemType.Database); // Make a new AdventureWorks LobSystemInstance. this.lobSystemInstance = this.lobSystem.LobSystemInstances.Create(name, true); return(this); }
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"]); }
/// <summary> /// Reads configuration parameters from BDCM and instantiates the ShopifyClient. /// </summary> /// <returns></returns> private ShopifyClient GetShopifyClient() { INamedPropertyDictionary properties = LobSystemInstance.GetProperties(); string apiKey; string apiPassword; string apiHostName; if (properties.ContainsKey("ApiKey") && !string.IsNullOrWhiteSpace(properties["ApiKey"].ToString())) { apiKey = properties["ApiKey"].ToString(); } else { throw new ArgumentException("ApiKey property must be defined for LOB System Instance"); } if (properties.ContainsKey("ApiPassword") && !string.IsNullOrWhiteSpace(properties["ApiPassword"].ToString())) { apiPassword = properties["ApiPassword"].ToString(); } else { throw new ArgumentException("ApiPassword property must be defined for LOB System Instance"); } if (properties.ContainsKey("ApiHostName") && !string.IsNullOrWhiteSpace(properties["ApiHostName"].ToString())) { apiHostName = properties["ApiHostName"].ToString(); } else { throw new ArgumentException("ApiHostName property must be defined for LOB System Instance"); } return(new ShopifyClient(apiKey, apiPassword, apiHostName)); }
// Uncomment the method below to handle the event raised after a feature has been activated. public override void FeatureActivated(SPFeatureReceiverProperties properties) { // Get the Catalog for the SharePoint site BdcService service = SPFarm.Local.Services.GetValue <BdcService>(String.Empty); SPSite site = new SPSite("http://sp2016:2016/"); SPServiceContext context = SPServiceContext.GetContext(site); AdministrationMetadataCatalog catalog = service.GetAdministrationMetadataCatalog(context); catalog.GetModels("EmployeeModel")?.ToList().ForEach(m => m.Delete()); // Create a new Employee Model // NOTE: Assume that the "EmployeeModel" Model // does not already exist. Model EmployeeModel = Model.Create("EmployeeModel", true, catalog); // Make a new Employee LobSystem // NOTE: Assume that the "AdventureWorks" LobSystem // does not already exist. LobSystem adventureWorksLobSystem = EmployeeModel.OwnedReferencedLobSystems.Create("AdventureWorks", true, SystemType.Database); // Make a new AdventureWorks LobSystemInstance. LobSystemInstance adventureWorksLobSystemInstance = adventureWorksLobSystem.LobSystemInstances.Create("AdventureWorks", true); // Set the connection properties. adventureWorksLobSystemInstance.Properties.Add( "ShowInSearchUI", ""); adventureWorksLobSystemInstance.Properties.Add( "DatabaseAccessProvider", "SqlServer"); adventureWorksLobSystemInstance.Properties.Add( "RdbConnection Data Source", "SP2016"); adventureWorksLobSystemInstance.Properties.Add( "RdbConnection Initial Catalog", "AdventureWorks2016"); adventureWorksLobSystemInstance.Properties.Add( "AuthenticationMode", "RdbCredentials"); adventureWorksLobSystemInstance.Properties.Add( "SsoProviderImplementation", "Microsoft.Office.SecureStoreService.Server.SecureStoreProvider, Microsoft.Office.SecureStoreService, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"); adventureWorksLobSystemInstance.Properties.Add( "SsoApplicationId", "Adventure"); adventureWorksLobSystemInstance.Properties.Add( "RdbConnection Pooling", "true"); // Create a new Employee Entity. Entity EmployeeEntity = Entity.Create( "Employee", "AdventureWorks", true, new Version("1.0.0.4"), 10000, CacheUsage.Default, adventureWorksLobSystem, EmployeeModel, catalog); // Set the identifier to the EmployeeID column. EmployeeEntity.Identifiers.Create( "BusinessEntityID", true, "System.Int32"); // Create the Finder Method, // i.e. the method to return all rows. CreateReadListMethod(catalog, EmployeeEntity); // Create the Specific Finder Method, // i.e. the method to return one row. CreateReadItemMethod(catalog, EmployeeEntity); // Validate the Employee Entity. ActivationError[] activationErrors = EmployeeEntity.Validate(); // Check if the validation failed. if (activationErrors.Count() == 0) { // The validation was successful so publish the Employee Entity. EmployeeEntity.Activate(); } }
public void SetConsumerSystemInstance(LobSystemInstance lobSystemInstance) { this.systemInstance = lobSystemInstance; }
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); } }
public override void UpdatePanel(Panel panel) { string str = string.Format("<option value=\"{0}\"{2}>{1}</option>", string.Empty, string.Empty, string.Empty); string str2 = str; bool flag = false; "<div id=\"div_{0}\"><div class=\"rox-prop\"><label id=\"label_{0}\" for=\"{0}\">{1}</label></div><input style=\"width: 98%;\" class=\"ms-input\" type=\"text\" name=\"{0}\" id=\"{0}\" value=\"{2}\"{3}/></div>".Replace("<input ", "<input disabled=\"disabled\" "); string str5 = "<div id=\"div_{0}\"><div class=\"rox-prop\"><label id=\"label_{0}\" for=\"{0}\">{1}</label></div><select style=\"width: 98%;\" class=\"ms-input\" name=\"{0}\" id=\"{0}\"{2}>{3}</select></div>".Replace("<select ", "<select disabled=\"disabled\" "); string str6 = "<div id=\"div_{0}\" class=\"rox-prop\"><input onclick=\"{3}\" type=\"checkbox\" name=\"{0}\" id=\"{0}\"{2}/><label id=\"label_{0}\" for=\"{0}\">{1}</label></div>".Replace("<input ", "<input disabled=\"disabled\" "); "<div id=\"div_{0}\"><div class=\"rox-prop\"><label id=\"label_{0}\" for=\"{0}\">{1}</label></div><textarea rows=\"{3}\" onchange=\"{4}\" style=\"width: 96%;\" class=\"ms-input\" name=\"{0}\" id=\"{0}\">{2}</textarea></div>".Replace("<textarea ", "<textarea disabled=\"disabled\" "); panel.Controls.Add(new LiteralControl("<div class=\"roxsectionlink\"><a onclick=\"jQuery('#roxfilterspecial').slideToggle();\" href=\"#noop\">" + base["FilterProps", new object[] { roxority_FilterZen.FilterBase.GetFilterTypeTitle(base.GetType()) }] + "</a></div><fieldset style=\"padding: 4px; background-color: InfoBackground; color: InfoText;\" id=\"roxfilterspecial\" style=\"display: none;\">")); if (base.parentWebPart != null) { try { try { foreach (KeyValuePair <string, LobSystemInstance> pair in this.GetLobSystemInstances()) { try { foreach (KeyValuePair <string, Microsoft.Office.Server.ApplicationRegistry.MetadataModel.Entity> pair2 in this.GetEntities(pair.Value)) { try { if ((pair2.Value.GetIdentifierCount() == 1) && this.HasSpecificFinder(pair2.Value)) { string str3; str2 = str2 + string.Format("<option value=\"{0}\"{2}>{1}</option>", str3 = pair.Key + "{C453BF77-8CC4-4e1a-A50E-8A60B293CE94}" + pair2.Key, (pair.Value.ContainsLocalizedDisplayName() ? pair.Value.GetLocalizedDisplayName() : pair.Value.GetDefaultDisplayName()) + ": " + (pair2.Value.ContainsLocalizedDisplayName() ? pair2.Value.GetLocalizedDisplayName() : pair2.Value.GetDefaultDisplayName()), (flag = str3.Equals(this.Get <string>("BdcEntity"))) ? " selected=\"selected\"" : string.Empty); if (flag) { this.lobInstance = pair.Value; this.entity = pair2.Value; this.view = roxority_BusinessDataItemBuilderWebPart.GetView(this.entity); } } } catch (Exception exception) { base.Report(exception); } } } catch (Exception exception2) { base.Report(exception2); } } } catch (Exception exception3) { base.Report(exception3); } panel.Controls.Add(base.CreateControl(base.Le(4, false) ? "<div id=\"div_{0}\"><div class=\"rox-prop\"><label id=\"label_{0}\" for=\"{0}\">{1}</label></div><select style=\"width: 98%;\" class=\"ms-input\" name=\"{0}\" id=\"{0}\"{2}>{3}</select></div>" : str5, "BdcEntity", new object[] { " onchange=\"roxRefreshFilters();\"", str2 })); str2 = str; try { if (this.view != null) { foreach (Field field in this.view.Fields) { try { str2 = str2 + string.Format("<option value=\"{0}\"{2}>{1}</option>", field.Name, field.ContainsLocalizedDisplayName ? field.LocalizedDisplayName : field.DefaultDisplayName, (flag = field.Name.Equals(this.Get <string>("BdcValueField"))) ? " selected=\"selected\"" : string.Empty); if (flag) { this.valueField = field; } } catch (Exception exception4) { base.Report(exception4); } } } } catch (Exception exception5) { base.Report(exception5); } panel.Controls.Add(base.CreateControl(base.Le(4, false) ? "<div id=\"div_{0}\"><div class=\"rox-prop\"><label id=\"label_{0}\" for=\"{0}\">{1}</label></div><select style=\"width: 98%;\" class=\"ms-input\" name=\"{0}\" id=\"{0}\"{2}>{3}</select></div>" : str5, "BdcValueField", new object[] { " onchange=\"roxRefreshFilters();\"", str2 })); str2 = str; try { if (this.view != null) { foreach (Field field2 in this.view.Fields) { try { str2 = str2 + string.Format("<option value=\"{0}\"{2}>{1}</option>", field2.Name, field2.ContainsLocalizedDisplayName ? field2.LocalizedDisplayName : field2.DefaultDisplayName, (flag = field2.Name.Equals(this.Get <string>("BdcDisplayField"))) ? " selected=\"selected\"" : string.Empty); if (flag) { this.dispField = field2; } } catch (Exception exception6) { base.Report(exception6); } } } } catch (Exception exception7) { base.Report(exception7); } panel.Controls.Add(base.CreateControl(base.Le(4, false) ? "<div id=\"div_{0}\"><div class=\"rox-prop\"><label id=\"label_{0}\" for=\"{0}\">{1}</label></div><select style=\"width: 98%;\" class=\"ms-input\" name=\"{0}\" id=\"{0}\"{2}>{3}</select></div>" : str5, "BdcDisplayField", new object[] { " onchange=\"roxRefreshFilters();\"", str2 })); str2 = string.Format("<option value=\"{0}\"{2}>{1}</option>", string.Empty, base["Empty", new object[0]], string.Empty); if ((this.entity != null) && (this.view != null)) { if (this.valueField == null) { this.valueField = this.view.Fields[0]; } if (this.valueField != null) { if (this.dispField == null) { this.dispField = this.valueField; } using (IEntityInstanceEnumerator enumerator = this.entity.FindFiltered(new FilterCollection(), this.lobInstance)) { while (enumerator.MoveNext()) { string str4; if ((enumerator.Current != null) && !string.IsNullOrEmpty(str4 = ProductPage.Serialize <object>(this.GetIdentifierValues(enumerator.Current)))) { str2 = str2 + string.Format("<option value=\"{0}\"{2}>{1}</option>", str4, enumerator.Current[this.dispField.Name], str4.ToString().Equals(this.Get <string>("BdcInstanceID")) ? " selected=\"selected\"" : string.Empty); } } } } } panel.Controls.Add(base.CreateControl(base.Le(4, false) ? "<div id=\"div_{0}\"><div class=\"rox-prop\"><label id=\"label_{0}\" for=\"{0}\">{1}</label></div><select style=\"width: 98%;\" class=\"ms-input\" name=\"{0}\" id=\"{0}\"{2}>{3}</select></div>" : str5, "BdcInstanceID", new object[] { " onchange=\"" + scriptCheckDefault + "\"", str2 })); } catch (Exception exception8) { base.Report(exception8); } finally { try { if ((this.lobInstance != null) && (this.lobInstance.CurrentConnection != null)) { this.lobInstance.CloseConnection(); } } catch (Exception exception9) { base.Report(exception9); } } } panel.Controls.Add(new LiteralControl("</fieldset>")); try { panel.Controls.Add(base.CreateControl(base.Le(4, false) ? "<div id=\"div_{0}\" class=\"rox-prop\"><input onclick=\"{3}\" type=\"checkbox\" name=\"{0}\" id=\"{0}\"{2}/><label id=\"label_{0}\" for=\"{0}\">{1}</label></div>" : str6, "SendNull", new object[] { base.GetChecked(this.Get <bool>("SendNull")) })); base.UpdatePanel(panel); panel.Controls.Add(base.CreateScript(scriptCheckDefault)); } catch (Exception exception10) { base.Report(exception10); } }
internal Dictionary <string, Microsoft.Office.Server.ApplicationRegistry.MetadataModel.Entity> GetEntities(LobSystemInstance inst) { return(inst.GetEntities()); }