Esempio n. 1
0
        private async Task <bool> CreateRemoteNode(RemoteVsLocalFile inf, CancellationToken cancelToken)
        {
            var newFid = await UploadLocalFile(inf, cancelToken);

            if (newFid <= 0)
            {
                return(false);
            }

            inf.Status = "Creating new node...";
            var nodeDto = new SyncableFileDto(inf.Local, newFid);
            var newNode = await _client.Post(nodeDto, cancelToken);

            if (!newNode.IsValidNode())
            {
                return(false);
            }

            if (await AddToFolderNode(newNode.nid))
            {
                return(false);
            }

            inf.Status = "File uploaded; node created.";
            return(true);
        }
Esempio n. 2
0
        private async Task <bool> AddItem(TClass item, CancellationToken tkn)
        {
            D7NodeBase dto;

            try   { dto = D7FieldMapper.Map(item); }
            catch (Exception ex) { return(LogError("D7FieldMapper.Map", ex)); }

            if (dto == null)
            {
                return(Error_n("Failed to map to D7 fields.", ""));
            }

            D7NodeBase node;

            try   { node = await _client.Post(dto, tkn); }
            catch (Exception ex) { return(LogError("_client.Post", ex)); }

            if (node == null || node.nid < 1)
            {
                return(Error_n("Failed to add item to repo.", ""));
            }

            RaiseOneChangeCommitted();
            return(true);
        }