예제 #1
0
        public void UpdateLinkEntityData(Entity linkEntity, int channelId, Entity channelEntity, Configuration config, string parentId)
        {
            lock (SingletonEPiLock.Instance)
            {
                try
                {
                    string channelName = _businessHelper.GetDisplayNameFromEntity(channelEntity, config, -1);

                    string parentEntryId      = _channelPrefixHelper.GetEPiCodeWithChannelPrefix(parentId, config);
                    string linkEntityIdString = _channelPrefixHelper.GetEPiCodeWithChannelPrefix(linkEntity.Id, config);

                    string dispName = linkEntity.EntityType.Id + '_' + _businessHelper.GetDisplayNameFromEntity(linkEntity, config, -1).Replace(' ', '_');

                    LinkEntityUpdateData dataToSend = new LinkEntityUpdateData
                    {
                        ChannelName          = channelName,
                        LinkEntityIdString   = linkEntityIdString,
                        LinkEntryDisplayName = dispName,
                        ParentEntryId        = parentEntryId
                    };

                    RestEndpoint <LinkEntityUpdateData> endpoint = new RestEndpoint <LinkEntityUpdateData>(config.Settings, "UpdateLinkEntityData", this._context);
                    endpoint.Post(dataToSend);
                }
                catch (Exception exception)
                {
                    _context.Log(LogLevel.Error, string.Format("Failed to update data for link entity with id:{0}", linkEntity.Id), exception);
                }
            }
        }
예제 #2
0
        public void UpdateEntryRelations(string catalogEntryId, int channelId, Entity channelEntity, Configuration config, string parentId, Dictionary <string, bool> shouldExistInChannelNodes, string linkTypeId, List <string> linkEntityIdsToRemove)
        {
            lock (SingletonEPiLock.Instance)
            {
                try
                {
                    string        channelName            = _businessHelper.GetDisplayNameFromEntity(channelEntity, config, -1);
                    List <string> removeFromChannelNodes = new List <string>();
                    foreach (KeyValuePair <string, bool> shouldExistInChannelNode in shouldExistInChannelNodes)
                    {
                        if (!shouldExistInChannelNode.Value)
                        {
                            removeFromChannelNodes.Add(
                                _channelPrefixHelper.GetEPiCodeWithChannelPrefix(shouldExistInChannelNode.Key, config));
                        }
                    }

                    var channelMappingHelper = new EpiMappingHelper(_context);

                    string parentEntryId              = _channelPrefixHelper.GetEPiCodeWithChannelPrefix(parentId, config);
                    string catalogEntryIdString       = _channelPrefixHelper.GetEPiCodeWithChannelPrefix(catalogEntryId, config);
                    string channelIdEpified           = _channelPrefixHelper.GetEPiCodeWithChannelPrefix(channelId, config);
                    string inriverAssociationsEpified = _channelPrefixHelper.GetEPiCodeWithChannelPrefix("_inRiverAssociations", config);
                    bool   relation = channelMappingHelper.IsRelation(linkTypeId, config);
                    bool   parentExistsInChannelNodes = shouldExistInChannelNodes.Keys.Contains(parentId);

                    UpdateEntryRelationData updateEntryRelationData = new UpdateEntryRelationData
                    {
                        ParentEntryId              = parentEntryId,
                        CatalogEntryIdString       = catalogEntryIdString,
                        ChannelIdEpified           = channelIdEpified,
                        ChannelName                = channelName,
                        RemoveFromChannelNodes     = removeFromChannelNodes,
                        LinkEntityIdsToRemove      = linkEntityIdsToRemove,
                        InRiverAssociationsEpified = inriverAssociationsEpified,
                        LinkTypeId = linkTypeId,
                        IsRelation = relation,
                        ParentExistsInChannelNodes = parentExistsInChannelNodes
                    };

                    RestEndpoint <UpdateEntryRelationData> endpoint =
                        new RestEndpoint <UpdateEntryRelationData>(config.Settings, "UpdateEntryRelations", this._context);
                    endpoint.Post(updateEntryRelationData);
                }
                catch (Exception exception)
                {
                    string parentEntryId = _channelPrefixHelper.GetEPiCodeWithChannelPrefix(parentId, config);
                    string childEntryId  = _channelPrefixHelper.GetEPiCodeWithChannelPrefix(catalogEntryId, config);
                    _context.Log(
                        LogLevel.Error,
                        string.Format("Failed to update entry relations between parent entry id {0} and child entry id {1} in catalog with id {2}", parentEntryId, childEntryId, catalogEntryId),
                        exception);
                }
            }
        }
예제 #3
0
 public void DeleteCatalog(int catalogId, Configuration config)
 {
     lock (SingletonEPiLock.Instance)
     {
         try
         {
             RestEndpoint <int> endpoint = new RestEndpoint <int>(config.Settings, "DeleteCatalog", this._context);
             endpoint.Post(catalogId);
         }
         catch (Exception exception)
         {
             _context.Log(LogLevel.Error, $"Failed to delete catalog with id: {catalogId}", exception);
         }
     }
 }
예제 #4
0
 public void DeleteCatalogEntry(string entityId, Configuration config)
 {
     lock (SingletonEPiLock.Instance)
     {
         try
         {
             string catalogEntryId          = _channelPrefixHelper.GetEPiCodeWithChannelPrefix(entityId, config);
             RestEndpoint <string> endpoint = new RestEndpoint <string>(config.Settings, "DeleteCatalogEntry", this._context);
             endpoint.Post(catalogEntryId);
         }
         catch (Exception exception)
         {
             _context.Log(LogLevel.Error, string.Format("Failed to delete catalog entry based on entity id: {0}", entityId), exception);
         }
     }
 }
예제 #5
0
 public void DeleteCatalogNode(int catalogNodeId, int catalogId, Configuration config)
 {
     lock (SingletonEPiLock.Instance)
     {
         try
         {
             string catalogNode             = _channelPrefixHelper.GetEPiCodeWithChannelPrefix(catalogNodeId, config);
             RestEndpoint <string> endpoint = new RestEndpoint <string>(config.Settings, "DeleteCatalogNode", this._context);
             endpoint.Post(catalogNode);
         }
         catch (Exception ex)
         {
             _context.Log(LogLevel.Error, string.Format("Failed to delete catalogNode with id: {0} for channel: {1}", catalogNodeId, catalogId), ex);
         }
     }
 }
예제 #6
0
        public void CheckAndMoveNodeIfNeeded(string nodeId, Configuration config)
        {
            lock (SingletonEPiLock.Instance)
            {
                try
                {
                    string entryNodeId = _channelPrefixHelper.GetEPiCodeWithChannelPrefix(nodeId, config);

                    RestEndpoint <string> endpoint = new RestEndpoint <string>(config.Settings, "CheckAndMoveNodeIfNeeded", this._context);
                    endpoint.Post(entryNodeId);
                }
                catch (Exception exception)
                {
                    _context.Log(LogLevel.Warning, string.Format("Failed when calling the interface function: CheckAndMoveNodeIfNeeded"), exception);
                }
            }
        }
예제 #7
0
        public bool StartImportIntoEpiServerCommerce(string /*filePath, */ fileNameInCloud, Guid guid, Configuration config)
        {
            lock (SingletonEPiLock.Instance)
            {
                try
                {
                    RestEndpoint <string> endpoint = new RestEndpoint <string>(config.Settings, "ImportCatalogXml", this._context);
                    string result = endpoint.Post(fileNameInCloud);
                    _context.Log(LogLevel.Debug, string.Format("Import catalog returned: {0}", result));
                    return(true);
                }
                catch (Exception exception)
                {
                    _context.Log(LogLevel.Error, string.Format("Failed to import catalog xml file {0}.", fileNameInCloud), exception);
                    _context.Log(LogLevel.Error, exception.ToString());

                    return(false);
                }
            }
        }
예제 #8
0
 public bool DeleteCompleted(string catalogName, DeleteCompletedEventType eventType, Configuration config)
 {
     lock (SingletonEPiLock.Instance)
     {
         try
         {
             RestEndpoint <DeleteCompletedData> endpoint = new RestEndpoint <DeleteCompletedData>(config.Settings, "DeleteCompleted", this._context);
             DeleteCompletedData data = new DeleteCompletedData
             {
                 CatalogName = catalogName,
                 EventType   = eventType
             };
             string result = endpoint.Post(data);
             _context.Log(LogLevel.Debug, string.Format("DeleteCompleted returned: {0}", result));
             return(true);
         }
         catch (Exception exception)
         {
             _context.Log(LogLevel.Error, string.Format("Failed to fire DeleteCompleted for catalog {0}.", catalogName), exception);
             return(false);
         }
     }
 }
예제 #9
0
 public bool ImportUpdateCompleted(string catalogName, ImportUpdateCompletedEventType eventType, bool resourceIncluded, Configuration config)
 {
     lock (SingletonEPiLock.Instance)
     {
         try
         {
             RestEndpoint <ImportUpdateCompletedData> endpoint = new RestEndpoint <ImportUpdateCompletedData>(config.Settings, "ImportUpdateCompleted", this._context);
             ImportUpdateCompletedData data = new ImportUpdateCompletedData
             {
                 CatalogName       = catalogName,
                 EventType         = eventType,
                 ResourcesIncluded = resourceIncluded
             };
             string result = endpoint.Post(data);
             _context.Log(LogLevel.Debug, string.Format("ImportUpdateCompleted returned: {0}", result));
             return(true);
         }
         catch (Exception exception)
         {
             _context.Log(LogLevel.Error, string.Format("Failed to fire import update completed for catalog {0}.", catalogName), exception);
             return(false);
         }
     }
 }