private static void Patch20201222(EntityManager entMan, EntityRelationManager relMan, RecordManager recMan) { #region << ***Update field*** Entity: case Field Name: created_on >> { var currentEntity = entMan.ReadEntity(new Guid("0ebb3981-7443-45c8-ab38-db0709daf58c")).Object; InputDateTimeField datetimeField = new InputDateTimeField(); datetimeField.Id = currentEntity.Fields.SingleOrDefault(x => x.Name == "created_on").Id; datetimeField.Name = "created_on"; datetimeField.Label = "Created on"; datetimeField.PlaceholderText = null; datetimeField.Description = null; datetimeField.HelpText = null; datetimeField.Required = true; datetimeField.Unique = false; datetimeField.Searchable = false; datetimeField.Auditable = false; datetimeField.System = true; datetimeField.DefaultValue = null; datetimeField.Format = "yyyy-MMM-dd HH:mm"; datetimeField.UseCurrentTimeAsDefaultValue = true; datetimeField.EnableSecurity = false; datetimeField.Permissions = new FieldPermissions(); datetimeField.Permissions.CanRead = new List <Guid>(); datetimeField.Permissions.CanUpdate = new List <Guid>(); //READ //UPDATE { var response = entMan.UpdateField(new Guid("0ebb3981-7443-45c8-ab38-db0709daf58c"), datetimeField); if (!response.Success) { throw new Exception("System error 10060. Entity: case Field: created_on Message:" + response.Message); } } } #endregion }
public IActionResult OnPost() { if (!ModelState.IsValid) { throw new Exception("Antiforgery check failed."); } InitPage(); if (ErpEntity == null) { return(NotFound()); } if (String.IsNullOrWhiteSpace(ReturnUrl)) { ReturnUrl = $"/sdk/objects/entity/r/{RecordId}/rl/fields/c/select"; } //empty html input is not posted, so we init it with string.empty if (DefaultValue == null) { DefaultValue = string.Empty; } var entMan = new EntityManager(); try { var newFieldId = Guid.NewGuid(); if (Id != null) { newFieldId = Id.Value; } var response = new FieldResponse(); InputField input = null; switch (Type) { case FieldType.AutoNumberField: { decimal defaultDecimal = 1; if (Decimal.TryParse(DefaultValue, out decimal result)) { defaultDecimal = result; } input = new InputAutoNumberField() { Id = newFieldId, Name = Name, Label = Label, Required = Required, Description = Description, Unique = Unique, HelpText = HelpText, System = System, PlaceholderText = PlaceholderText, Searchable = Searchable, DefaultValue = defaultDecimal, StartingNumber = StartingNumber, DisplayFormat = DisplayFormat, EnableSecurity = EnableSecurity }; } break; case FieldType.CheckboxField: { bool?defaultValue = null; if (Boolean.TryParse(DefaultValue, out bool result)) { defaultValue = result; } input = new InputCheckboxField() { Id = newFieldId, Name = Name, Label = Label, Required = Required, Description = Description, Unique = Unique, HelpText = HelpText, System = System, PlaceholderText = PlaceholderText, Searchable = Searchable, DefaultValue = defaultValue, EnableSecurity = EnableSecurity }; } break; case FieldType.CurrencyField: { decimal?defaultDecimal = null; if (Decimal.TryParse(DefaultValue, out decimal result)) { defaultDecimal = result; } input = new InputCurrencyField() { Id = newFieldId, Name = Name, Label = Label, Required = Required, Description = Description, Unique = Unique, HelpText = HelpText, System = System, PlaceholderText = PlaceholderText, Searchable = Searchable, DefaultValue = defaultDecimal, EnableSecurity = EnableSecurity, MinValue = MinValue, MaxValue = MaxValue, Currency = Helpers.GetCurrencyType(CurrencyCode) }; } break; case FieldType.DateField: { DateTime?defaultValue = null; if (DateTime.TryParse(DefaultValue, out DateTime result)) { defaultValue = result; } input = new InputDateField() { Id = newFieldId, Name = Name, Label = Label, Required = Required, Description = Description, Unique = Unique, HelpText = HelpText, System = System, PlaceholderText = PlaceholderText, Searchable = Searchable, DefaultValue = defaultValue, EnableSecurity = EnableSecurity, Format = Format, UseCurrentTimeAsDefaultValue = UseCurrentTimeAsDefaultValue }; } break; case FieldType.DateTimeField: { DateTime?defaultValue = null; if (DateTime.TryParse(DefaultValue, out DateTime result)) { defaultValue = result; } input = new InputDateTimeField() { Id = newFieldId, Name = Name, Label = Label, Required = Required, Description = Description, Unique = Unique, HelpText = HelpText, System = System, PlaceholderText = PlaceholderText, Searchable = Searchable, DefaultValue = defaultValue, EnableSecurity = EnableSecurity, Format = Format, UseCurrentTimeAsDefaultValue = UseCurrentTimeAsDefaultValue }; } break; case FieldType.EmailField: { string defaultValue = null; if (DefaultValue.ToLowerInvariant() != "null") { defaultValue = DefaultValue; } input = new InputEmailField() { Id = newFieldId, Name = Name, Label = Label, Required = Required, Description = Description, Unique = Unique, HelpText = HelpText, System = System, PlaceholderText = PlaceholderText, Searchable = Searchable, DefaultValue = defaultValue, EnableSecurity = EnableSecurity, MaxLength = MaxLength }; } break; case FieldType.FileField: { string defaultValue = null; if (DefaultValue.ToLowerInvariant() != "null") { defaultValue = DefaultValue; } input = new InputFileField() { Id = newFieldId, Name = Name, Label = Label, Required = Required, Description = Description, Unique = Unique, HelpText = HelpText, System = System, PlaceholderText = PlaceholderText, Searchable = Searchable, DefaultValue = defaultValue, EnableSecurity = EnableSecurity }; } break; case FieldType.HtmlField: { string defaultValue = null; if (DefaultValue.ToLowerInvariant() != "null") { defaultValue = DefaultValue; } input = new InputHtmlField() { Id = newFieldId, Name = Name, Label = Label, Required = Required, Description = Description, Unique = Unique, HelpText = HelpText, System = System, PlaceholderText = PlaceholderText, Searchable = Searchable, DefaultValue = defaultValue, EnableSecurity = EnableSecurity }; } break; case FieldType.ImageField: { string defaultValue = null; if (DefaultValue.ToLowerInvariant() != "null") { defaultValue = DefaultValue; } input = new InputImageField() { Id = newFieldId, Name = Name, Label = Label, Required = Required, Description = Description, Unique = Unique, HelpText = HelpText, System = System, PlaceholderText = PlaceholderText, Searchable = Searchable, DefaultValue = defaultValue, EnableSecurity = EnableSecurity }; } break; case FieldType.MultiLineTextField: { string defaultValue = null; if (DefaultValue.ToLowerInvariant() != "null") { defaultValue = DefaultValue; } input = new InputMultiLineTextField() { Id = newFieldId, Name = Name, Label = Label, Required = Required, Description = Description, Unique = Unique, HelpText = HelpText, System = System, PlaceholderText = PlaceholderText, Searchable = Searchable, DefaultValue = defaultValue, EnableSecurity = EnableSecurity, MaxLength = MaxLength }; } break; case FieldType.MultiSelectField: { var selectOptions = (SelectOptions ?? string.Empty).Split(Environment.NewLine); var defaultOptions = (DefaultValue ?? string.Empty).Split(Environment.NewLine); var multiSelectOptions = new List <SelectOption>(); var defaultValues = new List <string>(); foreach (var option in selectOptions) { if (!String.IsNullOrWhiteSpace(option)) { var optionArray = option.Split(','); var key = ""; var value = ""; var iconClass = ""; var color = ""; if (optionArray.Length > 0 && !String.IsNullOrWhiteSpace(optionArray[0])) { key = optionArray[0].Trim().ToLowerInvariant(); } if (optionArray.Length > 1 && !String.IsNullOrWhiteSpace(optionArray[1])) { value = optionArray[1].Trim(); } else if (optionArray.Length > 0 && !String.IsNullOrWhiteSpace(optionArray[0])) { value = key; } if (optionArray.Length > 2 && !String.IsNullOrWhiteSpace(optionArray[2])) { iconClass = optionArray[2].Trim(); } if (optionArray.Length > 3 && !String.IsNullOrWhiteSpace(optionArray[3])) { color = optionArray[3].Trim(); } if (!String.IsNullOrWhiteSpace(key) && !String.IsNullOrWhiteSpace(value)) { multiSelectOptions.Add(new SelectOption() { Value = key, Label = value, IconClass = iconClass, Color = color }); } } } foreach (var option in defaultOptions) { var fixedOption = option.Trim().ToLowerInvariant(); if (!String.IsNullOrWhiteSpace(option) && multiSelectOptions.Any(x => x.Value == fixedOption)) { defaultValues.Add(fixedOption); } else if (!String.IsNullOrWhiteSpace(option) && !multiSelectOptions.Any(x => x.Value == fixedOption)) { Validation.Errors.Add(new ValidationError("DefaultValue", "one or more of the default values are not found as select options")); throw Validation; } } input = new InputMultiSelectField() { Id = newFieldId, Name = Name, Label = Label, Required = Required, Description = Description, Unique = Unique, HelpText = HelpText, System = System, PlaceholderText = PlaceholderText, Searchable = Searchable, EnableSecurity = EnableSecurity, Options = multiSelectOptions, DefaultValue = defaultValues }; } break; case FieldType.NumberField: { decimal?defaultDecimal = null; if (Decimal.TryParse(DefaultValue, out decimal result)) { defaultDecimal = result; } input = new InputNumberField() { Id = newFieldId, Name = Name, Label = Label, Required = Required, Description = Description, Unique = Unique, HelpText = HelpText, System = System, PlaceholderText = PlaceholderText, Searchable = Searchable, DefaultValue = defaultDecimal, EnableSecurity = EnableSecurity, MinValue = MinValue, MaxValue = MaxValue, DecimalPlaces = DecimalPlaces }; } break; case FieldType.PasswordField: { input = new InputPasswordField() { Id = newFieldId, Name = Name, Label = Label, Required = Required, Description = Description, Unique = Unique, HelpText = HelpText, System = System, PlaceholderText = PlaceholderText, Searchable = Searchable, MinLength = MinLength, Encrypted = Encrypted, EnableSecurity = EnableSecurity, MaxLength = MaxLength }; } break; case FieldType.PercentField: { decimal?defaultDecimal = null; if (Decimal.TryParse(DefaultValue, out decimal result)) { defaultDecimal = result; } input = new InputNumberField() { Id = newFieldId, Name = Name, Label = Label, Required = Required, Description = Description, Unique = Unique, HelpText = HelpText, System = System, PlaceholderText = PlaceholderText, Searchable = Searchable, DefaultValue = defaultDecimal, EnableSecurity = EnableSecurity, MinValue = MinValue, MaxValue = MaxValue, DecimalPlaces = DecimalPlaces }; } break; case FieldType.PhoneField: { string defaultValue = null; if (DefaultValue.ToLowerInvariant() != "null") { defaultValue = DefaultValue; } input = new InputPhoneField() { Id = newFieldId, Name = Name, Label = Label, Required = Required, Description = Description, Unique = Unique, HelpText = HelpText, System = System, PlaceholderText = PlaceholderText, Searchable = Searchable, DefaultValue = defaultValue, EnableSecurity = EnableSecurity, MaxLength = MaxLength }; } break; case FieldType.GuidField: { Guid?defaultGuid = null; if (Guid.TryParse(DefaultValue, out Guid result)) { defaultGuid = result; } input = new InputGuidField() { Id = newFieldId, Name = Name, Label = Label, Required = Required, Description = Description, Unique = Unique, HelpText = HelpText, System = System, PlaceholderText = PlaceholderText, Searchable = Searchable, DefaultValue = defaultGuid, EnableSecurity = EnableSecurity, GenerateNewId = GenerateNewId }; } break; case FieldType.SelectField: { var selectOptions = SelectOptions.Split(Environment.NewLine); var modelSelectOptions = new List <SelectOption>(); foreach (var option in selectOptions) { if (!String.IsNullOrWhiteSpace(option)) { var optionArray = option.Split(','); var key = ""; var value = ""; var iconClass = ""; var color = ""; if (optionArray.Length > 0 && !String.IsNullOrWhiteSpace(optionArray[0])) { key = optionArray[0].Trim().ToLowerInvariant(); } if (optionArray.Length > 1 && !String.IsNullOrWhiteSpace(optionArray[1])) { value = optionArray[1].Trim(); } else if (optionArray.Length > 0 && !String.IsNullOrWhiteSpace(optionArray[0])) { value = key; } if (optionArray.Length > 2 && !String.IsNullOrWhiteSpace(optionArray[2])) { iconClass = optionArray[2].Trim(); } if (optionArray.Length > 3 && !String.IsNullOrWhiteSpace(optionArray[3])) { color = optionArray[3].Trim(); } if (!String.IsNullOrWhiteSpace(key) && !String.IsNullOrWhiteSpace(value)) { modelSelectOptions.Add(new SelectOption() { Value = key, Label = value, IconClass = iconClass, Color = color }); } } } DefaultValue = DefaultValue.Trim().ToLowerInvariant(); if (!String.IsNullOrWhiteSpace(DefaultValue) && !modelSelectOptions.Any(x => x.Value == DefaultValue)) { Validation.Errors.Add(new ValidationError("DefaultValue", "one or more of the default values are not found as select options")); throw Validation; } input = new InputSelectField() { Id = newFieldId, Name = Name, Label = Label, Required = Required, Description = Description, Unique = Unique, HelpText = HelpText, System = System, PlaceholderText = PlaceholderText, Searchable = Searchable, DefaultValue = DefaultValue, EnableSecurity = EnableSecurity, Options = modelSelectOptions }; } break; case FieldType.UrlField: { string defaultValue = null; if (DefaultValue.ToLowerInvariant() != "null") { defaultValue = DefaultValue; } input = new InputUrlField() { Id = newFieldId, Name = Name, Label = Label, Required = Required, Description = Description, Unique = Unique, HelpText = HelpText, System = System, PlaceholderText = PlaceholderText, Searchable = Searchable, DefaultValue = defaultValue, EnableSecurity = EnableSecurity, MaxLength = MaxLength, OpenTargetInNewWindow = OpenTargetInNewWindow }; } break; case FieldType.TextField: { string defaultValue = null; if (DefaultValue.ToLowerInvariant() != "null") { defaultValue = DefaultValue; } input = new InputTextField() { Id = newFieldId, Name = Name, Label = Label, Required = Required, Description = Description, Unique = Unique, HelpText = HelpText, System = System, PlaceholderText = PlaceholderText, Searchable = Searchable, DefaultValue = defaultValue, EnableSecurity = EnableSecurity, MaxLength = MaxLength }; } break; default: throw new Exception("Field Type not recognized"); } var recordPermissionsKeyValues = JsonConvert.DeserializeObject <List <KeyStringList> >(FieldPermissions); input.Permissions = new FieldPermissions(); input.Permissions.CanRead = new List <Guid>(); input.Permissions.CanUpdate = new List <Guid>(); foreach (var role in recordPermissionsKeyValues) { var roleId = Guid.Empty; if (Guid.TryParse(role.Key, out Guid result)) { roleId = result; } if (roleId != Guid.Empty) { if (role.Values.Contains("read")) { input.Permissions.CanRead.Add(roleId); } if (role.Values.Contains("update")) { input.Permissions.CanUpdate.Add(roleId); } } } response = entMan.CreateField(ErpEntity.Id, input); if (!response.Success) { var exception = new ValidationException(response.Message); exception.Errors = response.Errors.MapTo <ValidationError>(); throw exception; } // because of https://github.com/aspnet/Mvc/issues/6711, i added TempDataExtensions int // WebVella.Erp.Web.Utils and using Put and Get<> instead of // TempData["ScreenMessage"] = new ScreenMessage() { Message = "Field created successfully" }; TempData.Put("ScreenMessage", new ScreenMessage() { Message = "Field created successfully" }); return(Redirect($"/sdk/objects/entity/r/{ErpEntity.Id}/rl/fields/l")); } catch (ValidationException ex) { Validation.Message = ex.Message; Validation.Errors = ex.Errors; } catch (Exception ex) { Validation.Message = ex.Message; Validation.Errors.Add(new ValidationError("", ex.Message, isSystem: true)); } HeaderToolbar.AddRange(AdminPageUtils.GetEntityAdminSubNav(ErpEntity, "fields")); ErpRequestContext.PageContext = PageContext; BeforeRender(); return(Page()); }
private static void Patch20180913(EntityManager entMan, EntityRelationManager relMan, RecordManager recMan, bool createSampleRecords = false) { #region << ***Update area*** Area name: projects >> { var patchObject = new EntityRecord(); patchObject["id"] = new Guid("205877a1-242c-41bf-a080-49ea01d4f519"); patchObject["attachments"] = "[{\"name\":null,\"label\":\"My Dashboard\",\"labelPlural\":null,\"iconName\":\"tachometer\",\"weight\":1,\"url\":\"/#/areas/projects/wv_project/dashboard\",\"view\":null,\"create\":null,\"list\":null},{\"name\":null,\"label\":\"Search\",\"url\":\"/#/areas/projects/wv_project/search\",\"labelPlural\":null,\"iconName\":\"search\",\"weight\":\"2\",\"view\":null,\"list\":null,\"create\":null},{\"name\":\"wv_task\",\"label\":\"Task\",\"labelPlural\":\"Tasks\",\"iconName\":\"tasks\",\"weight\":4,\"url\":null,\"view\":{\"name\":\"general\",\"label\":\"Details\"},\"create\":{\"name\":\"create\",\"label\":\"Create\"},\"list\":{\"name\":\"my_tasks\",\"label\":\"My open tasks\"}},{\"name\":\"wv_bug\",\"label\":\"Bug\",\"labelPlural\":\"Bugs\",\"iconName\":\"bug\",\"weight\":5,\"url\":null,\"view\":{\"name\":\"general\",\"label\":\"Details\"},\"create\":{\"name\":\"create\",\"label\":\"Create\"},\"list\":{\"name\":\"my_bugs\",\"label\":\"My open bugs\"}},{\"name\":\"wv_project\",\"label\":\"Project\",\"labelPlural\":\"Projects\",\"iconName\":\"product-hunt\",\"weight\":22,\"url\":null,\"view\":{\"name\":\"dashboard\",\"label\":\"Dashboard\"},\"create\":{\"name\":\"create\",\"label\":\"Create\"},\"list\":{\"name\":\"my_projects\",\"label\":\"My Projects\"}},{\"name\":null,\"label\":\"My Sprints\",\"url\":\"/#/areas/projects/wv_project/sprints\",\"labelPlural\":null,\"iconName\":\"fast-forward\",\"weight\":\"50\",\"view\":null,\"list\":null,\"create\":null}]"; var updateAreaResult = recMan.UpdateRecord("area", patchObject); if (!updateAreaResult.Success) { throw new Exception("System error 10060. Area update with name : projects. Message:" + updateAreaResult.Message); } } #endregion #region << ***Update field*** Entity: search Field Name: created_on >> { var currentEntity = entMan.ReadEntity(new Guid("171659b7-79a3-457e-844b-6c954b59420f")).Object; InputDateTimeField datetimeField = new InputDateTimeField(); datetimeField.Id = currentEntity.Fields.SingleOrDefault(x => x.Name == "created_on").Id; datetimeField.Name = "created_on"; datetimeField.Label = "Created On"; datetimeField.PlaceholderText = ""; datetimeField.Description = ""; datetimeField.HelpText = ""; datetimeField.Required = false; datetimeField.Unique = false; datetimeField.Searchable = true; datetimeField.Auditable = false; datetimeField.System = true; datetimeField.DefaultValue = null; datetimeField.Format = "dd MMM yyyy HH:mm"; datetimeField.UseCurrentTimeAsDefaultValue = true; datetimeField.EnableSecurity = false; datetimeField.Permissions = new FieldPermissions(); datetimeField.Permissions.CanRead = new List <Guid>(); datetimeField.Permissions.CanUpdate = new List <Guid>(); //READ //UPDATE { var response = entMan.UpdateField(new Guid("171659b7-79a3-457e-844b-6c954b59420f"), datetimeField); if (!response.Success) { throw new Exception("System error 10060. Entity: search Field: created_on Message:" + response.Message); } } } #endregion #region << ***Update field*** Entity: search Field Name: index >> { var currentEntity = entMan.ReadEntity(new Guid("171659b7-79a3-457e-844b-6c954b59420f")).Object; InputTextField textboxField = new InputTextField(); textboxField.Id = currentEntity.Fields.SingleOrDefault(x => x.Name == "index").Id; textboxField.Name = "index"; textboxField.Label = "Index"; textboxField.PlaceholderText = ""; textboxField.Description = ""; textboxField.HelpText = ""; textboxField.Required = true; textboxField.Unique = false; textboxField.Searchable = false; textboxField.Auditable = false; textboxField.System = true; textboxField.DefaultValue = "ddddd"; textboxField.MaxLength = null; textboxField.EnableSecurity = false; textboxField.Permissions = new FieldPermissions(); textboxField.Permissions.CanRead = new List <Guid>(); textboxField.Permissions.CanUpdate = new List <Guid>(); //READ //UPDATE { var response = entMan.UpdateField(new Guid("171659b7-79a3-457e-844b-6c954b59420f"), textboxField); if (!response.Success) { throw new Exception("System error 10060. Entity: search Field: index Message:" + response.Message); } } } #endregion }
private static void Patch20180912(EntityManager entMan, EntityRelationManager relMan, RecordManager recMan, bool createSampleRecords = false) { #region << ***Create field*** Entity: wv_bug Field Name: indexed_on >> { InputDateTimeField datetimeField = new InputDateTimeField(); datetimeField.Id = new Guid("3fa55ffc-eb9a-4fd1-8570-03e861ae043f"); datetimeField.Name = "indexed_on"; datetimeField.Label = "Indexed On"; datetimeField.PlaceholderText = ""; datetimeField.Description = ""; datetimeField.HelpText = ""; datetimeField.Required = false; datetimeField.Unique = false; datetimeField.Searchable = true; datetimeField.Auditable = false; datetimeField.System = true; datetimeField.DefaultValue = null; datetimeField.Format = "yyyy-MMM-dd HH:mm"; datetimeField.UseCurrentTimeAsDefaultValue = false; datetimeField.EnableSecurity = false; datetimeField.Permissions = new FieldPermissions(); datetimeField.Permissions.CanRead = new List <Guid>(); datetimeField.Permissions.CanUpdate = new List <Guid>(); //READ //UPDATE { var response = entMan.CreateField(new Guid("c11655fa-e4a3-4c2b-8f1e-0a6d87cfd20c"), datetimeField, false); if (!response.Success) { throw new Exception("System error 10060. Entity: wv_bug Field: indexed_on Message:" + response.Message); } } } #endregion #region << ***Create field*** Entity: wv_task Field Name: indexed_on >> { InputDateTimeField datetimeField = new InputDateTimeField(); datetimeField.Id = new Guid("2a28b090-433d-432b-9944-b00f6a5dbd3c"); datetimeField.Name = "indexed_on"; datetimeField.Label = "Indexed On"; datetimeField.PlaceholderText = ""; datetimeField.Description = ""; datetimeField.HelpText = ""; datetimeField.Required = false; datetimeField.Unique = false; datetimeField.Searchable = true; datetimeField.Auditable = false; datetimeField.System = true; datetimeField.DefaultValue = null; datetimeField.Format = "yyyy-MMM-dd HH:mm"; datetimeField.UseCurrentTimeAsDefaultValue = false; datetimeField.EnableSecurity = false; datetimeField.Permissions = new FieldPermissions(); datetimeField.Permissions.CanRead = new List <Guid>(); datetimeField.Permissions.CanUpdate = new List <Guid>(); //READ //UPDATE { var response = entMan.CreateField(new Guid("65acced0-1650-4ff0-bbff-9937c382cd89"), datetimeField, false); if (!response.Success) { throw new Exception("System error 10060. Entity: wv_task Field: indexed_on Message:" + response.Message); } } } #endregion #region << ***Create field*** Entity: wv_project_activity Field Name: user_id >> { InputGuidField guidField = new InputGuidField(); guidField.Id = new Guid("6819bbbc-65f8-4664-aecd-a8997d130cdb"); guidField.Name = "user_id"; guidField.Label = "User Id"; guidField.PlaceholderText = ""; guidField.Description = ""; guidField.HelpText = ""; guidField.Required = false; guidField.Unique = false; guidField.Searchable = true; guidField.Auditable = false; guidField.System = true; guidField.DefaultValue = null; guidField.GenerateNewId = false; guidField.EnableSecurity = false; guidField.Permissions = new FieldPermissions(); guidField.Permissions.CanRead = new List <Guid>(); guidField.Permissions.CanUpdate = new List <Guid>(); //READ //UPDATE { var response = entMan.CreateField(new Guid("145a489b-4dfc-4639-b473-2dedccb93ce0"), guidField, false); if (!response.Success) { throw new Exception("System error 10060. Entity: wv_project_activity Field: user_id Message:" + response.Message); } } } #endregion #region << ***Create entity*** Entity name: search >> { #region << entity >> { var entity = new InputEntity(); var systemFieldIdDictionary = new Dictionary <string, Guid>(); systemFieldIdDictionary["id"] = new Guid("a28b6c82-5ca3-4b2d-95f9-967501b0c619"); systemFieldIdDictionary["created_on"] = new Guid("234f44fa-512a-445e-a693-284e23ada9d8"); systemFieldIdDictionary["created_by"] = new Guid("b669d361-b1cc-4d89-87b7-c8ef661a82cd"); systemFieldIdDictionary["last_modified_on"] = new Guid("df59fde6-9367-4acd-b0a3-1880dba2cfea"); systemFieldIdDictionary["last_modified_by"] = new Guid("4ba95b2e-01f0-4b9b-b1be-6e6ed73351c7"); systemFieldIdDictionary["user_search_created_by"] = new Guid("f7f07ebd-1d26-4fe4-95f3-114d2322ce74"); systemFieldIdDictionary["user_search_modified_by"] = new Guid("277fbd26-dce9-4942-af50-9ccd58d810f1"); entity.Id = new Guid("171659b7-79a3-457e-844b-6c954b59420f"); entity.Name = "search"; entity.Label = "Search"; entity.LabelPlural = "Search"; entity.System = true; entity.IconName = "search"; entity.Weight = (decimal)10.0; entity.RecordPermissions = new RecordPermissions(); entity.RecordPermissions.CanCreate = new List <Guid>(); entity.RecordPermissions.CanRead = new List <Guid>(); entity.RecordPermissions.CanUpdate = new List <Guid>(); entity.RecordPermissions.CanDelete = new List <Guid>(); //Create entity.RecordPermissions.CanCreate.Add(new Guid("bdc56420-caf0-4030-8a0e-d264938e0cda")); entity.RecordPermissions.CanCreate.Add(new Guid("f16ec6db-626d-4c27-8de0-3e7ce542c55f")); //READ entity.RecordPermissions.CanRead.Add(new Guid("bdc56420-caf0-4030-8a0e-d264938e0cda")); entity.RecordPermissions.CanRead.Add(new Guid("f16ec6db-626d-4c27-8de0-3e7ce542c55f")); //UPDATE entity.RecordPermissions.CanUpdate.Add(new Guid("bdc56420-caf0-4030-8a0e-d264938e0cda")); entity.RecordPermissions.CanUpdate.Add(new Guid("f16ec6db-626d-4c27-8de0-3e7ce542c55f")); //DELETE entity.RecordPermissions.CanDelete.Add(new Guid("bdc56420-caf0-4030-8a0e-d264938e0cda")); entity.RecordPermissions.CanDelete.Add(new Guid("f16ec6db-626d-4c27-8de0-3e7ce542c55f")); { var response = entMan.CreateEntity(entity, false, false, systemFieldIdDictionary); if (!response.Success) { throw new Exception("System error 10050. Entity: search creation Message: " + response.Message); } } } #endregion } #endregion #region << ***Create field*** Entity: search Field Name: item_id >> { InputGuidField guidField = new InputGuidField(); guidField.Id = new Guid("99379d7b-defe-4e62-b9ee-b32f79d9429e"); guidField.Name = "item_id"; guidField.Label = "Item ID"; guidField.PlaceholderText = ""; guidField.Description = ""; guidField.HelpText = ""; guidField.Required = true; guidField.Unique = true; guidField.Searchable = true; guidField.Auditable = false; guidField.System = true; guidField.DefaultValue = Guid.Parse("00000000-0000-0000-0000-000000000000"); guidField.GenerateNewId = true; guidField.EnableSecurity = false; guidField.Permissions = new FieldPermissions(); guidField.Permissions.CanRead = new List <Guid>(); guidField.Permissions.CanUpdate = new List <Guid>(); //READ //UPDATE { var response = entMan.CreateField(new Guid("171659b7-79a3-457e-844b-6c954b59420f"), guidField, false); if (!response.Success) { throw new Exception("System error 10060. Entity: search Field: item_id Message:" + response.Message); } } } #endregion #region << ***Create field*** Entity: search Field Name: entity >> { InputTextField textboxField = new InputTextField(); textboxField.Id = new Guid("c5ba7772-db1c-407f-841d-36ca15abbe69"); textboxField.Name = "entity"; textboxField.Label = "Entity"; textboxField.PlaceholderText = ""; textboxField.Description = ""; textboxField.HelpText = ""; textboxField.Required = true; textboxField.Unique = false; textboxField.Searchable = true; textboxField.Auditable = false; textboxField.System = true; textboxField.DefaultValue = "entity"; textboxField.MaxLength = null; textboxField.EnableSecurity = false; textboxField.Permissions = new FieldPermissions(); textboxField.Permissions.CanRead = new List <Guid>(); textboxField.Permissions.CanUpdate = new List <Guid>(); //READ //UPDATE { var response = entMan.CreateField(new Guid("171659b7-79a3-457e-844b-6c954b59420f"), textboxField, false); if (!response.Success) { throw new Exception("System error 10060. Entity: search Field: entity Message:" + response.Message); } } } #endregion #region << ***Create field*** Entity: search Field Name: index >> { InputTextField textboxField = new InputTextField(); textboxField.Id = new Guid("5ef4a0e0-3e47-4e22-8ae4-fb25207ed7cf"); textboxField.Name = "index"; textboxField.Label = "Index"; textboxField.PlaceholderText = ""; textboxField.Description = ""; textboxField.HelpText = ""; textboxField.Required = true; textboxField.Unique = false; textboxField.Searchable = true; textboxField.Auditable = false; textboxField.System = true; textboxField.DefaultValue = "ddddd"; textboxField.MaxLength = null; textboxField.EnableSecurity = false; textboxField.Permissions = new FieldPermissions(); textboxField.Permissions.CanRead = new List <Guid>(); textboxField.Permissions.CanUpdate = new List <Guid>(); //READ //UPDATE { var response = entMan.CreateField(new Guid("171659b7-79a3-457e-844b-6c954b59420f"), textboxField, false); if (!response.Success) { throw new Exception("System error 10060. Entity: search Field: index Message:" + response.Message); } } } #endregion #region << ***Create field*** Entity: search Field Name: snippet >> { InputTextField textboxField = new InputTextField(); textboxField.Id = new Guid("c43dc119-aebe-4114-820d-6d888cda115c"); textboxField.Name = "snippet"; textboxField.Label = "Snippet"; textboxField.PlaceholderText = ""; textboxField.Description = ""; textboxField.HelpText = ""; textboxField.Required = true; textboxField.Unique = false; textboxField.Searchable = false; textboxField.Auditable = false; textboxField.System = true; textboxField.DefaultValue = "search snippet"; textboxField.MaxLength = null; textboxField.EnableSecurity = false; textboxField.Permissions = new FieldPermissions(); textboxField.Permissions.CanRead = new List <Guid>(); textboxField.Permissions.CanUpdate = new List <Guid>(); //READ //UPDATE { var response = entMan.CreateField(new Guid("171659b7-79a3-457e-844b-6c954b59420f"), textboxField, false); if (!response.Success) { throw new Exception("System error 10060. Entity: search Field: snippet Message:" + response.Message); } } } #endregion #region << ***Create field*** Entity: search Field Name: url >> { InputUrlField urlField = new InputUrlField(); urlField.Id = new Guid("e0324495-06f3-4c03-aea0-4f1ef6357ba4"); urlField.Name = "url"; urlField.Label = "Url"; urlField.PlaceholderText = ""; urlField.Description = ""; urlField.HelpText = ""; urlField.Required = true; urlField.Unique = false; urlField.Searchable = false; urlField.Auditable = false; urlField.System = true; urlField.DefaultValue = "/"; urlField.MaxLength = null; urlField.OpenTargetInNewWindow = false; urlField.EnableSecurity = false; urlField.Permissions = new FieldPermissions(); urlField.Permissions.CanRead = new List <Guid>(); urlField.Permissions.CanUpdate = new List <Guid>(); //READ //UPDATE { var response = entMan.CreateField(new Guid("171659b7-79a3-457e-844b-6c954b59420f"), urlField, false); if (!response.Success) { throw new Exception("System error 10060. Entity: search Field: url Message:" + response.Message); } } } #endregion #region << ***Create field*** Entity: search Field Name: title >> { InputTextField textboxField = new InputTextField(); textboxField.Id = new Guid("53370748-600d-446e-8995-6bb02785642a"); textboxField.Name = "title"; textboxField.Label = "Title"; textboxField.PlaceholderText = ""; textboxField.Description = ""; textboxField.HelpText = ""; textboxField.Required = true; textboxField.Unique = false; textboxField.Searchable = false; textboxField.Auditable = false; textboxField.System = true; textboxField.DefaultValue = "Search Title"; textboxField.MaxLength = null; textboxField.EnableSecurity = false; textboxField.Permissions = new FieldPermissions(); textboxField.Permissions.CanRead = new List <Guid>(); textboxField.Permissions.CanUpdate = new List <Guid>(); //READ //UPDATE { var response = entMan.CreateField(new Guid("171659b7-79a3-457e-844b-6c954b59420f"), textboxField, false); if (!response.Success) { throw new Exception("System error 10060. Entity: search Field: title Message:" + response.Message); } } } #endregion #region << ***Create field*** Entity: search Field Name: project_id >> { InputGuidField guidField = new InputGuidField(); guidField.Id = new Guid("5b24518d-4dcc-46de-b2d6-d7947dbcceee"); guidField.Name = "project_id"; guidField.Label = "Project ID"; guidField.PlaceholderText = ""; guidField.Description = ""; guidField.HelpText = ""; guidField.Required = true; guidField.Unique = false; guidField.Searchable = true; guidField.Auditable = false; guidField.System = true; guidField.DefaultValue = Guid.Parse("00000000-0000-0000-0000-000000000000"); guidField.GenerateNewId = false; guidField.EnableSecurity = false; guidField.Permissions = new FieldPermissions(); guidField.Permissions.CanRead = new List <Guid>(); guidField.Permissions.CanUpdate = new List <Guid>(); //READ //UPDATE { var response = entMan.CreateField(new Guid("171659b7-79a3-457e-844b-6c954b59420f"), guidField, false); if (!response.Success) { throw new Exception("System error 10060. Entity: search Field: project_id Message:" + response.Message); } } } #endregion #region << View Entity: wv_project name: search >> { var createViewEntity = entMan.ReadEntity(new Guid("7821ece9-42ce-470b-84d4-afc9eb35aa32")).Object; var createViewInput = new InputRecordView(); #region << details >> createViewInput.Id = new Guid("2010d57a-4a01-48e6-9a75-53ae63af9110"); createViewInput.Type = "General"; createViewInput.Name = "search"; createViewInput.Label = "search"; createViewInput.Title = "[{code}] {name}"; createViewInput.Default = false; createViewInput.System = true; createViewInput.Weight = Decimal.Parse("10"); createViewInput.CssClass = null; createViewInput.IconName = "tachometer"; createViewInput.DynamicHtmlTemplate = "/plugins/webvella-projects/templates/search.html"; createViewInput.DataSourceUrl = null; createViewInput.ServiceCode = null; #endregion #region << regions >> createViewInput.Regions = new List <InputRecordViewRegion>(); #region << Region: header >> { var viewRegion = new InputRecordViewRegion(); viewRegion.Name = "header"; viewRegion.Label = "Header"; viewRegion.Render = true; viewRegion.Weight = Decimal.Parse("1"); viewRegion.CssClass = ""; viewRegion.Sections = new List <InputRecordViewSection>(); //Save region createViewInput.Regions.Add(viewRegion); } #endregion #endregion #region << Relation options >> { createViewInput.RelationOptions = new List <EntityRelationOptionsItem>(); } #endregion #region << Action items >> { createViewInput.ActionItems = new List <ActionItem>(); #region << action item: wv_record_delete >> { var actionItem = new ActionItem(); actionItem.Name = "wv_record_delete"; actionItem.Menu = "page-title-dropdown"; actionItem.Weight = Decimal.Parse("1"); actionItem.Template = @"<a href=""javascript:void(0)"" confirmed-click=""ngCtrl.deleteRecord(ngCtrl)"" ng-confirm-click=""Are you sure?"" ng-if=""::ngCtrl.userHasRecordPermissions('canDelete')""> <i class=""fa fa-trash go-red""></i> Delete Record </a>" ; createViewInput.ActionItems.Add(actionItem); } #endregion #region << action item: wv_back_button >> { var actionItem = new ActionItem(); actionItem.Name = "wv_back_button"; actionItem.Menu = "sidebar-top"; actionItem.Weight = Decimal.Parse("1"); actionItem.Template = @"<a class=""back clearfix"" href=""javascript:void(0)"" ng-click=""sidebarData.goBack()""><i class=""fa fa-fw fa-arrow-left""></i> <span class=""text"">Back</span></a>"; createViewInput.ActionItems.Add(actionItem); } #endregion } #endregion #region << Sidebar >> createViewInput.Sidebar = new InputRecordViewSidebar(); createViewInput.Sidebar.CssClass = ""; createViewInput.Sidebar.Render = true; createViewInput.Sidebar.Items = new List <InputRecordViewSidebarItemBase>(); #region << list from relation: project_tasks >> { var viewItemFromRelation = new InputRecordViewSidebarRelationListItem(); viewItemFromRelation.EntityId = new Guid("65acced0-1650-4ff0-bbff-9937c382cd89"); viewItemFromRelation.EntityName = "wv_task"; viewItemFromRelation.ListId = new Guid("44f8ed83-b7e8-4223-b02e-b5e35ed4bcc1"); viewItemFromRelation.ListName = "project_tasks"; viewItemFromRelation.FieldLabel = "Tasks"; viewItemFromRelation.FieldPlaceholder = ""; viewItemFromRelation.FieldHelpText = ""; viewItemFromRelation.FieldRequired = false; viewItemFromRelation.FieldManageView = "general"; viewItemFromRelation.FieldLookupList = "lookup"; viewItemFromRelation.RelationId = new Guid("1f860b8c-7fa1-40fa-874f-19c2b5309817"); viewItemFromRelation.RelationName = "project_1_n_task"; viewItemFromRelation.Type = "listFromRelation"; createViewInput.Sidebar.Items.Add(viewItemFromRelation); } #endregion #region << list from relation: project_milestones >> { var viewItemFromRelation = new InputRecordViewSidebarRelationListItem(); viewItemFromRelation.EntityId = new Guid("d691b634-016c-46ef-8ba8-8c3328797497"); viewItemFromRelation.EntityName = "wv_milestone"; viewItemFromRelation.ListId = new Guid("92b40989-c3a2-4a06-869a-789fba54e733"); viewItemFromRelation.ListName = "project_milestones"; viewItemFromRelation.FieldLabel = "Milestones"; viewItemFromRelation.FieldPlaceholder = ""; viewItemFromRelation.FieldHelpText = ""; viewItemFromRelation.FieldRequired = false; viewItemFromRelation.FieldManageView = "general"; viewItemFromRelation.FieldLookupList = "lookup"; viewItemFromRelation.RelationId = new Guid("0c446f98-eec2-40c1-9d66-8a3c2a2498e9"); viewItemFromRelation.RelationName = "project_1_n_milestone"; viewItemFromRelation.Type = "listFromRelation"; createViewInput.Sidebar.Items.Add(viewItemFromRelation); } #endregion #region << list from relation: project_bugs >> { var viewItemFromRelation = new InputRecordViewSidebarRelationListItem(); viewItemFromRelation.EntityId = new Guid("c11655fa-e4a3-4c2b-8f1e-0a6d87cfd20c"); viewItemFromRelation.EntityName = "wv_bug"; viewItemFromRelation.ListId = new Guid("3b2ebe34-1d02-448a-9616-5b62538fe2c7"); viewItemFromRelation.ListName = "project_bugs"; viewItemFromRelation.FieldLabel = "Bugs"; viewItemFromRelation.FieldPlaceholder = ""; viewItemFromRelation.FieldHelpText = ""; viewItemFromRelation.FieldRequired = false; viewItemFromRelation.FieldManageView = "general"; viewItemFromRelation.FieldLookupList = "lookup"; viewItemFromRelation.RelationId = new Guid("d94f100c-024c-47e7-af32-d67a49be2b6c"); viewItemFromRelation.RelationName = "project_1_n_bug"; viewItemFromRelation.Type = "listFromRelation"; createViewInput.Sidebar.Items.Add(viewItemFromRelation); } #endregion #region << View: general >> { var viewItem = new InputRecordViewSidebarViewItem(); viewItem.EntityId = new Guid("7821ece9-42ce-470b-84d4-afc9eb35aa32"); viewItem.EntityName = "wv_project"; viewItem.ViewId = new Guid("211f028b-4e8e-418f-9c0e-78109f0839fc"); viewItem.ViewName = "general"; viewItem.Type = "view"; createViewInput.Sidebar.Items.Add(viewItem); } #endregion #endregion { var response = entMan.CreateRecordView(new Guid("7821ece9-42ce-470b-84d4-afc9eb35aa32"), createViewInput); if (!response.Success) { throw new Exception("System error 10060. Entity: wv_project Updated view: search Message:" + response.Message); } } } #endregion }
private static void Patch20201221(EntityManager entMan, EntityRelationManager relMan, RecordManager recMan) { #region << ***Update entity*** Entity name: role >> { var updateObject = new InputEntity(); updateObject.Id = new Guid("c4541fee-fbb6-4661-929e-1724adec285a"); updateObject.Name = "role"; updateObject.Label = "Role"; updateObject.LabelPlural = "Roles"; updateObject.System = true; updateObject.IconName = "fa fa-key"; updateObject.Color = "#f44336"; updateObject.RecordScreenIdField = null; updateObject.RecordPermissions = new RecordPermissions(); updateObject.RecordPermissions.CanRead = new List <Guid>(); updateObject.RecordPermissions.CanCreate = new List <Guid>(); updateObject.RecordPermissions.CanUpdate = new List <Guid>(); updateObject.RecordPermissions.CanDelete = new List <Guid>(); updateObject.RecordPermissions.CanRead.Add(new Guid("987148b1-afa8-4b33-8616-55861e5fd065")); updateObject.RecordPermissions.CanRead.Add(new Guid("f16ec6db-626d-4c27-8de0-3e7ce542c55f")); updateObject.RecordPermissions.CanRead.Add(new Guid("bdc56420-caf0-4030-8a0e-d264938e0cda")); updateObject.RecordPermissions.CanCreate.Add(new Guid("987148b1-afa8-4b33-8616-55861e5fd065")); updateObject.RecordPermissions.CanCreate.Add(new Guid("bdc56420-caf0-4030-8a0e-d264938e0cda")); updateObject.RecordPermissions.CanUpdate.Add(new Guid("bdc56420-caf0-4030-8a0e-d264938e0cda")); updateObject.RecordPermissions.CanDelete.Add(new Guid("bdc56420-caf0-4030-8a0e-d264938e0cda")); var updateEntityResult = entMan.UpdateEntity(updateObject); if (!updateEntityResult.Success) { throw new Exception("System error 10060. Entity update with name : role. Message:" + updateEntityResult.Message); } } #endregion #region << ***Update entity*** Entity name: user >> { var updateObject = new InputEntity(); updateObject.Id = new Guid("b9cebc3b-6443-452a-8e34-b311a73dcc8b"); updateObject.Name = "user"; updateObject.Label = "User"; updateObject.LabelPlural = "Users"; updateObject.System = true; updateObject.IconName = "fa fa-user"; updateObject.Color = "#f44336"; updateObject.RecordScreenIdField = null; updateObject.RecordPermissions = new RecordPermissions(); updateObject.RecordPermissions.CanRead = new List <Guid>(); updateObject.RecordPermissions.CanCreate = new List <Guid>(); updateObject.RecordPermissions.CanUpdate = new List <Guid>(); updateObject.RecordPermissions.CanDelete = new List <Guid>(); updateObject.RecordPermissions.CanRead.Add(new Guid("987148b1-afa8-4b33-8616-55861e5fd065")); updateObject.RecordPermissions.CanRead.Add(new Guid("f16ec6db-626d-4c27-8de0-3e7ce542c55f")); updateObject.RecordPermissions.CanRead.Add(new Guid("bdc56420-caf0-4030-8a0e-d264938e0cda")); updateObject.RecordPermissions.CanCreate.Add(new Guid("987148b1-afa8-4b33-8616-55861e5fd065")); updateObject.RecordPermissions.CanCreate.Add(new Guid("bdc56420-caf0-4030-8a0e-d264938e0cda")); updateObject.RecordPermissions.CanUpdate.Add(new Guid("bdc56420-caf0-4030-8a0e-d264938e0cda")); updateObject.RecordPermissions.CanDelete.Add(new Guid("bdc56420-caf0-4030-8a0e-d264938e0cda")); var updateEntityResult = entMan.UpdateEntity(updateObject); if (!updateEntityResult.Success) { throw new Exception("System error 10060. Entity update with name : user. Message:" + updateEntityResult.Message); } } #endregion #region << ***Update entity*** Entity name: user_file >> { var updateObject = new InputEntity(); updateObject.Id = new Guid("5c666c54-9e76-4327-ac7a-55851037810c"); updateObject.Name = "user_file"; updateObject.Label = "User File"; updateObject.LabelPlural = "User Files"; updateObject.System = true; updateObject.IconName = "fa fa-file"; updateObject.Color = "#f44336"; updateObject.RecordScreenIdField = null; updateObject.RecordPermissions = new RecordPermissions(); updateObject.RecordPermissions.CanRead = new List <Guid>(); updateObject.RecordPermissions.CanCreate = new List <Guid>(); updateObject.RecordPermissions.CanUpdate = new List <Guid>(); updateObject.RecordPermissions.CanDelete = new List <Guid>(); updateObject.RecordPermissions.CanRead.Add(new Guid("f16ec6db-626d-4c27-8de0-3e7ce542c55f")); updateObject.RecordPermissions.CanRead.Add(new Guid("bdc56420-caf0-4030-8a0e-d264938e0cda")); updateObject.RecordPermissions.CanCreate.Add(new Guid("f16ec6db-626d-4c27-8de0-3e7ce542c55f")); updateObject.RecordPermissions.CanCreate.Add(new Guid("bdc56420-caf0-4030-8a0e-d264938e0cda")); updateObject.RecordPermissions.CanUpdate.Add(new Guid("f16ec6db-626d-4c27-8de0-3e7ce542c55f")); updateObject.RecordPermissions.CanUpdate.Add(new Guid("bdc56420-caf0-4030-8a0e-d264938e0cda")); updateObject.RecordPermissions.CanDelete.Add(new Guid("f16ec6db-626d-4c27-8de0-3e7ce542c55f")); updateObject.RecordPermissions.CanDelete.Add(new Guid("bdc56420-caf0-4030-8a0e-d264938e0cda")); var updateEntityResult = entMan.UpdateEntity(updateObject); if (!updateEntityResult.Success) { throw new Exception("System error 10060. Entity update with name : user_file. Message:" + updateEntityResult.Message); } } #endregion #region << ***Update field*** Entity: case Field Name: created_on >> { var currentEntity = entMan.ReadEntity(new Guid("0ebb3981-7443-45c8-ab38-db0709daf58c")).Object; InputDateTimeField datetimeField = new InputDateTimeField(); datetimeField.Id = currentEntity.Fields.SingleOrDefault(x => x.Name == "created_on").Id; datetimeField.Name = "created_on"; datetimeField.Label = "Created on"; datetimeField.PlaceholderText = null; datetimeField.Description = null; datetimeField.HelpText = null; datetimeField.Required = true; datetimeField.Unique = false; datetimeField.Searchable = false; datetimeField.Auditable = false; datetimeField.System = true; try { datetimeField.DefaultValue = DateTime.Parse("12/31/1999 10:00:00 PM"); } catch { datetimeField.DefaultValue = DateTime.Parse("12/31/1999 10:00:00 PM", new CultureInfo("en-US")); } datetimeField.Format = "yyyy-MMM-dd HH:mm"; datetimeField.UseCurrentTimeAsDefaultValue = true; datetimeField.EnableSecurity = false; datetimeField.Permissions = new FieldPermissions(); datetimeField.Permissions.CanRead = new List <Guid>(); datetimeField.Permissions.CanUpdate = new List <Guid>(); //READ //UPDATE { var response = entMan.UpdateField(new Guid("0ebb3981-7443-45c8-ab38-db0709daf58c"), datetimeField); if (!response.Success) { throw new Exception("System error 10060. Entity: case Field: created_on Message:" + response.Message); } } } #endregion }