private string getSelectQuery(JPropertyInfo item) { string res = ""; bool isAbnrmal = false; string field = item.PropertyName.ToLower().Replace("id", ""); JPropertyInfo temp = _propList.FirstOrDefault(x => x.PropertyName.ToLower() == field); if (temp == null) { temp = _propList.FirstOrDefault(x => x.Xtype.ToLower().Contains(field)); isAbnrmal = true; } if (temp != null) { if (temp.Details != null && temp.Details.Count > 0) { int count = 0; string id = "", val = ""; foreach (JPropertyInfo pro in temp.Details) { if (pro.Checked) { if ((pro.PropertyName.ToLower() == field + "id") || (pro.PropertyName.ToLower() == "id")) { count++; id = pro.PropertyName; } else { count++; val = pro.PropertyName; } } if (count >= 2) { break; } } if (isAbnrmal) { res = string.Format(" ng-options=\"s.{0} as s.{1} for s in {2}List\"", id, val, temp.PropertyName.ToLower()); } else { res = string.Format(" ng-options=\"s.{0} as s.{1} for s in {2}List\"", id, val, field); } } } return(res); }
private string getValidation(JPropertyInfo item) { string res = ""; if (item.IsReq) { res += "required"; } if (item.IsMin) { res += string.Format(" ng-minlength=\"{0}\"", item.MinLength); } if (item.IsMax) { res += string.Format(" ng-maxlength=\"{0}\"", item.MaxLength); } return(res); }
private void AddUsing(string entity) { string folder = ConfigurationManager.AppSettings["EntityProject"]; string service = ConfigurationManager.AppSettings["ServiceProject"]; if (!string.IsNullOrEmpty(folder)) { _res.AppendLine(); _res.AppendFormat("using {0}.Entities;", folder); } _res.AppendLine(); _res.Append("using System;"); _res.AppendLine(); _res.Append("using System.Collections.Generic;"); _res.AppendLine(); _res.Append("using System.Linq; "); _res.AppendLine(); _res.Append("using System.Web.Mvc; "); _res.AppendLine(); _res.Append("using System.Web; "); _res.AppendLine(); _res.Append("//using log4net; "); _res.AppendLine(); _res.Append("using System.Reflection; "); if (!string.IsNullOrEmpty(service)) { _res.AppendLine(); _res.AppendFormat("using {0}.Interfaces;", service); } _res.AppendLine(); _res.Append("using Jwt.Core.Controllers; "); _res.AppendLine(); _res.Append("namespace WebApp.Controllers "); _res.Append("{"); string field = entity.ToLower() + "id"; JPropertyInfo temp = _propList.FirstOrDefault(x => x.PropertyName.ToLower() == field); _res.AppendLine(); _res.AppendFormat(TAB1 + "public class {0}Controller : JwtController<{0}, {1}>", entity, temp == null ? "int" : temp.Xtype); _res.AppendLine(); _res.AppendLine(TAB1 + "{"); }
private void AddConstructor(string entity) { _res.AppendLine(); _res.AppendFormat(TAB2 + "private {0}Scope scope = null;", entity); _res.AppendLine(); _res.AppendFormat(TAB2 + "private {0}Service service = null;", entity); _res.AppendLine(); _res.AppendFormat(TAB2 + "public {0}Ctrl({0}Scope scope, {0}Service service, Sce sce):base(scope, service, sce)", entity); _res.AppendLine(); _res.Append(TAB2 + "{"); _res.AppendLine(); _res.Append(TAB3 + "this.scope=scope;"); _res.AppendLine(); _res.Append(TAB3 + "this.service=service;"); _res.Append(this.scopeInitialized.ToString()); _res.AppendLine(); _res.Append(TAB3 + "scope.gridOpts.columnDefs = new List<ColumnDef>{"); _res.AppendLine(); _res.Append(TAB4 + "new ColumnDef{ name=\"AC\", width=50, enableSorting=false, cellTemplate=\"<div style='text-align:center'><a ng-click=\\\"getExternalScopes().EditAction(row)\\\" href=\\\"javascript:;\\\"> <i class=\\\"fa fa-pencil\\\"></i> </a><a ng-click=\\\"getExternalScopes().RemoveAction(row)\\\" href=\\\"javascript:;\\\"> <i class=\\\"fa fa-trash\\\"></i> </a></div>\"}"); foreach (var item in _propList) { if (item.Checked) { if (item.UiType == "date") { _res.AppendLine(); _res.Append(TAB4 + ",new ColumnDef{ name=\"" + item.PropertyName + "\" ,cellFilter=\"jwtDate | date:'yyyy-MM-dd'\"}"); } else if (item.UiType == "select") { string field = item.PropertyName.ToLower().Replace("id", ""); JPropertyInfo temp = _propList.FirstOrDefault(x => x.PropertyName.ToLower() == field); if (temp == null) { temp = _propList.FirstOrDefault(x => x.Xtype.ToLower().Contains(field)); } if (temp != null && temp.Details != null && temp.Details.Count > 0) { var x = temp.Details.FirstOrDefault(m => m.Checked && !(m.PropertyName.ToLower().Contains("id"))); if (x != null) { _res.AppendLine(); _res.Append(TAB4 + ",new ColumnDef{ name=\"" + temp.PropertyName + "\", field=\"" + temp.PropertyName + "_" + x.PropertyName + "\"}"); } } } else { _res.AppendLine(); _res.Append(TAB4 + ",new ColumnDef{ name=\"" + item.PropertyName + "\"}"); } } } _res.AppendLine(); _res.Append(TAB3 + "};"); _res.AppendLine(); _res.Append(TAB3 + "scope.gridOpts.onRegisterApi = gridApi => { "); _res.AppendLine(); _res.Append(TAB4 + "gridApi.paging.on.pagingChanged(scope,(newPage, pageSize)=>{"); _res.AppendLine(); _res.Append(TAB5 + "this.pageNo = newPage;"); _res.AppendLine(); _res.Append(TAB5 + "this.pageSize = pageSize;"); _res.AppendLine(); _res.Append(TAB5 + "this.GetPaged();"); _res.AppendLine(); _res.Append(TAB4 + "});"); _res.AppendLine(); _res.Append(TAB3 + "};"); _res.AppendLine(); _res.Append(TAB3 + "this.GetPaged();"); _res.AppendLine(); _res.Append(TAB3 + "this.LoadRelationalData();"); _res.AppendLine(); _res.Append(TAB2 + "}"); }