ad계정목록 csv내보내기 기능 추가
This commit is contained in:
@@ -9,6 +9,9 @@ using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using System.DirectoryServices;
|
||||
using System.IO;
|
||||
using CsvHelper;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Project._Common
|
||||
{
|
||||
@@ -72,7 +75,8 @@ namespace Project._Common
|
||||
try
|
||||
{
|
||||
Nodename = deParent.SchemaClassName;
|
||||
} catch (Exception ex)
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Util.MsgE(ex.Message + "\n" + tbEntry.Text);
|
||||
Nodename = string.Empty;
|
||||
@@ -187,8 +191,8 @@ namespace Project._Common
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
FCOMMON.Util.MsgI("exit");
|
||||
this.listView1.Visible = true;
|
||||
}
|
||||
@@ -204,7 +208,7 @@ namespace Project._Common
|
||||
|
||||
this.prb1.Maximum = items.Count;
|
||||
this.prb1.Value = 0;
|
||||
foreach(ListViewItem item in items)
|
||||
foreach (ListViewItem item in items)
|
||||
{
|
||||
|
||||
string sn = item.SubItems[0].Text; //이름
|
||||
@@ -221,9 +225,9 @@ namespace Project._Common
|
||||
try
|
||||
{
|
||||
//이 대상의 id가 잇는지 체크한다.
|
||||
if(taUser.ExistID(pager) > 0)
|
||||
if (taUser.ExistID(pager) > 0)
|
||||
{
|
||||
taUser.UpdateDept(dept, sn , title, pager);
|
||||
taUser.UpdateDept(dept, sn, title, pager);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -233,16 +237,16 @@ namespace Project._Common
|
||||
whencre,
|
||||
"Auto Gen", FCOMMON.info.Login.no, DateTime.Now);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
catch (Exception eX)
|
||||
{
|
||||
Console.WriteLine(sn + eX.Message);
|
||||
}
|
||||
|
||||
|
||||
this.prb1.Value += 1;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void allSelectToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
@@ -262,5 +266,47 @@ namespace Project._Common
|
||||
foreach (ListViewItem item in this.listView1.Items)
|
||||
item.Checked = false;
|
||||
}
|
||||
|
||||
private void toolStripButton2_Click(object sender, EventArgs e)
|
||||
{
|
||||
var sd = new SaveFileDialog();
|
||||
sd.Filter = "csv|*.csv";
|
||||
if (sd.ShowDialog() != DialogResult.OK) return;
|
||||
var records = new List<List<string>>();
|
||||
var data = new List<object>();
|
||||
|
||||
//데이터입력
|
||||
foreach (ListViewItem item in this.listView1.Items)
|
||||
{
|
||||
|
||||
|
||||
data.Add(new
|
||||
{
|
||||
sn = item.SubItems[0].Text,
|
||||
cn = item.SubItems[1].Text,
|
||||
disp = item.SubItems[2].Text,
|
||||
dept = item.SubItems[3].Text,
|
||||
title = item.SubItems[4].Text,
|
||||
tel = item.SubItems[5].Text,
|
||||
mail = item.SubItems[6].Text,
|
||||
pager = item.SubItems[7].Text,
|
||||
empno = item.SubItems[8].Text,
|
||||
when = item.SubItems[9].Text,
|
||||
});
|
||||
|
||||
//records.Add(data);
|
||||
}
|
||||
using (var writer = new StreamWriter(sd.FileName,false, System.Text.Encoding.Default))
|
||||
using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))
|
||||
{
|
||||
//foreach (var item in records)
|
||||
//{
|
||||
// csv.WriteRecord(item);
|
||||
//}
|
||||
|
||||
csv.WriteRecords(data);
|
||||
}
|
||||
FCOMMON.Util.MsgI("저장완료");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user