Example #1
0
        private void dgv_SNsIP_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (this.cb_TestTypes.SelectedIndex == -1)
            {
                MessageBox.Show("Najprv zvolte druh testu.");
                this.cb_TestTypes.Focus();
                return;
            }
            if ((e.ColumnIndex == 5) && (e.RowIndex == -1) && (this.dgv_SNsIP.Rows.Count > 0))
            {
                if (MessageBox.Show("Naozaj chcete ukoncit vsetky vyrobky zo zoznamu s vysledkom PASS?", "Hromadne ukoncenie", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    while (this.dgv_SNsIP.Rows.Count > 0)
                    {
                        String actSN = this.dgv_SNsIP.Rows[0].Cells[0].Value.ToString().Trim();
                        this.tb_SerialNumber.Text = actSN;
                        this.tb_SerialNumber_KeyUp(new object(), new KeyEventArgs(Keys.Enter));
                    }
                }
                return;
            }
            try
            {
                if (e.RowIndex == -1)
                {
                    return;
                }
                String actSN       = this.dgv_SNsIP.Rows[e.RowIndex].Cells[0].Value.ToString().Trim();
                String actTestType = this.dgv_SNsIP.Rows[e.RowIndex].Cells[2].Value.ToString().Trim();
                if (e.ColumnIndex == 5)
                {
                    this.tb_SerialNumber.Text = actSN;
                    this.tb_SerialNumber_KeyUp(new object(), new KeyEventArgs(Keys.Enter));
                    return;
                }
                else if (e.ColumnIndex == 6)
                {
                    StepInfo[] arrFSI = { };

                    InputBox_Form myIBF = new InputBox_Form("Failed test", "Zadajte nazov chybneho kroku");
                    if (myIBF.ShowDialog() == DialogResult.OK)
                    {
                        Array.Resize(ref arrFSI, 0);
                        while (myIBF.Answer != "")
                        {
                            StepInfo actFSI = new StepInfo();
                            actFSI.Name  = myIBF.Answer;
                            actFSI.Grade = "FAIL";
                            Array.Resize(ref arrFSI, arrFSI.Length + 1);
                            arrFSI.SetValue(actFSI, arrFSI.Length - 1);
                            myIBF = new InputBox_Form("Failed test", "Zadajte nazov dalsieho chybneho kroku");
                            myIBF.ShowDialog();
                        }
                        if (arrFSI.Length == 0)
                        {
                            StepInfo actFSI = new StepInfo();
                            actFSI.Name  = "Test1";
                            actFSI.Grade = "FAIL";
                            Array.Resize(ref arrFSI, arrFSI.Length + 1);
                            arrFSI.SetValue(actFSI, arrFSI.Length - 1);
                        }

                        this.act_SNS       = new SerialNumberSteps(actSN);
                        this.act_SNS.Steps = arrFSI;
                        this.GenerateReport(actSN, DateTime.Now);
                        this.myStationConfig.IsInProcessAndDelete(actSN, actTestType, true);
                        this.dgv_SNsIP.Rows.RemoveAt(e.RowIndex);
                        this.lbl_Info.ForeColor = System.Drawing.Color.Green;
                        this.lbl_Info.Text      = this.objBelMes.Authorization.strResult;
                    }
                }
                else if (e.ColumnIndex == 7)
                {
                    this.objBelMes.SetActualResult("Terminated", "", actSN);
                    this.myStationConfig.IsInProcessAndDelete(actSN, actTestType, true);
                    this.dgv_SNsIP.Rows.RemoveAt(e.RowIndex);
                    this.lbl_Info.ForeColor = System.Drawing.Color.FromArgb(255, 150, 0);
                    this.lbl_Info.Text      = this.objBelMes.Authorization.strResult;
                }
                else
                {
                    return;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                this.tb_SerialNumber.Clear();
                this.tb_SerialNumber.Focus();
            }
        }
Example #2
0
        private Boolean GenerateReport(String SerialNumber, DateTime StartTime)
        {
            try
            {
                DateTime starttime = StartTime;
                DateTime endtime   = StartTime.AddSeconds(5);

                UnitReport myReport = new UnitReport(starttime, endtime, "D", "", false);

                myReport.Operator.name = this.str_OperatorNr;

                myReport.Cathegory = new _Cathegory("Default");

                myReport.Cathegory.Product = new _Product("", SerialNumber); //mozno pridam stlpec s PartNumberom, ktory vrati autorizacia belmesu

                myReport.TestRun.name = this.cb_TestTypes.Text;

                myReport.starttime = starttime;
                myReport.endtime   = endtime;

                myReport.AddProperty("Work Order", SerialNumber.Substring(0, 8));

                String URMode = myStationConfig.GetMode();
                if (URMode == "")
                {
                    URMode = "D";
                }
                else
                {
                    myReport.mode = URMode;
                }
                XmlNode assembliesNode = ProductsConfig.XmlFile.LastChild.SelectSingleNode("./Assemblies");
                foreach (XmlNode actAssNode in assembliesNode.ChildNodes)
                {
                    if (actAssNode.SelectSingleNode("./Name").InnerText == myReport.Cathegory.Product.PartNo)
                    {
                        XmlNode propertiesNode = actAssNode.SelectSingleNode("./Properties");
                        if (propertiesNode != null)
                        {
                            foreach (XmlNode actPropNode in propertiesNode)
                            {
                                myReport.AddProperty(actPropNode.Name, actPropNode.InnerText);
                            }
                        }
                    }
                }

                XmlNode familyProperties = ProductsConfig.XmlFile.LastChild.SelectSingleNode("./Families");
                foreach (XmlNode actFamilyNode in familyProperties.ChildNodes)
                {
                    if (actFamilyNode.SelectSingleNode("./Name").InnerText == myReport.Cathegory.Product.PartNo)
                    {
                        XmlNode propertiesNode = actFamilyNode.SelectSingleNode("./Properties");
                        if (propertiesNode != null)
                        {
                            foreach (XmlNode actPropNode in propertiesNode)
                            {
                                myReport.AddProperty(actPropNode.Name, actPropNode.InnerText);
                            }
                        }
                    }
                }

                Array commonProperties = myStationConfig.GetProperties();
                for (int i = 0; i < commonProperties.GetLength(0); i++)
                {
                    String actNameNode = commonProperties.GetValue(i, 0).ToString().Trim().Replace('_', ' ');
                    myReport.AddProperty(actNameNode, commonProperties.GetValue(i, 1).ToString().Trim());
                }


                StationConfig.StationInfos actSI = myStationConfig.GetStationInfosForTest(this.cb_TestTypes.Text);

                foreach (StationConfig.StationInfos.StationProperty actProp in actSI.StationProperties)
                {
                    String actNameNode = actProp.Name.Replace('_', ' ');
                    myReport.AddProperty(actNameNode, actProp.Value);
                }

                String StationName = actSI.Name;
                String StationGUID = actSI.GUID;
                myReport.TestRun.grade = "PASS";

                myReport.Station = new _Station(StationGUID, StationName);
                if (this.act_SNS != null)
                {
                    if (myReport.Cathegory.Product.SerialNo == this.act_SNS.SerialNumber)
                    {
                        foreach (StepInfo actFSI in this.act_SNS.Steps)
                        {
                            if (actFSI.Name.Trim() == "CustomerSerialNumber")
                            {
                                myReport.AddProperty("CustomerSN", actFSI.ResultValue);
                                myReport.TestRun.AddTestRunChild(actFSI.Name, myReport.starttime, myReport.endtime, actFSI.Grade, actFSI.ResultValue, "*$*", actFSI.ResultValue);
                            }
                            else
                            {
                                myReport.TestRun.AddTestRunChild(actFSI.Name, myReport.starttime, myReport.endtime, actFSI.Grade, actFSI.ResultValue, "", "*$*");
                            }
                            if (actFSI.Grade == "FAIL")
                            {
                                myReport.TestRun.grade = "FAIL";
                            }
                        }
                    }
                    if (myReport.TestRun.grade == "FAIL")
                    {
                        myReport.AddProperty("To Repair", "Yes");
                    }
                }

                this.act_SNS = null;

                String strReportPath = this.myStationConfig.GetReportPathDirectory();
                Array  XmlReportLines;
                String XmlReportContent = "";
                try
                {
                    XmlReportLines = myReport.GetXMLReport(strReportPath, true);
                    if (myReport.TestRun.grade == "")
                    {
                        MessageBox.Show("Problem pri vytvarani reportu. Zavolajte prosim technika.");
                        this.Close();
                    }

                    foreach (String ActLine in XmlReportLines)
                    {
                        XmlReportContent = String.Concat(XmlReportContent, ActLine);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                //

                if (this.objBelMes.Activated)
                {
                    try
                    {
                        String testKind = this.cb_TestTypes.Text;
                        if (testKind == "Adjustement")
                        {
                            testKind = "Adjustment";
                        }
                        if (myReport.TestRun.grade.ToUpper().Trim() == "PASS")
                        {
                            myReport.TestRun.grade = "Pass";
                        }
                        if (myReport.TestRun.grade.ToUpper().Trim() == "FAIL")
                        {
                            myReport.TestRun.grade = "Fail";
                        }

                        if (this.objBelMes.SetActualResult(myReport.Cathegory.Product.SerialNo, testKind, String.Concat(myReport.TestRun.grade, "ed"), XmlReportContent))
                        {
                            if (this.objBelMes.Authorization.intReturnCode == 0)
                            {
                                this.lbl_Info.ForeColor = System.Drawing.Color.Green;
                            }
                            else
                            {
                                if (this.objBelMes.Authorization.blnMustTraced)
                                {
                                    this.lbl_Info.ForeColor = System.Drawing.Color.Red;
                                }
                                else
                                {
                                    this.lbl_Info.ForeColor = System.Drawing.Color.FromArgb(255, 150, 0);
                                }
                            }
                            //this.Authorization.TryAuthorization(myReport.Cathegory.Product.SerialNo, testKind, String.Concat(myReport.TestRun.grade, "ED"), this.Env, false, false, XmlReportContent);
                        }
                        else
                        {
                            return(false);
                        }
                        this.lbl_Info.Text = this.objBelMes.Authorization.strResult;
                    }
                    catch
                    {
                        return(false);
                    }
                }
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Example #3
0
        private void tb_SerialNumber_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode != Keys.Enter)
            {
                return;
            }

            DialogResult myDR = DialogResult.OK;

            if (NetworkInterface.GetIsNetworkAvailable())
            {
                //Do your stuffs when network available
            }
            else
            {
                //Do stuffs when network not available
                myDR = MessageBox.Show("Nie je aktivne sietove pripojenie. Skontrolujte ho. \n\nV pripade nutnosti zavolajte nadriadeneho.", "CHYBA", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
                while ((myDR == DialogResult.Retry) && (!NetworkInterface.GetIsNetworkAvailable()))
                {
                    myDR = MessageBox.Show("Nie je aktivne sietove pripojenie. Skontrolujte ho. \n\nV pripade nutnosti zavolajte nadriadeneho.", "CHYBA", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
                }
                if (myDR == DialogResult.Cancel)
                {
                    this.tb_SerialNumber.SelectAll();
                    this.tb_SerialNumber.Focus();
                    return;
                }
            }

            Ping      pingSender        = new Ping();
            String    hostNameOrAddress = "dcasql14";
            PingReply reply             = pingSender.Send(hostNameOrAddress);

            myDR = DialogResult.Retry;
            while ((reply.Status != IPStatus.Success) && (myDR == DialogResult.Retry))
            {
                myDR = MessageBox.Show("Nie je pristupny BelMes/dcasql14 server. \n\nKontaktujte nadriadeneho.", "CHYBA", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
            }

            if (reply.Status != IPStatus.Success)
            {
                this.tb_SerialNumber.SelectAll();
                this.tb_SerialNumber.Focus();
                return;
            }


            if (this.cb_TestTypes.SelectedIndex == -1)
            {
                MessageBox.Show("Najprv zvolte druh testu.");
                this.cb_TestTypes.Focus();
                return;
            }
            try
            {
                String strTestType = this.cb_TestTypes.Text.Trim();

                String strValidatedSerialNumber = this.tb_SerialNumber.Text;

                if (strValidatedSerialNumber.Substring(strValidatedSerialNumber.Length - 2) == "\n\t")
                {
                    strValidatedSerialNumber = String.Concat(strValidatedSerialNumber.Substring(0, strValidatedSerialNumber.Length - 2), ";");
                }

                if (strValidatedSerialNumber[0].ToString() == "#")
                {
                    if (strValidatedSerialNumber[strValidatedSerialNumber.Length - 1].ToString() != ";")
                    {
                        String[] buffArr = strValidatedSerialNumber.Split(';');
                        if (buffArr.Length == 2)
                        {
                            MessageBox.Show(String.Concat("Nespravny format udajov v Barcode. Posledny znak musi byt bodkociarka - \";\". \nBarcode obsahuje udaj:\n\n", strValidatedSerialNumber), "POZOR", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            this.tb_SerialNumber.SelectAll();
                            this.tb_SerialNumber.Focus();
                            return;
                        }
                    }
                    strValidatedSerialNumber = strValidatedSerialNumber.Substring(0, 14);
                }

                strValidatedSerialNumber = Regex.Match(tb_SerialNumber.Text.Trim(), @"\d+").Value;

                if (strValidatedSerialNumber.Length != 13)
                {
                    tb_SerialNumber.SelectAll();
                    this.lbl_Info.Text      = String.Concat(strValidatedSerialNumber, " nie je platné SN.");
                    this.lbl_Info.ForeColor = System.Drawing.Color.Red;
                    return;
                }

                String strProdID = this.objBelMes.GetProductID(strValidatedSerialNumber, strTestType);
                if (strProdID != "")
                {
                    if (!ProductsConfig.TestStationAllowed(strTestType, strProdID, this.objBelMes.Env.strTracePoint))
                    {
                        this.lbl_Info.Text      = String.Concat("Tento typ vyrobku nie je mozne testovat na tejto stanici. Zavolajte prosim leadera.");
                        this.lbl_Info.ForeColor = System.Drawing.Color.Purple;
                        return;
                    }
                }

                StationConfig.SerialNumberIP SNIPtoSAVE = new StationConfig.SerialNumberIP(); //SerialNumber In Process
                SNIPtoSAVE.ProductID = "";
                if (this.myStationConfig.IsInProcessAndDelete(strValidatedSerialNumber, strTestType, true))
                {
                    this.objBelMes.LastSerialNumber = "";
                    foreach (DataGridViewRow actrow in this.dgv_SNsIP.Rows)
                    {
                        if (actrow.Cells[0].Value.ToString().Trim() != strValidatedSerialNumber)
                        {
                            continue;
                        }

                        String actTestType = actrow.Cells[2].Value.ToString().Trim();
                        if (act_SNS != null)
                        {
                            Array.Resize(ref act_SNS.Steps, 0);
                        }

                        bool  nextSN = false;
                        Array ar_actTestInstructions = this.ProductsConfig.GetChildTestsInfos(actrow.Cells[1].Value.ToString().Trim(), strTestType);
                        if (ar_actTestInstructions.Length > 0)
                        {
                            frm_InstructionsOneByOne myInstructionsForm = new frm_InstructionsOneByOne();
                            myInstructionsForm.myStationConfig    = this.myStationConfig.StationConfigXML;
                            myInstructionsForm.actSN.SerialNumber = strValidatedSerialNumber;
                            myInstructionsForm.Instructions       = ar_actTestInstructions;

                            myInstructionsForm.OperatorName = str_OperatorNr;
                            myInstructionsForm.Item         = actrow.Cells[1].Value.ToString().Trim();
                            myInstructionsForm.StationName  = this.StationName;

                            this.Visible = false;

                            myInstructionsForm.ShowDialog();

                            this.Visible = true;

                            if (myInstructionsForm.Response == "TERMINATED")
                            {
                                if (this.objBelMes.SetActualResult(strValidatedSerialNumber, strTestType, "TERMINATED", ""))
                                {
                                    this.lbl_Info.ForeColor = System.Drawing.Color.Violet;
                                }
                                else
                                {
                                    this.lbl_Info.ForeColor = System.Drawing.Color.Red;
                                }
                                this.lbl_Info.Text = this.objBelMes.Authorization.strResult;

                                this.dgv_SNsIP.Rows.RemoveAt(actrow.Index);

                                this.lbl_Info.Text = this.objBelMes.Authorization.strResult;

                                continue;
                            }
                            else
                            {
                                this.act_SNS = myInstructionsForm.actSN;
                            }

                            /*
                             * foreach (DataGridViewRow actRow in myInstructionsForm.dgv_Instructions.Rows)
                             * {
                             *  StepInfo actSnStep = new StepInfo();
                             *  actSnStep.Name = actRow.Cells[0].Value.ToString().Trim();
                             *  while (actRow.Cells[0].Value.ToString().Trim() == "")
                             *  {
                             *      myInstructionsForm.ShowDialog();
                             *      if (myInstructionsForm.Response == "TERMINATED")
                             *      {
                             *          if (this.objBelMes.SetActualResult(strValidatedSerialNumber, strTestType, "TERMINATED", ""))
                             *          {
                             *              this.lbl_Info.ForeColor = System.Drawing.Color.Violet;
                             *          }
                             *          else
                             *          {
                             *              this.lbl_Info.ForeColor = System.Drawing.Color.Red;
                             *          }
                             *          this.lbl_Info.Text = this.objBelMes.Authorization.strResult;
                             *
                             *          break;
                             *      }
                             *  }
                             *  if (myInstructionsForm.Response == "TERMINATED")
                             *  {
                             *      nextSN = true;
                             *      break;
                             *  }
                             *
                             *  if (actRow.DefaultCellStyle.BackColor == Color.Green)
                             *  {
                             *      actSnStep.Grade = "PASS";
                             *  }
                             *  else
                             *  {
                             *      actSnStep.Grade = "FAIL";
                             *  }
                             *  if (actRow.Cells[2].ToolTipText != "")
                             *  {
                             *      actSnStep.ResultValue = actRow.Cells[2].ToolTipText;
                             *  }
                             *
                             * }
                             */
                            myInstructionsForm.Dispose();
                            if (nextSN)
                            {
                                continue;
                            }
                        }
                        this.GenerateReport(strValidatedSerialNumber, DateTime.Now);
                        dgv_SNsIP.Rows.Remove(actrow);
                        break;
                    }
                }
                else
                {
                    if (this.chb_JobIDChecking.Checked)
                    {
                        if (this.dgv_SNsIP.Rows.Count > 0)
                        {
                            String actJobID   = strValidatedSerialNumber.Substring(0, 8);
                            String tableJobID = this.dgv_SNsIP.Rows[0].Cells[0].Value.ToString().Trim().Substring(0, 8);
                            if (actJobID != tableJobID)
                            {
                                this.lbl_Info.Text        = String.Concat("Zoskenovane seriove cislo ", strValidatedSerialNumber, " nie je zo zakazky ", tableJobID, ".");
                                this.lbl_Info.ForeColor   = Color.Red;
                                this.tb_SerialNumber.Text = "";
                                this.tb_SerialNumber.Focus();
                                return;
                            }
                        }
                    }


                    this.objBelMes.BelMESAuthorization(strValidatedSerialNumber, strTestType, ref SNIPtoSAVE.ProductID, "", false);
                    Boolean hasInstructions = false;
                    if (this.objBelMes.Authorization.blnAuthorized)
                    {
                        SNIPtoSAVE.SerialNumber = strValidatedSerialNumber;
                        SNIPtoSAVE.TestType     = strTestType;
                        SNIPtoSAVE.Operator     = str_OperatorNr;
                        SNIPtoSAVE.StartTime    = DateTime.Now.ToString();
                        this.myStationConfig.SaveSerialNumberIP(SNIPtoSAVE);

                        String PassBtnText = "PASS";
                        Array  actCTIs     = ProductsConfig.GetChildTestsInfos(SNIPtoSAVE.ProductID, SNIPtoSAVE.TestType);
                        if (actCTIs.Length > 0)
                        {
                            PassBtnText     = "START";
                            hasInstructions = true;
                        }
                        this.dgv_SNsIP.Rows.Add(SNIPtoSAVE.SerialNumber, SNIPtoSAVE.ProductID, SNIPtoSAVE.TestType, SNIPtoSAVE.Operator, SNIPtoSAVE.StartTime, PassBtnText, "FAIL", "TERMINATE");
                        this.lbl_Info.ForeColor = Color.Green;
                    }
                    else
                    {
                        this.lbl_Info.ForeColor = Color.Red;

                        /*
                         * if (this.objBelMes.Authorization.blnMustTraced)
                         * {
                         *  this.lbl_Info.ForeColor = Color.Red;
                         * }
                         * else
                         * {
                         *  SNIPtoSAVE.SerialNumber = strValidatedSerialNumber;
                         *  SNIPtoSAVE.TestType = strTestType;
                         *  SNIPtoSAVE.Operator = str_OperatorNr;
                         *  SNIPtoSAVE.StartTime = DateTime.Now.ToString();
                         *  this.myStationConfig.SaveSerialNumberIP(SNIPtoSAVE);
                         *  this.dgv_SNsIP.Rows.Add(SNIPtoSAVE.SerialNumber, SNIPtoSAVE.ProductID, SNIPtoSAVE.TestType, SNIPtoSAVE.Operator, SNIPtoSAVE.StartTime, "PASS", "FAIL", "TERMINATE");
                         *  this.lbl_Info.ForeColor = Color.FromArgb(255, 150, 0);
                         * }
                         */
                    }
                    this.lbl_Info.Text = objBelMes.Authorization.strResult;
                    if (this.chb_ChecklistImmediatelyStart.Checked && hasInstructions)
                    {
                        if (this.lbl_Info.ForeColor == Color.Green)
                        {
                            this.tb_SerialNumber.Text = strValidatedSerialNumber;
                            this.tb_SerialNumber_KeyUp(new object(), new KeyEventArgs(Keys.Enter));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                this.lbl_Info.Text = ex.Message;
            }
            this.tb_SerialNumber.Clear();
            this.tb_SerialNumber.Focus();
        }