Exemple #1
0
        private void OnChanged(object sender, FileSystemEventArgs e)
        {
            if (!m_bDirty)
            {
                if (e.ChangeType == WatcherChangeTypes.Deleted || e.ChangeType == WatcherChangeTypes.Renamed)
                {
                    return;
                }
                else
                {
                    if (e.FullPath.Contains("Shanks_IB02"))
                    {
                        // DO SOMETING LIKE MOVE, COPY, ETC
                        bool exists = Directory.Exists(backup_log_folder);
                        if (!exists)
                        {
                            Directory.CreateDirectory(backup_log_folder);
                        }

                        string fullPath = backup_log_folder + e.Name;

                        if (File.Exists(fullPath))
                        {
                            File.Delete(fullPath);
                            Thread.Sleep(1000);
                            File.Copy(e.FullPath, fullPath);

                            var data = Ultils.ReadLogTxt(fullPath).LastOrDefault();

                            if (data == "FAIL")
                            {
                                _status    = "F";
                                boardState = "FAILD";
                                ng         = ng + 1;
                            }
                            else if (data == "PASS")
                            {
                                _status    = "P";
                                boardState = "OK";
                                pass       = pass + 1;

                                // Đóng dấu tự động
                                if (checkComWrite.Checked == true)
                                {
                                    comWrite.WriteData("A");
                                }
                            }

                            total = pass + ng;
                            Ultils.CreateFileLog(modelId, productionId, _status, gridLookUpEditProcessID.EditValue.ToString(), dateCheck);
                        }
                        else
                        {
                            Thread.Sleep(1000);
                            File.Copy(e.FullPath, fullPath);

                            var data = Ultils.ReadLogTxt(fullPath).LastOrDefault();

                            if (data == "FAIL")
                            {
                                _status    = "F";
                                boardState = "FAILD";
                                ng         = ng + 1;
                            }
                            else if (data == "PASS")
                            {
                                _status    = "P";
                                boardState = "OK";
                                pass       = pass + 1;
                            }

                            total = pass + ng;
                            Ultils.CreateFileLog(modelId, productionId, _status, gridLookUpEditProcessID.EditValue.ToString(), dateCheck);
                        }
                    }
                    else
                    {
                        return;
                    }
                }

                m_bDirty = true;
            }
        }
Exemple #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnChanged(object sender, FileSystemEventArgs e)
        {
            if (!_mBDirty)
            {
                if (e.ChangeType == WatcherChangeTypes.Deleted || e.ChangeType == WatcherChangeTypes.Renamed)
                {
                    return;
                }
                else
                {
                    if (e.FullPath.Contains("Mango_CTMS"))
                    {
                        // DO SOMETING LIKE MOVE, COPY, ETC
                        bool exists = Directory.Exists(backup_log_folder);
                        if (!exists)
                        {
                            Directory.CreateDirectory(backup_log_folder);
                        }

                        string fullPath = backup_log_folder + e.Name;

                        if (File.Exists(fullPath))
                        {
                            File.Delete(fullPath);
                            Thread.Sleep(1000);
                            File.Copy(e.FullPath, fullPath);

                            var data = Ultils.ReadLogTxt(fullPath).LastOrDefault();

                            if (data == "FAIL")
                            {
                                _status     = "F";
                                _boardState = "FAILD";
                                _ng         = _ng + 1;
                            }
                            else if (data == "PASS")
                            {
                                _status     = "P";
                                _boardState = "OK";
                                _pass       = _pass + 1;
                            }

                            _total = _pass + _ng;
                            Ultils.CreateFileLog(_modelId, _productionId, _status, gridLookUpEditProcessID.EditValue.ToString(), _dateCheck);
                        }
                        else
                        {
                            Thread.Sleep(1000);
                            File.Copy(e.FullPath, fullPath);

                            var data = Ultils.ReadLogTxt(fullPath).LastOrDefault();

                            if (data == "FAIL")
                            {
                                _status     = "F";
                                _boardState = "FAILD";
                                _ng         = _ng + 1;
                            }
                            else if (data == "PASS")
                            {
                                _status     = "P";
                                _boardState = "OK";
                                _pass       = _pass + 1;
                            }

                            _total = _pass + _ng;
                            Ultils.CreateFileLog(_modelId, _productionId, _status, gridLookUpEditProcessID.EditValue.ToString(), _dateCheck);
                        }
                    }
                    else
                    {
                        return;
                    }
                }
                _mBDirty = true;
            }
        }
Exemple #3
0
        /// <summary>
        /// Chờ sự thay đổi trong folder
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnChanged(object sender, FileSystemEventArgs e)
        {
            if (!m_bDirty)
            {
                if (e.ChangeType == WatcherChangeTypes.Deleted || e.ChangeType == WatcherChangeTypes.Renamed)
                {
                    return;
                }
                else
                {
                    // DO SOMETING LIKE MOVE, COPY, ETC
                    bool exists = Directory.Exists(backup_log_folder);
                    if (!exists)
                    {
                        Directory.CreateDirectory(backup_log_folder);
                    }

                    string fullPath = backup_log_folder + e.Name;

                    if (File.Exists(fullPath))
                    {
                        File.Delete(fullPath);
                        Thread.Sleep(5000);
                        File.Copy(e.FullPath, fullPath);
                        Thread.Sleep(5000);
                        var data = Ultils.ReadCsv(e.FullPath).Skip(1); // skip 1 headerlines

                        string[] _array = data.LastOrDefault();
                        if (string.IsNullOrEmpty(_array[3]))
                        {
                            return;
                        }
                        if (string.IsNullOrEmpty(_array[5]))
                        {
                            return;
                        }
                        if (_array[3] == "OK")
                        {
                            _status    = "P";
                            boardState = "OK";
                            pass       = pass + 1;

                            if (checkComWrite.Checked == true)
                            {
                                comWrite.WriteData("A");
                            }
                        }
                        if (_array[3] == "NG")
                        {
                            _status    = "F";
                            boardState = "FAILD";
                            ng         = ng + 1;
                        }
                        total = pass + ng;

                        Ultils.CreateFileLog(modelId, productionId, _status, gridLookUpEditProcessID.EditValue.ToString(), dateCheck);
                        StartTimerReadBarcode();
                    }
                    else
                    {
                        Thread.Sleep(5000);
                        File.Copy(e.FullPath, fullPath);
                        Thread.Sleep(5000);
                        var data = Ultils.ReadCsv(e.FullPath).Skip(1); // skip 1 headerlines

                        string[] _array = data.LastOrDefault();
                        if (string.IsNullOrEmpty(_array[3]))
                        {
                            return;
                        }
                        if (string.IsNullOrEmpty(_array[5]))
                        {
                            return;
                        }
                        if (_array[3] == "OK")
                        {
                            _status    = "P";
                            boardState = "OK";
                            pass       = pass + 1;
                        }
                        if (_array[3] == "NG")
                        {
                            _status    = "F";
                            boardState = "FAILD";
                            ng         = ng + 1;
                        }
                        string stationNo = gridLookUpEditProcessID.EditValue.ToString();
                        total = pass + ng;
                        Ultils.CreateFileLog(modelId, productionId, _status, stationNo, dateCheck);
                        StartTimerReadBarcode();
                    }
                }
                m_bDirty = true;
            }
        }
Exemple #4
0
        /// <summary>
        /// Insert Log
        /// </summary>
        /// <param name="boxId"></param>
        private void InsertLog(string boxId)
        {
            if (!string.IsNullOrEmpty(txtProductionID.Text.Trim()) ||
                !string.IsNullOrEmpty(txtBoxID.Text.Trim()))
            {
                int    lineId       = Program.CurrentUser.LineID;
                int    operationId  = Program.CurrentUser.OperationID;
                string operatorId   = Program.CurrentUser.OperatorCode;
                string productionId = txtProductionID.Text.Trim();

                string status = null;
                bool   judge  = false;
                if (checkPASS.Checked == true)
                {
                    status = "P";
                    judge  = true;
                }
                if (checkNG.Checked == true)
                {
                    status = "F";
                    judge  = false;
                }

                var logs = _oqcService.GetLogsByBoxId(boxId).ToList();

                // Nếu Box có dữ liệu của PCB
                if (logs.Any())
                {
                    var log = logs.SingleOrDefault(l => l.ProductionID == productionId);
                    // Nếu PCB mới bắn vào chưa có trong Box
                    if (log == null)
                    {
                        var model = _modelService.GetModelById(logs.FirstOrDefault().ModelID);
                        // Nếu Production ID, có Model giống với Model hiện tại
                        if (productionId.Contains(model.ModelName) && productionId.Contains(model.SerialNo))
                        {
                            string tmp           = lblQuantityModel.Text.Replace("/", "");
                            int    countPcbInBox = int.Parse(lblCountPCB.Text);
                            int    quantity      = int.Parse(tmp);

                            if (logs.Count == quantity)
                            {
                                SetErrorStatus("NG", $"Box [{txtBoxID.Text}] đã đủ số lượng. Vui lòng kiểm tra lại!");
                                Ultils.EditTextErrorNoMessage(txtBoxID);
                                checkFujiHP.Checked = false;
                                txtBoxID.Enabled    = true;
                                txtBoxID.Focus();
                                txtBoxID.ResetText();
                            }
                            else
                            {
                                try
                                {
                                    _iqcService.InsertLogs(productionId, lineId, txtMacAddress.Text, boxId, modelID, "N/T", 1, operatorId, false, "IT", StringHelper.GetInfo(), "tmp");

                                    if (!_iqcService.CheckResultExits(productionId, operationId))
                                    {
                                        _iqcService.InsertResult(productionId, operationId, judge, operatorId, _dateTimeCheck);
                                    }
                                    else
                                    {
                                        _iqcService.UpdateResult(productionId, operationId, judge, operatorId);
                                    }
                                    Ultils.CreateFileLog(lblCurentModel.Text, productionId, status, Program.CurrentUser.ProcessID, _dateTimeCheck);
                                    logs = _oqcService.GetLogsByBoxId(boxId).ToList();
                                    gridControlData.Refresh();
                                    gridControlData.DataSource = logs;
                                    lblCountPCB.Text           = logs.Count.ToString(CultureInfo.InvariantCulture);

                                    SetSuccessStatus("PASS", $"Thành công!\nPCB [{txtProductionID.Text}]");
                                    txtProductionID.ResetText();
                                    txtProductionID.Focus();

                                    if (logs.Count == quantity)
                                    {
                                        SetSuccessStatus("OK", $"Box [{txtBoxID.Text}] đã đủ số lượng!");
                                        Ultils.EditTextErrorNoMessage(txtBoxID);
                                        txtBoxID.Enabled = true;
                                        txtBoxID.Focus();
                                        txtBoxID.ResetText();
                                    }
                                }
                                catch (Exception ex)
                                {
                                    SetErrorStatus("NG", "Model chưa có trong hệ thống!\nVui lòng nhập model này vào, và thử lại. \n" + ex.Message);
                                    txtProductionID.ResetText();
                                    txtProductionID.Focus();
                                }
                            }
                        }
                        else
                        {
                            SetErrorStatus("NG", $"Sai Model: {lblCurentModel.Text} !\nPCB [{productionId}] này khác với các PCB trong Box [{boxId}].\nVui lòng kiểm tra lại!");
                            txtProductionID.ResetText();
                            txtProductionID.Focus();
                            Ultils.EditTextErrorNoMessage(txtProductionID);

                            logs = _oqcService.GetLogsByBoxId(boxId).ToList();
                            gridControlData.Refresh();
                            gridControlData.DataSource = logs;
                            lblCountPCB.Text           = logs.Count.ToString(CultureInfo.InvariantCulture);
                        }
                    }
                    // Nếu có rồi thì thống báo lỗi
                    else
                    {
                        SetErrorStatus("NG", $"PCB [{txtProductionID.Text}] này đã có trong Box rồi.\nVui lòng kiểm tra lại");
                        txtProductionID.ResetText();
                        txtProductionID.Focus();
                        gridControlData.Refresh();
                        gridControlData.DataSource = logs;
                        lblCountPCB.Text           = logs.Count.ToString(CultureInfo.InvariantCulture);
                    }
                }
                // Nếu Box chưa có dữ liệu gì, thực hiện insert
                else
                {
                    try
                    {
                        _iqcService.InsertLogs(productionId, lineId, txtMacAddress.Text, boxId, modelID, "N/T", 1, operatorId, false, "IT", StringHelper.GetInfo(), "tmp");

                        if (!_iqcService.CheckResultExits(txtProductionID.Text, operationId))
                        {
                            _iqcService.InsertResult(productionId, operationId, judge, operatorId, _dateTimeCheck);
                        }
                        else
                        {
                            _iqcService.UpdateResult(productionId, operationId, judge, operatorId);
                        }
                        Ultils.CreateFileLog(lblCurentModel.Text, productionId, status, Program.CurrentUser.ProcessID, _dateTimeCheck);
                        logs = _oqcService.GetLogsByBoxId(boxId).ToList();
                        gridControlData.Refresh();
                        gridControlData.DataSource = logs;
                        lblCountPCB.Text           = logs.Count.ToString(CultureInfo.InvariantCulture);

                        SetSuccessStatus("PASS", string.Format("Thêm thành công!\nPCB [{0}]", productionId));
                        txtProductionID.ResetText();
                        txtProductionID.Focus();
                    }
                    catch (Exception ex)
                    {
                        SetErrorStatus("NG", "Error Insert! \n" + ex.Message);
                        txtProductionID.ResetText();
                        txtProductionID.Focus();
                    }
                }
            }
            else
            {
                SetErrorStatus("NG", "Vui lòng nhập đủ thông tin!");
                txtProductionID.Focus();
                txtProductionID.SelectAll();
            }
        }
Exemple #5
0
        /// <summary>
        /// Insert Log
        /// </summary>
        /// <param name="boxId"></param>
        private void InsertLog(string boxId, string boardNo)
        {
            int    lineId      = Program.CurrentUser.LineID;
            int    operationId = Program.CurrentUser.OperationID;
            string operatorId  = Program.CurrentUser.OperatorCode;

            string status = null;
            bool   judge  = false;

            if (checkOK.Checked == true)
            {
                status = "P";
                judge  = true;
            }
            if (checkNG.Checked == true)
            {
                status = "F";
                judge  = false;
            }
            var logs = testLogService.Get(boxId);

            if (operationId == 1)
            {
                try
                {
                    var testLog = new tbl_test_log()
                    {
                        ProductionID = boardNo,
                        LineID       = lineId,
                        MacAddress   = txtMacAddress.Text.Trim(),
                        BoxID        = boxId,
                        DateCheck    = DateTimeServer.Date,
                        TimeCheck    = DateTimeServer.TimeOfDay,
                        OperatorCode = operatorId,
                        Target       = 1,
                        Actual       = 1,
                        FullBox      = false,
                        QA_Check     = false,
                        CheckBy      = operatorId,
                        ModelID      = _model.ModelID,
                    };

                    if (testLogService.Insert(testLog) == true)
                    {
                        var checkExists = testResultService.GetSingle(boardNo, operationId);

                        if (checkExists == null)
                        {
                            var result = new tbl_test_result()
                            {
                                ProductionID  = boardNo,
                                OperationID   = operationId,
                                OperationDate = DateTimeServer,
                                OperatorID    = operatorId,
                                JudgeResult   = judge,
                            };
                            testResultService.Insert(result);
                        }
                        else
                        {
                            checkExists.JudgeResult   = judge;
                            checkExists.OperatorID    = operatorId;
                            checkExists.OperationDate = DateTimeServer;

                            testResultService.Update(checkExists);
                        }
                    }

                    logs = testLogService.Get(boxId);
                    dataGridViewX1.DataSource = logs;

                    SuccessMessage("OK", string.Format("Thêm thành công!\nPCB [{0}]", boardNo));
                }
                catch (Exception ex)
                {
                    ErrorMessage("NG", "Error Insert! \n" + ex.Message);
                }

                // Create log
                Ultils.CreateFileLog(_model.ModelName, boardNo, status, Program.CurrentUser.ProcessID, DateTimeServer);

                txtBarcode.ResetText();
                txtBarcode.Focus();

                sw.Stop();
                MessageBox.Show(sw.Elapsed.ToString());
            }
        }
Exemple #6
0
        /// <summary>
        /// Insert Log
        /// </summary>
        /// <param name="boxId"></param>
        private void InsertLog(string boxId)
        {
            if (!string.IsNullOrEmpty(txtProductID.Text.Trim()) ||
                !string.IsNullOrEmpty(txtBoxID.Text.Trim()) ||
                !string.IsNullOrEmpty(txtModelUMC.Text.Trim()))
            {
                int    lineId       = Program.CurrentUser.LineID;
                int    operationId  = Program.CurrentUser.OperationID;
                string operatorId   = Program.CurrentUser.OperatorCode;
                string productionId = txtProductID.Text.Trim();

                string status = null;
                bool   judge  = false;
                if (checkPASS.Checked == true)
                {
                    status = "P";
                    judge  = true;
                }
                if (checkNG.Checked == true)
                {
                    status = "F";
                    judge  = false;
                }
                var logs = _murataService.GetProducts_Murata_by_BoxId(boxId).ToList();
                if (operationId == 1)
                {
                    // Nếu Box có dữ liệu của PCB
                    if (logs.Any())
                    {
                        var log = logs.SingleOrDefault(l => l.ProductionID == productionId);
                        // Nếu PCB mới bắn vào chưa có trong Box
                        if (log == null)
                        {
                            var checkModelInBox = logs.FirstOrDefault();
                            // Nếu Production ID, có Model giống với Model hiện tại
                            if (productionId.Contains(checkModelInBox.ModelName))
                            {
                                string tmp           = lblQuantityModel.Text.Replace("/", "");
                                int    countPcbInBox = int.Parse(lblCountPCB.Text);
                                int    quantity      = int.Parse(tmp);

                                if (logs.Count == quantity)
                                {
                                    SetErrorStatus("NG", $"Box [{txtBoxID.Text}] đã đủ số lượng. Vui lòng kiểm tra lại!");
                                    Ultils.EditTextErrorNoMessage(txtBoxID);
                                    EnableBoxIDWidthModel(true);
                                    if (checkModelCUS.Checked == true)
                                    {
                                        EnbaleCheckWidthModelCus(true);
                                    }
                                    else
                                    {
                                        EnbaleCheckWidthModelCus(false);
                                    }
                                    txtProductID.ResetText();
                                }
                                else
                                {
                                    try
                                    {
                                        _iqcService.InsertLogs(productionId, lineId, "N/A", boxId, modelID, "N/T", 1, operatorId, false, "IT", StringHelper.GetInfo(), txtModelCUS.Text.Trim());

                                        if (!_iqcService.CheckResultExits(productionId, operationId))
                                        {
                                            _iqcService.InsertResult(productionId, operationId, judge, operatorId, _dateTimeCheck);
                                        }
                                        else
                                        {
                                            _iqcService.UpdateResult(productionId, operationId, judge, operatorId);
                                        }
                                        Ultils.CreateFileLog(lblCurentModel.Text, productionId, status, Program.CurrentUser.ProcessID, _dateTimeCheck);
                                        Ultils.CreateFileLogDirModelName(lblCurentModel.Text, productionId, status, Program.CurrentUser.ProcessID, _dateTimeCheck);
                                        logs = _murataService.GetProducts_Murata_by_BoxId(boxId).ToList();
                                        gridControlData.Refresh();
                                        gridControlData.DataSource = logs;
                                        lblCountPCB.Text           = logs.Count.ToString(CultureInfo.InvariantCulture);

                                        SetSuccessStatus("OK", $"Thành công!\nPCB [{txtProductID.Text}]");
                                        ResetControls();
                                        if (logs.Count() == quantity)
                                        {
                                            SetErrorStatus("NG", $"Box [{txtBoxID.Text}] đã đủ số lượng. Vui lòng lấy box mới!");
                                            Ultils.EditTextErrorNoMessage(txtBoxID);
                                            EnableBoxIDWidthModel(true);
                                            if (checkModelCUS.Checked == true)
                                            {
                                                EnbaleCheckWidthModelCus(true);
                                            }
                                            else
                                            {
                                                EnbaleCheckWidthModelCus(false);
                                            }
                                            txtProductID.ResetText();
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        SetErrorStatus("NG", "Model chưa có trong hệ thống!\nVui lòng nhập model này vào, và thử lại. \n" + ex.Message);
                                        ResetControls();
                                    }
                                }
                            }
                            else
                            {
                                SetErrorStatus("NG", "Sai Model! Vui lòng kiểm tra và thử lại!");
                                Ultils.EditTextErrorNoMessage(txtProductID);
                                ResetControls();
                                logs = _murataService.GetProducts_Murata_by_BoxId(boxId).ToList();
                                gridControlData.Refresh();
                                gridControlData.DataSource = logs;
                                lblCountPCB.Text           = logs.Count.ToString(CultureInfo.InvariantCulture);
                            }
                        }
                        // Nếu có rồi thì thống báo lỗi
                        else
                        {
                            SetErrorStatus("NG", $"PCB [{txtProductID.Text}] này đã có trong Box rồi.\nVui lòng kiểm tra lại");
                            ResetControls();
                            gridControlData.Refresh();
                            gridControlData.DataSource = logs;
                            lblCountPCB.Text           = logs.Count.ToString(CultureInfo.InvariantCulture);
                        }
                    }
                    // Nếu Box chưa có dữ liệu gì, thực hiện insert
                    else
                    {
                        try
                        {
                            _iqcService.InsertLogs(productionId, lineId, "N/A", boxId, modelID, "N/T", 1, operatorId, false, "IT", StringHelper.GetInfo(), txtModelCUS.Text.Trim());

                            if (!_iqcService.CheckResultExits(txtProductID.Text, operationId))
                            {
                                _iqcService.InsertResult(productionId, operationId, judge, operatorId, _dateTimeCheck);
                            }
                            else
                            {
                                _iqcService.UpdateResult(productionId, operationId, judge, operatorId);
                            }
                            Ultils.CreateFileLog(lblCurentModel.Text, productionId, status, Program.CurrentUser.ProcessID, _dateTimeCheck);
                            Ultils.CreateFileLogDirModelName(lblCurentModel.Text, productionId, status, Program.CurrentUser.ProcessID, _dateTimeCheck);
                            logs = _murataService.GetProducts_Murata_by_BoxId(boxId).ToList();
                            gridControlData.Refresh();
                            gridControlData.DataSource = logs;
                            lblCountPCB.Text           = logs.Count.ToString(CultureInfo.InvariantCulture);

                            SetSuccessStatus("OK", string.Format("Thêm thành công!\nPCB [{0}]", productionId));
                            ResetControls();
                        }
                        catch (Exception ex)
                        {
                            SetErrorStatus("NG", "Error Insert! \n" + ex.Message);
                            ResetControls();
                        }
                    }
                }
                else if (operationId >= 2)
                {
                    _iqcService.UpdateLogs(productionId, lineId, "N/A", boxId, modelID, null, operatorId, txtModelCUS.Text.Trim());
                    _iqcService.InsertResult(productionId, operationId, judge, operatorId, _dateTimeCheck);

                    logs = _murataService.GetProducts_Murata_by_BoxId(boxId).ToList();
                    gridControlData.Refresh();
                    gridControlData.DataSource = logs;
                    lblCountPCB.Text           = logs.Count.ToString(CultureInfo.InvariantCulture);

                    SetSuccessStatus("OK", string.Format("Thành công!\nPCB [{0}] vừa được bắn lại lần {1}", productionId, operationId));
                    ResetControls();
                }
            }
            else
            {
                SetErrorStatus("NG", "Vui lòng nhập đủ thông tin!");
                EnableBoxIDWidthModel(true);
                txtBoxID.Focus();
            }
        }