private List <GridAllowedRole> GetGridAllowedRoleFromAllowedRoleList(SerializableList <PageDefinition.AllowedRole> allowedRoles) { List <RoleInfo> list = Resource.ResourceAccess.GetDefaultRoleList(); List <GridAllowedRole> roles = (from r in list orderby r.Name select new GridAllowedRole { RoleId = r.RoleId, RoleName = new StringTT { Text = r.Name, Tooltip = r.Description } }).ToList(); if (allowedRoles != null) { foreach (PageDefinition.AllowedRole allowedRole in allowedRoles) { GridAllowedRole role = (from r in roles where r.RoleId == allowedRole.RoleId select r).FirstOrDefault(); if (role != null) { ObjectSupport.CopyData(allowedRole, role); } } } GridAllowedRole superuser = (from r in roles where r.RoleId == Resource.ResourceAccess.GetSuperuserRoleId() select r).First(); superuser.View = PageDefinition.AllowedEnum.Yes; superuser.Edit = PageDefinition.AllowedEnum.Yes; superuser.Remove = PageDefinition.AllowedEnum.Yes; superuser.__editable = false; return(roles); }
public async Task <ActionResult> SkinSelection_Partial(SkinSelectionModel model) { if (!ModelState.IsValid) { return(PartialView(model)); } SiteDefinition origSite = new SiteDefinition(); ObjectSupport.CopyData(Manager.CurrentSite, origSite); // make a copy of original site SiteDefinition site = Manager.CurrentSite; // update new settings site.BootstrapSkin = model.BootstrapSkin; site.jQueryUISkin = model.jQueryUISkin; site.KendoUISkin = model.KendoUISkin; ObjectSupport.ModelDisposition modelDisp = ObjectSupport.EvaluateModelChanges(origSite, site); switch (modelDisp) { default: case ObjectSupport.ModelDisposition.None: return(FormProcessed(model, this.__ResStr("okSaved", "Site settings updated"))); case ObjectSupport.ModelDisposition.PageReload: await site.SaveAsync(); return(FormProcessed(model, this.__ResStr("okSaved", "Site settings updated"), OnClose: OnCloseEnum.ReloadPage, OnPopupClose: OnPopupCloseEnum.ReloadParentPage, ForceRedirect: true)); case ObjectSupport.ModelDisposition.SiteRestart: await site.SaveAsync(); return(FormProcessed(model, this.__ResStr("okSavedRestart", "Site settings updated - These settings won't take effect until the site is restarted"))); } }
public async Task <ActionResult> SiteProperties_Partial(SitePropertiesModel model) { SiteDefinition origSite; if (model.SiteHost == null) { origSite = Manager.CurrentSite; } else { origSite = await SiteDefinition.LoadSiteDefinitionAsync(model.SiteHost); } if (!ModelState.IsValid) { return(PartialView(model)); } ObjectSupport.CopyDataFromOriginal(origSite, model.Site); await model.Site.SaveAsync(); ObjectSupport.ModelDisposition modelDisp = ObjectSupport.EvaluateModelChanges(origSite, model.Site); switch (modelDisp) { default: case ObjectSupport.ModelDisposition.None: return(FormProcessed(model, this.__ResStr("okSaved", "Site settings updated"))); case ObjectSupport.ModelDisposition.PageReload: return(FormProcessed(model, this.__ResStr("okSaved", "Site settings updated"), OnClose: OnCloseEnum.ReloadPage, OnPopupClose: OnPopupCloseEnum.ReloadParentPage, ForceRedirect: true)); case ObjectSupport.ModelDisposition.SiteRestart: return(FormProcessed(model, this.__ResStr("okSavedRestart", "Site settings updated - These settings won't take effect until the site is restarted"))); } }
public BlogComment GetData() { BlogComment data = new BlogComment(); ObjectSupport.CopyData(this, data); return(data); }
/// <summary> /// /// </summary> /// [Test] public void FindType() { ObjectSupport.LoadAssembly(Assembly.GetAssembly(this.GetType()).Location); Type type = ObjectSupport.GetType("Oatc.OpenMI.Sdk.DevelopmentSupport.UnitTest.Location"); Assert.AreEqual(typeof(Location), type); }
public SiteDefinition GetData() { SiteDefinition data = new SiteDefinition(); ObjectSupport.CopyData(this, data); return(data); }
internal async Task<string> RenderPropertyListAsync(object model, bool ReadOnly) { HtmlBuilder hb = new HtmlBuilder(); Type modelType = model.GetType(); ClassData classData = ObjectSupport.GetClassData(modelType); RenderHeader(hb, classData); bool showVariables = YetaWF.Core.Localize.UserSettings.GetProperty<bool>("ShowVariables"); // property table HtmlBuilder hbProps = new HtmlBuilder(); string divId = Manager.UniqueId(); hbProps.Append($@" <div id='{divId}' class='yt_propertylist {(ReadOnly ? "t_display" : "t_edit")}'> {await RenderHiddenAsync(model)} {await RenderListAsync(model, null, showVariables, ReadOnly)} </div>"); if (!string.IsNullOrWhiteSpace(classData.Legend)) { YTagBuilder tagFieldSet = new YTagBuilder("fieldset"); YTagBuilder tagLegend = new YTagBuilder("legend"); tagLegend.SetInnerText(classData.Legend); tagFieldSet.InnerHtml = tagLegend.ToString(YTagRenderMode.Normal) + hbProps.ToString(); hb.Append(tagFieldSet.ToString(YTagRenderMode.Normal)); } else { hb.Append(hbProps.ToString()); } RenderFooter(hb, classData); ControlData cd = GetControlSets(model, divId); Manager.ScriptManager.AddLast($@"new YetaWF_ComponentsHTML.PropertyListComponent('{divId}', {Utility.JsonSerialize(new PropertyList.PropertyListSetup())}, {Utility.JsonSerialize(cd)});"); return hb.ToString(); }
private MenuEntry GetMenuEntry(ModuleAction moduleAction) { MenuEntry entry = new MenuEntry(); ObjectSupport.CopyData(moduleAction, entry); return(entry); }
public async Task <ActionResult> IPAddressLookup(string ipAddress, bool geoData) { if (string.IsNullOrWhiteSpace(ipAddress)) { throw new InternalError("IP address not specified"); } Model model = new Model(); model.IPAddress = ipAddress; if (geoData) { GeoLocation geoLocation = new GeoLocation(); if (geoLocation.GetRemainingRequests() <= 0) { throw new Error(this.__ResStr("limitExceeded", "The current limit of geolocation requests per minute has been exceeded")); } GeoLocation.UserInfo info = await geoLocation.GetUserInfoAsync(ipAddress); ObjectSupport.CopyData(info, model); } try { IPHostEntry hostEntry = Dns.GetHostEntry(ipAddress); model.HostName = hostEntry.HostName; } catch { } return(View(model)); }
public RecaptchaV2Config GetData() { RecaptchaV2Config data = new RecaptchaV2Config(); ObjectSupport.CopyData(this, data); return(data); }
public void SetData(UserInfo userInfo) { ObjectSupport.CopyData(userInfo, this); if (AddressType == CountryISO3166.Country.US) { CityUS = userInfo.City; StateUS = userInfo.State; ZipUS = userInfo.Zip; } else if (AddressType == CountryISO3166.Country.Zip1) { CityZip1 = userInfo.City; ZipZip1 = userInfo.Zip; } else if (AddressType == CountryISO3166.Country.ZipLast) { CityZipLast = userInfo.City; ZipZipLast = userInfo.Zip; #if EXAMPLE } else if (AddressType == "DE") { CityDE = userInfo.City; ZipDE = userInfo.Zip; #endif } else { CityGeneric = userInfo.City; ZIPGeneric = userInfo.Zip; } }
public UserDefinition GetData() { UserDefinition data = new UserDefinition(); ObjectSupport.CopyData(this, data); return(data); }
public Entry(BlogEntry data, EntryDisplayModule dispMod, ModuleAction viewAction) { ObjectSupport.CopyData(data, this); ViewAction = viewAction; ViewAction.LinkText = Title; ViewAction.Tooltip = this.__ResStr("viewTT", "Published {0} - {1}", Formatting.FormatDate(data.DatePublished), data.DisplayableSummaryText); }
public Entry(BlogEntry data, EntryEditModule editMod, EntryDisplayModule dispMod, ModuleAction editAction, ModuleAction viewAction) { ObjectSupport.CopyData(data, this); ViewAction = viewAction; Actions = new List <ModuleAction>(); Actions.New(editAction); }
/// <summary> /// Install all events for the given object type. This is typically used to install scheduler items while installing packages. /// </summary> private async Task InstallItemsAsync(Type type) { string eventType = type.FullName + ", " + type.Assembly.GetName().Name; using (SchedulerDataProvider dataProvider = new SchedulerDataProvider()) { IScheduling schedEvt; try { schedEvt = (IScheduling)Activator.CreateInstance(type); } catch (Exception exc) { throw new InternalError("The specified object does not support the required IScheduling interface.", exc); } try { SchedulerItemBase[] items = schedEvt.GetItems(); foreach (var item in items) { SchedulerItemData evnt = new SchedulerItemData(); ObjectSupport.CopyData(item, evnt); evnt.Event.Name = item.EventName; evnt.Event.ImplementingAssembly = type.Assembly.GetName().Name; evnt.Event.ImplementingType = type.FullName; await dataProvider.AddItemAsync(evnt);// we ignore whether the add fails - it's OK if it already exists } } catch (Exception exc) { throw new InternalError("InstallEvents for the specified type {0} failed.", eventType, exc); } } }
public HolidayEntry GetData() { HolidayEntry data = new HolidayEntry(); ObjectSupport.CopyData(this, data); return(data); }
public async Task <ActionResult> PageEdit_Partial(EditModel model) { PageDefinition page = await PageDefinition.LoadAsync(model.PageGuid); if (page == null) { throw new Error(this.__ResStr("alreadyDeleted", "This page has been removed and can no longer be updated.")); } model.UpdateData(page); ObjectSupport.CopyData(page, model.Page, ReadOnly: true); // update read only properties in model in case there is an error model.Page.FavIcon_Data = page.FavIcon_Data; // copy favicon if (!ModelState.IsValid) { return(PartialView(model)); } page = model.GetData(page); // merge new data into original model.SetData(page); // and all the data back into model for final display await page.SaveAsync(); // this handles changing the Url automatically MenuList.ClearCachedMenus(); // page changes may affect all menus so clear the menu cache (this only clears current session) // if we're in a popup and the parent page is the page we're editing, then force a reload //$$$$ rename with querystring doesn't work OnPopupCloseEnum popupClose = OnPopupCloseEnum.ReloadModule; if (PageDefinition.IsSamePage(Manager.QueryReturnToUrl.Url, model.Page.Url)) { popupClose = OnPopupCloseEnum.ReloadParentPage; } return(FormProcessed(model, this.__ResStr("okSaved", "Page settings saved"), OnPopupClose: popupClose)); }
public SiteAnnouncement GetData() { SiteAnnouncement data = new SiteAnnouncement(); ObjectSupport.CopyData(this, data); return(data); }
private Task <string> GetHeaderAsync(TreeDefinition treeModel, List <TreeEntry> data, TreeSetup setup) { HtmlBuilder hb = new HtmlBuilder(); if (treeModel.ShowHeader) { PropertyData prop = ObjectSupport.GetPropertyData(treeModel.RecordType, nameof(TreeEntry.Text)); // Caption string caption = treeModel.Header.ToString(); if (string.IsNullOrWhiteSpace(caption)) { caption = prop.GetCaption(null); } // Description string description = treeModel.HeaderTooltip.ToString(); if (string.IsNullOrWhiteSpace(description)) { description = prop.GetDescription(null); } string alignCss = "tg_left"; // Render column header hb.Append($@" <div class='{alignCss} tg_header{(treeModel.UseSkinFormatting ? " ui-state-default" : "")}' {Basics.CssTooltip}='{HAE(description ?? "")}'> <span>{HE(caption)}</span> </div>"); } return(Task.FromResult(hb.ToString())); }
public async Task <ActionResult> UnifiedSetEdit_Partial(EditModel model) { using (UnifiedSetDataProvider unifiedSetDP = new UnifiedSetDataProvider()) { UnifiedSetData unifiedSet = await unifiedSetDP.GetItemAsync(model.UnifiedSetGuid);// get the original item if (unifiedSet == null) { throw new Error(this.__ResStr("alreadyDeleted", "The unified page set with id {0} has been removed and can no longer be updated", model.UnifiedSetGuid)); } ObjectSupport.CopyData(unifiedSet, model, ReadOnly: true); // update read only properties in model in case there is an error if (!ModelState.IsValid) { return(PartialView(model)); } unifiedSet = model.GetData(unifiedSet); // merge new data into original model.SetData(unifiedSet); // and all the data back into model for final display switch (await unifiedSetDP.UpdateItemAsync(unifiedSet)) { default: case UpdateStatusEnum.RecordDeleted: throw new Error(this.__ResStr("alreadyDeleted", "The unified page set with id {0} has been removed and can no longer be updated", model.UnifiedSetGuid)); case UpdateStatusEnum.NewKeyExists: ModelState.AddModelError(nameof(model.Name), this.__ResStr("alreadyExists", "An unified page set named \"{0}\" already exists", model.Name)); return(PartialView(model)); case UpdateStatusEnum.OK: break; } return(FormProcessed(model, this.__ResStr("okSaved", "Unified page set saved"), OnPopupClose: OnPopupCloseEnum.ReloadModule)); } }
public FeedbackData GetData() { FeedbackData data = new FeedbackData(); ObjectSupport.CopyData(this, data); return(data); }
public SchedulerItemData GetEvent() { SchedulerItemData evnt = new SchedulerItemData(); ObjectSupport.CopyData(this, evnt); return(evnt); }
public AddModel() { ObjectSupport.CopyData(new BlogComment(), this); Captcha = new RecaptchaV2Data() { }; }
// returns all properties for an object that have a description, in sorted order private IEnumerable <PropertyData> GetProperties(Type objType) { return(from property in ObjectSupport.GetPropertyData(objType) where property.Description != null // This means it has to be a DescriptionAttribute (not a resource redirect) orderby property.Order select property); }
public PackageModel(PackagesModule module, ModuleDefinition modLocalize, Package p) { Package = p; Module = module; ModLocalize = modLocalize; ObjectSupport.CopyData(p, this); }
/// <summary> /// Add all string properties of an object as search terms. /// </summary> public void AddObjectContents(object searchObject) { if (searchObject == null) { return; } Type tp = searchObject.GetType(); foreach (var propData in ObjectSupport.GetPropertyData(tp)) { if (propData.PropInfo.CanRead && propData.PropInfo.CanWrite) { if (propData.PropInfo.PropertyType == typeof(string)) { string s = (string)propData.PropInfo.GetValue(searchObject, null); AddContent(s); } else if (propData.PropInfo.PropertyType == typeof(MultiString)) { MultiString ms = (MultiString)propData.PropInfo.GetValue(searchObject, null); AddContent(ms); } } } }
public async Task <ActionResult> ControlPanelConfig_Partial(Model model) { using (ControlPanelConfigDataProvider dataProvider = new ControlPanelConfigDataProvider()) { ControlPanelConfigData origConfig = await dataProvider.GetItemAsync();// get the original item if (!ModelState.IsValid) { return(PartialView(model)); } ControlPanelConfigData config = await dataProvider.GetItemAsync(); config = model.GetData(config); // merge new data into config model.SetData(config); // and all the data back into model for final display await dataProvider.UpdateConfigAsync(config); ObjectSupport.ModelDisposition modelDisp = ObjectSupport.EvaluateModelChanges(origConfig, config); switch (modelDisp) { default: case ObjectSupport.ModelDisposition.None: return(FormProcessed(model, this.__ResStr("okSaved", "Control Panel settings saved"))); case ObjectSupport.ModelDisposition.PageReload: return(FormProcessed(model, this.__ResStr("okSaved", "Control Panel settings saved"), OnClose: OnCloseEnum.ReloadPage, OnPopupClose: OnPopupCloseEnum.ReloadParentPage, ForceRedirect: true)); case ObjectSupport.ModelDisposition.SiteRestart: return(FormProcessed(model, this.__ResStr("okSavedRestart", "Control Panel settings saved - These settings won't take effect until the site is restarted"))); } } }
public ExtensionEntry GetData() { ExtensionEntry data = new ExtensionEntry(); ObjectSupport.CopyData(this, data); return(data); }
public BlogEntry GetData() { BlogEntry data = new BlogEntry(); ObjectSupport.CopyData(this, data); return(data); }
public UnifiedSetData GetData() { UnifiedSetData unifiedSet = new UnifiedSetData(); ObjectSupport.CopyData(this, unifiedSet); return(unifiedSet); }