Ejemplo n.º 1
0
 private void OnCheckInResult(CheckInEventArgs e)
 {
     if (CheckInResult != null)
     {
         CheckInResult(this, e);
     }
 }
        private void OnComponentCheckIn(Component component, CheckInEventArgs args, EventPhases phase)
        {
            configManager = ConfigurationManager.GetInstance(component);

            string value = configManager["Publication"];

            Dictionary <string, string> configs = configManager.Configurations;
            string value2 = configs["Publication"];
        }
        private void OnComponentCheckIn(Component component, CheckInEventArgs args, EventPhases phase)
        {
            configManager = ConfigurationManager.GetInstance(component);

            string value = configManager["Publication"];

            Dictionary<string, string> configs = configManager.Configurations;
            string value2 = configs["Publication"];
        }
Ejemplo n.º 4
0
        public void CheckIn()
        {
#if !TESTING
            Assert.Inconclusive("Not in test mode.");
#endif
            var service = new Service.FourSquare();

            service.Error         += new ErrorEventHandler(service_Error);
            service.CheckInResult += new CheckInEventHandler(service_CheckInResult);
            wait.Reset();
            result    = null;
            exception = null;
            //css festas
            service.CheckIn(new Venue()
            {
                Id = "4c1d4a0b63750f47ff08b867"
            }, "teste", false, null, null);
            wait.WaitOne();

            if (exception != null)
            {
                Assert.Fail(exception.InnerException == null ? exception.Message : exception.InnerException.Message);
            }

            Assert.IsNotNull(result);
            Assert.IsNotNull(result.CheckIn);
            Assert.IsNotNull(result.CheckIn.Venue);

            Assert.IsNotNull(result.Notifications);
            bool hasMessage = false;
            foreach (INotification notif in result.Notifications)
            {
                var message   = notif as MessageNotification;
                var score     = notif as ScoreNotification;
                var badge     = notif as Badge;
                var mayorship = notif as Mayorship;
                var special   = notif as Special;

                if (message != null)
                {
                    hasMessage = true;
                }
            }
            Assert.IsTrue(hasMessage);
        }
 private void OnTBBSavePre(TemplateBuildingBlock tbb, CheckInEventArgs args, EventPhases phase)
 {
     configManager = ConfigurationManager.GetInstance(tbb);
 }
 private void OnTBBSavePre(TemplateBuildingBlock tbb, CheckInEventArgs args, EventPhases phase)
 {
     configManager = ConfigurationManager.GetInstance(tbb);
 }
        /// <summary>
        /// On (Save, and) Check-in of a Component, create a Page for that Component and update an index Page with the Component and publish both to a staging target.
        /// </summary>
        /// <remarks>
        /// The metadata of the Folder the Component resides in, will be used as the configuration for the actions.
        /// </remarks>
        /// <param name="subject">checked in Component</param>
        /// <param name="args">check in event arguments</param>
        /// <param name="phase">event phase</param>
        private static void ComponentCheckInAction(Component subject, CheckInEventArgs args, EventPhases phase)
        {
            // get Folder from Component for configuration metadata
            Folder folder = (Folder)subject.OrganizationalItem;

            // proceed when Folder has metadata
            if (folder.Metadata == null)
            {
                return;
            }

            ItemFields metadata = new ItemFields(folder.Metadata, folder.MetadataSchema);
            ReiConfig  config   = new ReiConfig(metadata);

            // proceed when metadata contains valid URIs, and Schema of Component is recognised
            if (!config.IsValid || subject.Schema.Id.ItemId != config.SchemaUri.ItemId)
            {
                return;
            }

            // create list of items to publish
            List <IdentifiableObject> items = new List <IdentifiableObject>();

            // if Component is already used on any Page then no need to create new Page and update index, just publish Component
            UsingItemsFilter pageFilter = new UsingItemsFilter(subject.Session)
            {
                ItemTypes = new List <ItemType> {
                    ItemType.Page
                }
            };

            if (subject.HasUsingItems(pageFilter))
            {
                items.Add(subject);
            }
            else
            {
                // create Page and add Component Presentation (using Context Publication of Structure Group)
                TcmUri            localUri          = ReiConfig.TransformTcmUri(subject.Id, config.StructureGroupUri);
                Component         localComponent    = new Component(localUri, subject.Session);
                ComponentTemplate componentTemplate = new ComponentTemplate(config.ComponentTemplateUri, subject.Session);
                Page page = new Page(subject.Session, config.StructureGroupUri);
                try
                {
                    page.Title        = subject.Title;
                    page.FileName     = GetSafeFileName(subject.Title);
                    page.PageTemplate = new PageTemplate(config.PageTemplateUri, subject.Session);
                    page.ComponentPresentations.Add(new ComponentPresentation(localComponent, componentTemplate));
                    page.Save(true);

                    // add Page to publish items list
                    items.Add(page);
                }
                catch (Exception ex)
                {
                    Logger.Write(ex, ReiConfig.Name, LoggingCategory.General, TraceEventType.Error);
                }

                // add Component to index Page (using Context Publication of index Page)
                localUri          = ReiConfig.TransformTcmUri(subject.Id, config.IndexPageUri);
                localComponent    = new Component(localUri, subject.Session);
                componentTemplate = new ComponentTemplate(config.IndexComponentTemplateUri, subject.Session);
                Page indexPage = new Page(config.IndexPageUri, subject.Session);
                try
                {
                    indexPage.CheckOut();
                    indexPage.ComponentPresentations.Add(new ComponentPresentation(localComponent, componentTemplate));
                    indexPage.Save(true);

                    // add index Page to publish items list
                    items.Add(indexPage);
                }
                catch (Exception ex)
                {
                    Logger.Write(ex, ReiConfig.Name, LoggingCategory.General, TraceEventType.Error);
                }
            }

            // publish items
            if (items.Count > 0)
            {
                List <TargetType> targets = new List <TargetType> {
                    new TargetType(config.TargetTypeUri, subject.Session)
                };
                PublishInstruction publishInstruction = new PublishInstruction(subject.Session);
                PublishEngine.Publish(items, publishInstruction, targets, ReiConfig.Priority);
            }
            else
            {
                Logger.Write("No items were published.", ReiConfig.Name, LoggingCategory.General, TraceEventType.Information);
            }
        }
Ejemplo n.º 8
0
 void service_CheckInResult(object serder, CheckInEventArgs e)
 {
     result = e;
     wait.Set();
 }
Ejemplo n.º 9
0
 void Service_CheckInResult(object serder, MySquare.FourSquare.CheckInEventArgs e)
 {
     checkInResult = e;
     CheckInResult();
 }