public static string Generate(SearchFieldsModel searchFieldsModel, string generateType="") { using (var sqlb = DbHelper.CreateSql()) { sqlb.SelectSql = @"SELECT TOP 100 f.*, t.ControlTypeName,t.Pattern,t.EntityPattern,t.KimlPattern, t.HtmlPattern, t.MvcPattern FROM DevFieldInfo f JOIN dbo.DevControlType t ON f.ControlTypeId=t.ControlTypeId "; sqlb.AddFilter("f.TableName LIKE @TableName", "@TableName", sqlb.Wrap(searchFieldsModel.TableName)); sqlb.AddFilter("f.FieldName LIKE @FieldName", "@FieldName", sqlb.Wrap(searchFieldsModel.FieldName)); sqlb.AddFilter("f.CategoryName LIKE @CategoryName", "@CategoryName", sqlb.Wrap(searchFieldsModel.CategoryName)); sqlb.AddFilter("f.FieldLabel LIKE @FieldLabel", "@FieldLabel", sqlb.Wrap(searchFieldsModel.FieldLabel)); sqlb.OrderBy = " ORDER BY ControlIndex ASC "; var dtFields = sqlb.QueryDataTable(); if(generateType == "sql") { return GenerateSql( dtFields); } StringBuilder sb = new StringBuilder(); foreach (DataRow row in dtFields.Rows) { string str = row[generateType+"Pattern"]?.ToString()?.Replace("[PropertyName]", row["EntityProperty"]?.ToString()); string type = GetCsTypeName(row["DataType"].ToString()); str = str?.Replace("[Type]", type); str = str?.Replace("[FieldLabel]", row["FieldLabel"].ToString()); string nullable = ""; if (Convert.ToBoolean(row["CanNull"]) && !"string".Equals(type, StringComparison.CurrentCultureIgnoreCase)) nullable = "?"; str = str?.Replace("[Nullable]",nullable); str = str?.Replace("[FieldName]", row["FieldName"].ToString()); sb.AppendLine(str); sb.AppendLine(); } return sb.ToString(); } }
public ActionResult SearchFields(SearchFieldsModel model) { model.GridModel.Editable = true; model.GridModel.Addable = true; model.GridModel.Duplicatable = true; model.GridModel.JsDuplicateFunction = "duplicateField"; model.GridModel.UrlUpdateField = Url.Content("~/ViewBuilder/UpdateField"); model.GridModel.HasRowDetail = true; model.GridModel.UrlRowDetail = Url.Content("~/ViewBuilder/FieldDetail"); model.GridModel.Title = "Development Field Information"; DevBiz.SearchFields(model); return View(model); }
public static void SearchFields(SearchFieldsModel searchFieldsModel) { using (var sqlb = DbHelper.CreateSql()) { sqlb.SelectSql = @"SELECT TOP 100 f.*, t.ControlTypeName FROM DevFieldInfo f LEFT JOIN dbo.DevControlType t ON f.ControlTypeId=t.ControlTypeId "; sqlb.AddFilter("f.TableName LIKE @TableName", "@TableName", sqlb.Wrap(searchFieldsModel.TableName)); sqlb.AddFilter("f.FieldName LIKE @FieldName", "@FieldName", sqlb.Wrap(searchFieldsModel.FieldName)); sqlb.AddFilter("f.FieldLabel LIKE @FieldLabel", "@FieldLabel", sqlb.Wrap(searchFieldsModel.FieldLabel)); sqlb.AddFilter("f.CategoryName LIKE @CategoryName", "@CategoryName", sqlb.Wrap(searchFieldsModel.CategoryName)); sqlb.OrderBy = " ORDER BY ControlIndex ASC "; searchFieldsModel.GridModel.SortField = "ControlIndex"; searchFieldsModel.GridModel.Data = sqlb.QueryDataTable(); searchFieldsModel.GridModel.AutoSetFields(); } }
public ActionResult SearchFields() { SearchFieldsModel model = new SearchFieldsModel(); return View(model); }
public string Generate(SearchFieldsModel model) { string type = Request.QueryString["type"]; string code = DevBiz.Generate(model, type); return code; }