/// <summary> /// 获取首页新品上市商品列表 /// </summary> /// <returns></returns> public List <RecommendItemModel> GetHomeRecommendProductList() { var config = AppSettings.GetCachedConfig(); List <RecommendItemModel> res = new List <RecommendItemModel>(); List <RecommendProduct> resultList = RecommendFacade.QueryNewRecommendProduct(config.CountRecommendProductItemList, ConstValue.LanguageCode, ConstValue.CompanyCode); if (null != resultList && resultList.Count > 0) { foreach (var item in resultList) { RecommendItemModel model = new RecommendItemModel() { Code = item.ProductID, ID = item.SysNo, ImageUrl = ProductFacade.BuildProductImage(ImageUrlHelper.GetImageSize(ImageType.Middle), item.DefaultImage), Price = new SalesInfoModel() { CurrentPrice = item.RealPrice, BasicPrice = item.BasicPrice, TariffPrice = item.TariffPrice, CashRebate = item.CashRebate }, ProductTitle = item.ProductTitle, PromotionTitle = item.PromotionTitle }; res.Add(model); } } return(res); }
public List <RecommendItemModel> GetHomeRecommendItemList(int postionID, int count) { var recommendItemEntityList = RecommendFacade.QueryRecommendProduct(0, 0, postionID, count, ConstValue.LanguageCode, ConstValue.CompanyCode); List <RecommendItemModel> result = new List <RecommendItemModel>(); ImageSize imageSize = ImageUrlHelper.GetImageSize(ImageType.Middle); foreach (var itemEntity in recommendItemEntityList) { RecommendItemModel itemModel = new RecommendItemModel(); itemModel.ID = itemEntity.SysNo; itemModel.ProductTitle = itemEntity.BriefName; itemModel.PromotionTitle = itemEntity.PromotionTitle; itemModel.Code = itemEntity.ProductID; itemModel.ImageUrl = ProductFacade.BuildProductImage(imageSize, itemEntity.DefaultImage); var priceModel = new SalesInfoModel(); itemModel.Price = priceModel; priceModel.BasicPrice = itemEntity.BasicPrice; priceModel.CurrentPrice = itemEntity.RealPrice; priceModel.CashRebate = itemEntity.CashRebate; priceModel.TariffPrice = itemEntity.TariffPrice; priceModel.FreeEntryTax = itemEntity.TariffPrice <= ConstValue.TariffFreeLimit; decimal realTariffPrice = priceModel.TariffPrice; if (priceModel.FreeEntryTax) { realTariffPrice = 0; } priceModel.TotalPrice = itemEntity.CurrentPrice + itemEntity.CashRebate + realTariffPrice; result.Add(itemModel); } return(result); }
public ActionResult Register(User model, HttpPostedFileBase imageData) { if (ModelState.IsValid) { if (model.Password != model.PasswordConfirm) { ModelState.AddModelError(string.Empty, "введенные пароли не совпадают!"); return(View("Index", model)); } var userInDb = dbContext.Users.FirstOrDefault(c => c.Nickname == model.Nickname); if (userInDb != null) { ModelState.AddModelError(string.Empty, "Пользователь с таким псевдонимом уже существует"); return(View("Index", model)); } //// почта if (imageData != null) { model.Photo = ImageSaveHelper.SaveImage(imageData); } dbContext.Users.Add(model); dbContext.SaveChanges(); FormsAuthentication.SetAuthCookie(model.Nickname, false); Session["UserId"] = model.Id.ToString(); Session["Nickname"] = model.Nickname; Session["Photo"] = ImageUrlHelper.GetUrl(model.Photo); return(RedirectToAction("Index", "Home")); } return(View("Index", model)); }
public ActionResult MiniSnookerProfile(int athleteID, string extraText = "", string nameIfNotFound = "Not found") { var person = new PeopleLogic(db).GetBasic(0, athleteID); string picture = person != null ? person.Picture : null; if (string.IsNullOrEmpty(picture) == false) { picture = ImageUrlHelper.MakeUrlForWebProfile(picture); } else { picture = new Uri("/images/default-snookerplayer.png", UriKind.Relative).ToString(); } ViewBag.Picture = picture; ViewBag.ExtraText = extraText; if (person == null) { person = new PersonBasicWebModel(); person.Name = Url.Encode(nameIfNotFound); return(PartialView("MiniSnookerProfile", person)); } return(PartialView("MiniSnookerProfile", person)); }
private FloorModel MapFloor(FloorEntity floorEntity) { List <FloorItemBanner> bannerList = FloorHelper.GetFloorItem <FloorItemBanner>(floorEntity).OrderBy(x => x.Priority).ToList(); List <FloorItemProduct> productList = FloorHelper.GetFloorItem <FloorItemProduct>(floorEntity).OrderBy(x => x.Priority).ToList(); FloorModel model = new FloorModel(); //楼层基本信息 model.Name = floorEntity.FloorName; //banner var banner = bannerList.FirstOrDefault(); if (banner != null) { model.Banner.BannerResourceUrl = banner.ImageSrc; model.Banner.BannerTitle = banner.BannerText; model.Banner.BannerLink = banner.LinkUrl; //从BannerLink中提取相关信息(比如ProductSysNo等) BannerHelper.FillPromoInfo(model.Banner); } //推荐商品列表 ImageSize imageSize = ImageUrlHelper.GetImageSize(ImageType.Small); for (int i = 0; i < 3 && i < productList.Count; i++) { var item = productList[i]; var floorItemModel = MapFloorItem(item, imageSize); model.ItemList.Add(floorItemModel); } return(model); }
public ActionResult Login(LoginViewModel model) { if (ModelState.IsValid) //если заполнен и логин и пароль, то атворизация { var userInDb = dbContext.Users.FirstOrDefault( c => c.NickName == model.Nickname && c.Password == model.Password ); if (userInDb != null) { //храним пользователя в сессии FormsAuthentication.SetAuthCookie(userInDb.NickName, model.RememberMe); // задаем куки авторизации Session["UserId"] = userInDb.Id.ToString(); Session["Nickname"] = userInDb.NickName; Session["Photo"] = ImageUrlHelper.GetUrl(userInDb.Photo); return(RedirectToAction("Index", "Feed")); // переход на ленту } else { ModelState.AddModelError(string.Empty, "Неверный псевдоним или пароль"); } } return(View("Index", model)); }
public static GetImageUrlsResponse GetImageUrls(GetImageUrlsParameters parameters) { if (string.IsNullOrEmpty(parameters.Path)) { var empty = new GetImageUrlsResponse { imageUrls = new string[0] }; return(empty); } DocumentInfoOptions documentInfoOptions = new DocumentInfoOptions(parameters.Path); DocumentInfoContainer documentInfoContainer = _imageHandler.GetDocumentInfo(documentInfoOptions); int[] pageNumbers = new int[documentInfoContainer.Pages.Count]; for (int i = 0; i < documentInfoContainer.Pages.Count; i++) { pageNumbers[i] = documentInfoContainer.Pages[i].Number; } var applicationHost = GetApplicationHost(); string[] imageUrls = ImageUrlHelper.GetImageUrls(applicationHost, pageNumbers, parameters); var result = new GetImageUrlsResponse { imageUrls = imageUrls }; return(result); }
public ActionResult Login(LoginViewModel model) { if (ModelState.IsValid) { var useInDb = dbContext.Users.FirstOrDefault( c => c.Nickname == model.Nickname && c.Password == model.Password ); if (useInDb != null) { FormsAuthentication.SetAuthCookie(useInDb.Nickname, model.RememberMe); // авторизация через куки Session["UserId"] = useInDb.Id.ToString(); Session["Nickname"] = useInDb.Nickname; Session["Photo"] = ImageUrlHelper.GetUrl(useInDb.Photo); return(RedirectToAction("Index", "Feed")); } else { ModelState.AddModelError(string.Empty, "Неверный псевдоним или пароль!"); } } return(View("Index", model)); }
public static IEnumerable <object[]> GetEnumValues(Type type, string fileName) { foreach (var icon in Enum.GetValues(type)) { fileName = fileName ?? ImageUrlHelper.GetEmbeddedFontLocation((Enum)icon); yield return(new[] { icon, fileName }); } }
public override object?Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value is Guid imageid) { if (Guid.Empty == imageid) { return(null); } return(ImageUrlHelper.GetImageApiUrlById(imageid)); } return(value); }
/// <summary> /// 获取商品列表 /// </summary> /// <param name="info"></param> /// <param name="group"></param> /// <returns></returns> private static List <OrderProductItemModel> GetCartItemList(OrderInfo info, OrderItemGroup group) { List <OrderProductItemModel> list = new List <OrderProductItemModel>(); ImageSize imageSize = ImageUrlHelper.GetImageSize(ImageType.Middle); group.ProductItemList.ForEach(item => { OrderProductItemModel model = new OrderProductItemModel() { ProductSysNo = item.ProductSysNo, ProductID = item.ProductID, ProductName = item["ProductTitle"] == null ? "" : item["ProductTitle"].ToString(), SplitGroupPropertyDescList = item.SplitGroupPropertyDescList, DefaultImage = ProductFacade.BuildProductImage(imageSize, item.DefaultImage), ConsumptionDate = item.ConsumptionDate, UnitQuantity = item.UnitQuantity, UnitMarketPrice = item.UnitMarketPrice, UnitCostPrice = item.UnitCostPrice, UnitSalePrice = item.UnitSalePrice, Weight = item.Weight, TotalInventory = item.TotalInventory, WarehouseNumber = item.WarehouseNumber, WarehouseName = item.WarehouseName, WarehouseCountryCode = item.WarehouseCountryCode, MerchantSysNo = item.MerchantSysNo, UnitRewardedPoint = item.UnitRewardedPoint, TotalRewardedPoint = item.TotalRewardedPoint, SpecialActivityType = item.SpecialActivityType, SpecialActivitySysNo = item.SpecialActivitySysNo, Quantity = group.Quantity * item.UnitQuantity, AttachmentList = GetAttachment(info, GetPackageNo(group.PackageNo, item), item.ProductSysNo), GiftList = GetGiftItem(info, GetPackageNo(group.PackageNo, item), item.ProductSysNo, 2), ProductChecked = item.ProductChecked }; decimal discountPrice = item["UnitDiscountAmt"] == null ? GetDiscountPrice(info, GetPackageNo(group.PackageNo, item), item.ProductSysNo) : (decimal)item["UnitDiscountAmt"];//折扣金额 model.UnitPrice = item.UnitSalePrice - discountPrice; // model.UnitTaxFee = decimal.Round((decimal)item["TariffRate"] * (model.UnitPrice - (item["UnitCouponAmt"] == null ? 0m : (decimal)item["UnitCouponAmt"])), 2, MidpointRounding.AwayFromZero);//- (item["UnitDiscountAmt"] == null ? 0m : (decimal)item["UnitDiscountAmt"])折扣金额 model.UnitTaxFee = (item["UnitDiscountAmt"] == null ? 0m : (decimal)item["UnitDiscountAmt"]);//折扣金额 model.TotalSalePrice = (item.UnitSalePrice - discountPrice + model.UnitTaxFee) * model.Quantity; //计算是否已加入收藏夹 model.IsWished = false; Nesoft.ECWeb.UI.LoginUser currUser = Nesoft.ECWeb.UI.UserMgr.ReadUserInfo(); if (currUser != null && currUser.UserSysNo > 0) { model.IsWished = ProductFacade.IsProductWished(item.ProductSysNo, currUser.UserSysNo); } list.Add(model); }); return(list); }
public ImageUrlDto UploadImage(FileDescription imageFile) { if (!imageFile.IsImageFile()) { throw new BusinessException("Your Upload is not a Images!"); } var fileName = ImageUrlHelper.NewImageFileName(); _storageProvider.CreateImage(ImageUrlHelper.GetFileGuid(fileName).GetValueOrDefault(), imageFile.Data); return(ImageUrlHelper.ToImageUrl(fileName)); }
public ActionResult Register(User model, HttpPostedFileBase imageData) { if (ModelState.IsValid) { //регистрация if (model.Password != model.PasswordConfirm) { ModelState.AddModelError(string.Empty, "Введенные пароли не совпадают!"); return(View("Index", model)); } var userInDb = dBContext.Users.FirstOrDefault(c => c.Nickname == model.Nickname); if (userInDb != null) { ModelState.AddModelError(string.Empty, "Пользователь с таким псевдонимом уже существует!"); return(View("Index", model)); } var userEmailInDb = dBContext.Users.FirstOrDefault(c => c.Email == model.Email); if (userEmailInDb != null) { ModelState.AddModelError(string.Empty, "Данный адрес электронной почты уже использован!"); return(View("Index", model)); } if (imageData != null) { if (!ImageFormatHelper.IsJpg(imageData)) { ModelState.AddModelError(string.Empty, "Загруженное изображение не картинка формата JPG"); return(View("Index", model)); } model.Photo = ImageSaveHelper.SaveImage(imageData); } dBContext.Users.Add(model); dBContext.SaveChanges(); FormsAuthentication.SetAuthCookie(model.Nickname, false); Session["UserId"] = model.Id.ToString(); Session["Nickname"] = model.Nickname; // Session["Photo"] = userInDb.Photo.ToString(); Session["Photo"] = ImageUrlHelper.GetUrl(model.Photo); return(RedirectToAction("Index", "Feed")); } return(View("Index", model)); }
public CustomerSearchTypeView(StringHelper stringHelper, bool titleMode, string label, string type, string image) { Orientation = Android.Widget.Orientation.Horizontal; _stringHelper = stringHelper; _helper = new MobileCustomerSearchHelper(); TitleMode = titleMode; Label = label; CustomerType = type; Image = image; this.SetWillNotDraw(false); this.SetAccessibilityIdentifier(string.Format("TYPE:{0}", CustomerType)); if (TitleMode) { this.SetBackgroundColor(StyleGuide.OpaqueSkinColor); this.TitleLabel = Label; _selectAllButton = new SelectAllButton(stringHelper, _helper); _selectAllButton.Click += Handle_selectAllButtonTouchDown; var layoutParameters = new Android.Widget.LinearLayout.LayoutParams( Android.Views.ViewGroup.LayoutParams.WrapContent, Android.Views.ViewGroup.LayoutParams.WrapContent); layoutParameters.Gravity = Android.Views.GravityFlags.Center; _selectAllButton.LayoutParameters = layoutParameters; this.AddView(_selectAllButton); //this.SizeToFit(); } else { this.CustImage = ImageUrlHelper.GetImage(Image); this.CustTypeLabel = Label;; _selectCust = new CdlCheckBoxFactory.MultiCheckBox(false); _selectCust.On = false; _selectCust.On = _helper.IsSelected; _selectCust.ValueChanged += Handle_selectCustValueChanged; var layoutParameters = new Android.Widget.LinearLayout.LayoutParams( Android.Views.ViewGroup.LayoutParams.WrapContent, Android.Views.ViewGroup.LayoutParams.WrapContent); layoutParameters.SetMargins(8.px(), 8.px(), 8.px(), 8.px()); layoutParameters.Gravity = Android.Views.GravityFlags.Center; _selectCust.LayoutParameters = layoutParameters; this.AddView(_selectCust); //this.SizeToFit(); } }
public ActionResult Register(User model, HttpPostedFileBase imageData) { if (ModelState.IsValid) { if (model.Password != model.PasswordConfirm) { ModelState.AddModelError(string.Empty, "Введенные пароли не совпадают!"); return(View("Index", model)); } var userIndb = dbContext.Users.FirstOrDefault(c => c.Nickname == model.Nickname); if (userIndb != null) { ModelState.AddModelError(string.Empty, "Пользователь с таким именем уже существует"); return(View("Index", model)); } var emailIndb = dbContext.Users.FirstOrDefault(c => c.Email == model.Email); if (emailIndb != null) { ModelState.AddModelError(string.Empty, "Такая почта уже зарегистрирована"); return(View("Index", model)); } if (imageData != null) { if (!ImageFormatHelper.IsJpg(imageData)) { ModelState.AddModelError(string.Empty, "Загруженное изображение не картинка формата JPG"); return(View("Index", model)); } model.Photo = ImageSaveHelper.SaveImage(imageData); } dbContext.Users.Add(model); dbContext.SaveChanges(); FormsAuthentication.SetAuthCookie(model.Nickname, false); // авторизация через куки Session["UserId"] = model.Id.ToString(); Session["Nickname"] = model.Nickname; Session["Photo"] = ImageUrlHelper.GetUrl(model.Photo); return(RedirectToAction("Index", "Feed")); } return(View("Index", model)); }
public ActionResult GetImageUrls(GetImageUrlsParameters parameters) { var guid = parameters.Path; // Get document info var documentInfoContainer = _imageHandler.GetDocumentInfo(guid); var pageNumbers = documentInfoContainer.Pages.Select(_ => _.Number).ToArray(); var applicationHost = GetApplicationHost(); // Get image urls string[] imageUrls = ImageUrlHelper.GetImageUrls(applicationHost, pageNumbers, parameters); return(ToJsonResult(new GetImageUrlsResult(imageUrls))); }
public ActionResult Register(User model, HttpPostedFileBase imageData)//получать данные с формы и сохранять инфу в БД { if (ModelState.IsValid) { //регистрация if (model.Password != model.PasswordConfirm)//если пароли { ModelState.AddModelError(string.Empty, "Введенные пароли не совпадают!"); return(View("Index", model)); } //проверка для никнэйма var userInDb = dbContext.Users.FirstOrDefault(c => c.NickName == model.NickName); if (userInDb != null) { ModelState.AddModelError(string.Empty, "Пользователь с таким псевдонимом уже существует!"); return(View("Index", model)); } //проверка для почты var userEmailInDb = dbContext.Users.FirstOrDefault(c => c.Email == model.Email); if (userEmailInDb != null) { ModelState.AddModelError(string.Empty, "Пользователь с такой почтой уже существует!"); return(View("Index", model)); } if (imageData != null) { if (!ImageFormatHelper.IsJpg(imageData)) { ModelState.AddModelError(string.Empty, "Загруженное изображение не картинка формата JPG"); return(View("Index", model)); } model.Photo = ImageSaveHelper.SaveImage(imageData); } dbContext.Users.Add(model); dbContext.SaveChanges(); FormsAuthentication.SetAuthCookie(model.NickName, false); // задаем куки авторизации Session["UserId"] = model.Id.ToString(); Session["Nickname"] = model.NickName; Session["Photo"] = ImageUrlHelper.GetUrl(model.Photo); return(RedirectToAction("Index", "Feed")); // переход на ленту } return(View("Index", model)); }
public async Task SellerUpdateAds(SellerUpdateAds sellerUpdateAds) { if (sellerUpdateAds.EmailRecipients != null) { var viewModel = new SellerUpdateAdsViewModel { EmailContent = sellerUpdateAds.EmailContent }; var attachmentFile = string.Empty; if (sellerUpdateAds.AdsContent != null) { attachmentFile = ImageUrlHelper.PrepareAdsFile(sellerUpdateAds.AdsContent); } var body = await _razorViewToStringRenderer.RenderViewToStringAsync("/Views/Emails/Ads/SellerUpdateAds.cshtml", viewModel); await AddNotification(body, new EmailConf(sellerUpdateAds.EmailRecipients, Priority.High), sellerUpdateAds.Subject, attachmentFile); } }
public ActionResult Register(User model, HttpPostedFileBase imageData) { if (ModelState.IsValid) { if (model.Password != model.PasswordConfirm) { ModelState.AddModelError(string.Empty, "Пароли не совпадают"); return(View("Index", model)); } var userInDb = dBContext.Users.FirstOrDefault(c => c.Nickname == model.Nickname); if (userInDb != null) { ModelState.AddModelError(string.Empty, "Такой псевдоним уже занят"); return(View("Index", model)); } userInDb = null; userInDb = dBContext.Users.FirstOrDefault(c => c.Email == model.Email); if (userInDb != null) { ModelState.AddModelError(string.Empty, "Такая почта уже зарегистрированна"); return(View("Index", model)); } if (imageData != null) { if (!ImageFormatHelper.IsJpg(imageData)) { ModelState.AddModelError(string.Empty, "Загруженное изображение не jpeg"); return(View("Index", model)); } model.Photo = ImageSaveHelper.SaveImage(imageData); } dBContext.Users.Add(model); dBContext.SaveChanges(); FormsAuthentication.SetAuthCookie(model.Nickname, false); Session["UserId"] = model.Id.ToString(); Session["Nickname"] = model.Nickname.ToString(); Session["Photo"] = ImageUrlHelper.GetUrl(model.Photo); return(RedirectToAction("Index", "Feed")); } return(View("Index", model)); }
private static void ViewDocumentAsImage(ViewDocumentParameters request, ViewDocumentResponse result, string fileName) { var docInfo = _imageHandler.GetDocumentInfo(new DocumentInfoOptions(request.Path)); var maxWidth = 0; var maxHeight = 0; foreach (var pageData in docInfo.Pages) { if (pageData.Height > maxHeight) { maxHeight = pageData.Height; maxWidth = pageData.Width; } } var fileData = new FileData { DateCreated = DateTime.Now, DateModified = docInfo.LastModificationDate, PageCount = docInfo.Pages.Count, Pages = docInfo.Pages, MaxWidth = maxWidth, MaxHeight = maxHeight }; result.documentDescription = new FileDataJsonSerializer(fileData, new FileDataOptions()).Serialize(true); result.docType = docInfo.DocumentType; result.fileType = docInfo.FileType; DocumentInfoOptions documentInfoOptions = new DocumentInfoOptions(request.Path); DocumentInfoContainer documentInfoContainer = _imageHandler.GetDocumentInfo(documentInfoOptions); int[] pageNumbers = new int[documentInfoContainer.Pages.Count]; for (int i = 0; i < documentInfoContainer.Pages.Count; i++) { pageNumbers[i] = documentInfoContainer.Pages[i].Number; } string applicationHost = GetApplicationHost(); result.imageUrls = ImageUrlHelper.GetImageUrls(applicationHost, pageNumbers, request); }
private List <ProductItemModel> TransformResultItemList(PagedResult <ProductSearchResultItem> solrItemList) { List <ProductItemModel> result = new List <ProductItemModel>(); ImageSize imageSizeItemList = ImageUrlHelper.GetImageSize(ImageType.Middle); foreach (var item in solrItemList) { ProductItemModel model = new ProductItemModel(); //基本信息 model.ID = item.ProductSysNo; model.Code = item.ProductID; model.ProductTitle = item.ProductDisplayName; model.PromotionTitle = item.PromotionTitle; model.ImageUrl = ProductFacade.BuildProductImage(imageSizeItemList, item.ProductDefaultImage); //价格相关信息 SalesInfoModel salesInfo = new SalesInfoModel(); salesInfo.BasicPrice = item.MarketPrice; salesInfo.CurrentPrice = item.SalesPrice; salesInfo.CashRebate = item.CashRebate; salesInfo.TariffPrice = item.ProductTariffAmt; salesInfo.FreeEntryTax = item.ProductTariffAmt <= ConstValue.TariffFreeLimit; salesInfo.TotalPrice = item.TotalPrice; //赠送积分数量 salesInfo.PresentPoint = item.Point; salesInfo.OnlineQty = item.OnlineQty; salesInfo.IsHaveValidGift = item.IsHaveValidGift; salesInfo.IsCountDown = item.IsCountDown; salesInfo.IsNewProduct = item.IsNewproduct; salesInfo.IsGroupBuyProduct = item.IsGroupBuyProduct; model.SalesInfo = salesInfo; //其它信息 model.ReviewCount = item.ReviewCount; model.ReviewScore = item.ReviewScore; result.Add(model); } return(result); }
public async Task <ImageUrlDto> UpdateUserAvatarAsync(int userId, EditUserAvatarDto dto) { var userFromDb = await _userRepository.GetAsync(userId); if (dto.ImageFiles.IsNullOrEmpty()) { userFromDb.ADUserAvatarFileName = string.Empty; } else { userFromDb.ADUserAvatarFileName = ImageUrlHelper.NewImageFileName(); _storageProvider.CreateImage(ImageUrlHelper.GetFileGuid(userFromDb.ADUserAvatarFileName).GetValueOrDefault(), dto.ImageFiles.First()); } await _userRepository.UpdateAsync(userFromDb); await _unitOfWork.CompleteAsync(); return(ImageUrlHelper.ToImageUrl(ImageUrlHelper.GetFileGuid(userFromDb.ADUserAvatarFileName).GetValueOrDefault())); }
public ImageSource GetImageSource(string picture, BackgroundEnum background = BackgroundEnum.White, bool originalSize = false) { if (string.IsNullOrEmpty(picture) == true || picture.ToLower().StartsWith("http") == false) { string file; if (background == BackgroundEnum.Background1) { file = "personBackground1.png"; } else if (background == BackgroundEnum.Black) { file = "personBlackBackground.png"; } else { file = "personWhiteBackground.png"; } return(new FileImageSource() { File = file }); } string url; if (originalSize) { url = ImageUrlHelper.MakeUrlForOriginalImage(picture); } else { url = ImageUrlHelper.MakeUrlForMobileProfile(picture, background); } return(new UriImageSource() { Uri = new Uri(url) }); }
/// <summary> /// 获取赠品 /// </summary> /// <param name="info"></param> /// <param name="packageNo">套餐编号</param> /// <param name="ParentProductSysNo"></param> /// <param name="isGiftPool">0获取全部,1赠品池 2非赠品池</param> /// <returns></returns> private static List <OrderGiftItem> GetGiftItem(OrderInfo info, int packageNo, int parentProductSysNo, int isGiftPool) { List <OrderGiftItem> list = new List <OrderGiftItem>(); if (info.GiftItemList != null && info.GiftItemList.Count > 0) { MobileAppConfig config = AppSettings.GetCachedConfig(); ImageSize imageSize = ImageUrlHelper.GetImageSize(ImageType.Middle); string path = config.MobileAppServiceHost; foreach (OrderGiftItem item in info.GiftItemList) { if (string.IsNullOrEmpty(item.DefaultImage)) { item.DefaultImage = path.TrimEnd('/').TrimEnd('\\') + "/Resources/Images/shoppingcart" + (item.ProductSysNo % 4 + 1) + ".jpg"; } else { item.DefaultImage = ProductFacade.BuildProductImage(imageSize, item.DefaultImage); } if (isGiftPool == 0 && item.ParentProductSysNo == parentProductSysNo && item.ParentPackageNo == packageNo) { list.Add(item); } else if (isGiftPool == 1 && item.ParentProductSysNo == parentProductSysNo && item.ParentPackageNo == packageNo && item.IsGiftPool == true) { list.Add(item); } else if (isGiftPool == 2 && item.ParentProductSysNo == parentProductSysNo && item.ParentPackageNo == packageNo && item.IsGiftPool == false) { list.Add(item); } } } return(list); }
public List <RecommendItemModel> MapAdvItem(List <SaleAdvertisementItem> advItemList) { List <RecommendItemModel> result = new List <RecommendItemModel>(); if (advItemList == null) { return(result); } ImageSize imageSize = ImageUrlHelper.GetImageSize(ImageType.Big); foreach (var itemEntity in advItemList) { RecommendItemModel itemModel = new RecommendItemModel(); itemModel.ID = itemEntity.ProductSysNo; itemModel.ProductTitle = itemEntity.ProductTitle; itemModel.Code = itemEntity.ProductCode; itemModel.ImageUrl = ProductFacade.BuildProductImage(imageSize, itemEntity.DefaultImage); var priceModel = new SalesInfoModel(); itemModel.Price = priceModel; priceModel.BasicPrice = itemEntity.MarketPrice; priceModel.CurrentPrice = itemEntity.CurrentPrice; priceModel.CashRebate = itemEntity.CashRebate; priceModel.FreeEntryTax = itemEntity.ProductTariffAmt <= ConstValue.TariffFreeLimit; priceModel.TariffPrice = itemEntity.ProductTariffAmt; decimal realTariffPrice = priceModel.TariffPrice; if (priceModel.FreeEntryTax) { realTariffPrice = 0; } priceModel.TotalPrice = itemEntity.CurrentPrice + itemEntity.CashRebate + realTariffPrice; result.Add(itemModel); } return(result); }
private void ViewDocumentAsImage(ViewDocumentParameters request, ViewDocumentResponse result) { var guid = request.Path; // Get document info var documentInfo = _imageHandler.GetDocumentInfo(guid); // Serialize document info SerializationOptions serializationOptions = new SerializationOptions { UsePdf = request.UsePdf, SupportListOfBookmarks = request.SupportListOfBookmarks, SupportListOfContentControls = request.SupportListOfContentControls }; var documentInfoJson = new DocumentInfoJsonSerializer(documentInfo, serializationOptions) .Serialize(); // Build result result.documentDescription = documentInfoJson; result.docType = documentInfo.DocumentType; result.fileType = documentInfo.FileType; int[] pageNumbers = documentInfo.Pages.Select(_ => _.Number).ToArray(); result.imageUrls = ImageUrlHelper.GetImageUrls(GetApplicationHost(), pageNumbers, request); }
/// <summary> /// 限时抢购列表 /// </summary> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> /// <returns></returns> public QueryResult <CountDownItemModel> GetCountDownList(int pageIndex, int pageSize) { var countDownList = CountDownFacade.GetCountDownList(pageIndex, pageSize); //列表信息 QueryResult <CountDownItemModel> result = new QueryResult <CountDownItemModel>(); result.ResultList = new List <CountDownItemModel>(); ImageSize imageSize = ImageUrlHelper.GetImageSize(ImageType.Middle); var countDownItemList = countDownList.ResultList ?? new List <CountDownInfo>(); foreach (var item in countDownItemList) { CountDownItemModel itemModel = new CountDownItemModel(); itemModel.Code = item.ProductID; itemModel.ID = item.ProductSysNo; itemModel.ImageUrl = ProductFacade.BuildProductImage(imageSize, item.DefaultImage); itemModel.ProductTitle = item.ProductTitle; itemModel.PromotionTitle = item.PromotionTitle; //Asura 添加开始时间 开始 itemModel.StartTime = string.Format("{0:G}", item.StartTime); //Asura 添加开始时间 结束 if (item.StartTime > DateTime.Now) { itemModel.LeftSeconds = (int)(DateTime.Now - item.StartTime).TotalSeconds; } else { if (item.EndTime < DateTime.Now) { itemModel.LeftSeconds = 0; } else { itemModel.LeftSeconds = (int)(item.EndTime - DateTime.Now).TotalSeconds; } } //销售相关信息 var priceModel = new SalesInfoModel(); itemModel.Price = priceModel; decimal realSnapShotTariffPrice = item.SnapShotTariffPrice; if (realSnapShotTariffPrice <= ConstValue.TariffFreeLimit) { realSnapShotTariffPrice = 0; } priceModel.BasicPrice = item.SnapShotCurrentPrice + item.SnapShotCashRebate + realSnapShotTariffPrice; priceModel.CurrentPrice = item.CountDownPrice; priceModel.CashRebate = item.CountDownCashRebate; priceModel.TariffPrice = item.TariffPrice; decimal realTariffPrice = item.TariffPrice; if (item.TariffPrice <= ConstValue.TariffFreeLimit) { realTariffPrice = 0; } priceModel.TotalPrice = item.CountDownPrice + item.CountDownCashRebate + realTariffPrice; priceModel.OnlineQty = item.OnlineQty; result.ResultList.Add(itemModel); } result.ResultList.Sort((x, y) => x.LeftSeconds.CompareTo(y.LeftSeconds)); //result.ResultList.Reverse(); //分页信息 if (countDownList.PageInfo != null) { var pageInfo = new PageInfo(); pageInfo.PageIndex = pageIndex; pageInfo.PageSize = pageSize; pageInfo.TotalCount = countDownList.PageInfo.TotalCount; result.PageInfo = pageInfo; } return(result); }
private static void ViewDocumentAsImage(ViewDocumentParameters request, ViewDocumentResponse result, string fileName) { var docInfo = _imageHandler.GetDocumentInfo(request.Path); var maxWidth = 0; var maxHeight = 0; foreach (var pageData in docInfo.Pages) { if (pageData.Height > maxHeight) { maxHeight = pageData.Height; maxWidth = pageData.Width; } } var fileData = new FileData { DateCreated = DateTime.Now, DateModified = docInfo.LastModificationDate, PageCount = docInfo.Pages.Count, Pages = docInfo.Pages, MaxWidth = maxWidth, MaxHeight = maxHeight }; int[] pageNumbers = new int[docInfo.Pages.Count]; for (int i = 0; i < docInfo.Pages.Count; i++) { pageNumbers[i] = docInfo.Pages[i].Number; } string applicationHost = GetApplicationHost(); var documentUrls = ImageUrlHelper.GetImageUrls(applicationHost, pageNumbers, request); string[] attachmentUrls = new string[0]; foreach (AttachmentBase attachment in docInfo.Attachments) { List <PageImage> pages = _imageHandler.GetPages(attachment); var attachmentInfo = _imageHandler.GetDocumentInfo(_tempPath + "\\" + Path.GetFileNameWithoutExtension(docInfo.Guid) + Path.GetExtension(docInfo.Guid).Replace(".", "_") + "\\attachments\\" + attachment.Name); fileData.PageCount += pages.Count; fileData.Pages.AddRange(attachmentInfo.Pages); ViewDocumentParameters attachmentResponse = request; attachmentResponse.Path = attachmentInfo.Guid; int[] attachmentPageNumbers = new int[pages.Count]; for (int i = 0; i < pages.Count; i++) { attachmentPageNumbers[i] = pages[i].PageNumber; } Array.Resize <string>(ref attachmentUrls, (attachmentUrls.Length + pages.Count)); string[] attachmentImagesUrls = new string[pages.Count]; attachmentImagesUrls = ImageUrlHelper.GetImageUrls(applicationHost, attachmentPageNumbers, attachmentResponse); attachmentImagesUrls.CopyTo(attachmentUrls, (attachmentUrls.Length - pages.Count)); } SerializationOptions serializationOptions = new SerializationOptions { UsePdf = request.UsePdf, SupportListOfBookmarks = request.SupportListOfBookmarks, SupportListOfContentControls = request.SupportListOfContentControls }; var documentInfoJson = new DocumentInfoJsonSerializer(docInfo, serializationOptions).Serialize(); result.documentDescription = documentInfoJson; result.docType = docInfo.DocumentType; result.fileType = docInfo.FileType; if (docInfo.Attachments.Count > 0) { var imagesUrls = new string[attachmentUrls.Length + documentUrls.Length]; documentUrls.CopyTo(imagesUrls, 0); attachmentUrls.CopyTo(imagesUrls, documentUrls.Length); result.imageUrls = imagesUrls; } else { result.imageUrls = documentUrls; } }
public static GetImageUrlsResponse GetImageUrls(GetImageUrlsParameters parameters) { var docPath = parameters.Path; if (string.IsNullOrEmpty(parameters.Path)) { var empty = new GetImageUrlsResponse { imageUrls = new string[0] }; return(empty); } DocumentInfoContainer documentInfoContainer = _imageHandler.GetDocumentInfo(parameters.Path); int[] pageNumbers = new int[documentInfoContainer.Pages.Count]; for (int i = 0; i < documentInfoContainer.Pages.Count; i++) { pageNumbers[i] = documentInfoContainer.Pages[i].Number; } var applicationHost = GetApplicationHost(); string[] imageUrls = ImageUrlHelper.GetImageUrls(applicationHost, pageNumbers, parameters); string[] attachmentUrls = new string[0]; foreach (AttachmentBase attachment in documentInfoContainer.Attachments) { List <PageImage> pages = _imageHandler.GetPages(attachment); var attachmentInfo = _imageHandler.GetDocumentInfo(_tempPath + "\\" + Path.GetFileNameWithoutExtension(docPath) + Path.GetExtension(docPath).Replace(".", "_") + "\\attachments\\" + attachment.Name); GetImageUrlsParameters attachmentResponse = parameters; attachmentResponse.Path = attachmentInfo.Guid; int[] attachmentPageNumbers = new int[pages.Count]; for (int i = 0; i < pages.Count; i++) { attachmentPageNumbers[i] = pages[i].PageNumber; } Array.Resize <string>(ref attachmentUrls, (attachmentUrls.Length + pages.Count)); string[] attachmentImagesUrls = new string[pages.Count]; attachmentImagesUrls = ImageUrlHelper.GetImageUrls(applicationHost, attachmentPageNumbers, attachmentResponse); attachmentImagesUrls.CopyTo(attachmentUrls, (attachmentUrls.Length - pages.Count)); } if (documentInfoContainer.Attachments.Count > 0) { var imagesUrls = new string[attachmentUrls.Length + imageUrls.Length]; imageUrls.CopyTo(imagesUrls, 0); attachmentUrls.CopyTo(imagesUrls, imageUrls.Length); var result = new GetImageUrlsResponse { imageUrls = imagesUrls }; return(result); } else { var result = new GetImageUrlsResponse { imageUrls = imageUrls }; return(result); } }
public ImageUrlDto GetImageUrl(Guid guid) { return(ImageUrlHelper.ToImageUrl(guid)); }