コード例 #1
0
        public void SaveItemAndAttributes(int itemID, int itemTypeID, int attributeSetID, int storeID, int portalID, string userName, string culture, int taxRuleID, string categoriesIds, string relatedItemsIds, string upSellItemsIds, string crossSellItemsIds, string downloadItemsValue, string sourceFileCol, string dataCollection, AspxNameValue[] formVars)
        {
            try
            {
                string uplodedDownlodableFormValue = string.Empty;

                if (itemTypeID == 2 && downloadItemsValue != "")
                {
                    FileHelperController downLoadableObj = new FileHelperController();
                    string tempFolder = @"Upload\temp";
                    uplodedDownlodableFormValue = downLoadableObj.MoveFileToDownlodableItemFolder(tempFolder,
                                                                                                  downloadItemsValue,
                                                                                                  @"Modules/AspxCommerce/AspxItemsManagement/DownloadableItems/",
                                                                                                  itemID, "item_");
                }

                ItemsController itemController = new ItemsController();
                itemID = itemController.SaveUpdateItemAndAttributes(itemID, itemTypeID, attributeSetID, storeID, portalID,
                                                                    userName, culture, taxRuleID,
                                                                    categoriesIds, relatedItemsIds, upSellItemsIds,
                                                                    crossSellItemsIds, uplodedDownlodableFormValue,
                                                                    formVars);
                //return "({\"returnStatus\":1,\"Message\":'Item saved successfully.'})";
                if (itemID > 0 && sourceFileCol != "" && dataCollection != "")
                {
                    StoreSettingConfig ssc = new StoreSettingConfig();
                    int itemLargeThumbNailSize = Convert.ToInt32(ssc.GetStoreSettingsByKey(StoreSetting.ItemLargeThumbnailImageSize, storeID,
                                                                                           portalID, culture));
                    int itemMediumThumbNailSize = Convert.ToInt32(ssc.GetStoreSettingsByKey(StoreSetting.ItemMediumThumbnailImageSize,
                                                                                            storeID, portalID, culture));
                    int itemSmallThumbNailSize = Convert.ToInt32(ssc.GetStoreSettingsByKey(StoreSetting.ItemSmallThumbnailImageSize, storeID,
                                                                                           portalID, culture));
            
                    dataCollection = dataCollection.Replace("../", "");
                    SaveImageContents(itemID, @"Modules/AspxCommerce/AspxItemsManagement/uploads/", sourceFileCol,
                                      dataCollection, itemLargeThumbNailSize, itemMediumThumbNailSize,
                                      itemSmallThumbNailSize, "item_");
                }
                else if (itemID > 0 && sourceFileCol == "" && dataCollection == "")
                {
                    DeleteImageContents(itemID);
                }

                //if (itemID==0)
                //{
                //    //SaveImageContents(itemID, @"Modules/AspxCommerce/AspxItemsManagement/uploads/", sourceFileCol, dataCollection, "item_");
                //    //TODO:: DELTE UPLOADED FILE FROM DOWNLOAD FOLDER

                //}
            }
            catch (Exception ex)
            {
                throw ex;
                //ErrorHandler errHandler = new ErrorHandler();
                //if (errHandler.LogWCFException(ex))
                //{
                //    return "({\"returnStatus\":-1,\"errorMessage\":'" + ex.Message + "'})";
                //}
                //else
                //{
                //    return "({\"returnStatus\":-1,\"errorMessage\":'Error while saving item!'})";
                //}
            }
        }
コード例 #2
0
        public int SaveItemAndAttributes(ItemsInfo.ItemSaveBasicInfo itemObj, AspxCommonInfo aspxCommonObj)
        {
            try
            {
                string uplodedDownlodableFormValue = string.Empty;

                if (itemObj.ItemTypeId == 2 && itemObj.DownloadItemsValue != "")
                {
                    FileHelperController downLoadableObj = new FileHelperController();
                    string tempFolder = @"Upload\temp";
                    uplodedDownlodableFormValue = downLoadableObj.MoveFileToDownlodableItemFolder(tempFolder,
                                                                                                  itemObj.DownloadItemsValue,
                                                                                                  @"Modules/AspxCommerce/AspxItemsManagement/DownloadableItems/",
                                                                                                  itemObj.ItemId, "item_");
                    itemObj.DownloadItemsValue = uplodedDownlodableFormValue;
                }


                int itemID = AspxItemMgntController.SaveUpdateItemAndAttributes(itemObj, aspxCommonObj);

                //kit produtct
                if (itemObj.ItemTypeId == 6)
                {

                    AspxKitController _kitCtl = new AspxKitController();
                    _kitCtl.SaveKits(itemObj.KitConfig, itemID, aspxCommonObj);
                }
                //return "({\"returnStatus\":1,\"Message\":'Item saved successfully.'})";
                int storeId = aspxCommonObj.StoreID;
                int portalId = aspxCommonObj.PortalID;
                string culture = aspxCommonObj.CultureName;
                // if (itemID > 0 && sourceFileCol != "" && dataCollection != "")
                if (itemID > 0 && itemObj.SourceFileCol != "" && itemObj.DataCollection != "")
                {
                    StoreSettingConfig ssc = new StoreSettingConfig();
                    int itemLargeThumbNailHeight = Convert.ToInt32(ssc.GetStoreSettingsByKey(StoreSetting.ItemLargeThumbnailImageHeight, storeId, portalId, culture));
                    int itemLargeThumbNailWidth = Convert.ToInt32(ssc.GetStoreSettingsByKey(StoreSetting.ItemLargeThumbnailImageWidth, storeId, portalId, culture));
                    int itemMediumThumbNailHeight = Convert.ToInt32(ssc.GetStoreSettingsByKey(StoreSetting.ItemMediumThumbnailImageHeight, storeId, portalId, culture));
                    int itemMediumThumbNailWidth = Convert.ToInt32(ssc.GetStoreSettingsByKey(StoreSetting.ItemMediumThumbnailImageWidth, storeId, portalId, culture));
                    int itemSmallThumbNailHeight = Convert.ToInt32(ssc.GetStoreSettingsByKey(StoreSetting.ItemSmallThumbnailImageHeight, storeId, portalId, culture));
                    int itemSmallThumbNailWidth = Convert.ToInt32(ssc.GetStoreSettingsByKey(StoreSetting.ItemSmallThumbnailImageWidth, storeId, portalId, culture));
                    var dataCollection = itemObj.DataCollection;
                    dataCollection = dataCollection.Replace("../", "");
                    SaveImageContents(itemID, @"Modules/AspxCommerce/AspxItemsManagement/uploads/", itemObj.SourceFileCol,
                                      dataCollection, itemLargeThumbNailHeight, itemLargeThumbNailWidth, itemMediumThumbNailHeight, itemMediumThumbNailWidth,
                                      itemSmallThumbNailHeight, itemSmallThumbNailWidth, "item_", aspxCommonObj.CultureName, aspxCommonObj.PortalID);
                }
                else if (itemID > 0 && itemObj.SourceFileCol == "" && itemObj.DataCollection == "")
                {
                    DeleteImageContents(itemID);
                }
                return itemID;
                //if (itemID == 0)
                //{
                //    //SaveImageContents(itemID, @"Modules/AspxCommerce/AspxItemsManagement/uploads/", sourceFileCol, dataCollection, "item_");
                //    //TODO:: DELTE UPLOADED FILE FROM DOWNLOAD FOLDER

                //}
            }
            catch (Exception ex)
            {
                throw ex;
                //ErrorHandler errHandler = new ErrorHandler();
                //if (errHandler.LogWCFException(ex))
                //{
                //    return "({\"returnStatus\":-1,\"errorMessage\":'" + ex.Message + "'})";
                //}
                //else
                //{
                //    return "({\"returnStatus\":-1,\"errorMessage\":'Error while saving item!'})";
                //}
            }
        }