示例#1
0
        public static async Task CheckinFromDrive(this Record record, string driveId, string token, bool saveRecord = false)
        {
            string downloadUrl = GraphApiHelper.GetOneDriveItemContentIdUrl(driveId);

            var fileResult = await ODataHelper.GetItem <OneDriveItem>(GraphApiHelper.GetOneDriveItemIdUrl(driveId), token, null);

            string filePath = Path.Combine(TrimApplication.WebServerWorkPath, fileResult.Name);


            await ODataHelper.GetItem <string>(downloadUrl, token, filePath);

            var inputDocument = new InputDocument(filePath);


            inputDocument.CheckinAs = record.SuggestedFileName;
            record.SetDocument(inputDocument, true, false, "checkin from Word Online");

            string pdfPath = Path.Combine(TrimApplication.WebServerWorkPath, Path.ChangeExtension(fileResult.Name, "pdf"));
            string pdfUrl  = GraphApiHelper.GetOneDriveItemContentIdUrl(driveId, "pdf");
            await ODataHelper.GetItem <string>(pdfUrl, token, pdfPath);


            var rendition = record.ChildRenditions.NewRendition(pdfPath, RenditionType.Longevity, "Preview");


            if (saveRecord)
            {
                record.Save();

                File.Delete(filePath);
                File.Delete(pdfPath);
            }
            return;
        }