protected override void OnInit(EventArgs e) { base.OnInit(e); // Check if revisit is valid or not if (!base.IsPostBack) { ANO_User cooike = ANOProfile.GetCookieValues(HttpContext.Current.Request.UserHostAddress); if (cooike != null) { if (!ActionValidator.IsValid(ActionValidator.ActionTypeEnum.ReVisit)) { Response.End(); } } else { if (!ActionValidator.IsValid(ActionValidator.ActionTypeEnum.FirstVisit)) { Response.End(); } } } else { // Limit number of postbacks if (!ActionValidator.IsValid(ActionValidator.ActionTypeEnum.Postback)) { Response.End(); } } }
void WidgetDataList_ItemCommand(object source, DataListCommandEventArgs e) { if (!ActionValidator.IsValid(ActionValidator.ActionTypeEnum.AddNewWidget)) { return; } int widgetId = int.Parse(e.CommandArgument.ToString()); //DashboardFacade facade = new DashboardFacade(HttpContext.Current.Profile.UserName); //User added a new widget. The new widget is loaded for the first time. So, it's not //a postback experience for the widget. But for rest of the widgets, it is a postback experience. WidgetInstance widgetInstance; var facade = Services.Get <Facade>(); { widgetInstance = facade.AddWidgetInstance(widgetId, 0, 0, 0); } // -- Workflow way. Obselete. //var response = WorkflowHelper.Run<AddWidgetWorkflow,AddWidgetRequest,AddWidgetResponse>( // new AddWidgetRequest { WidgetId = widgetId, RowNo = 0, ColumnNo = 0, ZoneId = 0, UserName = Profile.UserName } // ); //widgetRefreshCallback(response.WidgetInstanceAffected); widgetRefreshCallback(widgetInstance); }
public void AddWidgetInstanceByObjectType(string objectId, string objectType, string pageId, int column, int row) { if (ActionValidator.IsValid(ActionValidator.ActionTypeEnum.AddNewWidget)) { Guid communityId = DataAccess.Business.Utils.GetCommunityIdFromPage(pageId.ToGuid()); if ((DataObject.GetUserAccess(UserDataContext.GetUserDataContext(), communityId, communityId, Common.Helper.GetObjectTypeNumericID("Community")) & ObjectAccessRight.Update) == ObjectAccessRight.Update) { Guid widgetId = Common.Helper.GetObjectType(objectType).DetailWidgetId; WidgetElement widget = WidgetSection.CachedInstance.Widgets.Cast <WidgetElement>().Where(w => w.Id == widgetId).Single(); HitblWidgetInstanceIn widgetInstance = new HitblWidgetInstanceIn(); widgetInstance.InsId = Guid.NewGuid(); widgetInstance.InsColumnNo = column; widgetInstance.InsCreatedDate = widgetInstance.InsLastUpdate = DateTime.Now; widgetInstance.InsShowAfterInsert = 0; widgetInstance.InsOrderNo = row; widgetInstance.InsPagId = new Guid(pageId); widgetInstance.InsXmlStateData = string.Format("<root><ObjectType>{0}</ObjectType><ByUrl>False</ByUrl><Source>-1</Source><ObjectID>{1}</ObjectID></root>", Common.Helper.GetObjectType(objectType).Id, objectId); widgetInstance.WdgId = widgetId; widgetInstance.WtpId = Constants.DEFAULT_LAYOUTID.ToGuid(); widgetInstance.InsHideIfNoContent = true; if (!string.IsNullOrEmpty(widget.OutputTemplates)) { string[] outputTemplates = widget.OutputTemplates.Split(';'); widgetInstance.InsOutputTemplate = outputTemplates[0].ToGuid(); } widgetInstance.Save(); HitblWidgetInstanceTextWit widgetInstanceText = new HitblWidgetInstanceTextWit(); widgetInstanceText.InsId = widgetInstance.InsId; widgetInstanceText.WitLangCode = "de-CH"; widgetInstanceText.WitTitle = "##OBJ_TITLE##"; widgetInstanceText.Save(); SPs.HispWidgetInstanceReorderByPageColumn(new Guid(pageId), widgetInstance.InsColumnNo).Execute(); } } }
/// <summary> /// Override the OnInit behavior to load the current user's pages and widgets. This /// needs to be done in OnInit, not on Page_Load because the ASP.NET control tree /// is prepared after this and we need to create the widgets as dynamic controls. /// So, we need to load the widgets and pages before the control tree creation starts. /// </summary> /// <param name="e"></param> protected override void OnInit(EventArgs e) { base.OnInit(e); //AspectF.Define // .Log(Services.Get<ILogger>(), "OnInit: " + Profile.UserName) // .Retry(errors => errors.ToArray().Each(x => ErrorOnPage.InnerText += x.ToString()), Services.Get<ILogger>()) // .Do(() => // { // Check if revisit is valid or not if (!base.IsPostBack) { // Block cookie less visit attempts if (Profile.IsFirstVisit) { if (!ActionValidator.IsValid(ActionValidator.ActionTypeEnum.FirstVisit)) { Stop(); } } else { if (!ActionValidator.IsValid(ActionValidator.ActionTypeEnum.Revisit)) { Stop(); } } } else { // Limit number of postbacks if (!ActionValidator.IsValid(ActionValidator.ActionTypeEnum.Postback)) { Stop(); } } //}); }
public void AddWidgetInstance(string widgetId, string pageId, int column, int row) { if (ActionValidator.IsValid(ActionValidator.ActionTypeEnum.AddNewWidget)) { Guid communityId = DataAccess.Business.Utils.GetCommunityIdFromPage(pageId.ToGuid()); if ((DataObject.GetUserAccess(UserDataContext.GetUserDataContext(), communityId, communityId, Common.Helper.GetObjectTypeNumericID("Community")) & ObjectAccessRight.Update) == ObjectAccessRight.Update) { WidgetElement widget = WidgetSection.CachedInstance.Widgets.Cast <WidgetElement>().Where(w => w.Id == widgetId.ToGuid()).Single(); HitblWidgetInstanceIn widgetInstance = new HitblWidgetInstanceIn(); widgetInstance.InsId = Guid.NewGuid(); widgetInstance.InsColumnNo = column; widgetInstance.InsCreatedDate = widgetInstance.InsLastUpdate = DateTime.Now; widgetInstance.InsShowAfterInsert = (int)widget.ShowAfterInsert; widgetInstance.InsOrderNo = row; widgetInstance.InsPagId = new Guid(pageId); widgetInstance.InsXmlStateData = widget.Settings.Value; widgetInstance.WdgId = widgetId.ToGuid(); widgetInstance.WtpId = Constants.DEFAULT_LAYOUTID.ToGuid(); widgetInstance.InsHideIfNoContent = true; if (!string.IsNullOrEmpty(widget.OutputTemplates)) { string[] outputTemplates = widget.OutputTemplates.Split(';'); widgetInstance.InsOutputTemplate = outputTemplates[0].ToGuid(); } widgetInstance.Save(); HitblWidgetInstanceTextWit widgetInstanceText = new HitblWidgetInstanceTextWit(); widgetInstanceText.InsId = widgetInstance.InsId; widgetInstanceText.WitLangCode = "de-CH"; widgetInstanceText.WitTitle = GuiLanguage.GetGuiLanguage(widget.LocalizationBaseFileName).GetString(widget.TitleKey); widgetInstanceText.Save(); SPs.HispWidgetInstanceReorderByPageColumn(new Guid(pageId), widgetInstance.InsColumnNo).Execute(); } } }