private bool FormatModel(string entityContent, BusinessDataSetting setting, out ScanModel model)
        {
            model = new ScanModel();
            List <string> dataList        = entityContent.Split(new string[] { setting.FileSpilit }, StringSplitOptions.None).ToList();
            List <string> titleColumnList = setting.TitleColumn.Split(new string[] { setting.FileSpilit }, StringSplitOptions.None).ToList();

            if (string.IsNullOrEmpty(string.Join("", dataList).Trim()) == false)
            {
                if (dataList.Count < titleColumnList.Count)
                {
                    throw new Exception("导入文件格式出错");
                }
                model.DeviceId        = dataList[0];
                model.ModelNumber     = dataList[1];
                model.HardwareVersion = dataList[2];
                model.QRCodeFormat    = dataList[3];
                model.EncryptedQRCode = dataList[4];
                if (titleColumnList.Contains("ScanTime"))
                {
                    model.ScanTime = dataList[5];
                    model.Barcode  = dataList[6];
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
        private bool CheckDeviceId(string barcode, out string message, out SoundType soundType)
        {
            #region 是否匹配规则
            string ruleType = "";

            string originalBarcode = barcode;

            //截取条码
            //string CheckData = barcode.Replace("-", "");
            //if(CheckData.Length>=2)
            //{
            //    CheckData = CheckData.Substring(2);
            //}

            if (string.IsNullOrEmpty(originalBarcode) == true)
            {
                message   = "条码不能为空";
                soundType = SoundType.NoData;
                return(false);
            }
            #endregion

            #region whether dumplicated
            //先判断逻辑
            //1.条码不能是已扫
            ScanModel product = POMACList.FirstOrDefault(c => c.DeviceId == originalBarcode);
            if (product != null && string.IsNullOrEmpty(product.ScanTime) == false)
            {
                message   = "条码已扫描, 时间:" + product.ScanTime;
                soundType = SoundType.SameData;
                return(false);
            }
            else if (product == null)
            {
                message   = "找不到条码";
                soundType = SoundType.BarcodeNotSuccess;
                return(false);
            }
            #endregion

            product.Barcode  = originalBarcode;
            CurrentScanModel = product;
            message          = "";
            soundType        = SoundType.Succeed;
            return(true);
        }
        private void RefreshDataGrid(ScanModel scanEntity = null)
        {
            BindingSource bs = this.dataGridView.DataSource as BindingSource;

            bs.DataSource = null;
            bs.DataSource = ViewPOMACList;
            bs.ResetBindings(true);
            string[] displayColumns = DisplayColumnNameList.ToArray();
            foreach (DataGridViewColumn item in dataGridView.Columns)
            {
                item.Visible = displayColumns.Contains(item.Name);
                if (item.Visible == true)
                {
                    item.DisplayIndex = DisplayColumnNameList.IndexOf(item.Name);
                }
                item.Width = 280;
            }
            //dataGridView.Columns["SN"].Width = 300;
            //dataGridView.Columns["MAC"].Width = 300;
            this.dataGridView.ClearSelection();

            if (scanEntity != null)
            {
                int pIndex = ViewPOMACList.IndexOf(scanEntity);
                if (pIndex >= 0)
                {
                    this.dataGridView.Rows[pIndex].Selected           = true;
                    this.dataGridView.FirstDisplayedScrollingRowIndex = pIndex;
                }
            }
            else if (this.ViewPOMACList.Count > 0)
            {
                this.dataGridView.Rows[this.ViewPOMACList.Count - 1].Selected = true;
                this.dataGridView.FirstDisplayedScrollingRowIndex             = this.ViewPOMACList.Count - 1;
            }
        }