Exemplo n.º 1
0
        protected BotSubscription CreateBotSubscription(BotSubscriptionEntity entity)
        {
            LastActivity activity;

            if (entity.LastActivityDate == null)
            {
                activity = null;
            }
            else
            {
                activity = new LastActivity()
                {
                    ActitityId     = entity.ActitityId,
                    ConversationId = entity.ConversationId,
                    Created        = entity.LastActivityDate.Value,
                };
            }

            return(new BotSubscription()
            {
                ChannelId = entity.ChannelId,
                GroupName = entity.GroupName,
                ServiceUrl = entity.ServiceUrl,
                TeamId = entity.TeamId,
                TenantId = entity.TeamId,
                LastActivity = activity
            });
        }
Exemplo n.º 2
0
 public override string ToString()
 {
     return(Util.f("ec:{0} sc:{1} ssc:{2} sl:{3:.0} ts:{4:.0} la:{5:.0}",
                   EventCount,
                   SessionCount,
                   SubSessionCount,
                   SessionLenght.SecondsFormat(),
                   TimeSpent.SecondsFormat(),
                   LastActivity.SecondsFormat()
                   ));
 }
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = Id?.GetHashCode() ?? 0;
         hashCode = (hashCode * 397) ^ (Name?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (ListName?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ LastActivity.GetHashCode();
         hashCode = (hashCode * 397) ^ (Members?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (Url?.GetHashCode() ?? 0);
         return(hashCode);
     }
 }
Exemplo n.º 4
0
 public override string ToString()
 {
     return(Util.F("ec:{0} sc:{1} ssc:{2} sl:{3:.0} ts:{4:.0} la:{5:.0} adid:{6} isGdprForgotten:{7}",
                   EventCount,
                   SessionCount,
                   SubSessionCount,
                   SessionLength.SecondsFormat(),
                   TimeSpent.SecondsFormat(),
                   LastActivity.SecondsFormat(),
                   Adid,
                   IsGdprForgotten
                   ));
 }
Exemplo n.º 5
0
        public LastActivity GetLastActivity(long userId)
        {
            var parameters = new VkParameters {
                { "user_id", userId }
            };

            var response = _vk.Call("messages.getLastActivity", parameters);

            LastActivity activity = response;

            activity.UserId = userId;

            return(activity);
        }
Exemplo n.º 6
0
        public void GetLastActivity_NormalCast_LastActivityObject()
        {
            url  = "https://api.vk.com/method/messages.getLastActivity?user_id=77128&v=5.37&access_token=token";
            json =
                @"{
					'response': {
					  'online': 0,
					  'time': 1344484645
					}
				  }"                ;

            LastActivity activity = Cat.GetLastActivity(77128);

            Assert.That(activity.UserId, Is.EqualTo(77128));
            Assert.That(activity.IsOnline, Is.False);
            Assert.That(activity.Time, Is.EqualTo(new DateTime(2012, 8, 9, 3, 57, 25, DateTimeKind.Utc).ToLocalTime()));
        }
        /// <summary>
        /// Undoes this instance.
        /// </summary>
        protected override void Undo()
        {
            if (LastActivity == null)
            {
                throw new WorkflowExecuteExeception("没有步骤可供撤销");
            }
            //撤销动作
            LastActivity.OnUndo(this);
            if (this.stateRecordNames.Count > 0)
            {
                WorkflowRuntime.Current.OnWorkflowCanceled(new StateChangedEventArgs(this, this.stateName, this.stateRecordNames[stateRecordNames.Count - 1]));
            }
            //返回到上一状态
            MoveBack();
            //在动作列表中删除被撤销的动作
            executedActivities.RemoveAt(executedActivities.Count - 1);
            executedActivities.TrimExcess();

            RemoveChildren();
            //保存实例
            Save();
        }
Exemplo n.º 8
0
 public EDUpdatedDomainEvent(Guid id, long transactionId, int employeeId, string firstName, string lastName, string payCode, string payCodeDescription, DateTime payDateFrom, DateTime payDateTo, DateTime coverageDateFrom,
                             DateTime coverageDateTo, decimal amount, string remarks)
 {
     Id                 = id;
     AggregateId        = Id.ToString();
     ClientIP           = "";
     Description        = "EDUpdatedDomainEvent event is successful";
     EventCreated       = DateTime.UtcNow;
     EventState         = "CREATED";
     EventLastModified  = DateTime.UtcNow;
     TransactionId      = transactionId;
     EmployeeId         = employeeId;
     FirstName          = firstName;
     LastName           = lastName;
     PayCode            = payCode;
     PayCodeDescription = payCodeDescription;
     PayDateFrom        = payDateFrom;
     PayDateTo          = payDateTo;
     CoverageDateFrom   = coverageDateFrom;
     CoverageDateTo     = coverageDateTo;
     Amount             = amount;
     Remarks            = remarks;
     LastActivity       = LastActivity.Edited;
 }
 protected bool Equals(TrelloCardInfo other)
 {
     return(string.Equals(Id, other.Id) && string.Equals(Name, other.Name) &&
            string.Equals(ListName, other.ListName) && LastActivity.Equals(other.LastActivity) &&
            Equals(Members, other.Members) && string.Equals(Url, other.Url));
 }
Exemplo n.º 10
0
        // NOTE: To run this test you must have installed the Azure Storage Emulator.
        // You can download it here: https://go.microsoft.com/fwlink/?linkid=717179&clcid=0x409
        // The test will automatically start the emulator.
        public async Task TableLoggerTest()
        {
            var tableName = "TableLoggerTestActivities";
            var account   = CloudStorageAccount.DevelopmentStorageAccount;

            account.CreateCloudTableClient().GetTableReference(tableName).DeleteIfExists();
            var builder = new ContainerBuilder();

            builder.RegisterModule(new TableLoggerModule(account, tableName));
            var container = builder.Build();
            var logger    = container.Resolve <IActivityLogger>();
            var source    = container.Resolve <IActivitySource>();
            var manager   = container.Resolve <IActivityManager>();

            var activities = GetTestActivityList();

            var comparator = new CompareActivity();

            for (var i = 0; i < activities.Count; ++i)
            {
                await logger.LogAsync(activities[i]);

                var oldest = LastActivity.AddSeconds(-30);
                AssertEqual(Filter(activities, oldest: oldest, take: i + 1), source.Activities(DefaultChannel, DefaultConversation, oldest));
            }

            var conversation = Filter(activities);

            AssertEqual(conversation, source.Activities(DefaultChannel, DefaultConversation));
            AssertEqual(Filter(activities, channel: "channel2"), source.Activities("channel2", "conversation1"));
            AssertEqual(Filter(activities, conversation: "conversation2"), source.Activities(DefaultChannel, "conversation2"));

            var transcript = new List <string>();

            foreach (var activity in conversation)
            {
                var msg = activity as IMessageActivity;
                if (msg != null)
                {
                    transcript.Add($"({msg.From.Name} {msg.Timestamp:g})");
                    transcript.Add($"{msg.Text}");
                }
            }
            int j         = 0;
            var botToUser = new Mock <IBotToUser>();

            botToUser
            .Setup(p => p.PostAsync(It.IsAny <IMessageActivity>(), It.IsAny <CancellationToken>()))
            .Returns(Task.CompletedTask)
            .Callback((IMessageActivity activity, CancellationToken cancel) =>
                      Assert.AreEqual(transcript[j++], activity.Text));
            botToUser
            .Setup(p => p.MakeMessage())
            .Returns(new Activity());
            var replay = new ReplayTranscript(botToUser.Object);
            await source.WalkActivitiesAsync(replay.Replay, DefaultChannel, DefaultConversation);

            await manager.DeleteConversationAsync(DefaultChannel, "conversation2");

            Assert.AreEqual(0, source.Activities(DefaultChannel, "conversation2").Count());

            await manager.DeleteConversationAsync("channel2", DefaultConversation);

            Assert.AreEqual(0, source.Activities("channel2", DefaultConversation).Count());

            await manager.DeleteUserActivitiesAsync("user2");

            await source.WalkActivitiesAsync(activity =>
            {
                Assert.IsTrue(activity.From.Id != "user2" && activity.Recipient.Id != "user2");
                return(Task.CompletedTask);
            });

            var purge = LastActivity.AddSeconds(-30.0);
            await manager.DeleteBeforeAsync(purge);

            AssertEqual(Filter(activities, oldest: purge), source.Activities(DefaultChannel, DefaultConversation));
        }