コード例 #1
0
        public async Task<bool> UpdateDocument(Guid guid, string path)
        {
            ExactOnlineClient exactOnlineClient = this.GetExactOnlineClient();

            DropboxClient dropboxClient = this.GetDropboxClient(DropboxModel.AccessToken);
            DownloadArg arg = new DownloadArg(path);

            DocumentAttachment attachment = new DocumentAttachment();
            attachment.Document = guid;
            attachment.FileName = this.GetFileName(path);
            attachment.Attachment = await this.GetDropboxService().DownloadContentAsByteArray(dropboxClient, arg);

            bool isAttached = exactOnlineClient.For<DocumentAttachment>().Insert(ref attachment);

            return isAttached;
        }
コード例 #2
0
        public async Task<bool> NewDocument(string path)
        {
            ExactOnlineClient exactOnlineClient = this.GetExactOnlineClient();

            Document document = new Document();
            document.Subject = this.GetFileName(path);
            document.Type = 183; // Attachment Type
            document.Category = Guid.Parse("3b6d3833-b31b-423d-bc3c-39c62b8f2b12"); // General Category

            bool isCreated = exactOnlineClient.For<Document>().Insert(ref document);

            if (!isCreated)
            {
                throw new Exception("Document fail to create on Exact Online server");
            }

            DropboxClient dropboxClient = this.GetDropboxClient(this.DropboxModel.AccessToken);
            DownloadArg arg = new DownloadArg(path);

            DocumentAttachment attachment = new DocumentAttachment();
            attachment.Document = document.ID;
            attachment.FileName = this.GetFileName(path);
            attachment.Attachment = await this.GetDropboxService().DownloadContentAsByteArray(dropboxClient, arg);

            bool isAttached = exactOnlineClient.For<DocumentAttachment>().Insert(ref attachment);

            return isAttached;
        }