/// <summary> /// 获取页面分组信息 /// </summary> /// <returns></returns> public async Task <List <pageDetailForGroup> > GetPageGroupInfo(string pageid) { string apitype = JsonApiType.groupPageGet; BaseRequest bj = GetCommonBaseRequest(apitype); //string review = "0"; string review = string.Empty; PageGroupData pgd = new PageGroupData(pageid, review); bj.api_type = apitype; bj.data = pgd; try { var result = await Post(bj); BaseReturn brj = JsonController.DeSerializeToClass <BaseReturn>(result); pageGroupReturnData pgr = JsonController.DeSerializeToClass <pageGroupReturnData>(brj.data.ToString()); if (!object.Equals(pgr.data, null) && pgr.data.Length > 0) { List <pageDetailForGroup> listpage = new List <pageDetailForGroup>(); listpage.AddRange(pgr.data[0].page_list); return(listpage); } return(null); } catch (Exception ex) { string test = ex.Message; return(null); } }
/// <summary> /// 审核页面 /// </summary> /// <param name="pageid"></param> /// <param name="version"></param> /// <returns></returns> public async Task <bool> ReviewPage(string pageid, int version) { string apitype = JsonApiType.reviewPage; BaseRequest bj = GetCommonBaseRequest(apitype); ReviewRequest re = new ReviewRequest(version, pageid); bj.api_type = apitype; bj.data = re; try { var result = await Post(bj); BaseReturn brj = JsonController.DeSerializeToClass <BaseReturn>(result); CommonReturn cr = JsonController.DeSerializeToClass <CommonReturn>(brj.data.ToString()); if (cr.error_code.Equals(ReturnConst.right)) { return(true); } else { return(false); } } catch { return(false); } }
/// <summary> /// 获取最近上传页面 /// </summary> /// <param name="version"></param> /// <returns></returns> public async Task <List <PageGroupDetail> > GetRecentUploadPages() { string apitype = JsonApiType.groupPageGet; BaseRequest bj = GetCommonBaseRequest(apitype); string reviewState = "0"; RecentUploadPageRequest pgd = new RecentUploadPageRequest(reviewState); bj.api_type = apitype; bj.data = pgd; try { var result = await Post(bj); BaseReturn brj = JsonController.DeSerializeToClass <BaseReturn>(result); pageGroupReturnData pgr = JsonController.DeSerializeToClass <pageGroupReturnData>(brj.data.ToString()); if (!object.Equals(pgr.data, null) && pgr.data.Length > 0) { List <PageGroupDetail> listreturn = new List <PageGroupDetail>(); listreturn.AddRange(pgr.data); return(listreturn); } else { return(null); } } catch { return(null); } }
/// <summary> /// 上传文件 /// 将返回路径存储到d0字段中 /// </summary> /// <param name="value"></param> public void SetA1(object value) { ControlDetailForPage obj = (this.Tag as ControlDetailForPage); //上传文件 var values = new[] { new KeyValuePair <string, string>("api_type", "upload"), new KeyValuePair <string, string>("sql", /*obj.d5*/ string.Empty), //other values }; OpenFileDialog opf = new OpenFileDialog(); string filter = this.GetFilterType(); if (!string.IsNullOrEmpty(filter)) { opf.Filter = filter; } if (opf.ShowDialog() == DialogResult.OK) { if (IsValidImage(opf.FileName)) { long length = new System.IO.FileInfo(opf.FileName).Length; float lef = length / (1024 * 1024); if (lef > 2.0) { MessageBox.Show("图片大小超过2m!"); return; } } try { bool resultbol = false; //if (CommonFunction.IsFinishLoading) //{ // resultbol = true; // CommonFunction.IsFinishLoading = false; // CommonFunction.ShowWaitingForm(); //} BaseConnection bcc = new BaseConnection(); var result = bcc.PostFile(opf.FileName, values); BaseReturn brj = JsonController.DeSerializeToClass <BaseReturn>(result.Result); FileUploadReturn returnResult = JsonController.DeSerializeToClass <FileUploadReturn>(brj.data.ToString()); obj.d0 = returnResult.data.path; this.Tag = obj; this.SetP9(obj.p9); //if (resultbol) //{ // CommonFunction.IsFinishLoading = true; //} } catch { //调用失败后走这里 this.SetP12(obj.p12); } } }
/// <summary> /// 生成父控件 /// </summary> public void ProduceFatherControl(ControlDetailForPage controlObj, List <ControlDetailForPage> listControlObj, List <IControl> listControl, UIElement fatherControl, bool isNeedSetRow = false) { if (controlObj.ctrl_type.Equals(xinLongyuControlType.PCGrid)) { string teset = string.Empty; } IControl newfatherControl = this.ProductChildControl(controlObj, listControl, fatherControl); if (isNeedSetRow) { (newfatherControl as FrameworkElement).SetValue(Grid.RowProperty, 1); } //导航栏控件由自身进行初始化 if (xinLongyuControlType.pcnavigationBarType.Equals(controlObj.ctrl_type)) { //(newfatherControl as xinlongyuNavigationControl).InitControl(controlObj, listControlObj, listControl); return; } //表格控件也由自身进行初始化 if (xinLongyuControlType.PCGrid.Equals(controlObj.ctrl_type)) { //(newfatherControl as xinlongyuDataGird).LoadMyData(listControlObj, controlObj); return; } //获取子控件列表 string controlList = _D0FatherControlList.Contains(controlObj.ctrl_type) ? controlObj.d0 : controlObj.d17; if (string.IsNullOrEmpty(controlList)) { return; } List <int> controlIdList = JsonController.DeSerializeToClass <List <int> >(controlList); if (object.Equals(controlIdList, null) || controlIdList.Count < 1) { return; } //这里对层级进行排序 List <ControlDetailForPage> childrenList = listControlObj.Where(p => controlIdList.Contains(p.ctrl_id)).OrderBy(p => p.ctrl_level).ToList(); foreach (ControlDetailForPage ctObj in childrenList) { //这里使用递归循环生成控件 if (_fatherControlList.Contains(ctObj.ctrl_type)) { ProduceFatherControl(ctObj, listControlObj, listControl, newfatherControl as UIElement); } else { this.ProductChildControl(ctObj, listControl, newfatherControl as UIElement); } } }
/// <summary> /// 解析事件数组 /// </summary> /// <param name="inText"></param> /// <returns></returns> public List <DecoderOfControl> DecodeEvent(string inText) { string[] array = JsonController.DeSerializeToClass <string[]>(inText); List <DecoderOfControl> list = new List <DecoderOfControl>(); foreach (string eventText in array) { list.Add(DecodeNewCharacter(eventText)); } return(list); }
/// <summary> /// 设置字体样式 /// </summary> /// <param name="value"></param> public void SetD6(string value) { if (!string.IsNullOrEmpty(value.Trim())) { Font font = JsonController.DeSerializeToClass <Font>(value); this.FontStyle = font.Style == System.Drawing.FontStyle.Italic ? FontStyles.Italic : FontStyles.Normal; this.FontFamily = CommonConverter.FontToMediaFontFamily(font); this.FontSize = font.Size; this.FontWeight = font.Bold ? FontWeights.Bold : FontWeights.Normal; } }
/// <summary> /// 生成节点内容 /// </summary> /// <param name="listControlObj"></param> /// <param name="listControl"></param> /// <param name="treeviewItemObj"></param> /// <returns></returns> private UIElement ProduceTreeviewItem(List <ControlDetailForPage> listControlObj, List <IControl> listControl, ControlDetailForPage treeviewItemObj) { List <int> listChild = JsonController.DeSerializeToClass <List <int> >(treeviewItemObj.d17); ControlDetailForPage gridObj = listControlObj.Where(p => listChild.Contains(p.ctrl_id)).ToList()[0]; ControlDecoder controlDecoder = new ControlDecoder(); xinlongyuParentControl parentControl = new xinlongyuParentControl(); controlDecoder.ProduceFatherControl(gridObj, listControlObj, listControl, parentControl); parentControl.Width = 200; parentControl.Height = 50; return(parentControl); }
/// <summary> /// 获取所有的一级目录 /// </summary> /// <returns></returns> private List <ControlDetailForPage> GetParentGroups(List <ControlDetailForPage> listControlObj, string childlistStr) { List <int> controlIdList = JsonController.DeSerializeToClass <List <int> >(childlistStr); if (controlIdList.Count < 1) { return(null); } //获取父目录控件并进行排序 List <ControlDetailForPage> childrenList = listControlObj.Where(p => controlIdList.Contains(p.ctrl_id) && validStr.Equals(p.d12)) .OrderBy(p => CommonConverter.StringToInt(p.d21)).ToList(); return(childrenList); }
/// <summary> /// 上传图片 /// </summary> /// <param name="filePath"></param> /// <returns></returns> private string UploadImage(string filePath) { try { var result = bcc.PostFile(filePath, values); BaseReturn brj = JsonController.DeSerializeToClass <BaseReturn>(result.Result); FileUploadReturn returnResult = JsonController.DeSerializeToClass <FileUploadReturn>(brj.data.ToString()); string fileUrl = returnResult.data.path; return(fileUrl); } catch { return(string.Empty); } }
/// <summary> /// 启动控件 /// </summary> /// <param name="text"></param> public void SetA1(string text) { if (!object.Equals(_allFiles, null) && _allFiles.Count > 0) { try { ControlDetailForPage obj = (this.Tag as ControlDetailForPage); //上传文件 var values = new[] { new KeyValuePair <string, string>("api_type", "upload"), new KeyValuePair <string, string>("sql", string.Empty), }; SqlController slcontroller = new SqlController(); string sqlInsert = obj.d5; //sqlInsert = DecoderAssistant.FormatSql(sqlInsert, this); //bool resultbol = false; //if (CommonFunction.IsFinishLoading) //{ // resultbol = true; // CommonFunction.IsFinishLoading = false; // CommonFunction.ShowWaitingForm(); //} //改为传相对路径 foreach (string file in _allFiles) { var result = slcontroller.PostFile(file, values); BaseReturn brj = JsonController.DeSerializeToClass <BaseReturn>(result.Result); FileUploadReturn returnResult = JsonController.DeSerializeToClass <FileUploadReturn>(brj.data.ToString()); string fileUrl = returnResult.data.path; string filename = this.GetRelativePath(file, _folderPath);; string fileName = @"\" + @filename; fileName = fileName.Replace("\\", "\\\\"); slcontroller.ExcuteSqlWithReturn(string.Format(sqlInsert, fileUrl, fileName)); } //if (resultbol) //{ // CommonFunction.IsFinishLoading = true; //} this.SetP9(obj.p9); } catch { this.SetP9((this.Tag as ControlDetailForPage).p12); } } }
/// <summary> /// 获取页面信息 /// </summary> /// <param name="pageId"></param> /// <returns></returns> public async Task <PageInfoDetail> GetPageInfo(int pageId) { //string pageVersion = string.IsNullOrEmpty(LocalCacher.GetCache("page_version")) ? "0" : LocalCacher.GetCache("page_version"); string pageVersion = "4"; BaseRequest bj = this.GetPageRequest(pageId, pageVersion); try { PageInfoDetail prd; try { var result = await Post(bj); BaseReturn brj = JsonController.DeSerializeToClass <BaseReturn>(result); ReturnCode code = JsonController.DeSerializeToClass <ReturnCode>(brj.data.ToString()); if (code.error_code.Equals("1")) { throw new Exception("获取页面失败"); } prd = JsonController.DeSerializeToClass <PageInfoDetail>(brj.data.ToString()); } catch (Exception ex) { Logging.Error(ex.Message); //这种情况是连不上服务的处理或者调用接口失败 prd = new PageInfoDetail(); prd.data = null; } if (object.Equals(prd.data, null)) { return(_pageCacher.GetPageInfo(pageId)); } else { //获取页面成功后进行缓存 if ("0".Equals(pageVersion)) { _pageCacher.CachePageInfo(prd); } return(prd); } } catch { return(null); } }
/// <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="type"></param> /// <param name="phonenumber"></param> /// <param name="code"></param> /// <returns></returns> public async Task <bool> DealWithSMS(string type, string phonenumber, string code = "", bool isVerify = false) { string apitype = JsonApiType.sendCode; BaseRequest bj = GetCommonBaseRequest(apitype); bj.api_type = apitype; if (isVerify) { SmsRequest sr = new SmsRequest() { type = type, to = phonenumber, code = code }; bj.data = sr; } else { SmsRequestSend sr = new SmsRequestSend() { type = type, to = phonenumber }; bj.data = sr; } try { string result = await Post(bj); BaseReturn brj = JsonController.DeSerializeToClass <BaseReturn>(result); CommonReturn cr = JsonController.DeSerializeToClass <CommonReturn>(brj.data.ToString()); if (cr.error_code.Equals(ReturnConst.right)) { return(true); } else { return(false); } } catch { return(false); } }
/// <summary> /// 设置表格的列 /// </summary> /// <param name="listControlObj"></param> /// <param name="gridObj"></param> private void SetDataGridColumns(List <ControlDetailForPage> listControlObj, ControlDetailForPage gridObj) { mydatagridview.Columns.Clear(); //获取所有的列 List <int> listChildId = JsonController.DeSerializeToClass <List <int> >(gridObj.d17); List <ControlDetailForPage> listAllColumns = listControlObj.Where(p => listChildId.Contains(p.ctrl_id) && xinLongyuControlType.GridColumnName.Equals(p.ctrl_type)) .OrderBy(p => CommonConverter.StringToInt(p.d21)).ToList(); //获取键值对应字典 Dictionary <int, string> ctrlIdToColumnName = this.GetDicCtrlToColumn(gridObj.d22); //生成列类型 foreach (ControlDetailForPage ctObj in listAllColumns) { DataGridColumn column = GetDataGridColumn(ctObj, ctrlIdToColumnName, listControlObj); column.Header = ctObj.d0; mydatagridview.Columns.Add(column); } //设置行高 mydatagridview.RowHeight = CommonConverter.StringToInt(gridObj.d19); }
/// <summary> /// 获取对应的列 /// </summary> /// <returns></returns> private DataGridColumn GetDataGridColumn(ControlDetailForPage ctObj, Dictionary <int, string> ctrlIdToColumnName, List <ControlDetailForPage> listControlObj) { List <int> listChild = JsonController.DeSerializeToClass <List <int> >(ctObj.d17); List <ControlDetailForPage> listAllChild = listControlObj.Where(p => listChild.Contains(p.ctrl_id)).ToList(); DataGridTemplateColumn tcolumn = new DataGridTemplateColumn(); DataTemplate template = new DataTemplate(); template.DataType = typeof(ObjectHelperForDataGrid); if (listAllChild.Count > 1) { FrameworkElementFactory factory = new FrameworkElementFactory(typeof(Grid)); factory.SetValue(VerticalAlignmentProperty, VerticalAlignment.Stretch); factory.SetValue(HorizontalAlignmentProperty, HorizontalAlignment.Stretch); foreach (ControlDetailForPage obj in listAllChild) { if (ctrlIdToColumnName.ContainsKey(obj.ctrl_id)) { factory.AppendChild(GetFrameworkElement(_propertyNameToColumnName[ctrlIdToColumnName[obj.ctrl_id]], obj)); } else { factory.AppendChild(GetFrameworkElement(string.Empty, obj)); } } template.VisualTree = factory; } else { string propertyName = ctrlIdToColumnName.ContainsKey(listAllChild[0].ctrl_id)? _propertyNameToColumnName[ctrlIdToColumnName[listAllChild[0].ctrl_id]] : string.Empty; FrameworkElementFactory factory = new FrameworkElementFactory(typeof(Grid)); FrameworkElementFactory factorychild = GetFrameworkElement(propertyName, listAllChild[0]); factorychild.SetValue(VerticalAlignmentProperty, VerticalAlignment.Stretch); factorychild.SetValue(HorizontalAlignmentProperty, HorizontalAlignment.Stretch); factory.AppendChild(factorychild); template.VisualTree = factory; } tcolumn.CellTemplate = template; return(tcolumn); }
/// <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> 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; } } } }