static void CreateMetaField2009_06_03() { using (DataContext.Current = new DataContext("Data source=S2;Initial catalog=ibn48portal;Integrated Security=SSPI;")) { MetaClass workflowClass = DataContext.Current.GetMetaClass(WorkflowDefinitionEntity.ClassName); using (MetaClassManagerEditScope scope = DataContext.Current.MetaModel.BeginEdit()) { workflowClass.DeleteMetaField("PlanDuration"); using (MetaFieldBuilder mfb = new MetaFieldBuilder(workflowClass)) { //PlanFinishDate: DateTime mfb.CreateDateTime("PlanFinishDate", "Plan Finish Date", true, true); //PlanDuration: Duration mfb.CreateDuration("PlanDuration", "Plan Duration", true, 60); //PlanFinishTimeType: Enum (None, DateTime, Duration) mfb.CreateEnumField("PlanFinishTimeType", "Plan Finish Time Type", "TimeType", false, "1", false); mfb.SaveChanges(); } scope.SaveChanges(); } } }
private void AddCustomerStripeFieldIfNeccessary() { var bafConnectionString = BusinessFoundationConfigurationSection.Instance.Connection.Database; if (bafConnectionString == null) { return; } DataContext.Current = new DataContext(bafConnectionString); Mediachase.BusinessFoundation.Data.Modules.ModuleManager.InitializeActiveModules(); var fields = DataContext.Current.MetaModel.MetaClasses[ContactEntity.ClassName].Fields; if (fields.Contains("StripeId")) { return; } var manager = DataContext.Current.MetaModel; var mc = manager.MetaClasses[ContactEntity.ClassName]; using (var builder = new MetaFieldBuilder(mc)) { builder.CreateText("StripeId", "StripeId", false, 512, false); builder.SaveChanges(); } }
internal static void CreateCustomPageMetaClass() { DataContext.Current = new DataContext("Data source=S2;Initial catalog=ibn48portal;Integrated Security=SSPI;"); using (MetaClassManagerEditScope scope = DataContext.Current.MetaModel.BeginEdit()) { MetaClass googleGadget = DataContext.Current.MetaModel.CreateMetaClass("CustomPage", "Custom Page", "Custom Pages", "cls_CustomPage", PrimaryKeyId.ValueType.Guid); using (MetaFieldBuilder builder = new MetaFieldBuilder(googleGadget)) { builder.CreateText("Title", "Title", false, 255, false); builder.CreateLongText("Description", "Description", true); builder.CreateFile("Icon", "Icon", true, string.Empty); builder.CreateLongText("JsonData", "Json Data", false); builder.CreateGuid("TemplateId", "Template Id", false); builder.CreateGuid("Uid", "Uid", false); builder.CreateReference("Profile", "Profile", true, CustomizationProfileEntity.ClassName, true); builder.CreateReference("User", "User", true, "Principal", true); builder.SaveChanges(); } googleGadget.TitleFieldName = "Title"; BusinessObjectServiceManager.InstallService(googleGadget, ChangeDetectionService.ServiceName); scope.SaveChanges(); } }
private static void AddCustomerField(MetaFieldBuilder builder, Mediachase.BusinessFoundation.Data.Meta.Management.MetaClass customContactMetaClass, string field) { if (customContactMetaClass.Fields[field] == null) { builder.CreateText(field, field, true, 100, false); } }
static void TestCreateFields() { DataContext.Current = new DataContext("Data source=S2;Initial catalog=ibn48portal;Integrated Security=SSPI;"); using (MetaClassManagerEditScope scope = DataContext.Current.MetaModel.BeginEdit()) { MetaClass mc = DataContext.Current.GetMetaClass(WorkflowDefinitionEntity.ClassName); // Create Enum MetaFieldType enumType = MetaEnum.Create("SupportedIbnObjectType", "Supported Ibn Object Type", true); MetaEnum.AddItem(enumType, 16, "Document", 1); MetaEnum.AddItem(enumType, 5, "Task", 2); MetaEnum.AddItem(enumType, 6, "Todo", 3); MetaEnum.AddItem(enumType, 7, "Incident", 4); // Create Project Field using (MetaFieldBuilder bulder = new MetaFieldBuilder(mc)) { bulder.CreateReference("Project", "Project", true, "Project", true); bulder.CreateEnumField("SupportedIbnObjectTypes", "Supported Ibn Object Types", "SupportedIbnObjectType", true, "16", false); bulder.SaveChanges(); } scope.SaveChanges(); } }
internal static void CreateGoogleGadgetMetaClass() { DataContext.Current = new DataContext("Data source=S2;Initial catalog=ibn48portal;Integrated Security=SSPI;"); using (MetaClassManagerEditScope scope = DataContext.Current.MetaModel.BeginEdit()) { MetaClass googleGadget = DataContext.Current.MetaModel.CreateMetaClass("GoogleGadget", "Google Gadget", "Google Gadgets", "cls_GoogleGadget", PrimaryKeyId.ValueType.Guid); using (MetaFieldBuilder builder = new MetaFieldBuilder(googleGadget)) { builder.CreateText("Title", "Title", false, 255, false); builder.CreateLongText("Description", "Description", true); builder.CreateUrl("Link", "Link", false, 1024, false, string.Empty); builder.SaveChanges(); } googleGadget.TitleFieldName = "Title"; BusinessObjectServiceManager.InstallService(googleGadget, ChangeDetectionService.ServiceName); scope.SaveChanges(); } }
/// <summary> /// Initialize /// </summary> /// <param name="context"></param> public void Initialize(InitializationEngine context) { MetaDataContext mdContext = CatalogContext.MetaDataContext; var netaxeptBankPaymentMethod = GetOrCreateCardField(mdContext, NetaxeptConstants.NetaxeptPaymentMethod); JoinField(mdContext, netaxeptBankPaymentMethod, NetaxeptConstants.OtherPaymentClass); var callbackUrl = GetOrCreateCardField(mdContext, NetaxeptConstants.CallbackUrl); JoinField(mdContext, callbackUrl, NetaxeptConstants.OtherPaymentClass); var cardInformationIssuerCountryField = GetOrCreateCardField(mdContext, NetaxeptConstants.CardInformationIssuerCountryField); JoinField(mdContext, cardInformationIssuerCountryField, NetaxeptConstants.OtherPaymentClass); var cardInformationExpiryDateField = GetOrCreateCardField(mdContext, NetaxeptConstants.CardInformationExpiryDateField); JoinField(mdContext, cardInformationExpiryDateField, NetaxeptConstants.OtherPaymentClass); var cardInformationIssuerField = GetOrCreateCardField(mdContext, NetaxeptConstants.CardInformationIssuerField); JoinField(mdContext, cardInformationIssuerField, NetaxeptConstants.OtherPaymentClass); var cardInformationIssuerIdField = GetOrCreateCardField(mdContext, NetaxeptConstants.CardInformationIssuerIdField); JoinField(mdContext, cardInformationIssuerIdField, NetaxeptConstants.OtherPaymentClass); var cardInformationMaskedPanField = GetOrCreateCardField(mdContext, NetaxeptConstants.CardInformationMaskedPanField); JoinField(mdContext, cardInformationMaskedPanField, NetaxeptConstants.OtherPaymentClass); var cardInformationPaymentMethodField = GetOrCreateCardField(mdContext, NetaxeptConstants.CardInformationPaymentMethodField); JoinField(mdContext, cardInformationPaymentMethodField, NetaxeptConstants.OtherPaymentClass); var cartOrderNumberTempField = GetOrCreateCardField(mdContext, NetaxeptConstants.CartOrderNumberTempField); JoinField(mdContext, cartOrderNumberTempField, NetaxeptConstants.CartClass); // Create PanHash field on the customer contact. We need this for using EasyPayments var customContactMetaClass = DataContext.Current.MetaModel.MetaClasses["Contact"]; if (customContactMetaClass != null) { using (MetaFieldBuilder builder = new MetaFieldBuilder(customContactMetaClass)) { AddCustomerField(builder, customContactMetaClass, NetaxeptConstants.CustomerPanHashFieldName); AddCustomerField(builder, customContactMetaClass, NetaxeptConstants.CustomerCardMaskedFieldName); AddCustomerField(builder, customContactMetaClass, NetaxeptConstants.CustomerCardExpirationDateFieldName); AddCustomerField(builder, customContactMetaClass, NetaxeptConstants.CustomerCardPaymentMethodFieldName); AddCustomerField(builder, customContactMetaClass, NetaxeptConstants.CustomerCardIssuerCountryFieldName); AddCustomerField(builder, customContactMetaClass, NetaxeptConstants.CustomerCardIssuerIdFieldName); AddCustomerField(builder, customContactMetaClass, NetaxeptConstants.CustomerCardIssuerFieldName); builder.SaveChanges(); } } }
public void CreationTest(string name, EncapsulationLevel encapsulationLevel) { var fb = new MetaFieldBuilder(name); fb.EncapsulationLevel = encapsulationLevel; fb.SetType(MetaType.Boolean); var field = fb.Build(); Assert.AreEqual(field.Name, name); Assert.AreEqual(field.EncapsulationLevel, encapsulationLevel); Assert.AreEqual(field.Type, MetaType.Boolean); Assert.AreEqual(field.Module, null); }
static void CreateMetaField2009_06_03() { using (DataContext.Current = new DataContext("Data source=S2;Initial catalog=ibn48portal;Integrated Security=SSPI;")) { MetaClass workflowClass = DataContext.Current.GetMetaClass(WorkflowInstanceEntity.ClassName); using (MetaClassManagerEditScope scope = DataContext.Current.MetaModel.BeginEdit()) { // WorkflowInstanceTimeStatus MetaFieldType workflowInstanceTimeStatus = MetaEnum.Create("WorkflowInstanceTimeStatus", "Workflow Instance Time Status", false); MetaEnum.AddItem(workflowInstanceTimeStatus, "OverStart", 1); MetaEnum.AddItem(workflowInstanceTimeStatus, "OverDue", 2); // FinishTimeType MetaFieldType timeType = MetaEnum.Create("TimeType", "Time Type", false); MetaEnum.AddItem(timeType, "NotSet", 1); MetaEnum.AddItem(timeType, "DateTime", 2); MetaEnum.AddItem(timeType, "Duration", 3); using (MetaFieldBuilder mfb = new MetaFieldBuilder(workflowClass)) { //ActualStartDate: DateTime mfb.CreateDateTime("ActualStartDate", "Actual Start Date", true, true); //ActualFinishDate: DateTime mfb.CreateDateTime("ActualFinishDate", "Actual Finish Date", true, true); //TimeStatus: DateTime mfb.CreateEnumField("TimeStatus", "Time Status", "WorkflowInstanceTimeStatus", true, "", false); //PlanFinishDate: DateTime mfb.CreateDateTime("PlanFinishDate", "Plan Finish Date", true, true); //PlanDuration: Duration mfb.CreateDuration("PlanDuration", "Plan Duration", true, 60); //PlanFinishTimeType: Enum (None, DateTime, Duration) mfb.CreateEnumField("PlanFinishTimeType", "Plan Finish Time Type", "TimeType", false, "1", false); mfb.SaveChanges(); } scope.SaveChanges(); } } }
public ActionResult CreateClubCardClass() { var viewModel = new BisFoundViewModel(); using (MetaClassManagerEditScope metaEdit = DataContext.Current.MetaModel.BeginEdit()) { MetaClass clubCard = DataContext.Current.MetaModel.CreateMetaClass("ClubCard", "Club Card", "ClubCards", "demoClub_Cards", PrimaryKeyIdValueType.Integer); clubCard.AccessLevel = AccessLevel.Customization; metaEdit.SaveChanges(); } MetaFieldType cardEnum = DataContext.Current.MetaModel.RegisteredTypes["CardType"]; if (cardEnum == null) { using (MetaClassManagerEditScope metaEdit = DataContext.Current.MetaModel.BeginEdit()) { cardEnum = MetaEnum.Create("CardType", "Club Card Type", false); cardEnum.AccessLevel = AccessLevel.Customization; metaEdit.SaveChanges(); MetaEnum.AddItem(cardEnum, "Gold", 1); MetaEnum.AddItem(cardEnum, "Silver", 2); MetaEnum.AddItem(cardEnum, "Bronze", 3); } } using (MetaFieldBuilder fieldBuilder = new MetaFieldBuilder(DataContext.Current.GetMetaClass("ClubCard"))) { MetaField titleField = fieldBuilder.CreateText("TitleField", "Title Field", false, 100, false); fieldBuilder.MetaClass.TitleFieldName = titleField.Name; fieldBuilder.CreateText("CardOwnerName", "Card Owner Name", false, 100, false); fieldBuilder.CreateEmail("Email", "Email", false, 100, true); fieldBuilder.CreateInteger("Balance", "Balance", true, 0); var mf = fieldBuilder.CreateEnumField("CardTypeEnum", "Card Type", cardEnum.Name, true, String.Empty, true); mf.AccessLevel = AccessLevel.Customization; fieldBuilder.SaveChanges(); MetaDataWrapper.CreateReference("Contact", "ClubCard", "ContactRef", "Contact References", false, "InfoBlock", "ClubCard", "10"); } FillModel(viewModel); return(View("Index", viewModel)); }
private void CreateMetaField(string metaClassName, string metaFieldName, string friendlyName, bool isNullable = true, int maxLength = 255, bool isUnique = false) { var metaClass = GetMetaClass(metaClassName, metaFieldName); if (metaClass == null) { return; } using (var metaFieldBuilder = new MetaFieldBuilder(metaClass)) { metaFieldBuilder.MetaClass.AccessLevel = AccessLevel.Customization; metaFieldBuilder.CreateText(metaFieldName, friendlyName, isNullable, maxLength, isUnique); metaFieldBuilder.SaveChanges(); } }
private void CreateGuidMetaField(string metaClassName, string metaFieldName, string friendlyName, bool isNullable = true) { var metaClass = GetMetaClass(metaClassName, metaFieldName); if (metaClass == null) { return; } using (var metaFieldBuilder = new MetaFieldBuilder(metaClass)) { metaFieldBuilder.MetaClass.AccessLevel = AccessLevel.Customization; metaFieldBuilder.CreateGuid(metaFieldName, friendlyName, isNullable); metaFieldBuilder.SaveChanges(); } }
static void CreatePropertyJsonDataField() { DataContext.Current = new DataContext("Data source=S2;Initial catalog=ibn48portal;Integrated Security=SSPI;"); using (MetaClassManagerEditScope scope = DataContext.Current.MetaModel.BeginEdit()) { MetaClass metaClass = DataContext.Current.GetMetaClass(CustomPageEntity.ClassName); using (MetaFieldBuilder builder = new MetaFieldBuilder(metaClass)) { builder.CreateLongText("PropertyJsonData", "Property Json Data", true); builder.SaveChanges(); } scope.SaveChanges(); } }
private static void CreateMetaField() { DataContext.Current = new DataContext("Data source=S2;Initial catalog=ibn48portal;Integrated Security=SSPI;"); using (MetaClassManagerEditScope scope = DataContext.Current.MetaModel.BeginEdit()) { MetaClass metaClass = DataContext.Current.GetMetaClass(AssignmentEntity.ClassName); using (MetaFieldBuilder builder = new MetaFieldBuilder(metaClass)) { builder.CreateInteger("ClosedBy", "Closed By", true, 0); builder.SaveChanges(); } scope.SaveChanges(); } }
static void CreateMetaField2009_06_05() { using (DataContext.Current = new DataContext("Data source=S2;Initial catalog=ibn48portal;Integrated Security=SSPI;")) { MetaClass workflowClass = DataContext.Current.GetMetaClass(WorkflowDefinitionEntity.ClassName); using (MetaClassManagerEditScope scope = DataContext.Current.MetaModel.BeginEdit()) { using (MetaFieldBuilder mfb = new MetaFieldBuilder(workflowClass)) { mfb.CreateLongText("XSParameters", "Xml Serialized Parameters", true); mfb.SaveChanges(); } scope.SaveChanges(); } } }
protected override void ExecuteInternal(IProgressMessenger progressMessenger) { using (var scope = DataContext.Current.MetaModel.BeginEdit(MetaClassManagerEditScope.SystemOwner, Mediachase.BusinessFoundation.Data.Meta.Management.AccessLevel.System)) { var manager = DataContext.Current.MetaModel; var changeTrackingManifest = ChangeTrackingManager.CreateModuleManifest(); var recentReferenceManifest = RecentReferenceManager.CreateModuleManifest(); var contactMetaClass = manager.MetaClasses[ContactEntity.ClassName]; var demoUserMenu = MetaEnum.Create("DemoUserMenu", "Show in Demo User Menu", false); MetaEnum.AddItem(demoUserMenu, 1, "Never", 1); MetaEnum.AddItem(demoUserMenu, 2, "Always", 2); MetaEnum.AddItem(demoUserMenu, 3, "Commerce Only", 3); using (var builder = new MetaFieldBuilder(contactMetaClass)) { builder.CreateEnumField("ShowInDemoUserMenu", "{Customer:DemoUserMenu}", "DemoUserMenu", true, "1", false); builder.CreateText("DemoUserTitle", "{Customer:DemoUserTitle}", true, 100, false); builder.CreateText("DemoUserDescription", "{Customer:DemoUserDescription}", true, 500, false); builder.SaveChanges(); } AddMetaFieldToForms(contactMetaClass, contactMetaClass.Fields["ShowInDemoUserMenu"]); AddMetaFieldToForms(contactMetaClass, contactMetaClass.Fields["DemoUserTitle"]); AddMetaFieldToForms(contactMetaClass, contactMetaClass.Fields["DemoUserDescription"]); var giftCardClass = manager.CreateMetaClass("GiftCard", "{Customer:GiftCard}", "{Customer:GiftCard}", "cls_GiftCard", PrimaryKeyIdValueType.Guid); ModuleManager.Activate(giftCardClass, changeTrackingManifest); using (var builder = new MetaFieldBuilder(giftCardClass)) { builder.CreateText("GiftCardName", "{Customer:GiftCardName}", false, 100, false); builder.CreateCurrency("InitialAmount", "{Customer:InitialAmount}", true, 0, true); builder.CreateCurrency("RemainBalance", "{Customer:RemainBalance}", true, 0, true); builder.CreateText("RedemptionCode", "{Customer:RedemptionCode}", true, 100, false); builder.CreateCheckBoxBoolean("IsActive", "{Customer:IsActive}", true, true, "{Customer:IsActive}"); giftCardClass.Fields[MetaClassManager.GetPrimaryKeyName(giftCardClass.Name)].FriendlyName = "{GlobalMetaInfo:PrimaryKeyId}"; var contactReference = builder.CreateReference("Contact", "{Customer:CreditCard_mf_Contact}", true, "Contact", false); contactReference.Attributes.Add(McDataTypeAttribute.ReferenceDisplayBlock, "InfoBlock"); contactReference.Attributes.Add(McDataTypeAttribute.ReferenceDisplayText, "{Customer:GiftCard}"); contactReference.Attributes.Add(McDataTypeAttribute.ReferenceDisplayOrder, "10000"); builder.SaveChanges(); } giftCardClass.AddPermissions(); AddMetaFieldToForms(giftCardClass, giftCardClass.Fields["GiftCardName"]); AddMetaFieldToForms(giftCardClass, giftCardClass.Fields["InitialAmount"]); AddMetaFieldToForms(giftCardClass, giftCardClass.Fields["RemainBalance"]); AddMetaFieldToForms(giftCardClass, giftCardClass.Fields["RedemptionCode"]); AddMetaFieldToForms(giftCardClass, giftCardClass.Fields["IsActive"]); AddMetaFieldToForms(giftCardClass, giftCardClass.Fields["ContactId"]); scope.SaveChanges(); } var contactProfile = @"<ListViewProfile xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema""> <Id>{54a649a9-302f-48bd-b657-11ca3604fda9}</Id> <Name>{Customer:AllContacts}</Name> <IsSystem>true</IsSystem> <IsPublic>true</IsPublic> <FieldSetName>Contacts</FieldSetName> <FieldSet> <string>FullName</string> <string>Email</string> <string>LastOrder</string> <string>NumberOfOrders</string> <string>NumberOfReviews</string> <string>Points</string> <string>ShowInDemoUserMenu</string> <string>DemoUserTitle</string> </FieldSet> <GroupByFieldName /> <Filters /> <Sorting /> <ColumnsUI> <Column field=""FullName"" width=""150"" /> <Column field=""Email"" width=""150"" /> <Column field=""LastOrder"" width=""150"" /> <Column field=""NumberOfOrders"" width=""150"" /> <Column field=""NumberOfReviews"" width=""150"" /> <Column field=""Points"" width=""150"" /> <Column field=""ShowInDemoUserMenu"" width=""150"" /> <Column field=""DemoUserTitle"" width=""150"" /> </ColumnsUI> </ListViewProfile>"; var contactviewProfile = (ListViewProfile)_listViewProfileXmlSerializer.Deserialize(new StringReader(contactProfile)); ListViewProfile.SaveSystemProfile("Contact", "EntityList", Guid.NewGuid(), contactviewProfile); using (var stream = new FileStream(Path.Combine(HostingEnvironment.ApplicationPhysicalPath, @"App_Data\Customers.xml"), FileMode.Open)) { ProcessCustomers(stream); ProcessOrganizations(stream); } }
public void CreateBusinessFoundation() { var clubCard = DataContext.Current.GetMetaClass("ClubCard"); if (clubCard == null) { using (MetaClassManagerEditScope metaEdit = DataContext.Current.MetaModel.BeginEdit()) { clubCard = DataContext.Current .MetaModel .CreateMetaClass("ClubCard", "Club Card", "ClubCards", "demoClub_Cards", PrimaryKeyIdValueType.Integer); clubCard.AccessLevel = AccessLevel.Customization; metaEdit.SaveChanges(); } } MetaFieldType cardEnum = DataContext.Current.MetaModel.RegisteredTypes["CardType"]; if (cardEnum == null) { using (MetaClassManagerEditScope metaEdit = DataContext.Current.MetaModel.BeginEdit()) { cardEnum = MetaEnum.Create("CardType", "Club Card Type", false); cardEnum.AccessLevel = AccessLevel.Customization; metaEdit.SaveChanges(); MetaEnum.AddItem(cardEnum, "Gold", 1); MetaEnum.AddItem(cardEnum, "Silver", 2); MetaEnum.AddItem(cardEnum, "Bronze", 3); } } using (MetaFieldBuilder fieldBuilder = new MetaFieldBuilder(DataContext.Current.GetMetaClass("ClubCard"))) { MetaField titleField = fieldBuilder.CreateText("TitleField", "Title Field", false, 100, false); fieldBuilder.MetaClass.TitleFieldName = titleField.Name; fieldBuilder.CreateText("CardOwnerName", "Card Owner Name", false, 100, false); fieldBuilder.CreateEmail("Email", "Email", false, 100, true); fieldBuilder.CreateInteger("Balance", "Balance", true, 0); var mf = fieldBuilder.CreateEnumField("CardTypeEnum", "Card Type", cardEnum.Name, true, string.Empty, true); mf.AccessLevel = AccessLevel.Customization; fieldBuilder.SaveChanges(); MetaDataWrapper.CreateReference("Contact", "ClubCard", "ContactRef", "Contact Reference", false, "InfoBlock", "ClubCard", "10"); } //set data EntityObject cardObjSet = true ? BusinessManager.InitializeEntity("ClubCard") : BusinessManager.Load("ClubCard", 12); cardObjSet["TitleField"] = "test"; if (true) { BusinessManager.Create(cardObjSet); } else { BusinessManager.Update(cardObjSet); } //get data EntityObject cardObj = BusinessManager.Load("ClubCartd", 12); var test = (string)cardObj["TitleField"]; //delete DataContext.Current.MetaModel.DeleteMetaClass("ClubCard"); MetaFieldType cardEnumDelete = DataContext.Current.MetaModel.RegisteredTypes["CardType"]; if (cardEnumDelete != null && !MetaEnum.IsUsed(cardEnum)) { MetaEnum.Remove(cardEnumDelete); } }