コード例 #1
0
ファイル: ScannerController.cs プロジェクト: Qdabra/QFS
        public ActionResult ScanTemplates(List <string> urls)
        {
            var spContext = SharePointContextProvider.Current.GetSharePointContext(System.Web.HttpContext.Current);
            var scanInfo  = new ScanTemplateInfo();
            var listInfo  = new List <FormInformation>();

            using (var clientContext = spContext.CreateUserClientContextForSPHost())
            {
                foreach (var url in urls)
                {
                    try
                    {
                        SP.Web web = clientContext.Site.RootWeb;

                        var file = web.GetFileByServerRelativeUrl(url);

                        FormInformation info = InfoPathAnalytics.FormInformation(clientContext, file);
                        info.XsnUrl = file.ServerRelativeUrl;

                        listInfo.Add(info);
                    }
                    catch
                    {
                        scanInfo.AddMessage(url);
                    }
                }
            }
            scanInfo.FormInfos = listInfo;

            return(View(scanInfo));
        }
コード例 #2
0
ファイル: ScannerController.cs プロジェクト: Qdabra/QFS
        public async Task <ActionResult> ScanTemplate(string templateName)
        {
            var scanInfo = new ScanTemplateInfo();
            var listInfo = new List <FormInformation>();

            if (string.IsNullOrEmpty(templateName))
            {
                return(new EmptyResult());
            }

            var spContext = SharePointContextProvider.Current.GetSharePointContext(System.Web.HttpContext.Current);

            using (var clientContext = spContext.CreateUserClientContextForSPHost())
            {
                var blobInfo = await TemplateManager.GetXsnBlobInfo(templateName, StorageContext);

                if (blobInfo == null)
                {
                    return(new EmptyResult());
                }

                try
                {
                    FormInformation info = InfoPathAnalytics.FormInformation(blobInfo.FileStream);
                    info.XsnUrl = blobInfo.FileName;
                    listInfo.Add(info);
                }
                catch
                {
                    scanInfo.AddMessage(templateName);
                }
            }


            scanInfo.FormInfos = listInfo;

            return(View("ScanTemplates", scanInfo));
        }