コード例 #1
0
        public async Task <ActionResult> Save(ClientConfigAttributeViewModel model)
        {
            using (ClientConfigAttributeServiceClient client = new ClientConfigAttributeServiceClient())
            {
                ClientConfigAttribute obj = new ClientConfigAttribute()
                {
                    Key = new ClientConfigAttributeKey()
                    {
                        ClientName    = model.ClientName,
                        AttributeName = model.AttributeName
                    },
                    Value    = model.Value,
                    Editor   = User.Identity.Name,
                    EditTime = DateTime.Now,
                };
                MethodReturnResult rst = await client.AddAsync(obj);

                if (rst.Code == 0)
                {
                    rst.Message = string.Format(FMMResources.StringResource.ClientConfigAttribute_Save_Success
                                                , obj.Key);
                }
                return(Json(rst));
            }
        }
コード例 #2
0
        public override void WriteJson(JsonWriter writer, object value)
        {
            if (value != null)
            {
                bool           isControls = value is MapControls;
                PropertyInfo[] properties = value.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
                StringBuilder  sb         = new StringBuilder();
                foreach (PropertyInfo property in properties)
                {
                    ClientConfigAttribute attr = ClientConfig.GetClientConfigAttribute(property);

                    if (attr != null && property.PropertyType == typeof(bool))
                    {
                        object prValue      = property.GetValue(value, null);
                        object defaultValue = ReflectionUtils.GetDefaultValue(property);
                        if ((bool)prValue)
                        {
                            if (!isControls)
                            {
                                if (!(bool)defaultValue)
                                {
                                    sb.Append(string.Concat("'enable", property.Name, "',"));
                                }
                            }
                            else
                            {
                                sb.Append(string.Concat("'", property.Name, "',"));
                            }
                        }
                        else
                        {
                            if (!isControls)
                            {
                                if ((bool)defaultValue)
                                {
                                    sb.Append(string.Concat("'disable", property.Name, "',"));
                                }
                            }
                        }
                    }
                }

                if (sb.Length > 0)
                {
                    sb.Remove(sb.Length - 1, 1);
                    writer.WriteStartArray();
                    writer.WriteRaw(sb.ToString());
                    writer.WriteEndArray();
                    return;
                }
            }
            writer.WriteStartArray();
            writer.WriteEndArray();
        }