예제 #1
0
        /// <summary>
        /// 导入案例后统计未入库案例个数
        /// </summary>
        /// <param name="importCaseList">准备导入的案例</param>
        /// <param name="notImportCase">导入失败的案例</param>
        /// <param name="message"></param>
        /// <param name="_db"></param>
        /// <returns></returns>
        public static bool UpdateNotImportCaseCount(List <案例信息> importCaseList, List <案例库上传信息过滤表> notImportCase, out string message, DataClass _db = null)
        {
            message = "";
            DataClass db = new DataClass(_db);

            try
            {
                //设置案例楼盘ID,行政区ID,片区ID
                importCaseList = ProjectManager.SetProjectId(importCaseList, _dc: db);
                List <SysData_ProjectCaseCount> addCount    = new List <SysData_ProjectCaseCount>();
                List <SysData_ProjectCaseCount> updateCount = GetSysData_ProjectCaseCountByCase(importCaseList, _db: db);
                foreach (案例信息 caseObj in importCaseList)
                {
                    if (caseObj.fxtId != null)
                    {
                        continue;
                    }
                    bool nowObj = false;//true:新实体,false:存在实体
                    SysData_ProjectCaseCount countObj = updateCount.Where(tbl => tbl.ProjectId == Convert.ToInt64(caseObj.ProjectId) && tbl.AreaId == Convert.ToInt64(caseObj.AreaId)).FirstOrDefault();
                    //个数记录不存在
                    if (countObj == null)
                    {
                        countObj = addCount.Where(tbl => tbl.ProjectId == Convert.ToInt64(caseObj.ProjectId) && tbl.AreaId == Convert.ToInt64(caseObj.AreaId)).FirstOrDefault();
                        if (countObj == null)
                        {
                            nowObj   = true;
                            countObj = new SysData_ProjectCaseCount {
                                ProjectId = Convert.ToInt64(caseObj.ProjectId), AreaId = Convert.ToInt64(caseObj.AreaId), NotImportCaseCount = 0
                            };
                        }
                    }
                    案例库上传信息过滤表 notImport = notImportCase.Where(tbl => tbl.案例ID == caseObj.ID).FirstOrDefault();
                    //当前为导入成功的
                    if (notImport == null)
                    {
                        //当前案例为曾经导入失败的案例
                        if (caseObj.是否已进行入库整理 == 1 && countObj.NotImportCaseCount > 0)
                        {
                            countObj.NotImportCaseCount = countObj.NotImportCaseCount - 1;
                        }
                    }
                    else//当前为导入失败的
                    {
                        //当前案例为曾经导入失败的案例
                        if (caseObj.是否已进行入库整理 != 1)
                        {
                            countObj.NotImportCaseCount = countObj.NotImportCaseCount + 1;
                        }
                    }
                    if (nowObj)
                    {
                        addCount.Add(countObj);
                    }
                }
                db.DB.SysData_ProjectCaseCount.InsertAllOnSubmit(addCount);
                db.DB.SubmitChanges();
            }
            catch (Exception ex)
            {
                db.Connection_Close();
                db.Dispose();
                message = "导入案例后统计未入库案例个数_系统异常";
                log.Error("UpdateNotImportCaseCount(List<VIEW_案例信息_城市表_网站表> importCaseList, List<案例库上传信息过滤表> notImportCase,out string message, DataClass _db = null)", ex);

                return(false);
            }
            db.Connection_Close();
            db.Dispose();
            return(true);
        }
예제 #2
0
 /// <summary>
 /// 设置案例楼盘ID,行政区ID,片区ID
 /// </summary>
 /// <param name="_list"></param>
 /// <param name="_dc"></param>
 /// <returns></returns>
 public static List <VIEW_案例信息_城市表_网站表> SetProjectId(List <VIEW_案例信息_城市表_网站表> _list, DataClass _dc = null)
 {
     if (_list != null && _list.Count > 0)
     {
         List <long> longs = new List <long>();
         _list.ForEach(delegate(VIEW_案例信息_城市表_网站表 obj)
         {
             if ((!string.IsNullOrEmpty(obj.楼盘名.TrimBlank()) && obj.ProjectId == null) ||
                 (!string.IsNullOrEmpty(obj.行政区.TrimBlank()) && obj.AreaId == null) ||
                 !string.IsNullOrEmpty(obj.片区.TrimBlank()) && obj.SubAreaId == null)
             {
                 longs.Add(obj.ID);
             }
         });
         if (longs != null && longs.Count > 0)
         {
             DataClass   dc   = new DataClass(_dc);
             List <案例信息> list = dc.DB.案例信息.Where(p => longs.Contains(p.ID)).ToList();
             list.ForEach(delegate(案例信息 obj)
             {
                 if (!string.IsNullOrEmpty(obj.楼盘名.TrimBlank()) && obj.ProjectId == null)
                 {
                     SysData_Project project = ProjectManager.GetProjectByProjectNameAndCityId(obj.楼盘名.TrimBlank(), obj.城市ID, _db: dc);
                     if (project == null)
                     {
                         project = ProjectManager.InsertProject(obj.楼盘名, obj.城市ID, Convert.ToInt32(obj.网站ID), _db: dc);
                     }
                     obj.ProjectId = project.ID;
                     obj.楼盘名       = null;
                 }
                 if (!string.IsNullOrEmpty(obj.行政区.TrimBlank()) && obj.AreaId == null)
                 {
                     SysData_Area areaObj = AreaManager.GetAreaByAreaNameLikeByCityId(obj.行政区, obj.城市ID, _db: dc);
                     if (areaObj == null)
                     {
                         areaObj = AreaManager.InsertArea(obj.行政区, obj.城市ID, Convert.ToInt32(obj.网站ID), _db: dc);
                     }
                     obj.AreaId = areaObj.ID;
                     obj.行政区    = null;
                 }
                 else if (string.IsNullOrEmpty(obj.行政区.TrimBlank()) && obj.AreaId == null)
                 {
                     obj.AreaId = 0;
                     obj.行政区    = null;
                 }
                 if (!string.IsNullOrEmpty(obj.片区.TrimBlank()) && obj.SubAreaId == null)
                 {
                     SysData_SubArea subAreaObj = SubAreaManager.GetAreaByAreaNameByCityId(obj.片区, obj.城市ID, _db: dc);
                     if (subAreaObj == null)
                     {
                         subAreaObj = SubAreaManager.InsertArea(obj.片区, obj.城市ID, Convert.ToInt32(obj.网站ID), _db: dc);
                     }
                     obj.SubAreaId = subAreaObj.ID;
                     obj.片区        = null;
                 }
                 VIEW_案例信息_城市表_网站表 vObj = _list.Where(p => p.ID == obj.ID).FirstOrDefault();
                 if (vObj != null)
                 {
                     vObj.ProjectId = obj.ProjectId;
                     vObj.楼盘名       = obj.楼盘名;
                     vObj.AreaId    = obj.AreaId;
                     vObj.行政区       = obj.行政区;
                     vObj.SubAreaId = obj.SubAreaId;
                     vObj.片区        = obj.片区;
                 }
             });
             dc.DB.SubmitChanges();
             dc.Connection_Close();
             dc.Dispose();
         }
     }
     return(_list);
 }