Esempio n. 1
0
        private void InventoryForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (UploadServer.GetInstance().CheckUndoTask())
            {
                if (MetroMessageBox.Show(this, "当前有未上传的队列数据,是否确认现在退出?\r\n【注意】退出可能导致数据丢失,请谨慎操作", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.No)
                {
                    e.Cancel = true;
                }
            }
            timer.Stop();
            if (this.logicThread != null)
            {
                this.logicThread.Abort();
            }
            if (this.threadRightView != null)
            {
                this.threadRightView.Abort();
            }
            if (this.threadLoad != null)
            {
                this.threadLoad.Abort();
            }

            CloseWindow();
        }
Esempio n. 2
0
 private void timer1_Tick(object sender, EventArgs e)
 {
     Invoke(new Action(() => {
         int count         = UploadServer.GetInstance().CurrentUploadQueue.Count;
         uploadButton.Text = string.Format("上传列表({0})", count);
     }));
 }
Esempio n. 3
0
 private void Timer_Tick(object sender, EventArgs e)
 {
     this.Invoke(new Action(() =>
     {
         this.lblUploadQueue.Text = UploadServer.GetInstance().CurrentUploadQueue.Count.ToString();
     }));
 }
Esempio n. 4
0
 /// <summary>
 /// 将所有需要异步上传的数据都加入此队列
 /// </summary>
 /// <param name="obj"></param>
 private bool EnqueueUploadData(object obj)
 {
     if (UploadServer.GetInstance().CurrentUploadQueue.Count > 199)
     {
         MetroMessageBox.Show(this, "装箱数据上传队列已满,请检查网络环境,以确保数据能正常上传", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         return(false);
     }
     if (obj.GetType() == typeof(EbBoxErrorRecordInfo))
     {
         if (Cache.Instance[CacheKey.ERROR_RECORD] != null)
         {
             (Cache.Instance[CacheKey.ERROR_RECORD] as List <EbBoxErrorRecordInfo>).Add(obj as EbBoxErrorRecordInfo);
         }
     }
     else if (obj.GetType() == typeof(EbBoxCheckRecordInfo))
     {
         if (Cache.Instance[CacheKey.CHECK_RECORD] != null)
         {
             (Cache.Instance[CacheKey.CHECK_RECORD] as List <EbBoxCheckRecordInfo>).Add(obj as EbBoxCheckRecordInfo);
         }
         AddCheckRecord(obj as EbBoxCheckRecordInfo);
     }
     else if (obj.GetType() == typeof(UploadEbBoxInfo))
     {
         SqliteDataService.InsertUploadData(obj as UploadEbBoxInfo);
     }
     UploadServer.GetInstance().CurrentUploadQueue.Push(obj);
     return(true);
 }
Esempio n. 5
0
        private void grid_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            switch (e.ColumnIndex)
            {
            case 3:
                //重新上传
                if (!UploadServer.GetInstance().CurrentUploadQueue.Contains(grid.Rows[e.RowIndex].Tag as UploadOutLogDataInfo))
                {
                    UploadServer.GetInstance().CurrentUploadQueue.Push(grid.Rows[e.RowIndex].Tag as UploadOutLogDataInfo);
                    MetroMessageBox.Show(this, "成功加入上传队列", "提示");
                }
                else
                {
                    MetroMessageBox.Show(this, "该下架单已在上传队列中,请耐心等候", "提示");
                }
                break;

            case 4:
                //打开
                if (OnOutLogOpen == null)
                {
                    return;
                }
                else
                {
                    OnOutLogOpen((grid.Rows[e.RowIndex].Tag as UploadOutLogDataInfo).UploadData.PickTask);
                    this.Close();
                }
                break;

            case 5:
                //删除
                if (MetroMessageBox.Show(this, "确认删除?", "提示", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK)
                {
                    //检查该下架单在服务器上是否已经下架
                    List <InventoryOutLogDetailInfo> list = SAPDataService.GetHLAShelvesSingleTask(SysConfig.LGNUM, (grid.Rows[e.RowIndex].Tag as UploadOutLogDataInfo).UploadData.PickTask);

                    if (list != null && list.Count > 0)
                    {
                        if (list[0].IsOut != 1)
                        {
                            //已下架,允许删除
                            MetroMessageBox.Show(this, "该下架单未下架,不允许删除!", "提示"
                                                 , MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            return;
                        }
                    }
                    if (LocalDataService.DeleteUploaded((grid.Rows[e.RowIndex].Tag as UploadOutLogDataInfo).Guid))
                    {
                        grid.Rows.RemoveAt(e.RowIndex);
                    }
                    else
                    {
                        MetroMessageBox.Show(this, "删除失败", "提示");
                    }
                }
                break;
            }
        }
Esempio n. 6
0
        private void EnqueueUploadData(UploadBoxInfo data)
        {
            SqliteUploadDataInfo ud = new SqliteUploadDataInfo();

            ud.Guid       = Guid.NewGuid().ToString();
            ud.Data       = data;
            ud.IsUpload   = 0;
            ud.CreateTime = DateTime.Now;
            PackingBoxSqliteService.InsertUploadData(ud);
            UploadServer.GetInstance().CurrentUploadQueue.Push(ud);
        }
Esempio n. 7
0
        private void InventoryForm_Load(object sender, EventArgs e)
        {
            WindowState = FormWindowState.Maximized;

            lblUser.Text     = SysConfig.CurrentLoginUser != null ? SysConfig.CurrentLoginUser.UserId : "用户异常";
            lblDeviceNo.Text = SysConfig.DeviceInfo != null ? SysConfig.DeviceInfo.EQUIP_HLA : "设备异常";
            dtShip.Value     = DateTime.Now;
            threadLoad       = new Thread(new ThreadStart(() => {
                ShowLoading("正在连接PLC...");
                string deviceString = "";
                if (!ConnectPlc())
                {
                    deviceString += "PLC|";
                }
                ShowLoading("正在连接条码扫描枪...");
                ConnectBarcode();
                ShowLoading("正在连接读写器...");

                if (!ConnectReader())
                {
                    deviceString += "读写器|";
                    MetroMessageBox.Show(this, "连接读写器失败!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                if (deviceString.EndsWith("|"))
                {
                    deviceString = deviceString.Remove(deviceString.Length - 1, 1);
                }
                this.Invoke(new Action(() =>
                {
                    if (deviceString.Length > 0)
                    {
                        lblDeviceStatus.Text = string.Format(deviceStatus, deviceString);
                        lblDeviceStatus.Show();
                    }
                }));
            }));
            threadLoad.IsBackground = true;
            threadLoad.Start();

            //启动上传队列
            UploadServer.GetInstance().Start();

            this.lblHU.Text       = "";
            this.lblQTY.Text      = "0";
            this.lblScanNum.Text  = "0";
            this.lblRightNum.Text = "0";
            this.lblErrorNum.Text = "0";
            this.lblStatus.Text   = "停止";
            this.lblResult.Text   = "";
            this.txtImportBoxNo.Focus();
        }
Esempio n. 8
0
        private void btnReupload_Click(object sender, EventArgs e)
        {
            List <DataGridViewRow> rows = GetCheckedRows();

            if (rows != null && rows.Count > 0)
            {
                foreach (DataGridViewRow row in rows)
                {
                    UploadServer.GetInstance().addToQueue(row.Tag as UploadPKBoxInfo);
                }
                MetroMessageBox.Show(this, "成功加入上传队列", "提示");
            }
        }
Esempio n. 9
0
        private void uploadAgainButton_Click(object sender, EventArgs e)
        {
            List <PBBoxInfo> rowBoxList = new List <PBBoxInfo>();

            List <DataGridViewRow> rows = GetCheckedRows();

            if (rows != null && rows.Count > 0)
            {
                foreach (DataGridViewRow row in rows)
                {
                    PBBoxInfo box = row.Tag as PBBoxInfo;
                    if (box != null)
                    {
                        if (!rowBoxList.Exists(r => r.HU == box.HU))
                        {
                            rowBoxList.Add(box);
                        }
                    }
                }
            }

            foreach (PBBoxInfo data in rowBoxList)
            {
                UploadBoxInfo box = new UploadBoxInfo();
                box.EQUIP_HLA = SysConfig.DeviceInfo.EQUIP_HLA;
                box.LGNUM     = SysConfig.LGNUM;
                box.LOUCENG   = SysConfig.DeviceInfo.LOUCENG;
                box.SUBUSER   = SysConfig.CurrentLoginUser.UserId;
                box.Box       = data;

                SqliteUploadDataInfo ud = new SqliteUploadDataInfo();
                ud.Guid       = Guid.NewGuid().ToString();
                ud.Data       = box;
                ud.IsUpload   = 0;
                ud.CreateTime = DateTime.Now;
                PackingBoxSqliteService.InsertUploadData(ud);
                UploadServer.GetInstance().CurrentUploadQueue.Push(ud);
            }

            if (rowBoxList.Count > 0)
            {
                MetroMessageBox.Show(this, "成功加入上传列表", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Close();
            }
        }
Esempio n. 10
0
        private void logicCheck(ref CheckResult result)
        {
            try
            {
                Dictionary <string, CJianHuoContrastRe> re = contrastEpc();
                bool conOK = isContrastReOK(re);
                if (!conOK)
                {
                    result.InventoryResult = false;
                    result.UpdateMessage("异常");
                }
                else
                {
                    result.UpdateMessage(Consts.Default.RIGHT);
                }
                // add grid
                addGrid(re);
                //print
                if (conOK)
                {
                    PrintHelper.PrintRightTag(getPrintRightData());
                }
                else
                {
                    PrintHelper.PrintErrorTag(getPrintErrorData());
                }
                //save upload
                LocalDataService.SaveJianHuoInfo(mCurBoxNo, mCurJieHuoDan.PICK_LIST, re.Values.ToList());

                CJianHuoUpload uploadData = getUploadData(re);

                CUploadData cu = new CUploadData();
                cu.Guid       = Guid.NewGuid().ToString();
                cu.IsUpload   = 0;
                cu.Data       = uploadData;
                cu.CreateTime = DateTime.Now;
                SqliteDataService.saveToSqlite(cu);

                UploadServer.GetInstance().AddToQueue(cu);
            }
            catch (Exception e)
            {
                Log4netHelper.LogError(e);
            }
        }
Esempio n. 11
0
        private void uploadAgainButton_Click(object sender, EventArgs e)
        {
            List <YKBoxInfo> rowBoxList = new List <YKBoxInfo>();

            List <DataGridViewRow> rows = GetCheckedRows();

            if (rows != null && rows.Count > 0)
            {
                foreach (DataGridViewRow row in rows)
                {
                    YKBoxInfo box = row.Tag as YKBoxInfo;
                    if (box != null)
                    {
                        if (!rowBoxList.Exists(r => r.Hu == box.Hu))
                        {
                            rowBoxList.Add(box);
                        }
                    }
                }
            }

            foreach (YKBoxInfo data in rowBoxList)
            {
                SqliteUploadDataInfo ud = new SqliteUploadDataInfo();
                ud.Guid       = Guid.NewGuid().ToString();
                ud.Data       = data;
                ud.IsUpload   = 0;
                ud.CreateTime = DateTime.Now;
                YKBoxSqliteService.InsertUploadData(ud);
                UploadServer.GetInstance().CurrentUploadQueue.Push(ud);
            }

            if (rowBoxList.Count > 0)
            {
                MetroMessageBox.Show(this, "成功加入上传列表", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Close();
            }
        }
Esempio n. 12
0
        private void InventoryForm_Load(object sender, EventArgs e)
        {
            InitView();
            initThread = new Thread(new ThreadStart(() => {
                authList = SysConfig.DeviceInfo?.AuthList?.FindAll(i => i.AUTH_CODE.StartsWith("D"));

                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; }));
                }

                ShowLoading("正在下载楼号信息...");
                LoadLhInfo();

                ShowLoading("正在下载最新退货类型...");
                if (boxQtyList == null)
                {
                    boxQtyList = new List <BoxQtyInfo>();
                }

                returnTypeList = SAPDataService.GetReturnTypeInfo(SysConfig.LGNUM);

                bool closed = false;

                ShowLoading("正在下载物料数据...");
                //materialList = SAPDataService.GetMaterialInfoListAll(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;
                }

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

                        closed = true;
                        Close();
                    }));
                }

                if (closed)
                {
                    return;
                }

                HideLoading();

                Invoke(new Action(() => {
                    UpdateTotalInfo();
                }));

                UploadServer.GetInstance().OnUploaded += Box_OnUploaded;
                UploadServer.GetInstance().Start();
            }));
            initThread.IsBackground = true;
            initThread.Start();
        }
Esempio n. 13
0
 private void InventoryForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     timer1.Enabled = false;
     CloseWindow();
     UploadServer.GetInstance().End();
 }
Esempio n. 14
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();
        }
Esempio n. 15
0
        private void InventoryForm_Load(object sender, EventArgs e)
        {
            InitView();

            Invoke(new Action(() =>
            {
                btnStart.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; }));
                }

                bool closed = false;

                ShowLoading("正在下载物料数据...");
                //materialList = SAPDataService.GetMaterialInfoListAll(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;
                }

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

                        closed = true;
                        Close();
                    }));
                }


                if (closed)
                {
                    return;
                }

                Invoke(new Action(() =>
                {
                    btnStart.Enabled = true;
                }));


                HideLoading();
            }));

            thread.IsBackground = true;
            thread.Start();

            UploadServer.GetInstance().OnUploaded += UploadServer_OnUploaded;
            UploadServer.GetInstance().Start();

            List <CUploadData> jhUpload = SqliteDataService.GetExpUploadFromSqlite <CJianHuoUpload>();

            if (jhUpload != null && jhUpload.Count > 0)
            {
                foreach (var v in jhUpload)
                {
                    UploadServer.GetInstance().AddToQueue(v);
                }
            }
        }