Пример #1
0
        private static tblLotAttributeHistory CreateNewLotHistoryRecord(tblLot lot)
        {
            var history = new tblLotAttributeHistory
            {
                Lot         = lot.Lot,
                ArchiveDate = DateTime.UtcNow.ConvertUTCToLocal().RoundMillisecondsForSQL(),
                EmployeeID  = lot.EmployeeID,
                EntryDate   = lot.EntryDate,

                Notes = lot.Notes,

                TestDate  = lot.TestDate,
                TesterID  = lot.TesterID,
                TestNotes = lot.TestNotes,

                LotStat = lot.LotStat,
                LoBac   = lot.LoBac
            };

            foreach (var attribute in StaticAttributeNames.AttributeNames)
            {
                var get = lot.AttributeGet(attribute);
                var set = history.AttributeSet(attribute);

                if (get != null && set != null)
                {
                    set(get());
                }
            }

            return(history);
        }
Пример #2
0
        private static bool CommitLotHistory(tblLot lot, tblLotAttributeHistory history)
        {
            if (lot.LotStat != history.LotStat)
            {
                return(true);
            }

            if (lot.TestDate != history.TestDate)
            {
                return(true);
            }

            if (lot.TesterID != history.TesterID)
            {
                return(true);
            }

            foreach (var attribute in StaticAttributeNames.AttributeNames)
            {
                var lotGet     = lot.AttributeGet(attribute);
                var historyGet = history.AttributeGet(attribute);

                if (historyGet != null)
                {
                    var lotValue     = lotGet == null ? null : lotGet();
                    var historyValue = historyGet();

                    if (lotValue != null || historyValue != null)
                    {
                        if (lotValue == null || historyValue == null)
                        {
                            return(true);
                        }

                        if (Math.Abs(lotValue.Value - historyValue.Value) > 0.01m)
                        {
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }