Beispiel #1
0
        /// <summary>
        /// 生成文章类型前台控件
        /// </summary>
        /// <param name="model"></param>
        static void CreateArticlePagedListWidget(ModelInfo model)
        {
            NVelocityHelper helper = new NVelocityHelper(ModelConfig.ModelControlTemplatePath);
            string          path   = CreateWidgetDirectory(model, "PagedList");

            helper.Put("modelDesc", string.IsNullOrEmpty(model.Desc) ? model.Desc : model.ModelName);
            helper.Put("model", model);

            We7DataColumnCollection dcs = null;

            if (model.Layout.UCContrl.WidgetListFields == null)
            {
                dcs = model.DataSet.Tables[0].Columns;
            }
            else
            {
                dcs = new We7DataColumnCollection();
                foreach (We7DataColumn dc in model.DataSet.Tables[0].Columns)
                {
                    if (Array.Exists(model.Layout.UCContrl.WidgetListFieldArray, s => s == dc.Name))
                    {
                        dcs.Add(dc);
                    }
                }
            }

            helper.Put("columns", dcs);

            helper.Put("CurrentDate", DateTime.Now.ToString());


            string[] tpls = GetWidgetModelPagedListTemplate();
            CreateWidgets(helper, path, tpls);
        }
Beispiel #2
0
        /// <summary>
        /// 生成文章类型前台控件
        /// </summary>
        /// <param name="model"></param>
        static void CreateArticleListControl(ModelInfo model)
        {
            NVelocityHelper helper = new NVelocityHelper(ModelConfig.ModelControlTemplatePath);
            string          path   = CreateDirectory(model, "List", "ArticleModelListDataControl", "列表");

            helper.Put("modelDesc", string.IsNullOrEmpty(model.Desc) ? model.Desc : model.ModelName);
            helper.Put("model", model);

            We7DataColumnCollection dcs = null;

            if (model.Layout.UCContrl.DetailFieldArray == null)
            {
                dcs = model.DataSet.Tables[0].Columns;
            }
            else
            {
                dcs = new We7DataColumnCollection();
                foreach (We7DataColumn dc in model.DataSet.Tables[0].Columns)
                {
                    if (Array.Exists(model.Layout.UCContrl.DetailFieldArray, s => s == dc.Name))
                    {
                        dcs.Add(dc);
                    }
                }
            }

            helper.Put("columns", dcs);

            helper.Put("CurrentDate", DateTime.Now.ToString());
            if (ModelConfig.IsCreateArticleUC)
            {
                helper.Save("ArticleList.vm", path);
            }
            helper.Save("DbModelList.vm", CreateNewFilePath(path, "DB"));
        }
Beispiel #3
0
        /// <summary>
        /// 扩展数据表格
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="dcc"></param>
        public static void ExtendDataTable(DataTable dt, We7DataColumnCollection dcc)
        {
            foreach (We7DataColumn column in dcc)
            {
                if (!dt.Columns.Contains(column.Name) && (column.Direction == ParameterDirection.ReturnValue || column.Direction == ParameterDirection.Output || column.Direction == ParameterDirection.InputOutput))
                {
                    dt.Columns.Add(column.Name);
                }
            }

            foreach (DataRow row in dt.Rows)
            {
                if (!row.Table.Columns.Contains("Object"))
                {
                    continue;
                }
                foreach (We7DataColumn column in dcc)
                {
                    IOutputConvert convert = null;
                    string[]       fields;

                    if (column.Direction == ParameterDirection.InputOutput || column.Direction == ParameterDirection.Output)
                    {
                        fields  = new string[] { String.IsNullOrEmpty(column.Mapping) ? column.Name : column.Mapping };
                        convert = new GetEntityValue();
                        if (row[column.Name] == DBNull.Value)
                        {
                            row[column.Name] = convert.Convert(column, row, fields, row["Object"]);
                        }
                    }
                    else if (column.Direction == ParameterDirection.ReturnValue)
                    {
                        convert          = ConvertHelper.GetOutputConvert(column.Expression, out fields);
                        row[column.Name] = convert.Convert(column, row, fields, row["Object"]);
                    }
                }
            }
        }