コード例 #1
0
        public override global::System.Data.DataSet Clone()
        {
            Address_DS cln = ((Address_DS)(base.Clone()));

            cln.InitVars();
            cln.SchemaSerializationMode = this.SchemaSerializationMode;
            return(cln);
        }
コード例 #2
0
        //public AddressSelectForm()
        //{
        //    InitializeComponent();
        //}

        /// <summary>
        /// コンストラクタ
        /// </summary>
        /// <param name="ads"></param>
        public AddressSelectForm(Address_DS ads)
        {
            InitializeComponent();

            this._addressds             = ads;
            this.gridAddress.DataMember = "Address";
            this.gridAddress.DataSource = this._addressds;
        }
コード例 #3
0
        //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;
        }
コード例 #4
0
        public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs)
        {
            Address_DS ds = new Address_DS();

            global::System.Xml.Schema.XmlSchemaComplexType type     = new global::System.Xml.Schema.XmlSchemaComplexType();
            global::System.Xml.Schema.XmlSchemaSequence    sequence = new global::System.Xml.Schema.XmlSchemaSequence();
            global::System.Xml.Schema.XmlSchemaAny         any      = new global::System.Xml.Schema.XmlSchemaAny();
            any.Namespace = ds.Namespace;
            sequence.Items.Add(any);
            type.Particle = sequence;
            global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
            if (xs.Contains(dsSchema.TargetNamespace))
            {
                global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
                global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
                try {
                    global::System.Xml.Schema.XmlSchema schema = null;
                    dsSchema.Write(s1);
                    for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();)
                    {
                        schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                        s2.SetLength(0);
                        schema.Write(s2);
                        if ((s1.Length == s2.Length))
                        {
                            s1.Position = 0;
                            s2.Position = 0;
                            for (; ((s1.Position != s1.Length) &&
                                    (s1.ReadByte() == s2.ReadByte()));)
                            {
                                ;
                            }
                            if ((s1.Position == s1.Length))
                            {
                                return(type);
                            }
                        }
                    }
                }
                finally {
                    if ((s1 != null))
                    {
                        s1.Close();
                    }
                    if ((s2 != null))
                    {
                        s2.Close();
                    }
                }
            }
            xs.Add(dsSchema);
            return(type);
        }
コード例 #5
0
        /// <summary>
        /// OutLookのアドレス帳を読み込む
        /// </summary>
        /// <remarks>COMが見つからずWindows7では使えないためコメントアウト</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;

            //    //アドレスリストはおそらくアドレスのディレクトリ単位である。
            //    //そのディレクトリを1つずつ見ていく。
            //    foreach (Outlook.AddressList list in addressList)
            //    {
            //        //Entry1つ1つが実際のアドレスに相当する。
            //        //これらの内容を取得し、データセットに格納する。
            //        foreach (Outlook.AddressEntry oEntry in list.AddressEntries)
            //        {
            //            //NULLや空文字列・すでに取り込まれた行を取り込まない。
            //            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);
            //    }
            //}
        }
コード例 #6
0
        public AddressDirectInputForm(Address_DS ads)
        {
            InitializeComponent();

            this._ads = ads;
        }
コード例 #7
0
 public static List <Address> GetAddresses()
 {
     return(Address_DS.GetAddresses());
 }
コード例 #8
0
        private void ReadCSV()
        {
            //CSVファイル選択し、選択されなければ終了。
            if (this.openFileCSV.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            Address_DS ads     = new Address_DS();
            Address_DS errords = new Address_DS();

            //CSVファイルの読み込み
            using (TextFieldParser parser = new TextFieldParser(this.openFileCSV.FileName, System.Text.Encoding.GetEncoding("Shift-Jis")))
            {
                //CSVの区切り文字をセット
                parser.SetDelimiters(",");

                //1行目が存在するかチェック
                if (parser.EndOfData == true)
                {
                    //存在しない場合はメッセージボックスを表示して終了
                    MessageBox.Show(this, "読み込み可能な行がありません。");
                    return;
                }

                //1行目の読み込み
                ArrayList columnList = null;
                string[]  firstRows  = null;
                try
                {
                    firstRows  = parser.ReadFields();
                    columnList = new ArrayList(firstRows);
                }
                catch (MalformedLineException)
                {
                    //読み込み不可能な行であれば、終了する。
                    //存在しない場合はメッセージボックスを表示して終了
                    MessageBox.Show(this,
                                    "1行目のフォーマットがおかしいため、処理を続行できません。" + Environment.NewLine +
                                    "Excelでファイルを正しく開けるか確認してください。");
                    return;
                }

                using (ColumnSelectForm f = new ColumnSelectForm(columnList))
                {
                    //行選択画面を表示し、ユーザに読み込む行を指定してもらう
                    if (f.ShowDialog() != DialogResult.OK)
                    {
                        //選択されなければ、空のデータセットを返す。
                        return;
                    }

                    //1行目を読み込むならば、その行をデータセットに格納。
                    if (f.ReadFirstRow == true)
                    {
                        Address_DS.AddressRow aRow = ads.Address.NewAddressRow();
                        aRow.MailAddress = firstRows[f.SelectColumnIndex];
                        ads.Address.AddAddressRow(aRow);
                    }

                    //ユーザが指定した列を読み込む
                    while (parser.EndOfData == false)
                    {
                        try
                        {
                            //NULLや空文字列・すでに取り込まれた行を取り込まない。
                            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
                                {
                                    //メールアドレス形式でないものは、エラーリストに保存
                                    Address_DS.AddressRow aeRow = errords.Address.NewAddressRow();
                                    aeRow.MailAddress = mailAddr;
                                    errords.Address.AddAddressRow(aeRow);
                                }
                            }
                        }
                        catch
                        {
                            //行の解析に失敗したらその行をエラーリストに保存
                            Address_DS.AddressRow aeRow = errords.Address.NewAddressRow();
                            aeRow.MailAddress = string.Format("({0}行目は読み込みエラーです)", parser.ErrorLineNumber.ToString());
                            errords.Address.AddAddressRow(aeRow);
                        }
                    }
                }
            }

            //CSVファイルを読み取る。
            this._addressds.Merge(ads);

            //エラー情報をセットする。
            this._errorForm.ErrorList = errords;
        }
コード例 #9
0
        /// <summary>
        /// 指定されたExcelファイルを読み込む
        /// </summary>
        private void ReadExcel()
        {
            //Excelファイル選択し、選択されなければ終了。
            if (this.openFileExcel.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            Address_DS ads     = new Address_DS();
            Address_DS errords = new Address_DS();

            // ExcelWorkBookオープン
            ExcelWorkBook wBook = new ExcelWorkBook();

            wBook.Open(this.openFileExcel.FileName);
            try
            {
                //1行目を読み込む
                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);
                }

                //読み込み行がない場合は空のデータセットを返す。
                if (columnList.Count == 0)
                {
                    MessageBox.Show(this, "読み込み可能な行がありません。");
                    return;
                }

                using (ColumnSelectForm f = new ColumnSelectForm(columnList))
                {
                    //行選択画面を表示し、ユーザに読み込む行を指定してもらう
                    if (f.ShowDialog() != DialogResult.OK)
                    {
                        //選択されなければ、空のデータセットを返す。
                        return;
                    }

                    int readStartRowIndex = 0;
                    if (f.ReadFirstRow == true)
                    {
                        readStartRowIndex = 0;
                    }
                    else
                    {
                        readStartRowIndex = 1;
                    }


                    //ユーザが指定した列を読み込む
                    for (int row = readStartRowIndex; row <= sheet.LastRow; row++)
                    {
                        //NULLやすでに取り込まれたメールアドレスははずす。
                        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();
                            //メールアドレス形式のアドレスのみ登録
                            if (TKMP.Writer.MailAddressCollection.IsAddressPattern(mailAddr) == true)
                            {
                                Address_DS.AddressRow aRow = ads.Address.NewAddressRow();
                                aRow.MailAddress = mailAddr;
                                ads.Address.AddAddressRow(aRow);
                            }
                            else
                            {
                                //メールアドレス形式でないものは、エラーリストに保存
                                Address_DS.AddressRow aeRow = errords.Address.NewAddressRow();
                                aeRow.MailAddress = mailAddr;
                                errords.Address.AddAddressRow(aeRow);
                            }
                        }
                    }
                }
            }
            finally
            {
                // ExcelWorkBookクローズ
                wBook.Close();
            }

            //Excelファイルを読み取る。
            this._addressds.Merge(ads);

            //エラー情報をセットする。
            this._errorForm.ErrorList = errords;
        }
コード例 #10
0
 public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs) {
     global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType();
     global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence();
     Address_DS ds = new Address_DS();
     global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny();
     any1.Namespace = "http://www.w3.org/2001/XMLSchema";
     any1.MinOccurs = new decimal(0);
     any1.MaxOccurs = decimal.MaxValue;
     any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
     sequence.Items.Add(any1);
     global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny();
     any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1";
     any2.MinOccurs = new decimal(1);
     any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
     sequence.Items.Add(any2);
     global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute();
     attribute1.Name = "namespace";
     attribute1.FixedValue = ds.Namespace;
     type.Attributes.Add(attribute1);
     global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute();
     attribute2.Name = "tableTypeName";
     attribute2.FixedValue = "AddressDataTable";
     type.Attributes.Add(attribute2);
     type.Particle = sequence;
     global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
     if (xs.Contains(dsSchema.TargetNamespace)) {
         global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
         global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
         try {
             global::System.Xml.Schema.XmlSchema schema = null;
             dsSchema.Write(s1);
             for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) {
                 schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                 s2.SetLength(0);
                 schema.Write(s2);
                 if ((s1.Length == s2.Length)) {
                     s1.Position = 0;
                     s2.Position = 0;
                     for (; ((s1.Position != s1.Length) 
                                 && (s1.ReadByte() == s2.ReadByte())); ) {
                         ;
                     }
                     if ((s1.Position == s1.Length)) {
                         return type;
                     }
                 }
             }
         }
         finally {
             if ((s1 != null)) {
                 s1.Close();
             }
             if ((s2 != null)) {
                 s2.Close();
             }
         }
     }
     xs.Add(dsSchema);
     return type;
 }
コード例 #11
0
 public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) {
     Address_DS ds = new Address_DS();
     global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType();
     global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence();
     global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny();
     any.Namespace = ds.Namespace;
     sequence.Items.Add(any);
     type.Particle = sequence;
     global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
     if (xs.Contains(dsSchema.TargetNamespace)) {
         global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
         global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
         try {
             global::System.Xml.Schema.XmlSchema schema = null;
             dsSchema.Write(s1);
             for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) {
                 schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                 s2.SetLength(0);
                 schema.Write(s2);
                 if ((s1.Length == s2.Length)) {
                     s1.Position = 0;
                     s2.Position = 0;
                     for (; ((s1.Position != s1.Length) 
                                 && (s1.ReadByte() == s2.ReadByte())); ) {
                         ;
                     }
                     if ((s1.Position == s1.Length)) {
                         return type;
                     }
                 }
             }
         }
         finally {
             if ((s1 != null)) {
                 s1.Close();
             }
             if ((s2 != null)) {
                 s2.Close();
             }
         }
     }
     xs.Add(dsSchema);
     return type;
 }
コード例 #12
0
            public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs)
            {
                global::System.Xml.Schema.XmlSchemaComplexType type     = new global::System.Xml.Schema.XmlSchemaComplexType();
                global::System.Xml.Schema.XmlSchemaSequence    sequence = new global::System.Xml.Schema.XmlSchemaSequence();
                Address_DS ds = new Address_DS();

                global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny();
                any1.Namespace       = "http://www.w3.org/2001/XMLSchema";
                any1.MinOccurs       = new decimal(0);
                any1.MaxOccurs       = decimal.MaxValue;
                any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
                sequence.Items.Add(any1);
                global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny();
                any2.Namespace       = "urn:schemas-microsoft-com:xml-diffgram-v1";
                any2.MinOccurs       = new decimal(1);
                any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
                sequence.Items.Add(any2);
                global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute();
                attribute1.Name       = "namespace";
                attribute1.FixedValue = ds.Namespace;
                type.Attributes.Add(attribute1);
                global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute();
                attribute2.Name       = "tableTypeName";
                attribute2.FixedValue = "AddressDataTable";
                type.Attributes.Add(attribute2);
                type.Particle = sequence;
                global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
                if (xs.Contains(dsSchema.TargetNamespace))
                {
                    global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
                    global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
                    try {
                        global::System.Xml.Schema.XmlSchema schema = null;
                        dsSchema.Write(s1);
                        for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();)
                        {
                            schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                            s2.SetLength(0);
                            schema.Write(s2);
                            if ((s1.Length == s2.Length))
                            {
                                s1.Position = 0;
                                s2.Position = 0;
                                for (; ((s1.Position != s1.Length) &&
                                        (s1.ReadByte() == s2.ReadByte()));)
                                {
                                    ;
                                }
                                if ((s1.Position == s1.Length))
                                {
                                    return(type);
                                }
                            }
                        }
                    }
                    finally {
                        if ((s1 != null))
                        {
                            s1.Close();
                        }
                        if ((s2 != null))
                        {
                            s2.Close();
                        }
                    }
                }
                xs.Add(dsSchema);
                return(type);
            }