public void NavigateManager(string url) { if (url.Contains("{Image}")) { } else if (url.Contains("{Url}")) { string urlResponse = url.Replace("{Url}", string.Empty); ThreadView.GetInstance().SetUpPopupWebview(urlResponse); } else if (url.Contains("{Url-Quote-")) { var Id = url.Split('=').LastOrDefault(); ThreadView.GetInstance().SetContentForPostMessage(Id); } else if (url.Contains("{Url-MultiQuote-")) { var Id = url.Split('=').LastOrDefault(); var temp = Resource.STR_2C + Id; if (appSetting.Cookies_Vbmultiquote.Contains(temp)) { appSetting.Cookies_Vbmultiquote = appSetting.Cookies_Vbmultiquote.Replace(temp, Resource.STR_EMPTY); DialogResult.DialogOnlyOk("Removed " + Id.ToString() + " from quote list!"); } else { appSetting.Cookies_Vbmultiquote += temp; DialogResult.DialogOnlyOk("Added " + Id.ToString() + " to quote list!"); } } else if (url.Contains("{Url-Quick-")) { ThreadView.GetInstance().DisplayPopupPostMessage(); } }
/// <summary> /// Moves the specified old index. /// </summary> /// <param name="oldIndex">The old index.</param> /// <param name="newIndex">The new index.</param> /// <inheritdoc/> public void Move(int oldIndex, int newIndex) { ThreadView view = this._threadView.Value; if (view.dissalowReenterancy) { throwReenterancyException(); } this._lock.EnterWriteLock(); try { this._version++; this._collection.Move(oldIndex, newIndex); } catch (Exception) { view.waitingEvents.Clear(); throw; } finally { this._lock.ExitWriteLock(); } this.dispatchWaitingEvents(view); }
/// <inheritdoc/> /// <summary> /// Adds an item to the <see cref="T:System.Collections.IList"/>. /// </summary> /// <param name="value">The object to add to the <see cref="T:System.Collections.IList"/>.</param> /// <returns> /// The position into which the new element was inserted, or -1 to indicate that the item was not inserted into /// the collection. /// </returns> int IList.Add(object value) { ThreadView view = this._threadView.Value; if (view.dissalowReenterancy) { throwReenterancyException(); } int result; this._lock.EnterWriteLock(); try { this._version++; result = ((IList)this._collection).Add(value); } catch (Exception) { view.waitingEvents.Clear(); throw; } finally { this._lock.ExitWriteLock(); } this.dispatchWaitingEvents(view); return(result); }
/// <inheritdoc/> public bool Remove(T item) { ThreadView view = this._threadView.Value; if (view.dissalowReenterancy) { throwReenterancyException(); } bool result; this._lock.EnterWriteLock(); try { this._version++; result = this._collection.Remove(item); } catch (Exception) { view.waitingEvents.Clear(); throw; } finally { this._lock.ExitWriteLock(); } this.dispatchWaitingEvents(view); return(result); }
private void BtnVote_Click(object sender, RoutedEventArgs e) { int rating = 0; if (Rdo5Star.IsChecked == true) { rating = 5; } else if (Rdo4Star.IsChecked == true) { rating = 4; } else if (Rdo3Star.IsChecked == true) { rating = 3; } else if (Rdo2Star.IsChecked == true) { rating = 2; } else if (Rdo1Star.IsChecked == true) { rating = 1; } ThreadView.GetInstance().RatingThread(rating); }
/// <summary> /// Adds the range. /// </summary> /// <param name="items">The items.</param> /// <inheritdoc/> public void AddRange(IEnumerable <T> items) { ThreadView view = this._threadView.Value; if (view.dissalowReenterancy) { throwReenterancyException(); } this._lock.EnterWriteLock(); try { this._version++; foreach (T item in items) { this._collection.Add(item); } } catch (Exception) { view.waitingEvents.Clear(); throw; } finally { this._lock.ExitWriteLock(); } this.dispatchWaitingEvents(view); }
public void ThreadViewed(int threadID, int userID) { ThreadView view = _threadViewRepository.First(item => item.UserID == userID && item.ThreadID == threadID); if (view == null) { _threadViewRepository.Add(new ThreadView() { ThreadID = threadID, UserID = userID, }); } ThreadViewStamp viewStamp = _threadViewStampRepository.First(item => item.UserID == userID && item.ThreadID == threadID); if (viewStamp == null) { _threadViewStampRepository.Add(new ThreadViewStamp() { Date = DateTime.UtcNow, UserID = userID, ThreadID = threadID }); } _unitOfWork.Commit(); }
public void Clear() { ThreadView view = _threadView.Value; if (view.dissalowReenterancy) { throwReenterancyException(); } _lock.EnterWriteLock(); try { _version++; _collection.Clear(); } catch (Exception) { view.waitingEvents.Clear(); throw; } finally { _lock.ExitWriteLock(); } dispatchWaitingEvents(view); }
public ActionResult ThreadView(int topicId, int threadId, int start = 1) { Topic topic = Topic.Find(topicId); Thread thread = Thread.Find(threadId); ThreadView threadView = new ThreadView(topic, thread, start); return(View(threadView)); }
private static ThreadView ThreadViewTypeReducer(ThreadView threadViewType, IAction action) { switch (action) { case ChangeThreadViewTypeAction a: return(a.ThreadViewType); default: return(threadViewType); } }
internal Enumerator(ThreadView owner) { _owner = owner; // Lock required since destructors run MT lock (_owner) { _owner._snapshotRefCount++; _backing = owner.GetSnapshot().GetEnumerator(); } _disposed = false; }
internal ComBuf(ThreadView parent, int slavenum, int buflen) { if (buflen <= 0 || buflen >= 1073741824) { throw new Exception("Slave memory communication buffer has invalid byte size: " + buflen.ToString()); } this.parent = parent; this.slavenum = slavenum; this.buflen = buflen; }
/// <summary> /// Adds an item if it does not already exist in the collection /// </summary> /// <param name="item">The item to be added to the <see cref="AsyncObservableCollection{T}"/></param> /// <returns>True if the item is newly added, else false</returns> /// <remarks>Added by Josh DeGraw, but using techniques from the original source code</remarks> public bool AddDistinct(T item) { ThreadView view = this._threadView.Value; if (view.dissalowReenterancy) { throwReenterancyException(); } this._lock.EnterUpgradeableReadLock(); try { bool contains = false; contains = this._collection.Contains(item); if (contains) { return(false); } this._lock.EnterWriteLock(); try { this._version++; this._collection.Add(item); } catch { view.waitingEvents.Clear(); throw; } finally { this._lock.ExitWriteLock(); } } catch (Exception ex) { Console.WriteLine(ex); return(false); } finally { this._lock.ExitUpgradeableReadLock(); } this.dispatchWaitingEvents(view); return(true); }
private void InsertView(int threadID, string username) { using (ThreadDataContext pdc = new ThreadDataContext()) { ThreadView tv = new ThreadView() { ThreadID = threadID, Username = username, DateViewed = DateTime.Now }; pdc.ThreadViews.InsertOnSubmit(tv); pdc.SubmitChanges(); } }
private void Button_Click(object sender, RoutedEventArgs e) { if (TypeInput == 1) { ThreadView.GetInstance().UpdateContentTextbox(((Button)sender).Tag.ToString()); } else if (TypeInput == 2) { MessageView.GetInstance().UpdateContentTextbox(((Button)sender).Tag.ToString()); } else if (TypeInput == 3) { ListThreadView.GetInstance().UpdateContentTextbox(((Button)sender).Tag.ToString()); } }
private void dispatchWaitingEvents(ThreadView view) { List <EventArgs> waitingEvents = view.waitingEvents; try { if (waitingEvents.Count == 0) { return; // fast path for no events } if (view.dissalowReenterancy) { // Write methods should have checked this before we got here. Since we didn't that means there's a bugg in this class // itself. However, we can't dispatch the events anyways, so we'll have to throw an exception. if (Debugger.IsAttached) { Debugger.Break(); } throwReenterancyException(); } view.dissalowReenterancy = true; foreach (EventArgs args in waitingEvents) { NotifyCollectionChangedEventArgs ccArgs = args as NotifyCollectionChangedEventArgs; if (ccArgs != null) { _collectionChanged.raise(this, ccArgs); } else { PropertyChangedEventArgs pcArgs = args as PropertyChangedEventArgs; if (pcArgs != null) { _propertyChanged.raise(this, pcArgs); } } } } finally { view.dissalowReenterancy = false; waitingEvents.Clear(); } }
public void LoadData(object dataInstance) { var helper = ((OverviewDataHelper)dataInstance); using (mailbox.Messages.ReaderLock) SelectedMessage = mailbox.Messages.FirstOrDefault( c => c.MessageId == helper.MessageId); if (SelectedMessage == null) { throw new ApplicationException( String.Format("Message was not found. MessageId = {0}", ((OverviewDataHelper)dataInstance).MessageId)); } // Mark all messages as read SelectedMessage.MarkRead(); OnPropertyChanged("SelectedMessage"); OnPropertyChanged("Title"); if (SelectedConversation == null || SelectedMessage.Conversation != SelectedConversation) { SelectedConversation = SelectedMessage.Conversation; OnPropertyChanged("SelectedConversation"); Messages.Replace(SelectedConversation.Messages); if (list != null) { list.SelectedItem = SelectedMessage; Dispatcher.BeginInvoke(DispatcherPriority.Input, (Action)(() => list.ScrollIntoView(SelectedMessage))); } } MessageActionsBox.Show(SelectedMessage); ThreadView.Show(SelectedMessage); UserProfileControl.SourceAddress = SelectedMessage.From; FocusHelper.Focus(TabSink); }
/// <inheritdoc/> public T this[int index] { get { this._lock.EnterReadLock(); try { return(this._collection[index]); } finally { this._lock.ExitReadLock(); } } set { ThreadView view = this._threadView.Value; if (view.dissalowReenterancy) { throwReenterancyException(); } this._lock.EnterWriteLock(); try { this._version++; this._collection[index] = value; } catch (Exception) { view.waitingEvents.Clear(); throw; } finally { this._lock.ExitWriteLock(); } this.dispatchWaitingEvents(view); } }
protected void Page_Load(object sender, EventArgs e) { System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); sw.Start(); bool thread_mode = !string.IsNullOrEmpty(this.Request["id"]); if (thread_mode) { Response.Write(ThreadView.GenerateThreadPage(Convert.ToInt32(this.Request["id"]))); } else { Response.Write(IndexView.GenerateIndexPage(this.Context, false)); } sw.Stop(); Response.Write(string.Format("<!-- Generated in {0} sec -->", sw.Elapsed.TotalSeconds)); }
private void GenerateData(FrameGroup group) { List <ThreadRow> rows = new List <ThreadRow>(); if (group != null) { rows.Add(new HeaderThreadRow(group) { GradientTop = (ThreadView.OptickAlternativeBackground as SolidColorBrush).Color, GradientBottom = (ThreadView.OptickBackground as SolidColorBrush).Color, TextColor = Colors.Gray, //Header = new ThreadFilterView(), }); ChartRow cpuCoreChart = EventThreadView.GenerateCoreChart(group); if (cpuCoreChart != null) { cpuCoreChart.IsExpanded = false; //cpuCoreChart.ExpandChanged += CpuCoreChart_ExpandChanged; //cpuCoreChart.ChartHover += Row_ChartHover; rows.Add(cpuCoreChart); } //List<EventsThreadRow> threadRows = GenerateThreadRows(group); //foreach (EventsThreadRow row in threadRows) //{ // if (row.Description.Origin == ThreadDescription.Source.Core) // { // row.IsVisible = false; // coreRows.Add(row); // } //} //rows.AddRange(threadRows); } ThreadView.Scroll.ViewUnit.Width = 1.0; ThreadView.InitRows(rows, group != null ? group.Board.TimeSlice : null); }
public async Task <IActionResult> Put(int id, [FromBody] ThreadView <TUserView> value) { using (var transaction = session.BeginTransaction()) { var thread = await session.LoadAsync <Thread <TUser> >(id); var account = await accountService.GetCurrentUserAsync(); if (!await accountService.IsUser(account, thread.Author)) { return(Unauthorized()); } thread.Title = value.Title; thread.Text = await htmlSanitizerService.Sanitize(value.Text, account); thread.Sticky = value.Sticky; await session.UpdateAsync(thread); transaction.Commit(); } return(Ok()); }
public FormStatus() { mainFormStatus = new MainForm(); ThreadViewStatus = new ThreadView(); }
public async Task <IHttpActionResult <ThreadView <TUserView> > > Post(int forumId, [FromBody] ThreadView <TUserView> value) { var forum = await session.LoadAsync <Data.Forums.Forum>(forumId); var account = await accountService.GetCurrentUserAsync(); if (account == null || (forum.ReadRole != null && !await accountService.HasRole(account, forum.ReadRole))) { return(Unauthorized <ThreadView <TUserView> >()); } if (forum.WriteRole != null && !await accountService.HasRole(account, forum.WriteRole)) { return(Unauthorized <ThreadView <TUserView> >()); } using (var transaction = session.BeginTransaction()) { var html = await htmlSanitizerService.Sanitize(value.Text, account); var thread = new Thread <TUser> { NumberOfComments = 0, CreationDate = DateTime.UtcNow, Sticky = value.Sticky, Forum = forum, Text = html, Title = value.Title, Author = account }; await session.SaveAsync(thread); transaction.Commit(); return(Created("GetThread", thread.Id, forumsDataMapping.ToThreadView(thread, null))); } }
protected void Page_Load(object sender, EventArgs e) { if (!ApplicationSettings.PostingEnabled) { Response.StatusCode = 403; this.Response.Write(Language.Lang.postingisdisabled); this.Response.End(); } if (string.IsNullOrEmpty(Request["mode"])) { Response.StatusCode = 403; Response.Write("403"); Response.End(); } using (DbConnection con = DatabaseEngine.GetDBConnection()) { con.Open(); //check bans if (Board.BanHandler.IsIPBanned(Request.UserHostAddress, con)) { Response.Redirect(Paths.WebRoot + "banned.aspx", true); } //bool is_admin = false; //bool is_mod = false; bool all_ok = true; //check flood //check captcha if (!CaptchaProvider.Verifiy(this.Context)) { this.Response.Write(Language.Lang.wrongcaptcha); this.Response.End(); } //check file sizes for (int i = 0; i < Request.Files.Count; i++) { HttpPostedFile file = Request.Files[i]; if (file.ContentLength > ApplicationSettings.MaximumFileSize) { Response.Write(string.Format("The file '{0}' is larger than the allowed limit {1}.", file.FileName, ApplicationSettings.MaximumFileSize)); all_ok = false; break; } } if (all_ok) { switch (Request["mode"]) { case "thread": if (Request.Files.Count == 0 | Request.Files["ufile"].ContentLength == 0) { Response.Write("You need a file to start a thread"); } else { OPData op_data = new DataTypes.OPData() { Comment = Request["comment"], Email = Request["email"], Name = Request["name"], Subject = Request["subject"], Password = Request["password"], HasFile = true, IP = Request.UserHostAddress, UserAgent = Request.UserAgent, Time = DateTime.UtcNow }; int thread_id = -1; try { thread_id = Board.BoardCommon.MakeThread(op_data, Request.Files["ufile"], con); Response.Redirect(Paths.WebRoot + "default.aspx?id=" + thread_id.ToString(), true); } catch (Exception ex) { Response.Write(ex.Message); } } break; case "reply": if (string.IsNullOrEmpty(Request["threadid"])) { Response.Write("Thread id is not specified"); } else { int thread_id = -1; try { thread_id = Convert.ToInt32(Request["threadid"]); if (thread_id <= 0) { Response.Write("Invalid thread id"); Response.End(); } } catch (Exception) { Response.Write("Invalid thread id"); Response.End(); } ThreadInfo t_info = BoardCommon.GetThreadInfo(thread_id, con); if (t_info.isGone) { Response.Write("Thread does not exist."); Response.End(); } if (t_info.isLocked) { Response.Write("Thread is locked."); Response.End(); } if (t_info.isArchived) { Response.Write("Thread is archived."); Response.End(); } if (ApplicationSettings.EnableImpresonationProtection) { //do stuffs } List <HttpPostedFile> proper_files = new List <HttpPostedFile>(); //Discard any empty file field for (int i = 0; i < Request.Files.Count; i++) { HttpPostedFile file = Request.Files[i]; if (file.ContentLength > 0) { proper_files.Add(file); } } bool file_in_each_post = (Request["finp"] == "yes"); bool count_files = (Request["countf"] == "yes"); bool sage = (Request["email"] == "sage"); OPData op_data = new OPData() { Comment = Request["comment"], Email = sage ? "" : Request["email"], Name = Request["name"], Subject = Request["subject"], Password = Request["password"], IP = Request.UserHostAddress, UserAgent = Request.UserAgent, Time = DateTime.UtcNow }; int reply_id = -1; try { reply_id = BoardCommon.ReplyTo(op_data, thread_id, proper_files.ToArray(), file_in_each_post, count_files, con); if (reply_id > 0) { //Update thread body if (ApplicationSettings.CacheIndexView) { IndexView.UpdateThreadIndex(thread_id, con); } if (ApplicationSettings.CacheThreadView) { ThreadView.UpdateThreadBody(thread_id, con); } if (!sage) { BoardCommon.BumpThread(thread_id, con); } Response.Redirect(Paths.WebRoot + string.Format("default.aspx?id={0}#p{1}", thread_id, reply_id)); } } catch (Exception ex) { Response.Write(ex.Message); } } break; default: Response.Write(string.Format("Invalid posting mode '{0}'", Request["mode"])); break; } //mode switch block } // if all ok block } // database connection using block } //page load void
protected void Page_Load(object sender, EventArgs e) { bool do_action = (!string.IsNullOrEmpty(Request["id"]) & Request["mode"] == "deletefile"); if (do_action) { int id = -1; Int32.TryParse(Request["id"], out id); if (id <= 0) { Response.Write("Invalid post id."); Response.End(); } using (DbConnection dc = Database.DatabaseEngine.GetDBConnection()) { dc.Open(); WPost post = Board.BoardCommon.GetPostData(id, dc); if (post == null) { Response.Write("Post does not exist"); Response.End(); } else { //first check captcha, then check password, and finally delete files if (CaptchaProvider.Verifiy(this.Context)) { if (Request["pwd"] == post.Password) //pwd is the user input password { //We should gather a list of files hashes, and delete them List <string> file_hashes = new List <string>(); foreach (string qs in this.Request.Form) { if (qs.StartsWith("file")) { file_hashes.Add(qs.Remove(0, 4)); } } if (file_hashes.Count > 0) { BoardCommon.DeleteFileFromDatabase(id, file_hashes.ToArray(), dc); if (Settings.ApplicationSettings.AutoDeleteFiles) { foreach (WPostFile file in post.Files) { if (file_hashes.Contains(file.Hash)) { //remove the files physically from the disk System.IO.File.Delete(System.IO.Path.Combine(Settings.Paths.PhysicalFilesStorageFolder, file.ChanbName + "." + file.Extension)); //delete thumbs as well System.IO.File.Delete(System.IO.Path.Combine(Settings.Paths.PhysicalThumbStorageFolder, file.ChanbName + ".jpg")); System.IO.File.Delete(System.IO.Path.Combine(Settings.Paths.PhysicalThumbStorageFolder, file.ChanbName + ".png")); } } } //update thread page and index. IndexView.UpdateThreadIndex(id, dc); ThreadView.UpdateThreadBody(id, dc); Response.Write(file_hashes.Count + " files deleted successfully"); } else { //No file was selected. Redirect to the delete file page, with 'no file selected' notice. Response.Redirect(Settings.Paths.WebRoot + "deletefile.aspx?ns=1&id=" + id.ToString(), true); //ns == no file seleted } } else { //Bad password. Redirect to the delete file page, with 'bad password' notice. Response.Redirect(Settings.Paths.WebRoot + "deletefile.aspx?bp=1&id=" + id.ToString(), true); //bp == bad password } } else { //invalid captcha. Redirect to the delete file page, with 'bad captcha' notice Response.Redirect(Settings.Paths.WebRoot + "deletefile.aspx?wc=1&id=" + id.ToString(), true); //wc == wrong captcha } } } } else { int id = -1; Int32.TryParse(Request["id"], out id); if (id <= 0) { Response.Write("Invalid post id."); Response.End(); } using (DbConnection dc = Database.DatabaseEngine.GetDBConnection()) { dc.Open(); WPost post = Board.BoardCommon.GetPostData(id, dc); if (post == null) { Response.Write("Post does not exist"); Response.End(); } else { if (post.FileCount == 0) { Response.Write("Post has no files"); Response.End(); } else if (post.FileCount == 1) { if (string.IsNullOrEmpty(post.Comment) & post.Type == Enums.PostType.Reply) { Response.Write("Cannot delete this post because it has no comment and only a single file. \n Delete the post instead."); Response.End(); } else { //show delete file page Response.Write(generate_page(post)); } } else { Response.Write(generate_page(post)); } } } } }
/// <inheritdoc/> public IEnumerator <T> GetEnumerator() { ThreadView view = this._threadView.Value; return(new EnumeratorImpl(view.getSnapshot(), view)); }
public EnumeratorImpl(List <T> list, ThreadView view) { this._enumerator = list.GetEnumerator(); this._view = view; this._myId = view.enterEnumerator(); }
public void Dispose() { ThreadView.Dispose(); }