コード例 #1
0
        internal async Task DeleteThisItemAsync(DavFolder parentFolder)
        {
            await Context.ExecuteNonQueryAsync(
                "DELETE FROM Item WHERE ItemId = @ItemID",
                "@ItemID", ItemId);

            if (parentFolder != null)
            {
                await parentFolder.UpdateModifiedAsync();
            }
        }
コード例 #2
0
        internal async Task MoveThisItemAsync(DavFolder destFolder, string destName, DavFolder parent)
        {
            string command =
                @"UPDATE Item SET
                     Name = @Name,
                     ParentItemId = @Parent
                  WHERE ItemId = @ItemID";

            await Context.ExecuteNonQueryAsync(
                command,
                "@ItemID", ItemId,
                "@Name", destName,
                "@Parent", destFolder.ItemId);

            command = @"DELETE FROM Lock WHERE ItemID = @ItemID";

            await Context.ExecuteNonQueryAsync(
                command,
                "@ItemID", ItemId);

            await parent.UpdateModifiedAsync();

            await destFolder.UpdateModifiedAsync();
        }
コード例 #3
0
        internal async Task <DavFolder> CopyThisItemAsync(DavFolder destFolder, DavHierarchyItem destItem, string destName)
        {
            // returns created folder, if any, otherwise null
            DavFolder createdFolder = null;

            Guid destID;

            if (destItem == null)
            {
                // copy item
                string commandText =
                    @"INSERT INTO Item(
                           ItemId
                         , Name
                         , Created
                         , Modified
                         , ParentItemId
                         , ItemType
                         , Content
                         , ContentType
                         , SerialNumber
                         , TotalContentLength
                         , LastChunkSaved
                         , FileAttributes
                         )
                      SELECT
                           @Identity
                         , @Name
                         , GETUTCDATE()
                         , GETUTCDATE()
                         , @Parent
                         , ItemType
                         , Content
                         , ContentType
                         , SerialNumber
                         , TotalContentLength
                         , LastChunkSaved
                         , FileAttributes
                      FROM Item
                      WHERE ItemId = @ItemId";

                destID = Guid.NewGuid();
                await Context.ExecuteNonQueryAsync(
                    commandText,
                    "@Name", destName,
                    "@Parent", destFolder.ItemId,
                    "@ItemId", ItemId,
                    "@Identity", destID);

                await destFolder.UpdateModifiedAsync();

                if (this is IFolderAsync)
                {
                    createdFolder = new DavFolder(
                        Context,
                        destID,
                        destFolder.ItemId,
                        destName,
                        destFolder.Path + EncodeUtil.EncodeUrlPart(destName) + "/",
                        DateTime.UtcNow,
                        DateTime.UtcNow, fileAttributes);
                }
            }
            else
            {
                // update existing destination
                destID = destItem.ItemId;

                string commandText = @"UPDATE Item SET
                                       Modified = GETUTCDATE()
                                       , ItemType = src.ItemType
                                       , ContentType = src.ContentType
                                       FROM (SELECT * FROM Item WHERE ItemId=@SrcID) src
                                       WHERE Item.ItemId=@DestID";

                await Context.ExecuteNonQueryAsync(
                    commandText,
                    "@SrcID", ItemId,
                    "@DestID", destID);

                // remove old properties from the destination
                await Context.ExecuteNonQueryAsync(
                    "DELETE FROM Property WHERE ItemID = @ItemID",
                    "@ItemID", destID);
            }

            // copy properties
            string command =
                @"INSERT INTO Property(ItemID, Name, Namespace, PropVal)
                  SELECT @DestID, Name, Namespace, PropVal
                  FROM Property
                  WHERE ItemID = @SrcID";

            await Context.ExecuteNonQueryAsync(
                command,
                "@SrcID", ItemId,
                "@DestID", destID);

            return(createdFolder);
        }