Esempio n. 1
0
 public static PnpFileModel GetError(FileHandlerActivationParameters parameters, Exception ex)
 {
     return(new PnpFileModel(parameters)
     {
         ErrorMessage = ex.Message, ReadOnly = true
     });
 }
Esempio n. 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"
                })
            });
        }
Esempio n. 3
0
 private PnpFileModel(FileHandlerActivationParameters activationParameters)
 {
     this.ActivationParameters = activationParameters;
 }