private TransportBase CreateTransportObject(CrudCr info) { var transport = new TreeViewTransport(); if (string.IsNullOrEmpty(info.Read.Url)) { var _constantService = Cmn.AppBase.DependencyInjectionManager.Resolve <Service.IConstantService>(); var msg = string.Empty; _constantService.TryGetValue <string>("URLCanNotBeEmpty", out msg); throw new Exception(msg /*Core.Resources.ExceptionMessage.URLCanNotBeEmpty*/); } transport.Read.Url = info.Read.Url; if (!string.IsNullOrEmpty(info.Read.Data)) { transport.Read.Data = new Kendo.Mvc.ClientHandlerDescriptor { HandlerName = info.Read.Data }; } transport.Create.Url = string.IsNullOrEmpty(info.Insert.Url) ? transport.Read.Url : info.Insert.Url; transport.Update.Url = string.IsNullOrEmpty(info.Update.Url) ? transport.Read.Url : info.Update.Url; transport.Destroy.Url = string.IsNullOrEmpty(info.Remove.Url) ? transport.Read.Url : info.Remove.Url; return(transport); }
public DsConfig() { ModelCr = new ModelCr(); //SchemaCr = schemaCr; CrudCr = new CrudCr(); ServerRelated = new ServerRelInfo(); }
public static void DefineCrudActionAuthority(AccessOperation crudOpt, CrudCr crudInfo) { if (!System.Web.HttpContext.Current.User.Identity.IsAuthenticated) { //object area = null; //var tokens = System.Web.HttpContext.Current.Request.RequestContext.RouteData.DataTokens; //if (tokens.TryGetValue("area", out area) ) //{ var response = System.Web.HttpContext.Current.Response; response.Clear(); response.StatusCode = 403;//forbidden //} //else //{ // FormsAuthentication.RedirectToLoginPage(); //} return; } else { var currentUserId = CustomMembershipProvider.GetUserIdCookie() ?? 0; var readUrl = crudInfo.Read.Url.ToLower(); if (readUrl.StartsWith("api/") || readUrl.StartsWith("/api/")) { var originalUrl = readUrl.Split('/'); var actualUrlName = string.Empty; //has Area Name if (originalUrl.Length == 3) { if (originalUrl[2].ToLower().Equals("getentities")) { actualUrlName = originalUrl[0] + "/" + originalUrl[1]; } else { actualUrlName = originalUrl[1] + "/" + originalUrl[2]; } } else { if (originalUrl.Length == 4) { actualUrlName = originalUrl[1] + "/" + originalUrl[2]; } else { actualUrlName = originalUrl[1]; } } if (crudOpt.Insertable) { var insertUrl = string.IsNullOrEmpty(crudInfo.Insert.Url) ? actualUrlName + "/PostEntity" : crudInfo.Insert.Url; crudOpt.Insertable = AppBase.HasCurrentUserAccess(currentUserId, insertUrl); } if (crudOpt.Updatable) { var updateUrl = string.IsNullOrEmpty(crudInfo.Update.Url) ? actualUrlName + "/PutEntity" : crudInfo.Update.Url; crudOpt.Updatable = AppBase.HasCurrentUserAccess(currentUserId, updateUrl); } if (crudOpt.Removable) { var removeUrl = string.IsNullOrEmpty(crudInfo.Remove.Url) ? actualUrlName + "/DeleteEntity" : crudInfo.Remove.Url; crudOpt.Removable = AppBase.HasCurrentUserAccess(currentUserId, removeUrl); } } else { // Must be implemented for classical controller. throw new NotImplementedException(); } } }