Пример #1
0
        protected override void Execute(TContext model)
        {
            var ev      = model.Event;
            var eventId = ev.ExtendedDatas()[Constants.EventId].GetValue(model).ToString();
            var taskId  = ev.ExtendedDatas()[Constants.TaskUuid].GetValue(model).ToString();

            if (model.Workflow.GetEvent(Guid.Parse(eventId), out Event e))
            {
                if (e.GetAction(Guid.Parse(taskId), out PushedAction a))
                {
                    a.Change = ChangeEnum.New;
                    var i    = model.IncomingEvent;
                    var m    = new MessageRaw();
                    var body = new MessageBlock()
                               .Add(nameof(i.CreationDate), i.CreationDate.ToString())
                               .Add(nameof(i.EventDate), i.EventDate.ToString())
                    ;

                    foreach (var item in i.ExtendedDatas().Items)
                    {
                        body.Add(item.Key, item.Value.GetValue(model));
                    }

                    m.Body          = body;
                    a.ResultMessage = m;
                }
            }
        }
Пример #2
0
        public MessageBlock ParseWithUnprocessed(
            InputBuffer buffer,
            UnprocessedString unprocessedData,
            DateTimeOffset?readFrom  = null,
            DateTimeOffset?readUntil = null,
            int?maxMessageCount      = null,
            CancellationToken ct     = default(CancellationToken))
        {
            MessageBlock messageBlock = new MessageBlock();

            if (unprocessedData == null)
            {
                unprocessedData = new UnprocessedString();
            }
            this._lineNumber = 0;
            bool flag = false;
            int  num1 = Math.Max(500, buffer.LineCount / 10);

            foreach (string line in buffer.Lines)
            {
                string str1 = line.Trim(new char[1]);
                if (!string.IsNullOrEmpty(str1))
                {
                    int num2    = 0;
                    int length1 = unprocessedData.Length;
                    unprocessedData.Append(str1);
                    int startIndex = num2;
                    int num3       = 0;
                    do
                    {
                        if (num3 > -1)
                        {
                            num3 = str1.IndexOf("event>", startIndex, StringComparison.OrdinalIgnoreCase);
                        }
                        string str2 = flag ? "]]>" : "<![CDATA[";
                        int    num4 = str1.IndexOf(str2, startIndex, StringComparison.OrdinalIgnoreCase);
                        if (num4 >= 0 && (num3 <= 0 || num4 < num3))
                        {
                            flag       = !flag;
                            startIndex = num4 + str2.Length;
                        }
                        else
                        {
                            startIndex = num3 < 0 ? -1 : num3 + "event>".Length;
                        }
                    }while ((num3 < 0 || num3 > startIndex) && (startIndex >= 0 && startIndex < str1.Length));
                    int length2 = length1 + num3 + "event>".Length - num2;
                    while (!flag && num3 >= 0 && length2 > 0)
                    {
                        LogMessage xmlElement = this.ParseXmlElement(unprocessedData.Substring(num2, length2), buffer.Id);
                        if (xmlElement != null)
                        {
                            if (readUntil.HasValue)
                            {
                                DateTimeOffset?nullable     = readUntil;
                                DateTimeOffset adjustedTime = xmlElement.AdjustedTime;
                                if ((nullable.HasValue ? (nullable.GetValueOrDefault() < adjustedTime ? 1 : 0) : 0) != 0)
                                {
                                    this.NotifyProgress(1.0);
                                    return(messageBlock);
                                }
                            }
                            if (!readFrom.HasValue || xmlElement.AdjustedTime >= readFrom.Value)
                            {
                                messageBlock.Add(xmlElement);
                                if (maxMessageCount.HasValue)
                                {
                                    return(messageBlock);
                                }
                            }
                        }
                        num2 += length2;
                        if (num2 == unprocessedData.Length)
                        {
                            num3    = -1;
                            length2 = 0;
                        }
                        else
                        {
                            num3    = unprocessedData.IndexOfValueInLines("event>", num2, StringComparison.OrdinalIgnoreCase);
                            length2 = num3 - num2;
                        }
                    }
                    unprocessedData.Shorten(num2);
                }
                if (ct.IsCancellationRequested)
                {
                    return(messageBlock);
                }
                if (++this._lineNumber % num1 == 0)
                {
                    this.NotifyProgress(this._lineNumber * 1.0 / buffer.LineCount);
                }
            }
            this.NotifyProgress(1.0);
            return(messageBlock);
        }