Beispiel #1
0
    private void LoadGrid(string display)
    {
        Ektron.Cms.Activity.ActivityTypeCriteria activityListCriteria = new Ektron.Cms.Activity.ActivityTypeCriteria();
            activityListCriteria.OrderByDirection = Ektron.Cms.Common.EkEnumeration.OrderByDirection.Ascending;

            if (display == "colleagues")
            {
                activityListCriteria.AddFilter(Ektron.Cms.Activity.ActivityTypeProperty.Scope, CriteriaFilterOperator.EqualTo, EkEnumeration.ActivityActionSource.Colleague);
            }
            else
            {
                activityListCriteria.AddFilter(Ektron.Cms.Activity.ActivityTypeProperty.Scope, CriteriaFilterOperator.EqualTo, EkEnumeration.ActivityActionSource.CommunityGroup);
            }
            activityTypeList = _activityListApi.GetList(activityListCriteria);

            System.Data.DataTable dt = new System.Data.DataTable();
            System.Data.DataRow dr;
            dt.Columns.Add(new System.Data.DataColumn("EMPTY", typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn("EMAIL", typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn("SMS", typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn("NEWSFEED", typeof(string)));
            LoadPreferenceList();
            for (int i = 0; i <= activityTypeList.Count - 1; i++)
            {
                dr = dt.NewRow();
                dr["EMPTY"] = GetResourceText(activityTypeList[i].Name);
                if (preferenceList.Count > 0)
                {
                    foreach (NotificationPreferenceData tempLoopVar_prefData in preferenceList)
                    {
                        prefData = tempLoopVar_prefData;
                        if (CompareIds(activityTypeList[i].Id, 1))
                        {
                            dr["EMAIL"] = "<center><input type=\"Checkbox\" name = \"email" + activityTypeList[i].Id + "\" id=\"email" + activityTypeList[i].Id + "\" checked=\"checked\" /></center>";
                        }
                        else
                        {
                            dr["EMAIL"] = "<center><input type=\"Checkbox\" name = \"email" + activityTypeList[i].Id + "\" id=\"email" + activityTypeList[i].Id + "\" /></center>";
                        }
                        if (CompareIds(activityTypeList[i].Id, 2))
                        {
                            dr["NEWSFEED"] = "<center><input type=\"Checkbox\" name=\"feed" + activityTypeList[i].Id + "\" id=\"feed" + activityTypeList[i].Id + "\" checked=\"checked\"  /></center>";
                        }
                        else
                        {
                            dr["NEWSFEED"] = "<center><input type=\"Checkbox\" name=\"feed" + activityTypeList[i].Id + "\" id=\"feed" + activityTypeList[i].Id + "\" /></center>";

                        }

                        if (CompareIds(activityTypeList[i].Id, 3))
                        {
                            dr["SMS"] = "<center><input type=\"Checkbox\" name =\"sms" + activityTypeList[i].Id + "\" id=\"sms" + activityTypeList[i].Id + "\" checked=\"checked\" /></center>";
                        }
                        else
                        {
                            dr["SMS"] = "<center><input type=\"Checkbox\" name =\"sms" + activityTypeList[i].Id + "\" id=\"sms" + activityTypeList[i].Id + "\" /></center>";
                        }

                    }
                    dt.Rows.Add(dr);
                }
                else
                {
                    dr["EMAIL"] = "<center><input type=\"Checkbox\" name = \"email" + activityTypeList[i].Id + "\" id=\"email" + activityTypeList[i].Id + "\"/></center>";
                    dr["SMS"] = "<center><input type=\"Checkbox\" name =\"sms" + activityTypeList[i].Id + "\" id=\"sms" + activityTypeList[i].Id + "\"/></center>";
                    dr["NEWSFEED"] = "<center><input type=\"Checkbox\" name=\"feed" + activityTypeList[i].Id + "\" id=\"feed" + activityTypeList[i].Id + "\"/></center>";
                    dt.Rows.Add(dr);
                }

            }
            System.Data.DataView dv = new System.Data.DataView(dt);
            if (display == "colleagues")
            {
                CollGrid.DataSource = dv;
                CollGrid.DataBind();
            }
            else
            {
                GroupGrid.DataSource = dv;
                GroupGrid.DataBind();
            }
    }
    private void DisplayGrid(string display, string mode)
    {
        NotificationAgentCriteria criteria = new NotificationAgentCriteria();
        Ektron.Cms.Activity.ActivityTypeCriteria activityListCriteria = new Ektron.Cms.Activity.ActivityTypeCriteria();
        activityListCriteria.OrderByDirection = Ektron.Cms.Common.EkEnumeration.OrderByDirection.Ascending;
        criteria.AddFilter(NotificationAgentProperty.IsEnabled, CriteriaFilterOperator.EqualTo, true);

        agentList = _notificationAgentApi.GetList(criteria);
        if ((agentList != null) && agentList.Count > 0)
        {
            if (display == "colleagues")
            {
                activityListCriteria.AddFilter(Ektron.Cms.Activity.ActivityTypeProperty.Scope, CriteriaFilterOperator.EqualTo, EkEnumeration.ActivityActionSource.Colleague);
            }
            else
            {
                activityListCriteria.AddFilter(Ektron.Cms.Activity.ActivityTypeProperty.Scope, CriteriaFilterOperator.EqualTo, EkEnumeration.ActivityActionSource.CommunityGroup);
            }
            activityTypeList = _activityListApi.GetList(activityListCriteria);
            DefaultPrefGrid.Columns.Clear();
            DefaultPrefGrid.Columns.Add(_refStyle.CreateBoundField("EMPTY", "", "title-header", HorizontalAlign.Left, HorizontalAlign.NotSet, Unit.Percentage(20), Unit.Percentage(20), false, false));

            foreach (NotificationAgentData agentData in agentList)
            {
                if (agentData.IsEnabled)
                {
                    if ((agentData.Id) == 1)
                    {
                        DefaultPrefGrid.Columns.Add(_refStyle.CreateBoundField("EMAIL", "<center>" + msgHelper.GetMessage("sync conflict email") + "</center>", "title-header", HorizontalAlign.Left, HorizontalAlign.NotSet, Unit.Percentage(10), Unit.Percentage(10), false, false));
                    }
                    else if ((agentData.Id) == 2)
                    {
                        DefaultPrefGrid.Columns.Add(_refStyle.CreateBoundField("NEWSFEED", "<center>" + msgHelper.GetMessage("colheader newsfeed") + "</center>", "title-header", HorizontalAlign.Left, HorizontalAlign.NotSet, Unit.Percentage(10), Unit.Percentage(10), false, false));
                    }
                    else if ((agentData.Id) == 3)
                    {
                        DefaultPrefGrid.Columns.Add(_refStyle.CreateBoundField("SMS", "<center>" + msgHelper.GetMessage("colheader sms") + "</center>", "title-header", HorizontalAlign.Left, HorizontalAlign.NotSet, Unit.Percentage(10), Unit.Percentage(10), false, false));
                    }
                }
            }
            DataTable dt = new DataTable();
            DataRow dr;
            dt.Columns.Add(new DataColumn("EMPTY", typeof(string)));
            dt.Columns.Add(new DataColumn("EMAIL", typeof(string)));
            dt.Columns.Add(new DataColumn("SMS", typeof(string)));
            dt.Columns.Add(new DataColumn("NEWSFEED", typeof(string)));
            LoadPreferenceList();
            for (int i = 0; i <= activityTypeList.Count - 1; i++)
            {
                dr = dt.NewRow();
                dr["EMPTY"] = GetMessageText(activityTypeList[i].Name);
                if (preferenceList.Count > 0)
                {
                    foreach (NotificationPreferenceData tempLoopVar_prefData in preferenceList)
                    {
                        prefData = tempLoopVar_prefData;
                        if (CompareIds(activityTypeList[i].Id, 1))
                        {
                            dr["EMAIL"] = "<center><input type=\"Checkbox\" name = \"email" + activityTypeList[i].Id + "\" id=\"email" + activityTypeList[i].Id + "\" checked=\"checked\"" + mode + " /></center>";
                        }
                        else
                        {
                            dr["EMAIL"] = "<center><input type=\"Checkbox\" name = \"email" + activityTypeList[i].Id + "\" id=\"email" + activityTypeList[i].Id + "\"" + mode + " /></center>";
                        }
                        if (CompareIds(activityTypeList[i].Id, 2))
                        {
                            dr["NEWSFEED"] = "<center><input type=\"Checkbox\" name=\"feed" + activityTypeList[i].Id + "\" id=\"feed" + activityTypeList[i].Id + "\" checked=\"checked\" " + mode + " /></center>";
                        }
                        else
                        {
                            dr["NEWSFEED"] = "<center><input type=\"Checkbox\" name=\"feed" + activityTypeList[i].Id + "\" id=\"feed" + activityTypeList[i].Id + "\"" + mode + " /></center>";

                        }

                        if (CompareIds(activityTypeList[i].Id, 3))
                        {
                            dr["SMS"] = "<center><input type=\"Checkbox\" name =\"sms" + activityTypeList[i].Id + "\" id=\"sms" + activityTypeList[i].Id + "\" checked=\"checked\"" + mode + " /></center>";
                        }
                        else
                        {
                            dr["SMS"] = "<center><input type=\"Checkbox\" name =\"sms" + activityTypeList[i].Id + "\" id=\"sms" + activityTypeList[i].Id + "\"" + mode + "/></center>";
                        }

                    }
                    dt.Rows.Add(dr);
                }
                else
                {
                    dr["EMAIL"] = "<center><input type=\"Checkbox\" name = \"email" + activityTypeList[i].Id + "\" id=\"email" + activityTypeList[i].Id + "\"/></center>";
                    dr["SMS"] = "<center><input type=\"Checkbox\" name =\"sms" + activityTypeList[i].Id + "\" id=\"sms" + activityTypeList[i].Id + "\"/></center>";
                    dr["NEWSFEED"] = "<center><input type=\"Checkbox\" name=\"feed" + activityTypeList[i].Id + "\" id=\"feed" + activityTypeList[i].Id + "\"/></center>";
                    dt.Rows.Add(dr);
                }
            }

            //get totalpages
            this.TotalPagesNumber = dt.Rows.Count / _refContentApi.RequestInformationRef.PagingSize;
            if (TotalPagesNumber * _refContentApi.RequestInformationRef.PagingSize < dt.Rows.Count)
            {
                TotalPagesNumber++;
            }
            PageSettings();

            DataView dv = new DataView(dt);
            DefaultPrefGrid.DataSource = dv;
            SetGridPagingProperties();
            DefaultPrefGrid.DataBind();
        }
        else
        {
            agentDisabled.Visible = true;
        }
    }
    private void EditSettings(string setting)
    {
        Ektron.Cms.Activity.ActivityTypeCriteria activityListCriteria = new Ektron.Cms.Activity.ActivityTypeCriteria();

        if (setting == "colleagues")
        {
            activityListCriteria.AddFilter(Ektron.Cms.Activity.ActivityTypeProperty.Scope, CriteriaFilterOperator.EqualTo, EkEnumeration.ActivityActionSource.Colleague);
        }
        else
        {
            activityListCriteria.AddFilter(Ektron.Cms.Activity.ActivityTypeProperty.Scope, CriteriaFilterOperator.EqualTo, EkEnumeration.ActivityActionSource.CommunityGroup);
        }
        activityTypeList = _activityListApi.GetList(activityListCriteria);
        LoadPreferenceList();
        if (Page.IsPostBack)
        {
            preferenceList.Clear();
            for (int i = 0; i <= activityTypeList.Count - 1; i++)
            {

                if ((Page.Request.Form["email" + activityTypeList[i].Id] != null) && Page.Request.Form["email" + activityTypeList[i].Id] == "on")
                {
                    prefData = new NotificationPreferenceData();
                    prefData.ActivityTypeId = activityTypeList[i].Id;
                    prefData.AgentId = 1;
                    prefData.UserId = -1;
                    preferenceList.Add(prefData);
                }
                else
                {
                    prefData = new NotificationPreferenceData();
                    prefData.ActivityTypeId = activityTypeList[i].Id;
                    prefData.DataState = Ektron.Cms.Common.EkEnumeration.DataState.Deleted;
                    prefData.AgentId = 1;
                    prefData.UserId = -1;
                    preferenceList.Add(prefData);
                }
                if ((Page.Request.Form["sms" + activityTypeList[i].Id] != null) && Page.Request.Form["sms" + activityTypeList[i].Id] == "on")
                {
                    prefData = new NotificationPreferenceData();
                    prefData.ActivityTypeId = activityTypeList[i].Id;
                    prefData.AgentId = 3;
                    prefData.UserId = -1;
                    preferenceList.Add(prefData);
                }
                else
                {
                    prefData = new NotificationPreferenceData();
                    prefData.ActivityTypeId = activityTypeList[i].Id;
                    prefData.DataState = Ektron.Cms.Common.EkEnumeration.DataState.Deleted;
                    prefData.AgentId = 3;
                    prefData.UserId = -1;
                    preferenceList.Add(prefData);
                }
                if ((Page.Request.Form["feed" + activityTypeList[i].Id] != null) && Page.Request.Form["feed" + activityTypeList[i].Id] == "on")
                {
                    prefData = new NotificationPreferenceData();
                    prefData.ActivityTypeId = activityTypeList[i].Id;
                    prefData.AgentId = 2;
                    prefData.UserId = -1;
                    preferenceList.Add(prefData);
                }
                else
                {
                    prefData = new NotificationPreferenceData();
                    prefData.ActivityTypeId = activityTypeList[i].Id;
                    prefData.DataState = Ektron.Cms.Common.EkEnumeration.DataState.Deleted;
                    prefData.AgentId = 2;
                    prefData.UserId = -1;
                    preferenceList.Add(prefData);
                }
            }
            _notificationPreferenceApi.SaveUserPreferences(preferenceList);
            if (setting == "colleagues")
            {
                Response.Redirect("DefaultNotificationPreferences.aspx?mode=colleagues");
            }
            else
            {
                Response.Redirect("DefaultNotificationPreferences.aspx?mode=groups");
            }
        }
        else
        {
            DisplayGrid(setting, "");
        }
    }
    private void EditGroupsSettings(long groupId)
    {
        Ektron.Cms.Activity.ActivityTypeCriteria activityListCriteria = new Ektron.Cms.Activity.ActivityTypeCriteria();
            activityListCriteria.AddFilter(Ektron.Cms.Activity.ActivityTypeProperty.Scope, CriteriaFilterOperator.EqualTo, EkEnumeration.ActivityActionSource.CommunityGroup);
            activityTypeList = _activityListApi.GetList(activityListCriteria);
            LoadPreferenceList(groupId);
            if (Page.IsPostBack)
            {
                preferenceList.Clear();
                for (int i = 0; i <= activityTypeList.Count - 1; i++)
                {

                    if ((Page.Request.Form["email" + activityTypeList[i].Id] != null)&& Page.Request.Form["email" + activityTypeList[i].Id] == "on")
                    {
                        prefData = new NotificationPreferenceData();
                        prefData.ActivityTypeId = activityTypeList[i].Id;
                        prefData.AgentId = 1;
                        prefData.UserId = _notificationPreferenceApi.RequestInformation.UserId;
                        prefData.ActionSourceId = groupId;
                        preferenceList.Add(prefData);
                    }
                    else
                    {
                        prefData = new NotificationPreferenceData();
                        prefData.ActivityTypeId = activityTypeList[i].Id;
                        prefData.DataState = Ektron.Cms.Common.EkEnumeration.DataState.Deleted;
                        prefData.AgentId = 1;
                        prefData.UserId = _notificationPreferenceApi.RequestInformation.UserId;
                        prefData.ActionSourceId = groupId;
                        preferenceList.Add(prefData);
                    }
                    if ((Page.Request.Form["sms" + activityTypeList[i].Id] != null)&& Page.Request.Form["sms" + activityTypeList[i].Id] == "on")
                    {
                        prefData = new NotificationPreferenceData();
                        prefData.ActivityTypeId = activityTypeList[i].Id;
                        prefData.AgentId = 3;
                        prefData.UserId = _notificationPreferenceApi.RequestInformation.UserId;
                        prefData.ActionSourceId = groupId;
                        preferenceList.Add(prefData);
                    }
                    else
                    {
                        prefData = new NotificationPreferenceData();
                        prefData.ActivityTypeId = activityTypeList[i].Id;
                        prefData.DataState = Ektron.Cms.Common.EkEnumeration.DataState.Deleted;
                        prefData.AgentId = 3;
                        prefData.UserId = _notificationPreferenceApi.RequestInformation.UserId;
                        prefData.ActionSourceId = groupId;
                        preferenceList.Add(prefData);
                    }
                    if ((Page.Request.Form["feed" + activityTypeList[i].Id] != null)&& Page.Request.Form["feed" + activityTypeList[i].Id] == "on")
                    {
                        prefData = new NotificationPreferenceData();
                        prefData.ActivityTypeId = activityTypeList[i].Id;
                        prefData.AgentId = 2;
                        prefData.UserId = _notificationPreferenceApi.RequestInformation.UserId;
                        prefData.ActionSourceId = groupId;
                        preferenceList.Add(prefData);
                    }
                    else
                    {
                        prefData = new NotificationPreferenceData();
                        prefData.ActivityTypeId = activityTypeList[i].Id;
                        prefData.DataState = Ektron.Cms.Common.EkEnumeration.DataState.Deleted;
                        prefData.AgentId = 2;
                        prefData.UserId = _notificationPreferenceApi.RequestInformation.UserId;
                        prefData.ActionSourceId = groupId;
                        preferenceList.Add(prefData);
                    }

                }
                _notificationPreferenceApi.SaveUserPreferences(preferenceList);
            }
    }