예제 #1
0
 /// <summary>
 /// Saves the catalog association.
 /// </summary>
 /// <param name="dto">The dto.</param>
 public void SaveCatalogAssociation(CatalogAssociationDto dto)
 {
     CatalogAssociationManager.SaveCatalogAssociation(dto);
 }
예제 #2
0
 /// <summary>
 /// Gets the catalog association dto by entry code.
 /// </summary>
 /// <param name="catalogId">The catalog id.</param>
 /// <param name="catalogEntryCode">The catalog entry code.</param>
 /// <returns></returns>
 public CatalogAssociationDto GetCatalogAssociationDtoByEntryCode(int catalogId, string catalogEntryCode)
 {
     return(CatalogAssociationManager.GetCatalogAssociationDtoByEntryCode(catalogId, catalogEntryCode));
 }
예제 #3
0
 /// <summary>
 /// Gets the catalog association dto by entry id.
 /// </summary>
 /// <param name="catalogEntryId">The catalog entry id.</param>
 /// <returns></returns>
 public CatalogAssociationDto GetCatalogAssociationDtoByEntryId(int catalogEntryId)
 {
     return(CatalogAssociationManager.GetCatalogAssociationDtoByEntryId(catalogEntryId));
 }
예제 #4
0
 /// <summary>
 /// Gets the catalog association dto.
 /// </summary>
 /// <param name="catalogAssociationName">Name of the catalog association.</param>
 /// <returns></returns>
 public CatalogAssociationDto GetCatalogAssociationDto(string catalogAssociationName)
 {
     return(CatalogAssociationManager.GetCatalogAssociationDto(catalogAssociationName));
 }
예제 #5
0
        /*
         * public CatalogRelationDto GetCatalogEntryRelatedNodesDto(int catalogEntryId)
         * {
         *  //return CatalogRelationManager.GetCatalogRelationDto(0, 0, catalogEntryId, String.Empty, new CatalogRelationResponseGroup(CatalogRelationResponseGroup.ResponseGroup.NodeEntry);
         * }
         * */
        #endregion

        #region CatalogAssociation methods
        /// <summary>
        /// Gets the catalog association dto.
        /// </summary>
        /// <param name="catalogAssociationId">The catalog association id.</param>
        /// <returns></returns>
        public CatalogAssociationDto GetCatalogAssociationDto(int catalogAssociationId)
        {
            return(CatalogAssociationManager.GetCatalogAssociationDto(catalogAssociationId));
        }
예제 #6
0
        protected override int CreateSystemRow(FillDataMode Mode, int RowIndex, params object[] Item)
        {
            int    i = 0;
            object objSysRowAction    = Item[i++];
            object objAssociationName = Item[i++];
            object objParentCode      = Item[i++];
            object objChildCode       = Item[i++];
            object objSortOrder       = Item[i++];
            object objAssociationType = Item[i++];

            try
            {
                RowAction sysRowAction = RowAction.Default;

                if (objSysRowAction != null)
                {
                    sysRowAction = GetRowActionEnum((string)objSysRowAction);
                }

                string AssociationName;
                if (!String.IsNullOrEmpty((string)objAssociationName))
                {
                    AssociationName = (string)objAssociationName;
                }
                else
                {
                    throw new AbsentValue("Association Name");
                }

                string parentCode;
                if (!String.IsNullOrEmpty((string)objParentCode))
                {
                    parentCode = (string)objParentCode;
                }
                else
                {
                    throw new AbsentValue("Parent Entry Code");
                }

                string childCode;
                if (!String.IsNullOrEmpty((string)objChildCode))
                {
                    childCode = (string)objChildCode;
                }
                else
                {
                    throw new AbsentValue("Child Entry Code");
                }

                bool bIsNew = false;

                //Parent Entry
                CatalogEntryDto.CatalogEntryRow parentEntryRow = null;
                CatalogEntryDto catalogEntryDto = CatalogEntryManager.GetCatalogEntryDto(parentCode, new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.Associations));
                if (catalogEntryDto.CatalogEntry.Count > 0)
                {
                    parentEntryRow = catalogEntryDto.CatalogEntry[0];
                }
                else
                {
                    throw new MDPImportException(String.Format("The Parent Entry with code '{0}' does not exists.", parentCode));
                }

                //Child Entry
                CatalogEntryDto.CatalogEntryRow childEntryRow = null;
                CatalogEntryDto childEntryDto = CatalogEntryManager.GetCatalogEntryDto(childCode, new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryInfo));
                if (childEntryDto.CatalogEntry.Count > 0)
                {
                    childEntryRow = childEntryDto.CatalogEntry[0];
                }
                else
                {
                    throw new MDPImportException(String.Format("The Child Entry with code '{0}' does not exists.", childCode));
                }

                //CatalogAssociation (define CatalogAssociationId)
                int catalogAssociationId = 0;
                CatalogEntryDto.CatalogAssociationRow[] catalogAssociationRows = (CatalogEntryDto.CatalogAssociationRow[])catalogEntryDto.CatalogAssociation.Select(String.Format("AssociationName = '{0}'", AssociationName));
                if (catalogAssociationRows.Length == 0)
                {
                    CatalogEntryDto.CatalogAssociationRow newCatalogAssociationRow = catalogEntryDto.CatalogAssociation.NewCatalogAssociationRow();
                    newCatalogAssociationRow.CatalogEntryId         = parentEntryRow.CatalogEntryId;
                    newCatalogAssociationRow.AssociationName        = AssociationName;
                    newCatalogAssociationRow.AssociationDescription = String.Empty;
                    newCatalogAssociationRow.SortOrder = 0;
                    catalogEntryDto.CatalogAssociation.AddCatalogAssociationRow(newCatalogAssociationRow);

                    CatalogContext.Current.SaveCatalogEntry(catalogEntryDto);

                    catalogAssociationId = newCatalogAssociationRow.CatalogAssociationId;
                }
                else
                {
                    catalogAssociationId = catalogAssociationRows[0].CatalogAssociationId;
                }

                //catalogEntryAssociationRow
                CatalogAssociationDto catalogAssociationDto = CatalogAssociationManager.GetCatalogAssociationDto(catalogAssociationId);
                CatalogAssociationDto.CatalogAssociationRow catalogAssociationRow = catalogAssociationDto.CatalogAssociation[0];

                CatalogAssociationDto.CatalogEntryAssociationRow catalogEntryAssociationRow = null;

                CatalogAssociationDto.CatalogEntryAssociationRow[] catalogEntryAssociationRows = (CatalogAssociationDto.CatalogEntryAssociationRow[])catalogAssociationDto.CatalogEntryAssociation.Select(String.Format("CatalogEntryId = {0}", childEntryRow.CatalogEntryId));
                if (catalogEntryAssociationRows.Length == 0)
                {
                    if (sysRowAction == RowAction.Update)
                    {
                        throw new MDPImportException(String.Format("The Catalog Entry Association with name '{0}' for entry code '{1}' and child code '{2}' does not exists.", AssociationName, parentCode, childCode));
                    }

                    if (sysRowAction == RowAction.Delete)
                    {
                        throw new MDPImportException(String.Format("The Catalog Entry Association with name '{0}' for entry code '{1}' and child code '{2}' does not exists.", AssociationName, parentCode, childCode));
                    }

                    catalogEntryAssociationRow = catalogAssociationDto.CatalogEntryAssociation.NewCatalogEntryAssociationRow();
                    catalogEntryAssociationRow.CatalogAssociationId = catalogAssociationId;
                    catalogEntryAssociationRow.CatalogEntryId       = childEntryRow.CatalogEntryId;
                    catalogEntryAssociationRow.SortOrder            = 0;
                    if (catalogAssociationDto.AssociationType.Count > 0)
                    {
                        catalogEntryAssociationRow.AssociationTypeId = catalogAssociationDto.AssociationType[0].AssociationTypeId;
                    }

                    bIsNew = true;
                }
                else
                {
                    if (sysRowAction == RowAction.Insert)
                    {
                        throw new MDPImportException(String.Format("The Catalog Entry Association with name '{0}' for entry code '{1}' and child code '{2}' already exists.", AssociationName, parentCode, childCode));
                    }

                    catalogEntryAssociationRow = catalogEntryAssociationRows[0];

                    if (sysRowAction == RowAction.Delete)
                    {
                        catalogEntryAssociationRow.Delete();
                        CatalogContext.Current.SaveCatalogAssociation(catalogAssociationDto);
                        return(0);
                    }
                }

                if (objSortOrder != null)
                {
                    catalogEntryAssociationRow.SortOrder = (int)objSortOrder;
                }

                if (objAssociationType != null)
                {
                    string associationType = (string)objAssociationType;
                    if (!catalogEntryAssociationRow.AssociationTypeId.Equals(associationType))
                    {
                        CatalogAssociationDto.AssociationTypeRow[] associationTypeRows = (CatalogAssociationDto.AssociationTypeRow[])catalogAssociationDto.AssociationType.Select(String.Format("AssociationTypeId = '{0}'", associationType));
                        if (associationTypeRows.Length > 0)
                        {
                            catalogEntryAssociationRow.AssociationTypeId = associationTypeRows[0].AssociationTypeId;
                        }
                    }
                }

                if (bIsNew)
                {
                    catalogAssociationDto.CatalogEntryAssociation.AddCatalogEntryAssociationRow(catalogEntryAssociationRow);
                }

                using (TransactionScope tx = new TransactionScope())
                {
                    // Save modifications
                    if (catalogAssociationDto.HasChanges())
                    {
                        CatalogContext.Current.SaveCatalogAssociation(catalogAssociationDto);
                    }

                    tx.Complete();
                }
            }
            catch (Exception ex)
            {
                throw new MDPImportException(ex.Message, null, RowIndex, null, null, Item);
            }

            return(1);
        }