Esempio n. 1
0
 public void MergeFrom(CellCommentManager comments)
 {
     foreach (CellComment each in comments)
     {
         CellComment origin = GetComment(each.RowIndex, each.ColumnIndex);
         origin.MergeFrom(each);
     }
 }
Esempio n. 2
0
        public CellCommentManager Validate(SheetHelper sheet)
        {
            //int t1 = Environment.TickCount;
            _valid_factory.UpdateUnique = new UpdateUniqueRowValidator(_context, sheet);

            XmlElement xmlRule = _context.DataSource.GetValidateFieldRule();

            _validator.InitFromXMLNode(xmlRule);

            //Console.WriteLine("初始化 Validator時間:{0}", Environment.TickCount - t1);

            _validator.ErrorCaptured += new DocumentValidate.ErrorCapturedEventHandler(validator_ErrorCaptured);
            _validator.AutoCorrect   += new DocumentValidate.AutoCorrectEventHandler(validator_AutoCorrect);

            _sheetSource = new SheetRowSource(sheet, _context);
            int progress = 0, firstRow = sheet.FirstDataRowIndex, maxRow = sheet.MaxDataRowIndex;

            for (int rowIndex = firstRow; rowIndex <= maxRow; rowIndex++)
            {
                _sheetSource.BindRow(rowIndex);
                _validator.ValidateRow(_sheetSource);

                Application.DoEvents();

                //回報進度。
                if (((++progress) % ProgressStep) == 0)
                {
                    if (ProgressChanged != null)
                    {
                        int percentage = progress * 100 / (maxRow - firstRow);
                        ProgressUserState userState = new ProgressUserState();
                        ProgressChanged(this, new ProgressChangedEventArgs(percentage, userState));

                        if (userState.Cancel)
                        {
                            return(_comments);
                        }
                    }
                }
            }
            ProgressChanged(this, new ProgressChangedEventArgs(100, new ProgressUserState()));

            _validator.ErrorCaptured -= new DocumentValidate.ErrorCapturedEventHandler(validator_ErrorCaptured);
            _validator.AutoCorrect   -= new DocumentValidate.AutoCorrectEventHandler(validator_AutoCorrect);

            if (_context.CurrentMode == ImportMode.Update)
            {
                CellCommentManager comments = _valid_factory.UpdateUnique.CheckUpdateResult();
                _comments.MergeFrom(comments);
            }

            //foreach (CellComment each in _comments)
            //    Console.WriteLine(string.Format("{0}:{1} {2} Msg:{3}",
            //        each.RowIndex, each.ColumnIndex, each.BestComment, each.BestComment.Comment));

            return(_comments);
        }
Esempio n. 3
0
        public ValidateHelper(WizardContext context, IValidatorFactory factory)
        {
            _context       = context;
            _validator     = new DocumentValidate();
            _valid_factory = new CommentValidatorFactory(context);
            _comments      = new CellCommentManager();

            if (factory != null)
            {
                _validator.FieldValidatorList.AddValidatorFactory(factory);
                _validator.RowValidatorList.AddValidatorFactory(factory);
            }

            _validator.FieldValidatorList.AddValidatorFactory(_valid_factory);
            _validator.RowValidatorList.AddValidatorFactory(_valid_factory);
        }
Esempio n. 4
0
        public CellCommentManager Validate(SheetHelper sheet)
        {
            //int t1 = Environment.TickCount;
            _valid_factory.UpdateUnique = new UpdateUniqueRowValidator(_context, sheet);

            // 2018/4/17 穎驊註解,因應客服#5944 反應,檢查匯入班級機制,發現其驗證規則為抓取Severice 回傳的xml
            // 經過與恩正、均泰、耀明的討論後,決定將舊的程式碼註解,將其設定存在程式碼中(JH_C_ImportValidatorRule),直接抓取使用,方便日後維護。
            //XmlElement xmlRule = _context.DataSource.GetValidateFieldRule();

            //2018/12/21 穎驊 完成高雄項目 [10-03][??] 局端夠查詢學校班級有調整”導師”的功能
            // 有載入高雄自動編班模組的 , 其匯入規則 載Local 的設定KH版本(班級名稱、班導師 不得空白)
            XmlElement xmlRule;

            IClassBaseInfoItemAPI item = FISCA.InteractionService.DiscoverAPI <IClassBaseInfoItemAPI>();

            if (item != null)
            {
                //讀取XML欄位描述
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(Properties.Resources.JH_C_ImportValidatorRule_KH);
                xmlRule = doc.DocumentElement;
            }
            else
            {
                //讀取XML欄位描述
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(Properties.Resources.JH_C_ImportValidatorRule);
                xmlRule = doc.DocumentElement;
            };

            _validator.InitFromXMLNode(xmlRule);

            //Console.WriteLine("初始化 Validator時間:{0}", Environment.TickCount - t1);

            _validator.ErrorCaptured += new DocumentValidate.ErrorCapturedEventHandler(validator_ErrorCaptured);
            _validator.AutoCorrect   += new DocumentValidate.AutoCorrectEventHandler(validator_AutoCorrect);

            _sheetSource = new SheetRowSource(sheet, _context);
            int progress = 0, firstRow = sheet.FirstDataRowIndex, maxRow = sheet.MaxDataRowIndex;

            for (int rowIndex = firstRow; rowIndex <= maxRow; rowIndex++)
            {
                _sheetSource.BindRow(rowIndex);
                _validator.ValidateRow(_sheetSource);

                Application.DoEvents();

                //回報進度。
                if (((++progress) % ProgressStep) == 0)
                {
                    if (ProgressChanged != null)
                    {
                        int percentage = progress * 100 / (maxRow - firstRow);
                        ProgressUserState userState = new ProgressUserState();
                        ProgressChanged(this, new ProgressChangedEventArgs(percentage, userState));

                        if (userState.Cancel)
                        {
                            return(_comments);
                        }
                    }
                }
            }
            ProgressChanged(this, new ProgressChangedEventArgs(100, new ProgressUserState()));

            _validator.ErrorCaptured -= new DocumentValidate.ErrorCapturedEventHandler(validator_ErrorCaptured);
            _validator.AutoCorrect   -= new DocumentValidate.AutoCorrectEventHandler(validator_AutoCorrect);

            if (_context.CurrentMode == ImportMode.Update)
            {
                CellCommentManager comments = _valid_factory.UpdateUnique.CheckUpdateResult();
                _comments.MergeFrom(comments);
            }

            //foreach (CellComment each in _comments)
            //    Console.WriteLine(string.Format("{0}:{1} {2} Msg:{3}",
            //        each.RowIndex, each.ColumnIndex, each.BestComment, each.BestComment.Comment));

            return(_comments);
        }