public async Task <IHttpActionResult> PutDiscussion(int id, Discussions discussion) { var oldDiscussion = db.Discussions.Find(discussion.Id); if (discussion == null) { return(BadRequest()); } oldDiscussion.Name = discussion.Name; oldDiscussion.Category = await db.Categories.FindAsync(discussion.Category_Id); try { await db.SaveChangesAsync(); } catch (Exception ex) { if (!DiscussionsExists(discussion.Id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.OK)); }
/// <summary> /// Get the QQ discussion group list /// </summary> /// <param name="isDiscussionGroupAccountDetailedInfo"></param> /// <returns></returns> public List <DiscussionAccount> GetDiscussionGroupList(bool isDiscussionGroupAccountDetailedInfo = true) { string url = "http://s.web2.qq.com/api/get_discus_list?clientid=53999199&psessionid=#{psessionid}&vfwebqq=#{vfwebqq}&t=#{t}".Replace("#{psessionid}", smartQQ.PSessionId).Replace("#{vfwebqq}", smartQQ.VFWebQQ).Replace("#{t}", HTTP.AID_TimeStamp()); string dat = HTTP.Get(url, "http://d1.web2.qq.com/proxy.html?v=20151105001&callback=1&id=2"); Discussions disscuss = (Discussions)JsonConvert.DeserializeObject(dat, typeof(Discussions)); smartQQ.DiscussionAccounts = new List <DiscussionAccount>(); if (disscuss.result != null) { foreach (var discussion in disscuss.result.dnamelist) { DiscussionAccount discussionAccount = new DiscussionAccount(); discussionAccount.Did = discussion.did; discussionAccount.Name = discussion.name; smartQQ.DiscussionAccounts.Add(discussionAccount); } } if (isDiscussionGroupAccountDetailedInfo) { foreach (var discussion in smartQQ.DiscussionAccounts) { LoadDiscussionAccountDetailedInfo(discussion); } } return(smartQQ.DiscussionAccounts); }
private Discussions ProcessDiscussionsWithNameAsync(Discussions discussion) { string userName = Application.Current.Properties["Username"].ToString(); int residentId = (from resident in residents where resident.Username.ToLower() == userName.ToLower() select resident.ResidentID).FirstOrDefault(); discussion.ResID = residentId; return(discussion); }
public async Task <IHttpActionResult> PostDiscussions(Discussions discussion) { discussion.Category = db.Categories.Find(discussion.Category_Id); db.Discussions.Add(discussion); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = discussion.Id }, discussion)); }
public async Task <IHttpActionResult> GetDiscussion(int id) { Discussions discussions = await db.Discussions.FindAsync(id); if (discussions == null) { return(NotFound()); } return(Ok(discussions)); }
//Post discussions public async void postNewDiscussionsAsync(Discussions discussions) { HttpResponseMessage response1 = await client.PostAsJsonAsync("discussions", discussions); if (!response1.IsSuccessStatusCode) { ////Setting the data to the model //return discussionsDB = await response.Content.ReadAsAsync<List<discussions>>(); Console.WriteLine("Internal server Error"); } }
public IActionResult PostComment([FromBody, Bind("Username, Comment, ComDate")] Discussions dis) { _dis.AddDiscussion(dis); var getCom = _dis.GetDiscussion().FirstOrDefault(e => e.CommentId == dis.CommentId); if (getCom != null) { return(CreatedAtAction("GetCom", new { Id = getCom.CommentId }, dis)); } else { return(NotFound()); } }
private async Task loadDiscussions() { Discussions.Clear(); var payload = new DiscussionPayload(CurrentTag.Name, "10"); payload.Type = category; var result = await repository.LoadDiscussions(payload); if (result.StatusCode == System.Net.HttpStatusCode.OK) { foreach (var discussion in result.Data) { Discussions.Add(discussion); } } }
/// <summary> /// This event will be raised on click of discussion hyperlink /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void hlDiscussionSubject_Click(object sender, RoutedEventArgs e) { HyperlinkButton hlSubject = sender as HyperlinkButton; string subject = hlSubject.Content.ToString(); string disId = hlSubject.Tag.ToString(); //Retrieve discussionId and subject int discussionId = Convert.ToInt32(disId); Discussions objDiscussion = new Discussions(); objDiscussion.DiscussionId = discussionId; objDiscussion.Subject = subject; var discussion = App.Current as App; discussion.Discussion = objDiscussion; NavigationService.Navigate(new Uri("/Discussion.xaml", UriKind.Relative)); }
/// <summary> /// Method to retrieve discussions by discussionId /// </summary> /// <param name="cookie"></param> /// <param name="discussionId"></param> public async Task <Discussions> RetrieveDiscussionsByDiscussionId(string cookie, int discussionId) { try { using (HttpClient retrieveDiscussionClient = new HttpClient()) { retrieveDiscussionClient.DefaultRequestHeaders.Add("Authorization", "Token token=" + Constant.BACKPACKAPIKEY + ""); retrieveDiscussionClient.DefaultRequestHeaders.Add("Cookie", cookie); string responseDiscussion = await retrieveDiscussionClient.GetStringAsync(new Uri(Constant.BASEURL + Constant.RETRIEVEDISCUSSIONS + discussionId, UriKind.Absolute)); Discussions userDetails = JsonConvert.DeserializeObject <Discussions>(responseDiscussion); return(userDetails); } } catch (Exception) { throw; } }
public void receiveDiscussions(List <jsonValues.discussions> discussions, int forumcmid) { Forum f = getForum(forumcmid); Discussions template; foreach (jsonValues.discussions d in discussions) { template = new Discussions(); template.id = d.discussion; template.created = d.created; template.message = HtmlDecode(d.message); template.modified = d.modified; template.name = d.name; template.subject = HtmlDecode(d.subject); template.timemodified = d.timemodified; template.userfullname = d.userfullname; template.userid = d.userid; template.usermodifiedfullname = d.usermodifiedfullname; template.posts = new List <Posts>(); f.discussions.Add(template); } }
public void receivePosts(List <jsonValues.posts> posts, int forumid, int discID) { Discussions d = GetDiscussions(forumid, discID); if (d != null) { Posts template; foreach (jsonValues.posts p in posts) { template = new Posts(); template.created = p.created; template.discussion = p.discussion; template.id = p.id; template.message = HtmlDecode(p.message); template.modified = p.modified; template.parent = p.parent; template.subject = p.subject; template.userid = p.userid; d.posts.Add(template); } } }
private async void NewMessageHandler(NewMessageNotification obj) { var message = new Message(obj); if (message.Attachments != null && message.Attachments.Length != 0 && message.Attachments[0].IsImage) { await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { message.Attachments[0].ImagePreview = await message.Attachments[0].Base64ToBitmapImage(message.Attachments[0].ImagePreviewString); message.Attachments[0].ImagePreview = await rocketChatRest.GetImage(message.Attachments[0].ImageUrl); }); } message.User = Users.FirstOrDefault(x => x.Id == message.User.Id); if (SelectedChannel != null && SelectedChannel.Id == obj.fields.args[0].rid) { await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { Messages.Add(message); }); } else { await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { if (Channels.Any(x => x.Id == message.RoomId)) { Channels.FirstOrDefault(x => x.Id == message.RoomId).HasUnreadedMessages = true; Channels.FirstOrDefault(x => x.Id == message.RoomId).ChannelFontWeight = FontWeights.Bold; if (message.Attachments != null && message.Attachments[0].IsImage) { notificationService.ShowNewMessageToastNotification(message, Channels.FirstOrDefault(x => x.Id == message.RoomId), true); } else { notificationService.ShowNewMessageToastNotification(message, Channels.FirstOrDefault(x => x.Id == message.RoomId)); } } if (Discussions.Any(x => x.Id == message.RoomId)) { Discussions.FirstOrDefault(x => x.Id == message.RoomId).HasUnreadedMessages = true; Discussions.FirstOrDefault(x => x.Id == message.RoomId).ChannelFontWeight = FontWeights.Bold; if (obj.fields.args[0].t == null || obj.fields.args[0].t != "discussion-created") { if (message.Attachments != null && message.Attachments[0].IsImage) { notificationService.ShowNewMessageToastNotification(message, Discussions.FirstOrDefault(x => x.Id == message.RoomId), true); } else { notificationService.ShowNewMessageToastNotification(message, Discussions.FirstOrDefault(x => x.Id == message.RoomId)); } } } if (DirectConversations.Any(x => x.Id == message.RoomId)) { DirectConversations.FirstOrDefault(x => x.Id == message.RoomId).HasUnreadedMessages = true; DirectConversations.FirstOrDefault(x => x.Id == message.RoomId).ChannelFontWeight = FontWeights.Bold; if (message.Attachments != null && message.Attachments[0].IsImage) { notificationService.ShowNewMessageToastNotification(message, DirectConversations.FirstOrDefault(x => x.Id == message.RoomId), true); } else { notificationService.ShowNewMessageToastNotification(message, DirectConversations.FirstOrDefault(x => x.Id == message.RoomId)); } } if (PrivateGroups.Any(x => x.Id == message.RoomId)) { PrivateGroups.FirstOrDefault(x => x.Id == message.RoomId).HasUnreadedMessages = true; PrivateGroups.FirstOrDefault(x => x.Id == message.RoomId).ChannelFontWeight = FontWeights.Bold; } }); } }
public DiscussionDashboard(UISharedRTClient sharedClient, StatusWnd stWnd, Discussions.Main.OnDiscFrmClosing closing) { this._discussion = SessionInfo.Get().discussion; _sharedClient = sharedClient; _closing = closing; _stWnd = stWnd; InitializeComponent(); userCursor = new UserCursor(SessionInfo.Get().person.Name, CursorInputState.None); userCursor.usrId = SessionInfo.Get().person.Id; SetListeners(sharedClient, true); if(sharedClient.clienRt.IsConnected()) OnJoin(); ToLayerModeNoLayer(); }
public async void Discussion_Loaded(object sender, RoutedEventArgs e) { //Progress Indicator SystemTray.ProgressIndicator = new ProgressIndicator(); ProgressIndicator(true); SystemTray.ProgressIndicator.Text = "Loading...Please wait"; var discussion = App.Current as App; userId = discussion.User.UserId; cookie = discussion.Cookie; discussionId = discussion.Discussion.DiscussionId; subject = discussion.Discussion.Subject; txtSubect.Text = objParser.ParseHTMLContent(WebUtility.HtmlDecode(subject)); txtSubect.TextWrapping = TextWrapping.Wrap; objDiscussion = await RetrieveDiscussions(cookie, discussionId); //discussion value string discuss = objParser.ParseHTMLContent(WebUtility.HtmlDecode(objDiscussion.Body)); txtDiscussion.Text = discuss; txtDiscussion.TextWrapping = TextWrapping.Wrap; StackPanel spComments = new StackPanel(); for (int i = 0; i < objDiscussion.Replies.Count; i++) { //Generate rectangle 1st, then add 2 textbolck--one for Name,one for comments text and then add that rectangle to stackpanel //Creating border for each reply and attaching it to main spReply StackPanel Border breachReply = new Border(); breachReply.Name = "breachReply" + i; breachReply.BorderThickness = new Thickness(2, 2, 2, 2); breachReply.CornerRadius = new CornerRadius(5); breachReply.BorderBrush = new SolidColorBrush(Colors.White); breachReply.Margin = new Thickness(0, 15, 0, 0); //parent of reply border spReply.Children.Add(breachReply); //stack panel to hold a reply and all the comments and add it to border(parent) StackPanel spCommentAndReply = new StackPanel(); breachReply.Child = spCommentAndReply; StackPanel speachReply = new StackPanel(); //Adding textbox for reply TextBlock tbName = new TextBlock(); //tbName.Text = "Kumar" + i; string repliesName = objParser.ParseHTMLContent(WebUtility.HtmlDecode(objDiscussion.Replies[i].UserName)); tbName.Text = repliesName; tbName.TextWrapping = TextWrapping.Wrap; speachReply.Children.Add(tbName); TextBlock tbRply = new TextBlock(); //tbRply.Text = "Reply" + i; string repliesBody = objParser.ParseHTMLContent(WebUtility.HtmlDecode(objDiscussion.Replies[i].Body)); tbRply.Text = repliesBody; tbReply.TextWrapping = TextWrapping.Wrap; speachReply.Children.Add(tbRply); //added reply to spCommentReply stack panel spCommentAndReply.Children.Add(speachReply); //Adding textbox for comments for each reply for (int j = 0; j < objDiscussion.Replies[i].Comments.Count; j++) { //Boder for comments Border brComments = new Border(); brComments.BorderThickness = new Thickness(2, 2, 2, 2); brComments.CornerRadius = new CornerRadius(5); brComments.BorderBrush = new SolidColorBrush(Colors.White); brComments.Margin = new Thickness(5, 10, 5, 0); StackPanel speachComments = new StackPanel(); //added border child speachcomment brComments.Child = speachComments; //Adding textblock for comments TextBlock tbNameComments = new TextBlock(); //tbNameComments.Text = "Kumar" + j; string commentsName = objParser.ParseHTMLContent(WebUtility.HtmlDecode(objDiscussion.Replies[i].Comments[j].UserName)); tbNameComments.Text = commentsName; tbNameComments.TextWrapping = TextWrapping.Wrap; TextBlock tbComment = new TextBlock(); //tbComment.Text = "Comment" + j; string commentBody = objParser.ParseHTMLContent(WebUtility.HtmlDecode(objDiscussion.Replies[i].Comments[j].comment)); tbComment.Text = commentBody; tbComment.TextWrapping = TextWrapping.Wrap; speachComments.Children.Add(tbNameComments); speachComments.Children.Add(tbComment); spCommentAndReply.Children.Add(brComments); } //stack panel for sending comments StackPanel spsendComment = new StackPanel(); spsendComment.Orientation = System.Windows.Controls.Orientation.Horizontal; //Adding textbox at last to enter comments for each reply TextBox tbLastComment = new TextBox(); //assign id to a comment textbox tbLastComment.Name = "LastComment" + i; tbLastComment.Width = 300; tbLastComment.Text = "Enter your comments"; spsendComment.Children.Add(tbLastComment); Button btnSend = new Button(); //i will have discussion id btnSend.Click += btnSend_Click; btnSend.Tag = i; btnSend.Name = "btnComnt" + i; btnSend.Content = "Comments"; //btnSend.Width = 30; spsendComment.Children.Add(btnSend); spCommentAndReply.Children.Add(spsendComment); } //adding border for send reply Border brsendReply = new Border(); brsendReply.BorderThickness = new Thickness(2, 2, 2, 2); brsendReply.CornerRadius = new CornerRadius(5); brsendReply.BorderBrush = new SolidColorBrush(Colors.White); brsendReply.Margin = new Thickness(0, 25, 0, 0); //Adding textbox at last to enter reply..created stackpanel for placing textbox and button as c chold of spreply StackPanel spSendReply = new StackPanel(); brsendReply.Child = spSendReply; spSendReply.Orientation = System.Windows.Controls.Orientation.Vertical; //TextBox tbReply = new TextBox(); tbReply.Text = "Enter Reply"; spSendReply.Children.Add(tbReply); Button btnReply = new Button(); btnReply.Content = "Reply"; btnReply.HorizontalAlignment = HorizontalAlignment.Right; btnReply.Click += btnReply_Click; //btnReply.Width = 30; spSendReply.Children.Add(btnReply); spReply.Children.Add(brsendReply); ProgressIndicator(false); }
/// <summary> /// 发送消息。 /// </summary> /// <param name="type">目标类型。</param> /// <param name="id">用于发送的ID。</param> /// <param name="content">消息内容。</param> public async void Message(TargetType type, long id, string content) { if (Status != ClientStatus.Active) { throw new InvalidOperationException("尚未登录,无法进行该操作"); } //Logger.Debug("开始发送消息,对象类型:" + type); string paramName; ApiUrl url; switch (type) { case TargetType.Friend: paramName = "to"; url = ApiUrl.SendMessageToFriend; break; case TargetType.Group: paramName = "group_uin"; url = ApiUrl.SendMessageToGroup; break; case TargetType.Discussion: paramName = "did"; url = ApiUrl.SendMessageToDiscussion; break; default: throw new ArgumentOutOfRangeException(nameof(type), type, null); } var response = Client.PostWithRetry(url, new JObject { { paramName, id }, { "content", new JArray { StringHelper.TranslateEmoticons(content), new JArray { "font", JObject.FromObject(Font.DefaultFont) } } .ToString(Formatting.None) }, { "face", 573 }, { "clientid", ClientId }, { "msg_id", _messageId++ }, { "psessionid", Psessionid } }, RetryTimes); if (response.StatusCode != HttpStatusCode.OK) { Logger.Error("消息发送失败,HTTP返回码" + (int)response.StatusCode); } var status = JObject.Parse(await response.Content.ReadAsStringAsync())["retcode"].ToObject <int?>(); if (status != null && (status == 0 || status == 100100)) { //Logger.Debug("消息发送成功"); if (MessageEcho == null) { return; } MessageEchoEventArgs args; switch (type) { case TargetType.Friend: { args = new MessageEchoEventArgs(Friends.Find(_ => _.Id == id), content); break; } case TargetType.Group: { args = new MessageEchoEventArgs(Groups.Find(_ => _.Id == id), content); break; } case TargetType.Discussion: { args = new MessageEchoEventArgs(Discussions.Find(_ => _.Id == id), content); break; } default: throw new ArgumentOutOfRangeException(nameof(type), type, null); } MessageEcho(this, args); } else { Logger.Error("消息发送失败,API返回码" + status); } }
private async void SegmentChanged(int index) { category = (DiscussionCategory)index; Discussions.Clear(); await loadDiscussions(); }