using cuidian.Sql;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WdtUtils;
using WdtUtils.Load;
using WdtUtils.Proxy;
namespace WangToTempDb
{
///
/// 旺店通供应商上传中间库
///
public class VendorUpLoad : BaseUpLoad
{
private string __sql = "if not exists (select 1 from {14}..Vendor where cvencode = '{0}') insert into Vendor(cVenCode,cVenName,cVenPerson,cVenPhone,mobile,fax,cVenDefine11,email,cVenDefine4,cVenDefine5,[address],cVenDefine7,cmemo,cVenAbbName) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}')";
protected override Result _LoadFirstPage()
{
VendorProxy tmp = new VendorProxy();
Result rtn = _load.Load(_args, ref tmp);
_proxy = tmp;
return rtn;
}
protected override void _SetLoader()
{
_load = new VendorLoad();
}
protected override void _ImportData()
{
_operType = "插入供应商中间表数据";
Provider_List[] entitys = ((VendorProxy)_proxy).provider_list;
StringBuilder sb = new StringBuilder();
foreach (Provider_List item in entitys)
{
sb.AppendLine(string.Format(__sql, new object[] { _ConvertStr(item.provider_no), _ConvertStr(item.provider_name), _ConvertStr(item.contact), _ConvertStr(item.telno), _ConvertStr(item.mobile), _ConvertStr(item.fax), _ConvertNotStr(item.zip), _ConvertStr(item.email), _ConvertStr(item.qq), _ConvertStr(item.wangwang), _ConvertStr(item.address), _ConvertStr(item.website), _ConvertStr(item.remark), _ConvertStr(item.provider_name),ConnectionUtils.Instance.GetConnection().Database }));
_InsertIntoTempDb(sb.ToString(), item.provider_no);
}
}
protected override void _DeleteDup()
{
_operType = "删除供应商中间表重复数据";
string sql = "delete a from {0}..Vendor a,{1}..Vendor b where a.cVenCode = b.cVenCode";
DbUtils.ExecuteNonQuery(string.Format(sql, _tempDb.Database, _targetDb.Database), _tempDb);
}
protected override void _LoadNextPage()
{
_proxy = _load.Load(_args);
}
}
}