Exemplo n.º 1
0
        public static JToken ParseValue(JObject JItem, ApiModuleDataValueViewModel item)
        {
            JToken result      = null;
            bool   isHaveValue = JItem.TryGetValue(item.Name, out JToken val);

            if (isHaveValue)
            {
                switch (item.DataType)
                {
                case MixDataType.Reference:
                    //string url = $"/api/v1/odata/en-us/related-attribute-set-data/mobile/parent/set/{Id}/{item.Field.ReferenceId}";
                    val["value"] = new JArray();
                    break;

                case MixDataType.Upload:
                    string fullUrl = val["value"].ToString().TrimStart('/');

                    fullUrl = string.IsNullOrEmpty(fullUrl) || fullUrl.IndexOf("http") >= 0
                            ? fullUrl
                            : $"{MixService.GetAppSetting<string>(MixAppSettingKeywords.Domain.TrimEnd('/'))}/{fullUrl.TrimStart('/')}";
                    val["value"] = fullUrl;
                    break;

                case MixDataType.DateTime:
                case MixDataType.Date:
                case MixDataType.Time:
                case MixDataType.Double:
                case MixDataType.Boolean:
                case MixDataType.Integer:
                case MixDataType.Custom:
                case MixDataType.Duration:
                case MixDataType.PhoneNumber:
                case MixDataType.Text:
                case MixDataType.Html:
                case MixDataType.MultilineText:
                case MixDataType.EmailAddress:
                case MixDataType.Password:
                case MixDataType.Url:
                case MixDataType.ImageUrl:
                case MixDataType.CreditCard:
                case MixDataType.PostalCode:
                case MixDataType.Color:
                case MixDataType.Icon:
                case MixDataType.VideoYoutube:
                case MixDataType.TuiEditor:
                default:
                    break;
                }
                result = val;
            }
            return(result);
        }
Exemplo n.º 2
0
        public static JToken ParseValue(JObject JItem, ApiModuleDataValueViewModel item)
        {
            V_0 = null;
            if (JItem.TryGetValue(item.get_Name(), ref V_1))
            {
                switch (item.get_DataType())
                {
                case 0:
                case 1:
                case 2:
                case 3:
                case 4:
                case 5:
                case 6:
                case 7:
                case 8:
                case 9:
                case 10:
                case 11:
                case 12:
                case 13:
                case 14:
                case 15:
                case 17:
                case 18:
                case 19:
                case 20:
                case 21:
                case 22:
                {
Label0:
                    V_0 = V_1;
                    break;
                }

                case 16:
                {
                    V_2 = V_1.get_Item("value").ToString().TrimStart('/');
                    if (V_2.IndexOf("http") >= 0)
                    {
                        stackVariable21 = V_2;
                    }
                    else
                    {
                        stackVariable21 = string.Concat(MixService.GetConfig <string>("Domain"), "/", V_2);
                    }
                    V_2 = stackVariable21;
                    V_1.set_Item("value", JToken.op_Implicit(V_2));
                    goto Label0;
                }

                case 23:
                {
                    V_1.set_Item("value", new JArray());
                    goto Label0;
                }

                default:
                {
                    goto Label0;
                }
                }
            }
            return(V_0);
        }
        public override void ExpandView(SiocCmsContext _context = null, IDbContextTransaction _transaction = null)
        {
            Cultures = CommonRepository.Instance.LoadCultures(Specificulture, _context, _transaction);

            var objValue = Value != null?JObject.Parse(Value) : new JObject();

            this.DataProperties = new List <ApiModuleDataValueViewModel>();
            Fields       = InfoModuleViewModel.Repository.GetSingleModel(m => m.Id == ModuleId && m.Specificulture == Specificulture, _context, _transaction).Data?.Fields;
            this.Columns = new List <ModuleFieldViewModel>();
            if (!string.IsNullOrEmpty(Fields))
            {
                JArray arrField = JArray.Parse(Fields);

                foreach (var field in arrField)
                {
                    ModuleFieldViewModel thisField = new ModuleFieldViewModel()
                    {
                        Name       = CommonHelper.ParseJsonPropertyName(field["name"].ToString()),
                        Title      = field["title"]?.ToString(),
                        Priority   = field["priority"] != null ? field["priority"].Value <int>() : 0,
                        DataType   = (SWCmsConstants.DataType)(int) field["dataType"],
                        Width      = field["width"] != null ? field["width"].Value <int>() : 3,
                        Options    = field["options"] != null ? field["options"].Value <JArray>() : new JArray(),
                        IsUnique   = field["isUnique"] != null ? field["isUnique"].Value <bool>() : false,
                        IsRequired = field["isRequired"] != null ? field["isRequired"].Value <bool>() : false,
                        IsSelect   = field["isSelect"] != null ? field["isSelect"].Value <bool>() : false,
                        IsGroupBy  = field["isGroupBy"] != null ? field["isGroupBy"].Value <bool>() : false,
                        IsDisplay  = field["isDisplay"] != null ? field["isDisplay"].Value <bool>() : true
                    };
                    this.Columns.Add(thisField);
                }
            }
            foreach (var col in Columns)
            {
                JProperty prop = objValue.Property(col.Name);
                if (prop == null)
                {
                    JObject val = new JObject
                    {
                        { "dataType", (int)col.DataType },
                        { "value", null }
                    };
                    prop = new JProperty(col.Name, val);
                }
                var dataVal = new ApiModuleDataValueViewModel()
                {
                    ModuleId   = ModuleId,
                    DataType   = (SWCmsConstants.DataType)col.DataType,
                    Name       = CommonHelper.ParseJsonPropertyName(prop.Name),
                    Title      = col.Title,
                    IsRequired = col.IsRequired,
                    IsUnique   = col.IsUnique,
                    IsSelect   = col.IsSelect,
                    IsGroupBy  = col.IsGroupBy,
                    Options    = col.Options,
                    Value      = prop.Value["value"].Value <string>()
                };

                this.DataProperties.Add(dataVal);
            }
        }