private void DisplayGrid() { PagingInfo page; dvAddNewActivityType.Visible = false; dvActivityGrid.Visible = true; AddToolbar("viewgrid", 0); Ektron.Cms.Activity.ActivityTypeCriteria criteria = new Ektron.Cms.Activity.ActivityTypeCriteria(); page = new PagingInfo(); page.CurrentPage = _currentPageNumber; criteria.PagingInfo = page; criteria.PagingInfo.RecordsPerPage = _refContentApi.RequestInformationRef.PagingSize; activityTypeList = _activityTypeApi.GetList(criteria); TotalPagesNumber = page.TotalPages; // old code PageSettings(); if ((activityTypeList != null) && activityTypeList.Count > 0) { ActivityGrid.Columns.Clear(); ActivityGrid.Columns.Add(_refStyle.CreateBoundField("NAME", msgHelper.GetMessage("generic name"), "title-header", HorizontalAlign.Left, HorizontalAlign.NotSet, Unit.Percentage(20), Unit.Percentage(20), false, false)); ActivityGrid.Columns.Add(_refStyle.CreateBoundField("ID", msgHelper.GetMessage("generic id"), "title-header", HorizontalAlign.Left, HorizontalAlign.NotSet, Unit.Percentage(5), Unit.Percentage(5), false, false)); ActivityGrid.Columns.Add(_refStyle.CreateBoundField("ACTIONTYPE", msgHelper.GetMessage("lbl action type"), "title-header", HorizontalAlign.Left, HorizontalAlign.NotSet, Unit.Percentage(9), Unit.Percentage(6), false, false)); ActivityGrid.Columns.Add(_refStyle.CreateBoundField("OBJECTTYPE", msgHelper.GetMessage("lbl object type"), "title-header", HorizontalAlign.Left, HorizontalAlign.NotSet, Unit.Percentage(11), Unit.Percentage(8), false, false)); ActivityGrid.Columns.Add(_refStyle.CreateBoundField("SCOPE", msgHelper.GetMessage("lbl action scope"), "title-header", HorizontalAlign.Left, HorizontalAlign.NotSet, Unit.Percentage(11), Unit.Percentage(11), false, false)); DataTable dt = new DataTable(); DataRow dr; dt.Columns.Add(new DataColumn("NAME", typeof(string))); dt.Columns.Add(new DataColumn("ID", typeof(string))); dt.Columns.Add(new DataColumn("ACTIONTYPE", typeof(string))); dt.Columns.Add(new DataColumn("OBJECTTYPE", typeof(string))); dt.Columns.Add(new DataColumn("SCOPE", typeof(string))); for (int i = 0; i <= activityTypeList.Count - 1; i++) { dr = dt.NewRow(); dr["NAME"] = "<a href=\"activitytypes.aspx?mode=view&id=" + activityTypeList[i].Id + "\">" + GetResourceText(activityTypeList[i].Name) + "</a>"; dr["ID"] = activityTypeList[i].Id.ToString(); dr["ACTIONTYPE"] = GetResourceText(activityTypeList[i].ActionType.ToString()); dr["OBJECTTYPE"] = GetResourceText(activityTypeList[i].ObjectType.ToString()); dr["SCOPE"] = GetResourceText(activityTypeList[i].Scope.ToString()); dt.Rows.Add(dr); } DataView dv = new DataView(dt); ActivityGrid.DataSource = dv; ActivityGrid.DataBind(); } }
private void UpdateActivityPreferences() { Ektron.Cms.Activity.ActivityTypeCriteria activityCollListCriteria = new Ektron.Cms.Activity.ActivityTypeCriteria(); Ektron.Cms.Activity.ActivityTypeCriteria activityGroupListCriteria = new Ektron.Cms.Activity.ActivityTypeCriteria(); long uId = 0; if ((!(Request.QueryString["id"] == null)) && Information.IsNumeric(Request.QueryString["id"])) { long.TryParse(Request.QueryString["id"], out uId); } activityCollListCriteria.AddFilter(Ektron.Cms.Activity.ActivityTypeProperty.Scope, CriteriaFilterOperator.EqualTo, EkEnumeration.ActivityActionSource.Colleague); activityGroupListCriteria.AddFilter(Ektron.Cms.Activity.ActivityTypeProperty.Scope, CriteriaFilterOperator.EqualTo, EkEnumeration.ActivityActionSource.CommunityGroup); collActivityTypeList = _activityListApi.GetList(activityCollListCriteria); groupActivityTypeList = _activityListApi.GetList(activityGroupListCriteria); if (uId > 0) { //Colleague Preferences preferenceList = new System.Collections.Generic.List<NotificationPreferenceData>(); preferenceList.Clear(); for (int i = 0; i <= collActivityTypeList.Count - 1; i++) { if ((Page.Request.Form["email" + collActivityTypeList[i].Id] != null) && Page.Request.Form["email" + collActivityTypeList[i].Id] == "on") { prefData = new NotificationPreferenceData(); prefData.ActivityTypeId = collActivityTypeList[i].Id; prefData.AgentId = 1; prefData.UserId = uId; preferenceList.Add(prefData); } else { prefData = new NotificationPreferenceData(); prefData.ActivityTypeId = collActivityTypeList[i].Id; prefData.DataState = Ektron.Cms.Common.EkEnumeration.DataState.Deleted; prefData.AgentId = 1; prefData.UserId = uId; preferenceList.Add(prefData); } if ((Page.Request.Form["sms" + collActivityTypeList[i].Id] != null) && Page.Request.Form["sms" + collActivityTypeList[i].Id] == "on") { prefData = new NotificationPreferenceData(); prefData.ActivityTypeId = collActivityTypeList[i].Id; prefData.AgentId = 3; prefData.UserId = uId; preferenceList.Add(prefData); } else { prefData = new NotificationPreferenceData(); prefData.ActivityTypeId = collActivityTypeList[i].Id; prefData.DataState = Ektron.Cms.Common.EkEnumeration.DataState.Deleted; prefData.AgentId = 3; prefData.UserId = uId; preferenceList.Add(prefData); } if ((Page.Request.Form["feed" + collActivityTypeList[i].Id] != null) && Page.Request.Form["feed" + collActivityTypeList[i].Id] == "on") { prefData = new NotificationPreferenceData(); prefData.ActivityTypeId = collActivityTypeList[i].Id; prefData.AgentId = 2; prefData.UserId = uId; preferenceList.Add(prefData); } else { prefData = new NotificationPreferenceData(); prefData.ActivityTypeId = collActivityTypeList[i].Id; prefData.DataState = Ektron.Cms.Common.EkEnumeration.DataState.Deleted; prefData.AgentId = 2; prefData.UserId = uId; preferenceList.Add(prefData); } } //Group Preferences for (int i = 0; i <= groupActivityTypeList.Count - 1; i++) { if ((Page.Request.Form["email" + groupActivityTypeList[i].Id] != null) && Page.Request.Form["email" + groupActivityTypeList[i].Id] == "on") { prefData = new NotificationPreferenceData(); prefData.ActivityTypeId = groupActivityTypeList[i].Id; prefData.AgentId = 1; prefData.UserId = uId; prefData.ActionSourceId = -1; preferenceList.Add(prefData); } else { prefData = new NotificationPreferenceData(); prefData.ActivityTypeId = groupActivityTypeList[i].Id; prefData.DataState = Ektron.Cms.Common.EkEnumeration.DataState.Deleted; prefData.AgentId = 1; prefData.UserId = uId; prefData.ActionSourceId = -1; preferenceList.Add(prefData); } if ((Page.Request.Form["feed" + groupActivityTypeList[i].Id] != null) && Page.Request.Form["feed" + groupActivityTypeList[i].Id] == "on") { prefData = new NotificationPreferenceData(); prefData.ActivityTypeId = groupActivityTypeList[i].Id; prefData.AgentId = 2; prefData.UserId = uId; prefData.ActionSourceId = -1; preferenceList.Add(prefData); } else { prefData = new NotificationPreferenceData(); prefData.ActivityTypeId = groupActivityTypeList[i].Id; prefData.DataState = Ektron.Cms.Common.EkEnumeration.DataState.Deleted; prefData.AgentId = 2; prefData.UserId = uId; prefData.ActionSourceId = -1; preferenceList.Add(prefData); } if ((Page.Request.Form["sms" + groupActivityTypeList[i].Id] != null) && Page.Request.Form["sms" + groupActivityTypeList[i].Id] == "on") { prefData = new NotificationPreferenceData(); prefData.ActivityTypeId = groupActivityTypeList[i].Id; prefData.AgentId = 3; prefData.UserId = uId; prefData.ActionSourceId = -1; preferenceList.Add(prefData); } else { prefData = new NotificationPreferenceData(); prefData.ActivityTypeId = groupActivityTypeList[i].Id; prefData.DataState = Ektron.Cms.Common.EkEnumeration.DataState.Deleted; prefData.AgentId = 3; prefData.UserId = uId; prefData.ActionSourceId = -1; preferenceList.Add(prefData); } } _notificationPreferenceApi.SaveUserPreferences(preferenceList); } }