예제 #1
0
        // 提交
        private void _submit(object o)
        {
            string str = o as string;

            if (str == null)
            {
                return;
            }

            StringBuilder errorstr = new StringBuilder();

            _updateTBMain("\n\n--------------\n");

            int counts = 0, successcount = 0;

            string[] values = str.Split('\n');
            foreach (var v in values)
            {
                if (string.IsNullOrWhiteSpace(v))
                {
                    continue;
                }
                ++counts;
                OrderInfo order = new OrderInfo(v);
                if (order.IsAvailable)
                {
                    int    count   = mManager.SubmitResinOrder(order);
                    string showStr = _getSubmitFeedback(v, order, count, errorstr);
                    if (count > 0)
                    {
                        ++successcount;
                    }
                    _updateTBMain(showStr);
                }
                else
                {
                    _updateTBMain(v.TrimEnd() + "\t---\t数据无效\n");
                    errorstr.Append(v.TrimEnd()).Append("\t---\t数据无效\n");
                }
            }
            _updateTBMain($"--------------\n总计/成功/失败  {counts}/{successcount}/{counts - successcount}(条) nnns\n");
            _statusBarState("就绪", false);

            if (!string.IsNullOrWhiteSpace(errorstr.ToString()))
            {
                WarnWindow.ShowMessage(errorstr.ToString());
            }
        }
        private void _submit(object o)
        {
            string str = o as string;

            if (str == null)
            {
                return;
            }

            StringBuilder errorstr = new StringBuilder();
            TextBoxUpdate update   = new TextBoxUpdate(_textBoxUpdate);

            this.Dispatcher.Invoke(update, "\n\n--------------\n");
            int counts = 0, successcount = 0;
            var stocks = _getStocks(str);

            foreach (var v in stocks)
            {
                ++counts;
                if (v.IsAvailable)
                {
                    int    count   = m_manager.Submit(v);
                    string showStr = _getSubmitFeedback(v.OriginalString, v, count, errorstr);
                    if (count > 0)
                    {
                        ++successcount;
                    }
                    this.Dispatcher.Invoke(update, showStr);
                }
                else
                {
                    this.Dispatcher.Invoke(update, v.OriginalString + "\t---\t数据无效\n");
                    errorstr.Append(v.OriginalString).Append("\t---\t数据无效\n");
                }
            }
            this.Dispatcher.Invoke(update, $"--------------\n总计/成功/失败  {counts}/{successcount}/{counts - successcount}(条) nnns\n");

            _statusBarState("就绪", false);

            if (!string.IsNullOrWhiteSpace(errorstr.ToString()))
            {
                WarnWindow.ShowMessage(errorstr.ToString());
            }

            // 每次更新结束后检查是否需要备份数据库
            _checkBackup();
        }