Beispiel #1
0
        /// <summary>
        /// Create a topic
        /// </summary>
        /// <param name="processType">Process type</param>
        /// <param name="topicHandle">Topic handle</param>
        /// <param name="title">Topic title</param>
        /// <param name="text">Topic text</param>
        /// <param name="blobType">Blob type</param>
        /// <param name="blobHandle">Blob handle</param>
        /// <param name="categories">Topic categories</param>
        /// <param name="language">Topic language</param>
        /// <param name="group">Topic group</param>
        /// <param name="deepLink">Topic deep link</param>
        /// <param name="friendlyName">Topic friendly name</param>
        /// <param name="publisherType">Publisher type</param>
        /// <param name="userHandle">User handle</param>
        /// <param name="userVisibility">User visibility</param>
        /// <param name="createdTime">Created time</param>
        /// <param name="reviewStatus">Review status</param>
        /// <param name="appHandle">App handle</param>
        /// <param name="requestId">Request id associated with the create topic request</param>
        /// <returns>Create topic task</returns>
        public async Task CreateTopic(
            ProcessType processType,
            string topicHandle,
            string title,
            string text,
            BlobType blobType,
            string blobHandle,
            string categories,
            string language,
            string group,
            string deepLink,
            string friendlyName,
            PublisherType publisherType,
            string userHandle,
            UserVisibilityStatus userVisibility,
            DateTime createdTime,
            ReviewStatus reviewStatus,
            string appHandle,
            string requestId)
        {
            await this.topicsStore.InsertTopic(
                StorageConsistencyMode.Strong,
                topicHandle,
                title,
                text,
                blobType,
                blobHandle,
                categories,
                language,
                group,
                deepLink,
                friendlyName,
                publisherType,
                userHandle,
                createdTime,
                reviewStatus,
                appHandle,
                requestId);

            if (publisherType == PublisherType.User)
            {
                await this.topicsStore.InsertUserTopic(StorageConsistencyMode.Strong, userHandle, appHandle, topicHandle);

                await this.topicsStore.InsertFollowingTopic(StorageConsistencyMode.Strong, userHandle, appHandle, topicHandle, userHandle);

                await this.popularTopicsManager.UpdatePopularUserTopic(processType, userHandle, appHandle, topicHandle, 0);
            }

            // TODO: should we add a popular app topic feed
            await this.topicsStore.InsertRecentTopic(StorageConsistencyMode.Strong, appHandle, topicHandle, userHandle);

            await this.popularTopicsManager.UpdatePopularTopic(processType, appHandle, topicHandle, userHandle, createdTime, 0);

            await this.searchQueue.SendSearchIndexTopicMessage(topicHandle, createdTime);

            if (publisherType == PublisherType.User)
            {
                await this.fanoutTopicsQueue.SendFanoutTopicMessage(userHandle, appHandle, topicHandle);
            }
        }
Beispiel #2
0
        public async Task <IHttpActionResult> GetTopicNameV06(string topicName, PublisherType publisherType)
        {
            string className  = "TopicsController";
            string methodName = "GetTopicNameV06";
            string logEntry   = $"PublisherType = {publisherType}";

            this.LogControllerStart(this.log, className, methodName, logEntry);

            // currently, we only support app published topic names
            if (publisherType != PublisherType.App)
            {
                return(this.NotImplemented(ResponseStrings.NotImplemented));
            }

            // lookup the topic name using the name and the appHandle
            var topicNameEntity = await this.topicNamesManager.ReadTopicName(this.AppHandle, topicName);

            if (topicNameEntity == null)
            {
                return(this.NotFound(ResponseStrings.TopicNameNotFound));
            }

            var response = new GetTopicNameResponseV06()
            {
                TopicHandle = topicNameEntity.TopicHandle
            };

            logEntry += $", TopicHandle = {response.TopicHandle}";
            this.LogControllerEnd(this.log, className, methodName, logEntry);
            return(this.Ok <GetTopicNameResponseV06>(response));
        }
        /// <summary>
        /// Send like message
        /// </summary>
        /// <param name="likeHandle">Like handle</param>
        /// <param name="contentType">Content type</param>
        /// <param name="contentHandle">Content handle</param>
        /// <param name="userHandle">User handle</param>
        /// <param name="liked">Like status</param>
        /// <param name="contentPublisherType">Content publisher type</param>
        /// <param name="contentUserHandle">User handle of the content publisher</param>
        /// <param name="contentCreatedTime">Content createdTime</param>
        /// <param name="appHandle">App handle</param>
        /// <param name="lastUpdatedTime">Last updated time</param>
        /// <returns>Send message task</returns>
        public async Task SendLikeMessage(
            string likeHandle,
            ContentType contentType,
            string contentHandle,
            string userHandle,
            bool liked,
            PublisherType contentPublisherType,
            string contentUserHandle,
            DateTime contentCreatedTime,
            string appHandle,
            DateTime lastUpdatedTime)
        {
            LikeMessage message = new LikeMessage()
            {
                LikeHandle           = likeHandle,
                ContentType          = contentType,
                ContentHandle        = contentHandle,
                UserHandle           = userHandle,
                Liked                = liked,
                ContentPublisherType = contentPublisherType,
                ContentUserHandle    = contentUserHandle,
                ContentCreatedTime   = contentCreatedTime,
                AppHandle            = appHandle,
                LastUpdatedTime      = lastUpdatedTime
            };

            Queue queue = await this.QueueManager.GetQueue(this.QueueIdentifier);

            await queue.SendAsync(message);
        }
Beispiel #4
0
 public void Clear()
 {
     _selectedRepo      = RepositoryType.NotSelected;
     _selectedPublisher = PublisherType.NotSelected;
     _sqliteRepoConfig  = null;
     _lmdbRepoConfig    = null;
     _customRepository  = null;
     _customPublisher   = null;
 }
Beispiel #5
0
        public IDataPublisher Create(PublisherType publisherType)
        {
            if (publisherType == PublisherType.File)
            {
                var fileName = ConfigurationManager.AppSettings["inputFileName"];
                return(new FileFeedPublisher(fileName));
            }

            return(null);
        }
Beispiel #6
0
        /// <summary>
        /// Create a topic
        /// </summary>
        /// <param name="publisherType">publisher type</param>
        /// <returns>result of create topic operation</returns>
        public async Task <IHttpActionResult> PostTopic(PublisherType publisherType)
        {
            var postTopicRequest = new PostTopicRequest
            {
                PublisherType = publisherType,
                Text          = "Text" + this.seqNumber.GenerateStronglyOrderedSequenceNumber()
            };

            return(await this.PostTopic(postTopicRequest));
        }
Beispiel #7
0
 public IHttpActionResult GetPublishers(
     PublisherType publisherType = PublisherType.Undefined,
     string publisherName = null,
     string publisherCode = null,
     string publisherLin = null,
     int offset = 0,
     int? limit = null)
 {
     return Ok(this.publisherRepository.GetPublishers(publisherType, publisherName, publisherCode, publisherLin, offset, limit));
 }
Beispiel #8
0
 private TestConfig(string username, string password, string host, PublisherType publisherType, string publisher, int requestTimeout, int readWriteTimeout, int idleMilliseconds)
 {
     this.Username = username;
     this.Password = password;
     this.Host = host;
     this.PublisherType = publisherType;
     this.Publisher = publisher;
     this.RequestTimeout = requestTimeout;
     this.ReadWriteTimeout = readWriteTimeout;
     this.IdleMilliseconds = idleMilliseconds;
 }
 public IParser CreateParser(PublisherType type)
 {
     switch (type) {
         case PublisherType.Atom:
             return new AtomParser.AtomParser();
         case PublisherType.Rss:
             return new RssParser.RssParser();
         default:
             throw new ArgumentException("Unhandling parser type: " + type);
     }
 }
Beispiel #10
0
 /// <summary>
 /// Initializes a new instance of the PostTopicRequest class.
 /// </summary>
 public PostTopicRequest(PublisherType publisherType, string text, string title = default(string), BlobType?blobType = default(BlobType?), string blobHandle = default(string), string categories = default(string), string language = default(string), string deepLink = default(string), string friendlyName = default(string), string group = default(string))
 {
     PublisherType = publisherType;
     Title         = title;
     Text          = text;
     BlobType      = blobType;
     BlobHandle    = blobHandle;
     Categories    = categories;
     Language      = language;
     DeepLink      = deepLink;
     FriendlyName  = friendlyName;
     Group         = group;
 }
Beispiel #11
0
        public static Publisher FromDCT(this PublisherType p)
        {
            if (p == null)
            {
                return(null);
            }

            return(new Publisher
            {
                Address = p.Address,
                EMail = p.EMail,
                Phone = p.Phone,
                PublisherName = p.PublisherName,
                Books = p.Books.Select(FromDCT).ToList(),
            });
        }
Beispiel #12
0
        /// <summary>
        /// Insert topic
        /// </summary>
        /// <param name="storageConsistencyMode">Storage consistency mode</param>
        /// <param name="topicHandle">Topic handle</param>
        /// <param name="title">Topic title</param>
        /// <param name="text">Topic text</param>
        /// <param name="blobType">Blob type</param>
        /// <param name="blobHandle">Blob handle</param>
        /// <param name="categories">Topic categories</param>
        /// <param name="language">Topic language</param>
        /// <param name="group">Topic group</param>
        /// <param name="deepLink">Topic deep link</param>
        /// <param name="friendlyName">Topic friendly name</param>
        /// <param name="publisherType">Publisher type</param>
        /// <param name="userHandle">User handle</param>
        /// <param name="createdTime">Created time</param>
        /// <param name="reviewStatus">Review status</param>
        /// <param name="appHandle">App handle</param>
        /// <param name="requestId">Request id associated with the create topic request</param>
        /// <returns>Insert topic task</returns>
        public async Task InsertTopic(
            StorageConsistencyMode storageConsistencyMode,
            string topicHandle,
            string title,
            string text,
            BlobType blobType,
            string blobHandle,
            string categories,
            string language,
            string group,
            string deepLink,
            string friendlyName,
            PublisherType publisherType,
            string userHandle,
            DateTime createdTime,
            ReviewStatus reviewStatus,
            string appHandle,
            string requestId)
        {
            TopicEntity topicEntity = new TopicEntity()
            {
                Title           = title,
                Text            = text,
                BlobType        = blobType,
                BlobHandle      = blobHandle,
                Categories      = categories,
                Language        = language,
                Group           = group,
                DeepLink        = deepLink,
                FriendlyName    = friendlyName,
                PublisherType   = publisherType,
                UserHandle      = userHandle,
                CreatedTime     = createdTime,
                LastUpdatedTime = createdTime,
                AppHandle       = appHandle,
                ReviewStatus    = reviewStatus,
                RequestId       = requestId
            };

            CTStore store = await this.tableStoreManager.GetStore(ContainerIdentifier.Topics);

            ObjectTable table     = this.tableStoreManager.GetTable(ContainerIdentifier.Topics, TableIdentifier.TopicsObject) as ObjectTable;
            Operation   operation = Operation.Insert(table, topicHandle, topicHandle, topicEntity);
            await store.ExecuteOperationAsync(operation, storageConsistencyMode.ToConsistencyMode());
        }
Beispiel #13
0
        public static Publisher ToVM(this PublisherType item)
        {
            if (item == null)
            {
                return(null);
            }

            var publisher = new Publisher
            {
                Address       = item.Address,
                EMail         = item.EMail,
                Phone         = item.Phone,
                PublisherName = item.PublisherName,
                Books         = new System.Collections.Generic.List <Book>().Concat(item.Books.Select(ToVM)).ToList(),
            };

            return(publisher);
        }
Beispiel #14
0
        /// <summary>
        /// Delete a topic
        /// </summary>
        /// <param name="processType">Process type</param>
        /// <param name="topicHandle">Topic handle</param>
        /// <param name="publisherType">Publisher type</param>
        /// <param name="userHandle">User handle</param>
        /// <param name="appHandle">App handle</param>
        /// <returns>Remove topic task</returns>
        public async Task DeleteTopic(
            ProcessType processType,
            string topicHandle,
            PublisherType publisherType,
            string userHandle,
            string appHandle)
        {
            await this.topicsStore.DeleteTopic(StorageConsistencyMode.Strong, topicHandle);

            if (publisherType == PublisherType.User)
            {
                await this.topicsStore.DeleteUserTopic(StorageConsistencyMode.Strong, userHandle, appHandle, topicHandle);

                await this.popularTopicsManager.DeletePopularUserTopic(processType, userHandle, appHandle, topicHandle);
            }

            await this.topicsStore.DeleteRecentTopic(StorageConsistencyMode.Strong, appHandle, topicHandle);

            await this.popularTopicsManager.DeletePopularTopic(processType, appHandle, topicHandle, userHandle);

            await this.searchQueue.SendSearchRemoveTopicMessage(topicHandle);
        }
Beispiel #15
0
 /// <summary>
 /// Update pin
 /// </summary>
 /// <param name="processType">Process type</param>
 /// <param name="pinHandle">Pin handle</param>
 /// <param name="userHandle">User handle</param>
 /// <param name="topicHandle">Topic handle</param>
 /// <param name="pinned">Pin status</param>
 /// <param name="topicPublisherType">Topic publisher type</param>
 /// <param name="topicUserHandle">Topic user handle</param>
 /// <param name="appHandle">App handle</param>
 /// <param name="lastUpdatedTime">Last updated time</param>
 /// <param name="pinLookupEntity">Pin lookup entity</param>
 /// <returns>Update pin task</returns>
 public async Task UpdatePin(
     ProcessType processType,
     string pinHandle,
     string userHandle,
     string topicHandle,
     bool pinned,
     PublisherType topicPublisherType,
     string topicUserHandle,
     string appHandle,
     DateTime lastUpdatedTime,
     IPinLookupEntity pinLookupEntity)
 {
     await this.pinsStore.UpdatePin(
         StorageConsistencyMode.Strong,
         pinHandle,
         userHandle,
         appHandle,
         topicHandle,
         topicUserHandle,
         pinned,
         lastUpdatedTime,
         pinLookupEntity);
 }
Beispiel #16
0
 /// <summary>
 /// Initializes a new instance of the TopicView class.
 /// </summary>
 public TopicView(string topicHandle, DateTime createdTime, DateTime lastUpdatedTime, PublisherType publisherType, string text, long totalLikes, long totalComments, bool liked, UserCompactView user = default(UserCompactView), string title = default(string), BlobType?blobType = default(BlobType?), string blobHandle = default(string), string blobUrl = default(string), string categories = default(string), string language = default(string), string group = default(string), string deepLink = default(string), string friendlyName = default(string), bool?pinned = default(bool?), ContentStatus?contentStatus = default(ContentStatus?), AppCompactView app = default(AppCompactView))
 {
     TopicHandle     = topicHandle;
     CreatedTime     = createdTime;
     LastUpdatedTime = lastUpdatedTime;
     PublisherType   = publisherType;
     User            = user;
     Title           = title;
     Text            = text;
     BlobType        = blobType;
     BlobHandle      = blobHandle;
     BlobUrl         = blobUrl;
     Categories      = categories;
     Language        = language;
     Group           = group;
     DeepLink        = deepLink;
     FriendlyName    = friendlyName;
     TotalLikes      = totalLikes;
     TotalComments   = totalComments;
     Liked           = liked;
     Pinned          = pinned;
     ContentStatus   = contentStatus;
     App             = app;
 }
Beispiel #17
0
 /// <summary>
 /// Initializes a new instance of the DeleteTopicNameRequest class.
 /// </summary>
 public DeleteTopicNameRequest(PublisherType publisherType)
 {
     PublisherType = publisherType;
 }
Beispiel #18
0
 /// <summary>
 /// Get a topic by topic name
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='topicName'>
 /// Topic name
 /// </param>
 /// <param name='publisherType'>
 /// Publisher type. Possible values include: 'User', 'App'
 /// </param>
 /// <param name='authorization'>
 /// Format is: "Scheme CredentialsList". Possible values are:
 ///
 /// - Anon AK=AppKey
 ///
 /// - SocialPlus TK=SessionToken
 ///
 /// - Facebook AK=AppKey|TK=AccessToken
 ///
 /// - Google AK=AppKey|TK=AccessToken
 ///
 /// - Twitter AK=AppKey|RT=RequestToken|TK=AccessToken
 ///
 /// - Microsoft AK=AppKey|TK=AccessToken
 ///
 /// - AADS2S AK=AppKey|[UH=UserHandle]|TK=AADToken
 /// </param>
 public static GetTopicByNameResponse GetTopicByName(this ITopics operations, string topicName, PublisherType publisherType, string authorization)
 {
     return(Task.Factory.StartNew(s => ((ITopics)s).GetTopicByNameAsync(topicName, publisherType, authorization), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
Beispiel #19
0
        /// <summary>
        /// Update like
        /// </summary>
        /// <param name="processType">Process type</param>
        /// <param name="likeHandle">Like handle</param>
        /// <param name="contentType">Content type</param>
        /// <param name="contentHandle">Content handle</param>
        /// <param name="userHandle">User handle</param>
        /// <param name="liked">Like status</param>
        /// <param name="contentPublisherType">Content publisher type</param>
        /// <param name="contentUserHandle">User handle of the content publisher</param>
        /// <param name="contentCreatedTime">Content createdTime</param>
        /// <param name="appHandle">App handle</param>
        /// <param name="lastUpdatedTime">Last updated time</param>
        /// <param name="likeLookupEntity">Like lookup entity</param>
        /// <returns>Update like task</returns>
        public async Task UpdateLike(
            ProcessType processType,
            string likeHandle,
            ContentType contentType,
            string contentHandle,
            string userHandle,
            bool liked,
            PublisherType contentPublisherType,
            string contentUserHandle,
            DateTime contentCreatedTime,
            string appHandle,
            DateTime lastUpdatedTime,
            ILikeLookupEntity likeLookupEntity)
        {
            if (processType == ProcessType.Frontend)
            {
                await this.likesStore.UpdateLike(
                    StorageConsistencyMode.Strong,
                    likeHandle,
                    contentHandle,
                    userHandle,
                    liked,
                    lastUpdatedTime,
                    likeLookupEntity);

                await this.likesQueue.SendLikeMessage(
                    likeHandle,
                    contentType,
                    contentHandle,
                    userHandle,
                    liked,
                    contentPublisherType,
                    contentUserHandle,
                    contentCreatedTime,
                    appHandle,
                    lastUpdatedTime);
            }
            else if (processType == ProcessType.Backend || processType == ProcessType.BackendRetry)
            {
                if (liked & contentPublisherType == PublisherType.User && userHandle != contentUserHandle)
                {
                    await this.notificationsManager.CreateNotification(
                        processType,
                        contentUserHandle,
                        appHandle,
                        likeHandle,
                        ActivityType.Like,
                        userHandle,
                        contentUserHandle,
                        contentType,
                        contentHandle,
                        lastUpdatedTime);
                }

                if (liked && contentType == ContentType.Topic)
                {
                    await this.fanoutActivitiesQueue.SendFanoutActivityMessage(
                        userHandle,
                        appHandle,
                        likeHandle,
                        ActivityType.Like,
                        userHandle,
                        contentUserHandle,
                        contentType,
                        contentHandle,
                        lastUpdatedTime);

                    // TODO: check what happens if the topic is AppPublished?
                    await this.fanoutActivitiesQueue.SendFanoutTopicActivityMessage(
                        contentHandle,
                        appHandle,
                        likeHandle,
                        ActivityType.Like,
                        userHandle,
                        contentUserHandle,
                        contentType,
                        contentHandle,
                        lastUpdatedTime);
                }

                long?likesCount = await this.likesStore.QueryLikesCount(contentHandle);

                long likesCountValue = likesCount.HasValue ? likesCount.Value : 0;
                if (likesCountValue % PopularTopicsUpdateLikesCount == 0)
                {
                    if (contentType == ContentType.Topic)
                    {
                        await this.popularTopicsManager.UpdatePopularTopic(processType, appHandle, contentHandle, contentUserHandle, contentCreatedTime, likesCountValue);
                    }

                    if (contentType == ContentType.Topic && contentPublisherType == PublisherType.User)
                    {
                        await this.popularTopicsManager.UpdatePopularUserTopic(processType, contentUserHandle, appHandle, contentHandle, likesCountValue);
                    }
                }
            }
        }
Beispiel #20
0
 /// <summary>
 /// Get a topic by topic name
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='topicName'>
 /// Topic name
 /// </param>
 /// <param name='publisherType'>
 /// Publisher type. Possible values include: 'User', 'App'
 /// </param>
 /// <param name='authorization'>
 /// Format is: "Scheme CredentialsList". Possible values are:
 ///
 /// - Anon AK=AppKey
 ///
 /// - SocialPlus TK=SessionToken
 ///
 /// - Facebook AK=AppKey|TK=AccessToken
 ///
 /// - Google AK=AppKey|TK=AccessToken
 ///
 /// - Twitter AK=AppKey|RT=RequestToken|TK=AccessToken
 ///
 /// - Microsoft AK=AppKey|TK=AccessToken
 ///
 /// - AADS2S AK=AppKey|[UH=UserHandle]|TK=AADToken
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <GetTopicByNameResponse> GetTopicByNameAsync(this ITopics operations, string topicName, PublisherType publisherType, string authorization, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.GetTopicByNameWithHttpMessagesAsync(topicName, publisherType, authorization, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
        /// <summary>
        /// Several types of notication test with Get Put and Count
        /// </summary>
        /// <param name="appPublished">flag to indicate if topics are app published</param>
        /// <param name="appHandle">app handle</param>
        /// <returns>Fail if an exception is hit</returns>
        public async Task GetPutCountNotificationTestHelper(bool appPublished, string appHandle)
        {
            SocialPlusClient client1 = new SocialPlusClient(TestConstants.ServerApiBaseUrl);
            SocialPlusClient client2 = new SocialPlusClient(TestConstants.ServerApiBaseUrl);
            SocialPlusClient client3 = new SocialPlusClient(TestConstants.ServerApiBaseUrl);

            PostUserResponse postUserResponse = await TestUtilities.DoLogin(client1, "Stan", "TopicMan", string.Empty);

            string auth1 = AuthHelper.CreateSocialPlusAuth(postUserResponse.SessionToken);

            if (appPublished)
            {
                // add user1 as admin
                bool added = ManageAppsUtils.AddAdmin(TestConstants.EnvironmentName, appHandle, postUserResponse.UserHandle);
                if (!added)
                {
                    // delete the user and fail the test
                    await client1.Users.DeleteUserAsync(auth1);

                    Assert.Fail("Failed to set user as administrator");
                }
            }

            PostUserResponse postUserResponse2 = await TestUtilities.DoLogin(client2, "Emily", "Johnson", string.Empty);

            string           auth2             = AuthHelper.CreateSocialPlusAuth(postUserResponse2.SessionToken);
            PostUserResponse postUserResponse3 = await TestUtilities.DoLogin(client3, "Johnny", "OnTheSpot", string.Empty);

            string auth3 = AuthHelper.CreateSocialPlusAuth(postUserResponse3.SessionToken);

            PublisherType     publisherType     = appPublished ? PublisherType.App : PublisherType.User;
            PostTopicRequest  postTopicRequest  = new PostTopicRequest(publisherType: publisherType, text: "Text", title: "Title", blobHandle: "BlobHandle", language: "en-US", deepLink: "link", categories: "categories", friendlyName: "friendlyName", group: "group");
            PostTopicResponse postTopicResponse = await client1.Topics.PostTopicAsync(postTopicRequest, auth1);

            // all three users like the topic that was created
            await client1.TopicLikes.PostLikeAsync(postTopicResponse.TopicHandle, auth1);

            await client2.TopicLikes.PostLikeAsync(postTopicResponse.TopicHandle, auth2);

            await client3.TopicLikes.PostLikeAsync(postTopicResponse.TopicHandle, auth3);

            if (appPublished)
            {
                // for an app published topic, the topic creator (the content owner) does not receive notifications
                // when the topic is liked.
                await Task.Delay(TestConstants.ServiceBusMediumDelay);

                FeedResponseActivityView notifications1 = await client1.MyNotifications.GetNotificationsAsync(auth1);

                notifications1 = await client1.MyNotifications.GetNotificationsAsync(auth1, null, 10);

                CountResponse count1 = await client1.MyNotifications.GetNotificationsCountAsync(auth1);

                // Clean up state from the test
                await client1.Topics.DeleteTopicAsync(postTopicResponse.TopicHandle, auth1);

                ManageAppsUtils.DeleteAdmin(TestConstants.EnvironmentName, appHandle, postUserResponse.UserHandle);
                await client1.Users.DeleteUserAsync(auth1);

                await client2.Users.DeleteUserAsync(auth2);

                await client3.Users.DeleteUserAsync(auth3);

                // check that no notifications are delivered
                Assert.AreEqual(0, notifications1.Data.Count);
                Assert.AreEqual(0, count1.Count);
            }
            else
            {
                // for a user published topic, user1 (the content owner) should receive two notifications:
                // one when user2 likes the topic, and one when user3 likes the topic
                FeedResponseActivityView notifications1 = null;
                FeedResponseActivityView notifications2 = null;
                FeedResponseActivityView notifications3 = null;
                CountResponse            count1         = null;
                await TestUtilities.AutoRetryServiceBusHelper(
                    async() =>
                {
                    // get the first notification
                    notifications1 = await client1.MyNotifications.GetNotificationsAsync(auth1, null, 1);

                    // get the second notification using the first one as the cursor
                    notifications2 = await client1.MyNotifications.GetNotificationsAsync(auth1, notifications1.Cursor, 1);

                    // get up to 10 notifications
                    notifications3 = await client1.MyNotifications.GetNotificationsAsync(auth1, null, 10);

                    // get the count of unread notifications
                    count1 = await client1.MyNotifications.GetNotificationsCountAsync(auth1);
                },
                    () =>
                {
                    // verify
                    Assert.AreEqual(1, notifications1.Data.Count);
                    Assert.AreEqual(ActivityType.Like, notifications1.Data[0].ActivityType);
                    Assert.AreEqual(1, notifications1.Data[0].ActorUsers.Count);
                    Assert.AreEqual(1, notifications1.Data[0].TotalActions);
                    Assert.AreEqual(postTopicResponse.TopicHandle, notifications1.Data[0].ActedOnContent.ContentHandle);
                    Assert.AreEqual(BlobType.Unknown, notifications1.Data[0].ActedOnContent.BlobType);
                    Assert.AreEqual(ContentType.Topic, notifications1.Data[0].ActedOnContent.ContentType);

                    Assert.AreEqual(1, notifications2.Data.Count);
                    Assert.AreEqual(ActivityType.Like, notifications2.Data[0].ActivityType);
                    Assert.AreEqual(1, notifications2.Data[0].ActorUsers.Count);
                    Assert.AreEqual(1, notifications2.Data[0].TotalActions);
                    Assert.AreEqual(postTopicResponse.TopicHandle, notifications2.Data[0].ActedOnContent.ContentHandle);
                    Assert.AreEqual(BlobType.Unknown, notifications2.Data[0].ActedOnContent.BlobType);
                    Assert.AreEqual(ContentType.Topic, notifications2.Data[0].ActedOnContent.ContentType);

                    Assert.AreEqual(2, notifications3.Data.Count);
                    Assert.AreEqual(ActivityType.Like, notifications3.Data[0].ActivityType);
                    Assert.AreEqual(1, notifications3.Data[0].ActorUsers.Count);
                    Assert.AreEqual(1, notifications3.Data[0].TotalActions);
                    Assert.AreEqual(postTopicResponse.TopicHandle, notifications3.Data[0].ActedOnContent.ContentHandle);
                    Assert.AreEqual(BlobType.Unknown, notifications3.Data[0].ActedOnContent.BlobType);
                    Assert.AreEqual(ContentType.Topic, notifications3.Data[0].ActedOnContent.ContentType);

                    Assert.AreEqual(2, count1.Count);
                });

                // Update which is the most recent notification the user has read
                PutNotificationsStatusRequest putNotificationStatusRequest = new PutNotificationsStatusRequest(notifications3.Data.First().ActivityHandle);
                await client1.MyNotifications.PutNotificationsStatusAsync(putNotificationStatusRequest, auth1);

                // Get Notification
                FeedResponseActivityView notifications4 = await client1.MyNotifications.GetNotificationsAsync(auth1, null, 10);

                var count2 = await client1.MyNotifications.GetNotificationsCountAsync(auth1);

                // User3 creates another like on the topic.  Even though this doesn't change
                // the like status because the user has already liked this topic, it does generate
                // another notification.
                await client3.TopicLikes.PostLikeAsync(postTopicResponse.TopicHandle, auth3);

                FeedResponseActivityView notifications5 = null;
                CountResponse            count3         = null;
                await TestUtilities.AutoRetryServiceBusHelper(
                    async() =>
                {
                    // Get new notifications and the count of unread notifications
                    notifications5 = await client1.MyNotifications.GetNotificationsAsync(auth1, null, 10);
                    count3         = await client1.MyNotifications.GetNotificationsCountAsync(auth1);
                }, () =>
                {
                    // verify
                    Assert.AreEqual(2, notifications5.Data.Count);
                    Assert.AreEqual(ActivityType.Like, notifications5.Data[0].ActivityType);
                    Assert.AreEqual(1, notifications5.Data[0].ActorUsers.Count);
                    Assert.AreEqual(1, notifications5.Data[0].TotalActions);
                    Assert.AreEqual(postTopicResponse.TopicHandle, notifications5.Data[0].ActedOnContent.ContentHandle);
                    Assert.AreEqual(BlobType.Unknown, notifications5.Data[0].ActedOnContent.BlobType);
                    Assert.AreEqual(ContentType.Topic, notifications5.Data[0].ActedOnContent.ContentType);

                    Assert.AreEqual(1, count3.Count);
                });

                // User2 deletes their like on the topic.  This generates a notification
                await client2.TopicLikes.DeleteLikeAsync(postTopicResponse.TopicHandle, auth2);

                FeedResponseActivityView notifications6 = null;
                CountResponse            count4         = null;
                await TestUtilities.AutoRetryServiceBusHelper(
                    async() =>
                {
                    // Get new notifications and the count of unread notifications
                    notifications6 = await client1.MyNotifications.GetNotificationsAsync(auth1, null, 10);
                    count4         = await client1.MyNotifications.GetNotificationsCountAsync(auth1);
                }, () =>
                {
                    // verify
                    Assert.AreEqual(1, notifications6.Data.Count);
                    Assert.AreEqual(ActivityType.Like, notifications6.Data[0].ActivityType);
                    Assert.AreEqual(1, notifications6.Data[0].ActorUsers.Count);
                    Assert.AreEqual(1, notifications6.Data[0].TotalActions);
                    Assert.AreEqual(postTopicResponse.TopicHandle, notifications6.Data[0].ActedOnContent.ContentHandle);
                    Assert.AreEqual(BlobType.Unknown, notifications6.Data[0].ActedOnContent.BlobType);
                    Assert.AreEqual(ContentType.Topic, notifications6.Data[0].ActedOnContent.ContentType);

                    Assert.AreEqual(1, count4.Count);
                });

                // User2 once again likes the topic and generates a notification
                await client2.TopicLikes.PostLikeAsync(postTopicResponse.TopicHandle, auth2);

                FeedResponseActivityView notifications7 = null;
                CountResponse            count5         = null;

                await TestUtilities.AutoRetryServiceBusHelper(
                    async() =>
                {
                    // Get new notifications and the count of unread notifications
                    notifications7 = await client1.MyNotifications.GetNotificationsAsync(auth1, null, 10);
                    count5         = await client1.MyNotifications.GetNotificationsCountAsync(auth1);
                }, () =>
                {
                    // verify
                    Assert.AreEqual(2, notifications7.Data.Count);
                    Assert.AreEqual(ActivityType.Like, notifications7.Data[0].ActivityType);
                    Assert.AreEqual(1, notifications7.Data[0].ActorUsers.Count);
                    Assert.AreEqual(1, notifications7.Data[0].TotalActions);
                    Assert.AreEqual(postTopicResponse.TopicHandle, notifications7.Data[0].ActedOnContent.ContentHandle);
                    Assert.AreEqual(BlobType.Unknown, notifications7.Data[0].ActedOnContent.BlobType);
                    Assert.AreEqual(ContentType.Topic, notifications7.Data[0].ActedOnContent.ContentType);

                    Assert.AreEqual(2, count5.Count);
                });

                // Update the most recent notification read
                putNotificationStatusRequest = new PutNotificationsStatusRequest(notifications7.Data.First().ActivityHandle);
                await client1.MyNotifications.PutNotificationsStatusAsync(putNotificationStatusRequest, auth1);

                // Get new notifications and the count of unread notifications
                var notifications8 = await client1.MyNotifications.GetNotificationsAsync(auth1, null, 10);

                var count6 = await client1.MyNotifications.GetNotificationsCountAsync(auth1);

                // Clean up state from the test
                await client1.Topics.DeleteTopicAsync(postTopicResponse.TopicHandle, auth1);

                await client1.Users.DeleteUserAsync(auth1);

                await client2.Users.DeleteUserAsync(auth2);

                await client3.Users.DeleteUserAsync(auth3);

                // Validate everything
                Assert.AreEqual(1, notifications1.Data.Count);
                Assert.AreEqual(ActivityType.Like, notifications1.Data[0].ActivityType);
                Assert.AreEqual(1, notifications1.Data[0].ActorUsers.Count);
                Assert.AreEqual(1, notifications1.Data[0].TotalActions);
                Assert.AreEqual(postTopicResponse.TopicHandle, notifications1.Data[0].ActedOnContent.ContentHandle);
                Assert.AreEqual(BlobType.Unknown, notifications1.Data[0].ActedOnContent.BlobType);
                Assert.AreEqual(ContentType.Topic, notifications1.Data[0].ActedOnContent.ContentType);

                Assert.AreEqual(1, notifications2.Data.Count);
                Assert.AreEqual(ActivityType.Like, notifications2.Data[0].ActivityType);
                Assert.AreEqual(1, notifications2.Data[0].ActorUsers.Count);
                Assert.AreEqual(1, notifications2.Data[0].TotalActions);
                Assert.AreEqual(postTopicResponse.TopicHandle, notifications2.Data[0].ActedOnContent.ContentHandle);
                Assert.AreEqual(BlobType.Unknown, notifications2.Data[0].ActedOnContent.BlobType);
                Assert.AreEqual(ContentType.Topic, notifications2.Data[0].ActedOnContent.ContentType);

                Assert.AreEqual(2, notifications3.Data.Count);
                Assert.AreEqual(ActivityType.Like, notifications3.Data[0].ActivityType);
                Assert.AreEqual(1, notifications3.Data[0].ActorUsers.Count);
                Assert.AreEqual(1, notifications3.Data[0].TotalActions);
                Assert.AreEqual(postTopicResponse.TopicHandle, notifications3.Data[0].ActedOnContent.ContentHandle);
                Assert.AreEqual(BlobType.Unknown, notifications3.Data[0].ActedOnContent.BlobType);
                Assert.AreEqual(ContentType.Topic, notifications3.Data[0].ActedOnContent.ContentType);

                Assert.AreEqual(2, notifications4.Data.Count);
                Assert.AreEqual(ActivityType.Like, notifications4.Data[0].ActivityType);
                Assert.AreEqual(1, notifications4.Data[0].ActorUsers.Count);
                Assert.AreEqual(1, notifications4.Data[0].TotalActions);
                Assert.AreEqual(postTopicResponse.TopicHandle, notifications4.Data[0].ActedOnContent.ContentHandle);
                Assert.AreEqual(BlobType.Unknown, notifications4.Data[0].ActedOnContent.BlobType);
                Assert.AreEqual(ContentType.Topic, notifications4.Data[0].ActedOnContent.ContentType);

                Assert.AreEqual(2, notifications5.Data.Count);
                Assert.AreEqual(ActivityType.Like, notifications5.Data[0].ActivityType);
                Assert.AreEqual(1, notifications5.Data[0].ActorUsers.Count);
                Assert.AreEqual(1, notifications5.Data[0].TotalActions);
                Assert.AreEqual(postTopicResponse.TopicHandle, notifications5.Data[0].ActedOnContent.ContentHandle);
                Assert.AreEqual(BlobType.Unknown, notifications5.Data[0].ActedOnContent.BlobType);
                Assert.AreEqual(ContentType.Topic, notifications5.Data[0].ActedOnContent.ContentType);

                Assert.AreEqual(1, notifications6.Data.Count);
                Assert.AreEqual(ActivityType.Like, notifications6.Data[0].ActivityType);
                Assert.AreEqual(1, notifications6.Data[0].ActorUsers.Count);
                Assert.AreEqual(1, notifications6.Data[0].TotalActions);
                Assert.AreEqual(postTopicResponse.TopicHandle, notifications6.Data[0].ActedOnContent.ContentHandle);
                Assert.AreEqual(BlobType.Unknown, notifications6.Data[0].ActedOnContent.BlobType);
                Assert.AreEqual(ContentType.Topic, notifications6.Data[0].ActedOnContent.ContentType);

                Assert.AreEqual(2, notifications7.Data.Count);
                Assert.AreEqual(ActivityType.Like, notifications7.Data[0].ActivityType);
                Assert.AreEqual(1, notifications7.Data[0].ActorUsers.Count);
                Assert.AreEqual(1, notifications7.Data[0].TotalActions);
                Assert.AreEqual(postTopicResponse.TopicHandle, notifications7.Data[0].ActedOnContent.ContentHandle);
                Assert.AreEqual(BlobType.Unknown, notifications7.Data[0].ActedOnContent.BlobType);
                Assert.AreEqual(ContentType.Topic, notifications7.Data[0].ActedOnContent.ContentType);

                Assert.AreEqual(2, notifications8.Data.Count);
                Assert.AreEqual(ActivityType.Like, notifications8.Data[0].ActivityType);
                Assert.AreEqual(1, notifications8.Data[0].ActorUsers.Count);
                Assert.AreEqual(1, notifications8.Data[0].TotalActions);
                Assert.AreEqual(postTopicResponse.TopicHandle, notifications8.Data[0].ActedOnContent.ContentHandle);
                Assert.AreEqual(BlobType.Unknown, notifications8.Data[0].ActedOnContent.BlobType);
                Assert.AreEqual(ContentType.Topic, notifications8.Data[0].ActedOnContent.ContentType);

                Assert.AreEqual(2, count1.Count);
                Assert.AreEqual(0, count2.Count);
                Assert.AreEqual(1, count3.Count);
                Assert.AreEqual(1, count4.Count);
                Assert.AreEqual(2, count5.Count);
                Assert.AreEqual(0, count6.Count);
            }
        }
 /// <summary>
 /// Initializes a new instance of the PutTopicNameRequest class.
 /// </summary>
 public PutTopicNameRequest(PublisherType publisherType, string topicHandle)
 {
     PublisherType = publisherType;
     TopicHandle   = topicHandle;
 }
Beispiel #23
0
        /// <summary>
        /// Update like for content
        /// </summary>
        /// <param name="callerClassName">name of the controller class of the caller</param>
        /// <param name="callerMethodName">name of method insider controller class of the caller (should correspond to an HTTP action)</param>
        /// <param name="contentType">Content type</param>
        /// <param name="contentHandle">Content handle</param>
        /// <param name="liked">Like status</param>
        /// <returns>Http response</returns>
        protected async Task <IHttpActionResult> UpdateLike(string callerClassName, string callerMethodName, ContentType contentType, string contentHandle, bool liked)
        {
            PublisherType contentPublisherType = PublisherType.User;
            string        contentUserHandle    = null;
            string        contentAppHandle     = this.AppHandle;
            DateTime      contentCreatedTime   = DateTime.MinValue;
            string        logEntry             = null;

            if (contentType == ContentType.Topic)
            {
                var topicEntity = await this.topicsManager.ReadTopic(contentHandle);

                if (topicEntity == null)
                {
                    return(this.NotFound(ResponseStrings.TopicNotFound));
                }

                contentPublisherType = topicEntity.PublisherType;
                contentUserHandle    = topicEntity.UserHandle;
                contentAppHandle     = topicEntity.AppHandle;
                contentCreatedTime   = topicEntity.CreatedTime;
                logEntry             = $"TopicHandle = {contentHandle}";
            }
            else if (contentType == ContentType.Comment)
            {
                var commentEntity = await this.commentsManager.ReadComment(contentHandle);

                if (commentEntity == null)
                {
                    return(this.NotFound(ResponseStrings.CommentNotFound));
                }

                contentPublisherType = PublisherType.User;
                contentUserHandle    = commentEntity.UserHandle;
                contentAppHandle     = commentEntity.AppHandle;
                contentCreatedTime   = commentEntity.CreatedTime;
                logEntry             = $"CommentHandle = {contentHandle}";
            }
            else if (contentType == ContentType.Reply)
            {
                var replyEntity = await this.repliesManager.ReadReply(contentHandle);

                if (replyEntity == null)
                {
                    return(this.NotFound(ResponseStrings.ReplyNotFound));
                }

                contentPublisherType = PublisherType.User;
                contentUserHandle    = replyEntity.UserHandle;
                contentAppHandle     = replyEntity.AppHandle;
                contentCreatedTime   = replyEntity.CreatedTime;
                logEntry             = $"ReplyHandle = {contentHandle}";
            }

            var likeLookupEntity = await this.likesManager.ReadLike(contentHandle, this.UserHandle);

            DateTime currentTime = DateTime.UtcNow;

            if (likeLookupEntity != null && likeLookupEntity.LastUpdatedTime > currentTime)
            {
                return(this.Conflict(ResponseStrings.NewerItemExists));
            }

            string likeHandle = null;

            if (liked)
            {
                likeHandle = this.handleGenerator.GenerateShortHandle();
            }

            await this.likesManager.UpdateLike(
                ProcessType.Frontend,
                likeHandle,
                contentType,
                contentHandle,
                this.UserHandle,
                liked,
                contentPublisherType,
                contentUserHandle,
                contentCreatedTime,
                contentAppHandle,
                currentTime,
                likeLookupEntity);

            // Log new like to app metrics
            this.applicationMetrics.Like(
                ProcessType.Frontend.ToString(),
                likeHandle,
                contentType.ToString(),
                contentHandle,
                this.UserHandle,
                liked.ToString(),
                contentPublisherType.ToString(),
                contentUserHandle,
                contentCreatedTime,
                contentAppHandle,
                currentTime,
                likeLookupEntity?.LastUpdatedTime,
                likeLookupEntity?.Liked.ToString(),
                likeLookupEntity?.LikeHandle);

            logEntry += $", LikeHandle = {likeHandle}, OldLikedStatus = {likeLookupEntity?.Liked}, NewLikedStatus = {liked}";
            this.LogControllerEnd(this.log, callerClassName, callerMethodName, logEntry);
            return(this.NoContent());
        }
Beispiel #24
0
        public IEnumerable<PublisherDO> GetPublishers(
            PublisherType publisherType,
            string publisherName = null,
            string publisherCode = null,
            string publisherLin = null,
            int offset = 0,
            int? limit = null)
        {
            IQueryable<PublisherDO> publishers = null;

            if (publisherType == PublisherType.Undefined || publisherType == PublisherType.Inspector)
            {
                publishers = this.Concat(publishers,
                    from p in this.unitOfWork.DbContext.Set<GvaViewPerson>()
                    join i in this.unitOfWork.DbContext.Set<GvaViewPersonInspector>() on p.LotId equals i.LotId
                    where i.Valid
                    select new PublisherDO
                    {
                        Lin = p.Lin,
                        Name = p.Names,
                        Code = i.ExaminerCode,
                        PublisherType = PublisherType.Inspector
                    });
            }

            if (publisherType == PublisherType.Undefined || publisherType == PublisherType.Examiner)
            {
                publishers = this.Concat(publishers,
                    this.unitOfWork.DbContext.Set<GvaViewPerson>().Include(p => p.Examiner)
                        .Where(p => p.Examiner != null && p.Examiner.Valid)
                        .Select(p => new PublisherDO
                        {
                            Lin = p.Lin,
                            Name = p.Names,
                            Code = p.Examiner.ExaminerCode,
                            PublisherType = PublisherType.Examiner
                        }));
            }

            if (publisherType == PublisherType.Undefined || publisherType == PublisherType.School)
            {
                publishers = this.Concat(publishers,
                    from nv in this.unitOfWork.DbContext.GetNomValuesByTextContentProperty("schools", "isPilotTraining", "true")
                    where nv.IsActive
                    select new PublisherDO
                    {
                        Lin = null,
                        Name = nv.Name,
                        Code = null,
                        PublisherType = PublisherType.School
                    });
            }

            if (publisherType == PublisherType.Undefined || publisherType == PublisherType.Organization)
            {
                publishers = this.Concat(publishers,
                    from o in this.unitOfWork.DbContext.Set<GvaViewOrganization>().Include(o => o.OrganizationType)
                    where o.Valid
                    select new PublisherDO
                    {
                        Lin = null,
                        Name = o.Name,
                        Code = o.OrganizationType.Name,
                        PublisherType = PublisherType.Organization
                    });
            }

            if (publisherType == PublisherType.Undefined || publisherType == PublisherType.Caa)
            {
                publishers = this.Concat(publishers,
                    from nv in this.unitOfWork.DbContext.Set<NomValue>()
                    where nv.IsActive && nv.Nom.Alias == "caa"
                    select new PublisherDO
                    {
                        Lin = null,
                        Name = nv.Name,
                        Code = null,
                        PublisherType = PublisherType.Caa
                    });
            }

            if (publisherType == PublisherType.Undefined || publisherType == PublisherType.Other)
            {
                publishers = this.Concat(publishers,
                    from nv in this.unitOfWork.DbContext.Set<NomValue>()
                    where nv.IsActive && nv.Nom.Alias == "otherDocPublishers"
                    select new PublisherDO
                    {
                        Lin = null,
                        Name = nv.Name,
                        Code = null,
                        PublisherType = PublisherType.Other
                    });
            }

            if (!string.IsNullOrEmpty(publisherName))
            {
                publishers = publishers.Where(p => p.Name.Contains(publisherName));
            }

            if (!string.IsNullOrEmpty(publisherLin))
            {
                publishers = publishers.Where(p => p.Lin.ToString().Contains(publisherLin));
            }

            if (!string.IsNullOrEmpty(publisherCode))
            {
                publishers = publishers.Where(p => p.Code.Contains(publisherCode));
            }

            return publishers
                .OrderBy(p => p.PublisherType)
                .WithOffsetAndLimit(offset, limit)
                .ToList();
        }
Beispiel #25
0
 /// <summary>
 /// Create a publisher. Note, calling this constructor does not 
 /// create the publisher on a Gnip server.
 /// </summary>
 /// <param name="type">The publisher type.</param>
 /// <param name="name">the publisher's name</param>
 /// <param name="ruleTypes">the publisher's rule types</param>
 public Publisher(PublisherType type, string name, params RuleType[] ruleTypes)
     : this(type, name, (IEnumerable<RuleType>)ruleTypes)
 {
 }
Beispiel #26
0
 /// <summary>
 /// Create a publisher. Note, calling this constructor does not 
 /// create the publisher on a Gnip server.
 /// </summary>
 /// <param name="type">The publisher type.</param>
 /// <param name="name">the publisher's name</param>
 /// <param name="ruleTypes">the publisher's rule types</param>
 public Publisher(PublisherType type, string name, IEnumerable<RuleType> ruleTypes)
     : this(type, name)
 {
     this.SupportedRuleTypes.AddRange(ruleTypes);
 }
Beispiel #27
0
 /// <summary> 
 /// Basic constructor.
 /// </summary>
 /// <param name="type">The publisher type.</param>
 /// <param name="name">the name of the publisher</param>
 public Publisher(PublisherType type, string name)
     : this()
 {
     this.Type = type;
     this.Name = name;
 }
        /// <summary>
        /// Create comment
        /// </summary>
        /// <param name="processType">Process type</param>
        /// <param name="commentHandle">Comment handle</param>
        /// <param name="text">Comment text</param>
        /// <param name="blobType">Blob type</param>
        /// <param name="blobHandle">Blob handle</param>
        /// <param name="language">Comment language</param>
        /// <param name="userHandle">User handle</param>
        /// <param name="topicHandle">Topic handle</param>
        /// <param name="topicPublisherType">Topic publisher type</param>
        /// <param name="topicUserHandle">User handle of topic publisher</param>
        /// <param name="createdTime">Created time</param>
        /// <param name="reviewStatus">Review status</param>
        /// <param name="appHandle">App handle</param>
        /// <param name="requestId">Request id associated with the create request</param>
        /// <returns>Create comment task</returns>
        public async Task CreateComment(
            ProcessType processType,
            string commentHandle,
            string text,
            BlobType blobType,
            string blobHandle,
            string language,
            string userHandle,
            string topicHandle,
            PublisherType topicPublisherType,
            string topicUserHandle,
            DateTime createdTime,
            ReviewStatus reviewStatus,
            string appHandle,
            string requestId)
        {
            await this.commentsStore.InsertComment(
                StorageConsistencyMode.Strong,
                commentHandle,
                topicHandle,
                text,
                blobType,
                blobHandle,
                language,
                userHandle,
                createdTime,
                reviewStatus,
                appHandle,
                requestId);

            await this.commentsStore.InsertTopicComment(
                StorageConsistencyMode.Strong,
                topicHandle,
                commentHandle,
                userHandle);

            if (topicPublisherType == PublisherType.User && userHandle != topicUserHandle)
            {
                await this.notificationsManager.CreateNotification(
                    processType,
                    topicUserHandle,
                    appHandle,
                    commentHandle,
                    ActivityType.Comment,
                    userHandle,
                    topicUserHandle,
                    ContentType.Topic,
                    topicHandle,
                    createdTime);
            }

            await this.fanoutActivitiesQueue.SendFanoutActivityMessage(
                userHandle,
                appHandle,
                commentHandle,
                ActivityType.Comment,
                userHandle,
                topicUserHandle,
                ContentType.Topic,
                topicHandle,
                createdTime);

            await this.fanoutActivitiesQueue.SendFanoutTopicActivityMessage(
                topicHandle,
                appHandle,
                commentHandle,
                ActivityType.Comment,
                userHandle,
                topicUserHandle,
                ContentType.Topic,
                topicHandle,
                createdTime);
        }
Beispiel #29
0
        static PublisherType FillForm(PdfLoadedForm form, XElement el, string year, int tableIndex = 1)
        {
            bool isPionner = false;

            PublisherType publisherType = PublisherType.Undefined;

            // Name
            (form.Fields["Name"] as PdfLoadedTextBoxField).Text = (string)el.Element("fname") + " " + (string)el.Element("lname");

            // Gender
            if ((string)el.Element("gender") == "Male")
            {
                (form.Fields["Check Box1"] as PdfLoadedCheckBoxField).Checked = true;
            }
            else
            {
                (form.Fields["Check Box2"] as PdfLoadedCheckBoxField).Checked = true;
            }

            // Outra ovelha
            (form.Fields["Check Box3"] as PdfLoadedCheckBoxField).Checked = true;

            // <svt>Elder</svt> ,  <svt>MinSvt</svt>,
            if ((string)el.Element("svt") == "Elder")
            {
                (form.Fields["Check Box5"] as PdfLoadedCheckBoxField).Checked = true;
            }

            if ((string)el.Element("svt") == "MinSvt")
            {
                (form.Fields["Check Box6"] as PdfLoadedCheckBoxField).Checked = true;
            }

            // <birdate>1961-06-14</birdate>
            (form.Fields["Date of birth"] as PdfLoadedTextBoxField).Text = (string)el.Element("birdate");

            //< bapdate > 2003 - 07 - 19 </ bapdate >
            (form.Fields["Date immersed"] as PdfLoadedTextBoxField).Text = (string)el.Element("bapdate");
            if ((string)el.Element("bapdate") == String.Empty)
            {
                publisherType = PublisherType.NonBaptized;
            }

            if (tableIndex == 1)
            {
                (form.Fields["Service Year"] as PdfLoadedTextBoxField).Text = year;
            }
            if (tableIndex == 2)
            {
                (form.Fields["Service Year_2"] as PdfLoadedTextBoxField).Text = year;
            }

            int totalPlace = 0, totalVideos = 0, totalHours = 0, totalRV = 0, totalStudies = 0, monthsWithActivity = 0;

            string yearBackup = year;

            for (int i = 1; i <= 12; i++)
            {
                if (i <= 4)
                {
                    year = GetPastYear(yearBackup);
                }
                else
                {
                    year = yearBackup;
                }

                var matches = el.Elements(GetMonth3Letters(i));
                var e       = matches.FirstOrDefault(x => x.Attribute("Year").Value.Equals(year));
                if (e != null)
                {
                    var value = (string)e.Element("Plcmts");
                    (form.Fields[$"{tableIndex}-Place_{i}"] as PdfLoadedTextBoxField).Text = value;
                    int.TryParse(value, out int v);
                    totalPlace += v;

                    value = (string)e.Element("Videos");
                    (form.Fields[$"{tableIndex}-Video_{i}"] as PdfLoadedTextBoxField).Text = value;
                    int.TryParse(value, out v);
                    totalVideos += v;

                    value = (string)e.Element("Hours");
                    (form.Fields[$"{tableIndex}-Hours_{i}"] as PdfLoadedTextBoxField).Text = value;
                    int.TryParse(value, out v);
                    totalHours += v;

                    value = (string)e.Element("R.V.s");
                    (form.Fields[$"{tableIndex}-RV_{i}"] as PdfLoadedTextBoxField).Text = value;
                    int.TryParse(value, out v);
                    totalRV += v;

                    value = (string)e.Element("BiSt.");
                    (form.Fields[$"{tableIndex}-Studies_{i}"] as PdfLoadedTextBoxField).Text = value;
                    int.TryParse(value, out v);
                    totalStudies += v;

                    value = (string)e.Element("Remark");
                    var text = (string)e.Element("Pio") == "Aux" ? $"Pioneir{(IsMale(el) ? "o" : "a")} Auxiliar. {value}" : value;
                    if (tableIndex == 1)
                    {
                        (form.Fields[$"Remarks{GetMonth(i)}"] as PdfLoadedTextBoxField).Text = text;
                    }
                    else
                    {
                        (form.Fields[$"Remarks{GetMonth(i)}_2"] as PdfLoadedTextBoxField).Text = text;
                    }

                    isPionner = (string)e.Element("Pio") == "Reg";
                    (form.Fields["Check Box7"] as PdfLoadedCheckBoxField).Checked = isPionner;
                    if (isPionner)
                    {
                        publisherType = PublisherType.RegularPioneer;
                    }

                    if (!(form.Fields[$"{tableIndex}-Hours_{i}"] as PdfLoadedTextBoxField).Text.Equals(""))
                    {
                        monthsWithActivity++;
                    }
                }
            }

            (form.Fields[$"{tableIndex}-Place_Total"] as PdfLoadedTextBoxField).Text   = totalPlace.ToString();
            (form.Fields[$"{tableIndex}-Place_Average"] as PdfLoadedTextBoxField).Text = GetAvg(totalPlace, monthsWithActivity);

            (form.Fields[$"{tableIndex}-Video_Total"] as PdfLoadedTextBoxField).Text   = totalVideos.ToString();
            (form.Fields[$"{tableIndex}-Video_Average"] as PdfLoadedTextBoxField).Text = GetAvg(totalVideos, monthsWithActivity);

            (form.Fields[$"{tableIndex}-Hours_Total"] as PdfLoadedTextBoxField).Text   = totalHours.ToString();
            (form.Fields[$"{tableIndex}-Hours_Average"] as PdfLoadedTextBoxField).Text = GetAvg(totalHours, monthsWithActivity);

            (form.Fields[$"{tableIndex}-RV_Total"] as PdfLoadedTextBoxField).Text   = totalRV.ToString();
            (form.Fields[$"{tableIndex}-RV_Average"] as PdfLoadedTextBoxField).Text = GetAvg(totalRV, monthsWithActivity);

            (form.Fields[$"{tableIndex}-Studies_Total"] as PdfLoadedTextBoxField).Text   = totalStudies.ToString();
            (form.Fields[$"{tableIndex}-Studies_Average"] as PdfLoadedTextBoxField).Text = GetAvg(totalStudies, monthsWithActivity);

            return(publisherType == PublisherType.Undefined ? PublisherType.Baptized : publisherType);
        }
Beispiel #30
0
 public IRabbitMqConfigurationBuilder UseRabbitMQ()
 {
     _selectedPublisher = PublisherType.RabbitMQ;
     return(this);
 }
Beispiel #31
0
        /// <summary>
        /// Add some external instance factory that will be used to create algos of a given type - this is used to allow
        /// plugins and other external assemblies register their oen algos
        /// </summary>
        /// <param name="algoType"></param>
        /// <param name="factory"></param>
        public void AddInstanceFactory(PublisherType publisherType, K2InstanceFactory factory)
        {
            switch (publisherType)
            {
                case PublisherType.General:
                    m_PublisherFactories.Add(factory);
                    break;
                case PublisherType.Price:
                    m_PublisherFactories.Add(factory);
                    break;

                default:
                    m_PublisherFactories.Add(factory);
                    break;
            }
        }
 public PublisherAndSubscriber(PublisherType _type)
 {
     this.type = _type;
 }
Beispiel #33
0
 public IEventRepositoryBuild UseCustom(IEventPublisher publisher)
 {
     _selectedPublisher = PublisherType.Custom;
     _customPublisher   = publisher;
     return(this);
 }
 public Message(PublisherType _type, string _message)
 {
     this.type    = _type;
     this.message = _message;
 }