//public AddressSelectForm() //{ // InitializeComponent(); //} /// <summary> /// �R���X�g���N�^ /// </summary> /// <param name="ads"></param> public AddressSelectForm(Address_DS ads) { InitializeComponent(); this._addressds = ads; this.gridAddress.DataMember = "Address"; this.gridAddress.DataSource = this._addressds; }
//private bool _isAccountError = false; public ProgressForm(Account_DS.AccountRow accountRow, Address_DS addressDs, string mailSubject, string mailBody) { InitializeComponent(); this._accountRow = accountRow; this._addressDs = addressDs; this._mailBody = mailBody; this._mailSubject = mailSubject; }
public AddressDirectInputForm(Address_DS ads) { InitializeComponent(); this._ads = ads; }
/// <summary> /// OutLook�̃A�h���X����ǂݍ��� /// </summary> /// <remarks>COM�������炸Windows7�ł͎g���Ȃ����߃R�����g�A�E�g</remarks> /// <returns></returns> private Address_DS ReadOutLook() { Address_DS ads = new Address_DS(); return ads; //Outlook.Application outlook = null; //Outlook.NameSpace nameSpace = null; //Outlook.AddressLists addressList = null; //try //{ // outlook = new Outlook.Application(); // nameSpace = outlook.Session; // addressList = nameSpace.AddressLists; // //�A�h���X���X�g�͂����炭�A�h���X�̃f�B���N�g���P�ʂł���B // //���̃f�B���N�g����P�����Ă����B // foreach (Outlook.AddressList list in addressList) // { // //Entry�P�P�����ۂ̃A�h���X�ɑ�������B // //�����̓�e��擾���A�f�[�^�Z�b�g�Ɋi�[����B // foreach (Outlook.AddressEntry oEntry in list.AddressEntries) // { // //NULL�����E���łɎ�荞�܂ꂽ�s���荞�܂Ȃ��B // if ((string.IsNullOrEmpty(oEntry.Address) == false) && (ads.Address.FindByMailAddress(oEntry.Address) == null)) // { // Address_DS.AddressRow aRow = ads.Address.NewAddressRow(); // aRow.MailAddress = oEntry.Address; // ads.Address.AddAddressRow(aRow); // } // } // } //} //finally //{ // if (addressList != null) // { // System.Runtime.InteropServices.Marshal.ReleaseComObject(addressList); // } // if (nameSpace != null) // { // System.Runtime.InteropServices.Marshal.ReleaseComObject(nameSpace); // } // if (outlook != null) // { // System.Runtime.InteropServices.Marshal.ReleaseComObject(outlook); // } //} }
/// <summary> /// �w�肳�ꂽExcel�t�@�C����ǂݍ��� /// </summary> private void ReadExcel() { //Excel�t�@�C���I����A�I�����Ȃ���ΏI���B if (this.openFileExcel.ShowDialog() != DialogResult.OK) { return; } Address_DS ads = new Address_DS(); Address_DS errords = new Address_DS(); // ExcelWorkBook�I�[�v�� ExcelWorkBook wBook = new ExcelWorkBook(); wBook.Open(this.openFileExcel.FileName); try { //�P�s�ڂ�ǂݍ��� ExcelWorkSheet sheet = wBook.WorkSheets[0]; ArrayList columnList = new ArrayList(); for (int col = sheet.FirstColumn; col <= sheet.LastColumn; col++) { if (sheet.Cells[0, col].Value == null) { continue; } columnList.Add(sheet.Cells[0, col].Value); } //�ǂݍ��ݍs���Ȃ��ꍇ�͋�̃f�[�^�Z�b�g��Ԃ��B if (columnList.Count == 0) { MessageBox.Show(this, "�ǂݍ��݉\�ȍs������܂���B"); return; } using (ColumnSelectForm f = new ColumnSelectForm(columnList)) { //�s�I���ʂ�\�����A���[�U�ɓǂݍ��ލs��w�肵�Ă�炤 if (f.ShowDialog() != DialogResult.OK) { //�I�����Ȃ���A��̃f�[�^�Z�b�g��Ԃ��B return ; } int readStartRowIndex = 0; if (f.ReadFirstRow == true) readStartRowIndex = 0; else readStartRowIndex = 1; //���[�U���w�肵�����ǂݍ��� for (int row = readStartRowIndex; row <= sheet.LastRow; row++) { //NULL�₷�łɎ�荞�܂ꂽ���[���A�h���X�͂͂����B if (!((sheet.Cells[row, f.SelectColumnIndex].Value == null) || ads.Address.FindByMailAddress(sheet.Cells[row, f.SelectColumnIndex].Value.ToString()) != null)) { string mailAddr = sheet.Cells[row, f.SelectColumnIndex].Value.ToString(); //���[���A�h���X�`���̃A�h���X�̂ݓo�^ if (TKMP.Writer.MailAddressCollection.IsAddressPattern(mailAddr) == true) { Address_DS.AddressRow aRow = ads.Address.NewAddressRow(); aRow.MailAddress = mailAddr; ads.Address.AddAddressRow(aRow); } else { //���[���A�h���X�`���łȂ���̂́A�G���[���X�g�ɕۑ� Address_DS.AddressRow aeRow = errords.Address.NewAddressRow(); aeRow.MailAddress = mailAddr; errords.Address.AddAddressRow(aeRow); } } } } } finally { // ExcelWorkBook�N���[�Y wBook.Close(); } //Excel�t�@�C����ǂݎ��B this._addressds.Merge(ads); //�G���[����Z�b�g����B this._errorForm.ErrorList = errords; }
private void ReadCSV() { //CSV�t�@�C���I����A�I�����Ȃ���ΏI���B if (this.openFileCSV.ShowDialog() != DialogResult.OK) { return; } Address_DS ads = new Address_DS(); Address_DS errords = new Address_DS(); //CSV�t�@�C���̓ǂݍ��� using (TextFieldParser parser = new TextFieldParser(this.openFileCSV.FileName, System.Text.Encoding.GetEncoding("Shift-Jis"))) { //CSV�̋�蕶����Z�b�g parser.SetDelimiters(","); //�P�s�ڂ����݂��邩�`�F�b�N if (parser.EndOfData == true) { //���݂��Ȃ��ꍇ�̓��b�Z�[�W�{�b�N�X��\�����ďI�� MessageBox.Show(this, "�ǂݍ��݉\�ȍs������܂���B"); return ; } //�P�s�ڂ̓ǂݍ��� ArrayList columnList = null; string[] firstRows = null; try { firstRows = parser.ReadFields(); columnList = new ArrayList(firstRows); } catch (MalformedLineException) { //�ǂݍ��ݕs�\�ȍs�ł���A�I������B //���݂��Ȃ��ꍇ�̓��b�Z�[�W�{�b�N�X��\�����ďI�� MessageBox.Show(this, "�P�s�ڂ̃t�H�[�}�b�g�������������߁A�����s�ł��܂���B" + Environment.NewLine + "Excel�Ńt�@�C���𐳂����J���邩�m�F���Ă��������B"); return; } using (ColumnSelectForm f = new ColumnSelectForm(columnList)) { //�s�I���ʂ�\�����A���[�U�ɓǂݍ��ލs��w�肵�Ă�炤 if (f.ShowDialog() != DialogResult.OK) { //�I�����Ȃ���A��̃f�[�^�Z�b�g��Ԃ��B return; } //�P�s�ڂ�ǂݍ��ނȂ�A���̍s��f�[�^�Z�b�g�Ɋi�[�B if (f.ReadFirstRow == true) { Address_DS.AddressRow aRow = ads.Address.NewAddressRow(); aRow.MailAddress = firstRows[f.SelectColumnIndex]; ads.Address.AddAddressRow(aRow); } //���[�U���w�肵�����ǂݍ��� while (parser.EndOfData == false) { try { //NULL�����E���łɎ�荞�܂ꂽ�s���荞�܂Ȃ��B string mailAddr = parser.ReadFields()[f.SelectColumnIndex]; if ((string.IsNullOrEmpty(mailAddr) == false) && (ads.Address.FindByMailAddress(mailAddr) == null)) { if (TKMP.Writer.MailAddressCollection.IsAddressPattern(mailAddr) == true) { Address_DS.AddressRow aRow = ads.Address.NewAddressRow(); aRow.MailAddress = mailAddr; ads.Address.AddAddressRow(aRow); } else { //���[���A�h���X�`���łȂ���̂́A�G���[���X�g�ɕۑ� Address_DS.AddressRow aeRow = errords.Address.NewAddressRow(); aeRow.MailAddress = mailAddr; errords.Address.AddAddressRow(aeRow); } } } catch { //�s�̉�͂Ɏ��s�����炻�̍s��G���[���X�g�ɕۑ� Address_DS.AddressRow aeRow = errords.Address.NewAddressRow(); aeRow.MailAddress = string.Format("�i{0}�s�ڂ͓ǂݍ��݃G���[�ł��j", parser.ErrorLineNumber.ToString()); errords.Address.AddAddressRow(aeRow); } } } } //CSV�t�@�C����ǂݎ��B this._addressds.Merge(ads); //�G���[����Z�b�g����B this._errorForm.ErrorList = errords; }