public DevicePhoto Convert(ListItem listItem, SharepointClient sp)
        {
            var pictureName = listItem.Get <String>(SharepointFields.FileLeaf);

            var deviceName = listItem.Get <TaxonomyFieldValue>(SharepointFields.Device).ToSPTerm(_names);

            if (!String.IsNullOrEmpty(pictureName))
            {
                pictureName = pictureName.Replace(" ", String.Empty);
            }

            var photosUrl = UrlBuilder.GetPhotosUrl(pictureName).ToString();

            var isBigPhoto = IsBigPhoto(pictureName);

            var isCover = listItem.Get <Boolean>(SharepointFields.Cover);

            var devicePhoto = new DevicePhoto
            {
                Name     = pictureName,
                Dev_name = deviceName,
                Url      = photosUrl,
                IsBig    = isBigPhoto,
                IsCover  = isCover
            };

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

            sp.DownloadFileToLocal(pictureRef, UrlBuilder.LocalPath_photos, pictureName);

            return(devicePhoto);
        }
Exemplo n.º 2
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);
        }
        public SFile Convert(ListItem listItem, SharepointClient sp)
        {
            var firmwareFileType  = "4dadfd09-f883-4f42-9178-ded2fe88016b";
            var firmwareFileType2 = "e3de2072-1eb2-4b6d-a7e2-3319bf89836d";

            var fileType = _fileTypeTerms.FirstOrDefault(t => t.Id == new Guid(firmwareFileType));

            var docType = listItem.Get <TaxonomyFieldValue>(SharepointFields.DocType);

            if (docType.TermGuid == firmwareFileType2)
            {
                fileType = _fileTypeTerms.FirstOrDefault(t => t.Id == new Guid(firmwareFileType2));
            }


            string folder        = listItem.Get <String>(SharepointFields.FileDir);
            string parent_folder = folder.Substring(0, folder.LastIndexOf('/'));

            var name       = listItem.Get <String>(SharepointFields.FileLeaf);
            var title      = listItem.Get <String>(SharepointFields.Title);
            var devices    = _firmwarefolders.First(fldr => parent_folder == fldr.Get <String>(SharepointFields.FileRef)).Get <TaxonomyFieldValueCollection>(SharepointFields.Devices).ToSPTermList(_names);
            var createDate = listItem.Get <DateTime>(SharepointFields.Created);
            var url        = UrlBuilder.GetFirmwaresUrl(name).ToString();



            var firmwareFile = new SFile
            {
                Id        = listItem.Id,
                Name      = name,
                Title     = title,
                Devices   = devices,
                File_type = fileType,
                Created   = createDate,
                Url       = url
            };

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

            sp.DownloadFileToLocal(fileRef, UrlBuilder.LocalPath_firmwares, name);


            return(firmwareFile);
        }
Exemplo n.º 4
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);
            }
        }