/// <summary>
        /// 手工删除标签号码。
        /// </summary>
        /// <param name="code">标签号码</param>
        private void DeleteLabelByHand(string code)
        {
            // 删除号码。
            var lc = LableCode.QueryByLCode(code);

            if (lc == null)
            {
                CommonHelper.Warn("不存在这个号码!");
                return;
            }

            var area        = lc.ParseLocationArea();
            var bAndOnBoard = (area == "B" && lc.Status >= (int)LableState.OnPanel);
            var aCarea      = (area == "A" || area == "C");

            if (!bAndOnBoard && !aCarea)
            {
                CommonHelper.Warn("只能删除B区已上垛的号码, 或者A区、C区的号码!");
                return;
            }

            if (LableCode.Delete(code) || deleteFromTaskq(FrmMain.taskQ, code))
            {
                notifyOpc(code);
                lbxLog.Items.Insert(0, $"{lbxLog.Items.Count} {code}已经删除。");
                FrmMain.logOpt.Write(string.Format("删除标签{0}成功", code), LogType.NORMAL);
            }
            else
            {
                FrmMain.logOpt.Write(string.Format("删除标签{0}失败", code), LogType.NORMAL);
            }
        }
Esempio n. 2
0
        public void DeleteCodeFromQueAndDb(string code)
        {
            lock (TaskQueues.LOCK_LOCHELPER) {
                deleteFromTaskq(FrmMain.taskQ, code);
            }
            log($"号码{code}已从队列中删除");

            var label = LableCode.QueryByLCode(code);

            if (label != null)
            {
                label.Remark += ";delete";

                // 只有没计算过位置的布卷才可以从数据库中删除。
                if (string.IsNullOrEmpty(label.PanelNo) || label.FloorIndex == 0)
                {
                    LableCode.Delete(label.LCode);
                    LableCode.SaveToHistory(label);
                    log($"号码{label.LCode}已经从数据库中删除");
                }
                else
                {
                    log($"号码{label.LCode}不能从数据库删除,板号: {label.PanelNo}, 层位置: {label.FloorIndex}");
                }

                // tell plc.
                notifyOpc(label.LCode);
            }
            else
            {
                var msg = $"数据库中没有这个号码: {code}";
                log(msg);
            }
        }
        private void checkInDb(string code)
        {
            var lc = LableCode.QueryByLCode(code);

            if (lc != null)
            {
                lbxLog.Items.Insert(0, $"{lbxLog.Items.Count} 数据库: {lc.LCode} {lc.ToLocation} 实际交地: {lc.RealLocation} 扫描时间: {lc.CreateDate} 板号: {lc.PanelNo}");
            }
            else
            {
                lbxLog.Items.Insert(0, $"{lbxLog.Items.Count} {code}数据库中没有此号码。");
            }
        }
Esempio n. 4
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            mtxCode.SelectAll();
            var key = shrink(mtxCode.Text);

            if (string.IsNullOrEmpty(key))
            {
                return;
            }

            Cursor = Cursors.WaitCursor;
            try {
                if (!ckHistory.Checked)
                {
                    var c = LableCode.QueryByLCode(key);
                    if (c != null)
                    {
                        showlabel(c);
                    }
                    else
                    {
                        showwarning(key, "当前运行数据");
                    }
                    lbx.Items.Insert(0, $"<当前运行数据>查询结果:");
                    lbx.Items.Insert(0, $"---------------------");
                }

                if (ckHistory.Checked)
                {
                    var c = LableCode.QueryByLCodeFromHis(key);
                    if (c != null && c.Count() != 0)
                    {
                        foreach (var obj in c)
                        {
                            showlabel(obj);
                        }
                    }
                    else
                    {
                        showwarning(key, "历史数据");
                    }

                    var count = c == null ? 0 : c.Count;
                    lbx.Items.Insert(0, $"<历史数据>查询结果({count}):");
                    lbx.Items.Insert(0, $"---------------------");
                }
            } finally { Cursor = Cursors.Default; }
        }
Esempio n. 5
0
        /// <summary>
        ///  [交地]|[长度]
        /// </summary>
        /// <param name="code"></param>
        /// <param name="erpapi"></param>
        /// <param name="warnhandler"></param>
        /// <returns>[交地]|[长度]</returns>
        public static string GetLocationAndLength(IErpApi erpapi, string code, Action <string, bool> warnhandler)
        {
            var tolocation = string.Empty;
            var dt         = LableCode.QueryByLCode(code);

            if (dt != null)
            {
                FrmMain.logOpt.Write($"!号码重复: {code}", LogType.NORMAL);
                warnhandler?.Invoke("重复扫码", true);
            }
            else
            {
                var str = new Dictionary <string, string>();
                try {
                    str = erpapi.Post(clsSetting.GetLocation,
                                      new Dictionary <string, string> {
                        { "Bar_Code", code }
                    },
                                      clsSetting.ErpTimeout);
                    if (str["ERPState"] == "OK")
                    {
                        var res = JsonConvert.DeserializeObject <DataTable>(str["Data"].ToString());
                        if (res.Rows.Count > 0 && res.Rows[0]["LOCATION"].ToString() != "Fail")
                        {
                            tolocation = res.Rows[0]["LOCATION"].ToString();
                            FrmMain.logOpt.Write($"号码: {code}, 交地: {tolocation}", LogType.NORMAL);
                        }
                        else
                        {
                            warnhandler?.Invoke("取交地失败", true);
                            FrmMain.logOpt.Write($"!{code}获取交地失败。{JsonConvert.SerializeObject(str)}", LogType.NORMAL);
                        }
                    }
                    else
                    {
                        warnhandler?.Invoke("取交地失败", true);
                        FrmMain.logOpt.Write($"!{code}获取交地失败。{JsonConvert.SerializeObject(str)}", LogType.NORMAL);
                    }
                } catch (Exception ex) {
                    warnhandler?.Invoke("取交地失败", true);
                    FrmMain.logOpt.Write($"!来源: {nameof(GetLocationAndLength)}, {ex}, {JsonConvert.SerializeObject(str)}", LogType.NORMAL);
                }
            }
            return(tolocation);
        }