/* ============================================================================== * 功能描述:数据检查的检查项 * 创 建 者: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 { /// /// CheckBase /// public class DataCheckBase: ICheckBase { public string Name { get; set; } public CheckContext Context { get; set; } private List results = new List(); internal List 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 检查结果 /// /// 是否通过较验 /// public bool IsRight { get; set; } /// /// 提示信息 /// public string RMessage { get; set; } /// /// 设置表可见性 /// 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; } /// /// 保存并隐藏全部通过的sheet /// public void Export2() { DCRExport.SetTemplatePath(Context.TemplatePath); Export(); SetSheetVisible(); } #endregion #region 样式控制 /// /// 是否强制勾选 /// public bool RIsReadOnly { get; set; } /// /// 是否选中 /// public bool RIsChecked { get; set; } private List m_SpecificationSheet=new List(); /// /// 关联规范项 /// public List RSPecificationSheet { get { return m_SpecificationSheet; } set { m_SpecificationSheet = value; } } #endregion } }