/// <summary>
        /// 设置数据源
        /// </summary>
        private void SetDataSource(string sql)
        {
            //var sql = obj.d0;
            sql = EventAssitant.FormatSql(sql, _currentIControl);
            var dicarray = _sqlController.ExcuteSqlWithReturn(sql).data;

            if (object.Equals(dicarray, null))
            {
                return;
            }
            //每次都清空然后添加到数据源中
            _currentDataSource = new List <Dictionary <string, string> >();
            _currentDataSource.AddRange(dicarray);
            //var dicarray = dicresult.Result.data;
            var listsource = DicArrayToListObject(dicarray);

            Binding binding = new Binding()
            {
                Source = listsource, IsAsync = true
            };

            binding.UpdateSourceTrigger = UpdateSourceTrigger.Explicit;
            mydatagridview.SetBinding(DataGrid.ItemsSourceProperty, binding);
            //mydatagridview.ItemsSource = listsource;
        }
        /// <summary>
        /// 获取行数
        /// </summary>
        /// <returns></returns>
        private int GetTotalRowCount()
        {
            string _rowCountSql = _CurrentCtObj.d14;

            _rowCountSql = EventAssitant.FormatSql(_rowCountSql, _currentIControl);
            if (!string.IsNullOrEmpty(_rowCountSql))
            {
                var result = _sqlController.ExcuteSqlWithReturn(_rowCountSql);
                if (!object.Equals(result.data, null) && result.data.Length > 0)
                {
                    int totalCount = CommonConverter.StringToInt(result.data[0].First().Value);
                    return(totalCount);
                }
            }
            return(0);
        }
        /// <summary>
        /// 设置主值
        /// </summary>
        /// <param name="value"></param>
        public void SetD0(object value)
        {
            listItems.Clear();
            if (object.Equals(value, null) || string.IsNullOrEmpty(value.ToString()))
            {
                return;
            }
            ControlDetailForPage currentObj = this.Tag as ControlDetailForPage;
            //获取页面ID数组,默认全都要设置所以这里不进行判断
            List <int> listPageId = JsonController.DeSerializeToClass <List <int> >(currentObj.d11);

            //判断是数组还是sql
            if (System.Text.RegularExpressions.Regex.IsMatch(value.ToString().Replace("\r\n", string.Empty), @".*\[.*\].*"))
            {
                List <string> listImage = JsonController.DeSerializeToClass <List <string> >(value.ToString());
                for (int i = 0; i < listPageId.Count; i++)
                {
                    listItems.Add(new FlipViewItem()
                    {
                        ImageUrl = listImage[i], pageId = listPageId[i]
                    });
                }
            }
            else
            {
                //sql处理
                SqlController cn = new SqlController();
                value = EventAssitant.FormatSql(value.ToString(), this);
                var returnDic = cn.ExcuteSqlWithReturn(value.ToString().Trim());
                var result    = returnDic.data;
                if (!object.Equals(result, null) && result.Length > 0)
                {
                    int index = 0;
                    foreach (Dictionary <string, string> dic in result)
                    {
                        listItems.Add(new FlipViewItem()
                        {
                            ImageUrl = dic[currentObj.d19], pageId = listPageId[index]
                        });
                        index++;
                    }
                }
            }
            MyFlipView.ItemsSource = null;
            MyFlipView.ItemsSource = listItems;
        }
        /// <summary>
        /// 缓存到本地
        /// </summary>
        /// <param name="value"></param>
        public void SetA2(object value)
        {
            //缓存的本地里面
            string valueStr = value.ToString().Trim();

            string[] valueArray = valueStr.Split('&');
            Dictionary <string, string> dicTemp = new Dictionary <string, string>();

            foreach (string str in valueArray)
            {
                dicTemp.Add(str.Split('=')[0], str.Split('=')[1]);
            }
            foreach (string key in dicTemp.Keys)
            {
                LocalCacher.AddCache(key, EventAssitant.FormatSql(dicTemp[key], this));
            }
        }
        /// <summary>
        /// 打开新的窗体
        /// </summary>
        /// <param name="inText"></param>
        /// <param name="isDialog"></param>
        private async void OpenPage(string inText, bool isDialog = false)
        {
            int pageId = CommonConverter.StringToInt(inText);

            if (pageId != -1)
            {
                OpenPageById(pageId, isDialog);
            }
            //接下来是有传值的方法,格式应该是类似(1236, text={1.d0}&type=animal)
            else
            {
                if (Regex.IsMatch(inText, @"\d+, *\w+=.*"))
                {
                    pageId = CommonConverter.StringToInt(inText.Split(',')[0].Trim());
                    string   parameters     = inText.Split(',')[1].Trim();
                    string[] parameterArray = parameters.Split('&');
                    Dictionary <string, string> dicParameter       = new Dictionary <string, string>();
                    Dictionary <string, string> dicParameterResult = new Dictionary <string, string>();
                    foreach (string str in parameterArray)
                    {
                        dicParameter.Add(str.Split('=')[0], str.Split('=')[1]);
                    }
                    foreach (string key in dicParameter.Keys)
                    {
                        dicParameterResult.Add(key, EventAssitant.FormatSql(dicParameter[key], this));
                    }
                    OpenPageById(pageId, isDialog, dicParameterResult);
                }
                else
                {
                    string pageid = EventAssitant.FormatSql(inText, this);
                    pageId = CommonConverter.StringToInt(pageid);
                    if (pageId != -1)
                    {
                        OpenPageById(pageId, isDialog);
                    }
                }
            }
        }
        /// <summary>
        /// 设置显示
        /// </summary>
        /// <param name="value"></param>
        public void SetD0(object value)
        {
            this.Items.Clear();
            _listValue.Clear();

            if (!object.Equals(value, null))
            {
                if (value is string)
                {
                    if (!string.IsNullOrEmpty(value.ToString()))
                    {
                        ControlDetailForPage currentObj = this.Tag as ControlDetailForPage;
                        //数组处理

                        if (System.Text.RegularExpressions.Regex.IsMatch(value.ToString().Replace("\r\n", string.Empty), @".*\[.*\].*"))
                        {
                            string[] array = new string[1];
                            try
                            {
                                array = JsonController.DeSerializeToClass <string[]>(value.ToString().Replace("\r\n", string.Empty));
                            }
                            catch
                            {
                                array = JsonController.DeSerializeToClass <string[]>(value.ToString());
                            }
                            this.ItemsSource = array;
                            if (System.Text.RegularExpressions.Regex.IsMatch(currentObj.d5.Trim().Replace("\r\n", string.Empty), @".*\[.*\].*"))
                            {
                                _listValue.AddRange(JsonController.DeSerializeToClass <string[]>(currentObj.d5.Trim()));
                            }
                        }
                        else
                        {
                            if (string.IsNullOrEmpty(currentObj.d19) || string.IsNullOrEmpty(currentObj.d20))
                            {
                                return;
                            }
                            //sql处理
                            SqlController cn = new SqlController();
                            value = EventAssitant.FormatSql(value.ToString(), this);
                            var returnDic = cn.ExcuteSqlWithReturn(value.ToString().Trim());
                            var result    = returnDic.data;
                            if (!object.Equals(result, null) && result.Length > 0)
                            {
                                foreach (Dictionary <string, string> dic in result)
                                {
                                    this.Items.Add(dic[currentObj.d20]);
                                    _listValue.Add(dic[currentObj.d19]);
                                }
                            }
                        }
                        if (this.Items.Count > 0)
                        {
                            this.SelectedIndex = 0;
                        }
                    }
                }
                else
                {
                    //这里应该是用于.语法调用处理的时候进行处理,就是传进来的
                }
            }
        }
        /// <summary>
        /// 相等的逻辑判断
        /// </summary>
        /// <param name="text"></param>
        private void CustomEquals(string text, string specialChar)
        {
            text = text.Trim();
            string rightValue = text.Substring(text.IndexOf(specialChar) + specialChar.Length).Trim();
            string leftValue  = text.Substring(0, text.IndexOf(specialChar)).Trim();

            string leftPart  = leftValue;
            string rightPart = rightValue;

            if (Regex.IsMatch(leftValue, @"[{].*[}]"))
            {
                leftPart = EventAssitant.FormatSql(leftPart, this);
            }
            if (Regex.IsMatch(rightValue, @"[{].*[}]"))
            {
                rightPart = EventAssitant.FormatSql(rightPart, this);
            }

            bool isSuccess = false;

            if ("''".Equals(rightPart))
            {
                rightPart = string.Empty;
            }
            switch (specialChar)
            {
            case _equalStr:
                isSuccess = dealWithEqual(leftPart, rightPart);
                break;

            case _inequalStr:
                isSuccess = dealWithInEqual(leftPart, rightPart);
                break;

            case _upperOrEqual:
                isSuccess = dealWithUpperAndEqual(leftPart, rightPart);
                break;

            case _lowerOrEqual:
                isSuccess = dealWithLowerAndEqual(leftPart, rightPart);
                break;

            case _upper:
                isSuccess = dealWithUpper(leftPart, rightPart);
                break;

            case _lower:
                isSuccess = dealWithLower(leftPart, rightPart);
                break;

            default:
                break;
            }
            if (isSuccess)
            {
                this.SetP9((this.Tag as ControlDetailForPage).p9);
            }
            else
            {
                this.SetP12((this.Tag as ControlDetailForPage).p12);
            }
        }
Esempio n. 8
0
        /// <summary>
        /// 主值
        /// </summary>
        /// <param name="text"></param>
        public void SetD0(object value)
        {
            checkListItems.Clear();
            MyListBox.ItemsSource = null;

            if (!object.Equals(value, null))
            {
                if (value is string)
                {
                    if (!string.IsNullOrEmpty(value.ToString()))
                    {
                        ControlDetailForPage currentObj = this.Tag as ControlDetailForPage;
                        //数组处理

                        if (System.Text.RegularExpressions.Regex.IsMatch(value.ToString().Replace("\r\n", string.Empty), @".*\[.*\].*"))
                        {
                            List <string> listArray = JsonController.DeSerializeToClass <List <string> >(value.ToString().Replace("\r\n", string.Empty));
                            //判断是否需要显示与值分开
                            if (!string.IsNullOrEmpty(currentObj.d11))
                            {
                                List <string> listValue = JsonController.DeSerializeToClass <List <string> >(currentObj.d11);
                                for (int i = 0; i < listArray.Count; i++)
                                {
                                    checkListItems.Add(new CheckBoxListItem()
                                    {
                                        DisPlayValue = listArray[i], ActualValue = listValue [i]
                                    });
                                }
                            }
                            else
                            {
                                listArray.AsParallel().ForAll(p => checkListItems.Add(new CheckBoxListItem()
                                {
                                    ActualValue = p, DisPlayValue = p
                                }));
                            }
                        }
                        else
                        {
                            if (string.IsNullOrEmpty(currentObj.d19) || string.IsNullOrEmpty(currentObj.d20))
                            {
                                return;
                            }
                            //sql处理
                            SqlController cn = new SqlController();
                            value = EventAssitant.FormatSql(value.ToString(), this);
                            var returnDic = cn.ExcuteSqlWithReturn(value.ToString().Trim());
                            var result    = returnDic.data;
                            if (!object.Equals(result, null) && result.Length > 0)
                            {
                                foreach (Dictionary <string, string> dic in result)
                                {
                                    checkListItems.Add(new CheckBoxListItem()
                                    {
                                        ActualValue = dic[currentObj.d19], DisPlayValue = dic[currentObj.d20]
                                    });
                                }
                            }
                        }
                    }
                    if (!object.Equals(checkListItems, null))
                    {
                        MyListBox.ItemsSource = checkListItems;
                    }
                }
            }
        }