コード例 #1
0
ファイル: ImportUser.cs プロジェクト: gowhy/LoveBank
 public void Import()
 {
     var mySqlHelper = new MySqlHelper(MySql);
     var sqlHelper = new SqlHelper(SqlServer);
     var mysql = string.Format("select * from qdt_user");
     var dt = mySqlHelper.ExecuteDataTable(mysql);
     var sql = "";
     var n = 0;
     for (var i = 0; i < dt.Rows.Count; i++)
     {
         sql += "INSERT INTO qdt_user (id,user_name,user_pwd,sex,create_time,update_time,login_time,login_ip,group_id,is_effect," +
                "is_delete,email,email_passed,real_name,idno,idcard_passed,mobile,mobile_passed,pay_pwd,pay_pwd_passed," +
                "is_lender,is_borrower,money,lock_money,point,quota,pid) " +
                "VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}','{21}','{22}','{23}','{24}','{25}','{26}');\r\n"
                .FormatWith(dt.Rows[i]["id"], dt.Rows[i]["user_name"], dt.Rows[i]["user_pwd"].ToString().ToUpper(), dt.Rows[i]["sex"], GetTime(dt.Rows[i]["create_time"]), GetTime(dt.Rows[i]["update_time"]), GetTime(dt.Rows[i]["login_time"]), dt.Rows[i]["login_ip"], dt.Rows[i]["group_id"], dt.Rows[i]["is_effect"],
                dt.Rows[i]["is_delete"], dt.Rows[i]["email"], true, dt.Rows[i]["real_name"], dt.Rows[i]["idno"], dt.Rows[i]["idcardpassed"], dt.Rows[i]["mobile"], dt.Rows[i]["mobilepassed"], dt.Rows[i]["pay_pwd"].ToString().ToUpper(), !string.IsNullOrWhiteSpace(dt.Rows[i]["pay_pwd"].ToString()),
                !dt.Rows[i]["group_id"].Equals(2), dt.Rows[i]["group_id"].Equals(2), dt.Rows[i]["money"], dt.Rows[i]["lock_money"], dt.Rows[i]["point"], dt.Rows[i]["quota"], dt.Rows[i]["pid"]).Replace("'NULL'", "NULL");
         if ((i + 1) % 30 != 0) continue;
         n += sqlHelper.ExecuteNonQuery(sql);
         sql = "";
     }
     if (!string.IsNullOrWhiteSpace(sql))
     n += sqlHelper.ExecuteNonQuery(sql);
     Console.WriteLine("成功导入user表:" + n + "条数据!");
 }
コード例 #2
0
ファイル: ImportDeal.cs プロジェクト: gowhy/LoveBank
 public void Import()
 {
     var mySqlHelper = new MySqlHelper(MySql);
     var sqlHelper = new SqlHelper(SqlServer);
     var mysql = string.Format("select * from qdt_deal");
     var dt = mySqlHelper.ExecuteDataTable(mysql);
     var sql = "";
     var n = 0;
     for (var i = 0; i < dt.Rows.Count; i++)
     {
         sql += "INSERT INTO qdt_deal (id,name,sub_name,cate_id,user_id,description,is_effect,is_delete,borrow_amount,min_loan_money," +
                "repay_time,rate,create_time,update_time,is_recommend,buy_count,load_money,repay_money,start_time,success_time," +
                "repay_start_time,last_repay_time,next_repay_time,bad_time,deal_status,enddate,services_fee,is_send_bad_msg,bad_msg,loantype," +
                "warrant,titlecolor,is_send_contract,max_loan_money,icon,repay_time_type) " +
                "VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}','{21}','{22}','{23}','{24}','{25}','{26}','{27}','{28}','{29}','{30}','{31}','{32}','{33}','{34}','{35}');\r\n"
                .FormatWith(dt.Rows[i]["id"], dt.Rows[i]["name"], dt.Rows[i]["sub_name"], dt.Rows[i]["cate_id"], dt.Rows[i]["user_id"], dt.Rows[i]["description"].ToString().Replace('\'', '\"').Replace("./help/id-", "/Help/Index/").Replace("?", ""), dt.Rows[i]["is_effect"], dt.Rows[i]["is_delete"], dt.Rows[i]["borrow_amount"], dt.Rows[i]["min_loan_money"],
                dt.Rows[i]["repay_time"], dt.Rows[i]["rate"], GetTime(dt.Rows[i]["create_time"]), GetTime(dt.Rows[i]["update_time"]), dt.Rows[i]["is_recommend"], dt.Rows[i]["buy_count"], dt.Rows[i]["load_money"], dt.Rows[i]["repay_money"], GetTime(dt.Rows[i]["start_time"]), GetTime(dt.Rows[i]["success_time"]),
                GetTime(dt.Rows[i]["repay_start_time"]), GetTime(dt.Rows[i]["last_repay_time"]), GetTime(dt.Rows[i]["next_repay_time"]), GetTime(dt.Rows[i]["bad_time"]), dt.Rows[i]["deal_status"], dt.Rows[i]["enddate"], dt.Rows[i]["services_fee"], dt.Rows[i]["is_send_bad_msg"], dt.Rows[i]["bad_msg"], dt.Rows[i]["loantype"],
                dt.Rows[i]["warrant"], dt.Rows[i]["titlecolor"], dt.Rows[i]["is_send_contract"], dt.Rows[i]["max_loan_money"], dt.Rows[i]["icon"], dt.Rows[i]["repay_time_type"]).Replace("'NULL'","NULL");
         if ((i + 1) % 10 != 0) continue;
         n += sqlHelper.ExecuteNonQuery(sql);
         sql = "";
     }
     if (!string.IsNullOrWhiteSpace(sql))
     n += sqlHelper.ExecuteNonQuery(sql);
     Console.WriteLine("成功导入deal表:" + n + "条数据!");
 }
コード例 #3
0
ファイル: ImportAdmin.cs プロジェクト: gowhy/MicroWish
 public void Import()
 {
     var mySqlHelper = new MySqlHelper(MySql);
     var sqlHelper = new SqlHelper(SqlServer);
     var mysql = string.Format("select * from qdt_admin");
     var dt = mySqlHelper.ExecuteDataTable(mysql);
     var sql = "";
     var n = 0;
     for (var i = 0; i < dt.Rows.Count; i++)
     {
         sql += "INSERT INTO qdt_admin (id,name,password,is_effect,is_delete,role_id,login_time,login_ip) " +
                "VALUES ('" + dt.Rows[i]["id"] + "','" + dt.Rows[i]["adm_name"] + "','" + dt.Rows[i]["adm_password"].ToString().ToUpper() + "','" + dt.Rows[i]["is_effect"] + "','" + dt.Rows[i]["is_delete"] + "','" + dt.Rows[i]["role_id"] + "','" + GetTime(dt.Rows[i]["login_time"]) + "','" + dt.Rows[i]["login_ip"] + "');".Replace("'NULL'", "NULL");
         if ((i + 1) % 100 != 0) continue;
         n += sqlHelper.ExecuteNonQuery(sql);
         sql = "";
     }
     if (!string.IsNullOrWhiteSpace(sql))
     n += sqlHelper.ExecuteNonQuery(sql);
     Console.WriteLine("成功导入admin表:" + n + "条数据!");
 }
コード例 #4
0
ファイル: ImportArticle.cs プロジェクト: gowhy/MicroWish
 public void Import()
 {
     var mySqlHelper = new MySqlHelper(MySql);
     var sqlHelper = new SqlHelper(SqlServer);
     var mysql = string.Format("select * from qdt_article");
     var dt = mySqlHelper.ExecuteDataTable(mysql);
     var sql = "";
     var n = 0;
     for (var i = 0; i < dt.Rows.Count; i++)
     {
         sql += "INSERT INTO qdt_article (id,title,content,cate_id,create_time,update_time,add_admin_id,is_effect,rel_url,update_admin_id,is_delete,click_count,sort,seo_title,seo_keyword,seo_description,uname,sub_title,brief) " +
                "VALUES ('" + dt.Rows[i]["id"] + "','" + dt.Rows[i]["title"] + "','" + dt.Rows[i]["content"].ToString().Replace('\'', '\"') + "','" + dt.Rows[i]["cate_id"] + "','" + GetTime(dt.Rows[i]["create_time"]) + "','" + GetTime(dt.Rows[i]["update_time"]) + "','" + dt.Rows[i]["add_admin_id"] + "','" + dt.Rows[i]["is_effect"] + "','" + dt.Rows[i]["rel_url"] + "','" + dt.Rows[i]["update_admin_id"] + "','" + dt.Rows[i]["is_delete"] + "','" + dt.Rows[i]["click_count"] + "','" + dt.Rows[i]["sort"] + "','" + dt.Rows[i]["seo_title"] + "','" + dt.Rows[i]["seo_keyword"] + "','" + dt.Rows[i]["seo_description"] + "','" + dt.Rows[i]["uname"] + "','" + dt.Rows[i]["sub_title"] + "','" + dt.Rows[i]["brief"] + "');\r\n".Replace("'NULL'", "NULL");
         if ((i + 1) % 10 != 0) continue;
         n += sqlHelper.ExecuteNonQuery(sql);
         sql = "";
     }
     if (!string.IsNullOrWhiteSpace(sql))
     n += sqlHelper.ExecuteNonQuery(sql);
     Console.WriteLine("成功导入article表:" + n + "条数据!");
 }
コード例 #5
0
ファイル: ImportUserGroup.cs プロジェクト: gowhy/MicroWish
 public void Import()
 {
     var mySqlHelper = new MySqlHelper(MySql);
     var sqlHelper = new SqlHelper(SqlServer);
     var mysql = string.Format("select * from qdt_user_group");
     var dt = mySqlHelper.ExecuteDataTable(mysql);
     var sql = "";
     var n = 0;
     for (var i = 0; i < dt.Rows.Count; i++)
     {
         sql += "INSERT INTO qdt_user_group (id,name,score) " +
                "VALUES ('{0}','{1}','{2}');\r\n"
                .FormatWith(dt.Rows[i]["id"], dt.Rows[i]["name"], dt.Rows[i]["score"]);
         if ((i + 1) % 100 != 0) continue;
         n += sqlHelper.ExecuteNonQuery(sql);
         sql = "";
     }
     if (!string.IsNullOrWhiteSpace(sql))
     n += sqlHelper.ExecuteNonQuery(sql);
     Console.WriteLine("成功导入user_group表:" + n + "条数据!");
 }
コード例 #6
0
ファイル: ImportDealLoad.cs プロジェクト: gowhy/LoveBank
 public void Import()
 {
     var mySqlHelper = new MySqlHelper(MySql);
     var sqlHelper = new SqlHelper(SqlServer);
     var mysql = string.Format("select * from qdt_deal_load");
     var dt = mySqlHelper.ExecuteDataTable(mysql);
     var sql = "";
     var n = 0;
     for (var i = 0; i < dt.Rows.Count; i++)
     {
         sql += "INSERT INTO qdt_deal_load (id,deal_id,user_id,user_name,money,create_time,is_repay) " +
                "VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}');\r\n"
                .FormatWith(dt.Rows[i]["id"], dt.Rows[i]["deal_id"], dt.Rows[i]["user_id"], dt.Rows[i]["user_name"], dt.Rows[i]["money"], GetTime(dt.Rows[i]["create_time"]), dt.Rows[i]["is_repay"]).Replace("'NULL'", "NULL");
         if ((i + 1) % 100 != 0) continue;
         n += sqlHelper.ExecuteNonQuery(sql);
         sql = "";
     }
     if (!string.IsNullOrWhiteSpace(sql))
     n += sqlHelper.ExecuteNonQuery(sql);
     Console.WriteLine("成功导入deal_load表:" + n + "条数据!");
 }
コード例 #7
0
ファイル: ImportDealCate.cs プロジェクト: gowhy/LoveBank
 public void Import()
 {
     var mySqlHelper = new MySqlHelper(MySql);
     var sqlHelper = new SqlHelper(SqlServer);
     var mysql = string.Format("select * from qdt_deal_cate");
     var dt = mySqlHelper.ExecuteDataTable(mysql);
     var sql = "";
     var n = 0;
     for (var i = 0; i < dt.Rows.Count; i++)
     {
         sql += "INSERT INTO qdt_deal_cate (id,name,brief,is_delete,is_effect,sort,uname,icon) " +
                "VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}');\r\n"
                .FormatWith(dt.Rows[i]["id"], dt.Rows[i]["name"], dt.Rows[i]["brief"], dt.Rows[i]["is_delete"], dt.Rows[i]["is_effect"], dt.Rows[i]["sort"], dt.Rows[i]["uname"], dt.Rows[i]["icon"]);
         if ((i + 1) % 10 != 0) continue;
         n += sqlHelper.ExecuteNonQuery(sql);
         sql = "";
     }
     if (!string.IsNullOrWhiteSpace(sql))
     n += sqlHelper.ExecuteNonQuery(sql);
     Console.WriteLine("成功导入deal_cate表:" + n + "条数据!");
 }
コード例 #8
0
ファイル: ImportDealMsgList.cs プロジェクト: gowhy/LoveBank
 public void Import()
 {
     var mySqlHelper = new MySqlHelper(MySql);
     var sqlHelper = new SqlHelper(SqlServer);
     var mysql = string.Format("select * from qdt_deal_msg_list");
     var dt = mySqlHelper.ExecuteDataTable(mysql);
     var sql = "";
     var n = 0;
     for (var i = 0; i < dt.Rows.Count; i++)
     {
         sql += "INSERT INTO qdt_deal_msg_list (id,dest,send_type,content,send_time,is_send,create_time,user_id,result,is_success,is_html,title,is_youhui,youhui_id) " +
                "VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}');\r\n"
                .FormatWith(dt.Rows[i]["id"], dt.Rows[i]["dest"], Convert.ToInt32(dt.Rows[i]["send_type"]), dt.Rows[i]["content"].ToString().Replace('\'', '\"'), GetTime(dt.Rows[i]["send_time"]), dt.Rows[i]["is_send"], GetTime(dt.Rows[i]["create_time"]), dt.Rows[i]["user_id"], dt.Rows[i]["result"], dt.Rows[i]["is_success"], dt.Rows[i]["is_html"], dt.Rows[i]["title"].ToString().Replace('\'', '\"'), dt.Rows[i]["is_youhui"], dt.Rows[i]["youhui_id"]).Replace("'NULL'", "NULL");
         if ((i + 1) % 10 != 0) continue;
         n += sqlHelper.ExecuteNonQuery(sql);
         sql = "";
     }
     if (!string.IsNullOrWhiteSpace(sql))
     n += sqlHelper.ExecuteNonQuery(sql);
     Console.WriteLine("成功导入deal_msg_list表:" + n + "条数据!");
 }
コード例 #9
0
ファイル: ImportUserLog.cs プロジェクト: gowhy/LoveBank
        public void Import()
        {
            var mySqlHelper = new MySqlHelper(MySql);
            var sqlHelper = new SqlHelper(SqlServer);

            var mysql = string.Format("select * from qdt_user_log");
            var dt = mySqlHelper.ExecuteDataTable(mysql);
            var sql = "";
            var n = 0;
            for (var i = 0; i < dt.Rows.Count; i++)
            {
                sql += "INSERT INTO qdt_user_log (id,log_info,log_time,user_id,log_admin_id,log_user_id,money,lock_money,point,quota) " +
                       "VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}');\r\n"
                       .FormatWith(dt.Rows[i]["id"], dt.Rows[i]["log_info"], GetTime(dt.Rows[i]["log_time"]), dt.Rows[i]["user_id"], dt.Rows[i]["log_admin_id"], dt.Rows[i]["log_user_id"], dt.Rows[i]["money"], dt.Rows[i]["lock_money"], dt.Rows[i]["point"], dt.Rows[i]["quota"]);
                if ((i+1)%100 != 0) continue;
                n += sqlHelper.ExecuteNonQuery(sql);
                sql = "";
            }
            if (!string.IsNullOrWhiteSpace(sql))
            n += sqlHelper.ExecuteNonQuery(sql);
            Console.WriteLine("成功导入user_log表:" + n + "条数据!");
        }
コード例 #10
0
ファイル: ImportUserCarry.cs プロジェクト: gowhy/LoveBank
 public void Import()
 {
     var mySqlHelper = new MySqlHelper(MySql);
     var sqlHelper = new SqlHelper(SqlServer);
     var mysql = string.Format("select * from qdt_user_carry");
     var dt = mySqlHelper.ExecuteDataTable(mysql);
     var sql = "";
     var n = 0;
     for (var i = 0; i < dt.Rows.Count; i++)
     {
         sql += "INSERT INTO qdt_user_carry (Id,User_Id,Money,Fee,Bank_Id,Bank_Card,Create_Time,Update_Time,Status,Msg,[Desc],Real_Name,Bank_Zone,Region_Lv1,Region_Lv2,Region_Lv3,Region_Lv4) " +
                "VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}');\r\n"
                .FormatWith(dt.Rows[i]["Id"], dt.Rows[i]["User_Id"], dt.Rows[i]["Money"], dt.Rows[i]["Fee"], dt.Rows[i]["Bank_Id"], dt.Rows[i]["BankCard"], GetTime(dt.Rows[i]["Create_Time"]), GetTime(dt.Rows[i]["Update_Time"]),
                dt.Rows[i]["Status"], dt.Rows[i]["Msg"], dt.Rows[i]["Desc"], dt.Rows[i]["Real_Name"], dt.Rows[i]["BankZone"], dt.Rows[i]["Region_Lv1"], dt.Rows[i]["Region_Lv2"], dt.Rows[i]["Region_Lv3"], dt.Rows[i]["Region_Lv4"]).Replace("'NULL'", "NULL");
         if ((i + 1) % 100 != 0) continue;
         n += sqlHelper.ExecuteNonQuery(sql);
         sql = "";
     }
     if (!string.IsNullOrWhiteSpace(sql))
     n += sqlHelper.ExecuteNonQuery(sql);
     Console.WriteLine("成功导入user_carry表:" + n + "条数据!");
 }
コード例 #11
0
ファイル: ImportUserSta.cs プロジェクト: gowhy/MicroWish
 public void Import()
 {
     var mySqlHelper = new MySqlHelper(MySql);
     var sqlHelper = new SqlHelper(SqlServer);
     var mysql = string.Format("select * from qdt_user_sta");
     var dt = mySqlHelper.ExecuteDataTable(mysql);
     var sql = "";
     var n = 0;
     for (var i = 0; i < dt.Rows.Count; i++)
     {
         sql += "INSERT INTO qdt_user_sta (user_id,borrow_amount,repay_amount,need_repay_amount,deal_count,success_deal_count,load_earnings,load_count,load_money,load_repay_money,load_wait_repay_money,reback_load_count,wait_reback_load_count) " +
                "VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}');\r\n"
                .FormatWith(dt.Rows[i]["user_id"], dt.Rows[i]["borrow_amount"], dt.Rows[i]["repay_amount"], dt.Rows[i]["need_repay_amount"], dt.Rows[i]["deal_count"], dt.Rows[i]["success_deal_count"], dt.Rows[i]["load_earnings"]
                , dt.Rows[i]["load_count"], dt.Rows[i]["load_money"], dt.Rows[i]["load_repay_money"], dt.Rows[i]["load_wait_repay_money"], dt.Rows[i]["reback_load_count"], dt.Rows[i]["wait_reback_load_count"]);
         if ((i + 1) % 100 != 0) continue;
         n += sqlHelper.ExecuteNonQuery(sql);
         sql = "";
     }
     if (!string.IsNullOrWhiteSpace(sql))
     n += sqlHelper.ExecuteNonQuery(sql);
     Console.WriteLine("成功导入user_sta表:" + n + "条数据!");
 }
コード例 #12
0
ファイル: ImportChargeOrder.cs プロジェクト: gowhy/MicroWish
        public void Import()
        {
            var mySqlHelper = new MySqlHelper(MySql);
            var sqlHelper = new SqlHelper(SqlServer);

            var mysql = string.Format("select * from qdt_deal_order");
            var dt = mySqlHelper.ExecuteDataTable(mysql);
            var sql = "";
            var n = 0;
            for (var i = 0; i < dt.Rows.Count; i++)
            {
                if (Convert.ToDecimal(dt.Rows[i]["total_price"]).ToString().Length > 16) continue;
                sql += "INSERT INTO qdt_charge_order (id,order_sn,user_id,status,total_price,pay_amount,payment_key,bank_code,is_delete,memo,admin_memo,create_time,update_time) " +
                       "VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}');\r\n"
                       .FormatWith(dt.Rows[i]["id"], dt.Rows[i]["order_sn"], dt.Rows[i]["user_id"], dt.Rows[i]["pay_status"], dt.Rows[i]["total_price"], dt.Rows[i]["pay_amount"], GetPaymentKey(Convert.ToInt32(dt.Rows[i]["payment_id"])), dt.Rows[i]["bank_id"], dt.Rows[i]["is_delete"], dt.Rows[i]["memo"],
                       dt.Rows[i]["admin_memo"], GetTime(dt.Rows[i]["create_time"]), GetTime(dt.Rows[i]["update_time"])).Replace("'NULL'", "NULL");
                if ((i+1)%100 != 0) continue;
                n += sqlHelper.ExecuteNonQuery(sql);
                sql = "";
            }
            if (!string.IsNullOrWhiteSpace(sql))
            n += sqlHelper.ExecuteNonQuery(sql);
            Console.WriteLine("成功导入charge_order表:" + n + "条数据!");
        }
コード例 #13
0
ファイル: ImportPaymentNotice.cs プロジェクト: gowhy/LoveBank
        public void Import()
        {
            var mySqlHelper = new MySqlHelper(MySql);
            var sqlHelper = new SqlHelper(SqlServer);

            var mysql = string.Format("select * from qdt_payment_notice");
            var dt = mySqlHelper.ExecuteDataTable(mysql);
            var sql = "";
            var n = 0;
            for (var i = 0; i < dt.Rows.Count; i++)
            {
                if (Convert.ToDecimal(dt.Rows[i]["Money"]).ToString().Length > 16) continue;
                sql += "INSERT INTO qdt_payment_notice (id,NoticeSn,CreateTime,PayTime,OrderId,IsPaid,UserId,PaymentKey,Memo,Money,OuterNoticeSn) " +
                       "VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}');\r\n"
                       .FormatWith(dt.Rows[i]["id"], dt.Rows[i]["notice_sn"], GetTime(dt.Rows[i]["Create_Time"]), GetTime(dt.Rows[i]["Pay_Time"]), dt.Rows[i]["Order_Id"], dt.Rows[i]["Is_Paid"], dt.Rows[i]["User_Id"], GetPaymentKey(Convert.ToInt32(dt.Rows[i]["payment_id"])), dt.Rows[i]["Memo"], dt.Rows[i]["Money"],
                       dt.Rows[i]["Outer_Notice_Sn"]).Replace("'NULL'", "NULL");
                if ((i+1)%100 != 0) continue;
                n += sqlHelper.ExecuteNonQuery(sql);
                sql = "";
            }
            if (!string.IsNullOrWhiteSpace(sql))
            n += sqlHelper.ExecuteNonQuery(sql);
            Console.WriteLine("成功导入payment_notice表:" + n + "条数据!");
        }
コード例 #14
0
		/// <summary>
		/// OnDragDrop is used to create classes corresponding to the selection dragged
		/// from the Server Explorer
		/// </summary>
		private void OnDragDrop(object sender, DragEventArgs e)
		{
			// Check if the data present is in the DSRef format
			if (e.Data.GetDataPresent(DSRefNavigator.DataSourceReferenceFormat))
			{
				try
				{
					// Create a navigator for the DSRef Consumer (and dispose it when finished)
					using(DSRefNavigator navigator = new DSRefNavigator(e.Data.GetData(
					                                                    	DSRefNavigator.DataSourceReferenceFormat)
					                                                    as Stream))
					{
						_output = new OutputWindowHelper(DTEHelper.GetDTE(Store));

						// Get connection info of the connection of selected tables
						string providerType = null;
						IDbConnection connection = ServerExplorerHelper.GetConnection(navigator, out providerType);

						IDbHelper helper;

						switch(providerType)
						{
							case "System.Data.SqlClient.SqlConnection":
								helper = new SqlHelper(connection);
								break;
                            case "System.Data.OracleClient.OracleConnection":
                            case "Oracle.DataAccess.Client.OracleConnection":
                                Log("Selecting Oracle Helper for provider " + providerType);
                                helper = new OracleHelper(connection);
                                break;
                            case "MySql.Data.MySqlClient.MySqlConnection":
								helper = new MySqlHelper(connection);
								break;
							default:
								// TODO: Support other databases with native providers.
								Log(
									string.Format(
                                        @"Failed: ActiveWriter does not support model generation through {0}. Supported providers: System.Data.SqlClient.SqlConnection, System.Data.OracleClient.OracleConnection, Oracle.DataAccess.Client.OracleConnection, MySql.Data.MySqlClient.MySqlConnection. You can help us improve this functionality, though. See http://www.castleproject.org/others/contrib/index.html to access ActiveWriter source code under the contrib repository, and check Dsl\ServerExplorerSupport\IDbHelper.cs for the start.",
										providerType));
								return;
						}

						// Get the root element where we'll add the classes
						Model model = Helper.GetModel(Store);
						if (model == null)
						{
							Log("Failed: Cannot get the model for the store.");
							return;
						}

						_manager = new DiagramManager(Store, model);
						_manager.OutputWindow = _output;

						// Create a transaction to add the clases.
						using(Transaction txAdd =
							model.Store.TransactionManager.BeginTransaction("Add classes"))
						{
							List<DSRefNode> tableList = new List<DSRefNode>();
							// Get the tables from the Server Explorer selection
							// We'll iterate this list twice to use nodes' list to
							// determine if we have to generate relations for each
							// table or not.
							foreach(DSRefNode node in navigator.ChildTableNodes)
							{
								tableList.Add(node);
							}

							_manager.Tables = tableList;

							_relations = new List<Relation>();

							foreach(DSRefNode node in tableList)
							{
								// Create the table and add it to the model
								ModelClass cls = _manager.NewClass(node.Owner, node.Name);
								PopulateClass(cls, connection, helper);
								_manager.AssignModel(cls);
							}

							// Create relations
							if (_relations != null && _relations.Count > 0)
							{
								HandleRelations();
							}

							// Commit the transaction and add tables to the model
							txAdd.Commit();
						}

						// TODO: Auto layout doesn't work well. Will check with future versions of DSL tools.
						// this.AutoLayoutShapeElements(this.NestedChildShapes);
					}
				}
				catch(Exception ex)
				{
					Debug.WriteLine(ex.Message);
				}
				finally
				{
					_manager = null;
					_relations = null;
					_output = null;
				}
			}
		}
コード例 #15
0
ファイル: MySqlStore.cs プロジェクト: sdgdsffdsfff/PageCache
 public MySqlStore(string connectionString)
 {
     dbh = new MySqlHelper(connectionString);
 }