Esempio n. 1
0
        private string GetFormHtml(int idForm, bool newForm)
        {
            try {
                var xmlHtml  = new StringWriter();
                var xslt     = new XslCompiledTransform();
                var settings = new XsltSettings();
                settings.EnableScript           = true;
                settings.EnableDocumentFunction = true;
                XsltArgumentList args = new XsltArgumentList();

                xslt.Load(HostingEnvironment.ContentRootPath + "/XmlForms/FormTransform.xslt", settings, new XmlUrlResolver());

                XmlForm = FormXmlService.LoadXmlForm(idForm);
                FillBaseFormData(XmlForm, newForm);
                xslt.Transform(XmlForm, null, xmlHtml);

                return(xmlHtml.ToString());
            }
            catch (Exception e) {
                throw new Exception(e.Message);
            }
        }
Esempio n. 2
0
        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);
            }
        }