You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

116 lines
4.3 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Mesnac.Action.Base;
using Mesnac.Codd.Session;
using Mesnac.Basic;
using System.Data;
namespace Mesnac.Action.Feeding.Sys
{
#region 同步班组
/// <summary>
/// 同步班组
/// </summary>
public class ClassSynchronous : FeedingAction, IAction
{
public void Run(RuntimeParameter runtime)
{
base.RunIni(runtime);
if (base.NetType != 0)
{
base.LogError("{班组维护} 此系统版本为网络版,不能进行数据同步...");
return;
}
DatabaseAction action = new DatabaseAction();
///////服务器连接信息
DataSourceItem dsi = action.GetDataSourceItem(Mesnac.Basic.DataSourceFactory.MCDbType.Server);
//////测试服务器数据库连接
DbHelper dbHelper;
dbHelper = action.NewDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Server);
if (dbHelper == null)
{
action.LogError("连接服务器数据库失败...");
return;
}
/////本地数据库
DbHelper dbHelperlocal;
dbHelperlocal = action.NewDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.local);
if (dbHelperlocal == null)
{
action.LogError("本地连接数据库失败...");
return;
}
dbHelperlocal.ClearParameter();
dbHelperlocal.CommandType = CommandType.Text;
StringBuilder sqlstr = new StringBuilder();
sqlstr.AppendFormat(@"begin tran
delete from RJPT.dbo.PptClass
insert into dbo.PptClass (ObjID, ClassName, UseFlag)
select ObjID, ClassName, UseFlag from [{0}].[{1}].dbo.PptClass
if @@ERROR<>0
rollback tran
else
commit tran", dsi.Server,dsi.Database);
dbHelper.CommandText = sqlstr.ToString();
dbHelper.ExecuteNonQuery();
}
}
#endregion
#region 同步班次
/// <summary>
/// 同步班次
/// </summary>
public class ShiftSynchronous : FeedingAction, IAction
{
public void Run(RuntimeParameter runtime)
{
base.RunIni(runtime);
if (base.NetType != 0)
{
base.LogError("{班次维护} 此系统版本为网络版,不能进行数据同步...");
return;
}
DatabaseAction action = new DatabaseAction();
///////服务器连接信息
DataSourceItem dsi = action.GetDataSourceItem(Mesnac.Basic.DataSourceFactory.MCDbType.Server);
//////测试服务器数据库连接
DbHelper dbHelper;
dbHelper = action.NewDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Server);
if (dbHelper == null)
{
action.LogError("连接服务器数据库失败...");
return;
}
/////本地数据库
DbHelper dbHelperlocal;
dbHelperlocal = action.NewDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.local);
if (dbHelperlocal == null)
{
action.LogError("本地连接数据库失败...");
return;
}
dbHelperlocal.ClearParameter();
dbHelperlocal.CommandType = CommandType.Text;
StringBuilder sqlstr = new StringBuilder();
sqlstr.AppendFormat(@"begin tran
delete from RJPT.dbo.PptShift
insert into dbo.PptShift (ObjID, ShiftName, UseFlag)
select ObjID, ShiftName, UseFlag from [{0}].[{1}].dbo.PptClass
if @@ERROR<>0
rollback tran
else
commit tran", dsi.Server, dsi.Database);
dbHelper.CommandText = sqlstr.ToString();
dbHelper.ExecuteNonQuery();
}
}
#endregion
}