private void okBtn_Click(object sender, EventArgs e)
        {
            bool isValid = ValidateChildren();

            if (!isValid)
            {
                // Prevent closing the dialog if we've not got valid fields.
                // necessary because the name attribute name field starts empty - and hence doesn't get validated by default
                this.DialogResult = DialogResult.None;
                return;
            }
            else
            {
                this.DialogResult = DialogResult.OK;
            }

            BasePatch patch;

            if ((AttributePatchTypes)patchTypeCombo.SelectedItem == AttributePatchTypes.Patch)
            {
                patch = new PatchAttribute(elementXPathTextBox.Text, nameTextBox.Text, valueTextBox.Text);
            }
            else
            {
                patch = new SetAttribute(elementXPathTextBox.Text, nameTextBox.Text, valueTextBox.Text);
            }

            Patch = new PatchItem(patch, _treeNode);
        }
        string IsPatchApplied(PatchItem patch)
        {
            string FileName = GetFileName(patch.FileName);

            if (string.IsNullOrEmpty(FileName))
            {
                return("File Not Found");
            }

            string FileText = File.ReadAllText(FileName);

            FileText = FileText.Replace("\r\n", "\n");

            if (FileText.Contains(patch.NewLine))            //StringContains(FileText, patch.NewLine))
            {
                return("Applied");
            }

            if (FileText.Contains(patch.ExistingLine))//StringContains(FileText, patch.ExistingLine))
            {
                return("Can Be Patched");
            }

            return("Line Not Found");
        }
        private void okBtn_Click(object sender, EventArgs e)
        {
            var xml          = XElement.Parse(newElementTextBox.Text);
            var patchInstead = new PatchInstead(xPathForParent.Text, xPathForReplacement.Text, xml);

            Patch = new PatchItem(patchInstead, _treeNode);
        }
        public PatchDeleteForm(PatchItem patchItem) : this()
        {
            _treeNode = patchItem.RelatedTreeNode;

            treeView.BuildTreeView(_treeNode);

            var delete = patchItem.Patch as PatchDelete;

            xPathTextBox.Text = delete.XPathForElement;
        }
Beispiel #5
0
        public PatchNewChildForm(PatchItem patchItem) : this()
        {
            _treeNode = patchItem.RelatedTreeNode;

            newElementTextBox.ConfigureInsertionContextMenu(_rootXml.Root);
            treeView.BuildTreeView(_treeNode);

            var patch = patchItem.Patch as PatchInstead;

            xPathForParent.Text    = patch.XPathForParent;
            newElementTextBox.Text = patch.Replacement.ToString();
        }
Beispiel #6
0
        private void okButton_Click(object sender, EventArgs e)
        {
            var xml = XElement.Parse(newElementTextBox.Text);

            var patchInsert = new PatchInsert(
                parentXPathTextBox.Text,
                (ElementInsertPosition)positionComboBox.SelectedItem,
                orderXPathTextBox.Text,
                xml
                );

            Patch = new PatchItem(patchInsert, _treeNode);
        }
Beispiel #7
0
        public PatchInsertForm(PatchItem patchItem) : this()
        {
            _treeNode = patchItem.RelatedTreeNode;

            newElementTextBox.ConfigureInsertionContextMenu(_rootXml.Root);
            treeView.BuildTreeView(_treeNode);

            var patch = patchItem.Patch as PatchInsert;

            parentXPathTextBox.Text       = patch.XPathForParent;
            orderXPathTextBox.Text        = patch.XPathForOrder;
            positionComboBox.SelectedItem = patch.Position;
            newElementTextBox.Text        = patch.NewElement.ToString();
        }
        public PatchAttributeForm(PatchItem patchItem) : this()
        {
            _treeNode = patchItem.RelatedTreeNode;

            configureDefaultDropdown(_treeNode);

            treeView.BuildTreeView(_treeNode);

            var patch = patchItem.Patch as BaseAttributeChange;

            patchTypeCombo.SelectedItem = AttributePatchTypes.Patch;
            elementXPathTextBox.Text    = patch.XPathForElement;
            nameTextBox.Text            = patch.AttributeName;
            valueTextBox.Text           = patch.AttributeValue;
        }
        internal async Task RecallMessage(string convId,
                                          LCIMMessage message)
        {
            PatchCommand patch = new PatchCommand();
            PatchItem    item  = new PatchItem {
                Cid            = convId,
                Mid            = message.Id,
                From           = Client.Id,
                Recall         = true,
                Timestamp      = message.SentTimestamp,
                PatchTimestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
            };

            patch.Patches.Add(item);
            GenericCommand request = NewCommand(CommandType.Patch, OpType.Modify);

            request.PatchMessage = patch;
            await Connection.SendRequest(request);
        }
Beispiel #10
0
        public static IEnumerable <PatchItem> Load(PatchFile source)
        {
            using StreamReader reader = File.OpenText(source.Filename);

            var options = new CsvOptions {
                HeaderMode = source.HeaderMode, RowsToSkip = source.RowsToSkip, Separator = source.Separator[0]
            };

            foreach (var row in CsvReader.Read(reader, options))
            {
                var data = new PatchItem
                {
                    From = new GeoEntityId {
                        DataType = row[0], Reference = row[1], Name = row[2]
                    },
                    To = new GeoEntityId {
                        DataType = row[3], Reference = row[4], Name = row[5]
                    }
                };
                yield return(data);
            }
        }
        internal async Task UpdateMessage(string convId,
                                          LCIMMessage oldMessage,
                                          LCIMMessage newMessage)
        {
            PatchCommand patch = new PatchCommand();
            PatchItem    item  = new PatchItem {
                Cid            = convId,
                Mid            = oldMessage.Id,
                From           = Client.Id,
                Recall         = false,
                Timestamp      = oldMessage.SentTimestamp,
                PatchTimestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
            };

            if (newMessage is LCIMTypedMessage typedMessage)
            {
                item.Data = JsonConvert.SerializeObject(typedMessage.Encode());
            }
            else if (newMessage is LCIMBinaryMessage binaryMessage)
            {
                item.BinaryMsg = ByteString.CopyFrom(binaryMessage.Data);
            }
            if (newMessage.MentionIdList != null)
            {
                item.MentionPids.AddRange(newMessage.MentionIdList);
            }
            if (newMessage.MentionAll)
            {
                item.MentionAll = newMessage.MentionAll;
            }
            patch.Patches.Add(item);
            GenericCommand request = NewCommand(CommandType.Patch, OpType.Modify);

            request.PatchMessage = patch;
            GenericCommand response = await Connection.SendRequest(request);
        }
Beispiel #12
0
        private void okBtn_Click(object sender, EventArgs e)
        {
            var patchDelete = new PatchDelete(xPathTextBox.Text);

            Patch = new PatchItem(patchDelete, _treeNode);
        }
 private IEnumerable <GeoEntity> Patch(PatchItem patch, List <CrossReference> crossreferences)
 {
     return(new List <GeoEntity>());
 }