Пример #1
0
        public itemView <Roster.Services.Group> MetadataItem(string version, string id)
        {
            DisableCaching();
            var result = new itemView <Group>();

            try
            {
                var service = new RosterConfigService();
                var content = service.GetLists().FirstOrDefault(_ => _.Id == id.ToGuid());
                if (content != null)
                {
                    result.item = new Group {
                        Key = content.Id.ToSafeString(), Name = content.Name, Fields = new List <Entity>()
                    };
                    content.ListMetadataFields.ToList().ForEach(item =>
                    {
                        result.item.Fields.Add(new Entity {
                            Key = content.Id.ToSafeString(), Name = content.Name, Fields = item.ToNamed()
                        });
                    });
                }
            }
            catch (Exception ex)
            {
                result.message.message      = ex.Message;
                result.message.messageLevel = messageLevelEnum.critical;
                //HandleException(ex);
            }
            return(result);
        }
Пример #2
0
        public listView <Entity> MetadataList(string version, QueryDisplayParams query)
        {
            DisableCaching();
            var result = new listView <Entity>();

            try
            {
                result.page = new pager <Entity>();
                var service = new RosterConfigService();
                var content = service.GetLists();
                result.total = content.Count();
                content.Take(query.currentPageSize).Skip(query.currentPageNum * query.currentPageSize).ToList().ForEach(item =>
                {
                    result.page.pageItems.Add(new Entity
                    {
                        Key    = item.Id.ToSafeString(),
                        Name   = item.Name,
                        Fields = item.ToNamed()
                    });
                });
            }
            catch (Exception ex)
            {
                result.message.message      = ex.Message;
                result.message.messageLevel = messageLevelEnum.critical;
                //HandleException(ex);
            }
            return(result);
        }
        protected override void CreateChildControls()
        {
            RosterConfigService configProvider = new RosterConfigService();
            var lists = configProvider.GetLists();

            ddlCatalogs          = new DropDownList();
            ddlCatalogs.ID       = "catalogSelector";
            ddlCatalogs.CssClass = "lists_control";
            ddlCatalogs.Attributes.Add("onchange", "UpdateViewsList(this);");
            ddlCatalogs.Items.AddRange(lists.Select(x => new ListItem(x.Name, x.Id.ToString())).ToArray());

            ddlViews          = new DropDownList();
            ddlViews.ID       = "viewSelector";
            ddlViews.CssClass = "views_control";
            ddlViews.Items.AddRange(lists.SelectMany(x => x.ViewMetadatas).Select(v => new ListItem(v.Name, v.Id.ToString())).ToArray());

            hidAllViewsInfo       = new HiddenField();
            hidAllViewsInfo.ID    = "hidAllViewsHierarchy";
            hidAllViewsInfo.Value = new JavaScriptSerializer().Serialize(lists.Select(x => new { list = x.Id, views = x.ViewMetadatas.Select(v => new { viewId = v.Id, viewName = v.Name }) }));

            txtRelationFld    = new TextBox();
            txtRelationFld.ID = "txtRelationField";

            txtFilterOperators    = new TextBox();
            txtFilterOperators.ID = "txtFilterOperators";

            txtCalendarWidth    = new TextBox();
            txtCalendarWidth.ID = "txtCalendarWidth";

            txtCalendarHeight    = new TextBox();
            txtCalendarHeight.ID = "txtCalendarHeight";

            chEditMode      = new CheckBox();
            chEditMode.ID   = "chEditMode";
            chEditMode.Text = "Edit mode? (GridView only)";

            chDisplayPrepopulated      = new CheckBox();
            chDisplayPrepopulated.ID   = "chDisplayPrepopulated";
            chDisplayPrepopulated.Text = "Display pre-populated? (CalendarView only)";

            this.Controls.Add(ddlCatalogs);
            this.Controls.Add(ddlViews);
            this.Controls.Add(hidAllViewsInfo);
            this.Controls.Add(txtRelationFld);
            this.Controls.Add(txtFilterOperators);
            this.Controls.Add(txtCalendarWidth);
            this.Controls.Add(txtCalendarHeight);
            this.Controls.Add(chEditMode);
            this.Controls.Add(chDisplayPrepopulated);
            ScriptLink.Register(this.Page, "/_layouts/15/Roster.Presentation/js/cascadeSelection.view.js", true);

            //setting the last set values as current values on custom toolpart
            ExternalListViewWebPart wp = (ExternalListViewWebPart)this.ParentToolPane.SelectedWebPart;

            if (wp != null)
            {
                this.ddlCatalogs.SelectedValue     = wp.CatalogId;
                this.ddlViews.SelectedValue        = wp.ViewName;
                this.txtRelationFld.Text           = wp.RelationField;
                this.txtFilterOperators.Text       = wp.FilterOperators;
                this.txtCalendarWidth.Text         = wp.CalendarWidth;
                this.txtCalendarHeight.Text        = wp.CalendarHeight;
                this.chEditMode.Checked            = wp.EditMode;
                this.chDisplayPrepopulated.Checked = wp.DisplayPrepopulated;
            }

            base.CreateChildControls();
        }