mirror of
https://github.com/RaySollium99/MSNPSharp.git
synced 2025-09-05 14:27:45 -04:00
Add the files
This commit is contained in:
parent
f52694709e
commit
50aabc8afc
312 changed files with 95444 additions and 0 deletions
73
Example/ImportContacts.cs
Normal file
73
Example/ImportContacts.cs
Normal file
|
@ -0,0 +1,73 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using MSNPSharp;
|
||||
|
||||
namespace MSNPSharpClient
|
||||
{
|
||||
public partial class ImportContacts : Form
|
||||
{
|
||||
public ImportContacts()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
|
||||
private string invitationMessage = String.Empty;
|
||||
public string InvitationMessage
|
||||
{
|
||||
get
|
||||
{
|
||||
return invitationMessage;
|
||||
}
|
||||
}
|
||||
|
||||
private List<string> _contacts = new List<string>();
|
||||
public List<string> Contacts
|
||||
{
|
||||
get
|
||||
{
|
||||
return _contacts;
|
||||
}
|
||||
}
|
||||
|
||||
private void browseFile_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (DialogResult.OK == openFileDialog.ShowDialog(this))
|
||||
{
|
||||
Contacts.Clear();
|
||||
invitationMessage = txtInvitation.Text;
|
||||
try
|
||||
{
|
||||
XmlDocument doc = new XmlDocument();
|
||||
doc.LoadXml(File.ReadAllText(openFileDialog.FileName));
|
||||
|
||||
XmlNodeList contacts = doc.GetElementsByTagName("contact");
|
||||
foreach (XmlNode contactNode in contacts)
|
||||
{
|
||||
if (ClientType.PassportMember == (ClientType)Convert.ToInt32(contactNode.Attributes["type"].Value))
|
||||
{
|
||||
Contacts.Add(contactNode.InnerText.ToLower(System.Globalization.CultureInfo.InvariantCulture));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
MessageBox.Show(Contacts.Count.ToString() + " contacts to be imported.");
|
||||
}
|
||||
}
|
||||
|
||||
private void button_Click(object sender, EventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue