/// <summary> /// 修改属性值 /// </summary> /// <param name="entity"></param> /// <returns></returns> public virtual PropertyValueInfo UpdatePropertyValue(PropertyValueInfo entity) { if (string.IsNullOrEmpty(entity.ValueDescription.Content)) { throw new BizException(ResouceManager.GetMessageString("IM.Property", "PropertyValueName")); } if (entity.Priority < 0) { throw new BizException(ResouceManager.GetMessageString("IM.Property", "InValidPriority")); } //判断该属性下是否存在相同的属性值 if (IsExistsPropertyValueByPropertySysNo(entity.SysNo.Value, entity.PropertyInfo.SysNo.Value, entity.ValueDescription.Content)) { throw new BizException(ResouceManager.GetMessageString("IM.Property", "ExistsPropertyValueName")); } PropertyValueInfo oldEntity = new PropertyValueInfo(); oldEntity = propertyDA.GetPropertyValueByPropertyValueSysNo(entity.SysNo.Value); if (entity.ValueStatus == PropertyStatus.DeActive && oldEntity.ValueStatus == PropertyStatus.Active) { if (IsExistsProductPropertyValue(entity)) { throw new BizException(ResouceManager.GetMessageString("IM.Property", "PropertyValueChangeInvalid")); } } return(propertyDA.UpdatePropertyValue(entity)); }
/// <summary> /// 判断该属性值,是否已经有产品使用 /// 不能修改为无效,属性值已生成CommonSKU! /// </summary> /// <param name="entity"></param> /// <returns></returns> public bool IsExistsProductPropertyValue(PropertyValueInfo entity) { bool rtn = false; rtn = propertyDA.IsExistsProductPropertyValue(entity); return(rtn); }
/// <summary> /// 判断该属性值,是否已经有产品使用 /// 不能修改为无效,属性值已生成CommonSKU! /// </summary> /// <param name="entity"></param> /// <returns></returns> public bool IsExistsProductPropertyValue(PropertyValueInfo entity) { DataCommand dc = DataCommandManager.GetDataCommand("IsExistsProductPropertyValue"); dc.SetParameterValue("@SysNo", entity.SysNo.Value); if ((int)dc.ExecuteScalar() > 0) { return(true); } else { return(false); } }
public void PropertyContract_ShouldReturnUnchangedIfZeroProperties() { var idPropInfo = new PropertyValueInfo(typeof(MemberContractTestsClass).GetProperty(nameof(MemberContractTestsClass.Id))); var obj = new MemberContractTestsClass() { Id = 2001 }; var contract = new MemberContract("self", "http://baba.com/props/sven/{ds}", new KeyValuePair <string, IValueInfo> [0]); var token = contract.GetToken(obj); Assert.NotNull(token); Assert.True(token.Type.Equals(JTokenType.Property)); Assert.Equal("\"self\": \"http://baba.com/props/sven/{ds}\"", token.ToString()); }
/// <summary> /// 获取属性根据SysNo /// </summary> /// <param name="sysNo"></param> /// <param name="callback"></param> //public void GetPropertyBySysNo(int sysNo, EventHandler<RestClientEventArgs<PropertyInfo>> callback) //{ // string relativeUrl = string.Format("/IMService/Property/LoadPropertyBySysNo/{0}", sysNo); // restClient.Query<PropertyInfo>(relativeUrl, callback); //} private PropertyValueInfo CovertVMtoEntity(PropertyValueVM data) { PropertyValueInfo msg = new PropertyValueInfo(); msg.SysNo = data.SysNo; msg.PropertyInfo = new PropertyInfo() { SysNo = data.PropertySysNo }; msg.Priority = Convert.ToInt32(data.Priority); msg.ValueDescription = new LanguageContent(data.ValueDescription); msg.ValueStatus = data.Status == "有效" ? PropertyStatus.Active : PropertyStatus.DeActive; return(msg); }
/// <summary> /// 编辑属性值 /// </summary> /// <param name="entity"></param> /// <returns></returns> public PropertyValueInfo UpdatePropertyValue(PropertyValueInfo entity) { DataCommand dc = DataCommandManager.GetDataCommand("UpdatePropertyValue"); dc.SetParameterValue("@SysNo", entity.SysNo); dc.SetParameterValue("@PropertySysNo", entity.PropertyInfo.SysNo); dc.SetParameterValue("@ValueDescription", entity.ValueDescription.Content.Trim()); dc.SetParameterValue("@Priority", entity.Priority); dc.SetParameterValue("@LastEditUserSysNo", ServiceContext.Current.UserSysNo); dc.SetParameterValue("@IsActive", entity.ValueStatus); dc.SetParameterValue("@CompanyCode", "8601"); dc.ExecuteNonQuery(); return(entity); }
/// <summary> /// 创建属性值 /// </summary> /// <param name="entity"></param> /// <returns></returns> public virtual PropertyValueInfo CreatePropertyValue(PropertyValueInfo entity) { if (string.IsNullOrEmpty(entity.ValueDescription.Content)) { throw new BizException(ResouceManager.GetMessageString("IM.Property", "PropertyValueName")); } if (entity.Priority < 0) { throw new BizException(ResouceManager.GetMessageString("IM.Property", "InValidPriority")); } if (IsExistsPropertyValueByPropertySysNo(entity.SysNo.Value, entity.PropertyInfo.SysNo.Value, entity.ValueDescription.Content)) { throw new BizException(ResouceManager.GetMessageString("IM.Property", "ExistsPropertyValueName")); } return(propertyDA.CreatePropertyValue(entity)); }
/// <summary> /// 根据PropertySysNoList获取Property信息 /// </summary> /// <param name="sysNoList"></param> /// <returns></returns> public virtual Dictionary <int, List <PropertyValueInfo> > GetPropertyValueInfoByPropertySysNoList(List <int> sysNoList) { Dictionary <int, List <PropertyValueInfo> > result = new Dictionary <int, List <PropertyValueInfo> >(); string sysStr = sysNoList.Join(","); PropertyValueInfo valueEntity = new PropertyValueInfo(); List <PropertyValueInfo> valueList = propertyDA.GetPropertyValueInfoListByPropertySysNo(sysStr); if (valueList == null || valueList.Count == 0) { return(new Dictionary <int, List <PropertyValueInfo> >()); } List <int?> propertySysNoList = valueList.Select(p => p.PropertyInfo.SysNo).Distinct().ToList(); foreach (int item in propertySysNoList) { List <PropertyValueInfo> lists = valueList.Where(p => p.PropertyInfo.SysNo == item).ToList(); result.Add(item, lists); } return(result); }
private static CollectionArtifacts PopulateArtifactsProperties(IEnumerable <int> artifactIds, IReadOnlyList <ArtifactPropertyInfo> artifacts, IEnumerable <ProfileColumn> profileColumns) { var artifactDtos = new List <ArtifactDto>(); foreach (var id in artifactIds) { var artifactProperties = artifacts.Where(x => x.ArtifactId == id).ToList(); var propertyInfos = new List <PropertyValueInfo>(); int?itemTypeId = null; int?predefinedType = null; int?itemTypeIconId = null; var filledMultiValueProperties = new List <Tuple <int, int?, PropertyTypePredefined, PropertyPrimitiveType> >(); foreach (var artifactProperty in artifactProperties) { var propertyInfo = new PropertyValueInfo(); var propertyTypePredefined = (PropertyTypePredefined)artifactProperty.PropertyTypePredefined; var primitiveType = (PropertyPrimitiveType)artifactProperty.PrimitiveType; propertyInfo.PropertyTypeId = artifactProperty.PropertyTypeId; propertyInfo.Predefined = artifactProperty.PropertyTypePredefined; propertyInfo.IsRichText = artifactProperty.IsRichText ? true : (bool?)null; // Set null to ignore the property in final output. if (propertyTypePredefined == PropertyTypePredefined.ID) { itemTypeId = artifactProperty.ItemTypeId; predefinedType = artifactProperty.PrimitiveItemTypePredefined; itemTypeIconId = artifactProperty.ItemTypeIconId; } bool systemColumn = propertyTypePredefined != PropertyTypePredefined.CustomGroup; bool multiValue = primitiveType == PropertyPrimitiveType.Choice || primitiveType == PropertyPrimitiveType.User; propertyInfo.Value = systemColumn && !multiValue // Fill multi value properties below ? artifactProperty.PredefinedPropertyValue : primitiveType == PropertyPrimitiveType.Date ? artifactProperty.DateTimeValue?.ToString(CultureInfo.InvariantCulture) : primitiveType == PropertyPrimitiveType.Number ? artifactProperty.DecimalValue?.ToString(CultureInfo.InvariantCulture) : multiValue ? null // Fill multi value properties below : artifactProperty.IsRichText ? artifactProperty.HtmlTextValue : artifactProperty.FullTextValue; propertyInfo.Value = propertyTypePredefined == PropertyTypePredefined.ID ? artifactProperty.Prefix + propertyInfo.Value : propertyInfo.Value; var multiValueTuple = new Tuple <int, int?, PropertyTypePredefined, PropertyPrimitiveType>( artifactProperty.ArtifactId, artifactProperty.PropertyTypeId, (PropertyTypePredefined)artifactProperty.PropertyTypePredefined, (PropertyPrimitiveType)artifactProperty.PrimitiveType); if (!multiValue) { propertyInfos.Add(propertyInfo); } else if (!filledMultiValueProperties.Contains(multiValueTuple)) { var values = artifactProperties .Where(x => artifactProperty.PrimitiveType == x.PrimitiveType && artifactProperty.ArtifactId == x.ArtifactId && artifactProperty.PropertyTypeId == x.PropertyTypeId && artifactProperty.PropertyTypePredefined == x.PropertyTypePredefined) .Select(x => new { Value = systemColumn ? x.PredefinedPropertyValue : x.FullTextValue, x.ValueId // ValueId is necessary for deduplication }) .Distinct(); if (values.Count() > 1) { values = values .Select(x => new { Value = x.Value.Contains(ChoiceValueSeparator) ? ChoiceValueFrame + x.Value + ChoiceValueFrame : x.Value, x.ValueId }); } propertyInfo.Value = string.Join(ChoiceValueSeparator, values.Select(x => x.Value)); propertyInfos.Add(propertyInfo); filledMultiValueProperties.Add(multiValueTuple); } } artifactDtos.Add(new ArtifactDto { ArtifactId = id, ItemTypeId = itemTypeId, PredefinedType = predefinedType, ItemTypeIconId = itemTypeIconId, PropertyInfos = propertyInfos.OrderBy(x => x.PropertyTypeId) }); } return(new CollectionArtifacts { Items = artifactDtos, ArtifactListSettings = new ArtifactListSettings { Columns = profileColumns } }); }
public PropertyValueInfo UpdatePropertyValue(PropertyValueInfo request) { var entity = ObjectFactory <PropertyAppService> .Instance.UpdatePropertyValue(request); return(entity); }
/// <summary> /// 编辑属性值 /// </summary> /// <param name="entity"></param> /// <returns></returns> public virtual PropertyValueInfo UpdatePropertyValue(PropertyValueInfo entity) { var result = ObjectFactory <PropertyProcessor> .Instance.UpdatePropertyValue(entity); return(result); }