예제 #1
0
 public ActionResult GetGeneralCode()
 {
     try
     {
         string         template = "template".ValueOfForm();
         ListGeneralCfg cfg      = "cfg".ValueOfForm().ToObject <ListGeneralCfg>();
         ViewBag.cfg = cfg;
         return(View("~/Views/General/Template/{0}.cshtml".FormatWith(template)));
     }
     catch (Exception ex)
     {
         Response.Write(ex.GetInnerMessage());
         return(View("~/Views/Shared/ErrorHander.cshtml"));
     }
 }
예제 #2
0
        private ListGeneralCfg CreateListGeneralCfg(ListCfgVM cfgVM)
        {
            ListGeneralCfg cfg = new ListGeneralCfg();

            cfg.Name           = cfgVM.Name;
            cfg.DisplayName    = cfgVM.DisplayName;
            cfg.IsSupporExport = true;
            cfg.IsSupportAdd   = true;
            cfg.IsSupportEdit  = true;
            cfg.IsSupportView  = true;

            //BDCfg初始化

            cfg.DataSource.TableName  = cfgVM.TableName;
            cfg.DataSource.SourceType = cfgVM.SourceType;
            cfg.DataSource.SQL        = cfgVM.Sql;
            cfgVM.Cols.ForEach(t =>
            {
                cfg.DataSource.DBCols.Add(new ListGeneralCfg.DbCol()
                {
                    ColumnName  = t.Name,
                    DisplayName = string.IsNullOrEmpty(t.DisplayName) ? t.Name : t.DisplayName,
                    DataType    = t.DataType,
                    IsNullable  = t.IsNullable
                });
            });


            //QueryCfg初始化
            if (cfgVM.Cols.Where(t => t.IsCondition).Count() > 0)
            {
                var queryMaxCol = 3;
                var queryRowInx = 0;

                var queryFields = cfgVM.Cols.Where(t => t.IsCondition).ToList();

                for (var i = 0; i < queryFields.Count(); i++)
                {
                    var item = queryFields[i];
                    cfg.QueryCols.Add(new ListGeneralCfg.QueryCol()
                    {
                        Name        = item.Name,
                        DisplayName = string.IsNullOrEmpty(item.DisplayName) ? item.Name : item.DisplayName,
                        ColumnIdx   = queryRowInx,
                        QueryType   = GetQueryType(item.DataType),
                        RowIdx      = queryRowInx % queryMaxCol
                    });
                    if (i % queryMaxCol == 0 && i > 0)
                    {
                        queryRowInx++;
                    }
                }
            }

            //ListCfg初始化
            if (cfgVM.Cols.Where(t => t.IsList).Count() > 0)
            {
                var listFields = cfgVM.Cols.Where(t => t.IsList).ToList();
                for (var i = 0; i < listFields.Count(); i++)
                {
                    var item = listFields[i];
                    cfg.ListCols.Add(new ListGeneralCfg.ListCol()
                    {
                        ColumnIdx   = i,
                        DisplayName = string.IsNullOrEmpty(item.DisplayName) ? item.Name : item.DisplayName,
                        Name        = item.Name,
                        IsSort      = false,
                        IsSum       = false,
                        ListType    = GetListType(item.DataType),
                    });
                }
            }
            return(cfg);
        }