/// <summary>
        /// Initializes a new instance of the <see cref="UPInsightBoardGroupModelController"/> class.
        /// </summary>
        /// <param name="formItem">The form item.</param>
        /// <param name="identifier">The identifier.</param>
        /// <param name="theDelegate">The delegate.</param>
        public UPInsightBoardGroupModelController(FormItem formItem, IIdentifier identifier, IGroupModelControllerDelegate theDelegate)
            : base(formItem, theDelegate)
        {
            this.itemControllerArray   = new List <UPInsightBoardItemGroupModelController>();
            this.ExplicitTabIdentifier = identifier;
            this.ExplicitLabel         = formItem.Label;
            this.testViewReference     = formItem.ViewReference;
            string contextMenuName      = formItem.ViewReference.ContextValueForKey("MenuName");
            string recordIdentification = formItem.ViewReference.ContextValueForKey("RecordId");

            recordIdentification = UPCRMDataStore.DefaultStore.ReplaceRecordIdentification(recordIdentification);
            this.ConfigInsightBoard(contextMenuName, recordIdentification);

            UPMInsightBoardGroup insightBoardGroup = new UPMInsightBoardGroup(identifier);

            insightBoardGroup.LabelText = formItem.Label;

            if (formItem.Options != null)
            {
                string heightValue = formItem.Options.ContainsKey("height") ? formItem.Options["height"] as string : null;
                if (!string.IsNullOrEmpty(heightValue))
                {
                    insightBoardGroup.Height = Convert.ToInt32(heightValue);
                }

                string maxVisibleItems = formItem.Options.ContainsKey("MaxVisibleItems") ? formItem.Options["MaxVisibleItems"] as string : null;
                if (!string.IsNullOrEmpty(maxVisibleItems))
                {
                    insightBoardGroup.MaxVisibleItems = Convert.ToInt32(maxVisibleItems);
                }

                string vertical = formItem.Options.ContainsKey("Vertical") ? formItem.Options["Vertical"] as string : null;
                if (!string.IsNullOrEmpty(vertical))
                {
                    var isIntValue = int.TryParse(vertical, out int intValue);
                    insightBoardGroup.SingleRow = isIntValue ? !Convert.ToBoolean(intValue) : !Convert.ToBoolean(vertical);
                    if (!insightBoardGroup.SingleRow)
                    {
                        insightBoardGroup.Center = true;
                    }
                }

                string centerString = formItem.Options.ContainsKey("Center") ? formItem.Options["Center"] as string : null;
                if (!string.IsNullOrEmpty(centerString))
                {
                    insightBoardGroup.Center = Convert.ToBoolean(centerString);
                }

                string layoutValue = formItem.Options.ContainsKey("layout") ? formItem.Options["layout"] as string : null;
                if (!string.IsNullOrEmpty(layoutValue))
                {
                    insightBoardGroup.Layout = (UPMInsightBoardGroupLayout)Convert.ToInt32(layoutValue);
                }
            }

            this.ControllerState = this.itemControllerArray.Count > 0 ? GroupModelControllerState.Pending : GroupModelControllerState.Empty;
            this.Group           = insightBoardGroup;
            this.AddDependingKeysFromViewReference(formItem.ViewReference);
        }
        /// <summary>
        /// Applies the result row.
        /// </summary>
        /// <param name="row">The row.</param>
        /// <returns></returns>
        public override UPMGroup ApplyResultRow(UPCRMResultRow row)
        {
            string recordIdentification            = row.RootRecordIdentification;
            UPMInsightBoardGroup insightBoardGroup = new UPMInsightBoardGroup(this.TabIdentifierForRecordIdentification(recordIdentification))
            {
                LabelText       = this.TabLabel,
                Layout          = UPMInsightBoardGroupLayout.Layout2,
                Height          = 0,
                SingleRow       = this.horizontalStyle,
                Center          = !this.horizontalStyle && this.center,
                MaxVisibleItems = this.maxVisibleRow
            };

            this.pending         = this.itemControllerArray.Count;
            this.ControllerState = this.itemControllerArray.Count > 0 ? GroupModelControllerState.Pending : GroupModelControllerState.Empty;
            this.Group           = insightBoardGroup;
            foreach (UPInsightBoardItemGroupModelController itemController in this.itemControllerArray)
            {
                itemController.ApplyRecordIdentification(recordIdentification);
            }

            insightBoardGroup.Actions.AddRange(this.BuildAdditionalActionsForRecordIdentification(recordIdentification));
            return(insightBoardGroup);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="UPInsightBoardItemGroupModelController"/> class.
        /// </summary>
        /// <param name="menu">The menu.</param>
        /// <param name="theDelegate">The delegate.</param>
        /// <param name="sortIndex">Index of the sort.</param>
        /// <param name="insightBoardItemViewReference">The insight board item view reference.</param>
        /// <param name="recordIdentification">The record identification.</param>
        public UPInsightBoardItemGroupModelController(Menu menu, IGroupModelControllerDelegate theDelegate, int sortIndex,
                                                      ViewReference insightBoardItemViewReference, string recordIdentification)
            : base(theDelegate)
        {
            this.Menu      = menu;
            this.SortIndex = sortIndex;
            this.InsightBoardItemViewReference = insightBoardItemViewReference;
            this.recordIdentification          = recordIdentification;
            bool showImage = false;
            UPMInsightBoardItemType insightBoardType;

            if (menu?.ViewReference?.ViewName == "InsightBoardItem")
            {
                string contextMenuName = this.Menu.ViewReference.ContextValueForKey("ContextMenu");
                this.isAlternativeContextMenu = false;
                if (!string.IsNullOrEmpty(contextMenuName))
                {
                    IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore;
                    Menu configMenu = configStore.MenuByName(contextMenuName);
                    if (configMenu != null)
                    {
                        this.relevantViewReference = configMenu.ViewReference;
                        this.countable             = this.relevantViewReference.ViewName == "RecordListView";
                        if (this.relevantViewReference.ContextValueForKey("Modus") == "GeoSearch")
                        {
                            this.countable = false;
                        }

                        if (menu.ViewReference.ContextValueIsSet("ForceActionStyle"))
                        {
                            this.forcedRecordListView = this.countable;
                            this.countable            = false;
                        }
                        else
                        {
                            this.forcedRecordListView = false;
                        }

                        this.isAlternativeContextMenu = true;
                        if (this.countable)
                        {
                            this.searchAndListConfigurationName = this.relevantViewReference.ContextValueForKey("ConfigName");
                            this.infoAreaid = this.relevantViewReference.ContextValueForKey("InfoArea");
                            if (string.IsNullOrEmpty(this.searchAndListConfigurationName))
                            {
                                this.searchAndListConfigurationName = this.infoAreaid;
                            }
                        }
                    }
                }

                if (!this.isAlternativeContextMenu)
                {
                    this.relevantViewReference = this.Menu.ViewReference;
                    this.countable             = true;
                    if (menu.ViewReference.ContextValueIsSet("ForceActionStyle"))
                    {
                        this.forcedRecordListView = true;
                        this.countable            = false;
                    }

                    this.searchAndListConfigurationName = this.relevantViewReference.ContextValueForKey("ConfigName");
                    if (this.forcedRecordListView)
                    {
                        IConfigurationUnitStore configStore   = ConfigurationUnitStore.DefaultStore;
                        SearchAndList           searchAndList = configStore.SearchAndListByName(this.searchAndListConfigurationName);
                        this.infoAreaid = searchAndList.InfoAreaId;
                    }
                }

                string requestOptionString = this.Menu.ViewReference.ContextValueForKey("RequestOption");
                this.relevantViewReference = new ViewReference(this.relevantViewReference, requestOptionString, "InitialRequestOption", null);
                this.requestOption         = UPCRMDataStore.RequestOptionFromString(requestOptionString, UPRequestOption.Offline);
                insightBoardType           = this.countable ? UPMInsightBoardItemType.Count : UPMInsightBoardItemType.Action;
            }
            else
            {
                this.relevantViewReference = this.Menu.ViewReference;
                showImage        = true;
                insightBoardType = UPMInsightBoardItemType.ExMenu;
            }

            UPMInsightBoardGroup insightBoardGroup = new UPMInsightBoardGroup(StringIdentifier.IdentifierWithStringId("temp"));

            insightBoardGroup.LabelText = "InsightBoard";
            this.Group           = insightBoardGroup;
            this.ControllerState = GroupModelControllerState.Pending;
            IIdentifier identifier;

            if (!string.IsNullOrEmpty(this.infoAreaid))
            {
                identifier = new RecordIdentifier(this.infoAreaid, null);
            }
            else
            {
                identifier = StringIdentifier.IdentifierWithStringId("InsightBoardItem");
            }

            UPMInsightBoardItem item = new UPMInsightBoardItem(identifier)
            {
                ShowImage = showImage,
                Type      = insightBoardType
            };

            this.Group.AddChild(item);
        }