예제 #1
0
        public override void DoJob()
        {
            StringBuilder sb = new StringBuilder(); // Result of the query.

            sb.AppendFormat("JobType: {0}", GetName()).AppendLine();
            
            /*
             * TODO: Properly read in connection information here.
             */
            DbConnectorInfo sourceInfo = new DbConnectorInfo("localhost\\SQLEXPRESS", "NORTHWND", "sa", "Conestoga1");
            DbConnection sourceConnection = new DbConnection(sourceInfo, "MS");

            Dictionary<string, string> keys = new Dictionary<string, string>();
            keys.Add("Customers", "CustomerID");
            keys.Add("Orders", "OrderID");

            List<string> joins = new List<string>();
            joins.Add("full");

            sb.Append("Connecting to source...").AppendLine();
            sb.AppendFormat("DbConnectorInfo:").AppendLine();
            sb.AppendFormat("server: {0}", sourceInfo.server).AppendLine();
            sb.AppendFormat("database: {0}", sourceInfo.database).AppendLine();
            sb.AppendFormat("userid: {0}", sourceInfo.userid).AppendLine();

            /*
             * Open the source and destination databases.
             */
            if (!sourceConnection.ConnectionOpen)
            {
                sourceConnection.OpenDBConnection();
            }

            /*
             * Pull data from BioLinks.
             * TODO: Figure out wtf this method even takes.
             */
            DataTable sourceData = sourceConnection.pullData(keys, joins, null, null);

            /*
             * Log the query.
             */
            foreach (DataRow row in sourceData.Rows)
            {
                foreach (DataColumn col in sourceData.Columns)
                {
                    sb.AppendFormat("{0} ", row[col]);    
                }

                sb.AppendLine();
            }

            Logger.logMessage(sb.ToString(), AppDomain.CurrentDomain.BaseDirectory + AppDomain.CurrentDomain.RelativeSearchPath + "\\Events2.txt");

            /*
             * Close the source and destination databases.
             */
            sourceConnection.CloseDBConnection();
        }
예제 #2
0
        public override void DoJob()
        {
            const string ID_COLUMN_NAME = "EmployeeID";
            const string TABLE_NAME = "Employees";

            StringBuilder sb = new StringBuilder();

            sb.AppendFormat("JobType: {0}", GetName()).AppendLine();

            /*
             * TODO: Properly read in connection information here.
             */
            DbConnectorInfo sourceInfo = new DbConnectorInfo("localhost\\SQLEXPRESS", "NORTHWND", "sa", "Conestoga1");
            destinationInfo = new DbConnectorInfo("localhost\\SQLEXPRESS", "SimpleNorthwind", "sa", "Conestoga1");

            DbConnection sourceConnection = new DbConnection(sourceInfo, "MS");
            DbConnection destinationConnection = new DbConnection(destinationInfo, "MS");

            /*
             * Build the query for updating from the table.
             */
            //List<string> columns_to_pull = new List<string>();
            //columns_to_pull.Add(ROW_KEY);
            //columns_to_pull.Add(ROW_NAME);
            //columns_to_pull.Add(TABLE_NAME);
            List<string> where_clauses = new List<string>();
            /*
             * Some janky stuff to get this working.
             */
            where_clauses.Add(ID_COLUMN_NAME + " = " + i);
            ++i;

            sb.Append("Connecting to source...").AppendLine();
            sb.AppendFormat("DbConnectorInfo:").AppendLine();
            sb.AppendFormat("server: {0}", sourceInfo.server).AppendLine();
            sb.AppendFormat("database: {0}", sourceInfo.database).AppendLine();
            sb.AppendFormat("userid: {0}", sourceInfo.userid).AppendLine();

            sb.Append("Connecting to destination...").AppendLine();
            sb.AppendFormat("DbConnectorInfo:").AppendLine();
            sb.AppendFormat("server: {0}", destinationInfo.server).AppendLine();
            sb.AppendFormat("database: {0}", destinationInfo.database).AppendLine();
            sb.AppendFormat("userid: {0}", destinationInfo.userid).AppendLine();

            /*
             * Open the source and destination databases.
             */
            if (!sourceConnection.ConnectionOpen)
            {
                sourceConnection.OpenDBConnection();
            }
            if (!destinationConnection.ConnectionOpen)
            {
                destinationConnection.OpenDBConnection();
            }

            /*
             * Pull data from BioLinks.
             * TODO: Figure out wtf this method even takes.
             */
            DataTable sourceData = sourceConnection.pullData(TABLE_NAME, null, where_clauses);

            sb.AppendLine("Source Data: ");

            foreach (DataRow row in sourceData.Rows)
            {
                sb.AppendLine(sourceData.Rows.IndexOf(row).ToString());
            }

            /*
             * Insert/Update pulled into BioTrack.
             */
            destinationConnection.insert(TABLE_NAME, sourceData);

     
            destinationConnection.insert(TABLE_NAME, sourceData);

            Logger.logMessage(sb.ToString(), AppDomain.CurrentDomain.BaseDirectory + AppDomain.CurrentDomain.RelativeSearchPath + "\\Events.txt");

            /*
             * Close the source and destination databases.
             */
            sourceConnection.CloseDBConnection();
            destinationConnection.CloseDBConnection();
        }