Ejemplo n.º 1
0
        public void UpdateComponents(List <ComponentInfo> infos, UserInfo userInfo)
        {
            List <ComponentInfo> existsInfos = this.QueryComponentsByIDs(infos.Select(info => info.ID).ToList());

            foreach (ComponentInfo info in infos)
            {
                this.componentDao.UpdateComponent(info);
            }
            DataTable dt = FaultRateInfo.ConvertFaultRateDataTable(infos.SelectMany(component => component.FaultRates).ToList());

            this.faultRateDao.UpdateFaultRates(dt);

            // 零件转换日志信息

            infos.Sort();
            existsInfos.Sort();
            List <AuditHdrInfo> audits = new List <AuditHdrInfo>();
            int len = existsInfos.Count;

            for (int i = 0; i < len; i++)
            {
                AuditHdrInfo audit = existsInfos[i].ConvertAudit(infos[i], userInfo);
                audit.DetailInfo = audit.DetailInfo.Concat(FaultRateInfo.ConvertAuditDetail(existsInfos[i].FaultRates, infos[i].FaultRates)).ToList();
                //if(audit.DetailInfo.Count>0)
                audits.Add(audit);
            }
            DataTable auditDT       = audits.ConvertAuditDT();
            DataTable auditDetailDT = null;

            this.auditDao.AddAuditHdr(auditDT);
            for (int i = 0; i < len; i++)
            {
                if (auditDetailDT == null)
                {
                    auditDetailDT = audits[i].DetailInfo.ConvertAuditDetailDT(SQLUtil.ConvertInt(auditDT.Rows[i]["ID"]));
                }
                else
                {
                    auditDetailDT.Merge(audits[i].DetailInfo.ConvertAuditDetailDT(SQLUtil.ConvertInt(auditDT.Rows[i]["ID"])));
                }
            }
            this.auditDao.AddAuditDetail(auditDetailDT);
        }
Ejemplo n.º 2
0
        public int SaveComponent(ComponentInfo info, UserInfo userInfo)
        {
            if (info.ID == 0)
            {
                info.ID = this.componentDao.AddComponent(info);
                if (info.FaultRates.Count == 0)
                {
                    info.FaultRates = FaultRateInfo.GetInitList(info.ID, FaultRateInfo.ObjectType.Component);
                }
                else
                {
                    info.FaultRates.ForEach(faultRate => faultRate.ObjectID = info.ID);
                }
                this.faultRateDao.AddFaultRates(FaultRateInfo.ConvertFaultRateDataTable(info.FaultRates));
            }
            else
            {
                ComponentInfo existingInfo = this.componentDao.GetComponentByID(info.ID);
                existingInfo.FaultRates = this.faultRateDao.GetFaultRateByObject(existingInfo.ID, FaultRateInfo.ObjectType.Component);
                info.FujiClass2.Name    = this.fujiClassDao.GetFujiClass2ByID(info.FujiClass2.ID).Name;
                DataTable dtField = existingInfo.GetChangedFields(info);

                if (dtField.Rows.Count > 0)
                {
                    this.componentDao.UpdateComponent(info);

                    this.faultRateDao.UpdateFaultRates(FaultRateInfo.ConvertFaultRateDataTable(info.FaultRates));
                    // 转换故障率信息
                    if (info.FaultRates.Count != 0 && existingInfo.FaultRates.Count != 0)
                    {
                        dtField.Merge(FaultRateInfo.ConvertAuditDetail(existingInfo.FaultRates, info.FaultRates).ConvertAuditDetailDT(0));
                    }
                    this.auditManager.AddAuditLog(userInfo.ID, ObjectTypes.Component, info.ID, dtField);
                }
            }

            return(info.ID);
        }
Ejemplo n.º 3
0
        public void UpdateFaultRates(List <FaultRateInfo> infos)
        {
            DataTable dt = FaultRateInfo.ConvertFaultRateDataTable(infos);

            this.faultRateDao.UpdateFaultRates(dt);
        }