private void CreateChildrenNodes(ConfluencePageTreeTaskExecutor task, ChildPagesOutput_Result lastProcessed, string currentParentId, string parentSpace, TreeNodeCollection nodes) { string oldParentId = currentParentId; foreach (TreeNode node in nodes) { if (node.Checked && node.Tag != null) { ChildPagesOutput_Result tag = node.Tag as ChildPagesOutput_Result; if (tag != null) { lastProcessed = task.CreateChildPageX( AppSettingsHelper.GetValue(Strings.CREATE_PAGE_URL_KEY), JsonConvert.SerializeObject( task.CreateChildPageInstance(parentSpace, currentParentId, string.Format("{0} - {1}", tag.ParentSpace, tag.title), string.Format(AppSettingsHelper.GetValue(Strings.INCLUDE_PAGECONTENT_KEY), tag.title, tag.ParentSpace) ) ) ); if (node.Nodes.Count > 0) { currentParentId = lastProcessed.id; CreateChildrenNodes(task, lastProcessed, currentParentId, parentSpace, node.Nodes); currentParentId = oldParentId; } } } } }
private void AppendButton_Click(object sender, EventArgs e) { ConfluenceContext.SaveCredentials(AppSettingsHelper.GetValue("username"), AppSettingsHelper.GetValue("password")); ChildPagesOutput_Result firstchecked = GetFirstChecked(); ConfluencePageTreeTaskExecutor task = new ConfluencePageTreeTaskExecutor(); ChildPagesOutput_Result lastProcessed = firstchecked; string leftSideSpace = firstchecked.ParentSpace; string currentParentId = firstchecked.id; List <ChildPagesOutput_Result> list = new List <ChildPagesOutput_Result>(); List <ChildPagesOutput_Result> result = GetAllToAppend(this.ConfluencetreeView2.Nodes, list); foreach (ChildPagesOutput_Result node in result) { lastProcessed = task.CreateChildPageX( AppSettingsHelper.GetValue(Strings.CREATE_PAGE_URL_KEY), JsonConvert.SerializeObject( task.CreateChildPageInstance(leftSideSpace, currentParentId, string.Format("{0} - {1}", node.ParentSpace, node.title), string.Format(AppSettingsHelper.GetValue(Strings.INCLUDE_PAGECONTENT_KEY), node.title, node.ParentSpace) ) ) ); } MaincomboBox_SelectedIndexChanged(sender, e); MessageBox.Show("All Done."); }
private void Copybutton_Click(object sender, EventArgs e) { if (MaincomboBox.SelectedIndex == 0 || TargetcomboBox.SelectedIndex == 0) { return; } ConfluenceContext.SaveCredentials(AppSettingsHelper.GetValue("username"), AppSettingsHelper.GetValue("password")); ChildPagesOutput_Result firstchecked = GetFirstChecked(); ConfluencePageTreeTaskExecutor task = new ConfluencePageTreeTaskExecutor(); ChildPagesOutput_Result lastProcessed = firstchecked; string leftSideSpace = firstchecked.ParentSpace; string currentParentId = firstchecked.id; var projectNode = this.ConfluencetreeView2.Nodes[0]; if (projectNode != null) { lastProcessed = task.CreateChildPageX( AppSettingsHelper.GetValue(Strings.CREATE_PAGE_URL_KEY), JsonConvert.SerializeObject( task.CreateChildPageInstance(leftSideSpace, currentParentId, projectNode.Text, string.Format(AppSettingsHelper.GetValue(Strings.INCLUDE_PAGECONTENT_KEY), string.Format("{0} Home", projectNode.Text), rightSideSpace) ) ) ); } firstchecked = lastProcessed; currentParentId = lastProcessed.id; foreach (TreeNode node in this.ConfluencetreeView2.Nodes[0].Nodes) { if (node.Checked && node.Tag != null) { ChildPagesOutput_Result tag = node.Tag as ChildPagesOutput_Result; if (tag != null) { lastProcessed = task.CreateChildPageX( AppSettingsHelper.GetValue(Strings.CREATE_PAGE_URL_KEY), JsonConvert.SerializeObject( task.CreateChildPageInstance(leftSideSpace, currentParentId, string.Format("{0} - {1}", tag.ParentSpace, tag.title), string.Format(AppSettingsHelper.GetValue(Strings.INCLUDE_PAGECONTENT_KEY), tag.title, tag.ParentSpace) ) ) ); if (node.Nodes.Count > 0) { currentParentId = lastProcessed.id; CreateChildrenNodes(task, lastProcessed, currentParentId, leftSideSpace, node.Nodes); currentParentId = firstchecked.id; } } } } MessageBox.Show("All Done."); }