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);
        }
 public FirmwareFileConverter(SharepointClient sharepointClient, IEnumerable <SPTerm> names, IEnumerable <SPTerm> fileTypeTerms, ListItemCollection firmwarefolders)
 {
     _sharepointClient = sharepointClient;
     _names            = names;
     _fileTypeTerms    = fileTypeTerms;
     _firmwarefolders  = firmwarefolders;
 }
示例#3
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 Device Convert(ListItem listItem, SharepointClient sp)
        {
            var guidID = listItem.Get <String>(SharepointFields.DeviceStockID);

            var emptyStockNumber = "-1";

            var stock = guidID != null && _dataTable.ContainsKey(guidID) ? _dataTable[guidID] : emptyStockNumber;

            var stockNumber = Int16.Parse(stock);

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

            var name = listItem.Get <TaxonomyFieldValue>(SharepointFields.Name).ToSPTerm(_names);

            var purposes = listItem.Get <TaxonomyFieldValue>(SharepointFields.Purpose).ToSPTerm(_purposes);

            var linkedDevices =
                listItem.Get <TaxonomyFieldValueCollection>(SharepointFields.LinkedDevices).ToSPTermList(_names);

            var price = listItem.Get <Double?>(SharepointFields.Price);

            var label = listItem.Get <TaxonomyFieldValue>(SharepointFields.Label).ToSPTerm(_labels);

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

            var url = listItem.Get <String>(SharepointFields.Url);

            var device = new Device
            {
                Id                = listItem.Id,
                OldKey            = title,
                Name              = name,
                Destination       = purposes,
                Connected_devices = linkedDevices,
                Price             = price,
                Label             = label,
                Created           = created,
                Url               = url,
                DeviceStockUpdate = _deviceStockUpdate,
                DeviceStock       = stockNumber
            };

            var shortDescriptionField = listItem.Get <FieldUrlValue>(SharepointFields.ShortDescription);

            if (shortDescriptionField != null)
            {
                LoadFromConfluence(device, d => d.Short_description, shortDescriptionField.Url);
            }

            var longDescriptionField = listItem.Get <FieldUrlValue>(SharepointFields.LongDescription);

            if (longDescriptionField != null)
            {
                LoadFromConfluence(device, d => d.Long_description, longDescriptionField.Url);
            }

            return(device);
        }
        public Post Convert(ListItem listItem, SharepointClient sp)
        {
            var link = listItem.Get <FieldUrlValue>(SharepointFields.BodyLink);

            var content = link == null ? String.Empty : _confluenceClient.GetContentByUrl(link.Url);

            var title = link == null ? String.Empty : _confluenceClient.GetTitleByUrl(link.Url);

            var metaHtml = GetPageProperties(content);

            if (metaHtml != null)
            {
                content = RemovePagePropertiesInContent(content);
            }

            if (!String.IsNullOrWhiteSpace(title))
            {
                title = _tagRegex.Replace(title, String.Empty);
            }

            var id = listItem.Get <Int32>(SharepointFields.OldID);

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

            var body = content.ReplaceInternalLinks();

            var category = listItem.Get <TaxonomyFieldValue>(SharepointFields.Category).ToSPTerm(_categories);

            var createDate = listItem.Get <DateTime>(SharepointFields.PublicationDate);

            var urlName = link?.Description.Replace(".", "x2E").Trim(' ') ?? String.Empty;

            var relativeUrl = UrlBuilder.GetRelativePostUrl(urlName).ToString();

            var isTopPost = listItem.Get <Boolean>(SharepointFields.IsTop);

            var post = new Post
            {
                Id       = id,
                Title    = title,
                Devices  = devices,
                Body     = body,
                Category = category,
                Created  = createDate,
                Url_name = relativeUrl,
                IsTop    = isTopPost,
                MetaHtml = metaHtml
            };

            return(post);
        }
        public SiteText Convert(ListItem listItem, SharepointClient sp)
        {
            var link = listItem.Get <FieldUrlValue>(SharepointFields.BodyLink);

            var content = link == null ? String.Empty : _confluenceClient.GetContentByUrl(link.Url);

            var siteText = new SiteText
            {
                Tag  = listItem.Get <String>(SharepointFields.Title),
                Text = content.ReplaceInternalLinks()
            };

            return(siteText);
        }
示例#7
0
        HTMLInjection IListItemConverter <HTMLInjection> .Convert(ListItem listItem, SharepointClient sp)
        {
            var html    = listItem.Get <String>(SharepointFields.Html);
            var page    = listItem.Get <String>(SharepointFields.Page);
            var section = listItem.Get <String>(SharepointFields.Section);
            var title   = listItem.Get <String>(SharepointFields.Title);

            var htmlInjection = new HTMLInjection
            {
                HTML    = html,
                Page    = page,
                Section = section,
                Title   = title
            };

            return(htmlInjection);
        }
        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);
        }
示例#9
0
        public DeviceParameter Convert(ListItem listItem, SharepointClient sp)
        {
            var name = listItem.Get <TaxonomyFieldValue>(SharepointFields.Parameter).ToSPTerm(_deviceParameterTerms);

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

            var valueField = Helpers.IsCultureEng ? SharepointFields.EngValue : SharepointFields.Title;

            var value = listItem.Get <String>(valueField);

            var deviceParameter = new DeviceParameter
            {
                Id     = listItem.Id,
                Name   = name,
                Device = device,
                Value  = value
            };

            return(deviceParameter);
        }
示例#10
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);
            }
        }