Example #1
0
        /// <summary>
        /// 保存富士II类信息
        /// </summary>
        /// <param name="info">关联信息</param>
        /// <param name="isUpdate">是否更新</param>
        /// <param name="copyID">复制的II类id</param>
        /// <returns>富士II类id</returns>
        public JsonResult SaveFujiClass2(FujiClassLink info, bool isUpdate, int copyID = 0)
        {
            if (CheckSession() == false)
            {
                return(Json(ResultModelBase.CreateTimeoutModel(), JsonRequestBehavior.AllowGet));
            }
            if (CheckSessionID() == false)
            {
                return(Json(ResultModelBase.CreateLogoutModel(), JsonRequestBehavior.AllowGet));
            }

            ResultModelBase result = new ResultModelBase();

            try
            {
                this.fujiClassManager.SaveFujiClass2(info, GetLoginUser(), isUpdate, copyID);
            }
            catch (Exception ex)
            {
                NLog.LogManager.GetCurrentClassLogger().Error(ex, ex.Message);
                result.SetFailed(ResultCodes.SystemError, ControlManager.GetSettingInfo().ErrorMessage);
            }

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Example #2
0
        /// <summary>
        /// 根据富士II类id获取关联信息
        /// </summary>
        /// <param name="id">富士II类id</param>
        /// <returns>关联信息</returns>
        public FujiClassLink GetFujiLinkByClass2ID(int id)
        {
            FujiClassLink info = this.fujiClassDao.GetFujiLinkByClass2ID(id);

            info.FujiClass2.Repairs = this.faultRateDao.GetFaultRateByObject(id, FaultRateInfo.ObjectType.Repair);

            SetFujiClass2Rate(info.FujiClass2);
            return(info);
        }
Example #3
0
        public void DeleteFujiClass2ByLink(FujiClassLink info)
        {
            this.fujiClassDao.DeleteFujiClass2Link(info);

            if (!this.fujiClassDao.CheckFujiClass2LinkExisted(info))
            {
                this.faultRateDao.DeleteFaultRateByObjID(info.FujiClass2.ID, FaultRateInfo.ObjectType.Repair);
                this.consumableDao.DeleteConsumableByFujiClass2ID(info.FujiClass2.ID);
                FujiClass2Info fujiClass2 = this.GetFujiClass2ByID(info.FujiClass2.ID);
                foreach (ComponentInfo component in fujiClass2.Components)
                {
                    this.componentManager.DeleteComponentByID(component.ID);
                }
                this.fujiClassDao.DeleteFujiClass2ByID(info.FujiClass2.ID);
            }
        }
Example #4
0
        public JsonResult DeleteFujiClass2ByLink(FujiClassLink info)
        {
            if (CheckSession(false) == false)
            {
                return(Json(ResultModelBase.CreateTimeoutModel(), JsonRequestBehavior.AllowGet));
            }
            if (CheckSessionID() == false)
            {
                return(Json(ResultModelBase.CreateLogoutModel(), JsonRequestBehavior.AllowGet));
            }
            ResultModel <bool> result = new ResultModel <bool>();

            try
            {
                this.fujiClassManager.DeleteFujiClass2ByLink(info);
            }
            catch (Exception ex)
            {
                NLog.LogManager.GetCurrentClassLogger().Error(ex, ex.Message);
                result.SetFailed(ResultCodes.SystemError, ControlManager.GetSettingInfo().ErrorMessage);
            }
            return(JsonResult(result));
        }
Example #5
0
 public void DeleteFujiClassLink(FujiClassLink info)
 {
     this.fujiClassDao.DeleteFujiClassLink(info);
 }
Example #6
0
        public int SaveFujiClass2(FujiClassLink info, UserInfo userInfo, bool isUpdate, int copyID = 0)
        {
            List <AuditHdrInfo> audits = new List <AuditHdrInfo>();
            AuditHdrInfo        audit;

            if (info.FujiClass2.ID == 0)
            {
                if (copyID != 0)
                {
                    FujiClass2Info copyInfo = this.GetFujiClass2ByID(copyID);
                    copyInfo.FujiClass1  = info.FujiClass2.FujiClass1;
                    copyInfo.Name        = info.FujiClass2.Name;
                    copyInfo.Description = info.FujiClass2.Description;
                    info.FujiClass2.ID   = this.fujiClassDao.AddFujiClass2(copyInfo);
                    this.fujiClassDao.AddFujiClass2EqpType(info);
                    copyInfo.Repairs.ForEach(rate => rate.ObjectID = info.FujiClass2.ID);
                    this.AddFaultRates(copyInfo.Repairs);
                    if (copyInfo.Components.Count > 0)
                    {
                        foreach (ComponentInfo componentInfo in copyInfo.Components)
                        {
                            componentInfo.ID            = 0;
                            componentInfo.FujiClass2.ID = info.FujiClass2.ID;
                            this.componentManager.SaveComponent(componentInfo, userInfo);
                        }
                    }
                    if (copyInfo.Consumables.Count > 0)
                    {
                        foreach (ConsumableInfo consumableInfo in copyInfo.Consumables)
                        {
                            consumableInfo.ID            = 0;
                            consumableInfo.FujiClass2.ID = info.FujiClass2.ID;
                            this.consumableDao.AddConsumable(consumableInfo);
                        }
                    }
                }
                else
                {
                    this.fujiClassDao.AddFujiClass2(info.FujiClass2);
                    this.fujiClassDao.AddFujiClass2EqpType(info);
                    info.FujiClass2.Repairs = FaultRateInfo.GetInitList(info.FujiClass2.ID, FaultRateInfo.ObjectType.Repair);
                    this.AddFaultRates(info.FujiClass2.Repairs);
                }
                audit = info.ConvertAudit(userInfo);
                if (audit.DetailInfo.Count > 0)
                {
                    audits.Add(audit);
                }
            }
            else
            {
                FujiClassLink existsInfo = this.GetFujiLinkByClass2ID(info.FujiClass2.ID);
                if (isUpdate)
                {
                    info.FujiClass2.CheckEquipmentTypeRelatedFields();
                    this.fujiClassDao.UpdateFujiClass2(info.FujiClass2);
                    this.UpdateFaultRates(info.FujiClass2.Repairs);

                    audit            = existsInfo.FujiClass2.ConvertAudit(info.FujiClass2, userInfo);
                    audit.DetailInfo = audit.DetailInfo.Concat(FaultRateInfo.ConvertAuditDetail(existsInfo.FujiClass2.Repairs, info.FujiClass2.Repairs)).ToList();
                    if (audit.DetailInfo.Count > 0)
                    {
                        audits.Add(audit);
                    }

                    int componentLen = info.FujiClass2.Components.Count;
                    info.FujiClass2.Components.Sort();
                    existsInfo.FujiClass2.Components.Sort();
                    info.FujiClass2.Consumables.Sort();
                    existsInfo.FujiClass2.Consumables.Sort();
                    for (int i = 0; i < componentLen; i++)
                    {
                        this.componentDao.UpdateComponent(info.FujiClass2.Components[i]);
                        audit = existsInfo.FujiClass2.Components[i].ConvertAudit(info.FujiClass2.Components[i], userInfo);
                        if (audit.DetailInfo.Count > 0)
                        {
                            audits.Add(audit);
                        }
                    }
                    componentLen = info.FujiClass2.Consumables.Count;
                    for (int i = 0; i < componentLen; i++)
                    {
                        this.consumableDao.UpdateConsumable(info.FujiClass2.Consumables[i]);
                        audit = existsInfo.FujiClass2.Consumables[i].ConvertAudit(info.FujiClass2.Consumables[i], userInfo);
                        if (audit.DetailInfo.Count > 0)
                        {
                            audits.Add(audit);
                        }
                    }
                }
                else
                {
                    this.fujiClassDao.AddFujiClass2EqpType(info);
                    audit = info.ConvertAudit(userInfo);
                    if (audit.DetailInfo.Count > 0)
                    {
                        audits.Add(audit);
                    }
                }
            }

            int len = audits.Count;

            if (len == 0)
            {
                return(info.FujiClass2.ID);
            }
            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);

            return(info.FujiClass2.ID);
        }