98 lines
2.8 KiB
C#
98 lines
2.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using WX.CRM.Common;
|
|
using WX.CRM.DataSynFactory.BLL;
|
|
using WX.CRM.Model.EntitySync;
|
|
|
|
namespace WX.CRM.DataProceService.DataImport
|
|
{
|
|
public class DataImport
|
|
{
|
|
static List<SYNC_RECEIVE> _list = new List<SYNC_RECEIVE>();
|
|
|
|
static bool runing = false;
|
|
public static void Start()
|
|
{
|
|
if (runing)
|
|
return;
|
|
runing = true;
|
|
try
|
|
{
|
|
do
|
|
{
|
|
var info = GetReceiveInfo();
|
|
if (info != null)
|
|
DataSynFactory.CreateFactory.DataImport(info);
|
|
}
|
|
while (waitCount > 0);
|
|
//while (YXDataImport.waitFlag);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Common.LogHelper.Error(string.Concat("WX.CRM.DataProceService.DataImport.Start", e.Message, e.StackTrace));
|
|
}
|
|
finally
|
|
{
|
|
runing = false;
|
|
}
|
|
}
|
|
public static int waitCount
|
|
{
|
|
get
|
|
{
|
|
if (_list == null)
|
|
return 0;
|
|
else
|
|
return _list.Count;
|
|
}
|
|
}
|
|
|
|
public static bool waitFlag
|
|
{
|
|
get; set;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取一个待推送的数据包
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static SYNC_RECEIVE GetReceiveInfo()
|
|
{
|
|
SYNC_RECEIVE info = null;
|
|
try
|
|
{
|
|
//if (_list == null || _list.Count == 0)
|
|
//{
|
|
// string yx = Common.Utility.GetSettingByKey("YouXianChuLiBusiness");
|
|
// if (!string.IsNullOrEmpty(yx))
|
|
// {
|
|
// string[] keys = string.Format("{0}", yx).Split(',');
|
|
// _list = new SYNC_RECEIVE_BL().GetList(100, keys);
|
|
// }
|
|
// else
|
|
// {
|
|
// _list = new SYNC_RECEIVE_BL().GetList(100);
|
|
// }
|
|
//}
|
|
if (_list == null || _list.Count == 0)
|
|
_list = new SYNC_RECEIVE_BL().GetList(500);
|
|
var o = _list.FirstOrDefault();
|
|
if (o != null)
|
|
{
|
|
info = o;
|
|
_list.Remove(o);
|
|
waitFlag = true;
|
|
}
|
|
else waitFlag = false;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
info = null;
|
|
LogHelper.Error(string.Concat("【获取处理数据】WX.CRM.DataSynService.Push.WaitData.GetReceiveInfo()", ex.Message, ex.StackTrace));
|
|
}
|
|
return info;
|
|
}
|
|
}
|
|
}
|