Ejemplo n.º 1
0
        /// <summary>
        /// DTO添加数据
        /// </summary>
        /// <param name="inputEntity"></param>
        /// <returns></returns>
        public bool DTOAdd(ComplaInfoInputDTO inputEntity)
        {
            //AutoMapper转换
            ComplaInfo dataModel = Mapper.Map <ComplaInfoInputDTO, ComplaInfo>(inputEntity);

            HouseInfo list = houseInfoDAL.LoadEntities(u => u.HousID == dataModel.HousID).FirstOrDefault();

            dataModel.ComplaID    = CreateOrderCode();
            dataModel.State       = 2;
            dataModel.RsubmitData = DateTime.Now;
            dataModel.UserID      = list.UserID;
            //ComplaInfo entity = complaInfoDAL.LoadEntities(u => u.HousID == HousID).FirstOrDefault();
            if (complaInfoDAL.AddAndSaveChange(dataModel) > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
        private static HouseInfo ConvertHouse(string cityName, JToken item)
        {
            var room       = item["room"];
            var housePrice = room["cost1"].ToObject <decimal>();
            var house      = new HouseInfo()
            {
                HouseLocation    = room["address"].ToString(),
                HouseTitle       = room["summary"].ToString(),
                HouseOnlineURL   = $"http://www.zuber.im/app/room/{room["id"].ToString()}",
                HouseText        = item.ToString(),
                HousePrice       = housePrice,
                IsAnalyzed       = true,
                DisPlayPrice     = housePrice > 0 ? $"{housePrice}元" : "",
                Source           = ConstConfigName.Zuber,
                LocationCityName = cityName,
                Status           = 1,
                PicURLs          = GetPhotos(room),
                PubTime          = room["last_modify_time"].ToObject <DateTime>()
            };

            return(house);
        }
Ejemplo n.º 3
0
        public void GetHousePercentage(ref HouseInfo houseInfo)
        {
            var sp1 = projectInfo.Copy();

            for (int k = 0; k < houseInfo.Sections.Count; k++) //Квартиры
            {
                FlatInfo section = houseInfo.Sections[k];
                for (int l = 0; l < section.Flats.Count; l++) //Квартиры
                {
                    if (section.Flats[l].SubZone.Equals("0"))
                    {
                        continue;
                    }
                    var reqs =
                        sp1.requirments.Where(
                            x => x.CodeZone.Equals(section.Flats[l].SubZone))
                        .Where(x => x.MaxArea > section.Flats[l].AreaTotal & x.MinArea <= section.Flats[l].AreaTotal)
                        .ToList();
                    if (reqs.Count == 0)
                    {
                        continue;
                    }
                    reqs[0].RealCountFlats += section.Floors - 1;
                }
            }
            int countFlats = 0;

            foreach (var r in sp1.requirments)
            {
                countFlats += r.RealCountFlats;
            }
            foreach (var r in sp1.requirments)
            {
                double percentage = r.RealCountFlats * 100 / countFlats;
                r.RealPercentage = percentage;
            }
            houseInfo.SpotInf = sp1;
        }
Ejemplo n.º 4
0
        public override List <HouseInfo> ParseHouses(JToken config, string data)
        {
            var cityName = config["cityname"]?.ToString();
            List <HouseInfo> houseList = new List <HouseInfo>();

            if (string.IsNullOrEmpty(data))
            {
                return(houseList);
            }
            var htmlDoc    = htmlParser.Parse(data);
            var houseItems = htmlDoc.QuerySelectorAll("div.pan-item.clearfix");

            if (!houseItems.Any())
            {
                return(houseList);
            }
            foreach (var item in houseItems)
            {
                HouseInfo houseInfo = ConvertToHouse(cityName, item);
                houseList.Add(houseInfo);
            }
            return(houseList);
        }
Ejemplo n.º 5
0
        private static HouseInfo ConvertToHouse(string cityName, IElement item)
        {
            int    housePrice    = GetHousePrice(item);
            string houseLocation = GetLocation(item);
            var    titleItem     = item.QuerySelector("h2");
            var    pubTime       = GetPubTime(item);
            string houseURL      = GetHouseURL(titleItem);
            var    houseInfo     = new HouseInfo
            {
                HouseTitle       = titleItem.TextContent.Replace("\n", "").Trim() + houseLocation,
                HouseOnlineURL   = "http://zf.cdfgj.gov.cn" + houseURL,
                DisPlayPrice     = housePrice + "元/月",
                HouseLocation    = houseLocation,
                Source           = ConstConfigName.Chengdufgj,
                HousePrice       = housePrice,
                HouseText        = item.InnerHtml,
                LocationCityName = cityName,
                PubTime          = pubTime,
                PicURLs          = GetPhotos(item)
            };

            return(houseInfo);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 更新数据
        /// </summary>
        /// <param name="inputEntity"></param>
        /// <returns></returns>
        public int DTOUpdate(HouseInfoInputDTO inputEntity, out int outID)
        {
            //先查房屋信息 AsNoTracking() 不追踪
            outID = 0;
            HouseInfo checkmodel = houseInfoDAL.LoadEntities(u => u.HousID == inputEntity.HousID).AsNoTracking().FirstOrDefault();

            if (checkmodel != null)
            {
                //AutoMap转换
                HouseInfo dataModel = Mapper.Map <HouseInfoInputDTO, HouseInfo>(inputEntity);
                //修改数据
                dataModel.UserID = checkmodel.UserID;
                dataModel.State  = checkmodel.State;
                dataModel.ID     = checkmodel.ID; //把ID赋值,让EF知道应该修改哪条数据

                outID = dataModel.ID;             //给ID赋值
                return(houseInfoDAL.EditAndSaveChange(dataModel));
            }
            else
            {
                return(0);
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 根据ID删除数据
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool Delete(Array id)
        {
            foreach (var item in id)
            {
                int ID = Convert.ToInt32(item);
                //先查
                HouseInfo entity = houseInfoDAL.LoadEntities(u => u.ID == ID).FirstOrDefault();
                if (entity != null && entity.State == true)
                {
                    //打标记
                    houseInfoDAL.DeleteFlag(entity);
                }
            }

            if (unitOfWork.SaveChanges() > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 8
0
        private void DeleteDetailsRow(int iRowIndex)
        {
            HouseInfo house = GetDetailsRowModel(iRowIndex);

            if (house == null)
            {
                return;
            }

            if (MessageBox.Show(string.Format("是否确认删除库区【{0}】?", house.HouseName), "确认删除", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk) == DialogResult.No)
            {
                return;
            }

            try
            {
                if (house.IsDel != 2)
                {
                    string strErr = string.Empty;
                    if (!Basic_Func.DeleteHouseByID(house, ref strErr))
                    {
                        Common.Common_Func.ErrorMessage(strErr, "删除失败");
                        return;
                    }
                }

                Common.Common_Func.ErrorMessage("删除库区成功", "删除成功");
            }
            catch (Exception ex)
            {
                Common.Common_Func.ErrorMessage(ex.Message);
            }
            finally
            {
                GetListQueryData();
            }
        }
Ejemplo n.º 9
0
    public IEnumerator PostRegistery(string url, string bodyJsonString, System.Action <int> callback)
    {
        print(bodyJsonString);
        var request = new UnityWebRequest(url, "POST");

        byte[] bodyRaw = Encoding.UTF8.GetBytes(bodyJsonString);
        request.uploadHandler   = (UploadHandler) new UploadHandlerRaw(bodyRaw);
        request.downloadHandler = (DownloadHandler) new DownloadHandlerBuffer();
        request.SetRequestHeader("Content-Type", "application/json");

        //yield return request.Send();
        yield return(request.SendWebRequest());


        Debug.Log("Status Code: " + request.responseCode);

        //getting the body from call
        Debug.Log(request.downloadHandler.text);
        var       data      = request.downloadHandler.text;
        HouseInfo houseInfo = HouseInfo.CreateFromJSON(data);

        //Debug.Log("House: " + houseInfo.house);
        callback(houseInfo.house);
    }
Ejemplo n.º 10
0
        public async Task GetHouseInfoByIdAvailableForUserAsync_TimeoutException_ThrowsException()
        {
            // Arrange
            var houseInfo = new HouseInfo()
            {
                Id        = ObjectId.GenerateNewId(),
                OwnerId   = 123456789,
                MemberIds = new List <decimal>()
                {
                    123456789
                }
            };

            _houseRepositoryMock
            .Setup(hr => hr.FindOneAsync(
                       It.IsAny <PipelineDefinition <HouseInfo, HouseInfo> >(),
                       It.IsAny <CancellationToken>()))
            .Throws <TimeoutException>();

            // Act
            // Assert
            await Assert.ThrowsExceptionAsync <TimeoutException>(
                () => _houseService.GetHouseInfoByIdAvailableForUserAsync(houseInfo.Id, houseInfo.OwnerId));
        }
Ejemplo n.º 11
0
        private double GetTotalArea(HouseInfo house1)
        {
            double totalArea = 0;

            foreach (var section in house1.Sections)
            {
                double sectionArea = 0;
                foreach (var f in section.Flats)
                {
                    if (section.Floors == 25)
                    {
                        sectionArea += 9 * f.AreaTotal;
                        sectionArea += 15 * f.AreaTotalStandart;
                    }
                    else
                    {
                        sectionArea += (section.Floors - 1) * f.AreaTotalStandart;
                    }
                }
                totalArea   += sectionArea;
                section.Area = sectionArea;
            }
            return(totalArea);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// 发布房源
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult CreateHouseInfoView(long?id)
        {
            HouseInfo houseInfo = new HouseInfo();

            if (ViewBag.IsLogin)
            {
                ViewBag.IsPermission = false;
                ViewBag.IsPermission = OperateContext.Current.BLLSession.IUserAccountBLL.GetListBy(m => m.ID == OperateContext.Current.UserInfo.AccountID).FirstOrDefault().State == 0;


                if (id.HasValue)
                {
                    // 根据编号查询房源信息
                    houseInfo = OperateContext.Current.BLLSession.IHouseInfoBLL.GetListBy(m => m.ID == id.Value && m.UserInfoID == OperateContext.Current.UserInfo.ID).FirstOrDefault();
                }
                if (houseInfo != null)
                {
                    // 房源图片
                    houseInfo.HouseImgList = OperateContext.Current.BLLSession.IHouseImgBLL.GetListBy(m => m.HouseInfoID == id.Value);

                    if (houseInfo.HouseImgList != null)
                    {
                        houseInfo.JsonHouseImgList = JsonConvert.SerializeObject(houseInfo.HouseImgList);
                    }
                }
                else
                {
                    houseInfo = new HouseInfo();
                }
                // 配套设施
                ViewBag.HouseConfigureList = OperateContext.Current.BLLSession.IHouseConfigureBLL.GetListBy(m => m.ID > 0, m => m.Sort, true);
            }


            return(View(houseInfo));
        }
Ejemplo n.º 13
0
        /// <summary>
        /// DTO修改
        /// </summary>
        /// <param name="inputEntity"></param>
        /// <param name="outID"></param>
        /// <returns></returns>
        public bool DTOUpdate(UserInfoInputDTO inputEntity, out int outID)
        {
            //先查AsNoTracking() 不追踪
            outID = 0;
            UserInfo checkmodel = userInfoDAL.LoadEntities(u => u.UserID == inputEntity.UserID).AsNoTracking().FirstOrDefault();

            if (checkmodel != null)
            {
                //AutoMap转换
                UserInfo dataModel = Mapper.Map <UserInfoInputDTO, UserInfo>(inputEntity);
                //修改数据
                dataModel.ID       = checkmodel.ID;//把ID赋值,让EF知道应该修改哪条数据
                dataModel.HousID   = checkmodel.HousID;
                dataModel.PassWord = checkmodel.PassWord;
                if (!string.IsNullOrEmpty(inputEntity.HousID))
                {
                    dataModel.HousID = inputEntity.HousID;
                    //先查房屋信息i
                    HouseInfo entity = houseInfoDAL.LoadEntities(u => u.HousID == inputEntity.HousID).FirstOrDefault();
                    entity.UserID = dataModel.UserID;
                    entity.State  = false;
                    //打上标记
                    houseInfoDAL.EditFlag(entity);
                }
                outID = dataModel.ID;//给ID赋值
                userInfoDAL.EditFlag(dataModel);
            }
            if (unitOfWork.SaveChanges() > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 14
0
        public List <HouseInfo> GetList(string sqlWhere, params SqlParameter[] cmdParms)
        {
            string cmdText = @"select Id,HouseCode,PropertyCompanyId,ResidenceCommunityId,ResidentialBuildingId,ResidentialUnitId,HouseAcreage,Remark,LastUpdatedDate
                              from House";

            if (!string.IsNullOrEmpty(sqlWhere))
            {
                cmdText += " where 1=1 " + sqlWhere;
            }

            List <HouseInfo> list = new List <HouseInfo>();

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.SqlProviderConnString, CommandType.Text, cmdText, cmdParms))
            {
                if (reader != null && reader.HasRows)
                {
                    while (reader.Read())
                    {
                        HouseInfo model = new HouseInfo();
                        model.Id                    = reader.GetGuid(0);
                        model.HouseCode             = reader.GetString(1);
                        model.PropertyCompanyId     = reader.GetGuid(2);
                        model.ResidenceCommunityId  = reader.GetGuid(3);
                        model.ResidentialBuildingId = reader.GetGuid(4);
                        model.ResidentialUnitId     = reader.GetGuid(5);
                        model.HouseAcreage          = reader.GetDouble(6);
                        model.Remark                = reader.GetString(7);
                        model.LastUpdatedDate       = reader.GetDateTime(8);

                        list.Add(model);
                    }
                }
            }

            return(list);
        }
Ejemplo n.º 15
0
 // Start is called before the first frame update
 private void Start()
 {
     info = new HouseInfo();
     this.OnCollisionEnterAsObservable().Where(obj => obj.transform.tag == GameConfig.Tags.Player).Subscribe(_ => SceneManager.LoadScene(GameConfig.SceneName.Title));
 }
Ejemplo n.º 16
0
        public void Run()
        {
            foreach (var city in configuration.CityList)
            {
                for (var page = 1; page <= 100; page++)
                {
                    var houses    = new List <HouseInfo>();
                    var houseUrl  = $"https://{city.Code}.lianjia.com/ershoufang/pg{page}/";
                    var houseHTML = GetHTML(houseUrl);
                    var htmlDoc   = htmlParser.Parse(houseHTML);
                    var houseUL   = htmlDoc.QuerySelector("ul.sellListContent");
                    if (houseUL == null)
                    {
                        continue;
                    }
                    foreach (var item in houseUL.QuerySelectorAll("li.clear"))
                    {
                        var title = item.QuerySelector("div.title");
                        if (title == null)
                        {
                            continue;
                        }
                        var house = new HouseInfo();
                        house.HouseTitle = title.QuerySelector("a").TextContent;
                        house.OnlineURL  = title.QuerySelector("a").GetAttribute("href");
                        var address = item.QuerySelector("div.houseInfo");
                        if (address != null)
                        {
                            var addressList = address.TextContent.Split("/");
                            if (addressList.Any())
                            {
                                house.Address   = address.QuerySelector("a").TextContent;
                                house.HouseType = addressList.FirstOrDefault(text => text.Contains("室"));
                                house.Area      = decimal.Parse(addressList.FirstOrDefault(text => text.Contains("平米")).Replace("平米", ""));
                            }
                        }
                        var timeText = item.QuerySelector("div.timeInfo").TextContent;
                        var pubDay   = 0;
                        if (timeText.Contains("天"))
                        {
                            pubDay = int.Parse(timeText.Replace("天以前发布", ""));
                        }
                        else if (timeText.Contains("月"))
                        {
                            pubDay = int.Parse(timeText.Replace("个月以前发布", "")) * 30;
                        }
                        house.PubTime = DateTime.Now.AddDays(-pubDay);

                        house.TotalPrice = decimal.Parse(item.QuerySelector("div.totalPrice").QuerySelector("span").TextContent);
                        house.UnitPrice  = decimal.Parse(item.QuerySelector("div.unitPrice").GetAttribute("data-price"));
                        house.Pictures   = new List <string>()
                        {
                            item.QuerySelector("img.lj-lazy").GetAttribute("src")
                        };
                        house.HouseText = item.InnerHtml;
                        house.CityName  = city.Name;
                        houses.Add(house);
                    }
                    elasticsearchService.SaveHousesToES(houses);
                }
            }
        }
Ejemplo n.º 17
0
 public ActionResult AddHouse(HouseInfo house)
 {
     return(Json(new { success = true }));
 }
Ejemplo n.º 18
0
        public List <GeneralObject> Load(PIK1.C_Flats_PIK1DataTable dbFlats, out ProjectInfo pi)
        {
            List <GeneralObject> gos = new List <GeneralObject>();

            pi = null;

            dictRoomInfo = new Dictionary <string, RoomInfo>();
            foreach (var dbFlat in dbFlats)
            {
                if (!dictRoomInfo.ContainsKey(dbFlat.Type))
                {
                    RoomInfo flat = new RoomInfo();
                    flat.Type                = dbFlat.Type;
                    flat.AreaLive            = dbFlat.AreaLive;
                    flat.AreaModules         = dbFlat.AreaInModule;
                    flat.AreaTotal           = dbFlat.AreaTotalStandart;
                    flat.FactorSmoke         = dbFlat.FactorSmoke;
                    flat.ShortType           = dbFlat.ShortType;
                    flat.SubZone             = dbFlat.SubZone;
                    flat.SelectedIndexBottom = Convert.ToInt32(dbFlat.IndexBottom);
                    flat.SelectedIndexTop    = Convert.ToInt32(dbFlat.IndexTop);

                    dictRoomInfo.Add(dbFlat.Type, flat);
                }
            }

            var fileResult = PromptFileResult();

            using (ZipArchive zip = ZipFile.OpenRead(fileResult))
            {
                using (var stream = zip.GetEntry("gos").Open())
                {
                    using (reader = new BinaryReader(stream))
                    {
                        pi               = ReadProjectInfo();
                        pi.SpotOptions   = ReadSpotOptions();
                        pi.InsModulesAll = ReadInsModules();

                        var countGos = reader.ReadInt32();
                        for (int i = 0; i < countGos; i++)
                        {
                            var go = new GeneralObject();
                            go.GUID   = reader.ReadString();
                            go.Houses = new List <HouseInfo>();
                            var countHouse = reader.ReadInt32();
                            for (int h = 0; h < countHouse; h++)
                            {
                                var hi = new HouseInfo();
                                hi.Sections = ReadSections();
                                //hi.SpotInf = ReadSpotInfo();
                                go.Houses.Add(hi);
                            }
                            go.SpotInf = ReadProjectInfo();
                            go.SpotInf.InsModulesAll = pi.InsModulesAll;
                            gos.Add(go);
                        }
                    }
                }
            }
            return(gos);
        }
Ejemplo n.º 19
0
        public HouseDetailViewModel(HouseInfo houseInfo)
        {
            House          = houseInfo;
            HouseTitle     = house.DistrictName + " " + house.AreaName + " " + house.EstateName;
            House.PhotoUrl = string.IsNullOrWhiteSpace(House.PhotoUrl) ? "NullPic.jpg" : House.PhotoUrl;
            Visible        = House.EmpID == GlobalVariables.LoggedUser.EmpID;

            CheckCollected();

            GetPhotos();

            ShareCommand = new Command(() =>
            {
                var page = new ShareView(House.PropertyID);
                PopupNavigation.Instance.PushAsync(page);
            }, () => { return(true); });

            CallOwnerCommand = new Command(async() =>
            {
                string action = await Application.Current.MainPage.DisplayActionSheet("联系业主" + House.ownermobile, "取消", null, "打电话", "发短信");
                if (action == "打电话")
                {
                    try
                    {
                        if (!string.IsNullOrWhiteSpace(House.tel))
                        {
                            PhoneDialer.Open(House.tel);
                        }
                        else
                        {
                            CrossToastPopUp.Current.ShowToastError("电话号码为空", ToastLength.Long);
                        }
                    }
                    catch (FeatureNotSupportedException)
                    {
                        // Phone Dialer is not supported on this device.
                        CrossToastPopUp.Current.ShowToastError("该设备不支持拨号", ToastLength.Long);
                    }
                    catch (Exception)
                    {
                        // Other error has occurred.
                    }
                }
                else if (action == "发短信")
                {
                    try
                    {
                        if (!string.IsNullOrWhiteSpace(House.tel))
                        {
                            string result = await Application.Current.MainPage.DisplayPromptAsync("短信", "请输入短消息", "发送", "取消", "短消息(140个字以内)", 140, null);

                            if (result == null)
                            {
                                CrossToastPopUp.Current.ShowToastWarning("已取消", ToastLength.Long);
                            }
                            else if (result == "")
                            {
                                CrossToastPopUp.Current.ShowToastWarning("请输入短消息(140字以内)", ToastLength.Long);
                            }
                            else
                            {
                                var message = new SmsMessage()
                                {
                                    Body       = result,
                                    Recipients = new List <string>()
                                    {
                                        House.tel
                                    }
                                };
                                await Sms.ComposeAsync(message);
                            }
                        }
                        else
                        {
                            CrossToastPopUp.Current.ShowToastError("电话号码为空", ToastLength.Long);
                        }
                    }
                    catch (Exception)
                    {
                        throw;
                    }
                }
            }, () => { return(true); });

            SeeFollowUpCommand = new Command(() =>
            {
                SeeFollowUpPage seeFollowUpPage = new SeeFollowUpPage(House.PropertyID, true);
                Application.Current.MainPage.Navigation.PushAsync(seeFollowUpPage);
            }, () => { return(true); });

            WriteFollowUpCommand = new Command(() =>
            {
                WriteFollowUpPage writeFollowUpPage = new WriteFollowUpPage(House.PropertyID, true);
                Application.Current.MainPage.Navigation.PushAsync(writeFollowUpPage);
            }, () => { return(true); });

            EditCommand = new Command(() =>
            {
                AddHousePage2 EditHousePage = new AddHousePage2(houseInfo);
                Application.Current.MainPage.Navigation.PushAsync(EditHousePage);
            }, () => { return(true); });

            CallCommand = new Command(async() =>
            {
                string action = await Application.Current.MainPage.DisplayActionSheet("联系发布人" + House.tel, "取消", null, "打电话", "发短信");
                if (action == "打电话")
                {
                    try
                    {
                        if (!string.IsNullOrWhiteSpace(House.tel))
                        {
                            PhoneDialer.Open(House.tel);
                        }
                        else
                        {
                            CrossToastPopUp.Current.ShowToastError("电话号码为空", ToastLength.Long);
                        }
                    }
                    catch (FeatureNotSupportedException)
                    {
                        // Phone Dialer is not supported on this device.
                        CrossToastPopUp.Current.ShowToastError("该设备不支持拨号", ToastLength.Long);
                    }
                    catch (Exception)
                    {
                        // Other error has occurred.
                    }
                }
                else if (action == "发短信")
                {
                    try
                    {
                        if (!string.IsNullOrWhiteSpace(House.tel))
                        {
                            string result = await Application.Current.MainPage.DisplayPromptAsync("短信", "请输入短消息", "发送", "取消", "短消息(140个字以内)", 140, null);

                            if (result == null)
                            {
                                CrossToastPopUp.Current.ShowToastWarning("已取消", ToastLength.Long);
                            }
                            else if (result == "")
                            {
                                CrossToastPopUp.Current.ShowToastWarning("请输入短消息(140字以内)", ToastLength.Long);
                            }
                            else
                            {
                                var message = new SmsMessage()
                                {
                                    Body       = result,
                                    Recipients = new List <string>()
                                    {
                                        House.tel
                                    }
                                };
                                await Sms.ComposeAsync(message);
                            }
                        }
                        else
                        {
                            CrossToastPopUp.Current.ShowToastError("电话号码为空", ToastLength.Long);
                        }
                    }
                    catch (Exception)
                    {
                        throw;
                    }
                }
            }, () => { return(true); });

            CollectCommand = new Command(() =>
            {
                CollectOrCancel();
            }, () => { return(true); });

            CarouselTappedCommand = new Command <string>((p) =>
            {
                var page = new PhotoView(p);
                PopupNavigation.Instance.PushAsync(page);
            }, (p) => { return(true); });
        }
Ejemplo n.º 20
0
        public AddHouse(HouseInfo win, int _type, int land_index, int house_index)
        {
            InitializeComponent();
            the_window  = win;
            type        = _type;
            Land_Index  = land_index;
            House_Index = house_index;

            House_types         = new string[] { "Основной", "Вспомогательный" };
            TypeBox.DataContext = House_types;
            TypeBox.ItemsSource = House_types;

            MySqlConnection connector = new MySqlConnection(connection);
            DataTable       dt        = new DataTable();
            string          Query     = "SELECT Назначение_Здания from назначение_здания;";

            connector.Open();
            MySqlCommand command = new MySqlCommand(Query, connector);

            dt.Load(command.ExecuteReader());

            List <string> Purposes = new List <string>();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                string s = dt.Rows[i][0].ToString();
                Purposes.Add(s);
            }

            PurposeBox.DataContext = Purposes;
            PurposeBox.ItemsSource = Purposes;
            //////////////////////////


            if (type == 2)
            {
                this.Title = "Изменить здание";
                dt         = new DataTable();

                Query = "SELECT Возведено_самовольно, Назначение, Тип," +
                        "Год_постройки, Износ, Общая_площадь, Жилая_площадь, Материал_стен, Инвентаризационная_стоимость," +
                        "Этажность, Номер_здания FROM информация_о_здании RIGHT JOIN здание ON здание.Код_здания = информация_о_здании.Код_здания" +
                        " WHERE информация_о_здании.Код_Здания = " + House_Index + ";";

                command = new MySqlCommand(Query, connector);
                dt.Load(command.ExecuteReader());

                string SelfBuild__ = dt.Rows[0][0].ToString();


                if (SelfBuild__ == "1")
                {
                    SelfBuildBox.IsChecked = true;
                }

                PurposeBox.Text     = (string)dt.Rows[0][1];
                TypeBox.Text        = (string)dt.Rows[0][2];
                YearBox.Text        = dt.Rows[0][3].ToString();
                BrokenBox.Text      = dt.Rows[0][4].ToString();
                TotalSquareBox.Text = dt.Rows[0][5].ToString();
                LifeSquareBox.Text  = dt.Rows[0][6].ToString();
                WallsBox.Text       = (string)dt.Rows[0][7];
                PriceBox.Text       = dt.Rows[0][8].ToString();
                LevelsBox.Text      = dt.Rows[0][9].ToString();
                NumberBox.Text      = dt.Rows[0][10].ToString();
            }

            connector.Close();
        }
Ejemplo n.º 21
0
        public Player(int offset, int idx, Save save)
        {
            _saveData = save;
            Index     = idx;
            Offset    = offset;
            Offsets   = PlayerInfo.GetPlayerInfo(save.SaveType);
            Exists    = _saveData.ReadByte(offset + Offsets.Identifier) != 0 && _saveData.ReadByte(offset + Offsets.Identifier) != 0xFF;
            if (!Exists)
            {
                return;
            }

            var    playerDataType     = typeof(PlayerData);
            var    playerSaveInfoType = typeof(PlayerSaveInfo);
            object boxedData          = new PlayerData();

            foreach (var field in playerSaveInfoType.GetFields(BindingFlags.Public | BindingFlags.Instance))
            {
                if (field.GetValue(Offsets) != null && !field.Name.Contains("Count") && !field.Name.Contains("Size"))
                {
                    if (playerDataType.GetField(field.Name) != null)
                    {
                        if (field.FieldType != typeof(int) || (int)field.GetValue(Offsets) == -1)
                        {
                            continue;
                        }

                        var currentField = playerDataType.GetField(field.Name);
                        var fieldType    = currentField.FieldType;
                        var dataOffset   = Offset + (int)field.GetValue(Offsets);

                        switch (field.Name)
                        {
                        case "TownPassCardImage" when save.SaveGeneration == SaveGeneration.N3DS:
                            playerDataType.GetField("TownPassCardData").SetValue(boxedData, _saveData.ReadByteArray(dataOffset, 0x1400));
                            currentField.SetValue(boxedData,
                                                  ImageGeneration.GetTpcImage((byte[])playerDataType.GetField("TownPassCardData").GetValue(boxedData)));
                            break;

                        case "Reset" when save.SaveGeneration == SaveGeneration.GCN:
                            currentField.SetValue(boxedData, _saveData.ReadUInt32(dataOffset, _saveData.IsBigEndian) != 0);
                            break;

                        default:
                            if (fieldType == typeof(byte))
                            {
                                currentField.SetValue(boxedData, _saveData.ReadByte(dataOffset));
                            }
                            else if (fieldType == typeof(byte[]) && playerSaveInfoType.GetField(field.Name + "Count") != null)
                            {
                                currentField.SetValue(boxedData, _saveData.ReadByteArray(dataOffset,
                                                                                         (int)playerSaveInfoType.GetField(field.Name + "Count").GetValue(Offsets)));
                            }
                            else if (fieldType == typeof(ushort))
                            {
                                currentField.SetValue(boxedData, _saveData.ReadUInt16(dataOffset, _saveData.IsBigEndian));
                            }
                            else if (fieldType == typeof(ushort[]))
                            {
                                currentField.SetValue(boxedData, _saveData.ReadUInt16Array(dataOffset,
                                                                                           (int)playerSaveInfoType.GetField(field.Name + "Count").GetValue(Offsets), _saveData.IsBigEndian));
                            }
                            else if (fieldType == typeof(uint))
                            {
                                currentField.SetValue(boxedData, _saveData.ReadUInt32(dataOffset, _saveData.IsBigEndian));
                            }
                            else if (fieldType == typeof(string))
                            {
                                currentField.SetValue(boxedData, new AcString(_saveData.ReadByteArray(dataOffset,
                                                                                                      (int)playerSaveInfoType.GetField(field.Name + "Size").GetValue(Offsets)), _saveData.SaveType).Trim());
                            }
                            else if (fieldType == typeof(Inventory))
                            {
                                if (save.SaveGeneration == SaveGeneration.N3DS)
                                {
                                    currentField.SetValue(boxedData, new Inventory(_saveData.ReadUInt32Array(dataOffset,
                                                                                                             (int)playerSaveInfoType.GetField(field.Name + "Count").GetValue(Offsets), false)));
                                }
                                else
                                {
                                    currentField.SetValue(boxedData, new Inventory(_saveData.ReadUInt16Array(dataOffset,
                                                                                                             (int)playerSaveInfoType.GetField(field.Name + "Count").GetValue(Offsets), _saveData.IsBigEndian), save, this));
                                }
                            }
                            else if (fieldType == typeof(Item))
                            {
                                if (save.SaveGeneration == SaveGeneration.N3DS)
                                {
                                    currentField.SetValue(boxedData, new Item(_saveData.ReadUInt32(dataOffset, false)));
                                }
                                else
                                {
                                    currentField.SetValue(boxedData, new Item(_saveData.ReadUInt16(dataOffset, _saveData.IsBigEndian)));
                                }
                            }
                            else if (fieldType == typeof(Item[]))
                            {
                                if (field.Name.Equals("Dressers"))
                                {
                                    switch (_saveData.SaveGeneration)
                                    {
                                    case SaveGeneration.NDS:
                                        dataOffset = _saveData.SaveDataStartOffset + 0x15430 + 0xB4 * Index;         // Terrible hack
                                        break;

                                    case SaveGeneration.Wii:
                                        dataOffset = _saveData.SaveDataStartOffset + 0x1F3038 + 0x140 * Index;
                                        break;
                                    }
                                }

                                var itemArray = new Item[(int)playerSaveInfoType.GetField(field.Name + "Count").GetValue(Offsets)];
                                for (var i = 0; i < itemArray.Length; i++)
                                {
                                    if (save.SaveGeneration == SaveGeneration.N3DS)
                                    {
                                        itemArray[i] = new Item(_saveData.ReadUInt32(dataOffset + i * 4, false));
                                    }
                                    else
                                    {
                                        itemArray[i] = new Item(_saveData.ReadUInt16(dataOffset + i * 2, _saveData.IsBigEndian));
                                    }
                                }
                                currentField.SetValue(boxedData, itemArray);
                            }
                            else if (fieldType == typeof(NewLeafInt32))
                            {
                                var intData = _saveData.ReadUInt32Array(dataOffset, 2);
                                currentField.SetValue(boxedData, new NewLeafInt32(intData[0], intData[1]));
                            }
                            else if (fieldType == typeof(AcDate) && dataOffset > 0)
                            {
                                currentField.SetValue(boxedData, new AcDate(_saveData.ReadByteArray(dataOffset,
                                                                                                    (int)playerSaveInfoType.GetField(field.Name + "Size").GetValue(Offsets))));
                            }
                            break;
                        }
                    }
                }
            }
            Data = (PlayerData)boxedData;
            switch (save.SaveType)
            {
            case SaveType.WildWorld:
                var condensedData = Data.HairColor;
                Data.HairColor = (byte)(condensedData & 0x0F);
                Data.Tan       = (byte)((condensedData & 0xF0) >> 4); //Has to be 0 - 3
                condensedData  = Data.HairType;
                Data.FaceType  = (byte)(condensedData & 0x0F);
                Data.HairType  = (byte)((condensedData & 0xF0) >> 4);

                if (Data.Tan > 3)
                {
                    Data.Tan = 0;
                }
                if (Data.HairColor > 7)
                {
                    Data.HairColor = 0;
                }
                break;

            case SaveType.CityFolk:
                Data.Tan = (byte)(Data.Tan >> 1);     //Not 100% sure about this, but this is what ACToolkit does
                if (Data.Tan > 7)
                {
                    Data.Tan = 0;
                }
                if (Data.HairType > 0x19)
                {
                    Data.HairType = 0x19;
                }
                Data.FaceType = (byte)(Data.FaceType & 0x0F);
                Data.EyeColor = (byte)(Data.FaceType & 0xF0);     //Not actually eye color, just there to hold the upper nibble
                break;
            }
            if (Offsets.Patterns > -1)
            {
                Data.Patterns = new Pattern[Offsets.PatternCount];
                for (var i = 0; i < Data.Patterns.Length; i++)
                {
                    Data.Patterns[i] = new Pattern(offset + Offsets.Patterns + Offsets.PatternSize * i, i, save);
                }
            }

            if (_saveData.SaveType == SaveType.CityFolk)
            {
                Data.Reset = (_saveData.ReadByte(Offset + 0x8670) & 0x02) == 0x02;
            }
            else if (_saveData.SaveType == SaveType.NewLeaf)
            {
                Data.Reset = (_saveData.ReadByte(Offset + 0x5702) & 0x02) == 0x02;
            }
            else if (_saveData.SaveType == SaveType.WelcomeAmiibo)
            {
                Data.Reset = (_saveData.ReadByte(Offset + 0x570A) & 0x02) == 0x02;
            }

            // Get the Player's House
            House = HouseInfo.GetHouse(this, save.SaveType);
            if (House != null)
            {
                if (House.Data.Bed != null)
                {
                    Data.Bed = House.Data.Bed;
                }
            }

            Console.WriteLine($"Player {Index}'s house = {House}");

            // Mail Test
            if (_saveData.SaveGeneration != SaveGeneration.GCN)
            {
                return;
            }
            {
                for (var i = 0; i < 10; i++)
                {
                    var mail = new GcnPlayerMail(_saveData, this, i);
                    //System.Windows.Forms.MessageBox.Show(Mail.GetFormattedMailString());
                }
            }
        }
Ejemplo n.º 22
0
            protected override void Handle(DotnetSpider.Core.Page page)
            {
                HouseInfo Model = new HouseInfo();

                Model.Url = page.Request.Url;
                var HouseInfo = page.Selectable.XPath(".//div[@class='m-content']/div[@class='box-l']").Nodes();

                foreach (var item in HouseInfo)
                {
                    //基本信息
                    var BaseInfo = item.XPath(".//*[@id='introduction']/div/div/div[1]/div[2]/ul/li").Nodes();
                    foreach (var baseinfoitem in BaseInfo)
                    {
                        string title = baseinfoitem.XPath(".//span").GetValue(ValueOption.InnerText);
                        if (title == "房屋户型")
                        {
                            //2室2厅1厨1卫
                            string roominfo = baseinfoitem.XPath("./text()").GetValue();
                            if (roominfo.IndexOf("室") > 0)
                            {
                                Model.RoomCount = int.Parse(roominfo.Substring(roominfo.IndexOf("室") - 1, 1));
                            }
                            if (roominfo.IndexOf("厅") > 0)
                            {
                                Model.SaloonCount = int.Parse(roominfo.Substring(roominfo.IndexOf("厅") - 1, 1));
                            }
                            if (roominfo.IndexOf("卫") > 0)
                            {
                                Model.BathRoomCount = int.Parse(roominfo.Substring(roominfo.IndexOf("卫") - 1, 1));
                            }
                        }
                        else
                        {
                            string subitemtext = baseinfoitem.XPath("./text()").GetValue().Trim();
                            if (title == "所在楼层")
                            {
                                Model.Storey = subitemtext;
                            }
                            else if (title == "建筑面积")
                            {
                                Model.HouseArea = subitemtext.Replace("㎡", "");
                            }
                            else if (title == "户型结构")
                            {
                                Model.Housestruct = subitemtext;
                            }
                            else if (title == "套内面积")
                            {
                                Model.HouseInsideArea = subitemtext;
                            }
                            else if (title == "建筑类型")
                            {
                                Model.Building = subitemtext;
                            }
                            else if (title == "房屋朝向")
                            {
                                Model.HouseDirection = subitemtext;
                            }
                            else if (title == "建筑结构")
                            {
                                Model.BuildingStruct = subitemtext;
                            }
                            else if (title == "装修情况")
                            {
                                Model.Ornamant = subitemtext;
                            }
                            else if (title == "梯户比例")
                            {
                                Model.LiftScale = subitemtext;
                            }
                            else if (title == "供暖方式")
                            {
                                Model.WramStyle = subitemtext;
                            }
                            else if (title == "配备电梯")
                            {
                                Model.Lift = subitemtext;
                            }
                            else if (title == "产权年限")
                            {
                                Model.PropertyTime = subitemtext.Replace("年", "");
                            }
                        }
                    }

                    var transactionInfo = item.XPath(".//*[@id='introduction']/div/div/div[2]/div[2]/ul/li").Nodes();
                    foreach (var tranitem in transactionInfo)
                    {
                        string title = tranitem.XPath(".//span").GetValue(ValueOption.InnerText);
                        string value = tranitem.XPath("./span[2]").GetValue(ValueOption.InnerText).Trim();
                        if (title == "挂牌时间")
                        {
                            Model.HangOutTime = value;
                        }
                        else if (title == "交易权属")
                        {
                            Model.Ownership = value;
                        }
                        else if (title == "上次交易")
                        {
                            Model.LastSale = value;
                        }
                        else if (title == "房屋用途")
                        {
                            Model.HouseUseto = value;
                        }
                        else if (title == "房屋年限")
                        {
                            Model.HouseTime = value;
                        }
                        else if (title == "产权所属")
                        {
                            Model.Owne = value;
                        }
                        else if (title == "抵押信息")
                        {
                            Model.Mortgage = value;
                        }
                        else if (title == "房本备件")
                        {
                            Model.HouseLicence = value;
                        }
                    }


                    #region 房源特色
                    //var house = item.XPath(".//div[1]/div[@class='introContent showbasemore']/div[@class='baseattribute clear']").Nodes();
                    //foreach (var houseitem in house)
                    //{
                    //    string title = houseitem.XPath(".//div[@class='name']").GetValue();
                    //    string value = houseitem.XPath("../div[@class='content']").GetValue();
                    //    if (title == "售房详情")
                    //    {
                    //        Model.HouseDetails = value;
                    //    }
                    //    else if (title == "税费解析")
                    //    {
                    //        Model.TaxDetails = value;
                    //    }
                    //    else if (title == "权属抵押")
                    //    {
                    //        Model.MortgageDetails = value;
                    //    }
                    //    else if (title == "装修描述")
                    //    {
                    //        Model.OrnamantDetails = value;
                    //    }
                    //    else if (title == "核心卖点")
                    //    {
                    //        Model.SalePoint = value;
                    //    }
                    //}

                    #endregion
                }

                Model.Area = page.Selectable.XPath(".//div[@class='aroundInfo']/div[@class='areaName']/span[@class='info']/a/text()").GetValue();

                page.AddResultItem("HouseInfo", Model);
            }
        public ActionResult SaveHouseInfo(HouseInfo houseInfoModel, long?landlorId)
        {
            string       status        = "fail";
            string       msg           = null;
            UserInfoView loginUserInfo = OperateContext.Current.UserInfo;

            if (houseInfoModel != null)
            {
                #region 校验数据

                // TODO:校验数据
                #endregion
                //if(!landlorId.HasValue)
                //{
                //    msg = "请选择房东!";
                //    return OperateContext.Current.RedirectAjax(status, msg, null, null);
                //}
                //获取房东信息
                //var userOjb = OperateContext.Current.BLLSession.IUserInfoExtViewBLL.GetListBy(h => h.ID == landlorId).FirstOrDefault();
                //if (userOjb == null)
                //{
                //    msg = "未找到您选择的房东!";
                //    return OperateContext.Current.RedirectAjax(status, msg, null, null);
                //}
                if (!houseInfoModel.ShopId.HasValue)
                {
                    msg = "请选择店铺";
                    return(OperateContext.Current.RedirectAjax(status, msg, null, null));
                }
                var shop = OperateContext.Current.BLLSession.IShopInfoBLL.GetListBy(h => h.ID == houseInfoModel.ShopId).FirstOrDefault();
                if (shop == null)
                {
                    msg = "未找到您选择的店铺!";
                    return(OperateContext.Current.RedirectAjax(status, msg, null, null));
                }
                houseInfoModel.ShopId          = shop.ID;
                houseInfoModel.ShopName        = shop.ShopName;
                houseInfoModel.DecorativeStyle = (int)shop.ShopType.Value;
                houseInfoModel.Address         = shop.Locations;
                houseInfoModel.Rules           = shop.Rules;
                houseInfoModel.ChargesNotes    = shop.ChargesNotes;
                houseInfoModel.About           = shop.About;
                houseInfoModel.UserInfoID      = shop.UserId.Value;
                houseInfoModel.IsBack          = houseInfoModel.IsBack ?? 0;
                houseInfoModel.IsCancel        = houseInfoModel.IsCancel ?? 0;
                // 房源图片
                if (!String.IsNullOrWhiteSpace(houseInfoModel.JsonHouseImgList))
                {
                    houseInfoModel.HouseImgList = JsonConvert.DeserializeObject <IList <HouseImg> >(houseInfoModel.JsonHouseImgList);
                }

                int result = 0;

                // 房源基本信息
                if (houseInfoModel.ID > 0)
                {
                    // 修改
                    HouseInfo houseInfo = OperateContext.Current.BLLSession.IHouseInfoBLL.GetListBy(m => m.ID == houseInfoModel.ID).FirstOrDefault();

                    if (houseInfo != null)
                    {
                        houseInfo.HouseTitle      = houseInfoModel.HouseTitle;
                        houseInfo.DecorativeStyle = houseInfoModel.DecorativeStyle;
                        houseInfo.LeaseType       = houseInfoModel.LeaseType;
                        houseInfo.BedroomNum      = houseInfoModel.BedroomNum;
                        houseInfo.LivingRoomNum   = houseInfoModel.LivingRoomNum;
                        houseInfo.ToiletNum       = houseInfoModel.ToiletNum;
                        houseInfo.Price           = houseInfoModel.Price;
                        houseInfo.IsTrusteeship   = houseInfoModel.IsTrusteeship;
                        houseInfo.IsSell          = houseInfoModel.IsSell;
                        houseInfo.SellPrice       = houseInfoModel.SellPrice;
                        houseInfo.IsCooking       = houseInfoModel.IsCooking;
                        houseInfo.IsPet           = houseInfoModel.IsPet;
                        houseInfo.StayPersonNum   = houseInfoModel.StayPersonNum;
                        houseInfo.HouseSize       = houseInfoModel.HouseSize;
                        houseInfo.Facilities      = houseInfoModel.Facilities;
                        houseInfo.Address         = houseInfoModel.Address;
                        houseInfo.About           = houseInfoModel.About;
                        houseInfo.Rules           = houseInfoModel.Rules;
                        houseInfo.ChargesNotes    = houseInfoModel.ChargesNotes;
                        houseInfo.BaseInfo        = houseInfoModel.BaseInfo;
                        houseInfo.IsReals         = houseInfoModel.IsReals;
                        houseInfo.ProvinceId      = houseInfoModel.ProvinceId;
                        houseInfo.CityId          = houseInfoModel.CityId;
                        houseInfo.CountyId        = houseInfoModel.CountyId;
                        houseInfo.UserInfoID      = houseInfoModel.UserInfoID;
                        houseInfo.ShopId          = shop.ID;
                        houseInfo.ShopName        = shop.ShopName;
                        houseInfo.IsBack          = houseInfoModel.IsBack;
                        houseInfo.IsCancel        = houseInfoModel.IsCancel;

                        result = OperateContext.Current.BLLSession.IHouseInfoBLL.Modify(houseInfo);
                    }
                    else
                    {
                        msg = "系统未查询到房源信息!";
                    }
                }
                else
                {
                    // 新增
                    houseInfoModel.State      = 0;
                    houseInfoModel.CreateTime = DateTime.Now;
                    houseInfoModel.IsEmpty    = 0;
                    result = OperateContext.Current.BLLSession.IHouseInfoBLL.Add(houseInfoModel);
                }

                // 房源图片
                if (houseInfoModel.HouseImgList != null && houseInfoModel.HouseImgList.Count > 0)
                {
                    OperateContext.Current.BLLSession.IHouseImgBLL.DelBy(m => m.HouseInfoID == houseInfoModel.ID);

                    foreach (var houseImg in houseInfoModel.HouseImgList)
                    {
                        houseImg.HouseInfoID = houseInfoModel.ID;
                        houseImg.CreateTime  = DateTime.Now;

                        OperateContext.Current.BLLSession.IHouseImgBLL.Add(houseImg);
                    }
                }

                if (result == 1)
                {
                    status = "ok";
                    msg    = "保存成功!";
                }
            }
            else
            {
                msg = "获取数据失败!";
            }

            return(OperateContext.Current.RedirectAjax(status, msg, null, null));
        }
Ejemplo n.º 24
0
 public static bool GetHouseByID(ref HouseInfo model, ref string strError)
 {
     return(WMSWebService.service.GetHouseByID(ref model, Common_Var.CurrentUser, ref strError));
 }
Ejemplo n.º 25
0
 public static bool GetHouseList(ref List <HouseInfo> modelList, HouseInfo model, ref string strError)
 {
     return(WMSWebService.service.GetHouseList(ref modelList, model, Common_Var.CurrentUser, ref strError));
 }
Ejemplo n.º 26
0
 public static bool DeleteHouseByID(HouseInfo model, ref string strError)
 {
     return(WMSWebService.service.DeleteHouseByID(model, Common_Var.CurrentUser, ref strError));
 }
Ejemplo n.º 27
0
 /// <summary>
 /// 修改数据
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int Update(HouseInfo model)
 {
     return(dal.Update(model));
 }
Ejemplo n.º 28
0
 /// <summary>
 /// 添加数据到数据库
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int Insert(HouseInfo model)
 {
     return(dal.Insert(model));
 }
Ejemplo n.º 29
0
        public ActionResult SubmitOrder(OrderInfo order)
        {
            string status = "fail";
            string msg    = "提交订单失败!";

            // 房屋信息
            HouseInfo houseInfo = OperateContext.Current.BLLSession.IHouseInfoBLL.GetListBy(m => m.ID == order.HouseInfoID).FirstOrDefault();

            // 房东信息
            UserInfo userInfo = OperateContext.Current.BLLSession.IUserInfoBLL.GetListBy(m => m.ID == order.LandlordID).FirstOrDefault();

            // 校验数据
            if (houseInfo != null && userInfo != null)
            {
                order.LandlordName  = userInfo.Username;
                order.LandlordPhone = userInfo.PhoneNo;

                // 平台提成信息
                SystemConfig config = null;
                if (houseInfo.IsTrusteeship)
                {
                    config = OperateContext.Current.BLLSession.ISystemConfigBLL.GetListBy(m => m.Type == 2).FirstOrDefault();
                }
                else
                {
                    config = OperateContext.Current.BLLSession.ISystemConfigBLL.GetListBy(m => m.Type == 1).FirstOrDefault();
                }

                if (config != null)
                {
                    string strRand = "";
                    Random rand    = new Random();
                    for (int i = 0; i < 6; i++)
                    {
                        strRand += rand.Next(0, 10);
                    }

                    // 生成订单编号
                    string orderNo = DateTime.Now.ToString("yyyyMMddHHmmss") + strRand;

                    order.OrderNo         = orderNo;
                    order.UserInfoID      = OperateContext.Current.UserInfo.ID;
                    order.HouseTitle      = houseInfo.HouseTitle;
                    order.Price           = 0;
                    order.BuyCount        = (order.EndDate - order.StartDate).Days;
                    order.DownPayment     = houseInfo.Price * Convert.ToDecimal(config.Value) / 100 * order.BuyCount;
                    order.TotalPrice      = houseInfo.Price * order.BuyCount;
                    order.BalancePayment  = order.TotalPrice;
                    order.PlatformRoyalty = houseInfo.Price * Convert.ToDecimal(config.Value) / 100 * order.BuyCount;
                    order.IsFullPrice     = true;
                    order.State           = 0;
                    order.CreateTime      = DateTime.Now;
                    order.IsEvaluate      = false;

                    int result = OperateContext.Current.BLLSession.IOrderInfoBLL.Add(order);

                    if (result == 1)
                    {
                        status = "ok";
                        msg    = orderNo;
                    }
                    else
                    {
                        msg = "提交订单失败!";
                    }
                }
                else
                {
                    msg = "获取平台信息失败!";
                }
            }
            else
            {
                msg = "获取房源信息失败!";
            }

            return(OperateContext.Current.RedirectAjax(status, msg, null, null));
        }
Ejemplo n.º 30
0
        public ActionResult SubmitEvaluate(long orderId, int cleanScore, int locationScore, int environmentScore, int serviceScore, int performanceScore, string evaluateContent)
        {
            string status = "fail";
            string msg    = "提交评价失败!";

            if (orderId > 0)
            {
                OrderInfo orderInfo = OperateContext.Current.BLLSession.IOrderInfoBLL.GetListBy(m => m.ID == orderId).FirstOrDefault();

                if (orderInfo != null)
                {
                    // 订单信息
                    OrderInfo order = OperateContext.Current.BLLSession.IOrderInfoBLL.GetListBy(m => m.ID == orderId).FirstOrDefault();
                    if (order != null)
                    {
                        // 房屋信息
                        HouseInfo houseInfo = OperateContext.Current.BLLSession.IHouseInfoBLL.GetListBy(m => m.ID == order.HouseInfoID).FirstOrDefault();

                        if (houseInfo != null)
                        {
                            int averageScore = 0;
                            // 平均分
                            if (cleanScore != 0 || locationScore != 0 || environmentScore != 0 || serviceScore != 0 || performanceScore != 0)
                            {
                                averageScore = (cleanScore + locationScore + environmentScore + serviceScore + performanceScore) / 5;
                            }

                            // 评价信息
                            int result = OperateContext.Current.BLLSession.IHouseEvaluateBLL.Add(new HouseEvaluate()
                            {
                                AverageScore     = averageScore,
                                CleanScore       = cleanScore,
                                CreateTime       = DateTime.Now,
                                EnvironmentScore = environmentScore,
                                EvaluateContent  = evaluateContent,
                                HouseInfoID      = order.HouseInfoID,
                                HouseTitle       = order.HouseTitle,
                                LocationScore    = locationScore,
                                PerformanceScore = performanceScore,
                                ServiceScore     = serviceScore,
                                State            = 0,
                                UserInfoID       = order.UserInfoID,
                                Username         = order.Username,
                                UserPhone        = order.UserPhone,
                                UserImg          = OperateContext.Current.UserInfo.Img
                            });

                            if (result == 1)
                            {
                                // 更新订单评价状态
                                order.IsEvaluate = true;
                                result           = OperateContext.Current.BLLSession.IOrderInfoBLL.Modify(order, "IsEvaluate");
                            }

                            if (result == 1)
                            {
                                // 更新房屋评价信息
                                double averageScoreTotal = OperateContext.Current.BLLSession.IHouseEvaluateBLL.GetListBy(m => m.HouseInfoID == order.HouseInfoID).Sum(m => m.AverageScore);
                                int    evaluateCount     = OperateContext.Current.BLLSession.IHouseEvaluateBLL.CountRow(m => m.HouseInfoID == order.HouseInfoID);

                                int houseAverageScore = Convert.ToInt32(averageScoreTotal / evaluateCount);

                                houseInfo.EvaluateAvgScore = houseAverageScore;
                                houseInfo.EvaluateNum      = evaluateCount;
                                OperateContext.Current.BLLSession.IHouseInfoBLL.Modify(houseInfo, "EvaluateNum", "EvaluateAvgScore");
                            }

                            if (result == 1)
                            {
                                status = "ok";
                                msg    = "提交评价成功!";
                            }
                        }
                        else
                        {
                            msg = "房源信息不存在!";
                        }
                    }
                    else
                    {
                        msg = "订单信息不存在!";
                    }
                }
                else
                {
                    msg = "订单不存在!";
                }
            }
            else
            {
                msg = "参数错误!";
            }

            return(OperateContext.Current.RedirectAjax(status, msg, null, null));
        }