我有奇怪的问题我想从Oracle(在线Db)获取记录并插入和更新到脱机的MySQL数据库数据库,如果故障转移MYSQL数据库启动功能。我必须将主要记录从Oracle更新到MySql,这样如果离线数据库在游戏中启动,它就会包含所有相关的同步数据。
我已经用BackgroundWorker类编写了代码,以便我可以将它保存在一个单独的线程中 以下是代码,请查看
代码
using Oracle.DataAccess.Client;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Data.EntityClient;
using System.Data;
namespace HospitalSystem
{
/// <summary>
/// Interaction logic for HospitalSync.xaml
/// </summary>
public partial class HospitalSync : Window
{
public BackgroundWorker Worker;
public int TotalRecords;
public HospitalSync()
{
InitializeComponent();
}
public int CalculatePercentage(int Current)
{
int Percentage = (int) (Current / TotalRecords) * 100;
return Percentage;
}
public void SyncDataFromKPT(object sender, DoWorkEventArgs e)
{
MedEntities Db = new MedEntities();
using (OracleConnection connection = new OracleConnection(Db.Database.Connection.ConnectionString))
{
DataTable RecordsToUpdateTable = new DataTable();
string SqlCommand = "SELECT * FROM medsec.vu_registration_modify";
using (OracleCommand cmd = new OracleCommand(SqlCommand, connection))
{
OracleDataAdapter adapter = new OracleDataAdapter(SqlCommand, connection);
adapter.SelectCommand.CommandType = CommandType.Text;
adapter.Fill(RecordsToUpdateTable);
if (RecordsToUpdateTable.Rows.Count > 0)
{
for (int j = 0; j <= RecordsToUpdateTable.Rows.Count; j++)
{
RecCountTotal.Content = j + 1;
CalculatePercentage(j);
}
}
}
}
}
public void ProcessCompleted(object sender, ProgressChangedEventArgs e)
{
UpdateBar.Value = e.ProgressPercentage;
}
public void InitializeWorker()
{
Worker = new BackgroundWorker();
Worker.WorkerReportsProgress = true;
Worker.DoWork += new DoWorkEventHandler(SyncDataFromKPT);
Worker.ProgressChanged += new ProgressChangedEventHandler(ProcessCompleted);
Worker.RunWorkerAsync(Worker);
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
InitializeWorker();
}
}
}
此时MedEntities Db = new MedEntities();
在使用块之后进入文件,即使我放置断点也不会执行代码。
请指导我如何制作代码功能
答案 0 :(得分:0)
在@Markus的帮助下解决了这个问题。 谢谢
这是我使用32位客户端库并在64位上进行调试的平台问题。