示例#1
0
		public static void Enable(Usr CurrentUsr, int ParentObjectK, Model.Entities.ObjectType ParentObjectType)
		{
			if (ParentObjectType.Equals(Model.Entities.ObjectType.Thread))
			{
				Thread t = new Thread(ParentObjectK);
				bool changed = false;
				if (t.CheckPermissionRead(CurrentUsr))
				{
					ThreadUsr tu = t.GetThreadUsr(CurrentUsr);

					if (!tu.IsWatching)
					{
						tu.ChangeStatus(ThreadUsr.StatusEnum.Archived, true);
						changed = true;
					}

					if (changed)
					{
						UpdateTotalParticipantsJob job = new UpdateTotalParticipantsJob();
						job.ExecuteAsynchronously();
					}
				}
				return;
			}

			try
			{
				CommentAlert c = new CommentAlert(CurrentUsr.K, ParentObjectType, ParentObjectK);
			}
			catch
			{
				CommentAlert c = new CommentAlert();
				c.UsrK = CurrentUsr.K;
				c.ParentObjectK = ParentObjectK;
				c.ParentObjectType = ParentObjectType;
				c.Update();
			}
		}
		public void DoInvites(List<int> usrKs, Usr currentUsr)
		{
			try
			{
				CurrentThread.Invite(
					usrKs,
					currentUsr,
					DateTime.Now,
					new List<int>(),
					false,
					null,
					true);
			}
			catch (Exception ex) { Bobs.Global.Log("36bcfd0e-f9ec-4e91-85eb-df36fac2ffc4 Usr.Current.K=" + currentUsr.K + " ThreadK=" + CurrentThread.K, ex); }

			try
			{
				UpdateTotalParticipantsJob job = new UpdateTotalParticipantsJob(CurrentThread);
				job.ExecuteSynchronously();
			}
			catch (Exception ex) { Bobs.Global.Log("6165c2ba-d60f-4850-871f-002befecb0c6", ex); }
		}
示例#3
0
		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());
						}
					}
				}

			}
		}
示例#4
0
		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();

		}
示例#5
0
		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();
示例#6
0
		private static void UpdateTotalParticipants(Thread newThread)
		{
			try
			{
				UpdateTotalParticipantsJob job = new UpdateTotalParticipantsJob(newThread);
				job.ExecuteSynchronously();
			}
			catch (Exception ex) { Bobs.Global.Log("572d2bb0-bcd8-4e88-a3d3-ab25d00db417", ex); }
			
		}
示例#7
0
		public void FixQuestionsThreadUsrs()
		{
			if (this.QuestionsThreadK > 0 && this.AdminUsrs.Count > 0)
			{
				try
				{
					Thread questionsThread = new Thread(this.QuestionsThreadK);

					Query questionsQuery = new Query(new Q(ThreadUsr.Columns.ThreadK, this.QuestionsThreadK));
					questionsQuery.Columns = new ColumnSet(ThreadUsr.Columns.ThreadK, ThreadUsr.Columns.UsrK);
					ThreadUsrSet threadUsrs = new ThreadUsrSet(questionsQuery);
					UsrSet salesTeam2 = Usr.GetNewPromoterSalesUsrsNameAndK();
					bool removeUsr;
					for (int i = threadUsrs.Count - 1; i >= 0; i--)
					{
						removeUsr = true;
						if (this.SalesUsrK > 0 && this.SalesUsrK == threadUsrs[i].UsrK)
						{
							removeUsr = false;
						}
						else
						{
							if (this.SalesUsrK == 0)
							{
								salesTeam2.Reset();
								foreach (Usr salesUsr in salesTeam2)
								{
									if (threadUsrs[i].UsrK == salesUsr.K)
									{
										removeUsr = false;
										break;
									}
								}
							}
							if (removeUsr)
							{
								this.AdminUsrs.Reset();
								foreach (Usr promoterUsr in this.AdminUsrs)
								{
									if (threadUsrs[i].UsrK == promoterUsr.K)
									{
										removeUsr = false;
										break;
									}
								}
							}
						}
						if (removeUsr)
							threadUsrs[i].Delete();
					}

					if (this.SalesUsrK > 0)
						questionsThread.AddThreadUsrWithoutInvite(this.SalesUsrK);
					else
					{
						salesTeam2.Reset();
						foreach (Usr salesUsr in salesTeam2)
						{
							questionsThread.AddThreadUsrWithoutInvite(salesUsr.K);
						}
					}

					this.AdminUsrs.Reset();
					foreach (Usr promoterUsr in this.AdminUsrs)
					{
						questionsThread.AddThreadUsrWithoutInvite(promoterUsr.K);
					}
					
					UpdateTotalParticipantsJob job = new UpdateTotalParticipantsJob(questionsThread);
					job.ExecuteSynchronously();
				}
				catch(Exception ex)
				{
					Utilities.AdminEmailAlert("Exception occurred in Promoter.FixQuestionsThreadUsrs() for promoter " + this.Name + " (" + this.K.ToString() + ")", 
												"Exception occurred in Promoter.FixQuestionsThreadUsrs() for promoter " + this.Name + " (" + this.K.ToString() + ")", ex, this);
				}
			}
		}
        public void WatchTopic(bool state, string functionArgs)
        {
            string[] ids = GetIds(functionArgs);

            bool response = false;

            foreach (string id in ids)
            {
                Thread t = new Thread(int.Parse(id));
                bool changed = false;
                if (t.CheckPermissionRead(Usr.Current))
                {
                    ThreadUsr tu = t.GetThreadUsr(Usr.Current);
                    if (state)
                    {
                        if (!tu.IsWatching)
                        {
                            tu.ChangeStatus(ThreadUsr.StatusEnum.Archived, true);
                            changed = true;
                        }
                    }
                    else
                    {
                        tu.ChangeStatus(ThreadUsr.StatusEnum.Ignore, true);
                        changed = true;
                    }
					if (changed)
					{
						UpdateTotalParticipantsJob job = new UpdateTotalParticipantsJob(t);
						job.ExecuteAsynchronously();
					}
                    response = tu.IsWatching;
                }
                else
                {
					throw new DsiUserFriendlyException("You don't have permission to watch this thread!");
                }
            }
            SendResponse(response);
            return;
        }