예제 #1
0
        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();
        }
예제 #2
0
 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());
 }
예제 #3
0
        /// <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);
        }
예제 #4
0
        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();
                }
            }
        }
예제 #5
0
        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);
        }
예제 #6
0
        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"));
        }
예제 #7
0
 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();
     }
 }
예제 #8
0
        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");
        }
예제 #9
0
 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);
     }
 }
예제 #10
0
 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);
     }
 }
예제 #11
0
        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));
            }
        }
예제 #12
0
        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));
            }
        }
예제 #13
0
        /// <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);
        }
예제 #14
0
        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();
        }
예제 #15
0
 void ResponseDelControl()
 {
     DataControlHelper.DelControl(Control);
     ResponseResult("success");
 }
예제 #16
0
        void ResponseReload()
        {
            DataControlInfo info = DataControlHelper.GetDataControlInfo(Control);

            ResponseResult(info.ToJson());
        }
예제 #17
0
 /// <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));
 }
예제 #18
0
 void BindContent()
 {
     CtrCodeTextBox.Text = DataControlHelper.GetControlCode(GroupCopy, ControlFile);
 }