Ejemplo n.º 1
0
        /// <summary>
        /// replaces an existing <seealso cref="IndiansInc.Internals.ColumnMapItem">ColumnMapItem</seealso> with a new <seealso cref="IndiansInc.Internals.ColumnMapItem">ColumnMapItem</seealso> element
        /// </summary>
        /// <param name="index">Item position in the <seealso cref="IndiansInc.Internals.ColumnMapItemCollection">ColumnMapItemCollection</seealso></param>
        /// <param name="item"><seealso cref="IndiansInc.Internals.ColumnMapItem">ColumnMapItem</seealso> item</param>
        /// <exception cref="System.IndexOutOfRangeException">if index does not contain in the range</exception>
        public void Replace(int index, ColumnMapItem item)
        {
            if (index < 0)
            {
                throw new IndexOutOfRangeException("index");
            }
            if (index > Count - 1)
            {
                throw new IndexOutOfRangeException("index");
            }

            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            if (index == Count - 1)
            {
                List.RemoveAt(index);
                List.Add(item);
            }
            else
            {
                List.RemoveAt(index);
                if (index > Count)
                {
                    List.Add(item);
                }
                else
                {
                    List.Insert(index, item);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Method to add new <seealso cref="IndiansInc.Internals.ColumnMapItem">ColumnMapItem</seealso> into the <seealso cref="IndiansInc.Internals.ColumnMapItemCollection">ColumnMapItem Collection</seealso>.
        /// </summary>
        /// <param name="item">Item that to be added to the collection</param>
        /// <exception cref="System.ArgumentNullException">Item is null</exception>
        
        public void Add(ColumnMapItem item)
        {
            // We need to do one more implementation on adding the item.
            // we need to verify whether the destination column is already present.
            // If it is present then we should not add this because no destination can have two source

            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            ColumnMapItem existing = Find(item.DestinationColumn);
            if (existing != null)
            {
                if (existing.DestinationColumn.ToUpper() == item.DestinationColumn.ToUpper())
                {
                    throw new DuplicateColumnMappingException("Duplicate destination column found");
                }
            }

            List.Add(item);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Method to add new <seealso cref="IndiansInc.Internals.ColumnMapItem">ColumnMapItem</seealso> into the <seealso cref="IndiansInc.Internals.ColumnMapItemCollection">ColumnMapItem Collection</seealso>.
        /// </summary>
        /// <param name="item">Item that to be added to the collection</param>
        /// <exception cref="System.ArgumentNullException">Item is null</exception>

        public void Add(ColumnMapItem item)
        {
            // We need to do one more implementation on adding the item.
            // we need to verify whether the destination column is already present.
            // If it is present then we should not add this because no destination can have two source

            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            ColumnMapItem existing = Find(item.DestinationColumn);

            if (existing != null)
            {
                if (existing.DestinationColumn.ToUpper() == item.DestinationColumn.ToUpper())
                {
                    throw new DuplicateColumnMappingException("Duplicate destination column found");
                }
            }

            List.Add(item);
        }
Ejemplo n.º 4
0
        private void Form1_Load(object sender, EventArgs e)
        {
            MySql.Data.MySqlClient.MySqlConnection connection = new MySql.Data.MySqlClient.MySqlConnection("Server=localhost;Port=3306;Database=destination;Uid=root;Pwd=12345;");
            MySql.Data.MySqlClient.MySqlConnection sourceConnection = new MySql.Data.MySqlClient.MySqlConnection("Server=localhost;Port=3306;Database=users;Uid=root;Pwd=12345;");
            try
            {
                connection.Open();
                sourceConnection.Open();
                DataTable table = new DataTable();
                MySqlBulkCopy upload = new MySqlBulkCopy();
                upload.DestinationTableName = "session";
                ColumnMapItemCollection collection = new ColumnMapItemCollection();
                ColumnMapItem sessionId = new ColumnMapItem();
                ColumnMapItem userId = new ColumnMapItem();
                ColumnMapItem dateLogged = new ColumnMapItem();
                ColumnMapItem loggedFrom = new ColumnMapItem();
                ColumnMapItem active = new ColumnMapItem();

                sessionId.DataType = "text";
                sessionId.DestinationColumn = "IdSession";
                sessionId.SourceColumn = "IdSession";

                userId.DataType = "int";
                userId.DestinationColumn = "userid";
                userId.SourceColumn = "userid";

                dateLogged.DataType = "datetime";
                dateLogged.DestinationColumn = "dateLogged";
                dateLogged.SourceColumn = "dateLogged";

                loggedFrom.DataType = "text";
                loggedFrom.DestinationColumn = "loggedFrom";
                loggedFrom.SourceColumn = "loggedFrom";

                active.DataType = "int";
                active.DestinationColumn = "active";
                active.SourceColumn = "active";

                collection.Add(sessionId);
                collection.Add(userId);
                collection.Add(dateLogged);
                collection.Add(loggedFrom);
                collection.Add(active);

                upload.ColumnMapItems = collection;
                upload.DestinationDbConnection = connection;

                MySql.Data.MySqlClient.MySqlCommand command = new MySql.Data.MySqlClient.MySqlCommand("select idsession,userid,datelogged,loggedfrom,active from session", sourceConnection);
                MySql.Data.MySqlClient.MySqlDataReader reader = command.ExecuteReader();
                upload.Upload(reader);
                reader.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            connection.Close();
            connection.Dispose();
            sourceConnection.Close();
            sourceConnection.Dispose();
        }
Ejemplo n.º 5
0
        /// <summary>
        /// replaces an existing <seealso cref="IndiansInc.Internals.ColumnMapItem">ColumnMapItem</seealso> with a new <seealso cref="IndiansInc.Internals.ColumnMapItem">ColumnMapItem</seealso> element
        /// </summary>
        /// <param name="index">Item position in the <seealso cref="IndiansInc.Internals.ColumnMapItemCollection">ColumnMapItemCollection</seealso></param>
        /// <param name="item"><seealso cref="IndiansInc.Internals.ColumnMapItem">ColumnMapItem</seealso> item</param>
        /// <exception cref="System.IndexOutOfRangeException">if index does not contain in the range</exception>
        public void Replace(int index, ColumnMapItem item)
        {
            if (index < 0)
            {
                throw new IndexOutOfRangeException("index");
            }
            if (index > Count - 1)
            {
                throw new IndexOutOfRangeException("index");
            }

            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            if (index == Count - 1)
            {
                List.RemoveAt(index);
                List.Add(item);
            }
            else
            {
                List.RemoveAt(index);
                if (index > Count)
                {
                    List.Add(item);
                }
                else
                {
                    List.Insert(index, item);
                }
            }

        }