Migrating Wiki Pages Remotely – Part 02

Note, this series starts at blogs.msdn.com/dwinter/archive/2008/06/28/migrating-wiki-pages-remotely-part-01.aspx

Before we can dig into the data itself, we need to know what is there. I built some simple functionality to enumerate the available Wiki Libraries and allow for selection. I write the name of the Library into a textbox after it is selected so that the user can manually change it if they want, or skip the enumeration step if they know the name of the list and want to save the time from making that trip to the servers for the source or destination values. Here is the enumeration code that you could essentially duplicate for the destination.

private void btn_EnumWikis_Click(object sender, EventArgs e)

{

    Trace.AutoFlush = true;

    lst_Wikis.Items.Clear();

    Trace.WriteLine("Cleared Server 1 WikiList");

    txt_Status.Text += "Cleared Server 1 WikiList\r\n";

    txt_Status.Select(txt_Status.Text.Length, 0);

    txt_Status.ScrollToCaret();

    if (lst_Wikis.Items.Count == 0)

    {

        Server1WS.Lists s1L = new WikiMigrator.Server1WS.Lists();

        s1L.Url = txt_SiteName.Text.Trim().TrimEnd("/".ToCharArray()) +"/_vti_bin/lists.asmx";

        s1L.Credentials = System.Net.CredentialCache.DefaultCredentials;

        try

        {

            XmlNode ndLists = s1L.GetListCollection();

            foreach (XmlNode list in ndLists.ChildNodes)

            {

                if (list.Attributes["ServerTemplate"].Value == "119")

                {

                    Trace.WriteLine("Found Source: " + list.Attributes["Title"].Value);

                    txt_Status.Text += "Found Source: " + list.Attributes["Title"].Value + "\r\n";

                    txt_Status.Select(txt_Status.Text.Length, 0);

                    txt_Status.ScrollToCaret();

                    lst_Wikis.Items.Add(list.Attributes["Title"].Value);

                }

            }

        }

        catch {}

    }

}

Here is how I was populating the Wiki 1 textbox for manual control—like with the listboxes, you can duplicate this between the source and destination objects:

private void lst_Wikis_SelectedIndexChanged(object sender, EventArgs e)

{

    Trace.AutoFlush = true;

    if (lst_Wikis.SelectedItem != null)

    {

        txt_SelectedWiki.Text = lst_Wikis.SelectedItem.ToString().TrimStart("/".ToCharArray());

        Trace.WriteLine("Wiki 1 set to: " + txt_SelectedWiki.Text);

        txt_Status.Text += "Wiki 1 set to: " + txt_SelectedWiki.Text + "\r\n";

        txt_Status.Select(txt_Status.Text.Length, 0);

        txt_Status.ScrollToCaret();

    }

}

Part 03:
blogs.msdn.com/dwinter/archive/2008/06/28/migrating-wiki-pages-remotely-part-03.aspx