发货通知单下推直接调拨单,弹出异常,但没有异常信息
金蝶云社区-Flong
Flong
0人赞赏了该文章 1,450次浏览 未经作者许可,禁止转载编辑于2016年07月18日 23:32:06

与第三方系统做集成,需要从中间表中读取发货通知单号,然后在Cloud中手动触发,根据读取的发货通知单号对应的发货通知单下推生成直接调拨单。

异常:弹出异常提示框,但没有显示异常内容。跟踪代码,下推成功。可读取到目标单据信息,执行保存后,状态为false,但没有异常内容。

注:用同样的方法,生产订单下推生产入库单,是成功的。


[code]string sourceFormId = "SAL_DELIVERYNOTICE"; //发货通知单
string targetFormId = "STK_TransferDirect"; //直接调拨单

var rules = ConvertServiceHelper.GetConvertRules(this.View.Context, sourceFormId, targetFormId);
var rule = rules.FirstOrDefault(t => t.IsDefault);

ListSelectedRow[] selectedRows = new ListSelectedRow[dtDeliveryNotice.Rows.Count];
for (int i = 0; i < dtDeliveryNotice.Rows.Count; i++)
{
selectedRows[i] = new ListSelectedRow(dtDeliveryNotice.Rows[i]["FID"].ToString(), dtDeliveryNotice.Rows[i]["FENTRYID"].ToString(), Int32.Parse(dtDeliveryNotice.Rows[i]["FSEQ"].ToString()), sourceFormId);
selectedRows[i].EntryEntityKey = "FEntity"; //源单据的分录实体标识 发货通知单 分体实体标识
}
ConvertOperationResult operationResult = null;
//传递的参数
Dictionary custParams = new Dictionary();
custParams.Add("CustData", dtDeliveryNotice);

try
{
PushArgs pushArgs = new PushArgs(rule, selectedRows)
{
CustomParams = custParams, // 可以传递额外附加的参数给单据转换插件,如无此需求,可以忽略
};
//执行下推操作,并获取下推结果
operationResult = ConvertServiceHelper.Push(this.View.Context, pushArgs, OperateOption.Create());
}
catch (KDExceptionValidate ex)
{
this.View.ShowErrMessage(ex.Message, ex.ValidateString);
e.Cancel = true;
return;
}
catch (KDException ex)
{
this.View.ShowErrMessage(ex.Message);
e.Cancel = true;
return;
}
catch
{
throw;
}
if (operationResult.IsSuccess)
{
// 获取生成的目标单据数据包
DynamicObject[] objs = (from p in operationResult.TargetDataEntities
select p.DataEntity).ToArray();

var targetBillMeta = MetaDataServiceHelper.Load(this.View.Context, targetFormId) as FormMetadata;
try
{

OperateOption saveOption = OperateOption.Create();
// 忽略全部需要交互性质的提示,直接保存;
saveOption.SetIgnoreWarning(true);
// 提交数据库保存,并获取保存结果
var saveResult = BusinessDataServiceHelper.Save(this.View.Context, targetBillMeta.BusinessInfo, objs, saveOption, "Save");

string strReturn = string.Empty;
if (saveResult == null)
{
this.View.ShowErrMessage("未知原因导致保存导入失败!");

e.Cancel = true;
return;
}
else if (saveResult.IsSuccess)
{
var oResults = saveResult.OperateResult;
foreach (var oResult in oResults)
{
strReturn += oResult.Message + "\r\n";
}
this.View.ShowMessage(strReturn);
e.Cancel = true;
return;
}
else
{
saveResult.MergeValidateErrors();
this.View.ShowOperateResult(saveResult.OperateResult);
var oResults = saveResult.ValidationErrors;
foreach (var oResult in oResults)
{
strReturn += oResult.Message + "\r\n";
}
this.View.ShowErrMessage(strReturn);
e.Cancel = true;
return;
}
}
catch (KDException ex)
{
this.View.ShowErrMessage(ex.Message);
e.Cancel = true;
return;
}
catch
{
throw;
}
}
else
{
this.View.ShowErrMessage("单据转换生成直接调拨单失败!");
e.Cancel = true;
return;
}[/code]