private void GetRequestForms(int idForm, int idView)
        {
            var viewNode = XmlForm.SelectSingleNode("//body/views/group/view[viewId='" + idView.ToString() + "']");

            var groupView = FormsBoardViewModel.GroupViews.SelectMany(g => g.Views.Where(v => v.Id.Equals(idView))).ToList();

            FormsBoardViewModel.CurrentView = groupView.First();

            var getAllRequests = viewNode.SelectSingleNode("listAllRequests") != null && viewNode.SelectSingleNode("listAllRequests").InnerText == "true";
            var formRequests   = FormRequestService.GetFormRequests(idForm, getAllRequests ? string.Empty : UserUtil.DisplayUserName);

            var jsonResult = new JObject();
            var row        = 1;

            foreach (var request in formRequests)
            {
                var formData = JObject.Parse(request.JSonFormData);
                formData.Add("IdFormRequest", request.Id.ToString());

                if (viewNode.SelectSingleNode("filter") != null)
                {
                    var filter = viewNode.SelectSingleNode("filter").InnerText;
                    if (!FormXmlService.ValidateConditions(request.JSonFormData, filter))
                    {
                        continue;
                    }
                }

                jsonResult.Add(row.ToString(), formData);
                row++;
            }

            FormsBoardViewModel.FormRequests = formRequests;

            var groupedJson = GroupBy(jsonResult, FormsBoardViewModel.CurrentView.GroupBy);

            var orderByNode = viewNode.SelectSingleNode("orderBy");

            if (orderByNode != null && !FormsBoardViewModel.CurrentView.GroupBy.Contains("Date") && !FormsBoardViewModel.CurrentView.GroupBy.Contains("Calendar"))
            {
                OrderBy(groupedJson, orderByNode.InnerText);
            }

            FormsBoardViewModel.JSonResult = groupedJson;
        }
        private void GetViews(int idForm)
        {
            XmlForm = FormXmlService.LoadXmlForm(idForm);

            FormsBoardViewModel.GroupViews = new List <ViewsGroupViewModel>();
            var groupViews = XmlForm.SelectNodes("//body/views/group");

            foreach (XmlNode nodeGroup in groupViews)
            {
                if (nodeGroup.SelectSingleNode("visible") != null)
                {
                    var visibleNode = nodeGroup.SelectSingleNode("visible").InnerText;
                    if (!FormXmlService.ValidateConditions(null, visibleNode))
                    {
                        continue;
                    }
                }

                var titleGroup = nodeGroup["title"].InnerText;
                if (titleGroup.Equals("User()"))
                {
                    titleGroup = UserUtil.DisplayUserName;
                }

                var groupView = new ViewsGroupViewModel
                {
                    Title = titleGroup,
                    Views = new List <ViewFormsViewModel>()
                };

                var views = nodeGroup.SelectNodes("view");
                foreach (XmlNode nodeView in views)
                {
                    if (nodeView.SelectSingleNode("visible") != null)
                    {
                        var visibleNode = nodeView.SelectSingleNode("visible").InnerText;
                        if (!FormXmlService.ValidateConditions(null, visibleNode))
                        {
                            continue;
                        }
                    }

                    var view = new ViewFormsViewModel
                    {
                        Id          = int.Parse(nodeView["viewId"].InnerText),
                        Title       = nodeView["name"].InnerText,
                        GroupBy     = nodeView["groupBy"] == null ? "" : nodeView["groupBy"].InnerText,
                        ViewColumns = new List <ViewColumn>()
                    };

                    var columns = nodeView.SelectNodes("columns/column");
                    foreach (XmlNode nodeColumn in columns)
                    {
                        var column = new ViewColumn
                        {
                            Name              = nodeColumn["name"].InnerText,
                            ControlId         = nodeColumn["controlId"] == null ? null : nodeColumn["controlId"].InnerText,
                            FunctionControlId = nodeColumn["functionControlId"] == null ? null : nodeColumn["functionControlId"].InnerText
                        };

                        view.ViewColumns.Add(column);
                    }

                    groupView.Views.Add(view);
                }

                FormsBoardViewModel.GroupViews.Add(groupView);
            }
        }