Ejemplo n.º 1
0
        /// <summary>
        /// Searches the nodes.
        /// </summary>
        /// <param name="searchGuid">The search GUID.</param>
        /// <returns></returns>
        public int SearchNodes(Guid searchGuid)
        {
            DataCommand cmd = CatalogDataHelper.CreateDataCommand();

            cmd.CommandText = String.Format("ecf_CatalogNodeSearch");
            cmd.Parameters  = new DataParameters();
            cmd.Parameters.Add(new DataParameter("ApplicationId", CatalogConfiguration.Instance.ApplicationId, DataParameterType.UniqueIdentifier));
            cmd.Parameters.Add(new DataParameter("SearchSetId", searchGuid, DataParameterType.UniqueIdentifier));
            cmd.Parameters.Add(new DataParameter("Language", SearchParameters.Language, DataParameterType.NVarChar, 50));
            cmd.Parameters.Add(new DataParameter("Catalogs", CommerceHelper.ConvertToString(SearchParameters.CatalogNames, ","), DataParameterType.NVarChar));
            cmd.Parameters.Add(new DataParameter("CatalogNodes", CommerceHelper.ConvertToString(SearchParameters.CatalogNodes, ","), DataParameterType.NVarChar));
            cmd.Parameters.Add(new DataParameter("SQLClause", SearchParameters.SqlWhereClause, DataParameterType.NVarChar));
            cmd.Parameters.Add(new DataParameter("MetaSQLClause", SearchParameters.SqlMetaWhereClause, DataParameterType.NVarChar));
            cmd.Parameters.Add(new DataParameter("FTSPhrase", SearchParameters.FreeTextSearchPhrase, DataParameterType.NVarChar));
            cmd.Parameters.Add(new DataParameter("AdvancedFTSPhrase", SearchParameters.AdvancedFreeTextSearchPhrase, DataParameterType.NVarChar));
            cmd.Parameters.Add(new DataParameter("OrderBy", SearchParameters.OrderByClause, DataParameterType.NVarChar));
            cmd.Parameters.Add(new DataParameter("Namespace", SearchOptions.Namespace, DataParameterType.NVarChar, 1024));
            cmd.Parameters.Add(new DataParameter("Classes", CommerceHelper.ConvertToString(SearchOptions.Classes, ","), DataParameterType.NVarChar));
            cmd.Parameters.Add(new DataParameter("StartingRec", SearchOptions.StartingRecord, DataParameterType.Int));
            cmd.Parameters.Add(new DataParameter("NumRecords", SearchOptions.RecordsToRetrieve, DataParameterType.Int));
            DataParameter param = new DataParameter("RecordCount", DataParameterType.Int);

            param.Direction = ParameterDirection.InputOutput;
            param.Value     = 0;
            cmd.Parameters.Add(param);

            DataService.ExecuteNonExec(cmd);

            return(Int32.Parse(cmd.Parameters["RecordCount"].Value.ToString()));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets the taxes.
        /// </summary>
        /// <returns></returns>
        public static CatalogTaxDto GetTaxCategories()
        {
            // Assign new cache key, specific for site guid and response groups requested
            string cacheKey = CatalogCache.CreateCacheKey("catalog-taxcategory", CatalogConfiguration.Instance.ApplicationId.ToString());

            CatalogTaxDto dto = null;

            // check cache first
            object cachedObject = CatalogCache.Get(cacheKey);

            if (cachedObject != null)
            {
                dto = (CatalogTaxDto)cachedObject;
            }

            // Load the object
            if (dto == null)
            {
                DataCommand cmd = CatalogDataHelper.CreateDataCommand();
                cmd.CommandText = "ecf_TaxCategory";
                cmd.Parameters  = new DataParameters();
                cmd.Parameters.Add(new DataParameter("ApplicationId", CatalogConfiguration.Instance.ApplicationId, DataParameterType.UniqueIdentifier));
                cmd.DataSet      = new CatalogTaxDto();
                cmd.TableMapping = DataHelper.MapTables("TaxCategory");

                DataResult results = DataService.LoadDataSet(cmd);

                dto = (CatalogTaxDto)results.DataSet;

                // Insert to the cache collection
                CatalogCache.Insert(cacheKey, dto, CatalogConfiguration.Instance.Cache.CatalogSchemaTimeout);
            }

            return(dto);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Returns 0 if no patches were installed.
        /// </summary>
        /// <param name="major"></param>
        /// <param name="minor"></param>
        /// <param name="patch"></param>
        /// <param name="installDate"></param>
        /// <returns></returns>
        public static int GetCatalogSystemVersion(out int major, out int minor, out int patch, out DateTime installDate)
        {
            int retval = 0;

            major       = 0;
            minor       = 0;
            patch       = 0;
            installDate = DateTime.MinValue;

            DataCommand command = CatalogDataHelper.CreateDataCommand();

            command.CommandText = "GetCatalogSchemaVersionNumber";
            DataResult result = DataService.LoadDataSet(command);

            if (result.DataSet != null)
            {
                if (result.DataSet.Tables.Count > 0 && result.DataSet.Tables[0].Rows.Count > 0)
                {
                    DataRow row = result.DataSet.Tables[0].Rows[0];
                    major       = (int)row["Major"];
                    minor       = (int)row["Minor"];
                    patch       = (int)row["Patch"];
                    installDate = (DateTime)row["InstallDate"];
                }
            }

            return(retval);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Saves changes in WarehouseDto.
        /// </summary>
        /// <param name="dto">The dto.</param>
        public static void SaveWarehouse(WarehouseDto dto)
        {
            if (dto == null)
            {
                throw new ArgumentNullException("dto", String.Format("WarehouseDto can not be null"));
            }

            DataCommand cmd = CatalogDataHelper.CreateDataCommand();

            using (TransactionScope scope = new TransactionScope())
            {
                DataHelper.SaveDataSetSimple(CatalogContext.MetaDataContext, cmd, dto, "Warehouse");
                scope.Complete();
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Saves changes in TaxCategory table.
        /// </summary>
        /// <param name="dto">The dto.</param>
        public static void SaveTaxCategory(CatalogTaxDto dto)
        {
            if (dto == null)
            {
                throw new ArgumentNullException("dto", String.Format("TaxDto can not be null"));
            }

            // TODO: Check if user is allowed to perform this operation
            DataCommand cmd = CatalogDataHelper.CreateDataCommand();

            using (TransactionScope scope = new TransactionScope())
            {
                DataHelper.SaveDataSetSimple(CatalogContext.MetaDataContext, cmd, dto, "TaxCategory");
                scope.Complete();
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Gets the tax category by name.
        /// </summary>
        /// <returns></returns>
        public static CatalogTaxDto GetTaxCategoryByName(string taxCategoryName)
        {
            CatalogTaxDto dto = null;

            DataCommand cmd = CatalogDataHelper.CreateDataCommand();

            cmd.CommandText = "ecf_TaxCategory_Name";
            cmd.Parameters  = new DataParameters();
            cmd.Parameters.Add(new DataParameter("ApplicationId", CatalogConfiguration.Instance.ApplicationId, DataParameterType.UniqueIdentifier));
            cmd.Parameters.Add(new DataParameter("Name", taxCategoryName, DataParameterType.NVarChar, 50));
            cmd.DataSet      = new CatalogTaxDto();
            cmd.TableMapping = DataHelper.MapTables("TaxCategory");

            DataResult results = DataService.LoadDataSet(cmd);

            dto = (CatalogTaxDto)results.DataSet;

            return(dto);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Retrieves table containing nodes and entries from the specified catalog and catagory.
        /// </summary>
        /// <param name="parameters">The parameters.</param>
        /// <param name="responseGroup">The response group.</param>
        /// <returns>
        /// DataTable with the following fields:
        /// ID, Name, Type, Code, StartDate, EndDate, IsActive, SortOrder, RowNumber.
        /// If returnTotalCount is true, [RecordCount] is returned in the last column of the output table.
        /// </returns>
        internal static DataTable GetCatalogItemsTable(ItemSearchParameters parameters, CatalogNodeResponseGroup responseGroup)
        {
            // Assign new cache key, specific for site guid and response groups requested
            string cacheKey = CatalogCache.CreateCacheKey("catalogitemslist", responseGroup.CacheKey, parameters.CatalogId.ToString(),
                                                          parameters.ParentNodeId.ToString(), parameters.OrderByClause, parameters.RecordsToRetrieve.ToString(),
                                                          parameters.StartingRecord.ToString(), parameters.ReturnTotalCount.ToString(), parameters.ReturnInactive.ToString());

            DataTable table = null;

            // check cache first
            object cachedObject = CatalogCache.Get(cacheKey);

            if (cachedObject != null)
            {
                table = (DataTable)cachedObject;
            }

            // Load the object
            if (table == null)
            {
                DataCommand cmd = CatalogDataHelper.CreateDataCommand();
                cmd.CommandText = String.Format("[ecf_CatalogNodesList]");
                cmd.Parameters  = new DataParameters();
                cmd.Parameters.Add(new DataParameter("CatalogId", parameters.CatalogId, DataParameterType.Int));
                cmd.Parameters.Add(new DataParameter("CatalogNodeId", parameters.ParentNodeId, DataParameterType.Int));
                cmd.Parameters.Add(new DataParameter("OrderClause", parameters.OrderByClause, DataParameterType.NVarChar, 100));
                cmd.Parameters.Add(new DataParameter("StartingRec", parameters.StartingRecord, DataParameterType.Int));
                cmd.Parameters.Add(new DataParameter("NumRecords", parameters.RecordsToRetrieve, DataParameterType.Int));
                cmd.Parameters.Add(new DataParameter("ReturnInactive", parameters.ReturnInactive, DataParameterType.Bit));
                cmd.Parameters.Add(new DataParameter("ReturnTotalCount", parameters.ReturnTotalCount, DataParameterType.Bit));

                table = DataService.LoadTable(cmd);

                if (table != null)
                {
                    // Insert to the cache collection
                    CatalogCache.Insert(cacheKey, table, CatalogConfiguration.Instance.Cache.CatalogNodeTimeout);
                }
            }

            return(table);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Gets the warehouses.
        /// </summary>
        /// <returns></returns>
        public static WarehouseDto GetWarehouseByWarehouseId(int warehouseId)
        {
            // Assign new cache key, specific for site guid and response groups requested
            //string cacheKey = CatalogCache.CreateCacheKey("catalog-warehouse-id", CatalogConfiguration.Instance.ApplicationId.ToString(), warehouseId);

            WarehouseDto dto = null;

            DataCommand cmd = CatalogDataHelper.CreateDataCommand();

            cmd.CommandText = "ecf_Warehouse_WarehouseId";
            cmd.Parameters  = new DataParameters();
            cmd.Parameters.Add(new DataParameter("ApplicationId", CatalogConfiguration.Instance.ApplicationId, DataParameterType.UniqueIdentifier));
            cmd.Parameters.Add(new DataParameter("WarehouseId", warehouseId, DataParameterType.Int));
            cmd.DataSet      = new WarehouseDto();
            cmd.TableMapping = DataHelper.MapTables("Warehouse");

            DataResult results = DataService.LoadDataSet(cmd);

            dto = (WarehouseDto)results.DataSet;

            return(dto);
        }