Пример #1
0
        public PubFiles Convert(ListItem listItem, SharepointClient sp)
        {
            var fileName = listItem.Get <String>(SharepointFields.FileLeaf);

            var fileUrl = UrlBuilder.GetPublicFilesUrl(fileName);

            var fileType = listItem.Get <TaxonomyFieldValue>(SharepointFields.FileType).ToSPTerm(_fileTypeTerms);

            var urlLink = listItem.Get <FieldUrlValue>(SharepointFields.Url).Url;

            var pubFiles = new PubFiles
            {
                Name      = fileName,
                File_type = fileType,
                Url       = fileUrl.ToString(),
                Url_link  = urlLink
            };

            var fileRef = listItem.Get <String>(SharepointFields.FileRef);

            sp.DownloadFileToLocal(fileRef, UrlBuilder.LocalPath_pubfiles, fileName);


            return(pubFiles);
        }
Пример #2
0
        public SFile Convert(ListItem listItem, SharepointClient sp)
        {
            try
            {
                var userGuideFileName = "User guide";

                var fileName = listItem.Get <String>(SharepointFields.Title);

                var fileType = listItem.Get <TaxonomyFieldValue>(SharepointFields.ManualFileType).ToSPTerm(_fileTypeTerms);

                var title = listItem.Get <String>(SharepointFields.Title);

                var devices = listItem.Get <TaxonomyFieldValueCollection>(SharepointFields.Devices).ToSPTermList(_names);

                var created = listItem.Get <DateTime>(SharepointFields.Created);

                var fileUrl = listItem.Get <FieldUrlValue>(SharepointFields.UrlUpperCase).Url;

                Debug.WriteLine($"Start loading manual '{fileUrl}'");
                Log.Trace($"Start loading manual '{fileUrl}'");

                var sFile = new SFile
                {
                    Id        = listItem.Id,
                    Name      = fileName,
                    Title     = title,
                    Devices   = devices,
                    File_type = fileType,
                    Created   = created,
                    Url       = UrlBuilder.GetPublicFilesUrl(fileName).ToString()
                };
                if (fileType.OwnNameFromPath != userGuideFileName)
                {
                    sp.DownloadFileToLocal(fileUrl, UrlBuilder.LocalPath_pubfiles, fileName);
                }
                else
                {
                    sFile.Url = fileUrl;
                }

                /*
                 * if (fileType.OwnNameFromPath == userGuideFileName)
                 * {
                 * var contentId = _confluenceClient.GetContentIdFromUrl(fileUrl);
                 *
                 * if (contentId.HasValue)
                 * {
                 *  var content = _confluenceClient.GetUserManual(contentId.Value, listItem.Id);
                 *
                 *  _manualSaver(content);
                 *
                 *  var url = UrlBuilder.GetRelativeDeviceGuideUrl(PrepareUrlName(content)).ToString();
                 *
                 *  sFile.Url = url;
                 * }
                 * else
                 * {
                 *  Debug.WriteLine($"End loading manual '{fileUrl}'");
                 *  Log.Trace($"End loading manual '{fileUrl}'");
                 *
                 *  return null;
                 * }
                 *
                 *
                 * } else
                 * {
                 *
                 *  sp.DownloadFileToLocal(fileUrl, UrlBuilder.LocalPath_pubfiles, fileName);
                 * }
                 */
                Debug.WriteLine($"End loading manual '{fileUrl}'");
                Log.Trace($"End loading manual '{fileUrl}'");

                return(sFile);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }