点击(此处)折叠或打开
- /* Microsoft SQL Server Integration Services Script Component
- * Write scripts using Microsoft Visual C# 2008.
- * ScriptMain is the entry point class of the script.*/
- using System;
- using System.Data;
- using Microsoft.SqlServer.Dts.Pipeline.Wrapper;
- using Microsoft.SqlServer.Dts.Runtime.Wrapper;
- using System.Data.SqlClient;
- using MySql.Data.MySqlClient;
- using System.Windows.Forms;
- [Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute]
- public class ScriptMain : UserComponent
- {
- private MySqlConnection conn;
- private MySqlDataReader reader;
- public override void AcquireConnections(object Transaction)
- {
- base.AcquireConnections(Transaction);
- this.conn = (MySqlConnection)this.Connections.source.AcquireConnection(null);
- }
- public override void PreExecute()
- {
- base.PreExecute();
- SqlConnection msconn = (SqlConnection)this.Connections.target.AcquireConnection(null);
- SqlCommand mscmd = new SqlCommand("select top 1 id from gt_campaign_la order by id desc", msconn);
- object ohasid = mscmd.ExecuteScalar();
- Int64 hasid;
- if (ohasid == null)
- {
- hasid = 0;
- }
- else
- {
- hasid = Convert.ToInt64(ohasid);
- }
- mscmd.Dispose();
- msconn.Close();
- string sql = "select * from gt_campaign_log where id>@id and create_time;
- MySqlCommand mysqlcmd = new MySqlCommand(sql, this.conn);
- MySqlParameter param1 = new MySqlParameter("@id", hasid);
- mysqlcmd.Parameters.Add(param1);
- string a = DateTime.Now.AddHours(-22).ToString("yyyy-MM-dd 00:00:00");
- mysqlcmd.Parameters.Add(new MySqlParameter("@time", a));
- this.reader = mysqlcmd.ExecuteReader();
- }
- public override void PostExecute()
- {
- base.PostExecute();
- this.reader.Close();
- }
- public override void CreateNewOutputRows()
- {
- while (this.reader.Read())
- {
- this.outputBuffer.AddRow();
- this.outputBuffer.id = this.reader.GetInt64("id");
- if (this.reader.IsDBNull(1))
- {
- this.outputBuffer.utmsource_IsNull = true;
- }
- else
- {
- this.outputBuffer.utmsource = this.reader.GetString("utm_source");
- }
- if (this.reader.IsDBNull(2))
- {
- this.outputBuffer.utmmedium_IsNull = true;
- }
- else
- {
- this.outputBuffer.utmmedium = this.reader.GetString("utm_medium");
- }
- if (this.reader.IsDBNull(3))
- {
- this.outputBuffer.utmcampaign_IsNull = true;
- }
- else
- {
- this.outputBuffer.utmcampaign = this.reader.GetString("utm_campaign");
- }
- if (this.reader.IsDBNull(4))
- {
- this.outputBuffer.cecid_IsNull = true;
- }
- else
- {
- this.outputBuffer.cecid = this.reader.GetString("ce_cid");
- }
- if (this.reader.IsDBNull(5))
- {
- this.outputBuffer.pubid_IsNull = true;
- }
- else
- {
- this.outputBuffer.pubid = this.reader.GetString("pub_id");
- }
- if (this.reader.IsDBNull(6))
- {
- this.outputBuffer.utmuserinfo_IsNull = true;
- }
- else
- {
- this.outputBuffer.utmuserinfo = this.reader.GetString("utm_userinfo");
- }
- if (this.reader.IsDBNull(7))
- {
- this.outputBuffer.locale_IsNull = true;
- }
- else
- {
- this.outputBuffer.locale = this.reader.GetString("locale");
- }
- if (this.reader.IsDBNull(8))
- {
- this.outputBuffer.minage_IsNull = true;
- }
- else
- {
- this.outputBuffer.minage = this.reader.GetString("min_age");
- }
- if (this.reader.IsDBNull(9))
- {
- this.outputBuffer.maxage_IsNull = true;
- }
- else
- {
- this.outputBuffer.maxage = this.reader.GetString("max_age");
- }
- if (this.reader.IsDBNull(10))
- {
- this.outputBuffer.gender_IsNull = true;
- }
- else
- {
- this.outputBuffer.gender = this.reader.GetString("gender");
- }
- if (this.reader.IsDBNull(11))
- {
- this.outputBuffer.country_IsNull = true;
- }
- else
- {
- this.outputBuffer.country = this.reader.GetString("country");
- }
- if (this.reader.IsDBNull(12))
- {
- this.outputBuffer.ip_IsNull = true;
- }
- else
- {
- this.outputBuffer.ip = this.reader.GetString("ip");
- }
- if (this.reader.IsDBNull(13))
- {
- this.outputBuffer.ipcountry_IsNull = true;
- }
- else
- {
- this.outputBuffer.ipcountry = this.reader.GetString("ip_country");
- }
- if (this.reader.IsDBNull(15))
- {
- this.outputBuffer.fromgame_IsNull = true;
- }
- else
- {
- this.outputBuffer.fromgame = this.reader.GetInt32("from_game");
- }
- if (this.reader.IsDBNull(16))
- {
- this.outputBuffer.logintype_IsNull = true;
- }
- else
- {
- this.outputBuffer.logintype = this.reader.GetString("login_type");
- }
- if (this.reader.IsDBNull(17))
- {
- this.outputBuffer.isreg_IsNull = true;
- }
- else
- {
- this.outputBuffer.isreg = this.reader.GetByte("is_reg");
- }
- if (this.reader.IsDBNull(18))
- {
- this.outputBuffer.loginuserid_IsNull = true;
- }
- else
- {
- this.outputBuffer.loginuserid = this.reader.GetInt64("login_userid");
- }
- if (this.reader.IsDBNull(19))
- {
- this.outputBuffer.loginusername_IsNull = true;
- }
- else
- {
- this.outputBuffer.loginusername = this.reader.GetString("login_username");
- }
- if (this.reader.IsDBNull(20))
- {
- this.outputBuffer.logintime_IsNull = true;
- }
- else
- {
- this.outputBuffer.logintime = this.reader.GetDateTime("login_time");
- }
- if (this.reader.IsDBNull(22))
- {
- this.outputBuffer.createtime_IsNull = true;
- }
- else
- {
- this.outputBuffer.createtime = this.reader.GetDateTime("create_time");
- }
- if (this.reader.IsDBNull(23))
- {
- this.outputBuffer.beblocked_IsNull = true;
- }
- else
- {
- this.outputBuffer.beblocked = this.reader.GetByte("be_blocked");
- }
- if (this.reader.IsDBNull(24))
- {
- this.outputBuffer.newuserforgame_IsNull = true;
- }
- else
- {
- this.outputBuffer.newuserforgame = this.reader.GetByte("new_user_for_game");
- }
- if (this.reader.IsDBNull(25))
- {
- this.outputBuffer.hasshowcode_IsNull = true;
- }
- else
- {
- this.outputBuffer.hasshowcode = this.reader.GetByte("has_show_code");
- }
- if (this.reader.IsDBNull(27))
- {
- this.outputBuffer.firstlogingame_IsNull = true;
- }
- else
- {
- this.outputBuffer.firstlogingame = this.reader.GetInt32("first_login_game");
- }
- if (this.reader.IsDBNull(28))
- {
- this.outputBuffer.firstlogingametime_IsNull = true;
- }
- else
- {
- this.outputBuffer.firstlogingametime = this.reader.GetDateTime("first_login_game_time");
- }
- if (this.reader.IsDBNull(29))
- {
- this.outputBuffer.hasid_IsNull = true;
- }
- else
- {
- this.outputBuffer.hasid = this.reader.GetString("has_id");
- }
- }
- }
- public override void ReleaseConnections()
- {
- base.ReleaseConnections();
- this.Connections.source.ReleaseConnection(this.conn);
- }
- }