Exemple #1
0
        public static List <MigrationAnalysisInfo> GetFormAnalysisInfos(XsnWrapper xsnWrapper)
        {
            List <MigrationAnalysisInfo> migrationInfos = new List <MigrationAnalysisInfo>();

            //get view list - key is file name, value is view name
            Dictionary <string, string> viewNames = xsnWrapper.Manifest.GetAllViewNames();

            //for each, name and length
            foreach (KeyValuePair <string, string> view in viewNames)
            {
                XmlNamespaceManager nsmgr;
                XmlDocument         xmlDoc = GetXmlDoc(xsnWrapper.FolderPath, view.Key, out nsmgr);

                // Case 42480
                XmlNodeList multiselectlistboxes = xmlDoc.SelectNodes("//span[@xd:xctname='multiselectlistbox']", nsmgr);
                XmlNodeList comboboxes           = xmlDoc.SelectNodes("//span[@xd:xctname='combobox']", nsmgr);
                XmlNodeList dropdownList         = xmlDoc.SelectNodes("//select[@xd:xctname='dropdown']//xsl:variable [@name='uniqueItems']", nsmgr);
                XmlNodeList externalItemPickers  = xmlDoc.SelectNodes("//object[@xd:xctname='entitypicker']", nsmgr);
                XmlNodeList hyperlinks           = xmlDoc.SelectNodes("//span[@xd:xctname='HyperlinkBox']", nsmgr);

                AddMigrationInfo(migrationInfos, "Breaking", "Multiple-Selection List Boxes - Not currently supported in FormsViewer.", multiselectlistboxes);
                AddMigrationInfo(migrationInfos, "Breaking", "External Item Pickers - Not currently supported in FormsViewer.", externalItemPickers);
                AddMigrationInfo(migrationInfos, "Warning", "Combo Boxes - FormsViewer displays a combo box control as a dropdown and that means no support for manually typing in entries.\nWorkaround: Add an Other option to your dropdown and use it to conditionally hide the dropdown control and show a text box control that allows free text entry. Add a button to the right of this control that toggles back to the dropdown.", comboboxes);
                AddMigrationInfo(migrationInfos, "Warning", "Dropdowns with Show Unique Entries - Form contains dropdown boxes with the 'Show only entries with unique display names' option. This may cause some form slowness.", dropdownList);
                AddMigrationInfo(migrationInfos, "Breaking", "Hyperlink Controls - FormsViewer does not support hyperlink controls because they are not very useful and there is a simple workaround.\nPlease change to a static hyperlink control using these steps:\n1) right click the hyperlink control in the view of your form (after opening the XSN in the InfoPath Designer) and change to text box.\n2) put your cursor under the text field and from the Designer menu, choose Insert->Hyperlink from InfoPath Designer) and change properties to Link to the data source field that you are using for the text box in your form's view.", hyperlinks);
            }

            return(migrationInfos);
        }
Exemple #2
0
 public static string GetFileText(string templateFileName, string fileName)
 {
     using (var wrapper = new XsnWrapper(templateFileName))
     {
         return(System.IO.File.ReadAllText(Path.Combine(wrapper.FolderPath, fileName)));
     }
 }
Exemple #3
0
        public static List <DetailingResult> GetDetailingResults(XsnWrapper xsnWrapper)
        {
            byte[] templateBytes = GetFileBytes(GetTemplate(xsnWrapper.FolderPath));

            XmlDocument questions = new XmlDocument();

            using (var stream = GetEmbeddedResourceStream("DetailingMetrics.xml"))
            {
                using (var sr = new StreamReader(stream))
                {
                    using (XmlReader transReader = XmlReader.Create(sr))
                    {
                        questions.Load(transReader);
                    }
                }
            }

            var xpaths    = BuildXPathSet();
            var executor  = new TemplateInspectionExecutor(questions, xpaths);
            var detResult = executor.RunOperations(templateBytes);

            XmlNodeList            results    = detResult.SelectNodes("/Results/Result");
            List <DetailingResult> resultList = new List <DetailingResult>();

            foreach (XmlNode result in results)
            {
                DetailingResult res = new DetailingResult(result.SelectSingleNode("OperationCode").InnerText,
                                                          result.SelectSingleNode("ResultLevel").InnerText, result.SelectSingleNode("ResultMessage").InnerText);
                resultList.Add(res);
            }

            return(resultList);
        }
Exemple #4
0
 public static FormInformation FormInformation(ClientContext context, Microsoft.SharePoint.Client.File file)
 {
     using (XsnWrapper xsnWrapper = new XsnWrapper(Utilities.DownloadXsn(context, file)))
     {
         FormInformation formInfo = Utilities.GenerateFormInformation(xsnWrapper);
         return(formInfo);
     }
 }
Exemple #5
0
 public static FormInformation FormInformation(ClientContext context, string libraryUrl, string xsnUrl)
 {
     using (XsnWrapper xsnWrapper = new XsnWrapper(Utilities.DownloadXsn(context, libraryUrl, xsnUrl)))
     {
         FormInformation formInfo = Utilities.GenerateFormInformation(xsnWrapper);
         return(formInfo);
     }
 }
Exemple #6
0
        public static FormInformation FormInformationFromFormFileRequest(FormFileRequest formFileRequest)
        {
            XsnWrapper      xsnWrapper = new XsnWrapper(Utilities.SaveFormFileRequest(formFileRequest));
            FormInformation formInfo   = Utilities.GenerateFormInformation(xsnWrapper);

            xsnWrapper.Dispose();

            return(formInfo);
        }
Exemple #7
0
        public static FormInformation FormInformation(Stream fileStream)
        {
            string templateFilename = Utilities.CopyXsnLocal(fileStream);

            using (XsnWrapper xsnWrapper = new XsnWrapper(templateFilename))
            {
                FormInformation formInfo = Utilities.GenerateFormInformation(xsnWrapper);
                return(formInfo);
            }
        }
Exemple #8
0
        public static FormPropertyList AllFormPropertiesFromFormFileRequest(FormFileRequest formFileRequest)
        {
            FormPropertyList propList   = new FormPropertyList();
            XsnWrapper       xsnWrapper = new XsnWrapper(Utilities.SaveFormFileRequest(formFileRequest));

            propList.FormProperties = xsnWrapper.GetAllXsnProperties();
            xsnWrapper.Dispose();

            return(propList);
        }
Exemple #9
0
        public static FormPropertyList AllFormProperties(ClientContext context, string libraryUrl, string xsnUrl)
        {
            FormPropertyList propList   = new FormPropertyList();
            XsnWrapper       xsnWrapper = new XsnWrapper(Utilities.DownloadXsn(context, libraryUrl, xsnUrl));

            propList.FormProperties = xsnWrapper.GetAllXsnProperties();
            xsnWrapper.Dispose();

            return(propList);
        }
Exemple #10
0
        public static ViewInfoList Views(ClientContext context, string libraryUrl, string xsnUrl)
        {
            ViewInfoList viewInfos  = new ViewInfoList();
            XsnWrapper   xsnWrapper = new XsnWrapper(Utilities.DownloadXsn(context, libraryUrl, xsnUrl));

            viewInfos.ViewInfos = Utilities.GetViewInfos(xsnWrapper);
            xsnWrapper.Dispose();

            return(viewInfos);
        }
Exemple #11
0
        public static ManifestFileWithProperties ManifestWithPropertiesFromFormFileRequest(FormFileRequest formFileRequest)
        {
            FormPropertyList propList   = new FormPropertyList();
            XsnWrapper       xsnWrapper = new XsnWrapper(Utilities.SaveFormFileRequest(formFileRequest));

            propList.FormProperties = xsnWrapper.GetAllXsnProperties();
            xsnWrapper.Dispose();

            return(new ManifestFileWithProperties(propList, new FormFile(manifestPath, xsnWrapper.Manifest.Manifest.OuterXml)));
        }
Exemple #12
0
        public static FormInformation FormInformation(HttpPostedFileBase file)
        {
            double formSize;

            using (XsnWrapper xsnWrapper = new XsnWrapper(Utilities.DownloadXsn(file, out formSize)))
            {
                FormInformation formInfo = Utilities.GenerateFormInformation(xsnWrapper, formSize);
                return(formInfo);
            }
        }
Exemple #13
0
 public static ManifestFileWithProperties ManifestWithProperties(ClientContext context, string libraryUrl, string xsnUrl)
 {
     using (XsnWrapper xsnWrapper = new XsnWrapper(Utilities.DownloadXsn(context, libraryUrl, xsnUrl)))
     {
         FormPropertyList propList = new FormPropertyList
         {
             FormProperties = xsnWrapper.GetAllXsnProperties()
         };
         return(new ManifestFileWithProperties(propList, new FormFile(manifestPath, xsnWrapper.Manifest.Manifest.OuterXml)));
     }
 }
Exemple #14
0
        public static List <DllInfo> GetDllInfos(XsnWrapper xsnWrapper)
        {
            List <DllInfo> dllInfos = new List <DllInfo>();

            //for each, name and length
            foreach (string file in xsnWrapper.XsnContents)
            {
                if (Path.GetExtension(file) == ".dll")
                {
                    dllInfos.Add(new DllInfo(Path.GetFileNameWithoutExtension(file), Utilities.GetSizeOfFile(file), FileVersionInfo.GetVersionInfo(file).FileVersion));
                }
            }

            return(dllInfos);
        }
Exemple #15
0
        public static List <ViewInfo> GetViewInfos(XsnWrapper xsnWrapper)
        {
            List <ViewInfo> viewInfos = new List <ViewInfo>();

            //get view list - key is file name, value is view name
            Dictionary <string, string> viewNames = xsnWrapper.Manifest.GetAllViewNames();

            //for each, name and length
            foreach (KeyValuePair <string, string> view in viewNames)
            {
                string fullViewPath = Path.Combine(xsnWrapper.FolderPath, view.Key);

                viewInfos.Add(new ViewInfo(view.Value, view.Key, Utilities.GetLinesInFile(fullViewPath), Utilities.GetSizeOfFile(fullViewPath)));
            }

            return(viewInfos);
        }
Exemple #16
0
        public static FormInformation GenerateFormInformation(XsnWrapper xsnWrapper, double?formSize = null)
        {
            FormInformation formInfo = new FormInformation();

            formInfo.ViewInfos              = GetViewInfos(xsnWrapper);
            formInfo.DataConnections        = xsnWrapper.Manifest.GetAllDataConnectionInfo();
            formInfo.FormProperties         = xsnWrapper.GetAllXsnProperties(formSize);
            formInfo.PromotedProperties     = xsnWrapper.Manifest.GetAllPromotedProperties();
            formInfo.DllInfos               = GetDllInfos(xsnWrapper);
            formInfo.DetailingResults       = GetDetailingResults(xsnWrapper);
            formInfo.MigrationAnalysisInfos = GetFormAnalysisInfos(xsnWrapper);
            formInfo.MigrationAnalysisInfos = xsnWrapper.AddRepeatingStructureWithSiblingsInfo(formInfo.MigrationAnalysisInfos);
            //formInfo.MigrationAnalysisInfos = xsnWrapper.Manifest.GetDataConnectionInfo(formInfo.MigrationAnalysisInfos);
            formInfo.QRulesInfos = xsnWrapper.Manifest.GetAllQRules();

            //TODO: Allow turning off getting form Level info
            AddFormLevelInformation(xsnWrapper, formInfo);

            return(formInfo);
        }
Exemple #17
0
        private static void AddFormLevelInformation(XsnWrapper xsnWrapper, FormInformation formInfo)
        {
            FormLevelInfo formLevel = new FormLevelInfo();

            //xml for the form info
            XmlSerializer serializer = new XmlSerializer(typeof(FormInformation));
            StringWriter  writer     = new StringWriter();

            serializer.Serialize(writer, formInfo);
            string xml = writer.ToString();

            XmlDocument doc = new XmlDocument();

            doc.LoadXml(xml);
            XPathNavigator formInfoNavigator = doc.CreateNavigator();

            //xml for the form level requirements
            XmlDocument fldoc = new XmlDocument();

            using (var stream = GetEmbeddedResourceStream("FormLevels.xml"))
            {
                using (var sr = new StreamReader(stream))
                {
                    using (XmlReader transReader = XmlReader.Create(sr))
                    {
                        fldoc.Load(transReader);
                    }
                }
            }

            XPathNavigator flNavigator = fldoc.CreateNavigator();

            //get levels
            XPathNodeIterator levels = flNavigator.Select("FormLevels/FormLevel");

            //loop through levels - if any expression evaluates false for a level, move to the next level.
            foreach (XPathNavigator level in levels)
            {
                //loop through Requirements
                XPathNodeIterator requirements = level.Select("Requirements/Requirement[Expression != '']");
                foreach (XPathNavigator requirement in requirements)
                {
                    XPathExpression expression = formInfoNavigator.Compile(requirement.SelectSingleNode("Expression").Value);
                    bool            success    = (bool)formInfoNavigator.Evaluate(expression);
                    requirement.SelectSingleNode("Result").SetValue(success.ToString().ToLower());

                    if (success)
                    {
                        formLevel.Level = level.SelectSingleNode("@name").Value;
                    }
                }
            }

            //add qualifiers and recommendations for level
            XPathNodeIterator qualifiers = flNavigator.Select(string.Format("FormLevels/FormLevel[@name = '{0}']/Requirements/Requirement[Result = 'true' or @alwaysInclude = 'true']/Description", formLevel.Level));

            formLevel.Qualifiers = new List <Qualifier>();
            foreach (XPathNavigator qualifier in qualifiers)
            {
                formLevel.Qualifiers.Add(new Qualifier(qualifier.Value));
            }

            XPathNodeIterator recommendations = flNavigator.Select(string.Format("FormLevels/FormLevel[@name = '{0}']/Recommendations/Recommendation", formLevel.Level));

            formLevel.Recommendations = new List <Recommendation>();
            foreach (XPathNavigator recommendation in recommendations)
            {
                formLevel.Recommendations.Add(new Recommendation(recommendation.Value));
            }

            formInfo.FormLevel = formLevel;
        }