Esempio n. 1
0
 /// <summary>
 /// 删除服务包相关,不能删除时,返回所有不能删除相关对象数量
 /// </summary>
 public bool DeleteServiceBundle(long serviceId, long userId, ref string faileReason)
 {
     try
     {
         var isbDal        = new ivt_service_bundle_dal();
         var thisSerBundle = isbDal.FindNoDeleteById(serviceId);
         if (thisSerBundle == null)
         {
             return(true);
         }
         var conSerList = new ctt_contract_service_dal().getContractByServiceId(thisSerBundle.id);
         if (conSerList != null && conSerList.Count > 0)
         {
             faileReason += $"{conSerList.Count} 合同\n";
         }
         var quoteItemList = new crm_quote_item_dal().GetItemByObjId(thisSerBundle.id);
         if (quoteItemList != null && quoteItemList.Count > 0)
         {
             faileReason += $"{quoteItemList.Count} 报价项\n";
         }
         var labourList = new sdk_work_entry_dal().GetListByService(thisSerBundle.id);
         if (labourList != null && labourList.Count > 0)
         {
             faileReason += $"{labourList.Count} 工时\n";
         }
         var insProList = new crm_installed_product_dal().GetInsListBySerBunId(thisSerBundle.id);
         if (insProList != null && insProList.Count > 0)
         {
             faileReason += $"{insProList.Count} 配置项\n";
         }
         if (!string.IsNullOrEmpty(faileReason))
         {
             return(false);
         }
         else
         {
             var isbsDal = new ivt_service_bundle_service_dal();
             var serList = GetServiceListByServiceBundleId(thisSerBundle.id);
             if (serList != null && serList.Count > 0)
             {
                 serList.ForEach(_ => {
                     isbsDal.Delete(_);
                 });
             }
             isbDal.SoftDelete(thisSerBundle, userId);
             OperLogBLL.OperLogDelete <ivt_service_bundle>(thisSerBundle, thisSerBundle.id, userId, DTO.DicEnum.OPER_LOG_OBJ_CATE.IVT_SERVICE_BUNDLE, "删除服务包");
         }
     }
     catch (Exception)
     {
         return(false);
     }
     return(true);
 }
Esempio n. 2
0
        /// <summary>
        /// 服务包的服务管理
        /// </summary>
        public void ServiceBundleManage(long serBunId, string serIds, long userId)
        {
            var isbsDal  = new ivt_service_bundle_service_dal();
            var serList  = GetServiceListByServiceBundleId(serBunId);
            var serIdArr = serIds.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

            if (serList != null && serList.Count > 0)
            {
                foreach (var serId in serIdArr)
                {
                    var thisSer = serList.FirstOrDefault(_ => _.service_id.ToString() == serId);
                    if (thisSer != null)
                    {
                        serList.Remove(thisSer);
                    }
                    else
                    {
                        isbsDal.Insert(new ivt_service_bundle_service()
                        {
                            id = isbsDal.GetNextIdCom(),
                            service_bundle_id = serBunId,
                            service_id        = long.Parse(serId),
                        });
                    }
                }
                if (serList.Count > 0)
                {
                    serList.ForEach(_ => {
                        isbsDal.Delete(_);
                    });
                }
            }
            else
            {
                foreach (var serId in serIdArr)
                {
                    isbsDal.Insert(new ivt_service_bundle_service()
                    {
                        id = isbsDal.GetNextIdCom(),
                        service_bundle_id = serBunId,
                        service_id        = long.Parse(serId),
                    });
                }
            }
        }