Ejemplo n.º 1
0
        public void Serialize_DefaultNoGroup_RankingXml()
        {
            var filterXml = new FilterXml
            {
                Ranking = new RankingXml()
                {
                    Operand = new ColumnOrdinalIdentifier(1),
                    Rank    = new TopRankingXml()
                }
            };

            var serializer = new XmlSerializer(typeof(FilterXml));
            var content    = string.Empty;

            using (var stream = new MemoryStream())
                using (var writer = new StreamWriter(stream, Encoding.UTF8))
                {
                    serializer.Serialize(writer, filterXml);
                    content = Encoding.UTF8.GetString(stream.ToArray());
                }

            Debug.WriteLine(content);

            Assert.That(content, Is.StringContaining("ranking"));
            Assert.That(content, Is.StringContaining("top"));
            Assert.That(content, Is.Not.StringContaining("count"));
            Assert.That(content, Is.Not.StringContaining("type"));
        }
Ejemplo n.º 2
0
        public void Serialize_WithGroupBy_RankingXml()
        {
            var filterXml = new FilterXml
            {
                Ranking = new RankingXml()
                {
                    Operand = new ColumnOrdinalIdentifier(1),
                    Type    = ColumnType.DateTime,
                    Rank    = new BottomRankingXml()
                    {
                        Count = 3
                    },
                    GroupBy = new GroupByXml()
                    {
                        Columns = new List <ColumnDefinitionLightXml>()
                        {
                            new ColumnDefinitionLightXml()
                            {
                                Identifier = new ColumnNameIdentifier("foo"),
                                Type       = ColumnType.Boolean
                            },
                            new ColumnDefinitionLightXml()
                            {
                                Identifier = new ColumnNameIdentifier("bar"),
                                Type       = ColumnType.Text
                            },
                        }
                    }
                }
            };

            var serializer = new XmlSerializer(typeof(FilterXml));
            var content    = string.Empty;

            using (var stream = new MemoryStream())
                using (var writer = new StreamWriter(stream, Encoding.UTF8))
                {
                    serializer.Serialize(writer, filterXml);
                    content = Encoding.UTF8.GetString(stream.ToArray());
                }

            Debug.WriteLine(content);

            Assert.That(content, Is.StringContaining("bottom"));
            Assert.That(content, Is.StringContaining("dateTime"));
            Assert.That(content, Is.StringContaining("count"));
            Assert.That(content, Is.StringContaining("group-by"));
            Assert.That(content, Is.StringContaining("column"));
            Assert.That(content, Is.StringContaining("foo"));
            Assert.That(content, Is.StringContaining("boolean"));
            Assert.That(content, Is.StringContaining("bar"));
            Assert.That(content, Is.Not.StringContaining("text"));
        }
Ejemplo n.º 3
0
        protected override void ExecuteWorkflowLogic()
        {
            var sourceRecord = ConvertToEntityReference(Record.Get(Context.ExecutionContext));

            var documentFilter = FilterXml.Get(Context.ExecutionContext);

            var documentsQuery = $@"
                <fetch>
                  <entity name='annotation'>
                    <attribute name='filename' />
                    <attribute name='documentbody' />
                    <filter type='and'>
                     <condition attribute='isdocument' operator='eq' value='1' />
                     <condition attribute='objectid' operator='eq' value='{sourceRecord.Id}' />";

            if (!string.IsNullOrEmpty(documentFilter))
            {
                documentsQuery += documentFilter.Replace('"', '\'');
            }

            documentsQuery += @"
                    </filter>
                  </entity>
                </fetch>";

            var notes = QueryWithPaging(new FetchExpression(documentsQuery));

            notes.ForEach(note =>
            {
                var activityattachment = new Entity("activitymimeattachment")
                {
                    ["objectid"]       = Email.Get(Context.ExecutionContext),
                    ["objecttypecode"] = "email",
                    ["body"]           = note["documentbody"],
                    ["filename"]       = note["filename"]
                };

                Context.UserService.Create(activityattachment);
            });

            if (SendAfterOperation.Get(Context.ExecutionContext))
            {
                base.ExecuteWorkflowLogic();
            }
        }
Ejemplo n.º 4
0
        // Module defining this command


        // Optional custom code for this activity


        /// <summary>
        /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run.
        /// </summary>
        /// <param name="context">The NativeActivityContext for the currently running activity.</param>
        /// <returns>A populated instance of Sytem.Management.Automation.PowerShell</returns>
        /// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks>
        protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context)
        {
            System.Management.Automation.PowerShell invoker       = global::System.Management.Automation.PowerShell.Create();
            System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName);

            // Initialize the arguments

            if (ListLog.Expression != null)
            {
                targetCommand.AddParameter("ListLog", ListLog.Get(context));
            }

            if (LogName.Expression != null)
            {
                targetCommand.AddParameter("LogName", LogName.Get(context));
            }

            if (ListProvider.Expression != null)
            {
                targetCommand.AddParameter("ListProvider", ListProvider.Get(context));
            }

            if (ProviderName.Expression != null)
            {
                targetCommand.AddParameter("ProviderName", ProviderName.Get(context));
            }

            if (Path.Expression != null)
            {
                targetCommand.AddParameter("Path", Path.Get(context));
            }

            if (MaxEvents.Expression != null)
            {
                targetCommand.AddParameter("MaxEvents", MaxEvents.Get(context));
            }

            if (Credential.Expression != null)
            {
                targetCommand.AddParameter("Credential", Credential.Get(context));
            }

            if (FilterXPath.Expression != null)
            {
                targetCommand.AddParameter("FilterXPath", FilterXPath.Get(context));
            }

            if (FilterXml.Expression != null)
            {
                targetCommand.AddParameter("FilterXml", FilterXml.Get(context));
            }

            if (FilterHashtable.Expression != null)
            {
                targetCommand.AddParameter("FilterHashtable", FilterHashtable.Get(context));
            }

            if (Force.Expression != null)
            {
                targetCommand.AddParameter("Force", Force.Get(context));
            }

            if (Oldest.Expression != null)
            {
                targetCommand.AddParameter("Oldest", Oldest.Get(context));
            }

            if (GetIsComputerNameSpecified(context) && (PSRemotingBehavior.Get(context) == RemotingBehavior.Custom))
            {
                targetCommand.AddParameter("ComputerName", PSComputerName.Get(context));
            }


            return(new ActivityImplementationContext()
            {
                PowerShellInstance = invoker
            });
        }