Exemple #1
0
        protected override void Execute()
        {
            ActivityInstanceData          activityInstance   = ActivityInstance;
            List <String>                 items              = new List <string>();
            TridionActivityDefinitionData activitydefinition = (TridionActivityDefinitionData)CoreServiceClient.Read(ActivityInstance.ActivityDefinition.IdRef, readoption);
            ProcessDefinitionData         processdefinition  = (ProcessDefinitionData)CoreServiceClient.Read(activitydefinition.ProcessDefinition.IdRef, readoption);

            Logger.Write(string.Format("ActivityInstance.Title : {0}", ActivityInstance.Title), "Workflow", LoggingCategory.General, TraceEventType.Information);

            foreach (WorkItemData wid in activityInstance.WorkItems)
            {
                items.Add(wid.Subject.Title);
            }

            try
            {
                SmtpClient  client = Utility.SMTPClientConfiguration();
                MailMessage mail   = Utility.WorkflowMailMessageConfiguration(ActivityInstance.Title.ToString(), items, null);
                client.Send(mail);
                Logger.Write(string.Format("Mail : {0}", mail.Body.ToString()), "Workflow", LoggingCategory.General, TraceEventType.Information);
                Logger.Write(string.Format("ActivityInstance.Title : {0}", "Mail Sent"), "Workflow", LoggingCategory.General, TraceEventType.Information);
            }
            catch (Exception ex)
            {
                Logger.Write(string.Format("ActivityInstance.Title : {0}", ex.Message.ToString()), "Workflow", LoggingCategory.General, TraceEventType.Information);
            }
            finally
            {
                CoreServiceClient.FinishActivity(ActivityInstance.Id, new ActivityFinishData {
                    Message = "Mail Sent to Target Audience, Finished Activity"
                }, null);
                Logger.Write(string.Format("Message: {0}", "Auto Approved and Send for Next Activity , Finished Activity"), "Workflow", LoggingCategory.General, TraceEventType.Information);
            }
        }
 protected override void Execute()
 {
     CoreServiceClient.FinishActivity(ActivityInstance.Id, new ActivityFinishData {
         Message = "Mail Sent to Target Audience, Finished Activity", NextActivityDueDate = System.DateTime.Now.AddMinutes(5)
     }, null);
     Logger.Write(string.Format("Message: {0}", "Auto Approved and Send for Next Activity , Finished Activity"), "Workflow", LoggingCategory.General, TraceEventType.Information);
 }
        protected override void Execute()
        {
            PublishInstructionData publishInstruction = new PublishInstructionData();

            publishInstruction.ResolveInstruction = new ResolveInstructionData();
            publishInstruction.RenderInstruction  = new RenderInstructionData();

            //Needed for publishing workflow revision/version
            publishInstruction.ResolveInstruction.IncludeWorkflow = true;
            TrusteeData          lastPerformer    = GetFirstManualActivityPerformer();
            ActivityInstanceData activityInstance = ActivityInstance;

            Logger.Write(string.Format("lastPerformer: {0}", lastPerformer.Title), "Workflow", LoggingCategory.General, TraceEventType.Information);

            if (Utility.IsMailSendOptionTrue(activityInstance.Title))
            {
                Logger.Write(string.Format("Mail Send Option: {0}", "True"), "Workflow", LoggingCategory.General, TraceEventType.Information);

                try
                {
                    SmtpClient  client = Utility.SMTPClientConfiguration();
                    MailMessage mail   = Utility.WorkflowMailMessageConfiguration(ActivityInstance.Title.ToString(), null, lastPerformer.Title);
                    client.Send(mail);
                    Logger.Write(string.Format("Mail : {0}", mail.Body.ToString()), "Workflow", LoggingCategory.General, TraceEventType.Information);
                    Logger.Write(string.Format("ActivityInstance.Title : {0}", "Mail Sent"), "Workflow", LoggingCategory.General, TraceEventType.Information);
                }
                catch (Exception ex)
                {
                    Logger.Write(string.Format("ActivityInstance.Title : {0}", ex.Message.ToString()), "Workflow", LoggingCategory.General, TraceEventType.Information);
                }
            }

            if (Utility.IsPublishedToPreviewTrue())
            {
                // Retrieving the Publication Target and Publish Transaction
                if (ProcessInstance.Variables.ContainsKey("PublishTransaction"))
                {
                    string publishTransactionId = ProcessInstance.Variables["PublishTransaction"];
                    // Undo Publish Transaction
                    CoreServiceClient.UndoPublishTransaction(publishTransactionId, QueueMessagePriority.Normal, null);
                }
            }


            // Finish the Activity
            ActivityFinishData finishData = new ActivityFinishData()
            {
                Message      = "The Item " + activityInstance.WorkItems.FirstOrDefault().ToString() + " has been rejected and reassigned to " + lastPerformer.Title,
                NextAssignee = new LinkToTrusteeData()
                {
                    IdRef = lastPerformer.Id
                }
            };

            CoreServiceClient.FinishActivity(activityInstance.Id, finishData, null);
        }
        /// <summary>
        /// This method is used to Publish Item to Preview environment
        /// </summary>
        protected override void Execute()
        {
            PublishInstructionData publishInstractionData = new PublishInstructionData();

            publishInstractionData.RenderInstruction  = new RenderInstructionData();
            publishInstractionData.ResolveInstruction = new ResolveInstructionData();
            publishInstractionData.ResolveInstruction.IncludeWorkflow          = true;
            publishInstractionData.ResolveInstruction.IncludeChildPublications = false;

            List <string> itemToPublish = new List <string>();

            String[] targets   = Utility.GetPublishingTarget("Preview Publication Target");
            String[] PublishTo = Utility.GetPublishingTo();
            int      length    = PublishTo.Length;

            Logger.Write(string.Format("length: {0}", length), "Workflow", LoggingCategory.General, TraceEventType.Information);

            ActivityInstanceData activityInstance = ActivityInstance;

            foreach (WorkItemData wid in activityInstance.WorkItems)
            {
                if (length != 0 && PublishTo[0].ToString() != "All")
                {
                    for (int counter = 0; counter < length; counter++)
                    {
                        string comp  = wid.Subject.IdRef;
                        int    index = comp.IndexOf('-');
                        string sub1  = comp.Substring(index, comp.Length - index);
                        comp = @"tcm:" + PublishTo[counter].ToString() + sub1;
                        Logger.Write(string.Format("component ID : {0}", comp), "Workflow", LoggingCategory.General, TraceEventType.Information);
                        itemToPublish.Add(comp);
                    }
                }
                else
                {
                    publishInstractionData.ResolveInstruction.IncludeChildPublications = true;
                    itemToPublish.Add(wid.Subject.IdRef);
                }
            }

            PublishTransactionData[] publishTransactionData = CoreServiceClient.Publish(itemToPublish.ToArray <String>(), publishInstractionData, targets, PublishPriority.High, null);

            if (ProcessInstance.Variables.ContainsKey("PublishTransaction"))
            {
                ProcessInstance.Variables["PublishTransaction"] = publishTransactionData[0].Id;
            }
            else
            {
                ProcessInstance.Variables.Add("PublishTransaction", publishTransactionData[0].Id);
            }

            CoreServiceClient.FinishActivity(ActivityInstance.Id, new ActivityFinishData {
                Message = "Publish to Preview Queued: Finished Activity"
            }, null);
            Logger.Write(string.Format("Message: {0}", "Publish to Preview Queued: Finished Activity"), "Workflow", LoggingCategory.General, TraceEventType.Information);
        }
Exemple #5
0
        protected override void Execute()
        {
            PublishInstructionData publishInstruction = new PublishInstructionData();

            publishInstruction.ResolveInstruction = new ResolveInstructionData();
            publishInstruction.RenderInstruction  = new RenderInstructionData();

            //Needed for publishing workflow revision/version
            publishInstruction.ResolveInstruction.IncludeWorkflow = true;
            ActivityInstanceData activityInstance   = ActivityInstance;
            IList <String>       itemsToPublishList = new List <String>();

            //Staging publication target URI
            String[] targets = Utility.GetPublishingTarget("Preview Publication Target");

            foreach (WorkItemData wid in activityInstance.WorkItems)
            {
                int value = Convert.ToInt32(Enum.Parse(typeof(ItemType), "VirtualFolder"));
                if (wid.Subject.IdRef.EndsWith(value.ToString()))
                {
                    itemsToPublishList.Add(wid.Subject.IdRef);
                }
            }

            //PublishTransactionData requires reference to System.ServiceModel
            PublishTransactionData[] publishTransactions = CoreServiceClient.Publish(itemsToPublishList.ToArray <String>(), publishInstruction, targets, PublishPriority.Normal, null);

            //Store the publish transaction id so that we can undo if needed!
            if (ProcessInstance.Variables.ContainsKey("PublishTransaction"))
            {
                ProcessInstance.Variables["PublishTransaction"] = publishTransactions[0].Id;
            }
            else
            {
                ProcessInstance.Variables.Add("PublishTransaction", publishTransactions[0].Id);
            }

            CoreServiceClient.FinishActivity(ActivityInstance.Id, new ActivityFinishData {
                Message = "Publish to Staging Queued: Finished Activity"
            }, null);
        }