Пример #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
        public static bool DeleteCaseByIds(long[] ids, out string message, DataClassesDataContext db = null)
        {
            message = "";
            string idsStr = ids.ConvertToString();

            if (string.IsNullOrEmpty(idsStr))
            {
                return(true);
            }
            bool existsDb = true;
            bool existsTn = true;

            if (db == null)
            {
                existsDb = false;
                db       = new DataClassesDataContext();
            }
            if (db.Transaction == null)
            {
                db.Connection.Open();
                var tran = db.Connection.BeginTransaction();
                db.Transaction = tran;
                existsTn       = false;
            }
            try
            {
                List <案例信息> caseList = db.案例信息.Where(p => ids.Contains(p.ID) && p.是否已进行入库整理 == 1 && p.fxtId == null).ToList();
                bool        result   = ProjectCaseCountManager.UpdateNotImportCaseCount(caseList, new List <案例库上传信息过滤表>(), out message, new DataClass(db));
                if (!result)
                {
                    if (!existsTn)
                    {
                        db.Transaction.Rollback();
                    }
                    if (!existsDb)
                    {
                        db.Connection.Close();
                        db.Dispose();
                    }
                    return(false);
                }
                db.案例信息_DeleteByIds(idsStr);
                CaseFilterLogManager.DeleteCaseFilterByCaseIds(ids, db: db);
                if (!existsTn)
                {
                    db.Transaction.Commit();
                }
                if (!existsDb)
                {
                    db.Connection.Close();
                    db.Dispose();
                }
            }
            catch (Exception ex)
            {
                message = "系统异常";
                log.Debug(string.Format("删除案例信息失败,个数{0}", ids.Length));
                if (!existsTn)
                {
                    db.Transaction.Rollback();
                }
                if (!existsDb)
                {
                    db.Connection.Close();
                    db.Dispose();
                }
                return(false);
            }
            return(true);
        }