业务流程-Oracle反写快照数据迁移到sqlserver,解析报错

问题描述:
Oracle反写快照数据迁移到sqlserver,解析报错"XML parsing:line1,character 38,unable to switch the encoding",如下图 。

解决方案:
原因:这是因为oracle数据迁移到sqlserver会加上xml声明,导致的:

解决方案:使用插件代码把xml声明给去掉
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Data;
using System.IO;
using System.IO.Compression;
using Kingdee.BOS.Util;
using Kingdee.BOS.Core.Bill.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.App.Data;
using Kingdee.BOS.BusinessEntity.BusinessFlow;
using Kingdee.BOS.Orm.Drivers;
using Kingdee.BOS.Orm;
using Kingdee.BOS.Orm.DataEntity;
namespace Kingdee.BOS.TestPlugIn22.FormPlugin
{
[HotUpdate]
[Description("单据测试插件")]
public class TestFormPlugIn : AbstractBillPlugIn
{
public override void BarItemClick(BarItemClickEventArgs e)
{
if (e.BarItemKey.EqualsIgnoreCase("某某升级菜单key"))
{
//需要处理的两张表
List<string> hisTableNames = new List<string>() { "t_BF_InstanceSnapHis", "t_BF_SnapBackUp" };
foreach (var tbName in hisTableNames)
{
bool isContinue = true;
while (isContinue)
{
List<string> lstId = new List<string>();
string sql = string.Format("select top 30 FCID from {0} where FZIPTYPE =1 ", tbName);//一次处理30条
using (IDataReader reader = DBUtils.ExecuteReader(this.Context, sql))
{
while (reader.Read())
{
var fcid = reader["FCID"] as string;
lstId.Add(fcid);
}
}
if (lstId.Count < 30)
{
isContinue = false;
}
//得到压缩的数据进行处理
IDbDriver driver = new OLEDbDriver(this.Context);
HisSnapshotType dtSnap = new HisSnapshotType(tbName);
IDataManager dataManager = Orm.DataManagerUtils.GetDataManager(dtSnap, driver);
var snapshots = dataManager.Read(lstId).ToArray<DynamicObject>();
this.DecompressSnaps(dtSnap, snapshots); // 解压
dataManager.Save(snapshots); // 保存
}
}
}
}
/// <summary>
/// 解压历史快照
/// </summary>
/// <param name="dtSnap">历史快照实体模型</param>
/// <param name="snaps">历史快照数据包</param>
private void DecompressSnaps(HisSnapshotType dtSnap, IEnumerable<DynamicObject> snapshots)
{
// 逐个快照进行解压
foreach (var snapshot in snapshots)
{
string zipType = dtSnap.ZipTypeProperty.GetValue<string>(snapshot);
string xmlZip = dtSnap.XmlZipProperty.GetValue<string>(snapshot);
//把压缩的数据还原为xml,并把申请去掉
string xmlBody = this.ZipDecompress(xmlZip);
xmlBody = xmlBody.Replace("<?xml version=\"1.0\" encoding=\"UTF-8\"?>", "");
//这里有两种出来方式
业务流程-Oracle反写快照数据迁移到sqlserver,解析报错
问题描述:Oracle反写快照数据迁移到sqlserver,解析报错"XML parsing:line1,character 38,unable to switch the encoding",如下...
点击下载文档文档为doc格式
声明:除非特别标注,否则均为本站原创文章,转载时请以链接形式注明文章出处。如若本站内容侵犯了原著者的合法权益,可联系本站删除。
上一篇
已经是第一篇



