예제 #1
0
        public bool AddReply(Reply Reply, int PostId, int CommentID, string BlogPostJsonPath)
        {
            try
            {
                var            jsonContent = File.ReadAllText(BlogPostJsonPath);
                var            blogPosts   = JsonConvert.DeserializeObject <blogPosts>(jsonContent);
                List <Comment> Comments    = blogPosts.BlogPosts.Where(obj => obj.id == PostId)?.First()?.Comments;
                var            Replies     = Comments.ElementAt(CommentID - 1).Replies;

                if (Replies == null)
                {
                    Replies = new List <Reply>();
                }
                Replies.Add(Reply);
                Comments.ElementAt(CommentID - 1).Replies = Replies;

                blogPosts.BlogPosts.Where(obj => obj.id == PostId).First().Comments = Comments;
                if (!File.Exists(BlogPostJsonPath))
                {
                    var file = System.IO.File.Create(BlogPostJsonPath);
                    file.Close();
                }
                string res = JsonConvert.SerializeObject(blogPosts);
                File.WriteAllText(BlogPostJsonPath, res);
                return(true);
            }
            catch
            {
                return(false);
            }
        }
        public Task ReplyAsync(Message message)
        {
            Replies.Add(message);
#if NET452
            return(Task.FromResult <object>(null));
#else
            return(Task.CompletedTask);
#endif
        }
예제 #3
0
파일: TweetModel.cs 프로젝트: swinghu/Ocell
        private void GetReplies()
        {
            var convService = new ConversationService(DataTransfer.CurrentAccount);

            convService.Finished += (sender, e) => IsLoading = false;
            convService.GetConversationForStatus(Tweet, (statuses, response) =>
            {
                if (statuses != null)
                {
                    var statuses_noRepeat = statuses.Cast <ITweetable>().Except(Replies).ToList();
                    foreach (var status in statuses_noRepeat)
                    {
                        Replies.Add(status);
                    }
                }
            });
        }
예제 #4
0
        public void AddReply(string comment, User user)
        {
            if (ReplyToId.HasValue)
            {
                throw SheaftException.Validation("Une réponse ne peut être ajoutée qu'à une observation.");
            }

            if (Replies == null)
            {
                Replies = new List <Observation>();
            }

            var reply = new Observation(Guid.NewGuid(), comment, user, Producer, true);

            Replies.Add(reply);

            DomainEvents.Add(new ObservationRepliedEvent(Id, reply.Id));
            Refresh();
        }
예제 #5
0
        private async Task EditPropertyAsync(string callbackQueryId, string property)
        {
            var(propertyName, text) = property switch
            {
                "recipient_full_name" => new KeyValuePair <string, string>("RecipientFullName", "Reply with recipient's full name."),
                "street_address" => new KeyValuePair <string, string>("StreetAddress", "Reply with street address."),
                "town_city" => new KeyValuePair <string, string>("TownCity", "Reply with town / city."),
                "postcode" => new KeyValuePair <string, string>("Postcode", "Reply with postcode."),
                "state_county" => new KeyValuePair <string, string>("StateCounty", "Reply with state / county."),
                "country" => new KeyValuePair <string, string>("Country", "Reply with two-letter (ISO 3166-1) country code.\nExample for France: FR"),
                "message" => new KeyValuePair <string, string>("Message", "Reply with message for the recipient."),
                "email" => new KeyValuePair <string, string>("Email", "Reply with your email address.")
            };

            // Invisible mention hack, so the selective ForceReplyMarkup only gets triggered for the mentioned user
            var message = await _bot.SendTextMessageAsync(_orderMessage.Chat, $"[ ](tg://user?id={_userId})" + text, ParseMode.Markdown, replyMarkup : new ForceReplyMarkup()
            {
                Selective = true
            });

            Replies.Add(message.MessageId, propertyName);
        }
예제 #6
0
        public Post(JToken post, int maxContentLength = -1, int maxContentLineCount = -1, bool fullInfo = true)
            : this()
        {
            DateTime timeStamp;

            if (post[70].Type != JTokenType.Undefined)
            {
                Edited    = true;
                timeStamp = Utils.ToDateTime((double)post[70] / 1000);
            }
            else
            {
                Edited    = false;
                timeStamp = Utils.ToDateTime((double)post[5]);
            }

            ID          = (string)post[8];
            AuthorPhoto = new Uri(((string)post[18]).Replace("photo.", "s64-c-k/photo."), UriKind.Absolute);
            Author      = (string)post[3];
            AuthorID    = (string)post[16];

            if (fullInfo)
            {
                TimeStamp  = timeStamp.Date == DateTime.Now.Date ? timeStamp.ToShortTimeString() : timeStamp.ToShortDateString();
                Client     = (string)post[2] == "Google+" ? "Desktop" : (string)post[2];
                ShareRange = (int)post[32] == 0 ? "Limited" : "Public";
                if (post[82][2][7][0][0].Type != JTokenType.Undefined)
                {
                    Tag = (string)post[82][2][7][0][0];
                }
            }

            if (post[44].Type != JTokenType.Undefined)
            {
                string rawContent = (string)post[47];
                HasContent          = rawContent != "";
                Content             = Utils.ProcessRawContent(rawContent, maxContentLength, maxContentLineCount);
                IsReshare           = true;
                OriginalAuthorPhoto = new Uri(((string)post[44][4]).Replace("photo.", "s48-c-k/photo."), UriKind.Absolute);
                OriginalAuthor      = (string)post[44][0];
                OriginalAuthorID    = (string)post[44][1];
                rawContent          = (string)post[4];
                HasOriginalContent  = rawContent != "";
                OriginalContent     = Utils.ProcessRawContent(rawContent, maxContentLength, maxContentLineCount);
            }
            else
            {
                string rawContent = post[47].Type == JTokenType.Undefined ? (string)post[4] : (string)post[47];
                HasContent = rawContent != "";
                Content    = Utils.ProcessRawContent(rawContent, maxContentLength, maxContentLineCount);
                IsReshare  = false;
            }

            Media = new Media(post[97]);

            if (fullInfo)
            {
                PlusOneCount = (int)post[73][16];
                if (PlusOneCount > 0 && (int)post[73][13] == 1)
                {
                    DoIPlusOne = true;
                }
                ReshareCount = ((JArray)post[25]).Count;
                CommentCount = (int)post[93];

                foreach (JToken reply in post[7])
                {
                    Replies.Add(new Comment(reply, maxContentLength, maxContentLineCount));
                }
            }
        }