Esempio n. 1
0
        private void MonitoringRailTimeAsync(object sender, EventArgs e)
        {
            var result = _serviceTraceLog.GetListByMachineID(2, 1);

            TraceabilityLogModel log = result.Where(x => x.CreationDate.Date == DateTime.Now.Date).FirstOrDefault();

            //TraceabilityLogModel log = result.FirstOrDefault();
            if (log != null)
            {
                _view.traceabilityLog = _serviceTraceLog.GetByID(log.Id);
            }
        }
Esempio n. 2
0
        private void MonitoringRailTimeAsync(object sender, EventArgs e)
        {
            var result1 = _serviceTraceLog.GetListByMachineID(6, 1);
            var result2 = _serviceTraceLog.GetListByMachineID(7, 1);

            TraceabilityLogModel log1 = result1.Where(x => x.CreationDate.Date == DateTime.Now.Date).FirstOrDefault();
            TraceabilityLogModel log2 = result2.Where(x => x.CreationDate.Date == DateTime.Now.Date).FirstOrDefault();

            //TraceabilityLogModel log1 = result1.FirstOrDefault();
            //TraceabilityLogModel log2 = result2.FirstOrDefault();

            if (log1 != null)
            {
                _view.traceabilityUpperLog = _serviceTraceLog.GetByID(log1.Id);
                _view.CountQtyUpper        = _serviceTraceLog.GetListByMachineID(6, 500).Where(x => x.CreationDate.Date == DateTime.Now.Date).Count();
            }
            if (log2 != null)
            {
                _view.traceabilityLowerLog = _serviceTraceLog.GetByID(log2.Id);
                _view.CountQtyLower        = _serviceTraceLog.GetListByMachineID(7, 500).Where(x => x.CreationDate.Date == DateTime.Now.Date).Count();
            }
        }
Esempio n. 3
0
        public void LoadDetail(TraceabilityLogModel log)
        {
            //panelContainer.Controls.Clear();

            if (log.StationId == 1)
            {
                uCtrlStation1 uc = new uCtrlStation1();
                uc.MonitorFlag     = false;
                uc.traceabilityLog = log;
                uc.Height          = 264;
                uc.Dock            = DockStyle.Top;
                this.panelContainer.Controls.Add(uc);
            }

            if (log.StationId == 2)
            {
                uCtrlStation2 uc = new uCtrlStation2();
                uc.MonitorFlag     = false;
                uc.traceabilityLog = log;
                uc.Height          = 184;
                uc.Dock            = DockStyle.Top;
                this.panelContainer.Controls.Add(uc);
            }

            if (log.StationId == 3)
            {
                uCtrlStation3 uc = new uCtrlStation3();
                uc.MonitorFlag = false;
                if (log.MachineId == 3)
                {
                    uc.traceabilityUpperLog = log;
                }
                if (log.MachineId == 4)
                {
                    uc.traceabilityLowerLog = log;
                }
                uc.Dock = DockStyle.Top;
                this.panelContainer.Controls.Add(uc);
            }

            if (log.StationId == 4)
            {
                uCtrlStation4 uc = new uCtrlStation4();
                uc.MonitorFlag     = false;
                uc.traceabilityLog = log;
                uc.Height          = 316;
                uc.Dock            = DockStyle.Top;
                this.panelContainer.Controls.Add(uc);
            }

            if (log.StationId == 5)
            {
                uCtrlStation5 uc = new uCtrlStation5();
                uc.MonitorFlag = false;
                if (log.MachineId == 6)
                {
                    uc.traceabilityUpperLog = log;
                }
                if (log.MachineId == 7)
                {
                    uc.traceabilityLowerLog = log;
                }
                uc.Dock = DockStyle.Top;
                this.panelContainer.Controls.Add(uc);
            }
        }
Esempio n. 4
0
        private bool LoggingData(IEnumerable <ItemValueResult> r, MachineModel machine, IEnumerable <PlcTagModel> machineTags)
        {
            bool   result  = true;
            bool   invalid = false;
            string errMsg  = string.Empty;
            string tmpMsg  = string.Empty;

            TraceabilityLogModel trace = new TraceabilityLogModel();

            trace.StationId      = machine.StationId;
            trace.MachineId      = machine.Id;
            trace.Description    = "UPPER AGS FRAME";
            trace.ProductionDate = DateTime.Now;

            #region Validate and Default existing log by Item Code.
            var tagName  = _view.tagMainBlock + "ST3_1Code";
            var itemCode = r.Where(x => x.ItemName == tagName).FirstOrDefault().Value.ToString();
            WriteLog("KeepLogging" + _view.machine.Id + ".txt", String.Format("Item Code : {0}", itemCode));
            var loggings = _serviceTraceLog.GetListByItemCode(itemCode)
                           .Where(x => x.MachineId == machine.Id).ToList();

            //Exit if item code is null
            if (string.IsNullOrEmpty(itemCode))
            {
                return(true);
            }

            if (loggings.Count() > 0)
            {
                bool finishFlag = false;
                if (trace.FinalResult != 0)
                {
                    finishFlag = true;
                }

                trace            = _serviceTraceLog.GetByID(loggings.FirstOrDefault().Id);
                trace.FinishFlag = finishFlag;
            }
            #endregion

            foreach (var item in r)
            {
                tmpMsg = string.Empty;
                if (InvalidDataTag(item.Value.ToString(), item.ItemName, out tmpMsg))
                {
                    invalid = true;
                    if (!string.IsNullOrEmpty(errMsg))
                    {
                        errMsg += Environment.NewLine;
                    }

                    errMsg += tmpMsg;
                }

                if (!invalid)
                {
                    if (item.ItemName == _view.tagMainBlock + "ST3_1Code")
                    {
                        trace.ItemCode = item.Value.ToString();
                    }

                    if (item.ItemName == _view.tagMainBlock + "ST3_1TestResult[0]")
                    {
                        trace.Attribute1 = item.Value.ToString();
                    }

                    if (item.ItemName == _view.tagMainBlock + "ST3_1TestResult[1]")
                    {
                        trace.Jig = ConvertToInt(item.Value.ToString());
                    }

                    if (item.ItemName == _view.tagMainBlock + "ST3_1Final_Judgment")
                    {
                        if (Convert.ToInt32(item.Value) != 0)
                        {
                            trace.FinalResult = Convert.ToInt32(item.Value);
                        }
                    }

                    if (item.ItemName == _view.tagMainBlock + "ST3_1RepairTime")
                    {
                        trace.RepairTime = Convert.ToInt32(item.Value);
                    }

                    if (item.ItemName == _view.tagMainBlock + "ST3_1ModelRunning2")
                    {
                        trace.ModelRunningFlag = Convert.ToInt32(item.Value);
                    }
                }
            }

            if (invalid)
            {
                var mac = _view.machine;
                mac.MessageResult    = errMsg;
                _view.ResultnMessage = mac.MessageResult;
                mac.CompletedLogging = 3;
                _view.machine        = mac;
                result = false;
            }
            else if (!string.IsNullOrEmpty(trace.ItemCode))
            {
                TraceabilityLogModel logResult = new TraceabilityLogModel();
                if (trace.FinalResult != 0)
                {
                    trace.FinishFlag = true;
                }

                if (trace.Id == 0)
                {
                    try
                    {
                        _serviceTraceLog.Create(trace);
                        result = true;
                    }
                    catch
                    {
                        result = false;
                    }
                }
                else if (trace.Id != 0)
                {
                    try
                    {
                        _serviceTraceLog.Update(trace);
                        result = true;
                    }
                    catch
                    {
                        result = false;
                    }
                }
            }

            return(result);
        }