void andonManager_andonAlertEvent(object sender, AndonAlertEventArgs e)
        {
            int recordId = -1;

            try
            {
                foreach (LogEntry lg in e.StationLog)
                {
                    if (lg.Department == 0)
                    {
                        dataAccess.updateActualQuantity(e.StationId, Convert.ToInt32(lg.Data));

                        tbMsg.Dispatcher.BeginInvoke(DispatcherPriority.Background,
                                                     new Action(() =>
                        {
                            tbMsg.Text += lines.getLineName(e.StationId) + ":" +
                                          "Production Quantity - " + lg.Data.ToString() + Environment.NewLine;
                        }));

                        continue;
                    }
                    String logMsg = String.Empty;

                    logMsg += lines.getLineName(e.StationId) + ":";

                    /*
                     * String stationName = lines.getStationName(e.StationId, lg.Station);
                     * if (stationName == string.Empty)
                     *  stationName = "Station #" + lg.Station.ToString();
                     *
                     * logMsg += stationName + ":";
                     */
                    logMsg += departmentTable.Rows[lg.Department - 1]["description"] + "-";
                    //if (lg.Department == 3)
                    //{
                    //    logMsg += "PART #" + lg.Data;
                    //}
                    //else
                    //{

                    //    String className = lines.getClassName(e.StationId, lg.Station,
                    //                    lg.Department, Convert.ToInt32(lg.Data));

                    //    if (className == String.Empty)
                    //        lg.Data = "Class Code #" + Convert.ToInt32(lg.Data);
                    //    else lg.Data = className;

                    //    logMsg += "--" + lg.Data;
                    //}



                    recordId = dataAccess.findIssueRecord(e.StationId, lg.Station, lg.Department, lg.Data);



                    if (recordId == -1)     //new issue
                    {
                        recordId =
                            dataAccess.insertIssueRecord(e.StationId, lg.Station, lg.Department, lg.Data, logMsg);

                        Issue issue = new Issue(e.StationId, lg.Station, lg.Department, logMsg, timeout);
                        issue.issueEscalationEvent += new EventHandler <issueEscalateEventArgs>(issue_issueEscalationEvent);

                        Issues.Add(recordId, issue);

                        issue.raise();

                        logMsg += "--Issue Raised at " + DateTime.Now.ToString("HH:mm:ss dd-MM-yyyy");
                    }
                    else
                    {
                        dataAccess.updateIssueStatus(recordId);

                        if (Issues.ContainsKey(recordId))
                        {
                            Issues[recordId].resolve();
                            Issues.Remove(recordId);
                        }

                        logMsg += "--Issue Resolved";
                    }
                    dataAccess.updateIssueMarquee();
                    tbMsg.Dispatcher.BeginInvoke(DispatcherPriority.Background,
                                                 new Action(() => { tbMsg.Text += logMsg + Environment.NewLine; }));
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + Environment.NewLine + ex.StackTrace, "Error", MessageBoxButton.OK);
            }
        }
示例#2
0
        void andonManager_andonAlertEvent(object sender, AndonAlertEventArgs e)
        {
            int recordId = -1;
            int cmd;
            int line;

            try
            {
                cmd = e.StationLog[0];

                e.StationLog.RemoveAt(0);
                switch (cmd)
                {
                case (int)CMD.SYNCHRONIZE:
                    List <Byte> rtcData = new List <byte>();
                    DateTime    now     = DateTime.Now;
                    rtcData.Add(intToBCD(now.Second));
                    rtcData.Add(intToBCD(now.Minute));
                    rtcData.Add(intToBCD(now.Hour));

                    rtcData.Add((byte)(now.DayOfWeek + 1));
                    rtcData.Add(intToBCD(now.Day));
                    rtcData.Add(intToBCD(now.Month));
                    rtcData.Add(intToBCD(now.Year - 2000));
                    andonManager.addTransaction(01, AndonCommand.CMD_SET_RTC, rtcData);
                    break;


                case (int)CMD.SET_REFERENCE:
                    line = e.StationLog[0];
                    e.StationLog.RemoveAt(0);
                    char[] refe = new char[e.StationLog.Count - 1];
                    for (int i = 0; i < e.StationLog.Count - 1; i++)
                    {
                        refe[i] = (char)e.StationLog[i];
                    }

                    reference.Code = new String(refe);

                    updateMsg("SET REFERENCE for line:" + LINES[line - 2] + "-" + reference.Code);

                    break;


                case (int)CMD.SET_REFERENCE_CODE:
                    line = e.StationLog[0];
                    e.StationLog.RemoveAt(0);
                    char[] code = new char[e.StationLog.Count - 1];
                    for (int i = 0; i < e.StationLog.Count - 1; i++)
                    {
                        code[i] = (char)e.StationLog[i];
                    }

                    reference.Code = new String(code);

                    reference = dataAccess.getReference(line, reference);
                    if (reference.Name == String.Empty)
                    {
                        updateMsg("Invalid Code for:" + LINES[line - 2] + "-" + reference.Code);
                    }
                    else
                    {
                        updateMsg("Setting Reference for line:" + LINES[line - 2] + "-" + reference.Name);
                        var data = new List <Byte>();
                        data.Add((Byte)line);
                        data.AddRange(new List <Byte>(Encoding.ASCII.GetBytes(reference.Name)));
                        andonManager.addTransaction(01, AndonCommand.CMD_SET_REFERENCE, data);
                    }


                    break;



                case (int)CMD.SET_OPERATORS:
                    //line = e.StationId;
                    //int operators = e.StationLog[0];
                    //updateMsg("SET CYCLE TIME for line:" + LINES[line - 2]+"-"+operators.ToString());
                    break;

                case (int)CMD.GET_CYCLE_TIME:
                    line      = e.StationId;
                    reference = dataAccess.getCycleTime(line, reference);
                    updateMsg("Setting Cycle Time for line:" + LINES[line - 2]);
                    if (reference.CycleTime != 0 && reference.BottleNeckTime != 0)
                    {
                        byte[] ct = BitConverter.GetBytes((short)reference.CycleTime);
                        byte[] bt = BitConverter.GetBytes((short)reference.BottleNeckTime);

                        var data = new List <Byte>();
                        data.Add((byte)line);
                        data.AddRange(ct.ToList());
                        data.AddRange(bt.ToList());

                        andonManager.addTransaction(01, AndonCommand.CMD_SET_CYCLE_TIME, data);
                    }

                    break;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + Environment.NewLine + ex.StackTrace, "Error", MessageBoxButton.OK);
            }
        }