public int InfoCount()
 {
     using (var context = new FxHouseContext())
     {
         return context.HouseBuyInfos.Count() + context.HouseTransferInfos.Count();
     }
 }
 /// <summary>
 /// 房屋帖子数量(求购+转让)
 /// </summary>
 /// <returns></returns>
 public int InfoCount()
 {
     using (var context = new FxHouseContext())
     {
         return(context.HouseBuyInfos.Count() + context.HouseTransferInfos.Count());
     }
 }
Beispiel #3
0
 /// <summary>
 /// 获取房屋求购信息
 /// </summary>
 /// <param name="Id">房屋求购Id</param>
 /// <returns>房屋求购信息</returns>
 public Entity.FxHouse.HouseBuyInfo Get(int Id)
 {
     using (FxHouseContext context = new FxHouseContext())
     {
         return(context.HouseBuyInfos.Where(r => r.HouseBuyInfoId == Id).FirstOrDefault());
     }
 }
 public Entity.FxHouse.HouseBuyInfo Get(int Id)
 {
     using (FxHouseContext context = new FxHouseContext())
     {
         return context.HouseBuyInfos.Where(r => r.HouseBuyInfoId == Id).FirstOrDefault();
     }
 }
 public void CreateHouse()
 {
     //System.Data.Entity.Database.SetInitializer(new FxHouseInitializer());
     FxHouseContext context = new FxHouseContext();
     var entity = new Fx.Entity.FxHouse.HouseBuyInfo()
     {
         Action = "Action",
         AreaId = 1,
         Bill = false,
         CatagroyId = 1,
         CityId = 1,
         Controller = "Controller",
         HasFurniture = false,
         Mark = "Mark",
         Price = 1000,
         PublishTitle = "Title",
         PublishUserEmail = "PublishUserEmail",
         RoomNumber = 6,
         UserAccount = "UserAccount"
     };
     context.HouseBuyInfos.Add(entity);
     context.SaveChanges();
     context.HouseBuyInfos.Remove(entity);
     context.SaveChanges();
 }
 public Entity.FxHouse.HouseTransferInfo Get(int Id)
 {
     using (FxHouseContext context = new FxHouseContext())
     {
         return context.HouseTransferInfos.Include(r => r.Pictures)
             .Where(r => r.HouseTransferInfoId == Id).FirstOrDefault();
     }
 }
Beispiel #7
0
 /// <summary>
 /// 获取房屋转让信息
 /// </summary>
 /// <param name="Id">房屋转让Id</param>
 /// <returns>房屋转让信息</returns>
 public Entity.FxHouse.HouseTransferInfo Get(int Id)
 {
     using (FxHouseContext context = new FxHouseContext())
     {
         return(context.HouseTransferInfos.Include(r => r.Pictures)
                .Where(r => r.HouseTransferInfoId == Id).FirstOrDefault());
     }
 }
 public bool SaveBuyHouse(Entity.FxHouse.HouseBuyInfo house)
 {
     using (FxHouseContext context = new FxHouseContext())
     {
         context.HouseBuyInfos.Add(house);
         context.SaveChanges();
     }
     return house.HouseBuyInfoId > 0;
 }
Beispiel #9
0
 /// <summary>
 /// 保存房屋求购信息
 /// </summary>
 /// <param name="house">房屋求购信息</param>
 /// <returns>是否保存成功</returns>
 public bool SaveBuyHouse(Entity.FxHouse.HouseBuyInfo house)
 {
     using (FxHouseContext context = new FxHouseContext())
     {
         context.HouseBuyInfos.Add(house);
         context.SaveChanges();
     }
     return(house.HouseBuyInfoId > 0);
 }
Beispiel #10
0
 /// <summary>
 /// 保存房屋转让信息
 /// </summary>
 /// <param name="house">房屋转让信息</param>
 /// <returns>是否保存成功</returns>
 public bool SaveTransferHouse(HouseTransferInfo house)
 {
     using (var context = new FxHouseContext())
     {
         context.HouseTransferInfos.Add(house);
         context.SaveChanges();
     }
     return(house.HouseTransferInfoId > 0);
 }
 public bool SaveTransferHouse(HouseTransferInfo house)
 {
     using (var context = new FxHouseContext())
     {
         context.HouseTransferInfos.Add(house);
         context.SaveChanges();
     }
     return house.HouseTransferInfoId > 0;
 }
 public void Authorize()
 {
     int houseId = JobQueue.HouseBuyJobLoadQueue.GetItem(houseBuyJobService.Authorizing);
     if (houseId == 0)
     {
         return;
     }
     using (var context = new FxHouseContext())
     {
         while (houseId != 0)
         {
             var house = context.HouseBuyInfos.Where(r => r.HouseBuyInfoId == houseId).
                     Select(r => new { r.Mark, r.PublishTitle }).FirstOrDefault();
             if (house != null)
             {
                 if (filter.FilterContent(house.Mark).Success && filter.FilterContent(house.PublishTitle).Success)
                 {
                     try
                     {
                         houseBuyJobService.AuthorizeSuccess(houseId);
                         houseBuyJobService.Publish(houseId);
                     }
                     catch (Exception ex)
                     {
                         ex.LogEx(string.Format("{0} {1} {2}", JobKey, "houseBuyJobService.AuthorizeSuccess", houseId));
                     }
                 }
                 else
                 {
                     try
                     {
                         string msg = "";
                         var filter1 = filter.FilterContent(house.Mark);
                         var filter2 = filter.FilterContent(house.PublishTitle);
                         if (!filter1.Success)
                         {
                             msg += string.Format("你的帖子中包含了[[{0}]] 这个关键字", filter1.Key);
                         }
                         if (!filter2.Success)
                         {
                             msg += string.Format("你的帖子中包含了[[{0}]] 这个关键字", filter2.Key);
                         }
                         houseBuyJobService.AuthorizeFaild(houseId,msg);
                     }
                     catch (Exception ex)
                     {
                         ex.LogEx(string.Format("{0} {1} {2}", JobKey, "houseBuyJobService.AuthorizeFaild", houseId));
                     }
                 }
                 houseId = JobQueue.HouseBuyJobLoadQueue.GetItem(houseBuyJobService.Authorizing);
             }
         }
     }
 }
 /// <summary>
 /// 居住用房列表
 /// </summary>
 /// <returns></returns>
 public List<HouseTransferInfo> Properties()
 {
     List<HouseTransferInfo> list;
     using (FxHouseContext context = new FxHouseContext())
     {
         list = context.HouseTransferInfos.Include(r => r.Pictures)
         .Where(r => r.IsPublish == true && r.Action == "Properties")
         .OrderByDescending(r => r.CreatedTime)
         .Take(20).ToList();
     }
     if ((list.Count % 4) != 0)
     {
         return list.Take(list.Count - list.Count % 4).ToList();
     }
     return list;
 }
 /// <summary>
 /// 认证成功
 /// </summary>
 /// <param name="houseId">房屋转让帖子Id</param>
 /// <returns>操作是否成功</returns>
 public bool AuthorizeSuccess(int houseId)
 {
     using (var context = new FxHouseContext())
     {
         var house = context.HouseTransferInfos.Where(r => r.HouseTransferInfoId == houseId).FirstOrDefault();
         if (house != null)
         {
             house.InfoProcessState = (int)ProcessState.AuthorizeSuccess;
             house.Logs.Add(new Entity.FxHouse.HouseTransferLog()
             {
                 OperteName = Enum.GetName(typeof(ProcessState), ProcessState.AuthorizeSuccess)
             });
             return context.SaveChanges() > 0;
         }
     }
     return false;
 }
 /// <summary>
 /// 图片CDN中...
 /// </summary>
 /// <param name="houseId">房屋转让帖子Id</param>
 /// <returns>操作是否成功</returns>
 public bool PictrueCdning(int houseId)
 {
     using (var context = new FxHouseContext())
     {
         var house = context.HouseTransferInfos.Where(r => r.HouseTransferInfoId == houseId).FirstOrDefault();
         if (house != null)
         {
             house.InfoProcessState = (int)ProcessState.PictrueCdning;
             house.Logs.Add(new Entity.FxHouse.HouseTransferLog()
             {
                 OperteName = Enum.GetName(typeof(ProcessState), ProcessState.PictrueCdning)
             });
             return(context.SaveChanges() > 0);
         }
     }
     return(false);
 }
        /// <summary>
        /// 居住用房列表
        /// </summary>
        /// <returns></returns>
        public List <HouseTransferInfo> Properties()
        {
            List <HouseTransferInfo> list;

            using (FxHouseContext context = new FxHouseContext())
            {
                list = context.HouseTransferInfos.Include(r => r.Pictures)
                       .Where(r => r.IsPublish == true && r.Action == "Properties")
                       .OrderByDescending(r => r.CreatedTime)
                       .Take(20).ToList();
            }
            if ((list.Count % 4) != 0)
            {
                return(list.Take(list.Count - list.Count % 4).ToList());
            }
            return(list);
        }
 /// <summary>
 /// 认证失败
 /// </summary>
 /// <param name="houseId">房屋转让帖子Id</param>
 /// <param name="msg">认证失败错误信息</param>
 /// <returns>操作是否成功</returns>
 public bool AuthorizeFaild(int houseId, string msg)
 {
     using (var context = new FxHouseContext())
     {
         var house = context.HouseTransferInfos.Where(r => r.HouseTransferInfoId == houseId).FirstOrDefault();
         if (house != null)
         {
             house.InfoProcessState = (int)ProcessState.AuthorizeFaild;
             house.ErrorMsg         = msg;
             house.Logs.Add(new Entity.FxHouse.HouseTransferLog()
             {
                 OperteName = Enum.GetName(typeof(ProcessState), ProcessState.AuthorizeFaild)
             });
             return(context.SaveChanges() > 0);
         }
     }
     return(false);
 }
 public void LoadJob()
 {
     try
     {
         List<int> list = new List<int>();
         using (var context = new FxHouseContext())
         {
             list = context.HouseTransferInfos
                  .Where(r => r.InfoProcessState == (int)ProcessState.Commit).
                      Select(r => r.HouseTransferInfoId).Take(20).ToList();
         }
         JobQueue.HouseTransferJobLoadQueue.AddRange(list);
     }
     catch (Exception ex)
     {
         ex.LogEx(string.Format("{0} {1}", JobKey, "HouseBuyJobLoad"));
     }
 }
 public bool AuthorizeFaild(int houseId,string msg)
 {
     using (var context = new FxHouseContext())
     {
         var house = context.HouseBuyInfos.Where(r => r.HouseBuyInfoId == houseId).FirstOrDefault();
         if (house != null)
         {
             house.InfoProcessState = (int)ProcessState.AuthorizeFaild;
             house.ErrorMsg = msg;
             house.Logs.Add(new Entity.FxHouse.HouseBuyLog()
             {
                 OperteName = Enum.GetName(typeof(ProcessState), ProcessState.AuthorizeFaild)
             });
             return context.SaveChanges() > 0;
         }
     }
     return false;
 }
 public bool Publish(int houseId)
 {
     using (var context = new FxHouseContext())
     {
         var house = context.HouseBuyInfos.Where(r => r.HouseBuyInfoId == houseId).FirstOrDefault();
         if (house != null)
         {
             house.InfoProcessState = (int)ProcessState.Publish;
             house.IsPublish = true;
             house.Logs.Add(new Entity.FxHouse.HouseBuyLog()
             {
                 OperteName = Enum.GetName(typeof(ProcessState), ProcessState.Publish)
             });
             return context.SaveChanges() > 0;
         }
     }
     return false;
 }
 /// <summary>
 /// 删除
 /// </summary>
 /// <param name="houseId">房屋求购帖子Id</param>
 /// <returns>操作是否成功</returns>
 public bool Delete(int houseId)
 {
     using (var context = new FxHouseContext())
     {
         var house = context.HouseBuyInfos.Where(r => r.HouseBuyInfoId == houseId).FirstOrDefault();
         if (house != null)
         {
             house.InfoProcessState = (int)ProcessState.Delete;
             house.IsPublish        = false;
             house.IsDelete         = true;
             house.Logs.Add(new Entity.FxHouse.HouseBuyLog()
             {
                 OperteName = Enum.GetName(typeof(ProcessState), ProcessState.Delete)
             });
             return(context.SaveChanges() > 0);
         }
     }
     return(false);
 }
 /// <summary>
 /// 图片CDN失败
 /// </summary>
 /// <param name="houseId">房屋转让帖子Id</param>
 /// <param name="errorMsg">图片CDN失败错误信息</param>
 /// <returns>操作是否成功</returns>
 public bool PictrueCdnFailed(int houseId, string errorMsg)
 {
     using (var context = new FxHouseContext())
     {
         var house = context.HouseTransferInfos.Where(r => r.HouseTransferInfoId == houseId).FirstOrDefault();
         if (house != null)
         {
             house.InfoProcessState = (int)ProcessState.PictrueCdnFailed;
             house.Logs.Add(new Entity.FxHouse.HouseTransferLog()
             {
                 OperteName = Enum.GetName(typeof(ProcessState), ProcessState.PictrueCdnFailed)
             });
             context.PictureCdnErrors.Add(new PictureCdnError()
             {
                 ErorMsg    = errorMsg,
                 ObjectId   = houseId,
                 SourceType = (int)ChannelCatagroy.FxHouseTrasnfer
             });
             return(context.SaveChanges() > 0);
         }
     }
     return(false);
 }
 /// <summary>
 /// 图片CDN失败
 /// </summary>
 /// <param name="houseId">房屋转让帖子Id</param>
 /// <param name="errorMsg">图片CDN失败错误信息</param>
 /// <returns>操作是否成功</returns>
 public bool PictrueCdnFailed(int houseId, string errorMsg)
 {
     using (var context = new FxHouseContext())
     {
         var house = context.HouseTransferInfos.Where(r => r.HouseTransferInfoId == houseId).FirstOrDefault();
         if (house != null)
         {
             house.InfoProcessState = (int)ProcessState.PictrueCdnFailed;
             house.Logs.Add(new Entity.FxHouse.HouseTransferLog()
             {
                 OperteName = Enum.GetName(typeof(ProcessState), ProcessState.PictrueCdnFailed)
             });
             context.PictureCdnErrors.Add(new PictureCdnError()
             {
                 ErorMsg = errorMsg,
                 ObjectId = houseId,
                 SourceType = (int)ChannelCatagroy.FxHouseTrasnfer
             });
             return context.SaveChanges() > 0;
         }
     }
     return false;
 }
 public void PictureProcess()
 {
     int houseId = JobQueue.HouseTransferJobPictureProcessQueue.GetItem(houseTransferJobService.PictrueCdning);
     if (houseId == 0)
     {
         return;
     }
     using (var context = new FxHouseContext())
     {
         while (houseId != 0)
         {
             var car = context.HouseTransferInfos.Where(r => r.HouseTransferInfoId == houseId).FirstOrDefault();
             if (car != null)
             {
                 string source;
                 string destnation;
                 string destnationmin;
                 int error = 0;
                 string errmsg = "";
                 foreach (var picture in car.Pictures)
                 {
                     try
                     {
                         source = string.Format(picture.PhysicalPath);
                         destnation = string.Format("{0}{1}", appSettings.CdnPath(), picture.ImageUrl.Replace(@"/", @"\"));
                         destnationmin = string.Format("{0}{1}", appSettings.CdnPath(), picture.MinImageUrl.Replace(@"/", @"\"));
                         var job = new ImageJob(source, destnation, new ResizeSettings()
                         {
                             MaxHeight = 500,
                             MaxWidth = 500,
                         }) { CreateParentDirectory = true };
                         var jobmin = new ImageJob(source, destnationmin, new ResizeSettings()
                         {
                             MaxHeight = 64,
                             MaxWidth = 64,
                         }) { CreateParentDirectory = true };
                         ImageBuilder.Current.Build(job);
                         ImageBuilder.Current.Build(jobmin);
                     }
                     catch (Exception ex)
                     {
                         if (string.IsNullOrEmpty(errmsg))
                         {
                             if (ex.InnerException != null)
                             {
                                 errmsg = ex.InnerException.Message;
                             }
                             else
                             {
                                 errmsg = ex.Message;
                             }
                         }
                         error++;
                         ex.LogEx(string.Format("{0} {1} {2}", JobKey, "PictureProcess", picture.TransferPictureId));
                     }
                 }
                 if (error == 0)
                 {
                     houseTransferJobService.PictrueCdnSuccessd(houseId);
                     houseTransferJobService.Publish(houseId);
                 }
                 else
                 {
                     houseTransferJobService.PictrueCdnFailed(houseId, errmsg);
                 }
                 houseId = JobQueue.HouseTransferJobPictureProcessQueue.GetItem(houseTransferJobService.PictrueCdning);
             }
         }
     }
 }