public static DesignerViewPage BuildPage(StackAppContext appContext, RequestQueryString requestQuery) { var layoutModel = EntityMetaData.Get(EntityCode.EntityLayout).GetSingle(appContext, requestQuery.ItemId); var entity = EntityMetaData.Get(requestQuery.RelatedEntityId); var view = TView.ParseFromJSON(layoutModel.GetValue("layoutjson", "")); if (view == null) { view = entity.GetDefaultLayoutView(0); } var pallet = BuildPallet(appContext, entity); var page = new DesignerViewPage(pallet, view); page.LayoutFields = view.Fields; page.Actions = new InvariantDictionary <Model.Form.ActionInfo>(); var saveAction = new ActionInfo("Studio/SaveDesigner", requestQuery, "BTN_SAVE") { Title = "Save", ActionType = ActionType.Save, ExecutionType = ActionExecutionType.Custom }; page.Actions.Add("BTN_SAVE", saveAction); return(page); }
public FilterWidgetResponse BuildWithData(CustomRequestInfo request, RequestQueryString requestQuery) { if (request != null && request.Value != null) { var filtersRes = new List <ViewPage>(); var filterJson = request.Value; var exp = FilterExpression.BuildFromJson(requestQuery.EntityId, filterJson.ToString()); foreach (var field in exp.GetAll()) { var formContext = new EditFormContext(Context, EntityCode.User, requestQuery); formContext.Build(); var fieldInfo = formContext.Entity.GetFieldSchema(field.FieldName); CreateWidgets(formContext, fieldInfo, field); var page = new ViewPage(formContext); filtersRes.Add(page); } return(new FilterWidgetResponse() { Filters = filtersRes }); } return(null); }
public static List <ViewPageDataOnly> GetData(StackAppContext appContext, RequestQueryString requestQuery) { var baseEntity = EntityMetaData.Get(requestQuery.EntityId); var baseField = baseEntity.GetFieldSchema(requestQuery.FieldName); var childEntity = EntityMetaData.Get(baseField.RefObject); var ids = FetchDataModel(appContext, requestQuery.ItemId, baseField, childEntity); var pages = new List <ViewPageDataOnly>(); var lConext = new LayoutContext(appContext, 0, baseField.RefObject); lConext.Build(); foreach (var id in ids) { var query = new RequestQueryString() { EntityId = baseField.RefObject, ItemId = id }; var context = new EditFormContext(appContext, baseField.RefObject, query); context.Build(); context.CreateDataModel(); context.LayoutContext = lConext; var renderer = new EditFormRenderer(context); renderer.Generate(lConext); pages.Add(renderer.GetViewPageOnlyData()); } return(pages); }
private void AddHeaderActions(RequestQueryString reqQuery, int entityItemId) { View.Actions = new InvariantDictionary <Model.Form.ActionInfo>(); var qs = new RequestQueryString() { EntityId = EntityCode.EntitySchema, RelatedEntityId = EntityCode.EntityMaster, RelationField = "entityid", RelatedObjectId = entityItemId }; View.Actions.Add("BTN_NEW", new Model.Form.ActionInfo(AppLinkProvider.NEW_ENTITY_URL, qs) { Title = "New Field", LinkTarget = "POPUP" }); //var qs1 = new RequestQueryString() { EntityId = EntityCode.EntityAction, RelatedEntityId = EntityCode.EntityMaster, RelationField="entityid", RelatedObjectId = entityItemId }; //View.Actions.Add("BTN_NEW_ACTION", new Model.Form.ActionInfo(AppLinkProvider.NEW_ENTITY_URL, qs1){ Title = "New Action", LinkTarget="POPUP" }); //var refEntity = EntityMetaData.Get(entityItemId); //var layoutEntity = EntityMetaData.GetAs<Core.Entity.EntityLayoutEntity>(EntityCode.EntityLayout); //var fExp = new Model.Entity.FilterExpression(EntityCode.EntityLayout); //fExp.Add(new Model.Entity.FilterExpField("itemtype", FilterOperationType.Equal, refEntity.DefaultItemTypeId)); //fExp.Add(new Model.Entity.FilterExpField("entityid", FilterOperationType.Equal, entityItemId)); //fExp.Add(new Model.Entity.FilterExpField("viewtype", FilterOperationType.Equal, 0)); //var lids = layoutEntity.ReadIds(_appContext, fExp); //if(lids.Count > 0) //{ // var qs2 = new RequestQueryString() { EntityId = EntityCode.EntityLayout, ItemId = lids[0] }; // View.Actions.Add("BTN_VIEW_Layout", new Model.Form.ActionInfo(AppLinkProvider.DETAIL_ENTITY_URL, qs2){ Title = "View Layout", LinkTarget="POPUP" }); //} //else { // var qs2 = new RequestQueryString() { EntityId = EntityCode.EntityLayout, RelatedEntityId = EntityCode.EntityMaster, RelationField="entityid", RelatedObjectId = entityItemId }; // View.Actions.Add("BTN_NEW_Layout", new Model.Form.ActionInfo(AppLinkProvider.NEW_ENTITY_URL, qs2){ Title = "New Layout", LinkTarget="POPUP" }); //} }
public IActionResult EntityList() { this.RequestQuery.EntityId = EntityCode.EntityMaster; var context = new DeskPageContext(this.WebAppContext, EntityCode.EntityMaster, this.RequestQuery); context.Build(); var widgetContext = WidgetContext.BuildContext(context, "LayoutList"); widgetContext.WidgetType = FormControlType.EntityListView; var widget = new ViewModel.FormWidget.EntityListWidget(widgetContext); widget.OnCompile(); widget.SetValue(null); context.AddControl(widget); var page = new ViewPage(context); page.Actions = new InvariantDictionary <Model.Form.ActionInfo>(); var qs = new RequestQueryString() { EntityId = EntityCode.EntityMaster }; page.Actions.Add("BTN_NEW", new Model.Form.ActionInfo(AppLinkProvider.NEW_ENTITY_URL, qs) { Title = "New Entity", LinkTarget = "POPUP" }); return(CreatePageResult(page)); }
public override ViewPage GetPage(RequestQueryString reqQuery) { int entityItemId = reqQuery.EntityId.Code; View.PageType = AppPageType.AppStudio; View.CurrentQuery = reqQuery.ToQueryString(); var formContext = new DetailFormContext(_appContext, EntityCode.EntityMaster, new RequestQueryString() { EntityId = EntityCode.EntityMaster, ItemId = entityItemId }); formContext.Build(); formContext.CreateDataModel(); var entityMasterModel = formContext.EntityModel; View.PageTitle = new DynamicObj(); View.PageTitle.Add("Title", entityMasterModel.GetValue <string>("text", "")); AddHeaderActions(reqQuery, entityItemId); AddFieldListField(formContext); AddLayoutListField(formContext); AddListListField(formContext); AddEntityActionsListField(formContext); return(this.View); }
/// <summary> /// 获得URL参数 /// </summary> public void LoadGetUrlPara() { if (!string.IsNullOrEmpty(RequestQueryString.GetQueryString("InfoCategoryID"))) { InfoCategoryID = RequestQueryString.GetQueryString("InfoCategoryID").ToString(); } }
public FilterWidgetResponse Generate(CustomRequestInfo request, RequestQueryString requestQuery) { var formContext = new EditFormContext(Context, requestQuery.EntityId, requestQuery); formContext.Build(); if (request != null && request.Value != null) { JObject fieldId = (JObject)request.Value; var fid = fieldId["Value"]; var fieldInfo = formContext.Entity.GetFieldSchema(Convert.ToInt32(fid)); if (fieldInfo == null) { throw new EntityException("Invalid field!"); } CreateWidgets(formContext, fieldInfo); } var page = new ViewPage(formContext); var filtersRes = new List <ViewPage>() { page }; return(new FilterWidgetResponse() { Filters = filtersRes }); }
public AnyStatus SaveLayoutData(StackAppContext appContext, RequestQueryString requestQuery, TView view) { var layoutModel = GetSingle(appContext, requestQuery.ItemId); var json = view.ToStoreJSON(); layoutModel.SetValue("layoutjson", json); return(Save(appContext, layoutModel)); }
/// <summary> /// 获得URL参数 /// </summary> public void LoadGetUrlPara() { if (!string.IsNullOrEmpty(RequestQueryString.GetQueryString("MessageType"))) { MessageType = ConvertHelper.ConvertLong(RequestQueryString.GetQueryString("MessageType")); } if (!string.IsNullOrEmpty(RequestQueryString.GetQueryString("MessageID"))) { MessageID = ConvertHelper.ConvertLong(RequestQueryString.GetQueryString("MessageID")); } }
/// <summary> /// 获得URL参数 /// </summary> public void LoadGetUrlPara() { if (!string.IsNullOrEmpty(RequestQueryString.GetQueryString("InfoCategoryID"))) { InfoCategoryID = RequestQueryString.GetQueryString("InfoCategoryID").ToString(); } if (!string.IsNullOrEmpty(RequestQueryString.GetQueryString("type"))) { type = ConvertHelper.ConvertString(RequestQueryString.GetQueryString("type")); } }
public override int GetHashCode() { unchecked { int hashCode = (ETag != null ? ETag.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (RequestPath != null ? RequestPath.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (RequestQueryString != null ? RequestQueryString.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (RequestMethod != null ? RequestMethod.GetHashCode() : 0); return(hashCode); } }
public IActionResult QueryParser() { var q = new RequestQueryString(); if (Request.Query.ContainsKey("q")) { q.Load(Request.Query["q"].ToString()); } return(Json(q)); }
/// <summary> /// 获得URL参数 /// </summary> public void LoadGetUrlPara() { if (!string.IsNullOrEmpty(RequestQueryString.GetQueryString("InfoCategoryID"))) { InfoCategoryID = ConvertHelper.ConvertLong(RequestQueryString.GetQueryString("InfoCategoryID")); } if (!string.IsNullOrEmpty(RequestQueryString.GetQueryString("CategoryID"))) { CategoryID = ConvertHelper.ConvertLong(RequestQueryString.GetQueryString("CategoryID")); } }
private void BuildActions() { var q = new RequestQueryString(); q.EntityId = this.FormContext.Entity.EntityId; if (this.FormContext.Context.UserInfo.HasAccess(this.FormContext.Entity.EntityId, AccessType.Create)) { var newAction = PageActionCreator.Create(new ActionContext(this.FormContext, ActionType.New, "NEW") { Query = q }); this.FormContext.Actions.Add(newAction); } }
private ViewPage BuildRefForm(StackAppContext appContext, EntityCode refEntity) { var q = new RequestQueryString(); q.EntityId = refEntity; var context = new EditFormContext(appContext, refEntity, q); context.Build(); var builder = new PageBuilder.EntityPageBuilder(); var page = builder.CreateNewPage(context); return(page); }
public override void OnActionExecuting(Microsoft.AspNetCore.Mvc.Filters.ActionExecutingContext context) { RequestQuery = GetQuery(); if (HttpContext.Session.Keys.Count() == 0) { if (HttpContext.User.Identity != null && HttpContext.User.Identity.IsAuthenticated) { var cl = HttpContext.User.Claims.Where(c => c.Type == ClaimTypes.Sid); if (cl.Count() > 0) { (new Web.AuthService()).PrepareUserSession(int.Parse(cl.First().Value), HttpContext); if (HttpContext.Session.IsAvailable) { WebAppContext = (new Web.AuthService()).GetAppContext(_appSetting, HttpContext); WebAppContext.AppRoot = Url.Content("~/"); WebAppContext.RequestQuery = RequestQuery; } } else { (new Web.AuthService()).Logout(HttpContext); context.Result = RedirectToAction("Login", "Auth", new { isLogout = true }); } } else { (new Web.AuthService()).Logout(HttpContext); context.Result = RedirectToAction("Login", "Auth", new { isLogout = true }); } } else { if (HttpContext.Session.IsAvailable) { WebAppContext = (new Web.AuthService()).GetAppContext(_appSetting, HttpContext); WebAppContext.AppRoot = Url.Content("~/"); WebAppContext.RequestQuery = RequestQuery; } WebAppContext.RequestQuery = RequestQuery; } }
public static ActionInfo BuildActionFromDefinition(ActionLinkDefinition definition, FormContext context) { string url = definition.Action; if (definition.ActionType == ActionType.Function) { url = ""; } if (definition.ActionType != ActionType.Page) { url = GetUrlFromActionType(definition.ActionType); } url = string.Format("{0}{1}", context.Context.AppRoot, url); var q = context.RequestQuery.Clone(); if (definition.QueryParam != null && definition.QueryParam.Count > 0) { q = new RequestQueryString(); foreach (var p in definition.QueryParam) { q.Add(p.Name, ValueResolver.ResolveValue(context, p.Value).ToString()); } } var actionI = new ActionInfo(url, q, definition.ActionId); actionI.Title = definition.Text; actionI.ActionType = definition.ActionType; actionI.ExecutionType = definition.ExecType; if (definition.ActionType == ActionType.Function) { actionI.AddAttribute("Function", definition.Action); actionI.ExecutionType = ActionExecutionType.Custom; } return(actionI); }
public static ActionResponse SaveLayout(StackAppContext appContext, RequestQueryString requestQuery, JObject data) { var view = data["Layout"].ToObject <TView>(); if (view != null) { var tFields = data["Fields"].ToObject <List <TField> >(); view.Fields = tFields; view.ClearBlankRows(); var entity = EntityMetaData.GetAs <EntityLayoutEntity>(EntityCode.EntityLayout); var sts = entity.SaveLayoutData(appContext, requestQuery, view); if (sts == AnyStatus.Success) { var res = new SubmitActionResponse(null) { Status = SubmitStatus.Success, Message = "Layout saved successfully" }; return(res); } else { return(new ErrorResponse(null) { Message = sts.Message }); } } return(new ErrorResponse(null) { Message = "Invalid parameters." }); }
public SubmitActionResponse GetSaveAction(RequestQueryString requestQuery, UIFormModel model) { var context = new EditFormContext(_AppContext, requestQuery.EntityId, requestQuery); context.Build(model); var generator = new EntityModelGenerator(context); generator.Generate(model); var response = new SubmitActionResponse(null); response.Status = SubmitStatus.Fail; if (generator.Status == AnyStatus.Success) { var recordModel = generator.RecordModel; var saveStatus = context.Entity.Save(_AppContext, recordModel); if (saveStatus == AnyStatus.Success) { response.Status = SubmitStatus.Success; response.RedirectUrl = AppLinkProvider.GetDetailPageLink(recordModel.EntityId, recordModel.ID).Url; return(response); } else if (saveStatus == AnyStatus.InvalidData) { PrepareErrorModel(recordModel, ref model); response.Model = model; return(response); } response.Message = saveStatus.Message; return(response); } response.Message = generator.Status.Message; return(response); }
protected RequestQueryString GetQuery() { var q = new RequestQueryString(); // if (Request.Query.ContainsKey("entity")) // { // q.EntityId = EntityCode.Get(Request.Query["entity"].ToString()); // } // if (Request.Query.ContainsKey("itemid")) // { // q.ItemId = Convert.ToInt32(Request.Query["itemid"]); // } if (Request.Query.ContainsKey("q")) { q.Load(Request.Query["q"].ToString()); } else if (Request.Query.ContainsKey("qx")) { q.LoadNonEncrypt(Request.Query["qx"].ToString()); } return(q); }
public virtual ViewPage GetPage(RequestQueryString reqQuery) { View.CurrentQuery = reqQuery.ToQueryString(); return(this.View); }
public PickerListContext(StackAppContext context, RequestQueryString query, ListRequestinfo requestInfo) : base(context, query, requestInfo) { }
private static object GetRequestQueryValue(RequestQueryString requestQuery, string key) { return(requestQuery.GetData(key)); }
public EditFormContext(StackAppContext context, EntityCode entity, RequestQueryString requestQuery) : base(context, entity, requestQuery) { this.Entity = (IDBEntity)Core.EntityMetaData.Get(entity); this.EntityLayoutType = EntityLayoutType.Edit; }
public RelatedEntityListContext(StackAppContext context, RequestQueryString query, ListRequestinfo requestInfo) : base(context, query, requestInfo) { }
public DetailFormContext(StackAppContext context, EntityCode entity, RequestQueryString requestQuery) : base(context, entity, requestQuery) { this.Entity = (IDBEntity)Core.EntityMetaData.Get(entity); IsViewMode = true; this.EntityLayoutType = EntityLayoutType.View; }
public DeskPageContext(StackAppContext context, EntityCode entity, RequestQueryString requestQuery) : base(context, entity, requestQuery) { this.Entity = (IDBEntity)Core.EntityMetaData.Get(entity); IsViewMode = true; }