private async void PreviewButton_Click(object sender, RoutedEventArgs e) { ItemGridView.Visibility = Visibility.Collapsed; PreviewLastPostWebView.Visibility = Visibility.Visible; _forumReply.MapMessage(ReplyText.Text); var replyManager = new ReplyManager(); string result = await replyManager.CreatePreviewEditPost(_forumReply); if (!string.IsNullOrEmpty(result)) { PreviewLastPostWebView.NavigateToString(result); PreviewLastPostWebView.Visibility = Visibility.Visible; } else { LoadingProgressBar.Visibility = Visibility.Collapsed; string messageText = string.Format( "No text?! What good is showing you a preview then! Type something in and try again!{0}{1}", Environment.NewLine, Constants.ASCII_2); var msgDlg = new MessageDialog(messageText); await msgDlg.ShowAsync(); } }
public async override void Execute(object parameter) { var args = parameter as RoutedEventArgs; if (args == null) { await AwfulDebugger.SendMessageDialogAsync("Thread navigation failed!:(", new Exception("Arguments are null")); return; } var appButton = args.OriginalSource as AppBarButton; var vm = appButton?.DataContext as ThreadPageViewModel; if (vm == null) return; Locator.ViewModels.NewThreadReplyVm.PostBody = string.Empty; Locator.ViewModels.NewThreadReplyVm.ForumThreadEntity = vm.ForumThreadEntity; App.RootFrame.Navigate(typeof(NewThreadReplyPage)); Locator.ViewModels.NewThreadReplyVm.IsLoading = true; try { var replyManager = new ReplyManager(); Locator.ViewModels.NewThreadReplyVm.ForumReplyEntity = await replyManager.GetReplyCookies(Locator.ViewModels.NewThreadReplyVm.ForumThreadEntity); } catch (Exception ex) { AwfulDebugger.SendMessageDialogAsync("Can't reply in this thread.", ex); App.RootFrame.GoBack(); } Locator.ViewModels.NewThreadReplyVm.IsLoading = false; }
public async Task CreateReplyPreview(ForumReplyEntity forumReplyEntity, bool isEdit) { IsLoading = true; var replyManager = new ReplyManager(); string result; if (isEdit) { result = await replyManager.CreatePreviewEditPost(forumReplyEntity); } else { result = await replyManager.CreatePreviewPost(forumReplyEntity); } try { if (!string.IsNullOrEmpty(result)) { Html = result; } else { string messageText = string.Format( "No text?! What good is showing you a preview then! Type something in and try again!{0}{1}", Environment.NewLine, Constants.Ascii2); var msgDlg = new MessageDialog(messageText); await msgDlg.ShowAsync(); } } catch (Exception ex) { AwfulDebugger.SendMessageDialogAsync("Failed to get the preview html", ex); } IsLoading = false; }
public async Task <bool> Initialize(string jsonObjectString) { IsLoading = true; long threadId = 0; var replyManager = new ReplyManager(); try { _forumThread = JsonConvert.DeserializeObject <ForumThreadEntity>(jsonObjectString); } catch (Exception) { threadId = Convert.ToInt64(jsonObjectString); } try { if (_forumThread != null) { ForumReplyEntity = await replyManager.GetReplyCookies(_forumThread); } else { ForumReplyEntity = await replyManager.GetReplyCookies(threadId); } } catch (Exception ex) { ForumReplyEntity = null; } IsLoading = false; return(ForumReplyEntity != null); }
public async override void Execute(object parameter) { long id = long.Parse((string)parameter); var vm = Locator.ViewModels.ThreadPageVm; if (vm == null) return; Locator.ViewModels.NewThreadReplyVm.PostBody = string.Empty; Locator.ViewModels.NewThreadReplyVm.IsEdit = true; Locator.ViewModels.NewThreadReplyVm.ForumThreadEntity = vm.ForumThreadEntity; App.RootFrame.Navigate(typeof(EditPostPage)); Locator.ViewModels.NewThreadReplyVm.IsLoading = true; try { var replyManager = new ReplyManager(); Locator.ViewModels.NewThreadReplyVm.ForumReplyEntity = await replyManager.GetReplyCookiesForEdit(id); Locator.ViewModels.NewThreadReplyVm.PostBody = Locator.ViewModels.NewThreadReplyVm.ForumReplyEntity.Quote; } catch (Exception ex) { AwfulDebugger.SendMessageDialogAsync("Can't reply in this thread.", ex); App.RootFrame.GoBack(); } Locator.ViewModels.NewThreadReplyVm.IsLoading = false; }
public void GetVersionMsgTest() { var ns = new MockNodeStatus(); var cs = new MockClientSettings() { _protoVer = 123, _services = NodeServiceFlags.All, _time = 456, _port = 789, _ua = "foo", _relay = true, _netType = NetworkType.TestNet }; var bc = new MockBlockchain() { _height = 12345 }; var rep = new ReplyManager(ns, bc, cs) { rng = new MockNonceRng(0x0158a8e8ba5f3ed3) }; Message msg = rep.GetVersionMsg(); FastStream actual = new FastStream(); msg.Serialize(actual); byte[] expected = Helper.HexToBytes("0b11090776657273696f6e0000000000590000000ba371327b0000001f04000000000000c8010000000000001f0400000000000000000000000000000000ffff7f00000103151f0400000000000000000000000000000000ffff7f0000010315d33e5fbae8a8580103666f6f3930000001"); Assert.Equal(expected, actual.ToByteArray()); }
protected void Page_Load(object sender, EventArgs e) { try { RequestInfoFromLine info = new RequestInfoFromLine(Request); if (!CheckSignature(info)) { //不正リクエストなので、即return Response.StatusCode = 200; return; } //postbackイベントの場合 if (info.EventType == CommonSettings.EventType.POSTBACK && info.Message == "ok") { SendLeaveRequest(info); return; } ReplyManager manager = ReplyManagerFactory.Create(info.EventType); byte[] replyBodyBytes = manager.CreateReplyBodyBytes(info); SendReply(replyBodyBytes); System.Diagnostics.Trace.WriteLine("Entry: " + info.FromId); }catch (Exception ex) { } }
protected void BntReply_Click(object sender, EventArgs e) { Model.Reply reply = new Model.Reply(); BLL.ReplyManager replyManager = new ReplyManager(); Model.Reply reply1 = new Model.Reply(); BLL.ReplyManager replyManager1 = new ReplyManager(); string str = "replyID='" + Labeltest.Text + "'"; string id = replyManager1.GetUserID(str); string str1 = "replyID='" + Labeltest.Text + "'"; string replyFB = replyManager1.GetFBID(str); BLL.AdminManager adminManager1 = new BLL.AdminManager(); Model.Admin admin1 = adminManager1.GetModel1(Session["SadminID"].ToString()); int s = Convert.ToInt32(admin1.adminID); reply.feedbackID = Convert.ToInt32(replyFB); reply.text = txtReply.Text; reply.replierID = s; reply.receiverID = Convert.ToInt32(id); bool bo = replyManager.Add(reply); if (bo == true) { Response.Write("<script language=javascript>alert('回复成功!')</script>"); } else { Response.Write("<script language=javascript>alert('回复失败!请重试')"); } }
protected void BntReply_Click(object sender, EventArgs e) { Model.Reply reply = new Model.Reply(); BLL.ReplyManager replyManager = new ReplyManager(); BLL.AdminManager adminManager1 = new BLL.AdminManager(); Model.Admin admin1 = adminManager1.GetModel1(Session["SadminID"].ToString()); int s = Convert.ToInt32(admin1.adminID); reply.feedbackID = Convert.ToInt32(Labeltest.Text); reply.text = txtReply.Text; reply.replierID = s; reply.remark = "1"; reply.receiverID = Convert.ToInt32(LabelName.Text.Trim()); bool bo = replyManager.Add(reply); if (bo == true) { Response.Write("<script language=javascript>alert('回复成功!')</script>"); txtReply.Text = ""; } else { Response.Write("<script language=javascript>alert('回复失败!请重试')"); } }
public void GetReplyTest(MockNodeStatus ns, IClientSettings cs, IBlockchain bc, Message msg, Message[] expected) { var rep = new ReplyManager(ns, bc, cs); Message[] actual = rep.GetReply(msg); if (expected is null) { Assert.Null(actual); } else { Assert.NotNull(actual); Assert.Equal(expected.Length, actual.Length); for (int i = 0; i < expected.Length; i++) { var actualStream = new FastStream(Constants.MessageHeaderSize + actual[i].PayloadData.Length); var expectedStream = new FastStream(Constants.MessageHeaderSize + expected[i].PayloadData.Length); actual[i].Serialize(actualStream); expected[i].Serialize(expectedStream); Assert.Equal(expectedStream.ToByteArray(), actualStream.ToByteArray()); } } // Mock will change the following bools to false if it were called. Assert.False(ns.updateTime, "UpdateTime() was never called"); Assert.False(ns.smallViolation, "AddSmallViolation() was never called"); Assert.False(ns.mediumViolation, "AddMediumViolation() was never called"); Assert.False(ns.bigViolation, "AddBigViolation() was never called"); }
public void CheckVersionTest(MockNodeStatus ns, IClientSettings cs, IBlockchain bc, Message msg, Message[] expected) { var rep = new ReplyManager(ns, bc, cs) { rng = new MockNonceRng(0x0158a8e8ba5f3ed3) }; Message[] actual = rep.GetReply(msg); if (expected is null) { Assert.Null(actual); } else { Assert.NotNull(actual); Assert.Equal(expected.Length, actual.Length); for (int i = 0; i < expected.Length; i++) { var actualStream = new FastStream(Constants.MessageHeaderSize + actual[i].PayloadData.Length); var expectedStream = new FastStream(Constants.MessageHeaderSize + expected[i].PayloadData.Length); actual[i].Serialize(actualStream); expected[i].Serialize(expectedStream); Assert.Equal(expectedStream.ToByteArray(), actualStream.ToByteArray()); } } // Mock will change the following bool to false if it were called. Assert.False(ns.updateTime, "UpdateTime() was never called"); // Mock either doesn't have any h.s. to set or if it did set h.s. it was checked and then turned to null Assert.Null(ns._handShakeToSet); }
public async override void Execute(object parameter) { long id = long.Parse((string)parameter); var vm = Locator.ViewModels.ThreadPageVm; if (vm == null) { return; } Locator.ViewModels.NewThreadReplyVm.ForumThreadEntity = vm.ForumThreadEntity; App.RootFrame.Navigate(typeof(NewThreadReplyPage)); Locator.ViewModels.NewThreadReplyVm.IsLoading = true; try { var replyManager = new ReplyManager(); Locator.ViewModels.NewThreadReplyVm.ForumReplyEntity = await replyManager.GetReplyCookies(id); Locator.ViewModels.NewThreadReplyVm.PostBody = Locator.ViewModels.NewThreadReplyVm.ForumReplyEntity.Quote; } catch (Exception ex) { AwfulDebugger.SendMessageDialogAsync("Can't reply in this thread.", ex); App.RootFrame.GoBack(); } Locator.ViewModels.NewThreadReplyVm.IsLoading = false; }
public async Task Init(ThreadReply parameter) { if (WebManager == null) { LoginUser(); } _replyManager = new ReplyManager(WebManager); Selected = parameter; if (Selected.IsEdit) { Title = "Edit - " + Selected.Thread.Name; _forumReply = await _replyManager.GetReplyCookiesForEditAsync(Selected.QuoteId); ReplyBox.Text = _forumReply.Quote; } else if (Selected.QuoteId > 0) { Title = "Quote - " + Selected.Thread.Name; _forumReply = await _replyManager.GetReplyCookiesAsync(0, Selected.QuoteId); ReplyBox.Text = _forumReply.Quote; } else { Title = "Reply - " + Selected.Thread.Name; _forumReply = await _replyManager.GetReplyCookiesAsync(Selected.Thread.ThreadId); } }
public static string UpdateReply(int repId, string reply) { Replys rply = new Replys(); rply.Id = repId; rply.Reply = reply; return(ReplyManager.IsReplyUpdated(rply)); }
private async void ThreadWebView_ScriptNotify(object sender, NotifyEventArgs e) { string stringJson = e.Value; var command = JsonConvert.DeserializeObject <ThreadCommand>(stringJson); var replyManager = new ReplyManager(); switch (command.Command) { case "quote": LoadingProgressBar.Visibility = Visibility.Visible; string quoteString = await replyManager.GetQuoteString(Convert.ToInt64(command.Id)); quoteString = string.Concat(Environment.NewLine, quoteString); string replyText = string.IsNullOrEmpty(ReplyTextBox.Text) ? string.Empty : ReplyTextBox.Text; if (replyText != null) { ReplyTextBox.Text = replyText.Insert(ReplyTextBox.Text.Length, quoteString); } LoadingProgressBar.Visibility = Visibility.Collapsed; break; case "edit": //Frame.Navigate(typeof(EditReplyPage), command.Id); break; case "openThread": // Because we are coming from an existing thread, rather than the thread lists, we need to get the thread information beforehand. // However, right now the managers are not set up to support this. The thread is getting downloaded twice, when it really only needs to happen once. var threadManager = new ThreadManager(); var thread = await threadManager.GetThread(new ForumThreadEntity(), command.Id); if (thread == null) { var error = new MessageDialog("Specified post was not found in the live forums.") { DefaultCommandIndex = 1 }; await error.ShowAsync(); break; } string jsonObjectString = JsonConvert.SerializeObject(thread); Frame.Navigate(typeof(ThreadPage), jsonObjectString); break; case "setFont": break; default: var msgDlg = new MessageDialog("Not working yet!") { DefaultCommandIndex = 1 }; await msgDlg.ShowAsync(); break; } }
public static string InsertReply(string rply, int aId, int uId) { Replys reply = new Replys(); reply.Reply = rply; reply.AnswerID = aId; reply.UserId = uId; return(ReplyManager.IsReplyInserted(reply)); }
public async void LoadPreviousPosts(Thread thread, List <Post> posts) { if (WebManager == null) { LoginUser(); } _replyManager = new ReplyManager(WebManager); await Web.InvokeScriptAsync("FromCSharp", ForumCommandCreator.CreateForumCommand("addPosts", new Thread() { IsLoggedIn = true, Posts = posts })); }
public void CheckVerackTest(MockNodeStatus ns) { var rep = new ReplyManager(ns, new MockBlockchain(), new MockClientSettings()); var msg = new Message(new VerackPayload(), NetworkType.MainNet); Message[] actual = rep.GetReply(msg); Assert.Null(actual); // Mock will change the following bool to false if it were called. Assert.False(ns.updateTime, "UpdateTime() was never called"); // Mock either doesn't have any h.s. to set or if it did set h.s. it was checked and then turned to null Assert.Null(ns._handShakeToSet); }
protected void ReplyNumber() { Model.Reply reply1 = new Model.Reply(); BLL.ReplyManager replyManager1 = new ReplyManager(); BLL.AdminManager adminManager = new BLL.AdminManager(); Model.Admin admin = adminManager.GetModel1(Session["SadminID"].ToString()); int s = Convert.ToInt32(admin.adminID); string str = "0"; int id = s; replyManager1.UpdateState(str, s); LabelApply.Text = "0"; LabelApply.Visible = false; }
public void GetReply_IgnoredMessagesTest(Message msg) { var ns = new MockNodeStatus() { _handShakeToReturn = HandShakeState.Finished, updateTime = true }; var rep = new ReplyManager(ns, new MockBlockchain(), new MockClientSettings()); var actual = rep.GetReply(msg); Assert.Null(actual); Assert.False(ns.updateTime); }
protected void ReplyNumber() { Model.Reply reply1 = new Model.Reply(); BLL.ReplyManager replyManager1 = new ReplyManager(); BLL.UsersManager usersM = new UsersManager(); Model.Users users = usersM.GetModel1(Session["userID"].ToString()); int s = Convert.ToInt32(users.UserID); string str = "0"; int id = s; replyManager1.UpdateState(str, s); LabelMessage.Text = "0"; LabelMessage.Visible = false; }
public static ReplyRetrive[] GetReplys(int id) { List <ReplyRetrive> replys = new List <ReplyRetrive>(); foreach (DataRow dtr in ReplyManager.RetriveReplys(id).Rows) { ReplyRetrive reply = new ReplyRetrive(); reply.Id = int.Parse(dtr["Id"].ToString()); reply.Reply = dtr["Reply"].ToString(); reply.DateTime = dtr["DateTime"].ToString(); reply.UserName = dtr["Name"].ToString(); replys.Add(reply); } return(replys.ToArray()); }
public void GetReply_NoHandShakeTest() { var msg = new Message(new GetAddrPayload(), NetworkType.MainNet); var ns = new MockNodeStatus() { _handShakeToReturn = HandShakeState.None, mediumViolation = true, updateTime = true }; var rep = new ReplyManager(ns, new MockBlockchain(), new MockClientSettings()); var actual = rep.GetReply(msg); Assert.Null(actual); Assert.False(ns.updateTime); }
public void GetReply_UndefinedPayloadTest() { var pl = new MockSerializableMessagePayload((PayloadType)10000, new byte[] { 1, 2, 3 }); var msg = new Message(pl, NetworkType.MainNet); var ns = new MockNodeStatus() { _handShakeToReturn = HandShakeState.Finished, smallViolation = true, updateTime = true }; var rep = new ReplyManager(ns, new MockBlockchain(), new MockClientSettings()); var actual = rep.GetReply(msg); Assert.Null(actual); Assert.False(ns.updateTime); }
public void GetReply_FailToDeserializeTest(PayloadType plt) { var msg = new Message(new MockSerializableMessagePayload(plt, new byte[] { 255, 255, 255 }), NetworkType.MainNet); var ns = new MockNodeStatus() { _handShakeToReturn = HandShakeState.Finished, smallViolation = true, updateTime = true }; var rep = new ReplyManager(ns, new MockBlockchain(), new ClientSettings()); Message[] actual = rep.GetReply(msg); Assert.Null(actual); Assert.False(ns.updateTime); Assert.False(ns.smallViolation); }
protected void ReplyNumber() { Model.Reply reply = new Model.Reply(); BLL.ReplyManager replyManager = new ReplyManager(); BLL.AdminManager adminManager1 = new BLL.AdminManager(); Model.Admin admin1 = adminManager1.GetModel1(Session["SadminID"].ToString()); int s = Convert.ToInt32(admin1.adminID); string str = "remark='" + "1" + "'and receiverID='" + s + "'"; int number = replyManager.GetRecordCount(str); if (number > 0) { LabelMessage.Visible = true; LabelMessage.Text = Convert.ToString(number); } }
public async Task <bool> InitializeEdit(string jsonObjectString) { IsLoading = true; long threadId = Convert.ToInt64(jsonObjectString);; try { var replyManager = new ReplyManager(); ForumReplyEntity = await replyManager.GetReplyCookiesForEdit(threadId); } catch (Exception ex) { AwfulDebugger.SendMessageDialogAsync("You can't edit this post!", ex); } IsLoading = false; return(ForumReplyEntity != null); }
protected void ReplyNumber() { Model.Reply reply = new Model.Reply(); BLL.ReplyManager replyManager = new ReplyManager(); BLL.UsersManager usersM = new UsersManager(); Model.Users users = usersM.GetModel1(Session["userID"].ToString()); int s = Convert.ToInt32(users.UserID); string str = "remark='" + "1" + "'and receiverID='" + s + "'"; int number = replyManager.GetRecordCount(str); if (number > 0) { LabelMessage.Visible = true; LabelMessage.Text = Convert.ToString(number); } }
private async void PostButton_OnClick(object sender, RoutedEventArgs e) { LoadingProgressBar.Visibility = Visibility.Visible; _vm.ForumReplyEntity.MapMessage(ReplyTextBox.Text); var replyManager = new ReplyManager(); bool result = await replyManager.SendPost(_vm.ForumReplyEntity); if (result) { Frame.GoBack(); } else { LoadingProgressBar.Visibility = Visibility.Collapsed; var msgDlg = new MessageDialog("Error making reply!"); await msgDlg.ShowAsync(); } }
public async Task <bool> GetPreviewEditPost(string replyText) { Html = string.Empty; IsLoading = true; ForumReplyEntity.MapMessage(replyText); var replyManager = new ReplyManager(); try { Html = await replyManager.CreatePreviewEditPost(ForumReplyEntity); } catch (Exception ex) { AwfulDebugger.SendMessageDialogAsync("Could not create preview HTML", ex); } IsLoading = false; return(!string.IsNullOrEmpty(Html)); }
public async override void Execute(object parameter) { var replyManager = new ReplyManager(); var vm = Locator.ViewModels.NewThreadReplyVm; vm.ForumReplyEntity.Message = vm.PostBody; vm.IsLoading = true; bool result = await replyManager.SendPost(vm.ForumReplyEntity); if (result) { Locator.ViewModels.ThreadPageVm.RefreshThreadPageCommand.Execute(string.Empty); App.RootFrame.GoBack(); } else { vm.IsLoading = false; var msgDlg = new MessageDialog("Error making reply!"); await msgDlg.ShowAsync(); } vm.IsLoading = false; }
public void Dispose() { #region Hossam SkillManager.Dispose(); CourseManager.Dispose(); EmploymentTypeManager.Dispose(); UserPhotoManager.Dispose(); UserConnectionManager.Dispose(); #endregion #region Nora UserProjectManager.Dispose(); LanguageManager.Dispose(); UserLanguageManager.Dispose(); EducationManager.Dispose(); #endregion #region Wafaa ExperienceManager.Dispose(); CountryManager.Dispose(); CompanyManager.Dispose(); JobManager.Dispose(); CertificationManager.Dispose(); #endregion #region Aya PostManager.Dispose(); CommentManager.Dispose(); ReplyManager.Dispose(); PostPhotoManager.Dispose(); CommentPhotoManager.Dispose(); ReplyPhotoManager.Dispose(); #endregion ApplicationUserManager.Dispose(); ApplicationRoleManager.Dispose(); ApplicationSignInManager.Dispose(); context = null; }