CSDN上写博客让人很纠结,因为很慢,而且会丢失信息,这让我很郁闷,为了这个我都想将CSDN上的博客搬家到CNBLOG上去了。但是发现使用WLW既可以写CSDN的博客,也可以写CNBLOG的博客,我有想试一下,如果可以的话就不搬家了。我还是喜欢CSDN的环境。
下面测试代码能否插入。这里使用了插件Paste AS VS Code,而不是使用WindowsLiveWriter.SourceCode.dll这个插件。
Code Snippet
- Private Sub cmdImportUsers_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdImportUsers.Click
- Dim xmlDoc As New XmlDocument
- xmlDoc.LoadXml(txtUserXML.Text)
- ' update the user record in the database
- Dim responseBuilder As StringBuilder = New StringBuilder()
- For Each xmlItem As XmlElement In xmlDoc.SelectNodes("/Users/User")
- Dim oUserInfo As New UserInfo
- oUserInfo.PortalID = 0
- oUserInfo.Membership.Username = GetXmlItemValue(xmlItem, "Username")
- oUserInfo.Username = GetXmlItemValue(xmlItem, "Username")
- oUserInfo.Profile.FirstName = GetXmlItemValue(xmlItem, "FirstName")
- oUserInfo.FirstName = GetXmlItemValue(xmlItem, "FirstName")
- oUserInfo.Profile.LastName = GetXmlItemValue(xmlItem, "LastName")
- oUserInfo.LastName = GetXmlItemValue(xmlItem, "LastName")
- oUserInfo.Profile.Unit = GetXmlItemValue(xmlItem, "Unit")
- oUserInfo.Profile.Street = GetXmlItemValue(xmlItem, "Street")
- oUserInfo.Profile.City = GetXmlItemValue(xmlItem, "City")
- oUserInfo.Profile.Region = GetXmlItemValue(xmlItem, "Region")
- oUserInfo.Profile.PostalCode = GetXmlItemValue(xmlItem, "PostalCode")
- oUserInfo.Profile.Country = GetXmlItemValue(xmlItem, "Country")
- oUserInfo.Profile.Telephone = GetXmlItemValue(xmlItem, "Telephone")
- oUserInfo.Membership.Email = GetXmlItemValue(xmlItem, "Email")
- oUserInfo.Email = GetXmlItemValue(xmlItem, "Email")
- oUserInfo.Membership.Approved = True
- oUserInfo.AffiliateID = Null.NullInteger
- oUserInfo.Membership.Password = GetXmlItemValue(xmlItem, "Password")
- Dim createStatus As UserCreateStatus = UserController.CreateUser(oUserInfo)
- ' If createStatus = UserCreateStatus.Success Then
- ' responseBuilder.AppendLine(String.Format("User '{0}' created successfully", oUserInfo.Username))
- ' Else
- ' responseBuilder.AppendLine(String.Format("User '{0}' creation failed: {1}", oUserInfo.Username, [Enum].GetName(GetType(UserCreateStatus), createStatus)))
- 'End If
- '只输出导入不成功的用户。
- If createStatus <> UserCreateStatus.Success Then
- responseBuilder.AppendLine(String.Format("User '{0}' creation failed: {1}", oUserInfo.Username, [Enum].GetName(GetType(UserCreateStatus), createStatus)))
- End If
- Next
- txtUserXML.Text = responseBuilder.ToString()
- End Sub
本文转自xwdreamer博客园博客,原文链接:http://www.cnblogs.com/xwdreamer/archive/2010/06/04/2297127.html,如需转载请自行联系原作者