Пример #1
0
        public IEnumerable <SQLDynamicItem> GetDyncExpValue(DyncExp exp)
        {
            var dyncTable = _dynamicDataservices.GetDyncFormByCode(exp.Table);

            if (dyncTable == null)
            {
                throw new Exception($"不能找到code 为{exp.Table}的数据表");
            }
            return(_dynamicDataservices.GetDyncValueByDyncParam(dyncTable.Name, exp.FiledName, exp.Param));
        }
Пример #2
0
        private static void SetSourceValue(DyncField dyncField)
        {
            if (dyncField.Source == 0)
            {
                return;
            }

            if (dyncField.Source == 1 && dyncField.SourceValue.IsNullOrEmpty())
            {
                throw new Exception("url Param is null error");
            }

            var urlParam = dyncField.SourceValue.Split('=')[1];

            if (urlParam.IsNullOrEmpty())
            {
                throw new Exception("url urlParam is length number error");
            }

            var url = dyncField.SourceValue.Split('?')[0];

            if (url.IsNullOrEmpty())
            {
                throw new Exception("api url error");
            }

            var str = urlParam.Split('|');

            if (str.Length < 3)
            {
                throw new Exception("url Param is length number error");
            }

            var dyncExp = new DyncExp();

            if (str[0].IsNullOrEmpty())
            {
                throw new Exception("url table Param is error");
            }

            dyncExp.Table = str[0];
            if (str[1].IsNullOrEmpty())
            {
                throw new Exception("url FiledName Param is error");
            }

            dyncExp.FiledName = str[1];
            if (str[2].IsNotNullOrEmpty())
            {
                dyncExp.Param = str[2].Split(',').ToDictionary(t => t.Split(':')[0], x => x.Split(':')[1]);
            }

            var result = ApiProxy.Send(Common.Http.HttpMethod.POST, url, new StringContent(dyncExp.SerializeObject(), Encoding.UTF8));

            if (result.IsNullOrEmpty() || result == "null")
            {
                return;
            }

            dyncField.Itms = result.DeserializeObject <IEnumerable <SQLDynamicItem> >().Select(t =>
            {
                return(new DropdownModel()
                {
                    value = t.Value,
                    Checked = t.Value
                });
            });
        }