1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
| public virtual void LoadFromXml(string entityName, string attrName, XmlNode xmlNode) { var entityMetadata = EntityMetadataHelper.GetEntityMetadata(this.OrganizationServiceAdmin, entityName, LangId); if (entityMetadata == null) { throw new Exception($"entityMetadata is null,entityName:{entityName}"); }
AttributeMetadata attributeMetadata = null; if (Type != AttrTypes.MultiLookup) { attributeMetadata = EntityMetadataHelper.GetAttributeMetadata(entityMetadata, attrName); }
#region Label,如果配置文件有值,则优先取配置文件的值,否则使用CRM中的值 var label = PluginResourceHelper.GetResource(this.OrganizationServiceAdmin, LangId, $"{entityName}.{attrName}"); if (string.IsNullOrWhiteSpace(label)) { label = attributeMetadata?.DisplayName?.GetUserLocalizedLabel(LangId); } if (string.IsNullOrWhiteSpace(label)) { label = xmlNode.GetStringAttributeValue("label"); } this.Label = label; #endregion
#region Placeholder,先取翻译,没有就取配置文件,再没有就默认 var placeholder = PluginResourceHelper.GetResource(this.OrganizationServiceAdmin, LangId, $"{entityName}.{attrName}Placeholder"); if (string.IsNullOrWhiteSpace(placeholder)) { placeholder = xmlNode.GetStringAttributeValue("placeholder"); } if (string.IsNullOrWhiteSpace(placeholder)) { if (SelectInputTypes.Contains(this.Type)) { placeholder = string.Format(PluginResourceHelper.GetResource(this.OrganizationServiceAdmin, LangId, "common.genericSelectPlaceholder", "请选择{0}"), this.Label); } else { placeholder = string.Format(PluginResourceHelper.GetResource(this.OrganizationServiceAdmin, LangId, "common.genericInputPlaceholder", "请输入{0}"), this.Label); } } this.Placeholder = placeholder; #endregion
this.Disabled = xmlNode.GetBooleanAttributeValue("disabled"); this.OnChange = xmlNode.GetStringAttributeValue("onchange"); this.Readonly = xmlNode.GetBooleanAttributeValue("readonly"); this.ShowLabel = xmlNode.GetBooleanAttributeValue("showlabel", true); this.Visible = xmlNode.GetBooleanAttributeValue("visible", true);
if (xmlNode.HasAttribute("required")) { this.Required = xmlNode.GetBooleanAttributeValue("required"); } else { this.Required = attributeMetadata != null && attributeMetadata.IsRequired; } }
|