Exemplo n.º 1
0
		public bool CanPutInCart(BXIBlockElement item)
		{
			if(item == null)
				throw new ArgumentNullException("item");

			BXCatalogItem catalogItem = GetCatalogItem(item);
			if(catalogItem == null)
				return CanPutInCart(item.Id);

			return catalogItem.Catalog != null && (!catalogItem.Catalog.CheckStockAvailability || catalogItem.Quantity > 0);
		}
Exemplo n.º 2
0
        public CatalogueElementListComponent.CatalogClientPriceInfoSet GetClientPriceSet(BXIBlockElement item, int initQuantity, bool displayAllTiers, string[] userRoleNames, int currencyId, bool includeVATInPrice, IEnumerable<int> priceTypes)
        {
			if(item == null)
				throw new ArgumentNullException("item");

			BXCatalogItem catalogItem = GetCatalogItem(item);
			BXCatalogClientPriceSet set = catalogItem != null 
				? new BXCatalogClientPriceSet(catalogItem, !displayAllTiers ? initQuantity : 0, userRoleNames, currencyId, includeVATInPrice, priceTypes, BXCatalogClientPriceSetMode.View)
				: new BXCatalogClientPriceSet(item.Id, !displayAllTiers ? initQuantity : 0, userRoleNames, currencyId, includeVATInPrice, priceTypes, BXCatalogClientPriceSetMode.View);

            CatalogueElementListComponent.CatalogClientPriceInfo[] items = 
				new CatalogueElementListComponent.CatalogClientPriceInfo[set.Count];

            for (int i = 0; i < set.Count; i++)
                items[i] = CreateInfo(set[i]);

            return new CatalogueElementListComponent.CatalogClientPriceInfoSet(GetPriceTypes(), items, CreateInfo(set.GetSellingPrice(initQuantity > 0 ? initQuantity : 1)));
        }
Exemplo n.º 3
0
		public bool HasSkuItems(BXIBlockElement item)
		{
			if(item == null)
				throw new ArgumentNullException("item");

			BXCatalogItem catalogItem = GetCatalogItem(item);
			if(catalogItem != null)
				return catalogItem.SKUQuantity > 0;

			return HasSkuItems(item.Id);
		}
Exemplo n.º 4
0
		private BXCatalogItem GetCatalogItem(BXIBlockElement item)
		{
			if(item == null)
				return null;

			BXCatalogItem catalogItem;
			InnerCatalogItemAdapter.TryGetJoinedEntity(item, "_BX_CATALOG_ITEM_", out catalogItem);
			return catalogItem;
		}
Exemplo n.º 5
0
    public void TrySaveImages(int albumId)
    {
        if (!string.Equals(Request.HttpMethod, "POST", StringComparison.OrdinalIgnoreCase))
			return;

		//try
        //{
            int fileCount;

            if (!int.TryParse(Request.Form["FileCount"], out fileCount))
                return;

            //Iterate through uploaded data and save the original file, thumbnail, and description.
            for (int i = 1; i <= fileCount; i++)
            {
                //Get first thumbnail (the single thumbnail in this code sample) and save it to disk.
                HttpPostedFile thumbnail1File = Request.Files["Thumbnail1_" + i];
                HttpPostedFile thumbnail2File = Request.Files["Thumbnail2_" + i];
                HttpPostedFile thumbnail3File = Request.Files["Thumbnail3_" + i];

                //Save file info.
                string description = Request.Form["Description_" + i];
                string title = Request.Form["Title_" + i];
                if (title == String.Empty) title = thumbnail3File.FileName;

                //CREATE NEW FOTO

                //try
                //{
                    //if (!currentUserCanModifyElement)
                    //    throw new Exception("У вас не достаточно прав для создания нового элемента");

                bool savedSuccessfully = true;
                BXFile preview = null, detail = null;
                try
                {

                    detail = SaveFile(thumbnail3File);
                    preview = SaveFile(thumbnail1File);
                    
                    if (detail != null)
                    {
                        string detailFileName = detail.FileName.Substring(0,detail.FileName.LastIndexOf("."));
                        
                        Bitrix.Services.Image.BXImageInfo imageInfo =
                            Bitrix.Services.Image.BXImageUtility.GetResizedImage(
                                detail, PreviewWidth, PreviewHeight);

                        imageInfo =
                            Bitrix.Services.Image.BXImageUtility.GetResizedImage(
                                detail, PhotoWidth, PhotoHeight);

                        //imageInfo =
                        //    Bitrix.Services.Image.BXImageUtility.GetResizedImage(
                        //        detail, CoverWidth, CoverHeight);

                    //SaveFileToUploadFolder(thumbnail2File, PhotoWidth, PhotoHeight, Parameters.Get<string>("PhotoFolder"), BXPath.ToPhysicalPath(detail.FilePath),detailFileName);
                    }
                }
                catch (FormatException e)
                {
                    savedSuccessfully = false;
                    AddError(string.Concat(thumbnail1File.FileName, ": " ,e.Message));
                }


                if (!savedSuccessfully)
                    continue;

                BXIBlockElement el = new BXIBlockElement(Parameters.Get("IBlockId", 6), title, BXTextEncoder.EmptyTextEncoder);

                el.Active = true;
                el.ActiveFromDate = DateTime.MinValue;
                el.ActiveToDate = DateTime.MaxValue;
                el.CreatedBy = ((BXIdentity)Page.User.Identity).Id;
                el.ModifiedBy = ((BXIdentity)Page.User.Identity).Id;
                el.Sort = 500;
                el.DetailImageId = (detail!=null)? detail.Id : 0;
                el.DetailText = description;
                el.PreviewImageId = ((preview != null) ? preview.Id : 0);
                el.DetailTextType = BXTextType.Text;
                el.XmlId = Guid.NewGuid().ToString();
                el.Code = String.Empty;

                el.Sections.Add(albumId);
                el.Save();

                    if (el == null)
                        throw new Exception(GetMessageRaw("Exception.AnErrorHasOccurredWhileCreationElement"));
                //}
                //catch (BXEventException ee)
                //{
                //    throw ee;
                //}
                //catch (Exception ee)
                //{
                //    throw ee;
                //}
            }
        //}
        //catch{}

        Response.AddHeader("X-Powered-CMS", "Bitrix Site Manager (582fd04dac6869e159ea80524ec43d0d)");
    }