/// <summary> /// Updates the specified entity. /// Obtaines the page and entity info from the request. /// </summary> /// <param name="request">The request</param> /// <returns>a JSON response</returns> public virtual string UpdatePageEntity(HttpRequest request) { LoggerHelper.Info("Start"); Entity entity = null; try { Page page = GetPage(request); entity = CreateEntity(request, page); Entity whereEntity = null; string json = request.Params[PageInfo.WhereEntityParam]; LoggerHelper.Debug("whereEntity = " + json); if (!string.IsNullOrEmpty(json)) { whereEntity = EntityUtils.CreateEntity(page, false); Dictionary <string, string> props = new JavaScriptSerializer().Deserialize <Dictionary <string, string> >(json); whereEntity.SetProperties(props); } GetCatalogDAO(page).UpdateEntity(entity, whereEntity); } catch (Exception e) { LoggerHelper.Error(e); return(ErrorResponse(e)); } finally { LoggerHelper.Info("End"); } return(SuccessResponse(entity)); }
/// <summary> /// Creates an entity from the specified page and sets the entity date from the request if any. /// </summary> /// <param name="request">The HttpRequest</param> /// <param name="page">The page configuration</param> /// <param name="csv">signals if the entity will include exportable fields</param> /// <returns>The entity</returns> protected virtual Entity CreateEntity(HttpRequest request, Page page, bool csv) { Entity entity = EntityUtils.CreateEntity(page, csv); string json = request.Params[PageInfo.EntityParam]; LoggerHelper.Debug("entity = " + json); if (!String.IsNullOrEmpty(json)) { Dictionary <string, string> props = new JavaScriptSerializer().Deserialize <Dictionary <string, string> >(json); entity.SetProperties(props); } return(entity); }
private Entity GetTemplate(HttpRequest request) { string templateName = request.Params["templateName"]; string templateType = request.Params["templateType"]; IPageInfoDAO pageDAO = (IPageInfoDAO)FactoryUtils.GetDAO(ConfigurationManager.AppSettings["IPageInfoDAO"]); EPE.Common.Entities.Page.Page pageLetter = pageDAO.GetPageConfig("", "Templates"); Entity entityLetter = EntityUtils.CreateEntity(pageLetter); entityLetter.SetProperty("TemplateName", templateName); entityLetter.SetProperty("TemplateTypeText", templateType); IList <Entity> templates = DAOFactory.Instance.GetCatalogDAO().FindEntities(entityLetter, FilterInfo.SearchType.AND); return(templates[0]); }
private bool ValidateUser(string userName, string passWord) { EPE.Common.Entities.Page.Page usersPage = DAOFactory.Instance.GetPageInfoDAO().GetPageConfig("", "Users"); Entity entity = EntityUtils.CreateEntity(usersPage); entity.SetProperty("USE_Login", userName); entity.SetProperty("USE_Password", passWord); IList <Entity> list = DAOFactory.Instance.GetCatalogDAO().FindEntities(entity, FilterInfo.SearchType.AND); if (list.Count == 1) { Session["CurrentUser"] = list[0]; Session["CurrentUserLogin"] = userName; return(true); } return(false); }
private Entity GetUser(string userLogin) { if (string.IsNullOrEmpty(userLogin)) { return(null); } if (Session["CurrentUser"] == null) { EPE.Common.Entities.Page.Page usersPage = DAOFactory.Instance.GetPageInfoDAO().GetPageConfig("", "Users"); Entity entity = EntityUtils.CreateEntity(usersPage); entity.SetProperty("USE_Login", userLogin); IList <Entity> list = DAOFactory.Instance.GetCatalogDAO().FindEntities(entity); if (list.Count == 1) { Session["CurrentUser"] = list[0]; Entity user = (Entity)Session["CurrentUser"]; Session["CurrentUserName"] = user.GetProperty("USE_Name"); } } return((Entity)Session["CurrentUser"]); }