private static CommentStub CreateCommentStub(Comment comment, ThreadUsr threadUsr, GroupUsr groupUsr) { CommentStub c = new CommentStub() { k = comment.K, html = comment.GetHtml(null), script = comment.Script, usrName = comment.Usr.Name, usrPicSrc = comment.Usr.AnyPicPath, usrRollover = comment.Usr.RolloverMouseOverTextNoPic, usrUrl = comment.Usr.Url(), usrK = comment.Usr.K, isNew = comment.GetIsNew(threadUsr), friendlyTimeNoCaps = comment.FriendlyTimeNoCaps, editLinkVisible = Usr.Current != null && (comment.UsrK == Usr.Current.K || Usr.Current.IsAdmin), editedHtml = comment.EditedHtml, deleteLinkVisible = Usr.Current != null && Usr.Current.CanDelete(comment), deleteLinkOnClickConfirmText = Usr.Current == null ? "" : (groupUsr != null && groupUsr.Moderator) ? "You are using your group moderator power to delete this comment.\n\nAre you sure?" : (comment.UsrK != Usr.Current.K) ? "You are using your moderator power to delete this comment.\n\nAre you sure?" : "Are you sure?", threadK = comment.ThreadK }; c.lolHtml = comment.LolUsrListHtml(out c.haveAlreadyLold, Usr.Current != null ? Usr.Current.K : -1); return c; }
public CommentResult GetThreadComments(int threadK, int pageNumber, bool getCommentsOnly) { Thread thread = new Thread(threadK); GroupUsr groupUsr = null; if (Usr.Current != null && thread.Group != null) { groupUsr = thread.Group.GetGroupUsr(Usr.Current); } ThreadUsr threadUsr = null; if (Usr.Current != null && thread.CheckPermissionRead(Usr.Current)) { try { threadUsr = new ThreadUsr(thread.K, Usr.Current.K); } catch (BobNotFound) { } } CommentResult result = new CommentResult(); if (pageNumber <= 0) { pageNumber = (result.firstUnreadPage > 0) ? result.firstUnreadPage : 1; } result.comments = thread.ChildComments().Page(pageNumber, Vars.CommentsPerPage).ConvertAll(c => CreateCommentStub(c, threadUsr, groupUsr)).ToArray(); if (result.comments.Length == 0) { throw new Exception("No comments to retrieve."); } result.firstUnreadPage = !getCommentsOnly && threadUsr != null && threadUsr.ViewCommentsInUse > 0 ? (threadUsr.ViewCommentsInUse / Vars.CommentsPerPage) + 1 : 0; result.lastPage = !getCommentsOnly ? thread.LastPage : 0; result.currentPage = pageNumber; result.initialComment = (!getCommentsOnly && pageNumber > 1) ? CreateCommentStub(thread.ChildComments()[0], threadUsr, groupUsr) : null; result.viewComments = !getCommentsOnly && threadUsr != null ? threadUsr.ViewCommentsInUse : 0; result.totalComments = !getCommentsOnly ? thread.TotalComments : 0; return result; }
public void PanelSignUpFormClick(object o, System.EventArgs e) { Page.Validate(); if (Page.IsValid) { if (IsEdit) { if (!CanEdit) throw new Exception("You can't edit this promoter!"); #region Store changes to promoter in admin note string oldDetails = ""; if (!Cambro.Web.Helpers.StripHtml(Name.Text).Equals(CurrentPromoter.Name)) oldDetails += "Name: [" + CurrentPromoter.Name + "] - [" + Cambro.Web.Helpers.StripHtml(Name.Text) + "]\n"; if (!Cambro.Web.Helpers.StripHtml(ContactName.Text).Equals(CurrentPromoter.ContactName)) oldDetails += "ContactName: [" + CurrentPromoter.ContactName + "] - [" + Cambro.Web.Helpers.StripHtml(ContactName.Text) + "]\n"; if (!Cambro.Web.Helpers.StripHtml(PhoneNumber.Text).Equals(CurrentPromoter.PhoneNumber)) oldDetails += "PhoneNumber: [" + CurrentPromoter.PhoneNumber + "] - [" + Cambro.Web.Helpers.StripHtml(PhoneNumber.Text) + "]\n"; if (!Cambro.Web.Helpers.StripHtml(AddressStreet.Text).Equals(CurrentPromoter.AddressStreet)) oldDetails += "AddressStreet: [" + CurrentPromoter.AddressStreet + "] - [" + Cambro.Web.Helpers.StripHtml(AddressStreet.Text) + "]\n"; if (!Cambro.Web.Helpers.StripHtml(AddressArea.Text).Equals(CurrentPromoter.AddressArea)) oldDetails += "AddressArea: [" + CurrentPromoter.AddressArea + "] - [" + Cambro.Web.Helpers.StripHtml(AddressArea.Text) + "]\n"; if (!Cambro.Web.Helpers.StripHtml(AddressTown.Text).Equals(CurrentPromoter.AddressTown)) oldDetails += "AddressTown: [" + CurrentPromoter.AddressTown + "] - [" + Cambro.Web.Helpers.StripHtml(AddressTown.Text) + "]\n"; if (!Cambro.Web.Helpers.StripHtml(AddressCounty.Text).Equals(CurrentPromoter.AddressCounty)) oldDetails += "AddressCounty: [" + CurrentPromoter.AddressCounty + "] - [" + Cambro.Web.Helpers.StripHtml(AddressCounty.Text) + "]\n"; if (!Cambro.Web.Helpers.StripHtml(AddressPostcode.Text).Equals(CurrentPromoter.AddressPostcode)) oldDetails += "AddressPostcode: [" + CurrentPromoter.AddressPostcode + "] - [" + Cambro.Web.Helpers.StripHtml(AddressPostcode.Text) + "]\n"; if (!int.Parse(AddressCountry.SelectedValue).Equals(CurrentPromoter.AddressCountryK)) oldDetails += "CountryK: [" + CurrentPromoter.AddressCountryK + "] - [" + int.Parse(AddressCountry.SelectedValue).ToString() + "]\n"; if (!((Promoter.VatStatusEnum)Convert.ToInt32(VatStatusDropDownList.SelectedValue)).Equals(CurrentPromoter.VatStatus)) oldDetails += "VatStatus: [" + CurrentPromoter.VatStatus.ToString() + "] - [" + ((Promoter.VatStatusEnum)Convert.ToInt32(VatStatusDropDownList.SelectedValue)).ToString() + "]\n"; if (!Cambro.Web.Helpers.StripHtml(VatNumberTextBox.Text.Trim()).Equals(CurrentPromoter.VatNumber)) oldDetails += "VatNumber: [" + CurrentPromoter.VatNumber + "] - [" + Cambro.Web.Helpers.StripHtml(VatNumberTextBox.Text.Trim()) + "]\n"; if (!Convert.ToInt32(VatCountryDropDownList.SelectedValue).Equals(CurrentPromoter.VatCountryK)) oldDetails += "VatCountryK: [" + CurrentPromoter.VatCountryK.ToString() + "] - [" + Convert.ToInt32(VatCountryDropDownList.SelectedValue).ToString() + "]\n"; if (!Cambro.Web.Helpers.StripHtml(BankNameTextBox.Text).Equals(CurrentPromoter.BankName)) oldDetails += "BankName: [" + CurrentPromoter.BankName + "] - [" + Cambro.Web.Helpers.StripHtml(BankNameTextBox.Text) + "]\n"; if (!Cambro.Web.Helpers.StripHtml(BankAccountNameTextBox.Text).Equals(CurrentPromoter.BankAccountName)) oldDetails += "BankAccountName: [" + CurrentPromoter.BankAccountName + "] - [" + Cambro.Web.Helpers.StripHtml(BankAccountNameTextBox.Text) + "]\n"; if (!Cambro.Web.Helpers.StripHtml(BankAccountNumberTextBox.Text).Equals(CurrentPromoter.BankAccountNumber)) oldDetails += "BankAccountNumber: [" + CurrentPromoter.BankAccountNumber + "] - [" + Cambro.Web.Helpers.StripHtml(BankAccountNumberTextBox.Text) + "]\n"; if (!Cambro.Web.Helpers.StripHtml(BankAccountSortCodeTextBox.Text).Equals(CurrentPromoter.BankAccountSortCode)) oldDetails += "BankAccountSortCode: [" + CurrentPromoter.BankAccountSortCode + "] - [" + Cambro.Web.Helpers.StripHtml(BankNameTextBox.Text) + "]\n"; if (uiAgency.Checked != CurrentPromoter.IsAgency) oldDetails += "IsAgency: [" + CurrentPromoter.IsAgency.ToString() + "] - [" + uiAgency.Checked.ToString() + "]\n"; if (oldDetails.Length > 0) CurrentPromoter.AdminNote += "\n" + Usr.Current.NickName + " (" + Usr.Current.K.ToString() + ") changed these details on " + DateTime.Now.ToString() + ":\n" + oldDetails; #endregion } else { Guid DuplicateGuid = (Guid)ViewState["PromoterDuplicateGuid"]; PromoterSet ps = new PromoterSet(new Query(new Q(Promoter.Columns.DuplicateGuid, DuplicateGuid))); if (ps.Count > 0) { Response.Redirect(ps[0].UrlApp("edit")); return; } else { #region Initialise promoter record CurrentPromoter = new Promoter(); CurrentPromoter.DateTimeSignUp = DateTime.Now; CurrentPromoter.AddedByUsrK = Usr.Current.K; CurrentPromoter.HasGuestlist = true; CurrentPromoter.GuestlistCharge = 0.25m; CurrentPromoter.GuestlistCredit = 20; CurrentPromoter.GuestlistCreditLimit = 0; CurrentPromoter.Status = Promoter.StatusEnum.Enabled; CurrentPromoter.PricingMultiplier = 1.0; CurrentPromoter.TotalPaid = 0; CurrentPromoter.DuplicateGuid = (Guid)ViewState["PromoterDuplicateGuid"]; CurrentPromoter.LetterType = Promoter.LetterTypes.CurrentNewPromoter; CurrentPromoter.LetterStatus = Promoter.LetterStatusEnum.New; CurrentPromoter.IsSkeleton = false; CurrentPromoter.OfferType = Promoter.OfferTypes.None; Random r = new Random(); CurrentPromoter.AccessCodeRandom = r.Next(1000, 9999).ToString() + r.Next(1000, 9999).ToString(); CurrentPromoter.ClientSector = (Promoter.ClientSectorEnum)Convert.ToInt32(Sector.SelectedValue); CurrentPromoter.SalesCampaignK = int.Parse(SalesCampaignDropDown.SelectedValue); if (!Usr.Current.IsAdmin) { CurrentPromoter.PrimaryUsrK = Usr.Current.K; CurrentPromoter.AddedMethod = Promoter.AddedMedhods.EndUser; } else { CurrentPromoter.AddedMethod = Promoter.AddedMedhods.SalesUser; } // assign new Promoter to Usr.Current if they are on a promoter sales team or to a randomly assigned promoter sales person, as requested by Dave 7/2/07 if (Usr.Current.SalesTeam > 0) { CurrentPromoter.SalesStatus = Promoter.SalesStatusEnum.Proactive; CurrentPromoter.SalesUsrK = Usr.Current.K; } else { CurrentPromoter.SalesStatus = Promoter.SalesStatusEnum.New; // Randomly assign a sales usr List<Usr> promoterSalesUsrs; if (CurrentPromoter.ClientSector.Equals(Promoter.ClientSectorEnum.Promoter)) promoterSalesUsrs = Usr.GetNewPromoterSalesUsrsNameAndK().ToList(); else promoterSalesUsrs = new List<Usr>() { new Usr(1) }; CurrentPromoter.SalesUsrK = promoterSalesUsrs[r.Next(0, promoterSalesUsrs.Count)].K; } CurrentPromoter.SalesStatusExpires = DateTime.Today.AddMonths(3); CurrentPromoter.SalesNextCall = DateTime.Now.AddDays(3); // If first call is on a weekend, then make it Monday if(CurrentPromoter.SalesNextCall.DayOfWeek == DayOfWeek.Saturday) CurrentPromoter.SalesNextCall = DateTime.Now.AddDays(2); else if(CurrentPromoter.SalesNextCall.DayOfWeek == DayOfWeek.Sunday) CurrentPromoter.SalesNextCall = DateTime.Now.AddDays(1); #endregion } } #region Update promoter record with form contents CurrentPromoter.Name = Cambro.Web.Helpers.StripHtml(Name.Text); CurrentPromoter.ContactName = Cambro.Web.Helpers.StripHtml(ContactName.Text); CurrentPromoter.PhoneNumber = Cambro.Web.Helpers.StripHtml(PhoneNumber.Text); CurrentPromoter.AddressStreet = Cambro.Web.Helpers.StripHtml(AddressStreet.Text); CurrentPromoter.AddressArea = Cambro.Web.Helpers.StripHtml(AddressArea.Text); CurrentPromoter.AddressTown = Cambro.Web.Helpers.StripHtml(AddressTown.Text); CurrentPromoter.AddressCounty = Cambro.Web.Helpers.StripHtml(AddressCounty.Text); CurrentPromoter.AddressPostcode = Cambro.Web.Helpers.StripHtml(AddressPostcode.Text); bool updateTicketInvoices = false; // new VAT details, for Ticket System. 22/5/07 if (CurrentPromoter.VatStatus != Promoter.VatStatusEnum.Registered && CurrentPromoter.VatStatus != (Promoter.VatStatusEnum)Convert.ToInt32(VatStatusDropDownList.SelectedValue)) updateTicketInvoices = true; CurrentPromoter.VatStatus = (Promoter.VatStatusEnum)Convert.ToInt32(VatStatusDropDownList.SelectedValue); CurrentPromoter.VatCountryK = Convert.ToInt32(VatCountryDropDownList.SelectedValue); CurrentPromoter.VatNumber = Cambro.Web.Helpers.StripHtml(VatNumberTextBox.Text.Trim()); // new Admin only data entry fields, as requested by Dave 7/2/07 if (Usr.Current.IsAdmin || Usr.Current.IsSuperAdmin) { CurrentPromoter.AccountsEmail = Cambro.Web.Helpers.StripHtml(AccountsEmail.Text); CurrentPromoter.AccountsName = Cambro.Web.Helpers.StripHtml(AccountsName.Text); CurrentPromoter.AccountsPhone = Cambro.Web.Helpers.StripHtml(AccountsPhone.Text); CurrentPromoter.ContactPersonalTitle = Cambro.Web.Helpers.StripHtml(PersonalTitle.Text); CurrentPromoter.ContactTitle = Cambro.Web.Helpers.StripHtml(JobTitle.Text); CurrentPromoter.PhoneNumber2 = Cambro.Web.Helpers.StripHtml(PhoneNumber2.Text); CurrentPromoter.WebAddress = Cambro.Web.Helpers.StripHtml(WebAddress.Text); CurrentPromoter.ClientSector = (Promoter.ClientSectorEnum)Convert.ToInt32(Sector.SelectedValue); CurrentPromoter.SalesCampaignK = int.Parse(SalesCampaignDropDown.SelectedValue); CurrentPromoter.IsAgency = uiAgency.Checked; // new admin only bank details, as requested by Dave 15/6/07 CurrentPromoter.BankName = Cambro.Web.Helpers.StripHtml(BankNameTextBox.Text); CurrentPromoter.BankAccountName = Cambro.Web.Helpers.StripHtml(BankAccountNameTextBox.Text); CurrentPromoter.BankAccountNumber = Cambro.Web.Helpers.StripHtml(BankAccountNumberTextBox.Text); CurrentPromoter.BankAccountSortCode = Cambro.Web.Helpers.StripHtml(BankAccountSortCodeTextBox.Text); if (this.AccessMultiRadio.Checked && this.uiAccessUsersMultiSelector.Count > 0 && (Usr.Current.IsAdmin || Usr.Current.IsSuperAdmin)){ CurrentPromoter.PrimaryUsrK = int.Parse(uiPrimaryUserDropDown.SelectedValue); }else { CurrentPromoter.PrimaryUsrK = 0; CurrentPromoter.AdminNote += "\n" + Usr.Current.NickName + " (" + Usr.Current.K.ToString() + ") has setup this account with no primary user - " + DateTime.Now.ToString() + "\n"; } } if (!IsEdit) { if (CurrentPromoter.PrimaryUsrK > 0) CurrentPromoter.AddQuestionsThread(CurrentPromoter.PrimaryUsr, Cambro.Web.Helpers.StripHtml(Name.Text)); else CurrentPromoter.AddQuestionsThread(Usr.Current, Cambro.Web.Helpers.StripHtml(Name.Text)); } Country newCountry = new Country(int.Parse(AddressCountry.SelectedValue)); CurrentPromoter.AddressCountryK = newCountry.K; CurrentPromoter.Update(); if (updateTicketInvoices) CurrentPromoter.UpdateTicketInvoiceItemTaxCode(); CurrentPromoter.CreateUniqueUrlName(); #endregion #region Add / remove selected users if (CurrentPromoter.PrimaryUsrK == Usr.Current.K || Usr.Current.IsAdmin || Usr.Current.IsSuperAdmin) { ArrayList SelectedUsers = new ArrayList(); ArrayList CurrentUsers = new ArrayList(); if (CurrentPromoter.PrimaryUsrK > 0) { SelectedUsers.Add(CurrentPromoter.PrimaryUsrK); } if (AccessMultiRadio.Checked) { foreach (var pair in this.uiAccessUsersMultiSelector.Selections) { Usr u = new Usr(int.Parse(pair.Value)); if (!SelectedUsers.Contains(u.K)) SelectedUsers.Add(u.K); } } foreach (Usr u in CurrentPromoter.AdminUsrs) { if (!CurrentUsers.Contains(u.K)) CurrentUsers.Add(u.K); } if (SelectedUsers.Count > 0) { Usr JohnB = new Usr(1); Thread t = new Thread(CurrentPromoter.QuestionsThreadK); foreach (int usrK in SelectedUsers) { if (!CurrentUsers.Contains(usrK)) { PromoterUsr pu = new PromoterUsr(); pu.PromoterK = CurrentPromoter.K; pu.UsrK = usrK; pu.Update(); t.Invite(new List<int>(new int[] { usrK }), JohnB, DateTime.Now, new List<int>(), !IsEdit, null, false); ThreadUsr tu = new ThreadUsr(CurrentPromoter.QuestionsThreadK, usrK); tu.Favourite = true; tu.Update(); CurrentPromoter.AdminNote += "\n" + Usr.Current.NickName + " (" + Usr.Current.K.ToString() + ") added new user to admins - " + DateTime.Now.ToString() + " - " + pu.UsrK.ToString() + " (" + pu.Usr.NickName + ")\n"; CurrentPromoter.Update(); pu.Usr.UpdateIsPromoter(); } } } //if (!AccessNoAccountUsersRadio.Checked) //{ foreach (int usrK in CurrentUsers) { if (!SelectedUsers.Contains(usrK)) { PromoterUsr pu = new PromoterUsr(CurrentPromoter.K, usrK); CurrentPromoter.AdminNote += "\n" + Usr.Current.NickName + " (" + Usr.Current.K.ToString() + ") removed user from the admins - " + DateTime.Now.ToString() + " - " + pu.UsrK.ToString() + " (" + pu.Usr.NickName + ")\n"; CurrentPromoter.Update(); pu.Delete(); pu.Update(); pu.Usr.UpdateIsPromoter(); try { ThreadUsr tu = new ThreadUsr(CurrentPromoter.QuestionsThreadK, usrK); tu.Delete(); tu.Update(); UpdateTotalParticipantsJob job = new UpdateTotalParticipantsJob(tu.Thread); job.ExecuteSynchronously(); } catch { } } } //} //else //{ // foreach (int usrK in CurrentUsers) // { // PromoterUsr pu = new PromoterUsr(CurrentPromoter.K, usrK); // CurrentPromoter.AdminNote += "\n" + Usr.Current.NickName + " (" + Usr.Current.K.ToString() + ") removed user from the admins - " + DateTime.Now.ToString() + " - " + pu.UsrK.ToString() + " (" + pu.Usr.NickName + ")\n"; // CurrentPromoter.Update(); // pu.Delete(); // pu.Update(); // pu.Usr.UpdateIsPromoter(); // try // { // ThreadUsr tu = new ThreadUsr(CurrentPromoter.QuestionsThreadK, usrK); // tu.Delete(); // tu.Update(); // tu.Thread.UpdateTotalParticipants(); // } // catch { } // } //} } #endregion #region Add / remove selected brands ArrayList SelectedBrands = new ArrayList(); ArrayList CurrentBrands = new ArrayList(); if (AccountTypeRadioEvents.Checked) { foreach (var pair in this.uiBrandMultiSelector.Selections) { Brand b = new Brand(int.Parse(pair.Value)); if (!SelectedBrands.Contains(b.K)) SelectedBrands.Add(b.K); } } CurrentPromoter.AllBrands = null; foreach (Brand b in CurrentPromoter.AllBrands) { if (!CurrentBrands.Contains(b.K)) CurrentBrands.Add(b.K); } string failedBrands = ""; foreach (int brandK in SelectedBrands) { if (!CurrentBrands.Contains(brandK)) { Brand b = new Brand(brandK); bool changeStatus = false; if (b.PromoterK == 0) { CurrentPromoter.AdminNote += "\n" + Usr.Current.NickName + " (" + Usr.Current.K.ToString() + ") added brand - " + DateTime.Now.ToString() + " - " + b.K + " (" + b.Name + ") - "; b.PromoterK = CurrentPromoter.K; changeStatus = true; } else if (b.PromoterStatus.Equals(Brand.PromoterStatusEnum.Unconfirmed)) { CurrentPromoter.AdminNote += "\n" + Usr.Current.NickName + " (" + Usr.Current.K.ToString() + ") added brand - " + DateTime.Now.ToString() + " - " + b.K + " (" + b.Name + ") - removed from promoter " + b.PromoterK + " (" + b.Promoter.Name + ") - "; b.PromoterK = CurrentPromoter.K; changeStatus = true; } else //brand owned by someone else! { CurrentPromoter.AdminNote += "\n" + Usr.Current.NickName + " (" + Usr.Current.K.ToString() + ") attempted to add brand - " + DateTime.Now.ToString() + " - " + b.K + " (" + b.Name + "), but it's already confirmed to promoter " + b.PromoterK + " (" + b.Promoter.Name + ")\n"; failedBrands = (failedBrands.Length == 0 ? "" : ", ") + b.Name; } if (changeStatus) { bool foundBrandOwner = false; CurrentPromoter.AdminUsrs = null; foreach (Usr u in CurrentPromoter.AdminUsrs) { if (b.OwnerUsrK == u.K) foundBrandOwner = true; } if (foundBrandOwner || Usr.Current.IsAdmin) { b.PromoterStatus = Brand.PromoterStatusEnum.Confirmed; CurrentPromoter.AdminNote += "(status confirmed)\n"; } else { b.PromoterStatus = Brand.PromoterStatusEnum.Unconfirmed; CurrentPromoter.AdminNote += "(status new)\n"; } } b.Update(); CurrentPromoter.Update(); } } foreach (int brandK in CurrentBrands) { if (!SelectedBrands.Contains(brandK)) { Brand b = new Brand(brandK); CurrentPromoter.AdminNote += "\n" + Usr.Current.NickName + " (" + Usr.Current.K.ToString() + ") removed brand - " + DateTime.Now.ToString() + " - " + b.K + " (" + b.Name + ")"; b.PromoterStatus = Brand.PromoterStatusEnum.Unconfirmed; b.PromoterK = 0; b.Update(); CurrentPromoter.Update(); } } #endregion #region Add / remove selected venues ArrayList SelectedVenues = new ArrayList(); ArrayList CurrentVenues = new ArrayList(); if (VenuesRadioYes.Checked) { foreach (var pair in this.uiVenuesMultiSelector.Selections) { Venue v = new Venue(int.Parse(pair.Value)); if (!SelectedVenues.Contains(v.K)) SelectedVenues.Add(v.K); } } CurrentPromoter.AllVenues = null; foreach (Venue v in CurrentPromoter.AllVenues) { if (!CurrentVenues.Contains(v.K)) CurrentVenues.Add(v.K); } string failedVenues = ""; foreach (int venueK in SelectedVenues) { if (!CurrentVenues.Contains(venueK)) { Venue v = new Venue(venueK); bool changeStatus = false; if (v.PromoterK == 0) { CurrentPromoter.AdminNote += "\n" + Usr.Current.NickName + " (" + Usr.Current.K.ToString() + ") added venue - " + DateTime.Now.ToString() + " - " + v.K + " (" + v.Name + ") - "; v.PromoterK = CurrentPromoter.K; changeStatus = true; } else if (v.PromoterStatus.Equals(Venue.PromoterStatusEnum.Unconfirmed)) { CurrentPromoter.AdminNote += "\n" + Usr.Current.NickName + " (" + Usr.Current.K.ToString() + ") added venue - " + DateTime.Now.ToString() + " - " + v.K + " (" + v.Name + ") - removed from promoter " + v.PromoterK + " (" + v.Promoter.Name + ") - "; v.PromoterK = CurrentPromoter.K; changeStatus = true; } else //venue owned by someone else! { CurrentPromoter.AdminNote += "\n" + Usr.Current.NickName + " (" + Usr.Current.K.ToString() + ") attempted to add venue - " + DateTime.Now.ToString() + " - " + v.K + " (" + v.Name + "), but it's already confirmed to promoter " + v.PromoterK + " (" + v.Promoter.Name + ")\n"; failedVenues = (failedVenues.Length == 0 ? "" : ", ") + v.Name + " in " + v.Place.Name; } if (changeStatus) { bool foundVenueOwner = false; CurrentPromoter.AdminUsrs = null; foreach (Usr u in CurrentPromoter.AdminUsrs) { if (v.OwnerUsrK == u.K) foundVenueOwner = true; } if (foundVenueOwner || Usr.Current.IsAdmin) { v.PromoterStatus = Venue.PromoterStatusEnum.Confirmed; CurrentPromoter.AdminNote += "(status confirmed)\n"; } else { v.PromoterStatus = Venue.PromoterStatusEnum.Unconfirmed; CurrentPromoter.AdminNote += "(status new)\n"; } } v.Update(); CurrentPromoter.Update(); } } foreach (int venueK in CurrentVenues) { if (!SelectedVenues.Contains(venueK)) { Venue v = new Venue(venueK); CurrentPromoter.AdminNote += "\n" + Usr.Current.NickName + " (" + Usr.Current.K.ToString() + ") removed venue - " + DateTime.Now.ToString() + " - " + v.K + " (" + v.Name + ")"; v.PromoterStatus = Venue.PromoterStatusEnum.Unconfirmed; v.PromoterK = 0; v.Update(); CurrentPromoter.Update(); } } #endregion this.ViewState["CurrentPromoterK"] = CurrentPromoter.K; CurrentPromoter = new Promoter(CurrentPromoter.K); CurrentPromoter.FixQuestionsThreadUsrs(); CurrentPromoter.UpdateModerators(); Usr.Current.LegalTermsPromoter2 = true; Usr.Current.Update(); if (failedBrands.Length > 0 || failedVenues.Length > 0) { //show error form... BrandErrorLabel.Text = failedBrands; VenueErrorLabel.Text = failedVenues; BrandErrorPanel.Visible = failedBrands.Length > 0; VenueErrorPanel.Visible = failedVenues.Length > 0; ChangePanel(PanelBrandVenueError); } else { if (IsEdit) { if (Usr.Current.IsAdmin) Response.Redirect(CurrentPromoter.Url()); else ChangePanel(PanelEditDone); } else { if (!Usr.Current.IsAdmin) { Thread t = new Thread(CurrentPromoter.QuestionsThreadK); Response.Redirect(t.Url()); } else { Response.Redirect(CurrentPromoter.Url()); } } } } }
public void AddGarethDarren(object o, System.EventArgs e) { Cambro.Web.Helpers.WriteAlertHeader(); Cambro.Web.Helpers.WriteAlert("Selecting promoters...", 1); Query q = new Query(); //q.QueryCondition=??? PromoterSet bs = new PromoterSet(q); for (int count = 0; count < bs.Count; count++) { Promoter c = bs[count]; try { Thread t = new Thread(c.QuestionsThreadK); try { ThreadUsr tu = new ThreadUsr(t.K, 4); tu.Delete(); } catch { } try { ThreadUsr tu = new ThreadUsr(t.K, 78392); tu.Delete(); } catch { } try { ThreadUsr tuDarren = new ThreadUsr(t.K, 289079); } catch { ThreadUsr tuDarren = new ThreadUsr(); tuDarren.ThreadK = t.K; tuDarren.UsrK = 289079; tuDarren.InvitingUsrK = 1; tuDarren.Status = ThreadUsr.StatusEnum.Archived; tuDarren.DateTime = DateTime.Now; tuDarren.PrivateChatType = ThreadUsr.PrivateChatTypes.None; tuDarren.Favourite = false; tuDarren.Deleted = false; tuDarren.ViewDateTime = DateTime.Now; tuDarren.ViewDateTimeLatest = DateTime.Now; tuDarren.ViewComments = t.TotalComments; tuDarren.ViewCommentsLatest = t.TotalComments; tuDarren.StatusChangeDateTime = DateTime.Now; tuDarren.StatusChangeObjectType = Model.Entities.ObjectType.Usr; tuDarren.StatusChangeObjectK = 289079; tuDarren.Update(); } try { ThreadUsr tuGareth = new ThreadUsr(t.K, 294380); } catch { ThreadUsr tuGareth = new ThreadUsr(); tuGareth.ThreadK = t.K; tuGareth.UsrK = 294380; tuGareth.InvitingUsrK = 1; tuGareth.Status = ThreadUsr.StatusEnum.Archived; tuGareth.DateTime = DateTime.Now; tuGareth.PrivateChatType = ThreadUsr.PrivateChatTypes.None; tuGareth.Favourite = false; tuGareth.Deleted = false; tuGareth.ViewDateTime = DateTime.Now; tuGareth.ViewDateTimeLatest = DateTime.Now; tuGareth.ViewComments = t.TotalComments; tuGareth.ViewCommentsLatest = t.TotalComments; tuGareth.StatusChangeDateTime = DateTime.Now; tuGareth.StatusChangeObjectType = Model.Entities.ObjectType.Usr; tuGareth.StatusChangeObjectK = 294380; tuGareth.Update(); } // Do work here! //c.Update(); if (count % 10 == 0) Cambro.Web.Helpers.WriteAlert("Done " + c.Name + " - " + count + "/" + bs.Count, 2); } catch (Exception ex) { Cambro.Web.Helpers.WriteAlert("Exception " + count + "/" + bs.Count + " - " + ex.ToString(), 3); } bs.Kill(count); } Cambro.Web.Helpers.WriteAlert("Done!", 3); Cambro.Web.Helpers.WriteAlertFooter(); }
public void UpdateWatchingThreads(ThreadUsr.StatusEnum changeStatus, IBobType invitingBob) { UpdateThreadUsrs(changeStatus, ThreadUsr.WatchingStatuses, invitingBob); }
public void UpdateInboxThreads(ThreadUsr.StatusEnum changeStatus, IBobType invitingBob) { UpdateThreadUsrs(changeStatus, ThreadUsr.InboxStatuses, invitingBob); }
public void SmartDelete(ThreadUsr.StatusEnum threadStatusToChange, Model.Entities.ObjectType? statusChangeObjectType, int? statusChangeObjectK) { SmartDelete(new List<ThreadUsr.StatusEnum>() { threadStatusToChange }, statusChangeObjectType, statusChangeObjectK); }
public void UpdateThreadUsrs(ThreadUsr.StatusEnum changeStatus, List<ThreadUsr.StatusEnum> threadStatusesToChange, Model.Entities.ObjectType? statusChangeObjectType, int? statusChangeObjectK) { string memcachedKey = new Caching.CacheKey(Caching.CacheKeyPrefix.UpdateThreadUsrJobStatus, "UsrK", this.K.ToString(), "StatusChangeObjectType", statusChangeObjectType.ToString(), "StatusChangeObjectK", statusChangeObjectK.ToString()).ToString(); UpdateThreadUsrJob utuj = new UpdateThreadUsrJob(this.K, changeStatus, threadStatusesToChange, statusChangeObjectType, statusChangeObjectK, memcachedKey); utuj.ExecuteAsynchronously(); //Update uThreadUsr = new Update(); //uThreadUsr.Table = TablesEnum.ThreadUsr; //uThreadUsr.Changes.Add(new Assign(ThreadUsr.Columns.Status, changeStatus)); //uThreadUsr.Changes.Add(new Assign(ThreadUsr.Columns.StatusChangeDateTime, Time.Now)); //uThreadUsr.Where = new Q(ThreadUsr.Columns.UsrK, this.K); //if (threadStatusesToChange != null && threadStatusesToChange.Count > 0) //{ // Or statusOr = new Or(); // foreach (ThreadUsr.StatusEnum statusEnum in threadStatusesToChange) // { // statusOr = new Or(statusOr, // new Q(ThreadUsr.Columns.Status, statusEnum)); // } // uThreadUsr.Where = new And(uThreadUsr.Where, // statusOr); //} //else // throw new Exception("Usr.UpdateThreadUsrs(): Invalid list of ThreadUsr.StatusEnum to change."); //if (statusChangeObjectType != null) //{ // if (statusChangeObjectType.Value == Model.Entities.ObjectType.Usr) // { // // do nothing here // } // else // { // uThreadUsr.Where = new And(uThreadUsr.Where, // new Q(ThreadUsr.Columns.StatusChangeObjectType, statusChangeObjectType.Value)); // } // if (statusChangeObjectK != null) // { // if (statusChangeObjectType.Value == Model.Entities.ObjectType.Usr) // { // uThreadUsr.Where = new And(uThreadUsr.Where, // new Q(ThreadUsr.Columns.InvitingUsrK, statusChangeObjectK.Value)); // } // else // { // uThreadUsr.Where = new And(uThreadUsr.Where, // new Q(ThreadUsr.Columns.StatusChangeObjectK, statusChangeObjectK.Value)); // } // } //} //uThreadUsr.CommandTimeout = 90; //uThreadUsr.Run(); }
public UpdateThreadUsrJob(int usrK, ThreadUsr.StatusEnum changeStatus, List<ThreadUsr.StatusEnum> threadStatusesToChange, Model.Entities.ObjectType? statusChangeObjectType, int? statusChangeObjectK, string memcachedKey) { UsrK.Value = usrK; ChangeStatus.Value = changeStatus; ThreadStatusesToChange.Value = threadStatusesToChange; StatusChangeObjectType.Value = statusChangeObjectType; StatusChangeObjectK.Value = statusChangeObjectK; MemcachedKey.Value = memcachedKey; object cachedJobStatus = Caching.Instances.Main.Get(memcachedKey); if (cachedJobStatus != null && (Bobs.JobProcessor.Job.JobStatus.Queued == (Bobs.JobProcessor.Job.JobStatus)cachedJobStatus || Bobs.JobProcessor.Job.JobStatus.Running == (Bobs.JobProcessor.Job.JobStatus)cachedJobStatus)) { IsAlreadyRunning.Value = true; } else { Caching.Instances.Main.Store(memcachedKey, Job.JobStatus.Queued, new TimeSpan(0, 15, 0)); IsAlreadyRunning.Value = false; } }
public bool CheckPermissionPost(Usr u, ThreadUsr threadUsr, GroupUsr groupUsr) { if (this.Private) { try { return !threadUsr.Deleted; } catch { return false; } } else { if (this.GroupK > 0) { return u.CanGroupMember(groupUsr); } return true; } }
public bool CheckPermissionPost(Usr u) { if (this.Private) { try { ThreadUsr tu = new ThreadUsr(this.K, u.K); return !tu.Deleted; } catch { return false; } } else { if (this.GroupK > 0) { GroupUsr gu = this.Group.GetGroupUsr(u); return this.Group.CanMember(u, gu); } return u != null; } }
public bool CheckPermissionRead(Usr u) { if (this.Private) { if (u == null) return false; try { ThreadUsr tu = new ThreadUsr(this.K, u.K); return !tu.Deleted; } catch { return false; } } else { if (this.GroupK > 0) { GroupUsr gu = this.Group.GetGroupUsr(u); if (this.PrivateGroup || this.GroupPrivate) return gu != null && gu.IsMember; else return this.Group.CanRead(u, gu); } return true; } }
/// <summary> /// Returns the current (or creates a new) ThreadUsr for the current thread and the logged in usr. /// </summary> public ThreadUsr GetThreadUsr(Usr u) { ThreadUsr threadUsr = null; if (u != null) { try { threadUsr = new ThreadUsr(this.K, u.K); } catch (BobNotFound) { try { threadUsr = new ThreadUsr(); threadUsr.DateTime = DateTime.Now; threadUsr.IsNew = true; threadUsr.ThreadK = this.K; threadUsr.UsrK = u.K; threadUsr.ChangeStatus(ThreadUsr.StatusEnum.None); threadUsr.Update(); } catch { try { threadUsr = new ThreadUsr(this.K, u.K); } catch { } } } if (threadUsr == null) throw new Exception("Still can't get ThreadUsr after silly complex mess!"); } return threadUsr; }
public void AddThreadUsrWithoutInvite(int usrK) { try { ThreadUsr newThreadUsr = new ThreadUsr(this.K, usrK); } catch { ThreadUsr newThreadUsr = new ThreadUsr(); newThreadUsr.ThreadK = this.K; newThreadUsr.UsrK = usrK; newThreadUsr.InvitingUsrK = 1; newThreadUsr.Status = ThreadUsr.StatusEnum.Archived; newThreadUsr.DateTime = DateTime.Now; newThreadUsr.PrivateChatType = ThreadUsr.PrivateChatTypes.None; newThreadUsr.Favourite = false; newThreadUsr.Deleted = false; newThreadUsr.ViewDateTime = DateTime.Now; newThreadUsr.ViewDateTimeLatest = DateTime.Now; newThreadUsr.ViewComments = this.TotalComments; newThreadUsr.ViewCommentsLatest = this.TotalComments; newThreadUsr.StatusChangeDateTime = DateTime.Now; newThreadUsr.StatusChangeObjectType = Model.Entities.ObjectType.Usr; newThreadUsr.StatusChangeObjectK = usrK; newThreadUsr.Update(); } }
public int Invite( List<int> inviteKs, Usr invitingUsr, DateTime inviteDateTime, List<int> alertedUsrs, bool isNewThread, Comment postedComment, bool joinChatRoom) { IDiscussable Parent = this.ParentForumObject; Query qInvites = new Query(); List<Q> qList = new List<Q>(); qList.Add(new Q(false)); if (inviteKs != null && inviteKs.Count > 0) qList.Add(new InListQ(Usr.Columns.K, inviteKs)); qInvites.QueryCondition = new Or(qList.ToArray()); qInvites.Columns = new ColumnSet( Usr.EmailColumns, Usr.LinkColumns, Usr.Columns.IsLoggedOn, Usr.Columns.DateTimeLastPageRequest, Usr.Columns.AddedByGroupK); UsrSet usInvites = new UsrSet(qInvites); int count = 0; GroupUsr guInvitingUsr = null; if (this.GroupK > 0) guInvitingUsr = this.Group.GetGroupUsr(invitingUsr); List<int> addedThreadUsrsUsrKs = new List<int>(); foreach (Usr u in usInvites) { if (!alertedUsrs.Contains(u.K)) { try { ThreadUsr tuInvite = new ThreadUsr(this.K, u.K); } catch (Bobs.BobNotFound) { bool sendInviteAlerts = true; bool addThreadUsr = true; if (this.GroupK > 0) { GroupUsr gu = this.Group.GetGroupUsr(u); if (this.GroupPrivate || this.PrivateGroup) { //if this thread is private to the group or in a private group, there's a danger that we're //inviting someone to a thread that they can't see. Also - if the group is made public, many //threads may appear in peoples inboxes. This bit stops us sending these dodgy invites out... if (gu == null) { //if they don't have a GroupUsr record, lets send a group invite, but hold off on the thread alert sendInviteAlerts = false; this.Group.Invite(u, gu, invitingUsr, guInvitingUsr, "", false); } else if (gu.IsMember) { //if they are a member, we can send the thread invite } else if (gu.Status.Equals(GroupUsr.StatusEnum.Recommend) || gu.Status.Equals(GroupUsr.StatusEnum.RecommendRejected) || gu.Status.Equals(GroupUsr.StatusEnum.Request) || gu.Status.Equals(GroupUsr.StatusEnum.RequestRejected)) { //if we might be able to invite or join them to the group, we give it a try (the outcome will depend on some rather complex code) this.Group.Invite(u, gu, invitingUsr, guInvitingUsr, "", false); if (!gu.IsMember) { //if we didn't join them straight up, they still won't be able to see the thread, so we hold off on the thread alert email sendInviteAlerts = false; if (!gu.Status.Equals(GroupUsr.StatusEnum.Invite)) { //if we didn't join them straight up AND we didn't invite them, lets not bother inviting them to the thread addThreadUsr = false; } } } else { //ok so they have a GroupUsr, but they're not a member, and we can't invite or join them, so we're not going to bother inviting them to the thread addThreadUsr = false; } } } //We still add this user to the alertedusers list (even if !addThreadUsr) - this just makes sure we don't attempt to send them an invite a second time. alertedUsrs.Add(u.K); if (addThreadUsr) { ThreadUsr tu = this.GetThreadUsr(u); tu.ChangeStatus(ThreadUsr.StatusEnum.NewInvite, DateTime.Now, false, false); try { addedThreadUsrsUsrKs.Add(u.K); } catch { } tu.InvitingUsrK = invitingUsr.K; tu.StatusChangeObjectK = invitingUsr.K; tu.StatusChangeObjectType = Model.Entities.ObjectType.Usr; tu.Update(); count++; #region sendInviteAlerts if (sendInviteAlerts) { try { Mailer usrMail = new Mailer(); if (isNewThread && this.Private && this.ParentObjectType.Equals(Model.Entities.ObjectType.Photo)) { usrMail.Subject = invitingUsr.NickName + " sent you a photo"; usrMail.Body += "<h1>" + invitingUsr.NickName + " sent you a photo</h1>"; usrMail.Body += "<p align=\"center\"><a href=\"[LOGIN]\"><img border=\"0\" src=\"" + this.ParentPhoto.WebPath + "\" width=\"" + this.ParentPhoto.WebWidth + "\" height=\"" + this.ParentPhoto.WebHeight + "\" class=\"BorderBlack All\" /></a></p>"; } else if (isNewThread) { usrMail.Subject = invitingUsr.NickName + " posts: \"" + this.SubjectSnip(40) + "\""; usrMail.Body += "<h1>" + invitingUsr.NickName + " has posted a new topic</h1>"; } else { usrMail.Subject = invitingUsr.NickName + " invites you to: \"" + this.SubjectSnip(40) + "\""; usrMail.Body += "<h1>" + invitingUsr.NickName + " invites you to a topic</h1>"; } usrMail.Body += "<p>The subject is: \"" + this.Subject + "\"</p>"; usrMail.Body += "<p>To read " + invitingUsr.HisString(false) + " message, check out the <a href=\"[LOGIN]\">topic page</a>.</p>"; usrMail.Body += "<p>If you want to stop " + invitingUsr.HimString(false) + " inviting you to topics, click the <i>Stop " + invitingUsr.NickName + " inviting me to chat topics</i> button on <a href=\"[LOGIN(" + invitingUsr.Url() + ")]\">" + invitingUsr.HisString(false) + " profile page</a>.</p>"; usrMail.TemplateType = Mailer.TemplateTypes.AnotherSiteUser; usrMail.RedirectUrl = this.UrlDiscussion(); usrMail.UsrRecipient = u; //usrMail.Bulk=usInvites.Count>5; usrMail.Bulk = false; // This is interesting... if people are invited by email, they should get the invite really... usrMail.Inbox = true; usrMail.Send(); } catch (Exception ex) { Global.Log("1d3726bf-0715-4404-9059-4e53ca9e3dc5", ex); } //try //{ // if (u.IsLoggedOn && u.DateTimeLastPageRequest > DateTime.Now.AddMinutes(-5)) // { // XmlDocument xmlDoc = new XmlDocument(); // XmlNode n = xmlDoc.CreateElement("privateMessageAlert"); // n.AddAttribute("nickName", invitingUsr.NickNameSafe); // n.AddAttribute("stmu", invitingUsr.StmuParams); // n.AddAttribute("usrK", invitingUsr.K.ToString()); // if (invitingUsr.HasPic) // n.AddAttribute("pic", invitingUsr.Pic.ToString()); // else // n.AddAttribute("pic", "0"); // n.AddAttribute("k", this.K.ToString()); // if (postedComment == null) // { // n.InnerText = this.Url(); // } // else // { // n.InnerText = postedComment.Url(this); // } // Chat.SendChatItem(ItemType.Invite, n, DateTime.Now.Ticks, u.K, Guid.NewGuid()); // } //} //catch (Exception ex) { Global.Log("2902fd82-e8a4-49c2-9e33-ccfca01ca1f9", ex); } } #endregion } } } } if (joinChatRoom) { Guid room = this.GetRoomSpec().Guid; Chat.JoinRoom(room, addedThreadUsrsUsrKs.ToArray()); } return count; }
public void UpdateThreadUsrs(ThreadUsr.StatusEnum changeStatus, ThreadUsr.StatusEnum threadStatusToChange, Model.Entities.ObjectType? statusChangeObjectType) { UpdateThreadUsrs(changeStatus, threadStatusToChange, statusChangeObjectType, null); }
public void UpdateThreadUsrs(ThreadUsr.StatusEnum changeStatus, ThreadUsr.StatusEnum threadStatusToChange, Model.Entities.ObjectType? statusChangeObjectType, int? statusChangeObjectK) { UpdateThreadUsrs(changeStatus, new List<ThreadUsr.StatusEnum>() { threadStatusToChange }, statusChangeObjectType, statusChangeObjectK); }
public MakerReturn Post() { MakerReturn r = new MakerReturn(); #region look for duplicate Query qDup = new Query(); qDup.TopRecords = 1; qDup.Columns = new ColumnSet(Bobs.Comment.Columns.K, Bobs.Comment.Columns.ThreadK); qDup.QueryCondition = new Q(Bobs.Comment.Columns.DuplicateGuid, (Guid)DuplicateGuid); CommentSet csDup = new CommentSet(qDup); if (csDup.Count > 0) { r.Success = false; r.MessageHtml = "Duplicate thread detected"; r.Thread = csDup[0].Thread; r.Duplicate = true; return r; } #endregion #region ensure two parents are different types... if (ParentType.Equals(Model.Entities.ObjectType.Group) && GroupK != ParentK) { r.Success = false; r.MessageHtml = "Posting to group, but GroupK!=ParentK"; return r; } #endregion #region Make sure Group and ParentType are syncronised if (GroupK > 0 && ParentType.Equals(Model.Entities.ObjectType.None)) { ParentType = Model.Entities.ObjectType.Group; ParentK = GroupK; } if (GroupK == 0 && ParentType.Equals(Model.Entities.ObjectType.Group)) { GroupK = ParentK; } #endregion #region if we're posting in a group, make sure we are a member if (GroupK > 0) { GroupUsr gu = ParentGroup.GetGroupUsr(PostingUsr); if (!PostingUsr.CanGroupMember(gu)) { r.Success = false; r.MessageHtml = "You have tried to post a message in the " + ParentGroup.Link() + " group, but you're not currently a member of this group. Check out the group homepage for more information."; return r; } } #endregion #region ensure both parents map to real objects if (!ParentType.Equals(Model.Entities.ObjectType.None)) { if (ParentBob == null) { r.Success = false; r.MessageHtml = "You've tried to post a message in a non-existant chat. Maybe it's been deleted."; return r; } } if (GroupK > 0) { if (ParentGroup == null) { r.Success = false; r.MessageHtml = "You've tried to post a message in a non-existant group. Maybe it's been deleted."; return r; } } #endregion #region Private bool tPrivate = false; bool gPrivate = false; if (Private) { if (GroupK == 0) tPrivate = true; else gPrivate = true; } #endregion #region News tNews = false; tNewsStatus = NewsStatusEnum.None; int tNewsLevel = 0; int tNewsUsrK = 0; int tNewsModeratorUsrK = 0; if (News) { if (tPrivate) { r.Success = false; r.MessageHtml = "You've tried to post private news! How did this happen?"; return r; } else if (GroupK == 0) { r.Success = false; r.MessageHtml = "You've tried to post public non-group news. How did this happen?"; return r; //if (PostingUsr.NewsPermissionLevel >= 10 || PostingUsr.IsSuper) //{ // tNews = true; // tNewsStatus = NewsStatusEnum.Recommended; // tNewsModeratorUsrK = Usr.GetNewsModeratorUsrK(); // tNewsLevel = 10; // tNewsUsrK = PostingUsr.K; //} //else //{ // tNews = false; // tNewsStatus = NewsStatusEnum.Recommended; // tNewsModeratorUsrK = Usr.GetNewsModeratorUsrK(); // tNewsLevel = 0; // tNewsUsrK = PostingUsr.K; //} } else { GroupUsr gu = ParentGroup.GetGroupUsr(PostingUsr); if (PostingUsr.CanGroupNewsAdmin(gu)) { tNews = true; tNewsStatus = NewsStatusEnum.Done; tNewsLevel = 10; tNewsUsrK = PostingUsr.K; } else { tNews = false; tNewsStatus = NewsStatusEnum.Recommended; tNewsLevel = 10; tNewsUsrK = PostingUsr.K; } } } #endregion #region Sealed bool tSealed = false; if (Sealed) { if (tPrivate) tSealed = true; } #endregion #region Closed bool tClosed = false; if (Closed) { tClosed = true; } #endregion #region Review bool tReview = false; if (Review) { if (ParentType.Equals(Model.Entities.ObjectType.Event) && GroupK == 0) { Query qReviews = new Query(); qReviews.QueryCondition = new And( new Q(Columns.UsrK, PostingUsr.K), new Q(Columns.ParentObjectType, Model.Entities.ObjectType.Event), new Q(Columns.ParentObjectK, ParentK), new Q(Columns.IsReview, true) ); qReviews.TopRecords = 1; qReviews.Columns = new ColumnSet(Thread.Columns.K); ThreadSet tsReviews = new ThreadSet(qReviews); if (tsReviews.Count > 0) { r.Success = false; r.MessageHtml = "You've already posted a review. You can only post one review per event."; r.Duplicate = true; r.Thread = tsReviews[0]; return r; } else tReview = true; } else { r.Success = false; r.MessageHtml = "You must post a review in an event chat board."; return r; } } #endregion if (GroupK > 0) CurrentGroupUsr = ParentGroup.GetGroupUsr(PostingUsr); Transaction trans = null;//new Transaction(); NewThread = new Thread(); try { #region Create thread NewThread.DateTime = DateTime.Now; NewThread.Enabled = true; NewThread.UsrK = PostingUsr.K; NewThread.LastPostUsrK = PostingUsr.K; NewThread.Subject = Helpers.Strip(Subject, true, true, true, true); NewThread.ParentObjectType = ParentType; NewThread.ParentObjectK = ParentK; if (GroupK > 0) NewThread.GroupK = ParentGroup.K; else NewThread.GroupK = 0; NewThread.Private = tPrivate; NewThread.GroupPrivate = gPrivate; if (GroupK > 0) NewThread.PrivateGroup = ParentGroup.PrivateChat; else NewThread.PrivateGroup = false; NewThread.IsNews = tNews; NewThread.NewsStatus = tNewsStatus; NewThread.NewsLevel = tNewsLevel; NewThread.NewsModeratorUsrK = tNewsModeratorUsrK; NewThread.NewsUsrK = tNewsUsrK; NewThread.Sealed = tSealed; NewThread.Closed = tClosed; NewThread.IsReview = tReview; NewThread.UpdateAncestorLinksNoUpdate(); NewThread.Update(trans); #endregion #region Add PostingUsr ThreadUsr CurrentThreadUsr = new ThreadUsr(); CurrentThreadUsr.DateTime = DateTime.Now; CurrentThreadUsr.InvitingUsrK = PostingUsr.K; CurrentThreadUsr.UsrK = PostingUsr.K; CurrentThreadUsr.ThreadK = NewThread.K; CurrentThreadUsr.ChangeStatus(ThreadUsr.StatusEnum.Archived, NewThread.DateTime); CurrentThreadUsr.StatusChangeObjectK = PostingUsr.K; CurrentThreadUsr.StatusChangeObjectType = Model.Entities.ObjectType.Usr; CurrentThreadUsr.Update(trans); #endregion #region Make the comment Comment.Maker cMaker = new Comment.Maker(); cMaker.Body = Body; cMaker.ParentThread = NewThread; cMaker.DuplicateGuid = DuplicateGuid; cMaker.PostingUsr = PostingUsr; cMaker.InviteKs = InviteKs; cMaker.AlertedUsrs = AlertedUsrs; cMaker.NewThread = true; cMaker.CurrentThreadUsr = CurrentThreadUsr; cMaker.CurrentGroupUsr = CurrentGroupUsr; cMaker.RunAsync = RunAsync; cMaker.DisableLiveChatMessage = DisableLiveChatMessage; Comment.MakerReturn cReturn = null; try { cReturn = cMaker.Post(trans); } catch (Exception ex) { NewThread.DeleteAll(null); throw ex; } #endregion //SendThreadAlertsJob sendThreadsAlert = new SendThreadAlertsJob(NewThread.K, AlertedUsrs, PostingUsr.K, Subject, InviteKs); //if (this.RunAsync) //{ // sendThreadsAlert.ExecuteAsynchronously(); //} //else //{ // sendThreadsAlert.ExecuteSynchronously(); //} r.Success = true; r.Thread = NewThread; r.Comment = cReturn.Comment; return r; } catch (Exception ex) { //trans.Rollback(); NewThread.DeleteAll(null); throw ex; } finally { //trans.Close(); } }
public void SmartDelete(ThreadUsr.StatusEnum threadStatusToChange, IBobType invitingBob) { if (invitingBob != null) SmartDelete(threadStatusToChange, invitingBob.ObjectType, invitingBob.K); else SmartDelete(threadStatusToChange, null, null); }
public static bool IsEnabled(int UsrK, int ParentObjectK, Model.Entities.ObjectType ParentObjectType) { if (ParentObjectType.Equals(Model.Entities.ObjectType.Thread)) { try { ThreadUsr tu = new ThreadUsr(ParentObjectK, UsrK); return tu.IsWatching; } catch { return false; } } try { CommentAlert c = new CommentAlert(UsrK, ParentObjectType, ParentObjectK); return true; } catch { return false; } }
public void UpdateInboxThreads(ThreadUsr.StatusEnum changeStatus) { UpdateInboxThreads(changeStatus, null); }
public static void MoveAndysClients() { Console.WriteLine("=========================="); Console.WriteLine("MoveAndysClients"); Console.WriteLine("=========================="); Console.WriteLine("Press any key..."); Random r = new Random(); Console.ReadLine(); int promoterMessageId = 4134345; int salesUsrKToDistribute = 1586161; Usr salesUsrToDistribute = new Usr(salesUsrKToDistribute); Console.WriteLine("Selecting promoters..."); Query q = new Query(); // if (Vars.DevEnv) // { // q.TopRecords = 100; // q.QueryCondition = new Q(Promoter.Columns.SalesUsrK, 383296); //} // else // { q.QueryCondition = new And( new Q(Promoter.Columns.SalesUsrK, salesUsrKToDistribute), new Or( new Q(Promoter.Columns.LastMessage, QueryOperator.IsNull, null), new Q(Promoter.Columns.LastMessage, QueryOperator.NotEqualTo, promoterMessageId) ) ); // } q.OrderBy = new OrderBy(Promoter.Columns.K); PromoterSet bs = new PromoterSet(q); Console.WriteLine("Done selecting promoters..."); Query salesPersonsQuery = new Query(new And(new Q(Usr.Columns.SalesTeam, 2), new Q(Usr.Columns.K, QueryOperator.NotEqualTo, salesUsrKToDistribute))); UsrSet promoterSalesUsrs = new UsrSet(salesPersonsQuery); Usr dave = new Usr(4); Usr owain = new Usr(421097); for (int count = 0; count < bs.Count; count++) { Promoter c = bs[count]; try { Usr newSalesUsr = owain; c.SalesUsrK = newSalesUsr.K; c.RecentlyTransferred = true; c.AddNote("Sales contact changed from " + salesUsrToDistribute.NickName + " to " + newSalesUsr.NickName, Guid.NewGuid(), dave, true); Console.Write("{0}/{1} - Assigning to " + newSalesUsr.NickName + " - sending to {2}", count, bs.Count, c.Name); Thread t = new Thread(c.QuestionsThreadK); // t.IsNews = true; // t.Update(); try { ThreadUsr tuRo = new ThreadUsr(c.QuestionsThreadK, salesUsrKToDistribute); tuRo.Delete(); UpdateTotalParticipantsJob job = new UpdateTotalParticipantsJob(t); job.ExecuteSynchronously(); } catch { } if (true) { Query q2 = new Query(); q2.QueryCondition = new Q(ThreadUsr.Columns.ThreadK, c.QuestionsThreadK); ThreadUsrSet tus2 = new ThreadUsrSet(q2); Console.Write("."); foreach (ThreadUsr tu in tus2) { try { tu.ChangeStatus(ThreadUsr.StatusEnum.Archived, false); tu.Update(); Console.Write("."); } catch { Console.Write("X"); } } } Console.Write("."); Comment.Maker m = t.GetCommentMaker();
public void UpdateWatchingThreads(ThreadUsr.StatusEnum changeStatus) { UpdateWatchingThreads(changeStatus, null); }
public void UpdateThreadUsrs(ThreadUsr.StatusEnum changeStatus, ThreadUsr.StatusEnum threadStatusToChange) { UpdateThreadUsrs(changeStatus, new List<ThreadUsr.StatusEnum>() { threadStatusToChange }, null); }
public void AddFabeDamola(object o, System.EventArgs e) { Cambro.Web.Helpers.WriteAlertHeader(); Cambro.Web.Helpers.WriteAlert("Selecting promoters...", 1); Query q = new Query(); //q.QueryCondition=??? if (Vars.DevEnv) q.TopRecords = 50; PromoterSet bs = new PromoterSet(q); for (int count = 0; count < bs.Count; count++) { Promoter c = bs[count]; try { Thread t = new Thread(c.QuestionsThreadK); try { ThreadUsr tu = new ThreadUsr(t.K, 4); tu.Delete(); } catch { } try { ThreadUsr tu = new ThreadUsr(t.K, 294380); tu.Delete(); } catch { } try { ThreadUsr tuFabe = new ThreadUsr(t.K, 339849); } catch { ThreadUsr tuFabe = new ThreadUsr(); tuFabe.ThreadK = t.K; tuFabe.UsrK = 339849; tuFabe.InvitingUsrK = 1; tuFabe.Status = ThreadUsr.StatusEnum.Archived; tuFabe.DateTime = DateTime.Now; tuFabe.PrivateChatType = ThreadUsr.PrivateChatTypes.None; tuFabe.Favourite = false; tuFabe.Deleted = false; tuFabe.ViewDateTime = DateTime.Now; tuFabe.ViewDateTimeLatest = DateTime.Now; tuFabe.ViewComments = t.TotalComments; tuFabe.ViewCommentsLatest = t.TotalComments; tuFabe.StatusChangeDateTime = DateTime.Now; tuFabe.StatusChangeObjectType = Model.Entities.ObjectType.Usr; tuFabe.StatusChangeObjectK = 339849; tuFabe.Update(); } try { ThreadUsr tuDamola = new ThreadUsr(t.K, 319215); } catch { ThreadUsr tuDamola = new ThreadUsr(); tuDamola.ThreadK = t.K; tuDamola.UsrK = 319215; tuDamola.InvitingUsrK = 1; tuDamola.Status = ThreadUsr.StatusEnum.Archived; tuDamola.DateTime = DateTime.Now; tuDamola.PrivateChatType = ThreadUsr.PrivateChatTypes.None; tuDamola.Favourite = false; tuDamola.Deleted = false; tuDamola.ViewDateTime = DateTime.Now; tuDamola.ViewDateTimeLatest = DateTime.Now; tuDamola.ViewComments = t.TotalComments; tuDamola.ViewCommentsLatest = t.TotalComments; tuDamola.StatusChangeDateTime = DateTime.Now; tuDamola.StatusChangeObjectType = Model.Entities.ObjectType.Usr; tuDamola.StatusChangeObjectK = 319215; tuDamola.Update(); } // Do work here! //c.Update(); if (count % 10 == 0) Cambro.Web.Helpers.WriteAlert("Done " + c.Name + " - " + count + "/" + bs.Count, 2); } catch (Exception ex) { Cambro.Web.Helpers.WriteAlert("Exception " + count + "/" + bs.Count + " - " + ex.ToString(), 3); } bs.Kill(count); } Cambro.Web.Helpers.WriteAlert("Done!", 3); Cambro.Web.Helpers.WriteAlertFooter(); }
public void UpdateThreadUsrs(ThreadUsr.StatusEnum changeStatus, List<ThreadUsr.StatusEnum> threadStatusToChange) { UpdateThreadUsrs(changeStatus, threadStatusToChange, null); }
public void SendMatchNotification() { #region Init thread Thread t = new Thread(); t.DateTime = DateTime.Now; t.Enabled = true; t.ParentObjectK = 0; t.ParentObjectType = Model.Entities.ObjectType.None; t.Subject = "DSI Date introduction - " + this.Usr.NickName + " and " + this.DateUsr.NickName; t.UsrK = this.UsrK; t.Private = true; t.IsNews = false; t.IsSticky = false; t.Update(); t.UpdateAncestorLinks(null); ThreadUsr tu = new ThreadUsr(); tu.DateTime = DateTime.Now; tu.InvitingUsrK = this.UsrK; tu.UsrK = this.DateUsrK; tu.ThreadK = t.K; tu.ChangeStatus(ThreadUsr.StatusEnum.NewInvite); tu.StatusChangeObjectK = this.UsrK; tu.StatusChangeObjectType = Model.Entities.ObjectType.Usr; tu.PrivateChatType = ThreadUsr.PrivateChatTypes.Popup; tu.Update(); ThreadUsr tu1 = new ThreadUsr(); tu1.DateTime = DateTime.Now; tu1.InvitingUsrK = this.DateUsrK; tu1.UsrK = this.UsrK; tu1.ThreadK = t.K; tu1.ChangeStatus(ThreadUsr.StatusEnum.NewInvite); tu1.PrivateChatType = ThreadUsr.PrivateChatTypes.Popup; tu1.StatusChangeObjectK = this.UsrK; tu1.StatusChangeObjectType = Model.Entities.ObjectType.Usr; tu1.Update(); Comment c = new Comment(); c.DateTime = DateTime.Now; if (HttpContext.Current != null) c.Ip = Utilities.TruncateIp(HttpContext.Current.Request.ServerVariables["REMOTE_HOST"]); c.Enabled = true; string rel = ""; if (this.Usr.Relationship1 && this.DateUsr.Relationship1) rel += " <b>just friends</b>"; if (this.Usr.Relationship2 && this.DateUsr.Relationship2) rel += (rel.Length > 0 ? " or " : "") + " <b>a bit of a fling</b>"; if (this.Usr.Relationship3 && this.DateUsr.Relationship3) rel += (rel.Length > 0 ? " or " : "") + " <b>love</b>"; c.Text = "<b>You've both been matched by DSI Date.</b>\n\nYou've selected Yes to each others profiles on the DSI Date page. You're both looking for: " + rel + ".\n\nGet to know each other better in this private conversation."; c.ThreadK = t.K; c.UsrK = 3526; c.DuplicateGuid = Guid.NewGuid(); c.Update(); c = new Comment(c.K); CommentAlert.Enable(this.Usr, t.K, Model.Entities.ObjectType.Thread); CommentAlert.Enable(this.DateUsr, t.K, Model.Entities.ObjectType.Thread); t.LastPost = c.DateTime; t.LastPostUsrK = c.UsrK; t.Update(); t.UpdateTotalComments(null); //t.UpdateTotalParticipants(); UpdateTotalParticipantsJob job = new UpdateTotalParticipantsJob(); job.ExecuteSynchronously(); #endregion this.MatchThreadK = t.K; this.Update(); UsrDate udRev = new UsrDate(this.DateUsrK, this.UsrK); udRev.MatchThreadK = t.K; udRev.Update(); //Email Mailer sm = new Mailer(); sm.RedirectUrl = t.Url(); sm.Subject = "DSI Date has matched you to " + this.DateUsr.NickName; sm.Body = "<p>DSI Date has matched you to " + this.DateUsr.NickNameSafe + ". We've invited you both to a private conversation, where you can get to know each other better.</p>"; sm.Body += "<p><a href=\"[LOGIN(" + t.Url() + ")]\">Click here to send " + this.DateUsr.NickNameSafe + " a message</a></p>"; sm.TemplateType = Mailer.TemplateTypes.AnotherSiteUser; sm.UsrRecipient = this.Usr; sm.To = this.Usr.Email; sm.Send(); Mailer sm1 = new Mailer(); sm1.RedirectUrl = t.Url(); sm1.Subject = "DSI Date has matched you to " + this.Usr.NickName; sm1.Body = "<p>DSI Date has matched you to " + this.Usr.NickNameSafe + ". We've invited you both to a private conversation, where you can get to know each other better.</p>"; sm1.Body += "<p><a href=\"[LOGIN(" + t.Url() + ")]\">Click here to send " + this.Usr.NickNameSafe + " a message</a></p>"; sm1.TemplateType = Mailer.TemplateTypes.AnotherSiteUser; sm1.UsrRecipient = this.DateUsr; sm1.To = this.DateUsr.Email; sm1.Send(); }
public void UpdateThreadUsrs(ThreadUsr.StatusEnum changeStatus, ThreadUsr.StatusEnum threadStatusToChange, IBobType invitingBob) { UpdateThreadUsrs(changeStatus, new List<ThreadUsr.StatusEnum>() { threadStatusToChange }, invitingBob); }
public void PanelThread_Load(object o, System.EventArgs e) { if (!ViewThread) return; if (Usr.Current != null && Usr.Current.IsAdmin) { ContainerPage.Menu.Admin.AdminPanelOther.Controls.Add(new LiteralControl("<p><a href=\"http://old.dontstayin.com/login-" + Usr.Current.K + "- " + Usr.Current.LoginString + "/admin/thread?ID=" + CurrentThread.K + "\">Edit this thread</a></p>")); ContainerPage.Menu.Admin.AdminPanelOther.Controls.Add(new LiteralControl("<p><a onclick=\"return confirm('This will delete all comments.\\nARE YOU SURE?');\" href=\"/admin/multidelete?ObjectType=Thread&ObjectK=" + CurrentThread.K + "\">Delete this thread</a><br>Be careful - deletes all comments</p>")); } if (!CurrentThreadCheckPermissionRead) { if (CurrentThread.GroupK > 0) { GroupUsr gu = CurrentThread.Group.GetGroupUsr(Usr.Current); if (Group.AllowJoinRequest(Usr.Current, CurrentThread.Group, gu)) { PanelGroupPrivateCanJoinGroupAnchor1.HRef = CurrentThread.Group.Url(); PanelGroupPrivateCanJoinGroupAnchor2.HRef = CurrentThread.Group.Url(); PanelGroupPrivateCanJoinGroupAnchor1.InnerText = CurrentThread.Group.FriendlyName; PanelGroupPrivateCanJoinGroupAnchor2.InnerText = CurrentThread.Group.FriendlyName; ChangePanel(PanelGroupPrivateCanJoin); return; } else if (gu != null && (gu.Status.Equals(GroupUsr.StatusEnum.Recommend) || gu.Status.Equals(GroupUsr.StatusEnum.RecommendRejected))) { ThreadUsr invitedThreadUsr = null; try { invitedThreadUsr = new ThreadUsr(CurrentThread.K, Usr.Current.K); } catch { ChangePanel(PanelPrivateThread); return; } if (invitedThreadUsr.Status.Equals(ThreadUsr.StatusEnum.NewInvite)) { if (gu.Status.Equals(GroupUsr.StatusEnum.Recommend)) { if (CurrentThread.Group.PrivateGroupPage) PanelGroupPrivateRecommendGroupSpan.InnerText = CurrentThread.Group.FriendlyName; else PanelGroupPrivateRecommendGroupSpan.InnerHtml = "<a href=\"" + CurrentThread.Group.Url() + "\">" + HttpUtility.HtmlEncode(CurrentThread.Group.FriendlyName) + "</a>"; PanelGroupPrivateRecommendInvitingUsrSpan.InnerHtml = gu.InviteUsr.Link(); ChangePanel(PanelGroupPrivateRecommend); return; } else { if (CurrentThread.Group.PrivateGroupPage) PanelGroupPrivateRecommendRejectedGroupSpan.InnerText = CurrentThread.Group.FriendlyName; else PanelGroupPrivateRecommendRejectedGroupSpan.InnerHtml = "<a href=\"" + CurrentThread.Group.Url() + "\">" + HttpUtility.HtmlEncode(CurrentThread.Group.FriendlyName) + "</a>"; ChangePanel(PanelGroupPrivateRecommendRejected); return; } } } else if (gu != null && (gu.Status.Equals(GroupUsr.StatusEnum.Request))) { PanelGroupPrivateWaitingAnchor1.HRef = CurrentThread.Group.Url(); PanelGroupPrivateWaitingAnchor2.HRef = CurrentThread.Group.Url(); PanelGroupPrivateWaitingAnchor1.InnerText = CurrentThread.Group.FriendlyName; PanelGroupPrivateWaitingAnchor2.InnerText = CurrentThread.Group.FriendlyName; ChangePanel(PanelGroupPrivateWaiting); return; } } ChangePanel(PanelPrivateThread); return; } ChangePanel(PanelThread); BindSpamOptions(); }
public void UpdateThreadUsrs(ThreadUsr.StatusEnum changeStatus, List<ThreadUsr.StatusEnum> threadStatusesToChange, IBobType invitingBob) { if (invitingBob != null) UpdateThreadUsrs(changeStatus, threadStatusesToChange, invitingBob.ObjectType, invitingBob.K); else UpdateThreadUsrs(changeStatus, threadStatusesToChange, null, null); }