using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AddressBook
{
internal class AddressBook
{
public List list = new List();
string directory = string.Empty;
public AddressBook(string directory)
{
this.directory = directory;
}
public void GetItem(string filename)
{
using (var sr = new StreamReader(this.directory + filename, System.Text.Encoding.UTF8))
{
int i = 0;
while (sr.Peek() > -1)
{
string line = sr.ReadLine();
var array = line.Split(',');
if (i > 0)
{
list.Add(new Contact { 姓 = array[0], 名 = array[1], セイ = array[2], メイ = array[3], 電話 = array[4], FAX = array[5], 携帯 = array[6], 郵便番号 = array[7], 都道府県 = array[8], 市区町村 = array[9], 番地 = array[10], その他住所 = array[11], メールアドレス = array[12] });
}
i++;
}
}
}
public int MakeContactFileForGrandStreamPhone(string outboundPrefix)
{
int i = 1;
string crlf = @"\r\n";
using (var sw = new StreamWriter(this.directory + "phonebook.xml", false, System.Text.Encoding.UTF8))
{
string contactStr = "\n";
contactStr += "\n\n4\nBlacklist\n\n\n5\nWhitelist\n\n\n6\nWork\n\n\n7\nFriends\n\n\n8\nFamily\n\n";
foreach (var item in list)
{
contactStr += "\n";
contactStr += "" + i.ToString() + "\n";
contactStr += "" + item.名 + "\n";
contactStr += "" + item.姓 + "\n";
contactStr += "0\n";
contactStr += "\n";
contactStr += "" + outboundPrefix + item.電話.Replace(" ", "") + "\n";
contactStr += "1\n";
contactStr += "\n";
contactStr += "\n";
contactStr += "" + outboundPrefix + item.携帯.Replace(" ", "") + "\n";
contactStr += "1\n";
contactStr += "\n";
contactStr += "0\r\n";
contactStr += "\n";
i++;
}
contactStr += "";
sw.WriteLine(contactStr);
}
return i - 1;
}
public void SendPhoneBookXMLToWebSite(string website)
{
}
}
}