using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Data;
using System.Text.RegularExpressions;
namespace EDIService.Import.Helper.EdiCenterFactory
{
/// <summary>
/// EDI报文发送至指定目录
/// </summary>
public class EdiSendExecute : IEdiSendExecute
{
#region SendEdi
/// <summary>
/// 发送EDI报文文件至指定目录
/// </summary>
/// <returns></returns>
public bool SendEdi(DataSet data)
{
try
{
//循环创建EDI报文
for (int i = 0; i < data.Tables[0].Rows.Count; i++)
{
this.EdiFile(data.Tables[0].Rows[i],i);
}
return true;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region EdiFile
/// <summary>
/// EDI报文头
/// </summary>
/// <returns></returns>
public bool EdiFile(DataRow row,int i)
{
try
{
//拼文件名
string time = DateTime.Now.ToString("yyyyMMddHHmmss"); //时间string
Random dm = new Random(i);
int random = dm.Next(100000, 999999); //6位随机数
//判断目录是否存在,若不存在,则创建