123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- /* ==============================================================================
- * 功能描述:数据检查的检查项
- * 创 建 者:Garrett
- * 创建日期:2018/10/23 15:50:19
- * ==============================================================================*/
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using NPOI.SS.UserModel;
- using SAGA.DotNetUtils.Others;
- using SAGA.MBI.ToolsData.CheckBase;
- using SAGA.MBI.ToolsData.ModeCheck;
- namespace SAGA.MBI.ToolsData.DataCheck
- {
- /// <summary>
- /// CheckBase
- /// </summary>
- public class DataCheckBase: ICheckBase
- {
- public string Name { get; set; }
- public CheckContext Context { get; set; }
- private List<DataCheckResultBase> results = new List<DataCheckResultBase>();
- internal List<DataCheckResultBase> Results { get => results; set => results = value; }
- public void Check2(CheckContext context)
- {
- Context = context;
- if (!RIsChecked) return;
- Check();
- }
- public virtual bool Check()
- {
- throw new NotImplementedException();
- }
- public virtual void Correct()
- {
- throw new NotImplementedException();
- }
- public virtual void Export()
- {
- throw new NotImplementedException();
- }
- #region 检查结果
-
- /// <summary>
- /// 是否通过较验
- /// </summary>
- public bool IsRight { get; set; }
- /// <summary>
- /// 提示信息
- /// </summary>
- public string RMessage { get; set; }
- /// <summary>
- /// 设置表可见性
- /// </summary>
- public bool SetSheetVisible()
- {
- bool result = RIsChecked;
-
- if (result)
- result = !(results.All(t => t.IsRight));
- //如果有没有通过的项
- if (!result)
- {
- try
- {
- IWorkbook book = DCRExport.GetWorkbook();
- int index = book.GetSheetIndex(Name);
- //隐藏
- book.SetSheetHidden(index, SheetState.VeryHidden);
- //关联项隐藏
- foreach (var str in RSPecificationSheet) {
- int i = book.GetSheetIndex(str);
- //隐藏
- book.SetSheetHidden(i, SheetState.VeryHidden);
- }
- }
- catch (Exception e)
- {
- MessageShowBase.Show(e);
- }
- }
- return result;
- }
- /// <summary>
- /// 保存并隐藏全部通过的sheet
- /// </summary>
- public void Export2()
- {
- DCRExport.SetTemplatePath(Context.TemplatePath);
- Export();
- SetSheetVisible();
- }
- #endregion
- #region 样式控制
- /// <summary>
- /// 是否强制勾选
- /// </summary>
- public bool RIsReadOnly { get; set; }
- /// <summary>
- /// 是否选中
- /// </summary>
- public bool RIsChecked { get; set; }
- private List<string> m_SpecificationSheet=new List<string>();
- /// <summary>
- /// 关联规范项
- /// </summary>
- public List<string> RSPecificationSheet
- {
- get { return m_SpecificationSheet; }
- set { m_SpecificationSheet = value; }
- }
- #endregion
- }
- }
|