public override void Validate(Kingdee.BOS.Core.ExtendedDataEntity[] dataEntities, ValidateContext validateContext, Kingdee.BOS.Context ctx) { foreach (var dataEntity in dataEntities) { string FID = dataEntity["Id"].ToString(); //string procInstId = WorkflowChartServiceHelper.GetProcInstIdByBillInst(ctx, this.formId, FID); //List<ChartActivityInfo> routeCollection = WorkflowChartServiceHelper.GetProcessRouter(ctx, procInstId); //var WFNode = routeCollection[routeCollection.Count - 1]; var FEntity = dataEntity["FEntity"] as DynamicObjectCollection; foreach (var row in FEntity) { var FRoomNum = row["F_ora_RoomNum"] == null ? "" : row["F_ora_RoomNum"].ToString(); if (FRoomNum.IsNullOrEmptyOrWhiteSpace()) { ValidationErrorInfo ValidationErrorInfo = new ValidationErrorInfo( string.Empty, FID, dataEntity.DataEntityIndex, dataEntity.RowIndex, FID, "请返回审批页面点击右侧“更多”按钮后选择“修改单据”,在单据的明细信息中填写“房间号”并保存,最后再返回至审批页面点击“分配完成”进行提交!", string.Empty); validateContext.AddError(null, ValidationErrorInfo); } } } }
public override void Validate(ExtendedDataEntity[] dataEntities, ValidateContext validateContext, Context ctx) { if (dataEntities.IsNullOrEmpty() || dataEntities.Length == 0) { return; } foreach (ExtendedDataEntity item in dataEntities) { DynamicObject requestDynamic = item.DataEntity; string reason = Convert.ToString(requestDynamic["FWinReason"]); if (reason.Equals(" ")) { string msg = string.Format("商机编号{0}输赢原因没填", requestDynamic["FBillNo"]); var errInfo = new ValidationErrorInfo( item.BillNo, item.DataEntity["Id"].ToString(), item.DataEntityIndex, item.RowIndex, "ARValid019", msg, " ", Kingdee.BOS.Core.Validation.ErrorLevel.Error); validateContext.AddError(item.DataEntity, errInfo); } } }
private Dictionary <string, string> GetValidationErrorInfoes(ValidationException validationException) { var validationErrorInfos = new Dictionary <string, string>(); var i = 1; foreach (var validationResult in validationException.ValidationErrors) { var validationError = new ValidationErrorInfo(validationResult.ErrorMessage); if (validationResult.MemberNames != null && validationResult.MemberNames.Any()) { validationError.Members = validationResult.MemberNames.Select(m => m.ToCamelCase()).ToArray(); } var key = validationError.Members != null?string.Join(',', validationError.Members) : i++.ToString(); if (!validationErrorInfos.ContainsKey(key)) { validationErrorInfos.Add(key, validationError.Message); } else { var value = validationErrorInfos[key]; validationErrorInfos[key] = value + ". " + validationError.Message; } } return(validationErrorInfos); }
public override void Validate(ExtendedDataEntity[] dataEntities, ValidateContext validateContext, Context ctx) { if (dataEntities.IsNullOrEmpty() || dataEntities.Length == 0) { return; } foreach (ExtendedDataEntity item in dataEntities) { DynamicObject requestDynamic = item.DataEntity; bool isCreate = Convert.ToBoolean(requestDynamic["FIsCreateApply"]); //是否生成佣金费用申请单 string costReqBillNo = Convert.ToString(requestDynamic["FCostApplyNo"]); //佣金费用申请单单号 bool ISCREATEOTHERAP = Convert.ToBoolean(requestDynamic["FISCREATEOTHERAP"]); //是否生成其他应付单 string OTHERAPNO = Convert.ToString(requestDynamic["FOTHERAPNO"]); //其他应付单号 bool ISCREATEBOUNS = Convert.ToBoolean(requestDynamic["FISCREATEBOUNS"]); //是否生成提点申请单 string BOUNSAPPLYBILLNO = Convert.ToString(requestDynamic["FBOUNSAPPLYBILLNO"]); //提点申请单号 bool ISCREATELOGISTICS = Convert.ToBoolean(requestDynamic["FISCREATELOGISTICS"]); //是否生成管销申请单 string LOGISTICSAPPLYBILLNO = Convert.ToString(requestDynamic["FLOGISTICSAPPLYBILLNO"]); //管销申请单号 string billNo = Convert.ToString(requestDynamic["BillNo"]); if (isCreate || ISCREATEOTHERAP || ISCREATEBOUNS || ISCREATELOGISTICS) { string msg = string.Format("单据:{0}配送出库单,已生成下游单据,不允许反审核,具体信息见单据资金池页签", billNo); var errInfo = new ValidationErrorInfo( item.BillNo, item.DataEntity["Id"].ToString(), item.DataEntityIndex, item.RowIndex, "SALOUTValid019", msg, " ", Kingdee.BOS.Core.Validation.ErrorLevel.Error); validateContext.AddError(item.DataEntity, errInfo); } } }
public override void Validate(ExtendedDataEntity[] dataEntities, ValidateContext validateContext, Context ctx) { if (dataEntities.IsNullOrEmpty() || dataEntities.Length == 0) { return; } foreach (ExtendedDataEntity item in dataEntities) { DynamicObject requestDynamic = item.DataEntity; bool isCreate = Convert.ToBoolean(requestDynamic["FIsCreateApply"]); //是否生成费用申请单 string billNo = Convert.ToString(requestDynamic["BillNo"]); //收款单单号 string costReqBillNo = Convert.ToString(requestDynamic["FCostApplyNo"]); //费用申请单单号 DynamicObjectCollection Entry = requestDynamic["RECEIVEBILLENTRY"] as DynamicObjectCollection; string PurPoseNum = Convert.ToString(((DynamicObject)Entry[0]["PURPOSEID"])["Number"]); //门店加盟费:005 if (PurPoseNum.Equals("005") && isCreate) { string msg = string.Format("单据:{0}收付款用途包含门店加盟费,已生成费用申请单:{1},不允许反审核", billNo, costReqBillNo); var errInfo = new ValidationErrorInfo( item.BillNo, item.DataEntity["Id"].ToString(), item.DataEntityIndex, item.RowIndex, "ARValid019", msg, " ", Kingdee.BOS.Core.Validation.ErrorLevel.Error); validateContext.AddError(item.DataEntity, errInfo); } } }
public override void Validate(ExtendedDataEntity[] dataEntities, ValidateContext validateContext, Context ctx) { if (dataEntities.IsNullOrEmpty() || dataEntities.Length == 0) { return; } foreach (ExtendedDataEntity item in dataEntities) { DynamicObject requestDynamic = item.DataEntity; if (Convert.ToInt32(requestDynamic["F_PAEZ_SFYQZF"]) == 0) { string msg = string.Format("单据:{0},未启用银企支付参数,不可通过银企进行付款", requestDynamic["BillNo"]); var errInfo = new ValidationErrorInfo( item.BillNo, item.DataEntity["Id"].ToString(), item.DataEntityIndex, item.RowIndex, "Valid019", msg, " ", Kingdee.BOS.Core.Validation.ErrorLevel.Error); validateContext.AddError(item.DataEntity, errInfo); } } }
public override void Validate(ExtendedDataEntity[] dataEntities, ValidateContext validateContext, Context ctx) { if (Result != null && !Result.Success && !string.IsNullOrEmpty(Result.Message)) { ValidationErrorInfo info = new ValidationErrorInfo("FBillNo", Convert.ToString(new Guid()), 0, 0, FormId, Result.Message, ""); validateContext.AddError(new Guid(), info); } }
public override void Validate(ExtendedDataEntity[] dataEntities, ValidateContext validateContext, Kingdee.BOS.Context ctx) { if (dataEntities == null || dataEntities.Length == 0) { return; } List <long> dictErrMaterialId = new List <long>(); //取所有物料 List <long> listMaterialId = new List <long>(); foreach (ExtendedDataEntity entityObj in dataEntities) { DynamicObjectCollection collection = (DynamicObjectCollection)entityObj["Entity"]; //取酶活量小于等于于零的 var checkRows = collection.Where(f => Convert.ToDecimal(f["FJNUnitEnzymes"]) <= 0).ToList(); if (checkRows == null || checkRows.Count() <= 0) { continue; } foreach (DynamicObject rowObj in checkRows) { listMaterialId.Add((long)rowObj["MaterialId_Id"]); } } if (listMaterialId.Count > 0) { string sql = " select a.FMATERIALID from T_BD_MATERIAL a where exists (select 1 from TABLE(fn_StrSplit(@FMATERIALID, ',',1)) t where t.FID=a. FMATERIALID and a.FISMEASURE='1' ) "; SqlParam param = new SqlParam("@FMATERIALID", KDDbType.udt_inttable, listMaterialId.Distinct().ToArray()); using (IDataReader dr = DBUtils.ExecuteReader(this.Context, sql, param)) { while (dr.Read()) { if (dr != null) { dictErrMaterialId.Add(Convert.ToInt64(dr["FMATERIALID"])); } } } } foreach (ExtendedDataEntity entityObj in dataEntities) { DynamicObjectCollection collection = (DynamicObjectCollection)entityObj["Entity"]; foreach (DynamicObject rowObj in collection) { if (dictErrMaterialId.Contains((long)rowObj["MaterialId_Id"])) { ValidationErrorInfo errinfo = new ValidationErrorInfo("FMATERIALID", Convert.ToString(entityObj.DataEntity["Id"]), entityObj.DataEntityIndex, Convert.ToInt32(rowObj["Id"]), "SubmitValidator", "第" + Convert.ToString(rowObj["Seq"]) + "行启用双计量,单位酶活必须大于0", "校验失败", ErrorLevel.Error); validateContext.AddError(entityObj, errinfo); } } } }
/// <summary> /// 客户管理员 /// </summary> /// <param name="dataEntity"></param> /// <param name="validateContext"></param> /// <param name="ctx"></param> /// <param name="FID"></param> private void Act_CtrlCustAdmin(ExtendedDataEntity dataEntity, ValidateContext validateContext, Context ctx, string FID) { string FCustId = dataEntity["FCustName"] == null ? "0" : (dataEntity["FCustName"] as DynamicObject)["Id"].ToString(); if (FCustId == "0") { ValidationErrorInfo ValidationErrorInfo = new ValidationErrorInfo( string.Empty, FID, dataEntity.DataEntityIndex, dataEntity.RowIndex, FID, "客户不能为空!", string.Empty); validateContext.AddError(null, ValidationErrorInfo); } string sql = string.Format("SELECT FISTRADE FROM T_BD_CUSTOMER WHERE FCUSTID='{0}'", FCustId); var objs = DBUtils.ExecuteDynamicObject(ctx, sql); if (objs.Count > 0) { string FISTRADE = objs[0]["FISTRADE"].ToString(); if (FISTRADE == "0" || FISTRADE == "") { ValidationErrorInfo ValidationErrorInfo = new ValidationErrorInfo( string.Empty, FID, dataEntity.DataEntityIndex, dataEntity.RowIndex, FID, "当前客户为非交易客户,请转为交易客户后再进行提交!", string.Empty); validateContext.AddError(null, ValidationErrorInfo); } else { string FCustName = dataEntity["FCustName"] == null ? "" : (dataEntity["FCustName"] as DynamicObject)["Name"].ToString(); sql = "SELECT FCUSTID FROM T_BD_CUSTOMER_L WHERE FNAME='" + FCustName + "' AND FLOCALEID='2052'"; objs = DBUtils.ExecuteDynamicObject(ctx, sql); if (objs.Count < 1) { ValidationErrorInfo ValidationErrorInfo = new ValidationErrorInfo( string.Empty, FID, dataEntity.DataEntityIndex, dataEntity.RowIndex, FID, "当前客户还未进行分配,请分配到相应组织后再进行提交!", string.Empty); validateContext.AddError(null, ValidationErrorInfo); } } } }
public override void Validate(BOS.Core.ExtendedDataEntity[] dataEntities, ValidateContext validateContext, BOS.Context ctx) { Dictionary <string, decimal> dic = new Dictionary <string, decimal>(); foreach (var row in dataEntities) { DynamicObject material = row["MaterialID"] as DynamicObject; decimal qty = Convert.ToDecimal(row["Qty"]); decimal maxQty = Convert.ToDecimal(material["F_PAEZ_maxSaleQty"]); Boolean isLimitSaleQty = Convert.ToBoolean(material["F_PAEZ_isLimitSaleQty"]); DateTime startDate = Convert.ToDateTime(material["F_PAEZ_startDate"]); int seq = Convert.ToInt32(row["Seq"]); if (null == material || !isLimitSaleQty || startDate > DateTime.Now || Convert.ToString(startDate) == "0001-01-01 00:00:00") { continue; } //用字典记录下上面物料的数量 最大销量是这个单据上所有数量 + 其它已经审核 + 其它审核中 的数量 string number = material["Number"].ToString(); if (dic.ContainsKey(number)) { decimal qty1 = dic[number]; dic.Remove(number); dic.Add(number, qty1 + qty); } else { dic.Add(number, qty); } string sql = string.Format(@"SELECT sum(b.FQTY) qty FROM T_SAL_ORDER a inner join T_SAL_ORDERENTRY b on a.fid =b.fid WHERE b.FMATERIALID ='{0}' AND a.FDOCUMENTSTATUS in ('B','C') and a.FDATE>='{1}'", material["Id"], startDate.Date); DynamicObjectCollection saleOrderCol = DBUtils.ExecuteDynamicObject(this.Context, sql); if (saleOrderCol.Count > 0) { qty = dic[number] + Convert.ToDecimal(saleOrderCol[0]["qty"]); } if (qty > maxQty) { ValidationErrorInfo errinfo = new ValidationErrorInfo( "FSeq", //单据体序号标识 Convert.ToString(row.DataEntity["Id"]), row.DataEntityIndex, Convert.ToInt32(row["Id"]), "SubmitValidator", // "序号为" + seq + "这行数量大于此物料的最大销量,不允许提交当前销售订单!请更换其他产品.", //提示信息内容 "校验失败", //提示信息标题 ErrorLevel.Error); //添加错误信息到validateContext中 validateContext.AddError(row, errinfo); } } }
public ValidationInfo(OpenXmlPowerToolsDocument doc, ValidationErrorInfo err) { Document = doc; FileName = doc.FileName; Description = err.Description; ErrorType = err.ErrorType; Id = err.Id; Node = err.Node; Part = err.Part; XPath = err.Path.XPath; RelatedNode = err.RelatedNode; RelatedPart = err.RelatedPart; }
public void CreateError(string id, ValidationErrorType errorType, string description = null) { var error = new ValidationErrorInfo { Id = id, Description = description, Part = _part, ErrorType = errorType, Node = _element, }; AddError(error); }
internal static ValidationErrorInfo ComposeValidationError(this ValidationContext validationContext, ValidationErrorType errorType, OpenXmlElement element, OpenXmlElement child, string messageId, params string[] args) { ValidationErrorInfo errorInfo = new ValidationErrorInfo() { ErrorType = errorType, Part = validationContext.Part, Node = element, Id = messageId, RelatedNode = child, Description = string.Format(CultureInfo.CurrentUICulture, ValidationResources.ResourceManager.GetString(messageId), args) }; return(errorInfo); }
/// <summary> /// Bom员 /// </summary> /// <param name="dataEntity"></param> /// <param name="validateContext"></param> /// <param name="ctx"></param> /// <param name="FID"></param> private void Act_CtrlBomer(ExtendedDataEntity dataEntity, ValidateContext validateContext, Context ctx, string FID) { bool IsNull = false; var entity = dataEntity["FEntityBPR"] as DynamicObjectCollection; string FBMtlGroup = "0"; string FMaterialID = "0"; string userId = ctx.UserId.ToString(); string sql = string.Format(@"SELECT emg.F_ORA_CRMMTLGP FROM (SELECT * FROM T_SEC_USER WHERE FUSERID='{0}') u INNER JOIN V_BD_CONTACTOBJECT c ON u.FLINKOBJECT=c.FID INNER JOIN T_HR_EMPINFO e ON c.FNUMBER=e.FNUMBER AND e.F_ORA_ISCRMBOM=1 INNER JOIN T_HR_EMPINFOCrmMG emg ON e.FID=emg.FID", userId); var objs = DBUtils.ExecuteDynamicObject(ctx, sql); string MtlGp = ""; for (int i = 0; i < entity.Count; i++) { FBMtlGroup = entity[i]["FBMtlGroup"] == null ? "0" : (entity[i]["FBMtlGroup"] as DynamicObject)["Id"].ToString(); for (int j = 0; j < objs.Count; j++) { if (objs[j]["F_ORA_CRMMTLGP"].ToString() == FBMtlGroup) { FMaterialID = entity[i]["FMaterialID"] == null ? "0" : (entity[i]["FMaterialID"] as DynamicObject)["Id"].ToString(); if (FMaterialID == "0") { IsNull = true; break; } } } } if (IsNull) { ValidationErrorInfo ValidationErrorInfo = new ValidationErrorInfo( string.Empty, FID, dataEntity.DataEntityIndex, dataEntity.RowIndex, FID, "请选择对应的物料!", string.Empty); validateContext.AddError(null, ValidationErrorInfo); } }
public override void Validate(Kingdee.BOS.Core.ExtendedDataEntity[] dataEntities, ValidateContext validateContext, Kingdee.BOS.Context ctx) { foreach (var dataEntity in dataEntities) { string FID = dataEntity["Id"].ToString(); string procInstId = WorkflowChartServiceHelper.GetProcInstIdByBillInst(ctx, this.formId, FID); List <ChartActivityInfo> routeCollection = WorkflowChartServiceHelper.GetProcessRouter(ctx, procInstId); var WFNode = routeCollection[routeCollection.Count - 1]; if (WFNode.ActivityId == AllocProcessor_NodeID) { var FExecutor = dataEntity["FExecutor"] as DynamicObjectCollection; if (FExecutor.Count <= 0) { ValidationErrorInfo ValidationErrorInfo = new ValidationErrorInfo( string.Empty, FID, dataEntity.DataEntityIndex, dataEntity.RowIndex, FID, "请先分配执行人!", string.Empty); validateContext.AddError(null, ValidationErrorInfo); } else { } } else if (WFNode.ActivityId == ProcessorInputResult_NodeID) { if (dataEntity["FResult"].ToString().IsNullOrEmptyOrWhiteSpace()) { ValidationErrorInfo ValidationErrorInfo = new ValidationErrorInfo( string.Empty, FID, dataEntity.DataEntityIndex, dataEntity.RowIndex, FID, "请填写执行结果!", string.Empty); validateContext.AddError(null, ValidationErrorInfo); } } } }
public override void Validate(Kingdee.BOS.Core.ExtendedDataEntity[] dataEntities, ValidateContext validateContext, Kingdee.BOS.Context ctx) { foreach (var dataEntity in dataEntities) { string FID = dataEntity["Id"].ToString(); string procInstId = WorkflowChartServiceHelper.GetProcInstIdByBillInst(ctx, this.formId, FID); List <ChartActivityInfo> routeCollection = WorkflowChartServiceHelper.GetProcessRouter(ctx, procInstId); var WFNode = routeCollection[routeCollection.Count - 1]; if (WFNode.ActivityId == AllocRoom_NodeID) { var room = dataEntity["FBALCONYNUM2"]; if (room == null) { ValidationErrorInfo ValidationErrorInfo = new ValidationErrorInfo( string.Empty, FID, dataEntity.DataEntityIndex, dataEntity.RowIndex, FID, "请分配包厢号!", string.Empty); validateContext.AddError(null, ValidationErrorInfo); } } else if (WFNode.ActivityId == RealAmount_NodeID) { float FRealAmount = float.Parse(dataEntity["FRealAmount"].ToString()); if (FRealAmount <= 0) { ValidationErrorInfo ValidationErrorInfo = new ValidationErrorInfo( string.Empty, FID, dataEntity.DataEntityIndex, dataEntity.RowIndex, FID, "请确认实际金额!", string.Empty); validateContext.AddError(null, ValidationErrorInfo); } } } }
/// <summary> /// Check if specified context meets all registered constraints /// </summary> /// <param name="context"></param> /// <returns></returns> public IEnumerable <ValidationErrorInfo> CheckConstraints(ValidationContext context) { SemanticValidationLevel level = SemanticValidationLevel.Element; if (context.Part != null) { level = SemanticValidationLevel.Part; } if (context.Package != null) { level = SemanticValidationLevel.Package; } int elementTypeID = context.Element.ElementTypeId; if (_cleanList.Keys.Contains(elementTypeID)) { foreach (var con in _cleanList[elementTypeID]) { con.ClearState(context); } } if (_semConstraintMap.ContainsKey(elementTypeID)) { foreach (SemanticConstraint constraint in _semConstraintMap[elementTypeID]) { if ((constraint.SemanticValidationLevel & level) == level) { ValidationErrorInfo err = constraint.Validate(context); if (err != null) { #if DEBUG err.SemanticConstraintId = constraint.ConstratintId; #endif yield return(err); } } } } }
public override void Validate(Kingdee.BOS.Core.ExtendedDataEntity[] dataEntities, ValidateContext validateContext, Kingdee.BOS.Context ctx) { foreach (var dataEntity in dataEntities) { string FID = dataEntity["Id"].ToString(); string procInstId = WorkflowChartServiceHelper.GetProcInstIdByBillInst(ctx, this.formId, FID); List <ChartActivityInfo> routeCollection = WorkflowChartServiceHelper.GetProcessRouter(ctx, procInstId); var WFNode = routeCollection[routeCollection.Count - 1]; if (WFNode.ActivityId == GM_NodeID) //选择执行人 { var FExecutor = dataEntity["FExecutor"] as DynamicObjectCollection; if (FExecutor.Count <= 0) { ValidationErrorInfo ValidationErrorInfo = new ValidationErrorInfo( string.Empty, FID, dataEntity.DataEntityIndex, dataEntity.RowIndex, FID, "请分配执行人!", string.Empty); validateContext.AddError(null, ValidationErrorInfo); } } else if (WFNode.ActivityId == AP_NodeID)//申请人评价 { string FNotSatisfied = dataEntity["FNotSatisfied"].ToString(); string FSatisfied = dataEntity["FSatisfied"].ToString(); if ((FNotSatisfied == "False" && FSatisfied == "False") || (FNotSatisfied == "True" && FSatisfied == "True")) { ValidationErrorInfo ValidationErrorInfo = new ValidationErrorInfo( string.Empty, FID, dataEntity.DataEntityIndex, dataEntity.RowIndex, FID, "请对服务进行评价!", string.Empty); validateContext.AddError(null, ValidationErrorInfo); } } } }
public override void Validate(Kingdee.BOS.Core.ExtendedDataEntity[] dataEntities, ValidateContext validateContext, Kingdee.BOS.Context ctx) { DataTable _dt; string _sql = "exec proc_cztyCrm_Contract @FCrmSOID='#FID#'"; string _backM = ""; string _backMsg = ""; foreach (var dataEntity in dataEntities) { string _FID = dataEntity["Id"].ToString(); string _vadSql = _sql.Replace("#FID#", _FID); try { _dt = DBUtils.ExecuteDataSet(this.Context, _vadSql).Tables[0]; if (_dt.Rows.Count > 0) { _backM = _dt.Rows[0]["FBackM"].ToString(); _backMsg = _dt.Rows[0]["FBackMsg"].ToString(); } } catch (Exception _ex) { _backM = "ERR"; _backMsg = _ex.Message; } //判断到数据有错误 if (_backM == "ERR") { ValidationErrorInfo ValidationErrorInfo = new ValidationErrorInfo( string.Empty, dataEntity["Id"].ToString(), dataEntity.DataEntityIndex, dataEntity.RowIndex, dataEntity["Id"].ToString(), _backMsg, string.Empty); validateContext.AddError(null, ValidationErrorInfo); continue; } } }
public override void Validate(ExtendedDataEntity[] dataEntities, ValidateContext validateContext, Context ctx) { foreach (var dataEntity in dataEntities) { string _FIsSynHR = dataEntity["FIsSynHR"].ToString(); if (_FIsSynHR.Equals("True")) { ValidationErrorInfo ValidationErrorInfo = new ValidationErrorInfo( string.Empty, dataEntity["Id"].ToString(), dataEntity.DataEntityIndex, dataEntity.RowIndex, dataEntity["Id"].ToString(), "单据已同步至HR,不允许反审核!", string.Empty ); validateContext.AddError(null, ValidationErrorInfo); } } }
public override void Validate(Kingdee.BOS.Core.ExtendedDataEntity[] dataEntities, ValidateContext validateContext, Kingdee.BOS.Context ctx) { foreach (var dataEntity in dataEntities) { string FID = dataEntity["Id"].ToString(); string procInstId = WorkflowChartServiceHelper.GetProcInstIdByBillInst(ctx, this.formId, FID); List <ChartActivityInfo> routeCollection = WorkflowChartServiceHelper.GetProcessRouter(ctx, procInstId); var WFNode = routeCollection[routeCollection.Count - 1]; if (WFNode.ActivityId == Seal_NodeID) { string realOffTime = dataEntity["FRealOffTime"] == null ? "" : dataEntity["FRealOffTime"].ToString(); string realBackTime = dataEntity["FRealBackTime"] == null ? "" : dataEntity["FRealBackTime"].ToString(); if (realOffTime.IsNullOrEmptyOrWhiteSpace()) { ValidationErrorInfo ValidationErrorInfo = new ValidationErrorInfo( string.Empty, FID, dataEntity.DataEntityIndex, dataEntity.RowIndex, FID, "请填写印章实际带离时间!", string.Empty); validateContext.AddError(null, ValidationErrorInfo); } else if (realBackTime.IsNullOrEmptyOrWhiteSpace()) { ValidationErrorInfo ValidationErrorInfo = new ValidationErrorInfo( string.Empty, FID, dataEntity.DataEntityIndex, dataEntity.RowIndex, FID, "请填写印章实际归还时间!", string.Empty); validateContext.AddError(null, ValidationErrorInfo); } } } }
public override void Validate(Kingdee.BOS.Core.ExtendedDataEntity[] dataEntities, ValidateContext validateContext, Kingdee.BOS.Context ctx) { foreach (var dataEntity in dataEntities) { string FID = dataEntity["Id"].ToString(); //string procInstId = WorkflowChartServiceHelper.GetProcInstIdByBillInst(ctx, this.formId, FID); //List<ChartActivityInfo> routeCollection = WorkflowChartServiceHelper.GetProcessRouter(ctx, procInstId); //var WFNode = routeCollection[routeCollection.Count - 1]; string FMeetName = dataEntity["FMeetName"] == null ? "" : (dataEntity["FMeetName"] as DynamicObject)["Id"].ToString(); if (FMeetName.IsNullOrEmptyOrWhiteSpace()) { ValidationErrorInfo ValidationErrorInfo = new ValidationErrorInfo( string.Empty, FID, dataEntity.DataEntityIndex, dataEntity.RowIndex, FID, "请分配空闲的会议室!", string.Empty); validateContext.AddError(null, ValidationErrorInfo); } } }
private void RecursivelyCheckLineItemsInPresentation(ArrayList nNodes, ref List<ValidationErrorInfo> secValidationErrors) { if (nNodes == null) return; foreach (Node n in nNodes) { if (n.IsProhibited) continue; if (n.Parent != null) { if (n.IsAbstract && n.Id.EndsWith("LineItems")) { bool isError = true; if (n.Parent.MyElement != null && n.Parent.MyElement.IsHyperCubeItem()) { isError = false; } if (isError) { ValidationErrorInfo info = new ValidationErrorInfo( string.Format("Line Item {0} in report {1} does not confirm with the US GAAP architecture requirement of line items should only be a child of a table element.", n.MyElement.Name, n.GetPresentationLink().Title), ValidationErrorInfo.ValidationCategoryType.SECValidationError, "Presentation Error", ValidationErrorInfo.SequenceEnum.USGAAP_STRUCTURE_ERROR_LINE_ITEM2); secValidationErrors.Add(info); } } } RecursivelyCheckLineItemsInPresentation(n.children, ref secValidationErrors); } }
private void AssertValidationErrorCategory(string expected, ValidationErrorInfo targetErrorInfo) { #if DEBUG Assert.Equal(expected, targetErrorInfo.ValidationErrorCategory); #endif }
private void RecursivelyBuildChildrenForParent(Node parent, ref List<string> cns , ref List<ValidationErrorInfo> secValidationErrors) { if (parent.children == null) return; if (parent.IsProhibited) return; foreach (Node c in parent.children) { if (c.IsProhibited) continue; if (cns.Contains(c.MyElement.GetNameWithNamespacePrefix())) { ValidationErrorInfo info = new ValidationErrorInfo( string.Format("In Report '{0}' element '{1}' with Label '{2} is used multiple times in calculating a parent value. This might result in incorrect calculated values for the parent element.", parent.GetPresentationLink().Title, c.MyElement.GetNameWithNamespacePrefix(), c.Label), ValidationErrorInfo.ValidationCategoryType.SECValidationWarning, "Calculation Warning", ValidationErrorInfo.SequenceEnum.CALCULATION_WARNING_POSSIBLE_APPALACHIAN_TREE); info.MyErrorType = ValidationErrorInfo.ErrorType.Warning; secValidationErrors.Add(info); } else { cns.Add(c.MyElement.GetNameWithNamespacePrefix()); RecursivelyBuildChildrenForParent(c, ref cns, ref secValidationErrors); } } }
/// <summary> /// /// </summary> /// <param name="inUseElements"></param> /// <param name="role"></param> /// <param name="includeSegments"></param> /// <param name="missingPresentation"></param> /// <returns></returns> public void GetCalculationRelationshipsMissingInPresentation( Dictionary<string, bool> inUseElements, Dictionary<string, List<Node>> CalcParents, Dictionary<string, List<string>> inUsePresElementIdsByReport, ref List<ValidationErrorInfo> secValidationErrors) { if (inUseElements.Count == 0) return; foreach (KeyValuePair<string, List<Node>> kvp in CalcParents) { if (!inUseElements.ContainsKey(kvp.Value[0].Id)) continue; Dictionary<string, List<string>> reportsWithParent = new Dictionary<string, List<string>>(); foreach (KeyValuePair<string, List<string>> kvp1 in inUsePresElementIdsByReport) { if (kvp1.Value.Contains(kvp.Value[0].Id)) { reportsWithParent[kvp1.Key] = kvp1.Value; } } foreach (Node pn in kvp.Value) { if (pn.children == null) continue; foreach (Node cn in pn.children) { if (!inUseElements.ContainsKey(cn.Id)) continue; bool found = false; foreach (KeyValuePair<string, List<string>> kvp2 in reportsWithParent) { if (kvp2.Value.Contains(cn.Id)) { found = true; break; } } if (!found) { ValidationErrorInfo info = new ValidationErrorInfo( string.Format("Calculation Report '{0}' has element {1} as a parent and element {2} as a child. There should be at least one effective presentation relationship between these elements in any presentation report.", pn.GetPresentationLink().Title, pn.Name, cn.Name), ValidationErrorInfo.ValidationCategoryType.SECValidationError, "Calculation Error", ValidationErrorInfo.SequenceEnum.CALCULATION_RELATIONSHIP_MISSING_IN_PRESENTATION_ERROR); secValidationErrors.Add(info); } } } } }
/// <summary> /// Performs the SEC validations. /// </summary> /// <param name="validMarkups">The valid markups.</param> /// <param name="markedupElements">The marked up elements.</param> /// <param name="excludedReports">The excluded reports.</param> /// <param name="isMutualFundsTaxonomy">if set to <c>true</c> [is mutual funds taxonomy].</param> /// <param name="calculationItems">The calculation items.</param> /// <param name="secValidationErrors">The sec validation errors.</param> public void PerformSECValidations( List<MarkupProperty> validMarkups, Dictionary<string, bool> markedupElements, //should refactor to remove this as we want to use valid markups List<string> excludedReports, bool isMutualFundsTaxonomy, List<ValidationCalculationItem> calculationItems, ref List<ValidationErrorInfo> secValidationErrors) { if (validMarkups != null && validMarkups.Count > 0 ) { //rebuild the markedupElements based on the valid markups... markedupElements = new Dictionary<string, bool>(); foreach (MarkupProperty mp in validMarkups) { if (mp.element == null || mp.element.MyElement == null || string.IsNullOrEmpty(mp.element.MyElement.Id)) continue; markedupElements[mp.element.MyElement.Id] = true; } } List<RoleType> rts; this.TryGetUsedRoleTypes(out rts); foreach (RoleType rt in rts) { if (!this.IsExtendedRole(rt.Uri)) continue; IsValidateReportName(isMutualFundsTaxonomy, rt.Definition, ref secValidationErrors); } ArrayList presNodes = this.GetNodesByPresentation(true); ArrayList calcNodes = this.GetNodesByCalculation(); List<DimensionNode> dimNodes; TryGetAllDimensionNodesForDisplay(null, null, true, out dimNodes); if (dimNodes == null) dimNodes = new List<DimensionNode>(); if (excludedReports != null && excludedReports.Count > 0) { ArrayList tmp = new ArrayList(); if (presNodes != null) { foreach (Node n in presNodes) { if (!excludedReports.Contains(n.GetPresentationLink().Role)) { tmp.Add(n); } } presNodes = tmp; } tmp = new ArrayList(); if (calcNodes != null) { foreach (Node n in calcNodes) { if (!excludedReports.Contains(n.GetPresentationLink().Role)) { tmp.Add(n); } } calcNodes = tmp; } if (dimNodes != null) { List<DimensionNode> tmpDN = new List<DimensionNode>(); foreach (DimensionNode dn in dimNodes) { if (!excludedReports.Contains(dn.MyDefinitionLink.Role)) { tmpDN.Add(dn); } } dimNodes = tmpDN; } } //perform taxonomy level validations on the markedup elements. #region Presentation validations //Missing in Presentation List<Node> nodesNotInPresentation = GetInUseNodesMissingInPresentation(markedupElements, true, presNodes, excludedReports); foreach (Node n in nodesNotInPresentation) { ValidationErrorInfo info = new ValidationErrorInfo( string.Format("In use element '{0}' does not have a presentation relationship defined.", n.Label), ValidationErrorInfo.ValidationCategoryType.SECValidationError, "Presentation Error", ValidationErrorInfo.SequenceEnum.MISSING_IN_PRESENTATION_ERROR); secValidationErrors.Add(info); } //allow the same inuse element in multiple places only if it has different label roles.. Dictionary<string, List<Node>> inUsePresNodes = new Dictionary<string, List<Node>>(); Dictionary<string, List<string>> inUsePresElementIdsByReport = new Dictionary<string, List<string>>(); foreach (Node n in presNodes) { List<string> inUseElementsInReport = new List<string>(); RecursivelyGetInUseNodes(markedupElements, n, ref inUsePresNodes, ref inUseElementsInReport); inUsePresElementIdsByReport[n.GetPresentationLink().Role] = inUseElementsInReport; } //use this to avoid duplicate error display.... List<string> checkedErrors = new List<string>(); foreach (KeyValuePair<string, List<Node>> kvp in inUsePresNodes) { if (kvp.Value.Count <= 1) { continue; } Dictionary<string, Node> infos = new Dictionary<string, Node>(); foreach (Node n in kvp.Value) { string nInfo = string.Format("{0}-{1}-{2}", n.GetPresentationLink().Role, n.parent.Id, n.PreferredLabel == null ? string.Empty : n.PreferredLabel); if (checkedErrors.Contains(nInfo)) { continue; } Node other; if (infos.TryGetValue(nInfo, out other)) { if (other.Order != n.Order) { ValidationErrorInfo info = new ValidationErrorInfo( string.Format("Found duplicate occurrence of the element '{0}' in the report '{1}'.", n.Label, n.GetPresentationLink().Title), ValidationErrorInfo.ValidationCategoryType.SECValidationError, "Presentation Error", ValidationErrorInfo.SequenceEnum.DUPLICATION_IN_PRESENTATION_ERROR); secValidationErrors.Add(info); checkedErrors.Add(nInfo); } } infos[nInfo] = n; } } Dictionary<string, List<Node>> parentChildArcToRoleInfo = new Dictionary<string, List<Node>>(); //Withina report missing in Presentation but exists in calculation. if (calculationInfo != null) { foreach (Node calcRootNode in calcNodes) { PresentationLink pl = calcRootNode.GetPresentationLink(); bool missingPresentation = false; List<Node> missingNodes = GetInUseCalculationNodesMissingInCurrentReport(markedupElements, pl.Role, true, ref missingPresentation, calcRootNode); foreach (Node n in missingNodes) { ValidationErrorInfo info = new ValidationErrorInfo( string.Format("Report '{0}' has the element '{1}' in the calculation view but is missing in the presentation view.", pl.Title, n.Label), ValidationErrorInfo.ValidationCategoryType.SECValidationWarning, "Presentation Warning", ValidationErrorInfo.SequenceEnum.ELEMENT_IN_CALCULATION_NOT_IN_PRESENTATION_WARNING); info.MyErrorType = ValidationErrorInfo.ErrorType.Warning; secValidationErrors.Add(info); } if (missingPresentation) { ValidationErrorInfo info = new ValidationErrorInfo( string.Format("Report '{0}' does not have a presentation view.", pl.Role), ValidationErrorInfo.ValidationCategoryType.SECValidationWarning, "Presentation Warning", ValidationErrorInfo.SequenceEnum.PRESENTATION_REPORT_MISSING_WARNING); info.MyErrorType = ValidationErrorInfo.ErrorType.Warning; secValidationErrors.Add(info); } if (calcRootNode.children != null) { foreach (Node parent in calcRootNode.children) { RecursivelyCheckUniquenessOfParentChildArc(parent, markedupElements, ref parentChildArcToRoleInfo, ref secValidationErrors); CheckRecursionInCalculation(calcRootNode.GetPresentationLink(), parent, ref secValidationErrors); List<string> allChildren = new List<string>(); allChildren.Add(parent.MyElement.GetNameWithNamespacePrefix()); RecursivelyBuildChildrenForParent(parent, ref allChildren, ref secValidationErrors); RecursivelyCheckPeriodTypeOnParentChild(parent, ref secValidationErrors); } } } } PerformTextBlockElementValidation(presNodes, markedupElements, ref secValidationErrors); #endregion Dictionary<string, Node> reportLineItems = new Dictionary<string, Node>(); Dictionary<string, List<string>> reportDimensionInfos = new Dictionary<string, List<string>>(); ValidateStructure(excludedReports, presNodes, isMutualFundsTaxonomy, ref reportLineItems, ref reportDimensionInfos, ref secValidationErrors); //CheckIfAxisIsRequired(excludedReports, presNodes, validMarkups, // ref secValidationErrors); Dictionary<string, List<Node>> CalcParents = new Dictionary<string, List<Node>>(); ValidatePresentationandCalculationForUsGaapArchitecture(excludedReports, markedupElements, ref CalcParents, ref secValidationErrors); CheckPeriodTypeMismatchInCalculation(calcNodes, CalcParents, ref secValidationErrors); // For extended elements with a Monetary data type and Balance Type of N/A, show warning foreach (string eleId in markedupElements.Keys) { Element ele = this.allElements[eleId] as Element; if (ele != null && ele.IsAucentExtendedElement && ele.IsMonetary() && ele.BalType == Element.BalanceType.na) { ValidationErrorInfo info = new ValidationErrorInfo( string.Format("The extended element {0} has a data type of Monetary and a Balance Type of N/A. Please confirm the appropriateness with guidance at EFM 6.8.11 and EFM 6.11.5 ", ele.Name), ValidationErrorInfo.ValidationCategoryType.ExtendedElememntMonetaryNA, "Element Error", ValidationErrorInfo.SequenceEnum.EXTENDED_ELEMENT_MONETARY_NA); info.MyErrorType = ValidationErrorInfo.ErrorType.Warning; secValidationErrors.Add(info); } } GetCalculationRelationshipsMissingInPresentation(markedupElements, CalcParents, inUsePresElementIdsByReport, ref secValidationErrors); if (validMarkups != null) { PerformSECDimensionValidation(validMarkups, reportLineItems, reportDimensionInfos, ref secValidationErrors); } Dictionary<string, Element> elementsDt = new Dictionary<string, Element>(); foreach (Node n in presNodes) { if (n.children != null) { foreach (Node childNode in n.children) { RecursivelyGetAllAvailableElements(ref elementsDt, childNode); } } } foreach (Node n in calcNodes) { if (n.children != null && calculationItems != null ) { foreach (ValidationCalculationItem calcItem in calculationItems) { // only do the check if the item is in the marked up elements list. if (markedupElements.ContainsKey(calcItem.ElementId)) { Node result = n.GetChild(calcItem.ElementId); if (result != null) CheckCalcRules(result, calcItem, ref secValidationErrors); } } foreach (Node childNode in n.children) { RecursivelyGetAllAvailableElements(ref elementsDt, childNode); } } } foreach (Node n in dimNodes) { if (n.children != null) { foreach (Node childNode in n.children) { RecursivelyGetAllAvailableElements(ref elementsDt, childNode); } } } #region Extended elements validations //Extended element Id naming convension checks PerformExtendedElementValidation(ref secValidationErrors, markedupElements, presNodes, dimNodes, elementsDt, excludedReports, isMutualFundsTaxonomy); #endregion #region Extended Roles Validation PerfromExtendedRolesValidation(ref secValidationErrors); #endregion PerformElementLabelValidations(ref secValidationErrors, elementsDt, markedupElements, presNodes, isMutualFundsTaxonomy); secValidationErrors.Sort(); }
////just a flat list of all axis and members... //private Dictionary<string, bool> BuildDimensionElementsUsed( // List<MarkupProperty> validMarkups ) //{ // Dictionary<string, bool> ret = new Dictionary<string, bool>(); // foreach (MarkupProperty mp in validMarkups) // { // if (mp.contextRef == null) continue; // if (mp.contextRef.Segments != null && mp.contextRef.Segments.Count > 0) // { // List<string> eleDimMembers = new List<string>(); // StringBuilder dimVals = new StringBuilder(); // foreach (Segment seg in mp.contextRef.Segments) // { // if (seg.DimensionInfo == null) continue; // ret[seg.DimensionInfo.Id] = true; // ret[seg.DimensionInfo.dimensionId] = true; // } // } // } // return ret; //} private void RecursivelyCheckUniquenessOfParentChildArc(Node parent, Dictionary<string, bool> markedupElements, ref Dictionary<string, List<Node>> parentChildArcToRoleInfo, ref List<ValidationErrorInfo> secValidationErrors) { if (parent.IsProhibited) return; if (parent.children != null && parent.children.Count > 0) { foreach (Node child in parent.children) { if (child.IsProhibited) continue; if (markedupElements.ContainsKey(parent.Id) && markedupElements.ContainsKey(child.Id)) { string key = parent.Id + child.Id; List<Node> otherParentNodes; bool addParentNode = true; if (parentChildArcToRoleInfo.TryGetValue(key, out otherParentNodes)) { foreach (Node opn in otherParentNodes) { if (opn.GetPresentationLink().Role == parent.GetPresentationLink().Role) { //current parent already checked.... addParentNode = false; break; } Node GoodParent, badParent; if (IsInCompleteCalculation(opn, parent, markedupElements, out GoodParent, out badParent)) { ValidationErrorInfo info = new ValidationErrorInfo( string.Format("Calculation relationship between '{0}' and '{1}' is defined in report '{2}' and report '{3}'. Please remove this relationship from one of the reports to correct this problem.", parent.Label, child.Label, parent.GetPresentationLink().Title, opn.GetPresentationLink().Title), ValidationErrorInfo.ValidationCategoryType.SECValidationError, "Calculation Arc Error", ValidationErrorInfo.SequenceEnum.DUPLICATE_CALCULATION_ARC_ERROR); secValidationErrors.Add(info); } } } else { otherParentNodes = new List<Node>(); parentChildArcToRoleInfo[key] = otherParentNodes; } if (addParentNode) { otherParentNodes.Add(parent); } } RecursivelyCheckUniquenessOfParentChildArc(child, markedupElements, ref parentChildArcToRoleInfo, ref secValidationErrors); } } }
private void ValidatePresentationandCalculationForUsGaapArchitecture( List<string> excludedReports, Dictionary<string, bool> markedupElements, ref Dictionary<string, List<Node>> CalcParents, ref List<ValidationErrorInfo> secValidationErrors) { ArrayList pNodes = this.GetNodesByPresentation(); ArrayList cNodes = this.GetNodesByCalculation(); if (pNodes == null || cNodes == null) return; ArrayList tmp = new ArrayList(); foreach (Node n in pNodes) { if (excludedReports != null && excludedReports.Contains(n.GetPresentationLink().Role)) { //need to skip this report... continue; } tmp.Add(n); } pNodes = tmp; tmp = new ArrayList(); foreach (Node n in cNodes) { if (excludedReports != null && excludedReports.Contains(n.GetPresentationLink().Role)) { //need to skip this report... continue; } tmp.Add(n); } cNodes = tmp; RecursivelyProhibitUnusedNodes(markedupElements, pNodes); RecursivelyProhibitUnusedNodes(markedupElements, cNodes); Dictionary<string, Node> totalLabelElements = new Dictionary<string, Node>(); RecursivelyGetListOfCalcParents(cNodes, ref CalcParents); RecursivelyGetTotalLabelElements(pNodes, ref totalLabelElements); foreach (string ele in CalcParents.Keys) { if (!markedupElements.ContainsKey(ele)) { //we have a calc parent that is not used.. //we want to issue a warning for this case.. //so that PS can remove this element if required. ValidationErrorInfo info = new ValidationErrorInfo( string.Format("Element {0} is a unused total element in the calculation report {1}. Please verify if this element is required as a parent of other markedup elements.", ele, CalcParents[ele][0].GetPresentationLink().Title), ValidationErrorInfo.ValidationCategoryType.SECValidationWarning, "Calculation Warning", ValidationErrorInfo.SequenceEnum.CALCULATION_WARNING_UNUSED_TOTAL_ELEMENT); info.MyErrorType = ValidationErrorInfo.ErrorType.Warning; secValidationErrors.Add(info); continue; } if (!totalLabelElements.ContainsKey(ele)) { ValidationErrorInfo info = new ValidationErrorInfo( string.Format("Element {0} is a total element in the calculation report {1}. At least one presentation location of this element should use a total label role.", ele, CalcParents[ele][0].GetPresentationLink().Title), ValidationErrorInfo.ValidationCategoryType.SECValidationError, "Calculation Error", ValidationErrorInfo.SequenceEnum.CALCULATION_TOTAL_NOT_PRESENTATION_TOTAL); secValidationErrors.Add(info); } } foreach (string ele in totalLabelElements.Keys) { if (!CalcParents.ContainsKey(ele)) { ValidationErrorInfo info = new ValidationErrorInfo( string.Format("Element {0} is defined with a total label role in the presentation report {1}. It is not a valid total element in any calculation report.", ele, totalLabelElements[ele].GetPresentationLink().Title), ValidationErrorInfo.ValidationCategoryType.SECValidationError, "Presentation Error", ValidationErrorInfo.SequenceEnum.PRESENTATION_TOTAL_NOT_CALCULATION_TOTAL); secValidationErrors.Add(info); } } RecursivelyCheckLineItemsInPresentation(pNodes, ref secValidationErrors); }
private void CheckCalcRules(Node node, ValidationCalculationItem calcItem, ref List<ValidationErrorInfo> secValidationErrors) { decimal nodeCalcWeight = 0; decimal itemCalcWeight = 0; // convert the weights into decimals. some of the values are marked 1 and 1.0 if (decimal.TryParse(node.CalculationWeight, out nodeCalcWeight)) { if (decimal.TryParse(calcItem.Value, out itemCalcWeight)) { if (itemCalcWeight != nodeCalcWeight && calcItem.Category == "NetCashProvidedbyUsedInOperatingActivitiesShouldHavePositiveOneWeight") { ValidationErrorInfo info = new ValidationErrorInfo( string.Format("The element {0} should almost always have a weight of 1. Please confirm calculation weight", node.Id), ValidationErrorInfo.ValidationCategoryType.CalculationWeightWarning, "Calculation Weight Warning", ValidationErrorInfo.SequenceEnum.CALCULATION_WEIGHT_WARNING_NetCashProvidedByUsedInOperatingActivities); info.MyErrorType = ValidationErrorInfo.ErrorType.Warning; secValidationErrors.Add(info); } if (itemCalcWeight != nodeCalcWeight && calcItem.Category == "ElementsShouldHaveWeightPositiveOne") { ValidationErrorInfo info = new ValidationErrorInfo( string.Format("The element {0} almost always should receive a calculation weight of 1 per Rivet Rules. Please confirm calculation weight.", node.Id), ValidationErrorInfo.ValidationCategoryType.CalculationWeightWarning, "Calculation Weight Warning", ValidationErrorInfo.SequenceEnum.CALCULATION_WEIGHT_WARNING_ALMOST_NEVER_RECIEVE_CALCULATIONWEIGHT_NEGATIVE); info.MyErrorType = ValidationErrorInfo.ErrorType.Warning; secValidationErrors.Add(info); } if (itemCalcWeight != nodeCalcWeight && calcItem.Category == "ElementsShouldHaveWeightNegativeOne") { ValidationErrorInfo info = new ValidationErrorInfo( string.Format("The element {0} almost always should receive a calculation weight of -1 per Rivet Rules. Please confirm calculation weight.", node.Id), ValidationErrorInfo.ValidationCategoryType.CalculationWeightWarning, "Calculation Weight Warning", ValidationErrorInfo.SequenceEnum.CALCULATION_WEIGHT_WARNING_ALMOST_NEVER_RECIEVE_CALCULATIONWEIGHT_POSITIVE); info.MyErrorType = ValidationErrorInfo.ErrorType.Warning; secValidationErrors.Add(info); } } } }
public static bool IsValidateReportName(bool isMutualFundTaxonomy, string reportTitle, ref List<ValidationErrorInfo> secValidationErrors) { if (!System.Text.RegularExpressions.Regex.IsMatch(reportTitle, SECReportDefinitionRegex)) { string str = TraceUtility.FormatStringResource("XBRLAddin.ETWizard.Error.SECTitleFormatMessage"); string msg = string.Format(str, reportTitle, "{number} - {type} - {text}"); ValidationErrorInfo info = new ValidationErrorInfo(msg, ValidationErrorInfo.ValidationCategoryType.SECValidationError, "Report Name Error", ValidationErrorInfo.SequenceEnum.REPORT_NAME_ERROR, null); secValidationErrors.Add(info); return false; } //for sec we do not want to allow square brackets or curly brackets... if (!isMutualFundTaxonomy) { if (System.Text.RegularExpressions.Regex.IsMatch(reportTitle, SECReportDefinitionRegexSpecialNotAllowed)) { string str = TraceUtility.FormatStringResource("XBRLAddin.ETWizard.Error.SECTitleFormatMessage"); string msg = string.Format(str, reportTitle, "{number} - {type} - {text}"); msg += " Square brackets and curly braces are not allowed in the title as they would cause rendering issues."; ValidationErrorInfo info = new ValidationErrorInfo(msg, ValidationErrorInfo.ValidationCategoryType.SECValidationError, "Report Name Error", ValidationErrorInfo.SequenceEnum.REPORT_NAME_ERROR, null); secValidationErrors.Add(info); return false; } } return true; }
/// <summary> /// 合同评审员 /// </summary> /// <param name="dataEntity"></param> /// <param name="validateContext"></param> /// <param name="ctx"></param> /// <param name="FID"></param> private void Act_CtrlContractor(ExtendedDataEntity dataEntity, ValidateContext validateContext, Context ctx, string FID) { string FPayTerm = dataEntity["FPayTerm"] == null ? "0" : (dataEntity["FPayTerm"] as DynamicObject)["Id"].ToString(); string F_CZ_BillType = dataEntity["F_CZ_BillType"] == null ? "0" : dataEntity["F_CZ_BillType"].ToString(); string FSettleOrgId = dataEntity["FSettleOrgId"] == null ? "0" : (dataEntity["FSettleOrgId"] as DynamicObject)["Id"].ToString(); if (FPayTerm == "0") { ValidationErrorInfo ValidationErrorInfo = new ValidationErrorInfo( string.Empty, FID, dataEntity.DataEntityIndex, dataEntity.RowIndex, FID, "请选择付款方式!", string.Empty); validateContext.AddError(null, ValidationErrorInfo); } if (F_CZ_BillType == "") { ValidationErrorInfo ValidationErrorInfo = new ValidationErrorInfo( string.Empty, FID, dataEntity.DataEntityIndex, dataEntity.RowIndex, FID, "请选择订单类型!", string.Empty); validateContext.AddError(null, ValidationErrorInfo); } if (FSettleOrgId == "0") { ValidationErrorInfo ValidationErrorInfo = new ValidationErrorInfo( string.Empty, FID, dataEntity.DataEntityIndex, dataEntity.RowIndex, FID, "请选择签单组织!", string.Empty); validateContext.AddError(null, ValidationErrorInfo); } var entity = dataEntity["FEntityBPR"] as DynamicObjectCollection; bool IsNull = false; foreach (var row in entity) { string FProdFactory = row["FProdFactory"] == null ? "0" : (row["FProdFactory"] as DynamicObject)["Id"].ToString(); if (FProdFactory == "0") { IsNull = true; } } if (IsNull) { ValidationErrorInfo ValidationErrorInfo = new ValidationErrorInfo( string.Empty, FID, dataEntity.DataEntityIndex, dataEntity.RowIndex, FID, "请选择表体的生产工厂!", string.Empty); validateContext.AddError(null, ValidationErrorInfo); } }
public override void Validate(Kingdee.BOS.Core.ExtendedDataEntity[] dataEntities, ValidateContext validateContext, Kingdee.BOS.Context ctx) { foreach (var dataEntity in dataEntities) { string FID = dataEntity["Id"].ToString(); string procInstId = WorkflowChartServiceHelper.GetProcInstIdByBillInst(ctx, this.formId, FID); List <ChartActivityInfo> routeCollection = WorkflowChartServiceHelper.GetProcessRouter(ctx, procInstId); var WFNode = routeCollection[routeCollection.Count - 1]; var entity = dataEntity["FEntry"] as DynamicObjectCollection; bool IsNull = false; if (WFNode.ActivityId == AdminAlloc_1_NodeID) //司机 车牌号 出发地点 出发时间 { foreach (var row in entity) { string F_ora_rcvDiver = row["F_ora_rcvDiver"] == null ? "" : row["F_ora_rcvDiver"].ToString(); string F_ora_CarNum = row["F_ora_CarNum"] == null ? "" : row["F_ora_CarNum"].ToString(); string F_ora_StAddr = row["F_ora_StAddr"] == null ? "" : row["F_ora_StAddr"].ToString(); string F_ora_StTime = row["F_ora_StTime"] == null ? "" : row["F_ora_StTime"].ToString(); if (F_ora_rcvDiver == "" || F_ora_CarNum == "" || F_ora_StAddr == "" || F_ora_StTime == "") { IsNull = true; } } if (IsNull) { ValidationErrorInfo ValidationErrorInfo = new ValidationErrorInfo( string.Empty, FID, dataEntity.DataEntityIndex, dataEntity.RowIndex, FID, "请分配司机并填写车牌号、出发地点及出发时间!", string.Empty); validateContext.AddError(null, ValidationErrorInfo); } } /* * else if (WFNode.ActivityId == AdminAlloc_2_NodeID)//实际公里数 实际费用(自动计算) 补贴 * { * foreach (var row in entity) * { * float F_ora_Mileage = float.Parse(row["F_ora_Mileage"].ToString()); * float F_ora_Subsidy = float.Parse(row["F_ora_Subsidy"].ToString()); * if (F_ora_Mileage <= 0 || F_ora_Subsidy <= 0) * { * IsNull = true; * } * } * * if (IsNull) * { * ValidationErrorInfo ValidationErrorInfo = new ValidationErrorInfo( * string.Empty, * FID, * dataEntity.DataEntityIndex, * dataEntity.RowIndex, * FID, * "请确认实际行车公里数及补贴!", * string.Empty); * validateContext.AddError(null, ValidationErrorInfo); * } * } */ } }
public void AddError(ValidationErrorInfo error) => _addError(error);
public override void Validate(ExtendedDataEntity[] dataEntities, ValidateContext validateContext, Context ctx) { if (dataEntities.IsNullOrEmpty() || dataEntities.Length == 0) { return; } foreach (ExtendedDataEntity item in dataEntities) { DynamicObject requestDynamic = item.DataEntity; //有区域门店订货校验起订量 if ((Convert.ToString(((DynamicObject)requestDynamic["FCUSTTYPE"])["Number"]).Equals(ConstantBaseData.YQYMDNO) && Convert.ToInt64(((DynamicObject)requestDynamic["FYWTYPE"])["id"]) == ConstantBaseData.YQYMDDHID)) { double TotalAmount = Convert.ToDouble(requestDynamic["TotalAmount"]); if (TotalAmount < 1000) { string msg = string.Format("单据:{0},订货金额:{1}小于门店起订金额1000", requestDynamic["BillNo"], TotalAmount); var errInfo = new ValidationErrorInfo( item.BillNo, item.DataEntity["Id"].ToString(), item.DataEntityIndex, item.RowIndex, "Valid019", msg, " ", Kingdee.BOS.Core.Validation.ErrorLevel.Error); validateContext.AddError(item.DataEntity, errInfo); } } //有区域门店,订货可发量控制 if ((Convert.ToString(((DynamicObject)requestDynamic["FCUSTTYPE"])["Number"]).Equals(ConstantBaseData.YQYMDNO) && Convert.ToInt64(((DynamicObject)requestDynamic["FYWTYPE"])["id"]) == ConstantBaseData.YQYMDDHID)) { long custId = Convert.ToInt64(((DynamicObject)requestDynamic["FAPPLYCUST"])["Id"]); DynamicObjectCollection dyObjectCol = requestDynamic["FEntity"] as DynamicObjectCollection; foreach (DynamicObject dyObject in dyObjectCol) { long stockOrgId = Convert.ToInt64(((DynamicObject)dyObject["FDispatchOrgIdDetail"])["Id"]); long masterId = Convert.ToInt64(((DynamicObject)dyObject["MaterialId"])["msterID"]); long baseUnitId = Convert.ToInt64(((DynamicObjectCollection)((DynamicObject)dyObject["MaterialId"])["MaterialBase"])[0]["BaseUnitId_Id"]); long stockUnitId = Convert.ToInt64(((DynamicObjectCollection)((DynamicObject)dyObject["MaterialId"])["MaterialStock"])[0]["StoreUnitID_Id"]); double kfQty = XSXServiceHelper.XSXServiceHelper.GetKFQty(this.Context, stockOrgId, masterId, custId, baseUnitId, stockUnitId); double reqNum = Convert.ToDouble(dyObject["ReqQty"]); if (reqNum > kfQty) { string msg = string.Format("单据:{0},第{1}行申请数量:{2}超出库存可发量:{3},不允许进行订货", requestDynamic["BillNo"], dyObject["Seq"], reqNum, reqNum - kfQty); var errInfo = new ValidationErrorInfo( item.BillNo, item.DataEntity["Id"].ToString(), item.DataEntityIndex, item.RowIndex, "Valid019", msg, " ", Kingdee.BOS.Core.Validation.ErrorLevel.Error); validateContext.AddError(item.DataEntity, errInfo); continue; } } } //客户类别:区域:QY if (Convert.ToString(((DynamicObject)requestDynamic["FCUSTTYPE"])["Number"]).Equals(ConstantBaseData.QYMDNO) && Convert.ToInt64(((DynamicObject)requestDynamic["FYWTYPE"])["id"]) == ConstantBaseData.QYDHID) { string strSql = string.Format(@"/*dialect*/select a.FBILLNO, b.FSEQ from T_SCMS_ApplyGools a inner join T_SCMS_ApplyGoolsEntry b on a.FID = b.FID where a.FAPPLYCUST = {0} and b.FMRPCLOSESTATUS <> 'B' and a.FCUSTTYPE = {1} and a.FID <> {2} ", Convert.ToInt64(((DynamicObject)requestDynamic["FAPPLYCUST"])["Id"]), Convert.ToInt64(((DynamicObject)requestDynamic["FCUSTTYPE"])["Id"]), Convert.ToInt64(requestDynamic["Id"])); using (IDataReader reader = DBUtils.ExecuteReader(this.Context, strSql)) { while (reader.Read()) { string msg = string.Format("历史单据:{0},第{1}行业务没有关闭,不允许审核", reader["FBILLNO"], reader["FSEQ"]); var errInfo = new ValidationErrorInfo( item.BillNo, item.DataEntity["Id"].ToString(), item.DataEntityIndex, item.RowIndex, "Valid019", msg, " ", Kingdee.BOS.Core.Validation.ErrorLevel.Error); validateContext.AddError(item.DataEntity, errInfo); continue; } reader.Close(); } } //区域可订货余额校验 if (Convert.ToString(((DynamicObject)requestDynamic["FCUSTTYPE"])["Number"]).Equals(ConstantBaseData.QYMDNO) && Convert.ToInt64(((DynamicObject)requestDynamic["FYWTYPE"])["id"]) == ConstantBaseData.QYDHID) { double TotalAmount = Convert.ToDouble(requestDynamic["TotalAmount"]); double QYAmount = XSXServiceHelper.XSXServiceHelper.GetQYAmount(this.Context, Convert.ToString(((DynamicObject)requestDynamic["FApplyCust"])["Number"])); if (TotalAmount > QYAmount) { string msg = string.Format("单据:{0},订货金额:{1}超出可用额度:{2}", requestDynamic["BillNo"], TotalAmount, TotalAmount - QYAmount); var errInfo = new ValidationErrorInfo( item.BillNo, item.DataEntity["Id"].ToString(), item.DataEntityIndex, item.RowIndex, "Valid019", msg, " ", Kingdee.BOS.Core.Validation.ErrorLevel.Error); validateContext.AddError(item.DataEntity, errInfo); } } //有区域门店,无区域门店可订货余额检验 if ((Convert.ToString(((DynamicObject)requestDynamic["FCUSTTYPE"])["Number"]).Equals(ConstantBaseData.YQYMDNO) && Convert.ToInt64(((DynamicObject)requestDynamic["FYWTYPE"])["id"]) == ConstantBaseData.YQYMDDHID) || (Convert.ToString(((DynamicObject)requestDynamic["FCUSTTYPE"])["Number"]).Equals(ConstantBaseData.WQYMDNO) && Convert.ToInt64(((DynamicObject)requestDynamic["FYWTYPE"])["id"]) == ConstantBaseData.WQYMDDHID)) { double TotalAmount = Convert.ToDouble(requestDynamic["TotalAmount"]); double MDAmount = XSXServiceHelper.XSXServiceHelper.GetMDAmount(this.Context, Convert.ToString(((DynamicObject)requestDynamic["FApplyCust"])["Number"]), Convert.ToInt64(((DynamicObject)requestDynamic["FApplyCust"])["Id"])); if (TotalAmount > MDAmount) { string msg = string.Format("单据:{0},订货金额:{1}超出可用额度:{2}", requestDynamic["BillNo"], TotalAmount, TotalAmount - MDAmount); var errInfo = new ValidationErrorInfo( item.BillNo, item.DataEntity["Id"].ToString(), item.DataEntityIndex, item.RowIndex, "Valid019", msg, " ", Kingdee.BOS.Core.Validation.ErrorLevel.Error); validateContext.AddError(item.DataEntity, errInfo); } } if (Convert.ToInt64(((DynamicObject)requestDynamic["FYWTYPE"])["id"]) == ConstantBaseData.MDYJID && (Convert.ToString(((DynamicObject)requestDynamic["FCUSTTYPE"])["Number"]).Equals(ConstantBaseData.YQYMDNO) || Convert.ToString(((DynamicObject)requestDynamic["FCUSTTYPE"])["Number"]).Equals(ConstantBaseData.WQYMDNO))) { double TotalAmount = Convert.ToDouble(requestDynamic["TotalAmount"]); double YJAmount = XSXServiceHelper.XSXServiceHelper.GetYJAmount(this.Context, Convert.ToString(((DynamicObject)requestDynamic["FApplyCust"])["Number"]), Convert.ToInt64(((DynamicObject)requestDynamic["FApplyCust"])["Id"])); if (TotalAmount > YJAmount) { string msg = string.Format("单据:{0},订货金额:{1}超出营建可用额度:{2}", requestDynamic["BillNo"], TotalAmount, TotalAmount - YJAmount); var errInfo = new ValidationErrorInfo( item.BillNo, item.DataEntity["Id"].ToString(), item.DataEntityIndex, item.RowIndex, "Valid019", msg, " ", Kingdee.BOS.Core.Validation.ErrorLevel.Error); validateContext.AddError(item.DataEntity, errInfo); } } } }
public override void Validate(Kingdee.BOS.Core.ExtendedDataEntity[] dataEntities, ValidateContext validateContext, Kingdee.BOS.Context ctx) { foreach (var dataEntity in dataEntities) { string FID = dataEntity["Id"].ToString(); if (!ValidateDailyWeightSum(dataEntity)) { ValidationErrorInfo ValidationErrorInfo = new ValidationErrorInfo( string.Empty, FID, dataEntity.DataEntityIndex, dataEntity.RowIndex, FID, "汇报人日常工作的权重和必须等于100!", string.Empty); validateContext.AddError(null, ValidationErrorInfo); } /* * if (!ValidateRespWeightSum(dataEntity)) * { * ValidationErrorInfo ValidationErrorInfo = new ValidationErrorInfo( * string.Empty, * FID, * dataEntity.DataEntityIndex, * dataEntity.RowIndex, * FID, * "汇报人负责工作的权重和必须等于100!", * string.Empty); * validateContext.AddError(null, ValidationErrorInfo); * } */ //获取当前流程节点 //string procInstId = WorkflowChartServiceHelper.GetProcInstIdByBillInst(ctx, this.formId, FID); //List<ChartActivityInfo> routeCollection = WorkflowChartServiceHelper.GetProcessRouter(ctx, procInstId); //var WFNode = routeCollection[routeCollection.Count - 1]; //if (WFNode.ActivityId == Director_NodeID) //{ //} var entityL = dataEntity["FEntityL"] as DynamicObjectCollection; if (entityL.Count > 0) { // 上月计划表体存在时,发现有一行评分不为0时,则允许审核通过 var target = entityL .Where(item => item["FLSrcID"].ToString() != "0" && item["FLDirectorGrade"].ToString() != "0") .ToArray(); if (target.Length <= 0) { ValidationErrorInfo ValidationErrorInfo = new ValidationErrorInfo( string.Empty, FID, dataEntity.DataEntityIndex, dataEntity.RowIndex, FID, "请对汇报人上月工作进行评分!", string.Empty); validateContext.AddError(null, ValidationErrorInfo); } } if (!ValidatePreSum(dataEntity)) { ValidationErrorInfo ValidationErrorInfo = new ValidationErrorInfo( string.Empty, FID, dataEntity.DataEntityIndex, dataEntity.RowIndex, FID, "汇报人上月工作总评分不能超过105!", string.Empty); validateContext.AddError(null, ValidationErrorInfo); } } }
private void RecursivelyCheckPeriodTypeMismatch( Node currentNode, ref List<ValidationErrorInfo> secValidationErrors) { if (currentNode.IsProhibited) return; if (currentNode.children != null) { foreach (Node child in currentNode.children) { if (child.IsProhibited) continue; if (currentNode.PeriodType != child.PeriodType) { ValidationErrorInfo info = new ValidationErrorInfo( string.Format("Calculation relationship between '{0}' and '{1}' in report {2} is not allowed as their period types are not the same.", currentNode.Label, child.Label, child.GetPresentationLink().Title, currentNode.GetPresentationLink().Title), ValidationErrorInfo.ValidationCategoryType.SECValidationError, "Calculation Arc Error", ValidationErrorInfo.SequenceEnum.CALCULATION_PERIOD_ERROR); secValidationErrors.Add(info); } else { RecursivelyCheckPeriodTypeMismatch(child, ref secValidationErrors); } } } }
private void CheckRecursionInCalculation(PresentationLink link, Node current, ref List<ValidationErrorInfo> secValidationErrors) { if (current.IsProhibited) return; if (current.parent != null) { if (current.parent.GetParent(current.Id) != null) { ValidationErrorInfo info = new ValidationErrorInfo( string.Format("Report '{0}' has a recursive relationship for the element '{1}' in the calculation view.", link.Title, current.Label), ValidationErrorInfo.ValidationCategoryType.SECValidationError, "Calculation Error", ValidationErrorInfo.SequenceEnum.RECURSION_IN_CALCULATION); secValidationErrors.Add(info); } } if (current.children != null) { foreach (Node c in current.children) { CheckRecursionInCalculation(link, c, ref secValidationErrors); } } }
private void RecursivelyCheckPeriodTypeOnParentChild(Node parent, ref List<ValidationErrorInfo> secValidationErrors) { if (parent.IsProhibited) return; if (parent.children != null) { List<string> childIds = new List<string>(); foreach (Node child in parent.children) { if (child.IsProhibited) continue; if (childIds.Contains(child.Id)) { //we cannot have the same child twice for a single parent ValidationErrorInfo info = new ValidationErrorInfo( string.Format("In the Calculation view of the Report '{0}' Element '{1}' appears more than once as the child of the element '{2}'. Please remove all duplicate occurances of the same child element.", parent.GetPresentationLink().Title, child.Label, parent.Label), ValidationErrorInfo.ValidationCategoryType.SECValidationError, "Calculation Error", ValidationErrorInfo.SequenceEnum.DUPLICATE_IN_CALCULATION); secValidationErrors.Add(info); } else { childIds.Add(child.Id); } if (child.MyElement.PerType != parent.MyElement.PerType) { ValidationErrorInfo info = new ValidationErrorInfo( string.Format("In the Calculation view of the Report '{0}' period type of parent element '{1}' does not match the period type of child element '{2}'. Please correct this as the source and target of all calculation relationships must have the same period type.", parent.GetPresentationLink().Title, parent.Label, child.Label), ValidationErrorInfo.ValidationCategoryType.SECValidationError, "Calculation Error", ValidationErrorInfo.SequenceEnum.CALCULATION_PARENT_CHILD_PERIOD_TYPE_MISMATCH); secValidationErrors.Add(info); } else { RecursivelyCheckPeriodTypeOnParentChild(child, ref secValidationErrors); } } } }
private void PerformElementLabelValidations(ref List<ValidationErrorInfo> secValidationErrors, Dictionary<string, Element> elementsDt, Dictionary<string, bool> markedupElements, ArrayList presNodes, bool isMutualFundsTaxonomy ) { Dictionary<string, bool> elementsInPres = new Dictionary<string, bool>(); Dictionary<string, Element> stdLabelDt = new Dictionary<string, Element>(); List<string> allTopLevelPresentationElements = new List<string>(); //since the top level elements cannot have a pref label... //if two of the top level elements have the same label we need to show an error... foreach (Node tn in presNodes) { if (tn.children != null) { foreach (Node pn in tn.children) { if (!allTopLevelPresentationElements.Contains(pn.Id)) { allTopLevelPresentationElements.Add(pn.Id); } } } } //TODO: need to do just the elements in the presentation , calculation and definition files. foreach (Element ele in this.allElements.Values) { if (!elementsDt.ContainsKey(ele.Id)) continue; if (ele.LabelInfo == null) continue; bool checkStandardLabel = true; if (markedupElements.ContainsKey(ele.Id)) { if (ele.OrigElementType.EndsWith(":domainItemType")) { ValidationErrorInfo info = new ValidationErrorInfo( string.Format("The dimension element {0} is being used as a regualar fact, please use it only as a segment.", ele.Name), ValidationErrorInfo.ValidationCategoryType.SECValidationError, "Segment Element Error", ValidationErrorInfo.SequenceEnum.DIMENSION_AS_ELEMENT_ERROR); secValidationErrors.Add(info); } } if ( ele.TaxonomyInfoId == 0 && ele.OrigElementType.EndsWith(":domainItemType") ) { //for mutual funds we are going to change the label to terse label so //no need to check for stanard label problems... checkStandardLabel = false; } foreach (LabelDefinition ld in ele.LabelInfo.LabelDatas) { if (ld.LabelRole.Equals("documentation", StringComparison.CurrentCultureIgnoreCase)) { continue; //as we do not want to include the documentation } if (ld.LabelRole.Equals(LabelDefinition.DEPRECATED_LABEL_ROLE, StringComparison.CurrentCultureIgnoreCase)) { ValidationErrorInfo info = new ValidationErrorInfo( string.Format("The element {0} has been deprecated, please use a different element in the markup.", ele.Name), ValidationErrorInfo.ValidationCategoryType.SECValidationError, "Deprecated Element Error", ValidationErrorInfo.SequenceEnum.DECPRECATED_ELEMENT_USED_ERROR); secValidationErrors.Add(info); continue; //as we do not want to include the documentation } if (ld.LabelRole.Equals(LabelDefinition.DEPRECATEDDATE_LABEL_ROLE, StringComparison.CurrentCultureIgnoreCase)) { ValidationErrorInfo info = new ValidationErrorInfo( string.Format("The element {0} has been deprecated, please use a different element in the markup.", ele.Name), ValidationErrorInfo.ValidationCategoryType.SECValidationError, "Deprecated Element Error", ValidationErrorInfo.SequenceEnum.DECPRECATED_ELEMENT_USED_ERROR); secValidationErrors.Add(info); continue; //as we do not want to include the documentation } if (ld.Label.Length >= 511) { ValidationErrorInfo info = new ValidationErrorInfo( string.Format("The text of the label should be fewer than 511 characters. Please correct the label '{0}' for element '{1}'.", ld.Label, ele.Name), ValidationErrorInfo.ValidationCategoryType.SECValidationError, "Label Error", ValidationErrorInfo.SequenceEnum.MAX_LABEL_SIZE_ERROR); secValidationErrors.Add(info); } if (ld.Label.IndexOfAny(InvalidSECLabelCharaters.ToCharArray()) >= 0) { ValidationErrorInfo info = new ValidationErrorInfo( string.Format("The following special characters : '{2}' are not allowed in the text of a label. Please correct the label '{0}' for element '{1}'.", ld.Label, ele.Name, InvalidSECLabelCharaters), ValidationErrorInfo.ValidationCategoryType.SECValidationError, "Label Error", ValidationErrorInfo.SequenceEnum.INVALID_CHARACTER_IN_LABEL_ERROR); secValidationErrors.Add(info); } foreach (string str in invalidAsciiSequences) { if (ld.Label.Contains(str)) { ValidationErrorInfo info = new ValidationErrorInfo( string.Format("The following ASCII sequence is prohibited in the content of labels other than documentation labels: '{2}'. Please correct the label '{0}' for element '{1}'.", ld.Label, ele.Name, str), ValidationErrorInfo.ValidationCategoryType.SECValidationError, "Label Error", ValidationErrorInfo.SequenceEnum.INVALID_ASCII_SEQUENCE_IN_LABEL_ERROR); secValidationErrors.Add(info); } } if (ld.LabelRole == Node.LABELROLE) { if (checkStandardLabel) { if (ld.Language.Equals("en-us", StringComparison.CurrentCultureIgnoreCase) || ld.Language.Equals("en", StringComparison.CurrentCultureIgnoreCase)) { ld.Label = ld.Label.Trim(TRIMSET); ld.Label = multispaceRegEx.Replace(ld.Label, " ");//replace double space with a single space... string asciiLabel = TextUtilities.CovertValidUTF8ToAsciiInLabel(ld.Label.ToLower()); Element other; if (stdLabelDt.TryGetValue(asciiLabel, out other)) { ValidationErrorInfo info = new ValidationErrorInfo( string.Format("Multiple elements cannot have the same standard english label. Element '{0}' and element '{1}' have the same label '{2}'.", ele.Name, other.Name, ld.Label), ValidationErrorInfo.ValidationCategoryType.SECValidationError, "Label Error", ValidationErrorInfo.SequenceEnum.MULTIPLE_ELEMENT_SAME_STD_LABEL_ERROR); secValidationErrors.Add(info); } else { stdLabelDt[asciiLabel] = ele; } if (ele.TaxonomyInfoId == 0) { if (string.Compare(ele.Name, StringUtility.GetDefaultElementName(ld.Label)) != 0) { ValidationErrorInfo.ValidationCategoryType cType = ValidationErrorInfo.ValidationCategoryType.SECValidationWarning_LC3; if (ele.OrigElementType.EndsWith(":domainItemType")) { cType = ValidationErrorInfo.ValidationCategoryType.SECValidationWarning_LC3_Members; } ValidationErrorInfo info = new ValidationErrorInfo( string.Format("The name of an extended element '{0}' should consist of capitalized words corresponding to the standard english label, a convention called LC3. The standard label is '{1}' and its corresponding LC3 name is '{2}'.", ele.Name, ld.Label, StringUtility.GetDefaultElementName(ld.Label)), cType, "Element Name Warning", ValidationErrorInfo.SequenceEnum.LC3_WARNING); info.MyErrorType = ValidationErrorInfo.ErrorType.Warning; secValidationErrors.Add(info); } } } } } if (string.IsNullOrEmpty(ld.Label.Trim())) { ValidationErrorInfo info = new ValidationErrorInfo( string.Format("The text of the label is an emply string. Please correct the label with label role '{0}' for the for element '{1}'.", ld.LabelRole, ele.Name), ValidationErrorInfo.ValidationCategoryType.SECValidationError, "Label Error", ValidationErrorInfo.SequenceEnum.EMPTY_LABEL_ERROR); secValidationErrors.Add(info); } } } }
private void RecursivlyCheckForDuplicateMembers(string AxisId, ArrayList nodes, ref List<string> allDimMembers, ref List<string> allMembers, ref List<ValidationErrorInfo> secValidationErrors) { foreach (DimensionNode dn in nodes) { if (dn.IsProhibited) continue; if (allMembers.Contains(dn.Id)) { if (dn.Id.EndsWith("Domain")) { ValidationErrorInfo info = new ValidationErrorInfo( string.Format("Dimension Domain {0} exists in more than one location in Report {1}. This will result in undirected dimension cycles error.", dn.MyElement.Name, dn.MyDefinitionLink.Title), ValidationErrorInfo.ValidationCategoryType.SECValidationError, "Presentation Error", ValidationErrorInfo.SequenceEnum.DOMAIN_DUPLICATION_ERROR); secValidationErrors.Add(info); } else { ValidationErrorInfo info = new ValidationErrorInfo( string.Format("Dimension Member {0} exists in more than one location in Report {1}. This will result in undirected dimension cycles error.", dn.MyElement.Name, dn.MyDefinitionLink.Title), ValidationErrorInfo.ValidationCategoryType.SECValidationError, "Presentation Error", ValidationErrorInfo.SequenceEnum.MEMBER_DUPLICATION_ERROR); secValidationErrors.Add(info); } } else { allMembers.Add(dn.Id); } if (!dn.NodeDimensionInfo.IsDefault) { allDimMembers.Add(string.Format("{0}:{1}", AxisId, dn.Id)); } if (dn.children != null) { RecursivlyCheckForDuplicateMembers(AxisId, dn.children, ref allDimMembers, ref allMembers, ref secValidationErrors); } } }
private void PerformExtendedElementValidation(ref List<ValidationErrorInfo> secValidationErrors, Dictionary<string, bool> markedupElements, ArrayList presNodes, List<DimensionNode> dimNodes, Dictionary<string, Element> validelementsDt, List<string> excludedReports, bool isMutualFundTaxonomy) { if (this.IsAucentExtension) { Dictionary<string, bool> baseElementNames = new Dictionary<string, bool>(); Dictionary<string, bool> extendedElements = new Dictionary<string, bool>(); foreach (Element ele in this.allElements.Values) { if (ele.TaxonomyInfoId != 0) { baseElementNames[ele.Name] = true; } } foreach (Element ele in this.allElements.Values) { if (ele.TaxonomyInfoId == 0 && validelementsDt.ContainsKey(ele.Id)) { extendedElements[ele.Id] = true; if (baseElementNames.ContainsKey(ele.Name)) { ValidationErrorInfo info = new ValidationErrorInfo( string.Format("The name of an extended element cannot equal the name of a standard element. Element to change = '{0}'.", ele.Name), ValidationErrorInfo.ValidationCategoryType.SECValidationError, "Extension Error", ValidationErrorInfo.SequenceEnum.EXTENDED_ELEMENT_NAME_ERROR); secValidationErrors.Add(info); } if (ele.OrigsubstGroup.Equals(Element.DIMENSION_ITEM_TYPE)) { if (!ele.Name.EndsWith("Axis")) { ValidationErrorInfo info = new ValidationErrorInfo( string.Format("The name of an extended dimension element must end with 'Axis'. Element to change = '{0}'.", ele.Name), ValidationErrorInfo.ValidationCategoryType.SECValidationError, "Extension Error", ValidationErrorInfo.SequenceEnum.EXTENDED_DIMENSION_AXIS_NAME_ERROR1); secValidationErrors.Add(info); } } else { if (ele.Name.EndsWith("Axis", StringComparison.CurrentCultureIgnoreCase)) { ValidationErrorInfo info = new ValidationErrorInfo( string.Format("Only Dimension type elements can have names ending with 'Axis'. Element to change = '{0}'.", ele.Name), ValidationErrorInfo.ValidationCategoryType.SECValidationError, "Extension Error", ValidationErrorInfo.SequenceEnum.EXTENDED_DIMENSION_AXIS_NAME_ERROR2); secValidationErrors.Add(info); } } if (ele.OrigsubstGroup.Equals(Element.HYPERCUBE_ITEM_TYPE)) { if (!ele.Name.EndsWith("Table")) { ValidationErrorInfo info = new ValidationErrorInfo( string.Format("The name of an extended hypercube element must end with 'Table'. Element to change = '{0}'.", ele.Name), ValidationErrorInfo.ValidationCategoryType.SECValidationError, "Extension Error", ValidationErrorInfo.SequenceEnum.EXTENDED_TABLE_NAME_ERROR1); secValidationErrors.Add(info); } } else { if (ele.Name.EndsWith("Table", StringComparison.CurrentCultureIgnoreCase)) { ValidationErrorInfo info = new ValidationErrorInfo( string.Format("Only hypercube elements can have names ending with 'Table'. Element to change = '{0}'.", ele.Name), ValidationErrorInfo.ValidationCategoryType.SECValidationError, "Extension Error", ValidationErrorInfo.SequenceEnum.EXTENDED_TABLE_NAME_ERROR2); secValidationErrors.Add(info); } } if (ele.Name.EndsWith("LineItems", StringComparison.CurrentCultureIgnoreCase)) { if (!ele.IsAbstract) { ValidationErrorInfo info = new ValidationErrorInfo( string.Format("Only Abstract elements can have names ending with 'LineItems'. Element to change = '{0}'.", ele.Name), ValidationErrorInfo.ValidationCategoryType.SECValidationError, "Extension Error", ValidationErrorInfo.SequenceEnum.EXTENDED_LINE_ITEM_NAME_ERROR1); secValidationErrors.Add(info); } } if (ele.OrigElementType.EndsWith(":domainItemType")) { if (!ele.Name.EndsWith("Domain") && !ele.Name.EndsWith("Member")) { ValidationErrorInfo info = new ValidationErrorInfo( string.Format("Dimension member must have name that ends with either 'Domain' or 'Member'. Element to change = '{0}'.", ele.Name), ValidationErrorInfo.ValidationCategoryType.SECValidationError, "Extension Error", ValidationErrorInfo.SequenceEnum.EXTENDED_DIMENSION_MEMBER_NAME_ERROR1); secValidationErrors.Add(info); } } else { if (ele.Name.EndsWith("Domain", StringComparison.CurrentCultureIgnoreCase)) { ValidationErrorInfo info = new ValidationErrorInfo( string.Format("Only dimension members can have names ending with 'Domain'. Element to change = '{0}'.", ele.Name), ValidationErrorInfo.ValidationCategoryType.SECValidationError, "Extension Error", ValidationErrorInfo.SequenceEnum.EXTENDED_DIMENSION_MEMBER_NAME_ERROR2); secValidationErrors.Add(info); } else if (ele.Name.EndsWith("Member", StringComparison.CurrentCultureIgnoreCase)) { ValidationErrorInfo info = new ValidationErrorInfo( string.Format("Only dimension members can have names ending with 'Member'. Element to change = '{0}'.", ele.Name), ValidationErrorInfo.ValidationCategoryType.SECValidationError, "Extension Error", ValidationErrorInfo.SequenceEnum.EXTENDED_DIMENSION_MEMBER_NAME_ERROR3); secValidationErrors.Add(info); } } } } if (extendedElements.Count > 0) { List<Node> missing = GetInUseNodesMissingInPresentation(extendedElements, false, presNodes, excludedReports); foreach (Node n in missing) { if (isMutualFundTaxonomy) { //if it is a dimension member then it should be ok to miss it in presenation if (n.MyElement.OrigElementType.EndsWith(":domainItemType")) { continue; } } ValidationErrorInfo info = new ValidationErrorInfo( string.Format("Extended element '{0}' is missing in the Presentation view.", n.Label), ValidationErrorInfo.ValidationCategoryType.SECValidationError, "Presentation Error", ValidationErrorInfo.SequenceEnum.EXTENDED_ELEMENT_MISSING_IN_PRESENTATION_ERROR); secValidationErrors.Add(info); } } Dictionary<string, DimensionNode> extNodes = GetExtendedDimensionMembers(dimNodes); foreach (DimensionNode dn in extNodes.Values) { if (!validelementsDt.ContainsKey(dn.Id)) continue; if (dn.NodeDimensionInfo.NodeType == DimensionNode.NodeType.Item) { //member... if (!dn.MyElement.Name.EndsWith("Domain") && !dn.MyElement.Name.EndsWith("Member")) { ValidationErrorInfo info = new ValidationErrorInfo( string.Format("Dimension member must have name that ends with either 'Domain' or 'Member'. Element to change = '{0}'.", dn.MyElement.Name), ValidationErrorInfo.ValidationCategoryType.SECValidationError, "Extension Error", ValidationErrorInfo.SequenceEnum.EXTENDED_DIMENSION_MEMBER_NAME_ERROR1); secValidationErrors.Add(info); } if (!dn.MyElement.OrigElementType.EndsWith(":domainItemType")) { ValidationErrorInfo info = new ValidationErrorInfo( string.Format("Dimension member was created with an incorrect type. Please recreate the member '{0}' to fix this issue.", dn.MyElement.Name), ValidationErrorInfo.ValidationCategoryType.SECValidationError, "Extension Error", ValidationErrorInfo.SequenceEnum.EXTENDED_DIMENSION_MEMBER_TYPE_ERROR); secValidationErrors.Add(info); } } } } }
private void ValidateStructure(List<string> excludedReports, ArrayList pNodes, bool isMutualFundsTaxonomy, ref Dictionary<string, Node> reportLineItems, ref Dictionary<string, List<string>> reportDimensionInfos, ref List<ValidationErrorInfo> secValidationErrors) { List<string> mfSkippedReports = new List<string>(); if (isMutualFundsTaxonomy) { //the following base reports can be skipped for mutual fund taxonomies... mfSkippedReports.Add("http://xbrl.sec.gov/rr/role/Prospectus"); mfSkippedReports.Add("http://xbrl.sec.gov/rr/role/Class"); mfSkippedReports.Add("http://xbrl.sec.gov/rr/role/PerformanceMeasure"); mfSkippedReports.Add("http://xbrl.sec.gov/rr/role/Series"); } Dictionary<string, DimensionNode> axisDefaultInfo = new Dictionary<string, DimensionNode>(); foreach (Node root in pNodes) { if (excludedReports != null && excludedReports.Contains(root.GetPresentationLink().Role)) { //need to skip this report... continue; } if (isMutualFundsTaxonomy) { //the following base reports can be skipped... if (mfSkippedReports.Contains(root.GetPresentationLink().Role)) { //need to skip this report... continue; } } //1. Every report need to have the structure //Presentation //abstractParent //Table //Axis //Line Items //2. cannot have the same dimension member more than once in a report... Node absRoot = null; int countValid = 0; if (root.children != null) { foreach (Node abs in root.children) { if (abs.IsProhibited) continue; countValid++; if (abs.IsAbstract && !abs.MyElement.IsDimensionOrHyperCubeItem()) { absRoot = abs; } } } if (absRoot != null && countValid == 1) { Node tableNode = null; countValid = 0; if (absRoot.children != null) { foreach (Node tn in absRoot.children) { if (tn.IsProhibited) continue; countValid++; if (tn.MyElement.IsHyperCubeItem()) { tableNode = tn; } } } if (tableNode != null && countValid == 1 && tableNode.children != null) { ArrayList axises = new ArrayList(); Node lineItem = null; countValid = 0; foreach (Node tn in tableNode.children) { if (tn.IsProhibited) continue; if (tn.MyElement.IsDimensionItem()) { axises.Add(tn); } else { if (tn.IsHypercubeNodeInHierarchy()) { //we have another hypercube..nested in the presentation ValidationErrorInfo info = new ValidationErrorInfo( string.Format("Report {0} does not comply with the Rivet recommended Presentation structure. Found mulitple tables in the report.", root.GetPresentationLink().Title, tableNode.Name), ValidationErrorInfo.ValidationCategoryType.SECValidationError, "Presentation Error", ValidationErrorInfo.SequenceEnum.USGAAP_STRUCTURE_ERROR_TABLE); secValidationErrors.Add(info); } countValid++; if (tn.MyElement.Name.EndsWith("LineItems")) { lineItem = tn; } else if (isMutualFundsTaxonomy && tn.MyElement.IsAbstract) { lineItem = tn; } } } if (countValid == 1 && lineItem != null && axises.Count > 0) { List<string> allDimMembers = new List<string>(); foreach (DimensionNode dnAxis in axises) { if (dnAxis.IsProhibited || dnAxis.children == null) continue; //check to make sure we do not have the same member more than once in the dimension array //as it would result in non directed cycles...... List<string> allMembers = new List<string>(); RecursivlyCheckForDuplicateMembers(dnAxis.Id, dnAxis.children, ref allDimMembers, ref allMembers, ref secValidationErrors); //raise error if it has non default children foreach (DimensionNode cDN in dnAxis.children) { if (cDN.IsProhibited) continue; if (!cDN.NodeDimensionInfo.IsDefault) { ValidationErrorInfo info = new ValidationErrorInfo( string.Format("Report {0} does not comply with the Rivet recommended Presentation structure. The only child that an axis element should have is the default domain. Please move the non default children like {2} of axis {1} to be under the domain element.", root.GetPresentationLink().Title, dnAxis.Name, cDN.Name), ValidationErrorInfo.ValidationCategoryType.SECValidationError, "Presentation Error", ValidationErrorInfo.SequenceEnum.USGAAP_STRUCTURE_ERROR_AXIS); secValidationErrors.Add(info); } else { if (!cDN.MyElement.Name.EndsWith("domain", StringComparison.OrdinalIgnoreCase)) { ValidationErrorInfo info = new ValidationErrorInfo( string.Format("Report {0} does not comply with the Rivet recommended Presentation structure. The default {1} for the axis {2} does not end with the word Domain. Please use an Element that ends with Domain as the default member.", root.GetPresentationLink().Title, dnAxis.Id, cDN.Id), ValidationErrorInfo.ValidationCategoryType.SECValidationError, "Presentation Error", ValidationErrorInfo.SequenceEnum.USGAAP_STRUCTURE_ERROR_AXIS_DOMAIN_NOT_DEFAULT); secValidationErrors.Add(info); } DimensionNode defaultMem = null; if (!axisDefaultInfo.TryGetValue(dnAxis.Id, out defaultMem)) { axisDefaultInfo[dnAxis.Id] = cDN; } else { if (!defaultMem.Id.Equals(cDN.Id)) { ValidationErrorInfo info = new ValidationErrorInfo( string.Format("Axis {0} does not comply with Rivet recommended structure. Report {1} has Member {2} as the default and Report {3} has Member {4} as the default. Please ensure that the same member is used as the default for a given axis accross all reports. ", dnAxis.Label, root.GetPresentationLink().Title, cDN.Id, defaultMem.MyDefinitionLink.Title, defaultMem.Id), ValidationErrorInfo.ValidationCategoryType.SECValidationError, "Presentation Error", ValidationErrorInfo.SequenceEnum.USGAAP_STRUCTURE_ERROR_AXIS_MULTIPLE_DEFAULTS); secValidationErrors.Add(info); } } } } } reportLineItems[root.GetPresentationLink().Role] = lineItem; reportDimensionInfos[root.GetPresentationLink().Role] = allDimMembers; //need to make sure that the line item in pres is the same as the line item in definition file. DefinitionLink dl = this.netDefinisionInfo.DefinitionLinks[root.GetPresentationLink().Role] as DefinitionLink; if (dl.MeasureLocatorsHrefs == null || !dl.MeasureLocatorsHrefs.Contains(lineItem.Id)) { ValidationErrorInfo info = new ValidationErrorInfo( string.Format("Report {0} does not comply with the Rivet recommended Presentation structure. The hypercube line item does not match the presentation line item.", root.GetPresentationLink().Title), ValidationErrorInfo.ValidationCategoryType.SECValidationError, "Presentation Error", ValidationErrorInfo.SequenceEnum.USGAAP_STRUCTURE_LINEITEM_MISMATCH); secValidationErrors.Add(info); } if (dl.MeasureLocatorsHrefs.Count > 1) { List<string> uniqueMeasureRoots = new List<string>(); foreach (string mr in dl.MeasureLocatorsHrefs) { if (!uniqueMeasureRoots.Contains(mr)) { uniqueMeasureRoots.Add(mr); } } if (uniqueMeasureRoots.Count > 1) { ValidationErrorInfo info = new ValidationErrorInfo( string.Format("Report {0} does not comply with the Rivet recommended Presentation structure. Multiple hypercube line items found in the dimension linkbase.", root.GetPresentationLink().Title), ValidationErrorInfo.ValidationCategoryType.SECValidationError, "Presentation Error", ValidationErrorInfo.SequenceEnum.USGAAP_STRUCTURE_MULTIPLE_LINEITEM_MISMATCH); secValidationErrors.Add(info); } } } else { if (axises.Count == 0) { ValidationErrorInfo info = new ValidationErrorInfo( string.Format("Report {0} does not comply with the Rivet recommended Presentation structure. The Table element {1} should have atleast one Dimension child element.", root.GetPresentationLink().Title, tableNode.Name), ValidationErrorInfo.ValidationCategoryType.SECValidationError, "Presentation Error", ValidationErrorInfo.SequenceEnum.USGAAP_STRUCTURE_ERROR_DIMENSION); secValidationErrors.Add(info); } if (lineItem == null || countValid != 1) { ValidationErrorInfo info = new ValidationErrorInfo( string.Format("Report {0} does not comply with the Rivet recommended Presentation structure. The Table should have only dimension elements and a single line item element as its children.", root.GetPresentationLink().Title, tableNode.Name), ValidationErrorInfo.ValidationCategoryType.SECValidationError, "Presentation Error", ValidationErrorInfo.SequenceEnum.USGAAP_STRUCTURE_ERROR_LINE_ITEM); secValidationErrors.Add(info); } } } else { //error ValidationErrorInfo info = new ValidationErrorInfo( string.Format("Report {0} does not comply with the Rivet recommended Presentation structure. The root node should have a single Table element as its child element.", root.GetPresentationLink().Title), ValidationErrorInfo.ValidationCategoryType.SECValidationError, "Presentation Error", ValidationErrorInfo.SequenceEnum.USGAAP_STRUCTURE_ERROR_ROOT_NODE); secValidationErrors.Add(info); } } else { ValidationErrorInfo info = new ValidationErrorInfo( string.Format("Report {0} does not comply with the Rivet recommended Presentation structure. The report should have a single abstract (non table) element as the root node.", root.GetPresentationLink().Title), ValidationErrorInfo.ValidationCategoryType.SECValidationError, "Presentation Error", ValidationErrorInfo.SequenceEnum.USGAAP_STRUCTURE_ERROR_ROOT_NODE_ABSTRACT); secValidationErrors.Add(info); //validation error.... } } }
private void PerformTextBlockElementValidation(ArrayList presNodes, Dictionary<string, bool> markedupElements, ref List<ValidationErrorInfo> secValidationErrors) { foreach (Node n in presNodes) { if (n.children != null && n.children.Count > 0) { foreach (Node topLevelNode in n.children) { //we are interested only in non abstract elements that are in use... if (topLevelNode.IsAbstract || !markedupElements.ContainsKey(topLevelNode.MyElement.Id) || !topLevelNode.MyElement.IsTextBlock()) continue; //we have an extended element as a top level node in presentation... if (topLevelNode.MyElement.IsTextBlock()) { //we have a text block as the top level node.. //if this node is not a valid child node else where ... it is a bug... //based on the edgar manual bug... /* Edgar manual info.... A Text Block for each Footnote must appear in at least one presentation relationship in a base set. Each base set for a “Footnote as a Text Block” presentation link must contain one presentation relationship whose target is a Text Block. */ bool isValidChild = false; foreach (Node pn in presNodes) { if (isValidChild) break; if (pn.children != null && pn.children.Count > 0) { foreach (Node tpn in n.children) { if (RecursivelyCheckElementIfItIsaValidChild(tpn, topLevelNode.MyElement.Id)) { isValidChild = true; break; } } } } if (!isValidChild) { //error/// ValidationErrorInfo info = new ValidationErrorInfo( string.Format("In use text block element '{0}' needs to be a target of at least one presentation relationship. It is defined only as a top level element in the report {1}", topLevelNode.MyElement.Id, n.MyPresentationLink.Title), ValidationErrorInfo.ValidationCategoryType.SECValidationError, "Presentation Error", ValidationErrorInfo.SequenceEnum.TEXT_BLOCK_PRESENTATION_RELATION_ERROR); secValidationErrors.Add(info); } } } } } }
public void PerformSECDimensionValidation(List<MarkupProperty> validMarkups, Dictionary<string, Node> reportLineItems, Dictionary<string, List<string>> reportDimensionInfos, ref List<ValidationErrorInfo> secValidationErrors) { foreach (MarkupProperty mp in validMarkups) { if (mp.contextRef == null) continue; if (mp.contextRef.Segments != null && mp.contextRef.Segments.Count > 0) { List<string> eleDimMembers = new List<string>(); StringBuilder dimVals = new StringBuilder(); foreach (Segment seg in mp.contextRef.Segments) { if (seg.DimensionInfo == null) continue; string key = seg.DimensionInfo.ToString(); dimVals.Append(key + " "); eleDimMembers.Add(key); } if (eleDimMembers.Count == 0) continue; bool isValid = false; foreach (KeyValuePair<string, Node> kvp in reportLineItems) { if (isValid) break; List<string> dimInfos; if (!reportDimensionInfos.TryGetValue(kvp.Key, out dimInfos)) continue; if (kvp.Value.GetChild(mp.element.Id) != null) { //element exists in this report... bool isGood = true; foreach (string key in eleDimMembers) { if (!dimInfos.Contains(key)) { isGood = false; break; } } if (isGood) { //found a report that is valid.... isValid = true; break; } } } if (!isValid) { ValidationErrorInfo info = new ValidationErrorInfo( string.Format("Element {0} is using the following dimension(s){1}. At least one valid report should have the element as a decendant of the Line item and all the dimension members as the descendant of the Axis corresponding to the Line item.", mp.element.Name, dimVals.ToString()), ValidationErrorInfo.ValidationCategoryType.SECValidationError, "Dimension Error", ValidationErrorInfo.SequenceEnum.DIMENSION_VALIDATION); secValidationErrors.Add(info); } } } }
private void PerfromExtendedRolesValidation(ref List<ValidationErrorInfo> secValidationErrors) { List<RoleType> extendedRoles = this.GetListOfExtendedRoles(); Uri targetNameSpaceURI = new Uri(this.targetNamespace); foreach (RoleType rt in extendedRoles) { bool isValid = rt.Uri.Contains("/role/"); if (isValid) { Uri roleURI = new Uri(rt.Uri); isValid = targetNameSpaceURI.Authority.Equals(roleURI.Authority); } if (!isValid) { ValidationErrorInfo info = new ValidationErrorInfo( string.Format("URI '{0}' of Report '{1}' does not comply with the required format {2}. Please recreate the report.", rt.Uri, rt.Definition, "http://{Authority}/.../role/{mnemonic name in LC3 format}"), ValidationErrorInfo.ValidationCategoryType.SECValidationError, "Presentation Error", ValidationErrorInfo.SequenceEnum.REPORT_NAME_URI_ERROR); secValidationErrors.Add(info); } } }
public override void Validate(ExtendedDataEntity[] dataEntities, ValidateContext validateContext, Context ctx) { if ((dataEntities != null) && (dataEntities.Length > 0)) { foreach (ExtendedDataEntity entity in dataEntities) { DynamicObjectCollection objects = entity["BM_CTRLBILL"] as DynamicObjectCollection; bool flag = Convert.ToString(entity["CurrencyId"]) == "0"; int num = 0; foreach (DynamicObject obj2 in objects) { num++; string str = Convert.ToString(obj2["BillFormId_Id"]); if (!string.IsNullOrEmpty(str)) { FormMetadata formMetaData = this.GetFormMetaData(base.Context, str); List <Field> fieldList = formMetaData.BusinessInfo.GetFieldList(); string key = Convert.ToString(obj2["BillDateKey"]); string str3 = Convert.ToString(obj2["BillCurrencyKey"]); string str4 = Convert.ToString(obj2["BillOrgKey"]); string str5 = Convert.ToString(obj2["BillDeptKey"]); string str6 = Convert.ToString(obj2["CtrlTime"]); DynamicObject obj3 = obj2["BillFormId"] as DynamicObject; string str7 = Convert.ToString(obj3["Name"]); Field field = formMetaData.BusinessInfo.GetField(key); Field field2 = formMetaData.BusinessInfo.GetField(str3); Field field3 = formMetaData.BusinessInfo.GetField(str4); if (!flag && string.IsNullOrEmpty(str3)) { string message = string.Format(ResManager.LoadKDString("单据体“控制单据”第{0}行字段“单据币别”是必填项", "0032056000021901", SubSystemType.FIN, new object[0]), num); ValidationErrorInfo errorInfo = new ValidationErrorInfo(" ", Convert.ToString(obj2["ID"]), 0, 0, " ", message, ResManager.LoadKDString("单据币别字段", "0032056000021903", SubSystemType.FIN, new object[0]), ErrorLevel.FatalError); validateContext.AddError(null, errorInfo); } if ((field != null) && !this.IsHeadEntity(field.Entity)) { string str9 = string.Format(ResManager.LoadKDString("预算控制单据[{0}],控制日期字段[{1}]必须在单据头!", "0032056000020504", SubSystemType.FIN, new object[0]), str7, field.Name); ValidationErrorInfo info2 = new ValidationErrorInfo(field.Key, Convert.ToString(obj2["ID"]), 0, 0, " ", str9, " ", ErrorLevel.FatalError); validateContext.AddError(null, info2); } if ((field2 != null) && !this.IsHeadEntity(field2.Entity)) { string str10 = string.Format(ResManager.LoadKDString("预算控制单据[{0}],控制币别字段[{1}]必须在单据头!", "0032056000020505", SubSystemType.FIN, new object[0]), str7, field2.Name); ValidationErrorInfo info3 = new ValidationErrorInfo(field2.Key, Convert.ToString(obj2["ID"]), 0, 0, " ", str10, " ", ErrorLevel.FatalError); validateContext.AddError(null, info3); } switch (str6) { case "1": case "2": if ((field3 != null) && !this.IsHeadEntity(field3.Entity)) { string str11 = string.Format(ResManager.LoadKDString("预算控制单据[{0}],控制组织字段[{1}]必须在单据头!", "0032056000020499", SubSystemType.FIN, new object[0]), str7, field3.Name); ValidationErrorInfo info4 = new ValidationErrorInfo(field3.Key, Convert.ToString(obj2["ID"]), 0, 0, " ", str11, " ", ErrorLevel.FatalError); validateContext.AddError(null, info4); } if (!string.IsNullOrWhiteSpace(str5)) { Field field4 = formMetaData.BusinessInfo.GetField(str5); if ((field4 != null) && !this.IsHeadEntity(field4.Entity)) { string str12 = string.Format(ResManager.LoadKDString("预算控制单据[{0}],控制部门字段[{1}]必须在单据头!", "0032056000020501", SubSystemType.FIN, new object[0]), str7, field4.Name); ValidationErrorInfo info5 = new ValidationErrorInfo(field4.Key, Convert.ToString(obj2["ID"]), 0, 0, " ", str12, " ", ErrorLevel.FatalError); validateContext.AddError(null, info5); } } break; } DynamicObjectCollection objects2 = obj2["BM_CTRLBILLDIMENSION"] as DynamicObjectCollection; DynamicObjectCollection objects3 = obj2["BM_CTRLBILLDATA"] as DynamicObjectCollection; List <string> collection = (from p in objects2 select Convert.ToString(p["BillDimensionFieldKey"])).Distinct <string>().ToList <string>(); List <string> list3 = (from p in objects3 select Convert.ToString(p["BillDataFieldKey"])).Distinct <string>().ToList <string>(); List <string> source = new List <string>(); source.AddRange(collection); source.AddRange(list3); Dictionary <string, string> dictionary = source.Distinct <string>().ToDictionary <string, string>(p => p); Dictionary <string, Field> dictionary2 = new Dictionary <string, Field>(); foreach (Field field5 in fieldList) { if (dictionary.ContainsKey(field5.Key) && !this.IsHeadEntity(field5.Entity)) { if (dictionary2.Count == 0) { dictionary2.Add(field5.EntityKey, field5); } else { Field field6 = dictionary2.FirstOrDefault <KeyValuePair <string, Field> >().Value; if (string.Compare(field6.EntityKey, field5.EntityKey, true) != 0) { string str13 = string.Format(ResManager.LoadKDString("预算控制单据[{0}],字段[{1}]所属单据体[{2}]与字段[{3}]所属单据体[{4}]不一致,不允许保存!", "0032056000020503", SubSystemType.FIN, new object[0]), new object[] { str7, field5.Name, field5.Entity.Name, field6.Name, field6.Entity.Name }); ValidationErrorInfo info6 = new ValidationErrorInfo(field5.Key, Convert.ToString(obj2["ID"]), 0, 0, " ", str13, " ", ErrorLevel.FatalError); validateContext.AddError(null, info6); break; } } } } } } } } }
private void AddMsg(ValidateContext validateContext, ExtendedDataEntity entity, string displayToFieldKey, string msg) { ValidationErrorInfo errorInfo = new ValidationErrorInfo(displayToFieldKey, entity.DataEntity["Id"].ToString(), entity.DataEntityIndex, entity.RowIndex, "???", msg, Convert.ToString(entity.DataEntity["BillNo"]), ErrorLevel.Error); validateContext.AddError(entity.DataEntity, errorInfo); }