예제 #1
0
        private void InventoryForm_Load(object sender, EventArgs e)
        {
            InitView();

            Thread thread = new Thread(new ThreadStart(() =>
            {
                ShowLoading("正在连接PLC...");
                if (ConnectPlc())
                {
                    Invoke(new Action(() => { lblPlc.Text = "正常"; lblPlc.ForeColor = Color.Black; }));
                }
                else
                {
                    Invoke(new Action(() => { lblPlc.Text = "异常"; lblPlc.ForeColor = Color.OrangeRed; }));
                }
                ShowLoading("正在连接条码扫描枪...");
                ConnectBarcode();
                ShowLoading("正在连接读写器...");
                if (ConnectReader())
                {
                    Invoke(new Action(() => { lblReader.Text = "正常"; lblReader.ForeColor = Color.Black; }));
                }
                else
                {
                    Invoke(new Action(() =>
                    {
                        lblReader.Text = "异常"; lblReader.ForeColor = Color.OrangeRed;
                    }));
                }

                bool closed = false;

                ShowLoading("正在下载包材信息...");
                string def = "";
                DataTable boxStyleTable = SAPDataService.GetPackagingMaterialsList(SysConfig.LGNUM, SysConfig.DeviceInfo.LOUCENG, out def);

                if (boxStyleTable != null && boxStyleTable.Rows.Count > 0)
                {
                    this.Invoke(new Action(() =>
                    {
                        cboPxmat.DataSource    = boxStyleTable;
                        cboPxmat.ValueMember   = "PMAT_MATNR";
                        cboPxmat.DisplayMember = "MAKTX";
                    }));
                }
                else
                {
                    this.Invoke(new Action(() =>
                    {
                        HideLoading();
                        MetroMessageBox.Show(this, "未下载到包材数据,请检查网络情况", "提示");
                        closed = true;
                        Close();
                    }));
                }

                if (closed)
                {
                    return;
                }

                ShowLoading("正在更新SAP最新物料数据...");
                //materialList = SAPDataService.GetMaterialInfoList(SysConfig.LGNUM);
                materialList = LocalDataService.GetMaterialInfoList();

                if (materialList == null || materialList.Count <= 0)
                {
                    this.Invoke(new Action(() =>
                    {
                        HideLoading();
                        MetroMessageBox.Show(this, "未下载到物料主数据,请检查网络情况", "提示");
                        closed = true;
                        Close();
                    }));
                }
                if (closed)
                {
                    return;
                }

                hlaTagList = LocalDataService.GetAllRfidHlaTagList();
                if (hlaTagList == null || hlaTagList.Count <= 0)
                {
                    this.Invoke(new Action(() =>
                    {
                        HideLoading();
                        MetroMessageBox.Show(this, "未下载到吊牌主数据,请检查网络情况", "提示");
                        closed = true;
                        Close();
                    }));
                }
                if (closed)
                {
                    return;
                }

                ShowLoading("正在获取历史箱记录...");
                mBoxList = YKBoxService.GetUnHandoverBoxList(SysConfig.DeviceNO);
                if (mBoxList != null && mBoxList.Count > 0)
                {
                    bool first = true;
                    foreach (YKBoxInfo item in mBoxList)
                    {
                        Invoke(new Action(() =>
                        {
                            if (first)
                            {
                                cboSource.Text = item.Source;
                                cboTarget.Text = item.Target;
                            }
                            AddGrid(item);
                        }));
                    }
                }

                HideLoading();
            }));

            thread.IsBackground = true;
            thread.Start();
        }
예제 #2
0
        private void InventoryForm_Load(object sender, EventArgs e)
        {
#if DEBUG
            panelDebug.Show();
#endif
            InitView();
            dmButtonStart.Enabled = false;
            dmButtonStop.Enabled  = false;
            thread = new Thread(new ThreadStart(() => {
                ShowLoading("正在连接PLC...");
                if (ConnectPlc())
                {
                    Invoke(new Action(() => { lblPlc.Text = "正常"; lblPlc.ForeColor = Color.Black; }));
                }
                else
                {
                    Invoke(new Action(() => { lblPlc.Text = "异常"; lblPlc.ForeColor = Color.OrangeRed; }));
                }
                ShowLoading("正在连接条码扫描枪...");
                ConnectBarcode();
                ShowLoading("正在连接读写器...");
                if (ConnectReader())
                {
                    Invoke(new Action(() => { lblReader.Text = "正常"; lblReader.ForeColor = Color.Black; }));
                }
                else
                {
                    Invoke(new Action(() => {
                        lblReader.Text = "异常"; lblReader.ForeColor = Color.OrangeRed;
                    }));
                }

                mControlFlag = SysConfig.DeviceInfo != null ? SysConfig.DeviceInfo?.AuthList?.FindAll(i => i.AUTH_CODE.StartsWith("B")) : null;


                bool closed = false;

                ShowLoading("正在下载包材信息...");
                BoxStyleTable = SAPDataService.GetPackagingMaterialsList(SysConfig.LGNUM, SysConfig.DeviceInfo.LOUCENG, out res);

                if (BoxStyleTable != null)
                {
                    cboPxmat.DataSource    = BoxStyleTable;
                    cboPxmat.ValueMember   = "PMAT_MATNR";
                    cboPxmat.DisplayMember = "MAKTX";

                    if (BoxStyleTable.Rows.Count <= 0)
                    {
                        this.Invoke(new Action(() =>
                        {
                            HideLoading();
                            MetroMessageBox.Show(this, "未下载到包材数据,请检查网络情况", "提示");
                            closed = true;
                            Close();
                        }));
                    }
                }
                else
                {
                    this.Invoke(new Action(() =>
                    {
                        HideLoading();
                        MetroMessageBox.Show(this, "未下载到包材数据,请检查网络情况", "提示");
                        closed = true;
                        Close();
                    }));
                }

                if (closed)
                {
                    return;
                }

                ShowLoading("正在更新SAP最新物料数据...");
                materialList = SAPDataService.GetMaterialInfoList(SysConfig.LGNUM);
                //materialList = LocalDataService.GetMaterialInfoList();

                if (materialList == null || materialList.Count <= 0)
                {
                    this.Invoke(new Action(() =>
                    {
                        HideLoading();
                        MetroMessageBox.Show(this, "未下载到物料主数据,请检查网络情况", "提示");
                        closed = true;
                        Close();
                    }));
                }
                if (closed)
                {
                    return;
                }

                hlaTagList = LocalDataService.GetAllRfidHlaTagList();
                if (hlaTagList == null || hlaTagList.Count <= 0)
                {
                    this.Invoke(new Action(() =>
                    {
                        HideLoading();
                        MetroMessageBox.Show(this, "未下载到吊牌主数据,请检查网络情况", "提示");
                        closed = true;
                        Close();
                    }));
                }

                if (closed)
                {
                    return;
                }


                ShowLoading("正在检查是否存在未交接的历史箱记录...");
                boxList = YKBoxService.GetUnHandoverBoxList(SysConfig.DeviceNO);
                if (boxList != null && boxList.Count > 0)
                {
                    bool first = true;
                    foreach (YKBoxInfo item in boxList)
                    {
                        Invoke(new Action(() => {
                            if (first)
                            {
                                cboSource.Text = item.Source;
                                cboTarget.Text = item.Target;
                                Start();
                            }
                            AddGrid(item);
                        }));
                    }
                }
                UploadServer.GetInstance().OnUploaded += UploadServer_OnUploaded;
                UploadServer.GetInstance().Start();
                Invoke(new Action(() => {
                    dmButtonStart.Enabled = true;
                    UpdateTotalInfo();
                    UpdateErrorBoxButton();
                }));
                HideLoading();
            }));
            thread.IsBackground = true;
            thread.Start();
        }