コード例 #1
0
        public void Insert(SPList mediaList, MediaAsset asset, out int id, out string contentTypeId)
        {
            var item = mediaList.Items.Add();
            item["ContentTypeId"] = GetContentTypeId(mediaList, asset.MediaType.ToString());
            item["Title"] = asset.Title;
            item[new Guid(MediaAssetsColumns.TempLocation)] = asset.TempLocation;
            item[new Guid(MediaAssetsColumns.Format)] = asset.Format;
            item[new Guid(MediaAssetsColumns.ProcStatus)] = Enum.GetName(typeof(ProcessingStatus), asset.Status);
            if (!String.IsNullOrEmpty(asset.Location))
            {
                item[new Guid(MediaAssetsColumns.Location)] = asset.Location;
            }
            if (!String.IsNullOrEmpty(asset.Thumbnail))
            {
                item[new Guid(MediaAssetsColumns.Thumbnail)] = asset.Thumbnail;
            }
            if (!String.IsNullOrEmpty(asset.Poster))
            {
                item[new Guid(MediaAssetsColumns.Poster)] = asset.Poster;
            }
            if ((asset.MediaType == MediaType.Audio || asset.MediaType == MediaType.Video) && asset.Duration != TimeSpan.MinValue)
            {
                item[new Guid(MediaAssetsColumns.Length)] = asset.Duration.TotalSeconds;
            }
            item.Update();

            id = item.ID;
            contentTypeId = item.ContentTypeId.ToString();
        }
コード例 #2
0
        public IEnumerable<MediaAsset> GetMediaToProcess()
        {
            ClientContext ctx = new ClientContext(webFullUrl);
            Web web = ctx.Web;

            List list = web.Lists.GetByTitle(mediaAssetsList);

            CamlQuery camlQuery = new CamlQuery();
            camlQuery.ViewXml =
                         @"<View>
                            <Query>
                              <Where>
                                <Eq>
                                    <FieldRef Name='MediaProcStatus'/>
                                    <Value Type='Text'>Pending</Value>
                                </Eq>
                              </Where>
                            </Query>
                            <RowLimit>100</RowLimit>
                          </View>";
            ListItemCollection listItems = list.GetItems(camlQuery);
            ctx.Load(
                    listItems,
                    items => items
                        .Include(
                            item => item.Id,
                            item => item["Title"],
                            item => item.ContentType,
                            item => item["MediaTempLocation"],
                            item => item["Author"]));
            ctx.ExecuteQuery();
            foreach (ListItem item in listItems)
            {
                MediaAsset asset = new MediaAsset();
                asset.Id = item.Id;
                asset.Title = item["Title"].ToString();
                asset.TempLocation = item["MediaTempLocation"] != null ? item["MediaTempLocation"].ToString() : String.Empty;
                if (item.ContentType.Name.Contains(MediaType.Audio.ToString()))
                {
                    asset.MediaType = MediaType.Audio;
                }
                else if (item.ContentType.Name.Contains(MediaType.Image.ToString()))
                {
                    asset.MediaType = MediaType.Image;
                }
                else
                {
                    asset.MediaType = MediaType.Video;
                }
                var user = item.FieldValues["Author"] as FieldUserValue;
                asset.UploaderEmail = GetUserEmail(user.LookupId);
                yield return asset;

            }
        }
コード例 #3
0
 public static MediaAsset FromFile(FileInfo fileInfo, string originatingWeb, MediaConfig config)
 {
     MediaAsset item = new MediaAsset();
     item.MediaType = GetMediaTypeFromFileExtension(fileInfo, config);
     item.Title = Path.GetFileNameWithoutExtension(fileInfo.FullName);
     item.OriginatingWeb = originatingWeb;
     item.Format = GetMediaFormat(fileInfo);
     return item;
 }