Exemplo n.º 1
0
        public ActionResult AddressList()
        {
            var customer = workContext.GetAuthenticatedCustomer();

            if (customer == null)
            {
                return(RedirectToAction("SingIn", "Login"));
            }

            AddressListModel model = new AddressListModel();
            var cam = db.CustomerAddressMappings.Where(x => x.CustomerId == customer.Id).ToList();

            foreach (var addressId in cam)
            {
                var          address      = db.Addresses.FirstOrDefault(x => x.Id == addressId.AddressId);
                AddressModel addressModel = new AddressModel();
                addressModel.Id           = address.Id;
                addressModel.FirsName     = address.FirsName;
                addressModel.LastName     = address.LastName;
                addressModel.ProvinceId   = address.ProvinceId;
                addressModel.CountiesId   = address.CountiesId;
                addressModel.Address      = address.Address1;
                addressModel.Email        = address.Email;
                addressModel.Phone        = address.Phone;
                addressModel.CreatedOnUtc = address.CreatedOnUtc;
                model.Address.Add(addressModel);
            }

            return(View(model));
        }
        public async Task <IActionResult> Index(Guid id)
        {
            var addresses = await _addressAppService.GetAllByCustomerIdIncluding(id);

            var provinces = await _provinceAppService.GetAll();

            var countries = await _countryAppService.GetAll();

            if (!countries.Any())
            {
                throw new Exception("No countries found!");
            }

            IEnumerable <SelectListItem> selectListCountries = countries.Select(x => new SelectListItem {
                Text = L(x.Name), Value = x.Id.ToString()
            }).ToList();
            IEnumerable <SelectListItem> selectListProvinces = provinces.Where(x => x.CountryId == countries.First().Id).Select(x => new SelectListItem {
                Text = x.Name, Value = x.Id.ToString()
            }).ToList();

            var addressViewModel = new AddressListModel()
            {
                CustomerId = id,
                Addresses  = addresses,
                Countries  = selectListCountries,
                Provinces  = selectListProvinces
            };

            return(View(addressViewModel));
        }
Exemplo n.º 3
0
        public Task PrepareModelAsync(AddressListModel model, IPageable <Address> addresses)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }
            if (addresses == null)
            {
                throw new ArgumentNullException(nameof(addresses));
            }

            foreach (var address in addresses)
            {
                var addressModel = new AddressModel
                {
                    Address     = address,
                    AddressType = model.AddressType
                };

                model.Items.Add(addressModel);
            }

            model.Page       = addresses.Page;
            model.PageSize   = addresses.PageSize;
            model.PageFrom   = addresses.PageFrom;
            model.PageTo     = addresses.PageTo;
            model.TotalPages = addresses.TotalPages;
            model.TotalItems = addresses.TotalItems;

            return(Task.CompletedTask);
        }
Exemplo n.º 4
0
        public ActionResult AddressList()
        {
            var identity  = User;
            var model     = new AddressListModel();
            var addresses = DefaultStorage.UserAddressList(identity.Id, 0).OrderByDescending(x => x.IsDefault);

            model.Addresses = addresses.ToList();
            return(View(model));
        }
Exemplo n.º 5
0
        public async Task <ApiResult> List(AddressListModel model)
        {
            User user = JwtHelper.JwtDecrypt <User>(ControllerContext);
            AddressSearchResult result = await addressService.GetModelListAsync(user.Id, null, null, null, model.PageIndex, model.PageSize);

            AddressListApiModel res = new AddressListApiModel();

            res.pageCount   = result.PageCount;
            res.addressList = result.Address.Select(a => new AddressList {
                id = a.Id, address = a.Address, name = a.Name, mobile = a.Mobile, isDefault = a.IsDefault
            }).ToList();
            return(new ApiResult {
                status = 1, data = res
            });
        }
Exemplo n.º 6
0
        public async Task <IActionResult> Addresses(AddressFilter filter, int page)
        {
            var customer = await HttpContext.GetMemberAsync();

            filter.CustomerId = customer.Id;

            var addresses = await _addressService.GetQuery(filter).ToPageableAsync(page, _appSettings.PageDefaultSize);

            var model = new AddressListModel
            {
                Filter      = filter,
                AddressType = null
            };

            await _appService.PrepareModelAsync(model, addresses);

            return(View("AddressList", model));
        }
Exemplo n.º 7
0
        public async Task <IActionResult> AddressBook(AddressType?showAddressType)
        {
            var customer = await HttpContext.GetMemberAsync();

            var filter = new AddressFilter {
                CustomerId = customer.Id
            };
            var addresses = await _addressService.ListAsync(filter);

            var model = new AddressListModel
            {
                Filter      = filter,
                AddressType = showAddressType
            };

            await _appService.PrepareModelAsync(model, addresses.ToPageable());

            return(PartialView("AddressBook", model));
        }
Exemplo n.º 8
0
        public void All()
        {
            var    mem           = TrainerFacade.Instance.GameMem;
            UInt64 constTextList = mem.ReadUInt64(unchecked ((IntPtr)(TrainerFacade.Instance.GameContext.ConstTextAddress)));
            UInt64 playerList    = mem.ReadUInt64(unchecked ((IntPtr)(TrainerFacade.Instance.GameContext.PlayerAddress)));
            uint   playerIndex   = 0;
            UInt64 playerBase    = mem.ReadUInt64(unchecked ((IntPtr)(playerList + 8 * playerIndex + 0x210)));

            #region 玩家资源

            AddressListModel player0Model = new AddressListModel()
            {
                Caption = "玩家0",
            };
            MenuModel.Instance.PlayerList.Add(new MenuModel.MenuItemModel()
            {
                Category    = MenuModel.MenuCategory.Resource,
                IsMarked    = false,
                ContentText = player0Model.Caption,
                BubbleText  = "",
                PageModel   = player0Model,
            });
            UInt64 playerTreasury = unchecked (playerBase + 0x8BD8);
            player0Model.Add("Gold", new Int64Scale256AddressInfo()
            {
                Address = unchecked ((IntPtr)(playerTreasury + 0xA0)),
            });
            UInt64 playerReligion = unchecked (playerBase + 0x7840);
            player0Model.Add("Faith", new Int64Scale256AddressInfo()
            {
                Address = unchecked ((IntPtr)(playerReligion + 0xA8)),
            });
            UInt64 playerInfluence = unchecked (playerBase + 0x8398);
            player0Model.Add("Influence", new Int64Scale256AddressInfo()
            {
                Address = unchecked ((IntPtr)(playerInfluence + 0xD0)),
            });
            UInt64 playerResources    = unchecked (playerBase + 0x5F48);
            UInt64 playerResourceList = mem.ReadUInt64(unchecked ((IntPtr)(playerResources + 0x198)));
            for (UInt64 resourceIndex = 0; resourceIndex <= 0x30; resourceIndex++)
            {
                UInt64 resourceItem = mem.ReadUInt64(unchecked ((IntPtr)(playerResourceList + 0x18 * resourceIndex)));
                player0Model.Add($"Resource{resourceIndex:X02}", new UInt32AddressInfo()
                {
                    Address = unchecked ((IntPtr)(resourceItem + 0x4 * 0)),
                });
            }
            UInt64 playerEras = unchecked (playerBase + 0x7F90);
            player0Model.Add("Era", new UInt32AddressInfo()
            {
                Address = unchecked ((IntPtr)(playerEras + 0xA0)),
            });
            UInt64 playerTrade = unchecked (playerBase + 0xA28);
            player0Model.Add("RouteCapacity", new UInt32AddressInfo()
            {
                Address = unchecked ((IntPtr)(playerTrade + 0x98)),
            });

            #endregion

            #region 城市

            // 先遍历城市列表
            List <UInt64> cityList     = new List <UInt64>();
            UInt64        playerCities = unchecked (playerBase + 0x1770);
            UInt64        nextCity     = mem.ReadUInt64(unchecked ((IntPtr)(playerCities + 0xB8)));
            while (nextCity != 0)
            {
                UInt64 city = mem.ReadUInt64(unchecked ((IntPtr)(nextCity + 0)));
                cityList.Add(city);
                nextCity = mem.ReadUInt64(unchecked ((IntPtr)(nextCity + 0x10)));
            }

            // 遍历缓存好的城市列表
            foreach (var city in cityList)
            {
                // 名称
                UInt64 cityNamePointer = mem.ReadUInt64(unchecked ((IntPtr)(city + 0x7E0)));
                string cityName        = mem.ReadCString(unchecked ((IntPtr)(cityNamePointer + 0)));
                cityName = GameTranslation.Instance.GetNameFromKey(cityName);

                // 模型
                AddressListModel cityModel = new AddressListModel()
                {
                    Caption = cityName,
                };
                MenuModel.Instance.CityList.Add(new MenuModel.MenuItemModel()
                {
                    Category    = MenuModel.MenuCategory.City,
                    IsMarked    = false,
                    ContentText = cityModel.Caption,
                    BubbleText  = "",
                    PageModel   = cityModel,
                });

                // 属性
                cityModel.Add("Population", new UInt32AddressInfo()
                {
                    Address = unchecked ((IntPtr)(city + 0x1E8)),
                });

                // 增长
                UInt64 growth = unchecked (city + 0xA38 + 0x20);
                cityModel.Add("HousingFromCivics", new UInt32AddressInfo()
                {
                    Address = unchecked ((IntPtr)(growth + 0x30)),
                });
                cityModel.Add("HousingFromGreatPeople", new UInt32AddressInfo()
                {
                    Address = unchecked ((IntPtr)(growth + 0x34)),
                });
                cityModel.Add("HousingFromStartingEra", new UInt32AddressInfo()
                {
                    Address = unchecked ((IntPtr)(growth + 0x38)),
                });
                cityModel.Add("AmenitiesFromEntertainment", new UInt32AddressInfo()
                {
                    Address = unchecked ((IntPtr)(growth + 0x3C)),
                });
                cityModel.Add("AmenitiesFromCivics", new UInt32AddressInfo()
                {
                    Address = unchecked ((IntPtr)(growth + 0x40)),
                });
                cityModel.Add("AmenitiesFromGreatPeople", new UInt32AddressInfo()
                {
                    Address = unchecked ((IntPtr)(growth + 0x44)),
                });
                cityModel.Add("AmenitiesFromCityStates", new UInt32AddressInfo()
                {
                    Address = unchecked ((IntPtr)(growth + 0x48)),
                });
                cityModel.Add("AmenitiesFromReligion", new UInt32AddressInfo()
                {
                    Address = unchecked ((IntPtr)(growth + 0x4C)),
                });
                UInt64 production = mem.ReadUInt64(unchecked ((IntPtr)(growth + 0)));
                cityModel.Add("YIELD_FROM_GAMEEFFECTS_0", new UInt32AddressInfo()
                {
                    Address = unchecked ((IntPtr)(production + 4 * 0 + 0x570)),
                });
                cityModel.Add("YIELD_FROM_GAMEEFFECTS_1", new UInt32AddressInfo()
                {
                    Address = unchecked ((IntPtr)(production + 4 * 1 + 0x570)),
                });
                cityModel.Add("YIELD_FROM_GAMEEFFECTS_2", new UInt32AddressInfo()
                {
                    Address = unchecked ((IntPtr)(production + 4 * 2 + 0x570)),
                });
                cityModel.Add("YIELD_FROM_GAMEEFFECTS_3", new UInt32AddressInfo()
                {
                    Address = unchecked ((IntPtr)(production + 4 * 3 + 0x570)),
                });
                cityModel.Add("YIELD_FROM_GAMEEFFECTS_4", new UInt32AddressInfo()
                {
                    Address = unchecked ((IntPtr)(production + 4 * 4 + 0x570)),
                });
                cityModel.Add("YIELD_FROM_GAMEEFFECTS_5", new UInt32AddressInfo()
                {
                    Address = unchecked ((IntPtr)(production + 4 * 5 + 0x570)),
                });
                cityModel.Add("YIELD_FROM_MODIFIER_GAMEEFFECTS_0", new UInt32AddressInfo()
                {
                    Address = unchecked ((IntPtr)(production + 4 * 0 + 0x4C0)),
                });
                cityModel.Add("YIELD_FROM_MODIFIER_GAMEEFFECTS_1", new UInt32AddressInfo()
                {
                    Address = unchecked ((IntPtr)(production + 4 * 1 + 0x4C0)),
                });
                cityModel.Add("YIELD_FROM_MODIFIER_GAMEEFFECTS_2", new UInt32AddressInfo()
                {
                    Address = unchecked ((IntPtr)(production + 4 * 2 + 0x4C0)),
                });
                cityModel.Add("YIELD_FROM_MODIFIER_GAMEEFFECTS_3", new UInt32AddressInfo()
                {
                    Address = unchecked ((IntPtr)(production + 4 * 3 + 0x4C0)),
                });
                cityModel.Add("YIELD_FROM_MODIFIER_GAMEEFFECTS_4", new UInt32AddressInfo()
                {
                    Address = unchecked ((IntPtr)(production + 4 * 4 + 0x4C0)),
                });
                cityModel.Add("YIELD_FROM_MODIFIER_GAMEEFFECTS_5", new UInt32AddressInfo()
                {
                    Address = unchecked ((IntPtr)(production + 4 * 5 + 0x4C0)),
                });
                cityModel.Add("YIELD_FROM_BUILDING_PRODUCTION_BONUS", new UInt32AddressInfo()
                {
                    Address = unchecked ((IntPtr)(production + 0x418)),
                });
            }

            #endregion

            #region 部队

            // 先遍历部队列表
            List <UInt64> unitList    = new List <UInt64>();
            UInt64        playerUnits = unchecked (playerBase + 0x10D8);
            UInt64        nextUnit    = mem.ReadUInt64(unchecked ((IntPtr)(playerUnits + 0xB8)));
            while (nextUnit != 0)
            {
                UInt64 unit = mem.ReadUInt64(unchecked ((IntPtr)(nextUnit + 0)));
                unitList.Add(unit);
                nextUnit = mem.ReadUInt64(unchecked ((IntPtr)(nextUnit + 0x10)));
            }

            // 按名称排序
            Dictionary <UInt64, string> unitNameMap = new Dictionary <UInt64, string>();
            UInt64 unitNameConstText1 = mem.ReadUInt64(unchecked ((IntPtr)(constTextList + 0x20)));
            UInt64 unitNameConstText2 = mem.ReadUInt64(unchecked ((IntPtr)(unitNameConstText1 + 0xE70)));
            foreach (var unit in unitList)
            {
                // 理论上应该先读自定义名字和伟人的名字,但我懒所以跳过。这里一律显示unit type的名字
                UInt32 unitType        = mem.ReadUInt32(unchecked ((IntPtr)(unit + 0xD0)));
                UInt64 unitTypeInfo    = mem.ReadUInt64(unchecked ((IntPtr)(unitNameConstText2 + unitType * 2 * 8)));
                UInt64 unitNamePointer = mem.ReadUInt64(unchecked ((IntPtr)(unitTypeInfo + 0x88)));
                string unitName        = mem.ReadCString(unchecked ((IntPtr)(unitNamePointer)));
                unitName          = GameTranslation.Instance.GetNameFromKey(unitName);
                unitNameMap[unit] = unitName;
            }
            unitList.Sort((left, right) => unitNameMap[left].CompareTo(unitNameMap[right]));

            // 遍历缓存好的部队列表
            foreach (var unit in unitList)
            {
                string unitName = unitNameMap[unit];

                // 模型
                AddressListModel unitModel = new AddressListModel()
                {
                    Caption = unitName,
                };
                MenuModel.Instance.ArmyList.Add(new MenuModel.MenuItemModel()
                {
                    Category    = MenuModel.MenuCategory.Army,
                    IsMarked    = false,
                    ContentText = unitModel.Caption,
                    BubbleText  = "",
                    PageModel   = unitModel,
                });

                // 其他
                unitModel.Add("Damage", new UInt32AddressInfo()
                {
                    Address = unchecked ((IntPtr)(unit + 0x528)),
                });
                UInt64 unitExperience = unchecked (unit + 0xE90 + 0x20);
                unitModel.Add("ExperiencePoints", new UInt32AddressInfo()
                {
                    Address = unchecked ((IntPtr)(unitExperience + 0xC)),
                });
                unitModel.Add("m_xMovesRemaining", new UInt32Scale256AddressInfo()
                {
                    Address = unchecked ((IntPtr)(unit + 0x608)),
                });
                unitModel.Add("m_iAttacksRemaining", new UInt32AddressInfo()
                {
                    Address = unchecked ((IntPtr)(unit + 0x640)),
                });
                unitModel.Add("m_iBuildCharges", new UInt32AddressInfo()
                {
                    Address = unchecked ((IntPtr)(unit + 0x6B0)),
                });
                unitModel.Add("m_iAirSlotsModifier", new UInt32AddressInfo()
                {
                    Address = unchecked ((IntPtr)(unit + 0x6E8)),
                });
                unitModel.Add("m_bAttackAfterMoving", new ByteAddressInfo()
                {
                    Address = unchecked ((IntPtr)(unit + 0x838)),
                });
                unitModel.Add("m_bMoveAfterAttacking", new ByteAddressInfo()
                {
                    Address = unchecked ((IntPtr)(unit + 0x870)),
                });
                unitModel.Add("m_kSightModifiers", new UInt32AddressInfo()
                {
                    Address = unchecked ((IntPtr)(unit + 0xC90)),
                });
                unitModel.Add("m_kAttackRangeModifiers", new UInt32AddressInfo()
                {
                    Address = unchecked ((IntPtr)(unit + 0xCC8)),
                });

                // 宗教
                UInt64 unitReligion = unchecked (unit + 0xFA0 + 0x20);
                unitModel.Add("ReligiousStrength", new UInt32AddressInfo()
                {
                    Address = unchecked ((IntPtr)(unitReligion + 0x8)),
                });
                unitModel.Add("SpreadCharges", new UInt32AddressInfo()
                {
                    Address = unchecked ((IntPtr)(unitReligion + 0x10)),
                });
            }

            #endregion

            #region 研究

            AddressListModel techModel = new AddressListModel()
            {
                Caption = "自然科学",
            };
            MenuModel.Instance.ResearchList.Add(new MenuModel.MenuItemModel()
            {
                Category    = MenuModel.MenuCategory.Tech,
                IsMarked    = false,
                ContentText = techModel.Caption,
                BubbleText  = "",
                PageModel   = techModel,
            });
            UInt64 playerTechs = unchecked (playerBase + 0x74A0);
            UInt64 techList    = mem.ReadUInt64(unchecked ((IntPtr)(playerTechs + 0x1E0)));
            for (UInt64 i = 0; i <= 0x43; i++)
            {
                techModel.Add($"Tech{i:X02}", new ByteAddressInfo()
                {
                    Address = unchecked ((IntPtr)(techList + i)),
                });
            }

            // 每回合科研虽说是在自然科学分类,但为了修改器的易用性所以移动到资源页
            player0Model.Add("SCIENCE_FROM_OTHER", new UInt32Scale256AddressInfo()
            {
                Address = unchecked ((IntPtr)(playerTechs + 0x1A8)),
            });

            AddressListModel civicModel = new AddressListModel()
            {
                Caption = "社会科学",
            };
            MenuModel.Instance.ResearchList.Add(new MenuModel.MenuItemModel()
            {
                Category    = MenuModel.MenuCategory.Civic,
                IsMarked    = false,
                ContentText = civicModel.Caption,
                BubbleText  = "",
                PageModel   = civicModel,
            });
            UInt64 playerCulture = unchecked (playerBase + 0x4F38);
            UInt64 civicList     = mem.ReadUInt64(unchecked ((IntPtr)(playerCulture + 0x530)));
            for (UInt64 i = 0; i <= 0x31; i++)
            {
                civicModel.Add($"Civic{i:X02}", new ByteAddressInfo()
                {
                    Address = unchecked ((IntPtr)(civicList + i)),
                });
            }

            // 每回合文化虽说是在社会科学分类,但为了修改器的易用性所以移动到资源页
            player0Model.Add("CULTURE_FROM_OTHER", new UInt32Scale256AddressInfo()
            {
                Address = unchecked ((IntPtr)(playerCulture + 0x740)),
            });

            #endregion

            #region 测试

            AddressListModel debug1Model = new AddressListModel()
            {
                Caption = "Debug1",
            };
            MenuModel.Instance.DebugList.Add(new MenuModel.MenuItemModel()
            {
                Category    = MenuModel.MenuCategory.Debug1,
                IsMarked    = false,
                ContentText = debug1Model.Caption,
                BubbleText  = "",
                PageModel   = debug1Model,
            });

            foreach (var city in cityList)
            {
            }

            foreach (var unit in unitList)
            {
            }

            #endregion
        }
Exemplo n.º 9
0
        private static AddressListModel ConvertPickListToAddressListModel(QAPicklistType qasPickList)
        {
            _log.Debug("START ConvertPickListToAddressListModel");
            AddressListModel addressList = new AddressListModel();

            if (qasPickList != null && qasPickList.PicklistEntry != null && qasPickList.PicklistEntry.Length > 0)
            {
                _log.Debug("PickListEntries were found. Count = " + qasPickList.PicklistEntry.Length.ToString());
                int          numPicklistTotal = qasPickList.PicklistEntry.Length;
                int          numOfEntries     = numPicklistTotal < Config.QasPickListLength ? numPicklistTotal : Config.QasPickListLength; // ASA.Web.Services.AddrValidationService
                AddressModel PriorAddr        = new AddressModel();

                for (int i = 0; i < numOfEntries; i++)
                {
                    if (qasPickList.PicklistEntry[i] != null &&
                        qasPickList.PicklistEntry[i].Picklist != null &&
                        !string.IsNullOrEmpty(qasPickList.PicklistEntry[i].Picklist))
                    {
                        _log.Debug("Creating AddressModel for PickListEntry[" + i + "]");

                        AddressModel addr = new AddressModel();
                        if (qasPickList.Total != "0")
                        {
                            //_log.Debug("PickListEntry[" + i + "].Picklist = " + qasPickList.PicklistEntry[i].Picklist + " Score: " + qasPickList.PicklistEntry[i].Score);

                            string[] pickListParts = null;
                            pickListParts = qasPickList.PicklistEntry[i].Picklist.Split(',');

                            addr.CountryID = "US";
                            //if (qasPickList.PicklistEntry[i].PostcodeRecoded)

                            if (qasPickList.PicklistEntry[i].Postcode != null && qasPickList.PicklistEntry[i].Postcode.Length >= 5)
                            {
                                string strFullPostalZip = null;
                                strFullPostalZip = qasPickList.PicklistEntry[i].Postcode;
                                if (strFullPostalZip != null && strFullPostalZip.Length >= 5)
                                {
                                    strFullPostalZip = strFullPostalZip.Trim();
                                    addr.Zip         = strFullPostalZip.Substring(0, 5);
                                }
                            }

                            if (pickListParts != null && pickListParts.Length >= 2)
                            {
                                string strCityState = null;
                                strCityState = pickListParts[pickListParts.Length - 1];
                                // remove [odd] or [even] trailing strings
                                if (strCityState.Contains("["))
                                {
                                    strCityState = strCityState.Substring(0, strCityState.LastIndexOf("["));
                                }
                                if (strCityState != null && strCityState.Length > 2)
                                {
                                    // clean up whitespace
                                    strCityState = strCityState.Trim();
                                    addr.City    = strCityState.Substring(0, strCityState.Length - 3);
                                    addr.StateID = strCityState.Substring(strCityState.Length - 2, 2);
                                }
                                addr.AddressLine1 = pickListParts[0];
                            }
                            if (pickListParts != null && pickListParts.Length >= 3)
                            {
                                addr.AddressLine1 = pickListParts[0];
                                addr.AddressLine2 = pickListParts[1];
                            }
                        }
                        if ((PriorAddr.AddressLine1 + PriorAddr.AddressLine2 + PriorAddr.City + PriorAddr.StateID + PriorAddr.Zip) != (addr.AddressLine1 + addr.AddressLine2 + addr.City + addr.StateID + addr.Zip))
                        {
                            addressList.Addresses.Add(addr);
                            PriorAddr = addr;
                        }
                        else
                        {
                            if (numPicklistTotal > numOfEntries)
                            {
                                numOfEntries++;
                            }
                        }
                    }
                }
            }

            _log.Debug("END ConvertPickListToAddressListModel");
            return(addressList);
        }