Пример #1
0
 public static PnpFileModel GetError(FileHandlerActivationParameters parameters, Exception ex)
 {
     return(new PnpFileModel(parameters)
     {
         ErrorMessage = ex.Message, ReadOnly = true
     });
 }
Пример #2
0
        public static async Task <PnpFileModel> GetAsync(FileHandlerActivationParameters parameters, System.Web.Mvc.UrlHelper url)
        {
            // Retrieve an access token so we can make API calls
            string accessToken = null;

            try
            {
                accessToken = await AuthHelper.GetUserAccessTokenSilentAsync(parameters.ResourceId);
            }
            catch (Exception ex)
            {
                return(GetError(parameters, ex));
            }

            // Read the details of the specified item
            GraphServiceClient graphServiceClient = GraphHelper.Default.GetGraphServiceClient(accessToken);
            IDriveRequest      request            = new DriveRequest(parameters.ItemUrls[0], graphServiceClient, Array.Empty <Option>());
            Drive drive = await request.GetAsync();

            return(new PnpFileModel(parameters)
            {
                Title = drive.Name,
                // Create uri to use to load the content
                PreviewUri = url.Action("PreviewInfo", new
                {
                    resourceId = parameters.ResourceId,
                    uri = parameters.ItemUrls[0] + "/content"
                })
            });
        }
Пример #3
0
 private PnpFileModel(FileHandlerActivationParameters activationParameters)
 {
     this.ActivationParameters = activationParameters;
 }