void BindData() { List <DataControlInfo> result = DataControlHelper.GetDataControlsInfos(); if (ddlType.SelectedValue != "ALL") { result = result.FindAll(delegate(DataControlInfo dci) { return(dci.Group == ddlType.SelectedValue && (dci.Name.Contains(txtKeyWord.Text.Trim()) || dci.Desc.Contains(txtKeyWord.Text.Trim()))); }); } else { result = result.FindAll(delegate(DataControlInfo dci) { return(dci.Name.Contains(txtKeyWord.Text.Trim()) || dci.Desc.Contains(txtKeyWord.Text.Trim())); }); } PagedDataSource pds = new PagedDataSource(); pds.DataSource = result; pds.PageSize = Pager.PageSize; pds.AllowPaging = true; Pager.RecordCount = result.Count; pds.CurrentPageIndex = Pager.CurrentPageIndex - 1; if (pds.CurrentPageIndex < 0) { pds.CurrentPageIndex = 0; } ModeDataList.DataSource = pds; ModeDataList.DataBind(); }
protected void StoreButton_Click(object sender, EventArgs e) { if (hdKey.Value == "1") { string[] vs = hdValue.Value.Split('|'); string name = vs[0]; string key = vs[1]; string desc = vs[2]; string ctr = DataControlHelper.SaveControl(ControlFile, CtrCodeTextBox.Text.Trim(), name, key, desc); DataControl dc = DataControlHelper.GetDataControl(ctr); string ctrName = dc != null ? (string.IsNullOrEmpty(dc.Name) ? "(空)" : dc.Name) : "(空)"; string script = "window.returnValue={key:'" + ctrName + "',value:'" + ctr + "'};window.close()"; ClientScript.RegisterClientScriptBlock(this.GetType(), "returnValue", script, true); } else { try { DataControlHelper.EditControl(ControlFile, CtrCodeTextBox.Text.Trim()); string script = "window.close()"; ClientScript.RegisterClientScriptBlock(this.GetType(), "returnValue", script, true); } catch (Exception ex) { Response.Write(ex.Message); Response.End(); } } DataControlHelper.EditControl(GroupCopy, ControlFile, CtrCodeTextBox.Text.Trim()); }
/// <summary> /// Register a data control to give it Dynamic Data behavior /// </summary> /// <param name="setSelectionFromUrl">When true, if a primary key is found in the route values /// (typically on the query string), it will get be set as the selected item. This only applies /// to list controls.</param> public void RegisterControl(Control control, bool setSelectionFromUrl) { // if (DesignMode) { return; } IDataBoundControlInterface dataBoundControl = DataControlHelper.GetDataBoundControl(control, true /*failIfNotFound*/); // If we can't get an associated IDynamicDataSource, don't do anything IDynamicDataSource dataSource = dataBoundControl.DataSourceObject as IDynamicDataSource; if (dataSource == null) { return; } // If we can't get a MetaTable from the data source, don't do anything MetaTable table = MetaTableHelper.GetTableWithFullFallback(dataSource, Context.ToWrapper()); // Save the datasource so we can process its parameters in OnLoad. The value we set is irrelevant _dataSources[dataSource] = null; ((INamingContainer)control).SetMetaTable(table); BaseDataBoundControl baseDataBoundControl = control as BaseDataBoundControl; if (baseDataBoundControl != null) { EnablePersistedSelection(baseDataBoundControl, table); } RegisterControlInternal(dataBoundControl, dataSource, table, setSelectionFromUrl, Page.IsPostBack); }
protected void bttnStore_Click(object sender, EventArgs e) { string style = Style; if (hdKey.Value == "1") { try { string[] s = hdValue.Value.Split('|'); string sv = DataControlHelper.SaveCssByPath(ControlFile, s[0], s[1], style, CssTextBox.Text); doJs(sv); style = sv.Split('.')[0]; } catch (Exception ex) { msgLabel.Text = ex.Message; } } else { try { DataControlHelper.EditCssByPath(ControlFile, Style, CssTextBox.Text); Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "close", "window.close()", true); TemplateProcessor proccor = new TemplateProcessor(GroupCopy); proccor.OverrideCssByPath(ControlFile, style, CssTextBox.Text); } catch (Exception ex) { Response.Write(ex.Message); Response.End(); } } }
protected void SaveButton_Click(object sender, EventArgs e) { DataControlHelper.EditControl(GroupCopy, ControlFile, CtrCodeTextBox.Text.Trim()); string script = "window.close()"; ClientScript.RegisterClientScriptBlock(this.GetType(), "returnValue", script, true); }
void BindCategory() { List <DataControlGroup> list = DataControlHelper.GetDataControlGroups(); ddlType.DataSource = list; ddlType.DataTextField = "Label"; ddlType.DataValueField = "Name"; ddlType.DataBind(); ddlType.Items.Insert(0, new ListItem("所有", "ALL")); }
protected void Page_Load(object sender, EventArgs e) { if (String.IsNullOrEmpty(ControlFile) || String.IsNullOrEmpty(ControlFile.Split('.')[0]) || ( !File.Exists(HttpContext.Current.Server.MapPath(ControlFile)) && !File.Exists(Path.Combine(DataControlHelper.GetDataControlPath(ControlFile.Split('.')[0]), Constants.We7ControlConfigFile)))) { Response.Write("<p style='font-size:14px;color:red'>找不到控件的配置文件,请确认控件是否存在或控件标签格式是否正确!</p>"); Response.End(); } }
void ResponseDelStyle() { TemplateProcessor processor = new TemplateProcessor(TemplateGroup); processor.DelCss(Control, Style); processor = new TemplateProcessor(TemplateGroupCopy); processor.DelCss(Control, Style); DataControlHelper.DeleteCssFile(Control, Style); ResponseResult("success"); }
protected void btnCreateIndex_Click(object sender, EventArgs e) { try { DataControlHelper dchelper = HelperFactory.GetHelper <DataControlHelper>(); dchelper.CreateDataControlIndex(); ClientScript.RegisterStartupScript(this.GetType(), "msg", "alert('重建索引成功!')", true); } catch (Exception ex) { ClientScript.RegisterStartupScript(this.GetType(), "msg", "alert('重建索引失败:" + ex.Message + "')", true); } }
protected void CreateControlIndex_Click(object sender, EventArgs e) { try { DataControlHelper dchelper = HelperFactory.GetHelper <DataControlHelper>(); dchelper.CreateDataControlIndex(); //BaseControlHelper Helper = new BaseControlHelper(); //Helper.CreateIntegrationIndexConfig(); Messages.ShowMessage("重新索引成功"); } catch (Exception ex) { Messages.ShowError("重建索引失败:" + ex.Message); } }
protected void Sort(string sortName) { string sortText = sortName; List <DataControlInfo> ds = DataControlHelper.GetControls(sortName); ModeDataList.DataSource = ds; ModeDataList.DataBind(); if (ds.Count == 0) { ShowMessage("没有符合条件的控件。"); } else { ShowMessage(String.Format("总共 {0} 个控件。", ds.Count)); } }
protected override void Initialize() { string selectQuery = this.FieldDropDownList.SelectedItem.ToString(); string query = SearchTextBox.Text.Trim(); List <DataControlInfo> ds = DataControlHelper.GetControls(query, selectQuery); ModeDataList.DataSource = ds; ModeDataList.DataBind(); if (ds.Count == 0) { ShowMessage("没有符合条件的控件。"); } else { ShowMessage(String.Format("总共 {0} 个控件。", ds.Count)); } }
/// <summary> /// 将模型、插件、控件信息整合在一起 /// </summary> /// <returns></returns> private List <DataControlInfo> IntegrationWidgetsAndControls() { //部件索引与控件索引分开 //List<DataControlInfo> ctrs = GetControls("/Widgets/WidgetCollection"); DataControlHelper dchelper = HelperFactory.Instance.GetHelper <DataControlHelper>(); List <DataControlInfo> list = dchelper.GetControls() ?? new List <DataControlInfo>(); //if (ctrs != null) //{ // foreach (DataControlInfo di in ctrs) // { // foreach (DataControl dc in di.Controls) // { // dc.Name = dc.Description; // } // list.Add(di); // } //} return(list); }
protected void Page_Load(object sender, EventArgs e) { JsonResult result; String ctr = Request["ctr"]; if (String.IsNullOrEmpty(ctr)) { result = new JsonResult(false); } else { try { DataControl datacontrol = DataControlHelper.GetDataControl(ctr.Trim()); result = new JsonResult(true, datacontrol); } catch (Exception ex) { result = new JsonResult(false, ex.Message); } } result.Response(); }
void ResponseDelControl() { DataControlHelper.DelControl(Control); ResponseResult("success"); }
void ResponseReload() { DataControlInfo info = DataControlHelper.GetDataControlInfo(Control); ResponseResult(info.ToJson()); }
/// <summary> /// Find the containing data control, and return the data source it points to /// </summary> public static IDynamicDataSource FindDataSourceControl(this Control current) { return(DataControlHelper.FindDataSourceControl(current)); }
void BindContent() { CtrCodeTextBox.Text = DataControlHelper.GetControlCode(GroupCopy, ControlFile); }