Пример #1
0
        /// <summary>
        /// 更新入库失败案例的楼盘名称
        /// </summary>
        /// <param name="projectName"></param>
        /// <param name="cityId"></param>
        /// <param name="projectId"></param>
        /// <param name="areaId">无行政区时则传0</param>
        /// <param name="_dc"></param>
        /// <returns></returns>
        public static bool UpdateImportFailCaseProjectBy(string projectName, int cityId, long projectId, long areaId, out string message, DataClass _dc = null)
        {
            message = "";
            if (string.IsNullOrEmpty(projectName))
            {
                return(true);
            }
            DataClass dc = new DataClass(_dc);

            try
            {
                string          sql     = " update 案例信息 set ProjectId={0} , 楼盘名=null where 城市ID={1} and ProjectId={2} and {3} and 是否已进行入库整理=1 and fxtId is null ";
                SysData_Project project = ProjectManager.GetProjectByProjectNameAndCityId(projectName, cityId, _db: dc);
                if (project == null)
                {
                    project = ProjectManager.InsertProject(projectName, cityId, 0, _db: dc);
                }
                if (areaId > 0)
                {
                    sql = string.Format(sql, project.ID, cityId, projectId, "AreaId=" + areaId);
                }
                else
                {
                    sql = string.Format(sql, project.ID, cityId, projectId, "(AreaId is null or AreaId=0)");
                }
                int count = dc.DB.ExecuteCommand(sql);
                ProjectCaseCountManager.UpdateNotImportCaseCount(projectId, areaId, -count, _db: dc);
                ProjectCaseCountManager.UpdateNotImportCaseCount(project.ID, areaId, count, _db: dc);
            }
            catch (Exception ex)
            {
                message = "更新入库失败案例楼盘名称_系统异常";
                log.Error("UpdateImportFailCaseProjectBy异常", ex);
                dc.Connection_Close();
                dc.Dispose();
                return(false);
            }
            dc.Connection_Close();
            dc.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);
 }