public void SendPatches(int contentItemId, string elementId, string elementName, int contentItemVersion, List<PatchModel> patches) {
            var patchModelToPatchMapper = new PatchModelToPatchMapper();
            var patchesTranslated = patches.Select(o => patchModelToPatchMapper.Map(o)).ToList();

            var draftContentItem = ContentManager.Get(contentItemId, VersionOptions.DraftRequired);

            ContentManager.UpdateEditor(draftContentItem, new HubUpdateModel(elementName, patchesTranslated));

            // TODO: This needs to be an options ('Auto Publish Item', but also allow people to osee if a draft is currently availible)
            ContentManager.Publish(draftContentItem);

            Clients.Caller.changeAcknowledged(draftContentItem.Version);

            Clients.OthersInGroup(ContentGroupName(contentItemId)).applyPatches(elementId, contentItemVersion, patches);
        }
Exemplo n.º 2
0
        public void SendPatches(int contentItemId, string elementId, string elementName, int contentItemVersion, List <PatchModel> patches)
        {
            var patchModelToPatchMapper = new PatchModelToPatchMapper();
            var patchesTranslated       = patches.Select(o => patchModelToPatchMapper.Map(o)).ToList();

            var draftContentItem = ContentManager.Get(contentItemId, VersionOptions.DraftRequired);

            ContentManager.UpdateEditor(draftContentItem, new HubUpdateModel(elementName, patchesTranslated));

            // TODO: This needs to be an options ('Auto Publish Item', but also allow people to osee if a draft is currently availible)
            ContentManager.Publish(draftContentItem);

            Clients.Caller.changeAcknowledged(draftContentItem.Version);

            Clients.OthersInGroup(ContentGroupName(contentItemId)).applyPatches(elementId, contentItemVersion, patches);
        }
        public void ShouldApplyPatch() {
            var json =
                "[{\"diffs\":[[0,\"Welcome to Orchard!\"],[1,\"kk\"],[0,\"Welcome to Orchard!\"]],\"start1\":0,\"start2\":0,\"length1\":38,\"length2\":40}]";
            var patches = JsonConvert.DeserializeObject<List<PatchModel>>(json);


            var patchModelToPatchMapper = new PatchModelToPatchMapper();
            var patchesTranslated = patches.Select(o => patchModelToPatchMapper.Map(o)).ToList();

            
            var sample = _diffMatchPatch.patch_make("Welcome to Orchard!", "Welcome to Orchard!l");
            Object[] results = _diffMatchPatch.patch_apply(sample, "Welcome to Orchard!");

            var patchesApplied = _diffMatchPatch.patch_apply(patchesTranslated, "Welcome to Orchard!");

            //Assert.That(patchesApplied);

        }
Exemplo n.º 4
0
        public void ShouldApplyPatch()
        {
            var json =
                "[{\"diffs\":[[0,\"Welcome to Orchard!\"],[1,\"kk\"],[0,\"Welcome to Orchard!\"]],\"start1\":0,\"start2\":0,\"length1\":38,\"length2\":40}]";
            var patches = JsonConvert.DeserializeObject <List <PatchModel> >(json);


            var patchModelToPatchMapper = new PatchModelToPatchMapper();
            var patchesTranslated       = patches.Select(o => patchModelToPatchMapper.Map(o)).ToList();


            var sample = _diffMatchPatch.patch_make("Welcome to Orchard!", "Welcome to Orchard!l");

            Object[] results = _diffMatchPatch.patch_apply(sample, "Welcome to Orchard!");

            var patchesApplied = _diffMatchPatch.patch_apply(patchesTranslated, "Welcome to Orchard!");

            //Assert.That(patchesApplied);
        }