Ejemplo n.º 1
0
            /// <summary>
            /// Initializes a new instance of the <see cref="Publisher"/> class.
            /// </summary>
            /// <param name="publishingConfig">Publishing configuration.</param>
            /// <param name="channelId">The channel identifier.</param>
            public Publisher(PublishingConfiguration publishingConfig, long channelId)
            {
                CommerceRuntimeConfiguration configuration = CrtUtilities.GetCrtConfiguration();

                this.runtime = CommerceRuntime.Create(configuration, new CommercePrincipal(new CommerceIdentity(channelId, new string[] { CommerceRoles.Storefront })));

                this.channelManager   = ChannelManager.Create(this.runtime);
                this.productManager   = ProductManager.Create(this.runtime);
                this.onlineChannel    = this.channelManager.GetOnlineChannel(channelId);
                this.publishingConfig = publishingConfig;
            }
Ejemplo n.º 2
0
            /// <summary>
            /// Initializes a new instance of the <see cref="Publisher"/> class.
            /// </summary>
            /// <param name="publishingConfig">Publishing configuration.</param>
            /// <param name="operatingUnitNumber">The channel's operating unit number.</param>
            public Publisher(PublishingConfiguration publishingConfig, string operatingUnitNumber)
            {
                CommerceRuntimeConfiguration configuration = CrtUtilities.GetCrtConfiguration();

                // First creating a runtime without a channel association, this is needed to resolve the operating unit number.
                this.runtime = CommerceRuntime.Create(configuration, new CommercePrincipal(new CommerceIdentity(0, new string[] { CommerceRoles.Storefront })));

                ChannelManager manager   = ChannelManager.Create(this.runtime);
                long           channelId = manager.ResolveOperatingUnitNumber(operatingUnitNumber);

                // Now creating a runtime with the resolved channel Id.
                this.runtime = CommerceRuntime.Create(configuration, new CommercePrincipal(new CommerceIdentity(channelId, new string[] { CommerceRoles.Storefront })));

                this.channelManager   = ChannelManager.Create(this.runtime);
                this.productManager   = ProductManager.Create(this.runtime);
                this.onlineChannel    = this.channelManager.GetOnlineChannel(channelId);
                this.publishingConfig = publishingConfig;
            }