插件调用单据保存,提交 审核操作
金蝶云社区-疯狂的石头
疯狂的石头
46人赞赏了该文章 5,301次浏览 未经作者许可,禁止转载编辑于2020年12月16日 12:11:33

转载

--操作插件里面
[code]
///


/// 自动保存提交审核
///
/// 元数据
/// 数据包
/// 消息
/// 自动提交标志
/// 自动审核标志
private void AutoDoOperation(FormMetadata targetBillMeta, DynamicObject[] objs, string msg,
bool submitFlag = true, bool auditFlag = true)
{
object[] pkArray = null; //存储fid
OperateOption option = OperateOption.Create();
option.SetIgnoreWarning(true);
option.SetInteractionFlag(this.Option.GetInteractionFlag());
option.SetIgnoreInteractionFlag(true);
#region 保存

IOperationResult saveResult = BusinessDataServiceHelper.Save(this.View.Context, targetBillMeta.BusinessInfo,
objs, option, "Save");

if (saveResult.IsSuccess)
{
pkArray = (from p in (saveResult as OperationResult).SuccessDataEnity
select p[0]).ToArray();
}
else
{
StringBuilder saveStr = new StringBuilder();
_transFlag = false;
foreach (var resultMsg in saveResult.OperateResult)
{
saveStr.AppendLine(resultMsg.Message);
}
int failCount = saveResult.ValidationErrors.Count;
for (int p = 0; p < failCount; p++)
{
saveStr.AppendLine(saveResult.ValidationErrors[p].Message);
}
this.View.ShowErrMessage("调用下推," + msg + "保存 错误:\n" + saveStr.ToString());
}

#endregion

if (pkArray.IsNullOrEmpty()) return;

#region 提交

if (submitFlag)
{

IOperationResult submit = BusinessDataServiceHelper.Submit(this.View.Context,
targetBillMeta.BusinessInfo, pkArray.ToArray(), "Submit", option);
if (!submit.IsSuccess)
{
StringBuilder saveStr = new StringBuilder();
_transFlag = false;
foreach (var resultMsg in submit.OperateResult)
{
saveStr.AppendLine(resultMsg.Message);
}
int failCount = submit.ValidationErrors.Count;
for (int p = 0; p < failCount; p++)
{
saveStr.AppendLine(submit.ValidationErrors[p].Message);
}
this.View.ShowErrMessage("调用下推," + msg + "错误:\n" + saveStr.ToString());
}

}

#endregion

#region 审核

if (auditFlag)
{
IOperationResult audit = BusinessDataServiceHelper.Audit(this.View.Context,
targetBillMeta.BusinessInfo, pkArray.ToArray(), option);
if (!audit.IsSuccess)
{
StringBuilder saveStr = new StringBuilder();
_transFlag = false;
foreach (var resultMsg in audit.OperateResult)
{
saveStr.AppendLine(resultMsg.Message);
}
int failCount = audit.ValidationErrors.Count;
for (int p = 0; p < failCount; p++)
{
saveStr.AppendLine(audit.ValidationErrors[p].Message);
}
this.View.ShowErrMessage("调用下推," + msg + "审核 错误:\n" + saveStr.ToString());
}

}

#endregion
}
[/code]

----单据View上:

[code] ///


/// 单据自动保存提交审核
///
///
///
private void AutoDoViewOperation(bool submitFlag = true, bool auditFlag = true)
{
object[] pkArray = null; //存储fid
IMetaDataService service2 = ServiceHelper.GetService();
FormMetadata formMetadata =
(FormMetadata) service2.Load(base.Context, this.View.BusinessInfo.GetForm().Id, true);
#region 保存

ISaveService saveService = ServiceFactory.GetSaveService(base.Context);
IOperationResult saveResult = saveService.Save(base.Context, formMetadata.BusinessInfo,
new DynamicObject[] {this.View.Model.DataObject}, null, "");
if (saveResult.IsSuccess)
{
pkArray = (from p in (saveResult as OperationResult).SuccessDataEnity
select p[0]).ToArray();
}
else
{
StringBuilder saveStr = new StringBuilder();
foreach (var resultMsg in saveResult.OperateResult)
{
saveStr.AppendLine(resultMsg.Message);
}
int failCount = saveResult.ValidationErrors.Count;
for (int p = 0; p < failCount; p++)
{
saveStr.AppendLine(saveResult.ValidationErrors[p].Message);
}
this.ShowMessages("单据保存失败:\n" + saveStr.ToString());
}

#endregion

#region 提交

if (submitFlag)
{
ISubmitService submitService = ServiceFactory.GetSubmitService(base.Context);
IOperationResult submitResult = submitService.Submit(this.Context, formMetadata.BusinessInfo, pkArray,
null);
if (!submitResult.IsSuccess)
{
StringBuilder submitStr = new StringBuilder();
foreach (var resultMsg in submitResult.OperateResult)
{
submitStr.AppendLine(resultMsg.Message);
}
int failCount = submitResult.ValidationErrors.Count;
for (int p = 0; p < failCount; p++)
{
submitStr.AppendLine(submitResult.ValidationErrors[p].Message);
}
this.ShowMessages("单据提交失败:\n" + submitStr.ToString());
}
}

#endregion

#region 审核

if (auditFlag)
{
IAuditService auditService = ServiceFactory.GetAuditService(base.Context);
IOperationResult auditResult = auditService.Audit(base.Context, formMetadata.BusinessInfo, pkArray, null);
if (!auditResult.IsSuccess)
{
StringBuilder auditStr = new StringBuilder();
foreach (var resultMsg in auditResult.OperateResult)
{
auditStr.AppendLine(resultMsg.Message);
}
int failCount = auditResult.ValidationErrors.Count;
for (int p = 0; p < failCount; p++)
{
auditStr.AppendLine(auditResult.ValidationErrors[p].Message);
}
this.ShowMessages("单据审核失败:\n" + auditStr.ToString());
}
}

#endregion

}
[/code]

https://vip.kingdee.com/article/31955


本文转载自:a

作者:a

原文链接:a

图标赞 46
46人点赞
还没有人点赞,快来当第一个点赞的人吧!
图标打赏
0人打赏
还没有人打赏,快来当第一个打赏的人吧!