void BindPromoters()
		{
			Query q = new Query();
			q.QueryCondition = new And(
				Promoter.EnabledQ,
				new Or(
					new Q(Promoter.Columns.SalesHold, false),
					new Q(Promoter.Columns.SalesHold, QueryOperator.IsNull, null)
				),
				new Or(
					new Q(Promoter.Columns.SalesNextCall, QueryOperator.LessThan, DateTime.Today.AddDays(1)),
					new Q(Promoter.Columns.SalesNextCall, QueryOperator.IsNull, null)
				),
				new Q(Promoter.Columns.LetterStatus, Promoter.LetterStatusEnum.Posted),
				new StringQueryCondition("(SELECT COUNT(*) FROM [SalesCall] WHERE [SalesCall].[PromoterK]=[Promoter].[K] AND [SalesCall].[IsCall]=1)=0")
			);

			q.OrderBy = new OrderBy(
				new OrderBy(Promoter.Columns.FutureEvents, OrderBy.OrderDirection.Descending),
				new OrderBy(Promoter.Columns.SalesNextCall, OrderBy.OrderDirection.Ascending),
				new OrderBy(Promoter.Columns.DateTimeSignUp, OrderBy.OrderDirection.Ascending));
			PromoterSet ps = new PromoterSet(q);

			PromoterDataGrid.AllowPaging = (ps.Count > PromoterDataGrid.PageSize);
			PromoterDataGrid.DataSource = ps;
			PromoterDataGrid.DataBind();

		}
Exemplo n.º 2
0
		void BindNewPromoters()
		{
			if (true)
			{
				Query q = new Query();
				q.QueryCondition = new And(
					(ContainerPage.Url[0].Equals("all") ? new Q(Promoter.Columns.ClientSector, Promoter.ClientSectorEnum.Promoter) : new Q(true)),
					Promoter.EnabledQ,
					new Q(Promoter.Columns.SalesStatus, Promoter.SalesStatusEnum.New),
					SalesUsrQ,
					new Q(Promoter.Columns.SalesCallCount, 0),
					new Or(
						new Q(Promoter.Columns.SalesHold, false),
						new Q(Promoter.Columns.SalesHold, QueryOperator.IsNull, null)
					)
				);

				q.OrderBy = new OrderBy(Promoter.Columns.DateTimeSignUp, OrderBy.OrderDirection.Ascending);

				PromoterSet ps = new PromoterSet(q);

				NewPromoterDataGrid.AllowPaging = (ps.Count > NewPromoterDataGrid.PageSize);
				NewPromoterDataGrid.DataSource = ps;
				NewPromoterDataGrid.DataBind();

			}
		}
		private void LoadPromotersWithTicketRunsAndUnknownVatStatus()
		{
			Query q = new Query();

			if (this.VatStatusDropDownList.SelectedValue != "")
			{
				if (this.VatStatusDropDownList.SelectedValue == "0")
				{
					q.QueryCondition = new Or(new Q(Promoter.Columns.VatStatus, Promoter.VatStatusEnum.Unknown),
											  new Q(Promoter.Columns.VatStatus, QueryOperator.IsNull, null));
				}
				else
				{
					q.QueryCondition = new Q(Promoter.Columns.VatStatus, Convert.ToInt32(VatStatusDropDownList.SelectedValue));
				}
			}
			q.TableElement = new Join(Promoter.Columns.K, TicketRun.Columns.PromoterK);
			q.Distinct = true;
			q.DistinctColumn = Promoter.Columns.K;
			q.OrderBy = new OrderBy(Promoter.Columns.Name);

			PromoterSet promoters = new PromoterSet(q);

			UnknownPromoterVatStatusGridView.DataSource = promoters;
			UnknownPromoterVatStatusGridView.DataBind();
		}
Exemplo n.º 4
0
		void BindExpired()
		{
			List<Q> queryConditionList = new List<Q>();
			queryConditionList.Add(Promoter.EnabledQ);
			queryConditionList.Add(new Or(new Q(Promoter.Columns.SalesHold, false),
										  new Q(Promoter.Columns.SalesHold, QueryOperator.IsNull, null)));
			queryConditionList.Add(new Q(Promoter.Columns.SalesStatusExpires, QueryOperator.LessThan, DateTime.Now));
			queryConditionList.Add(new Or(new Q(Promoter.Columns.SalesNextCall, QueryOperator.LessThan, DateTime.Now), 
										  new Q(Promoter.Columns.SalesNextCall, QueryOperator.IsNull, null)));
			queryConditionList.Add(new Q(Promoter.Columns.SalesUsrK, Usr.Current.K));
			
			if(this.SectorFilterDropDownList.SelectedValue != "")
				queryConditionList.Add(new Q(Promoter.Columns.ClientSector, Convert.ToInt32(SectorFilterDropDownList.SelectedValue)));
			if(this.SalesEstimateFilterDropDownList.SelectedValue != "")
				queryConditionList.Add(new Q(Promoter.Columns.SalesEstimate, Convert.ToInt32(SalesEstimateFilterDropDownList.SelectedValue)));

			Query q = new Query(new And(queryConditionList.ToArray()));

			q.OrderBy = new OrderBy(
				new OrderBy(Promoter.Columns.SalesNextCall, OrderBy.OrderDirection.Descending),
				new OrderBy(Promoter.Columns.SalesEstimate, OrderBy.OrderDirection.Descending),
				new OrderBy(Promoter.Columns.DateTimeSignUp, OrderBy.OrderDirection.Descending));
			PromoterSet ps = new PromoterSet(q);

			ExpiredDataGrid.AllowPaging = (ps.Count > ExpiredDataGrid.PageSize);
			ExpiredDataGrid.DataSource = ps;
			ExpiredDataGrid.DataBind();
		}
Exemplo n.º 5
0
		void BindCallBacks()
		{
			if (true)
			{
				Query q = new Query();
				q.QueryCondition = new And(
					(ContainerPage.Url[0].Equals("all") ? new Q(Promoter.Columns.ClientSector, Promoter.ClientSectorEnum.Promoter) : new Q(true)),
					Promoter.EnabledQ,
					new Q(Promoter.Columns.SalesStatus, Promoter.SalesStatusEnum.New),
					SalesUsrQ,
					new Or(
						new Q(Promoter.Columns.SalesHold, false),
						new Q(Promoter.Columns.SalesHold, QueryOperator.IsNull, null)
					),
					new Q(Promoter.Columns.SalesNextCall, QueryOperator.LessThan, DateTime.Today.AddDays(1)),
					new Q(Promoter.Columns.SalesCallCount, QueryOperator.NotEqualTo, 0)
				);

				q.OrderBy = Promoter.NewIdleOrder;

				PromoterSet ps = new PromoterSet(q);

				CallBacksDataGrid.AllowPaging = (ps.Count > CallBacksDataGrid.PageSize);
				CallBacksDataGrid.DataSource = ps;
				CallBacksDataGrid.DataBind();
			}
		}
Exemplo n.º 6
0
		public PromoterSet Promoters(ColumnSet cs)
		{
			if (promoters == null || !promotersColumns.Equals(cs))
			{
				Query q = new Query();
				q.NoLock = true;
				q.TableElement = Usr.PromoterJoin;
				q.QueryCondition = new Q(PromoterUsr.Columns.UsrK, this.K);
				q.OrderBy = new OrderBy(Promoter.Columns.Name);
				q.Columns = cs;
				promoters = new PromoterSet(q);
				promotersColumns = cs;
			}
			return promoters;
		}
Exemplo n.º 7
0
		public void DeleteAll(Transaction transaction)
		{
			if (!this.Bob.DbRecordExists)
				return;


			Query qUsrEventGuestlist = new Query();
			qUsrEventGuestlist.QueryCondition = new Q(UsrEventGuestlist.Columns.UsrK, this.K);
			UsrEventGuestlistSet uegs = new UsrEventGuestlistSet(qUsrEventGuestlist);
			foreach (UsrEventGuestlist ueg in uegs)
			{
				ueg.Delete(transaction);
				ueg.Event.UpdateGuestlistCount(transaction);
			}

			//Promoters
			Query PromoterQ = new Query();
			PromoterQ.TableElement = Promoter.UsrJoin;
			PromoterQ.QueryCondition = new Q(Usr.Columns.K, this.K);
			PromoterSet promoters = new PromoterSet(PromoterQ);

			Delete PromoterUsrDelete = new Delete(
				TablesEnum.PromoterUsr,
				new Q(PromoterUsr.Columns.UsrK, this.K)
			);
			PromoterUsrDelete.CommandTimeout = 3600;
			PromoterUsrDelete.Run(transaction);

			foreach (Promoter p in promoters)
			{
				p.AdminUsrs = null;
				if (p.AdminUsrs.Count == 0)
				{
					p.DeleteAll(transaction);
				}
				else if (p.PrimaryUsrK == this.K)
				{
					p.PrimaryUsrK = p.AdminUsrs[0].K;
					p.Update(transaction);
				}
			}

			//UsrPlaceVisit
			Delete UsrPlaceVisitDelete = new Delete(
				TablesEnum.UsrPlaceVisit,
				new Q(UsrPlaceVisit.Columns.UsrK, this.K)
				);
			UsrPlaceVisitDelete.CommandTimeout = 3600;
			UsrPlaceVisitDelete.Run(transaction);

			//UsrEventAttended
			Delete UsrEventAttendedDelete = new Delete(
				TablesEnum.UsrEventAttended,
				new Q(UsrEventAttended.Columns.UsrK, this.K)
				);
			UsrEventAttendedDelete.CommandTimeout = 3600;
			UsrEventAttendedDelete.Run(transaction);

			//UsrPhotoFavourite
			Delete UsrPhotoFavouriteDelete = new Delete(
				TablesEnum.UsrPhotoFavourite,
				new Q(UsrPhotoFavourite.Columns.UsrK, this.K)
				);
			UsrPhotoFavouriteDelete.CommandTimeout = 3600;
			UsrPhotoFavouriteDelete.Run(transaction);

			//UsrPhotoMe
			PhotoSet psMe = this.PhotosMe(new ColumnSet(Photo.Columns.K, Photo.Columns.EventK, Photo.Columns.FirstUsrK, Photo.Columns.UsrCount), 0);
			foreach (Photo p in psMe)
			{
				this.PhotoMe(p, false, transaction);
			}

			//UsrMusicTypeFavourite
			Delete UsrMusicTypeFavouriteDelete = new Delete(
				TablesEnum.UsrMusicTypeFavourite,
				new Q(UsrMusicTypeFavourite.Columns.UsrK, this.K)
				);
			UsrMusicTypeFavouriteDelete.CommandTimeout = 3600;
			UsrMusicTypeFavouriteDelete.Run(transaction);

			//Buddy / Buddy reverse;
			BuddySet bs = new BuddySet(new Query(new Or(new Q(Buddy.Columns.UsrK, this.K), new Q(Buddy.Columns.BuddyUsrK, this.K))));
			foreach (Buddy b in bs)
				b.DeleteAll(transaction);

			//ChatMessageFrom
			//	Delete ChatMessageFromDelete = new Delete(
			//		TablesEnum.ChatMessage,
			//		new Q(ChatMessage.Columns.FromUsrK,this.K)
			//	);
			//	ChatMessageFromDelete.Run(transaction);

			//ChatMessageTo
			//	Delete ChatMessageToDelete = new Delete(
			//		TablesEnum.ChatMessage,
			//		new Q(ChatMessage.Columns.ToUsrK, this.K)
			//	);
			//	ChatMessageToDelete.Run(transaction);

			//UsrDate
			Delete UsrDateDelete = new Delete(
				TablesEnum.UsrDate,
				new Or(new Q(UsrDate.Columns.UsrK, this.K), new Q(UsrDate.Columns.DateUsrK, this.K))
				);
			UsrDateDelete.CommandTimeout = 3600;
			UsrDateDelete.Run(transaction);

			//Owners - Event
			EventSet esOwner = new EventSet(new Query(new Q(Event.Columns.OwnerUsrK, this.K)));
			foreach (Event e in esOwner)
			{
				e.OwnerUsrK = 8;
				e.Update(transaction);
			}

			BrandSet bsOwner = new BrandSet(new Query(new Q(Brand.Columns.OwnerUsrK, this.K)));
			foreach (Brand b in bsOwner)
			{
				b.OwnerUsrK = 8;
				b.Update(transaction);
			}

			//Owners - Venue
			VenueSet vsOwner = new VenueSet(new Query(new Q(Venue.Columns.OwnerUsrK, this.K)));
			foreach (Venue v in vsOwner)
			{
				v.OwnerUsrK = 8;
				v.Update(transaction);
			}

			//Remove EnabledByUsrK in Photos that this usr has enabled
			PhotoSet pEnableds = new PhotoSet(new Query(new Q(Photo.Columns.EnabledByUsrK, this.K)));
			foreach (Photo p in pEnableds)
			{
				p.EnabledByUsrK = 0;
				p.Update(transaction);
			}

			//ThreadUsr
			Delete ThreadUsrDelete = new Delete(
				TablesEnum.ThreadUsr,
				new Or(new Q(ThreadUsr.Columns.UsrK, this.K), new Q(ThreadUsr.Columns.InvitingUsrK, this.K))
				);
			ThreadUsrDelete.CommandTimeout = 3600;
			ThreadUsrDelete.Run(transaction);

			//CommentAlert
			Delete CommentAlertDelete = new Delete(
				TablesEnum.CommentAlert,
				new Q(CommentAlert.Columns.UsrK, this.K)
			);
			CommentAlertDelete.CommandTimeout = 3600;
			CommentAlertDelete.Run(transaction);


			//GroupUsr
			Delete GroupUsrDelete = new Delete(
				TablesEnum.GroupUsr,
				new Q(GroupUsr.Columns.UsrK, this.K)
				);
			GroupUsrDelete.CommandTimeout = 3600;
			GroupUsrDelete.Run(transaction);


			//Threads?
			ThreadSet ts = new ThreadSet(new Query(new Q(Thread.Columns.UsrK, this.K)));
			foreach (Thread t in ts)
				t.DeleteAll(transaction);

			Bobs.Update uLastPostUsrK = new Bobs.Update();
			uLastPostUsrK.Changes.Add(new Assign(Thread.Columns.LastPostUsrK, 0));
			uLastPostUsrK.Table = TablesEnum.Thread;
			uLastPostUsrK.Where = new Q(Thread.Columns.LastPostUsrK, this.K);
			uLastPostUsrK.CommandTimeout = 3600;
			uLastPostUsrK.Run(transaction);

			Bobs.Update uFirstParticipantUsrK = new Bobs.Update();
			uFirstParticipantUsrK.Changes.Add(new Assign(Thread.Columns.FirstParticipantUsrK, 0));
			uFirstParticipantUsrK.Table = TablesEnum.Thread;
			uFirstParticipantUsrK.Where = new Q(Thread.Columns.FirstParticipantUsrK, this.K);
			uFirstParticipantUsrK.CommandTimeout = 3600;
			uFirstParticipantUsrK.Run();

			//Comments?
			CommentSet cs = new CommentSet(new Query(new Q(Comment.Columns.UsrK, this.K)));
			foreach (Comment c in cs)
				c.DeleteAll(transaction);

			//PhotoReview ???
			PhotoReviewSet prs = new PhotoReviewSet(new Query(new Q(PhotoReview.Columns.UsrK, this.K)));
			foreach (PhotoReview pr in prs)
			{
				pr.Delete(transaction);
				pr.Photo.UpdateStats(transaction);
			}

			//Galleries
			GallerySet gs = new GallerySet(new Query(new Q(Gallery.Columns.OwnerUsrK, this.K)));
			foreach (Gallery g in gs)
				g.DeleteAll(transaction);

			//Photos
			PhotoSet ps = new PhotoSet(new Query(new Q(Photo.Columns.UsrK, this.K)));
			foreach (Photo p in ps)
				p.DeleteAll(transaction);

			//Aticles
			ArticleSet ars = new ArticleSet(new Query(new Q(Article.Columns.OwnerUsrK, this.K)));
			foreach (Article a in ars)
				a.DeleteAll(transaction);

			int k = this.K;

			//Usr-AddedByUsrK
			UsrSet usrsAddedByUsr = new UsrSet(new Query(new Q(Usr.Columns.AddedByUsrK, this.K)));
			foreach (Usr u in usrsAddedByUsr)
			{
				u.AddedByUsrK = 0;
				u.Update(transaction);
			}

			Guid oldPic = this.Pic;

			//Usr
			this.Delete(transaction);

			if (oldPic != Guid.Empty)
				Storage.RemoveFromStore(Storage.Stores.Pix, oldPic, "jpg");

		}
		private void GenerateSalesCallsReport(DateTime fromDate, DateTime toDate, DateGrouping dateGrouping, string salesUsrK)
		{
			Page.Validate("");
			if (Page.IsValid)
			{
				this.DateRangeValueLabel.Text = fromDate.ToString("dd/MM/yy") + " to " + toDate.ToString("dd/MM/yy");
				this.DateRangeLabel.Visible = true;
				this.DateRangeValueLabel.Visible = true;

				int startOfWeek = 1;	// Sunday = 0, Monday = 1
				fromDate = new DateTime(fromDate.Year, fromDate.Month, fromDate.Day);
				toDate = new DateTime(toDate.Year, toDate.Month, toDate.Day);

				if (toDate >= fromDate)
				{
					int numberOfDateGroupings = 0;
					if (dateGrouping.Equals(DateGrouping.Daily))
					{
						toDate = new DateTime(toDate.Year, toDate.Month, toDate.Day).AddDays(1);
						numberOfDateGroupings = ((TimeSpan)(toDate - fromDate)).Days;
					}
					else if (dateGrouping.Equals(DateGrouping.Weekly))
					{
						fromDate = Utilities.GetStartOfWeek(fromDate);
						toDate = Utilities.GetEndOfWeek(toDate);
						toDate = new DateTime(toDate.Year, toDate.Month, toDate.Day).AddDays(1);
						numberOfDateGroupings = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(((TimeSpan)(toDate - fromDate)).Days) / 7d));
					}
					else if (dateGrouping.Equals(DateGrouping.Monthly))
					{
						fromDate = Utilities.GetStartOfMonth(fromDate);
						toDate = Utilities.GetEndOfMonth(toDate);
						toDate = new DateTime(toDate.Year, toDate.Month, toDate.Day).AddDays(1);
						numberOfDateGroupings = (toDate.AddDays(-1).Year - fromDate.Year) * 12 + (toDate.AddDays(-1).Month - fromDate.Month) + 1;
					}

					List<UsrDataHolder> selectedSalesUsrs = SalesUsrs;
					if (salesUsrK != "0")
					{
						selectedSalesUsrs = new List<UsrDataHolder>();
						if (salesUsrK.IndexOf("team") == 0)
						{
							UsrSet salesTeam = Usr.GetCurrentSalesUsrsNameAndK(Convert.ToInt32(salesUsrK.Replace("team", "")));
							foreach (Usr salesUsr in salesTeam)
							{
								selectedSalesUsrs.Add(new UsrDataHolder(salesUsr));
							}
						}
						else
						{
							selectedSalesUsrs.Add(SalesUsrs[GetSalesPersonIndexNumber(SalesUsrs, Convert.ToInt32(salesUsrK))]);
						}
					}

					if (selectedSalesUsrs.Count > 0)
					{
						Q salesUsrsQueryCondition = new Q(SalesCall.Columns.UsrK, selectedSalesUsrs[0].K);
						Q invoiceSalesUsrsQueryCondition = new Q(Invoice.Columns.SalesUsrK, selectedSalesUsrs[0].K);
						Q promoterAddedByQueryCondition = new Q(Promoter.Columns.AddedByUsrK, selectedSalesUsrs[0].K);

						for (int i = 1; i < selectedSalesUsrs.Count; i++)
						{
							promoterAddedByQueryCondition = new Or(promoterAddedByQueryCondition,
															 new Q(Promoter.Columns.AddedByUsrK, selectedSalesUsrs[i].K));

							salesUsrsQueryCondition = new Or(salesUsrsQueryCondition,
															 new Q(SalesCall.Columns.UsrK, selectedSalesUsrs[i].K));

							invoiceSalesUsrsQueryCondition = new Or(invoiceSalesUsrsQueryCondition,
																	new Q(Invoice.Columns.SalesUsrK, selectedSalesUsrs[i].K));
						}

						Q salesCallDateRangeQueryCondition = new And(new Q(SalesCall.Columns.IsCall, true),
																	 new Q(SalesCall.Columns.DateTimeStart, QueryOperator.GreaterThanOrEqualTo, fromDate),
																	 new Q(SalesCall.Columns.DateTimeStart, QueryOperator.LessThan, toDate));

						Q promoterDateRangeQueryCondition = new And(
																new Q(Promoter.Columns.AddedMethod, Promoter.AddedMedhods.SalesUser), 
																new Q(Promoter.Columns.DateTimeSignUp, QueryOperator.GreaterThanOrEqualTo, fromDate),
																new Q(Promoter.Columns.DateTimeSignUp, QueryOperator.LessThan, toDate));

						#region Sales Calls: Total Money
						Query totalSalesAmountQuery = new Query(new And(invoiceSalesUsrsQueryCondition,
																		new Q(Invoice.Columns.SalesUsrAmount, QueryOperator.NotEqualTo, 0),
																		new Or(new And(new Q(Invoice.Columns.Type, Invoice.Types.Invoice),
																					   new Q(Invoice.Columns.Paid, true),
																					   new Q(Invoice.Columns.PaidDateTime, QueryOperator.GreaterThanOrEqualTo, fromDate),
																					   new Q(Invoice.Columns.PaidDateTime, QueryOperator.LessThan, toDate),
                                                                                       new Q(Usr.Columns.SalesTeam, QueryOperator.NotEqualTo, Usr.SalesTeams.CorporateSalesTeam)),
                                                                               new And(new Q(Invoice.Columns.Type, Invoice.Types.Invoice),
                                                                                       new Q(Invoice.Columns.TaxDateTime, QueryOperator.GreaterThanOrEqualTo, fromDate),
																					   new Q(Invoice.Columns.TaxDateTime, QueryOperator.LessThan, toDate),
                                                                                       new Q(Usr.Columns.SalesTeam, Usr.SalesTeams.CorporateSalesTeam)),
																			   new And(new Q(Invoice.Columns.Type, Invoice.Types.Credit),
																					   new Q(Invoice.Columns.CreatedDateTime, QueryOperator.GreaterThanOrEqualTo, fromDate),
																					   new Q(Invoice.Columns.CreatedDateTime, QueryOperator.LessThan, toDate))))); 
						
						totalSalesAmountQuery.TableElement = new Join(Invoice.Columns.SalesUsrK, Usr.Columns.K);
						totalSalesAmountQuery.ExtraSelectElements.Add("TotalSales", "SUM(SalesUsrAmount)");
						totalSalesAmountQuery.Columns = new ColumnSet(Invoice.Columns.SalesUsrK);
						if (dateGrouping.Equals(DateGrouping.Daily))
						{
							totalSalesAmountQuery.ExtraSelectElements.Add("Date", "CONVERT(datetime,CONVERT(varchar(2),DAY(IsNULL(CASE WHEN Usr.SalesTeam = " + Convert.ToInt32(Usr.SalesTeams.CorporateSalesTeam).ToString() + " THEN TaxDateTime ELSE PaidDateTime END, CreatedDateTime))) + '/' + CONVERT(varchar(2),MONTH(IsNULL(CASE WHEN Usr.SalesTeam = " + Convert.ToInt32(Usr.SalesTeams.CorporateSalesTeam).ToString() + " THEN TaxDateTime ELSE PaidDateTime END, CreatedDateTime))) + '/' + CONVERT(varchar(4),Year(IsNULL(CASE WHEN Usr.SalesTeam = " + Convert.ToInt32(Usr.SalesTeams.CorporateSalesTeam).ToString() + " THEN TaxDateTime ELSE PaidDateTime END, CreatedDateTime))))");
							totalSalesAmountQuery.OrderBy = new OrderBy("[Usr].[FirstName], YEAR(IsNULL(CASE WHEN Usr.SalesTeam = " + Convert.ToInt32(Usr.SalesTeams.CorporateSalesTeam).ToString() + " THEN TaxDateTime ELSE PaidDateTime END, CreatedDateTime)) desc, MONTH(IsNULL(CASE WHEN Usr.SalesTeam = " + Convert.ToInt32(Usr.SalesTeams.CorporateSalesTeam).ToString() + " THEN TaxDateTime ELSE PaidDateTime END, CreatedDateTime)) desc, DAY(IsNULL(CASE WHEN Usr.SalesTeam = " + Convert.ToInt32(Usr.SalesTeams.CorporateSalesTeam).ToString() + " THEN TaxDateTime ELSE PaidDateTime END, CreatedDateTime)) desc");
							totalSalesAmountQuery.GroupBy = new GroupBy("[Usr].[FirstName], DAY(IsNULL(CASE WHEN Usr.SalesTeam = " + Convert.ToInt32(Usr.SalesTeams.CorporateSalesTeam).ToString() + " THEN TaxDateTime ELSE PaidDateTime END, CreatedDateTime)), MONTH(IsNULL(CASE WHEN Usr.SalesTeam = " + Convert.ToInt32(Usr.SalesTeams.CorporateSalesTeam).ToString() + " THEN TaxDateTime ELSE PaidDateTime END, CreatedDateTime)), YEAR(IsNULL(CASE WHEN Usr.SalesTeam = " + Convert.ToInt32(Usr.SalesTeams.CorporateSalesTeam).ToString() + " THEN TaxDateTime ELSE PaidDateTime END, CreatedDateTime)), [Invoice].[SalesUsrK]");
						}
						else if (dateGrouping.Equals(DateGrouping.Weekly))
						{
							totalSalesAmountQuery.ExtraSelectElements.Add("Date", "CONVERT(dateTime,(CONVERT(varchar(2),DAY(DateAdd(day, -1 * datepart(dw, IsNULL(CASE WHEN Usr.SalesTeam = " + Convert.ToInt32(Usr.SalesTeams.CorporateSalesTeam).ToString() + " THEN TaxDateTime ELSE PaidDateTime END, CreatedDateTime)) + 1, IsNULL(CASE WHEN Usr.SalesTeam = " + Convert.ToInt32(Usr.SalesTeams.CorporateSalesTeam).ToString() + " THEN TaxDateTime ELSE PaidDateTime END, CreatedDateTime)))) + '/' + CONVERT(varchar(2),MONTH(DateAdd(day, -1 * datepart(dw, IsNULL(CASE WHEN Usr.SalesTeam = " + Convert.ToInt32(Usr.SalesTeams.CorporateSalesTeam).ToString() + " THEN TaxDateTime ELSE PaidDateTime END, CreatedDateTime)) + 1, IsNULL(CASE WHEN Usr.SalesTeam = " + Convert.ToInt32(Usr.SalesTeams.CorporateSalesTeam).ToString() + " THEN TaxDateTime ELSE PaidDateTime END, CreatedDateTime)))) + '/' + CONVERT(varchar(4),YEAR(DateAdd(day, -1 * datepart(dw, IsNULL(CASE WHEN Usr.SalesTeam = " + Convert.ToInt32(Usr.SalesTeams.CorporateSalesTeam).ToString() + " THEN TaxDateTime ELSE PaidDateTime END, CreatedDateTime)) + 1, IsNULL(CASE WHEN Usr.SalesTeam = " + Convert.ToInt32(Usr.SalesTeams.CorporateSalesTeam).ToString() + " THEN TaxDateTime ELSE PaidDateTime END, CreatedDateTime))))))");
							totalSalesAmountQuery.OrderBy = new OrderBy("[Usr].[FirstName], CONVERT(dateTime,(CONVERT(varchar(2),DAY(DateAdd(day, -1 * datepart(dw, IsNULL(CASE WHEN Usr.SalesTeam = " + Convert.ToInt32(Usr.SalesTeams.CorporateSalesTeam).ToString() + " THEN TaxDateTime ELSE PaidDateTime END, CreatedDateTime)) + 1, IsNULL(CASE WHEN Usr.SalesTeam = " + Convert.ToInt32(Usr.SalesTeams.CorporateSalesTeam).ToString() + " THEN TaxDateTime ELSE PaidDateTime END, CreatedDateTime)))) + '/' + CONVERT(varchar(2),MONTH(DateAdd(day, -1 * datepart(dw, IsNULL(CASE WHEN Usr.SalesTeam = " + Convert.ToInt32(Usr.SalesTeams.CorporateSalesTeam).ToString() + " THEN TaxDateTime ELSE PaidDateTime END, CreatedDateTime)) + 1, IsNULL(CASE WHEN Usr.SalesTeam = " + Convert.ToInt32(Usr.SalesTeams.CorporateSalesTeam).ToString() + " THEN TaxDateTime ELSE PaidDateTime END, CreatedDateTime)))) + '/' + CONVERT(varchar(4),YEAR(DateAdd(day, -1 * datepart(dw, IsNULL(CASE WHEN Usr.SalesTeam = " + Convert.ToInt32(Usr.SalesTeams.CorporateSalesTeam).ToString() + " THEN TaxDateTime ELSE PaidDateTime END, CreatedDateTime)) + 1, IsNULL(CASE WHEN Usr.SalesTeam = " + Convert.ToInt32(Usr.SalesTeams.CorporateSalesTeam).ToString() + " THEN TaxDateTime ELSE PaidDateTime END, CreatedDateTime)))))) desc");
							totalSalesAmountQuery.GroupBy = new GroupBy("[Usr].[FirstName], CONVERT(dateTime,(CONVERT(varchar(2),DAY(DateAdd(day, -1 * datepart(dw, IsNULL(CASE WHEN Usr.SalesTeam = " + Convert.ToInt32(Usr.SalesTeams.CorporateSalesTeam).ToString() + " THEN TaxDateTime ELSE PaidDateTime END, CreatedDateTime)) + 1, IsNULL(CASE WHEN Usr.SalesTeam = " + Convert.ToInt32(Usr.SalesTeams.CorporateSalesTeam).ToString() + " THEN TaxDateTime ELSE PaidDateTime END, CreatedDateTime)))) + '/' + CONVERT(varchar(2),MONTH(DateAdd(day, -1 * datepart(dw, IsNULL(CASE WHEN Usr.SalesTeam = " + Convert.ToInt32(Usr.SalesTeams.CorporateSalesTeam).ToString() + " THEN TaxDateTime ELSE PaidDateTime END, CreatedDateTime)) + 1, IsNULL(CASE WHEN Usr.SalesTeam = " + Convert.ToInt32(Usr.SalesTeams.CorporateSalesTeam).ToString() + " THEN TaxDateTime ELSE PaidDateTime END, CreatedDateTime)))) + '/' + CONVERT(varchar(4),YEAR(DateAdd(day, -1 * datepart(dw, IsNULL(CASE WHEN Usr.SalesTeam = " + Convert.ToInt32(Usr.SalesTeams.CorporateSalesTeam).ToString() + " THEN TaxDateTime ELSE PaidDateTime END, CreatedDateTime)) + 1, IsNULL(CASE WHEN Usr.SalesTeam = " + Convert.ToInt32(Usr.SalesTeams.CorporateSalesTeam).ToString() + " THEN TaxDateTime ELSE PaidDateTime END, CreatedDateTime)))))), [Invoice].[SalesUsrK]");
						}
						else if (dateGrouping.Equals(DateGrouping.Monthly))
						{
							totalSalesAmountQuery.ExtraSelectElements.Add("Date", "CONVERT(datetime,'1/' + CONVERT(varchar(2),MONTH(IsNULL(CASE WHEN Usr.SalesTeam = " + Convert.ToInt32(Usr.SalesTeams.CorporateSalesTeam).ToString() + " THEN TaxDateTime ELSE PaidDateTime END, CreatedDateTime))) + '/' + CONVERT(varchar(4),Year(IsNULL(CASE WHEN Usr.SalesTeam = " + Convert.ToInt32(Usr.SalesTeams.CorporateSalesTeam).ToString() + " THEN TaxDateTime ELSE PaidDateTime END, CreatedDateTime))))");
							totalSalesAmountQuery.OrderBy = new OrderBy("[Usr].[FirstName], YEAR(IsNULL(CASE WHEN Usr.SalesTeam = " + Convert.ToInt32(Usr.SalesTeams.CorporateSalesTeam).ToString() + " THEN TaxDateTime ELSE PaidDateTime END, CreatedDateTime)) desc, MONTH(IsNULL(CASE WHEN Usr.SalesTeam = " + Convert.ToInt32(Usr.SalesTeams.CorporateSalesTeam).ToString() + " THEN TaxDateTime ELSE PaidDateTime END, CreatedDateTime)) desc");
							totalSalesAmountQuery.GroupBy = new GroupBy("[Usr].[FirstName], MONTH(IsNULL(CASE WHEN Usr.SalesTeam = " + Convert.ToInt32(Usr.SalesTeams.CorporateSalesTeam).ToString() + " THEN TaxDateTime ELSE PaidDateTime END, CreatedDateTime)), YEAR(IsNULL(CASE WHEN Usr.SalesTeam = " + Convert.ToInt32(Usr.SalesTeams.CorporateSalesTeam).ToString() + " THEN TaxDateTime ELSE PaidDateTime END, CreatedDateTime)), [Invoice].[SalesUsrK]");
						}

						InvoiceSet salesInvoices = new InvoiceSet(totalSalesAmountQuery);

						#endregion

						#region Sales Calls: SalesUsrK, Minutes, and Total calls
						Query salesCallMinutesQuery = new Query(new And(salesCallDateRangeQueryCondition,
																		salesUsrsQueryCondition));
						salesCallMinutesQuery.ExtraSelectElements.Add("Minutes", "SUM([SalesCall].[Duration])");
						salesCallMinutesQuery = PopulateSalesCallQuery(salesCallMinutesQuery, dateGrouping, startOfWeek);

						SalesCallSet salesCallsMinutes = new SalesCallSet(salesCallMinutesQuery);
						#endregion

						#region Promoters: New leads
						Query promotersNewLeadsQuery = new Query(new And(promoterDateRangeQueryCondition,
																		  promoterAddedByQueryCondition));
						promotersNewLeadsQuery = PopulatePromotersQuery(promotersNewLeadsQuery, dateGrouping, startOfWeek);
						PromoterSet promotersNewLeads = new PromoterSet(promotersNewLeadsQuery);
						#endregion

						#region Sales Calls: New leads
						Query salesCallNewLeadsQuery = new Query(new And(salesCallDateRangeQueryCondition,
																		  salesUsrsQueryCondition,
																		  new Q(SalesCall.Columns.IsCallToNewLead, true)));
						salesCallNewLeadsQuery = PopulateSalesCallQuery(salesCallNewLeadsQuery, dateGrouping, startOfWeek);
						SalesCallSet salesCallsNewLeads = new SalesCallSet(salesCallNewLeadsQuery);
						#endregion

						#region Sales Calls: Effective
						Query salesCallEffectiveQuery = new Query(new And(salesCallDateRangeQueryCondition,
																		  salesUsrsQueryCondition,
																		  new Q(SalesCall.Columns.Effective, true)));
						salesCallEffectiveQuery = PopulateSalesCallQuery(salesCallEffectiveQuery, dateGrouping, startOfWeek);
						SalesCallSet salesCallsEffective = new SalesCallSet(salesCallEffectiveQuery);
						#endregion

						#region Sales Calls: Cold
						Query salesCallColdQuery = new Query(new And(salesCallDateRangeQueryCondition,
																			  salesUsrsQueryCondition,
																			  new Q(SalesCall.Columns.Type, SalesCall.Types.Cold)));
						salesCallColdQuery = PopulateSalesCallQuery(salesCallColdQuery, dateGrouping, startOfWeek);
						SalesCallSet salesCallsCold = new SalesCallSet(salesCallColdQuery);
						#endregion

						#region Sales Calls: Followup
						Query salesCallFollowupQuery = new Query(new And(salesCallDateRangeQueryCondition,
																		salesUsrsQueryCondition,
																		new Q(SalesCall.Columns.Type, SalesCall.Types.ProactiveFollowUp)));
						salesCallFollowupQuery = PopulateSalesCallQuery(salesCallFollowupQuery, dateGrouping, startOfWeek);
						SalesCallSet salesCallsFollowup = new SalesCallSet(salesCallFollowupQuery);
						#endregion

						#region Sales Calls: Active
						Query salesCallActiveQuery = new Query(new And(salesCallDateRangeQueryCondition,
																	  salesUsrsQueryCondition,
																	  new Q(SalesCall.Columns.Type, SalesCall.Types.Active)));
						salesCallActiveQuery = PopulateSalesCallQuery(salesCallActiveQuery, dateGrouping, startOfWeek);
						SalesCallSet salesCallsActive = new SalesCallSet(salesCallActiveQuery);
						#endregion

						#region Table
						this.SalesStatsResultsTable.Visible = false;
						this.SalesCallsResultsTable.Visible = true;
						HtmlTable salesCallsTable = this.SalesCallsResultsTable;
						salesCallsTable.Rows.Clear();
						#endregion

						#region Header Rows
						HtmlTableRow headerRow1 = new HtmlTableRow();

						headerRow1.Attributes.Add("class", "dataGrid1stHeader");
						salesCallsTable.Rows.Add(headerRow1);
						HtmlTableCell[] header1TableCells = new HtmlTableCell[6];
						header1TableCells[0] = new HtmlTableCell("td");
						header1TableCells[0].RowSpan = 2;
						header1TableCells[0].InnerHtml = "Date";

						for (int i = 1; i < header1TableCells.Length; i++)
						{
							header1TableCells[i] = new HtmlTableCell("th");
							header1TableCells[i].ColSpan = selectedSalesUsrs.Count;
							header1TableCells[i].Align = "center";
							header1TableCells[i].Attributes.Add("class", "dataGridColumnDivider");
						}

						header1TableCells[1].InnerHtml = "Total sales";
						
						header1TableCells[2].InnerHtml = "<b>Total calls</b>";
						header1TableCells[3].InnerHtml = "Minutes per call";
						
						header1TableCells[4].InnerHtml = "<b>New leads</b>";
						header1TableCells[5].InnerHtml = "Calls&nbsp;to new&nbsp;leads";

						//header1TableCells[4].InnerHtml = "<nobr>Effective calls</nobr>";
						//header1TableCells[7].InnerHtml = "<nobr>Cold (%)</nobr>";
						//header1TableCells[8].InnerHtml = "<nobr>Followup (%)</nobr>";
						//header1TableCells[9].InnerHtml = "<nobr>Active (%)</nobr>";

						foreach (HtmlTableCell tc in header1TableCells)
							headerRow1.Cells.Add(tc);

						HtmlTableRow headerRow2 = new HtmlTableRow();
						headerRow2.Attributes.Add("class", "dataGrid2ndHeader");
						salesCallsTable.Rows.Add(headerRow2);

						HtmlTableCell[] header2TableCells = new HtmlTableCell[selectedSalesUsrs.Count * (header1TableCells.Length - 1)];
						for (int i = 0; i < header2TableCells.Length; i++)
						{
							header2TableCells[i] = new HtmlTableCell("th");
							header2TableCells[i].InnerHtml = "<b>" + selectedSalesUsrs[i % selectedSalesUsrs.Count].FirstName + "</b>";
							header2TableCells[i].Align = "right";
							header2TableCells[i].Width = "10";


							if (i % selectedSalesUsrs.Count == 0)
							{
								header2TableCells[i].Attributes.Add("class", "dataGridColumnDivider");
							}

							headerRow2.Cells.Add(header2TableCells[i]);
						}
						#endregion

						#region Data Rows
						HtmlTableCell[,] dataTableCells = new HtmlTableCell[numberOfDateGroupings, selectedSalesUsrs.Count * (header1TableCells.Length - 1) + 1];
						for (int i = 0; i < numberOfDateGroupings; i++)
						{
							dataTableCells[i, 0] = new HtmlTableCell();
							dataTableCells[i, 0].InnerHtml = "<nobr>";
							if (dateGrouping.Equals(DateGrouping.Daily))
								dataTableCells[i, 0].InnerHtml += String.Format("{0:ddd'&nbsp;'d'&nbsp;'MMM}", toDate.AddDays(-1 * (i + 1)));
							else if (dateGrouping.Equals(DateGrouping.Weekly))
							{
								dataTableCells[i, 0].InnerHtml += toDate.AddDays(-7 * (i + 1)).ToString("dd/MM/yy") + "&nbsp;-&nbsp;" + toDate.AddDays(-7 * (i + 1) + 6).ToString("dd/MM/yy");
							}
							else if (dateGrouping.Equals(DateGrouping.Monthly))
							{
								dataTableCells[i, 0].InnerHtml += String.Format("{0:MMM'&nbsp;'yy}", toDate.AddMonths(-1 * (i + 1)));
							}
							dataTableCells[i, 0].InnerHtml += "</nobr>";
						}

						foreach (Invoice salesInvoice in salesInvoices)
						{
							try
							{
								int i = GetSalesPersonIndexNumber(selectedSalesUsrs, salesInvoice.SalesUsrK);

								int dateGroupingsFromTop = 0;
								if (dateGrouping.Equals(DateGrouping.Daily))
									dateGroupingsFromTop = ((TimeSpan)(toDate - ((DateTime)salesInvoice.ExtraSelectElements["Date"]))).Days;
								else if (dateGrouping.Equals(DateGrouping.Weekly))
									dateGroupingsFromTop = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(((TimeSpan)(toDate - ((DateTime)salesInvoice.ExtraSelectElements["Date"]))).Days) / 7d));
								else if (dateGrouping.Equals(DateGrouping.Monthly))
								{
									dateGroupingsFromTop = (toDate.AddDays(-1).Year - ((DateTime)salesInvoice.ExtraSelectElements["Date"]).Year) * 12 + (toDate.AddDays(-1).Month - ((DateTime)salesInvoice.ExtraSelectElements["Date"]).Month) + 1;
								}

								dataTableCells[dateGroupingsFromTop - 1, i + 1] = new HtmlTableCell();
Exemplo n.º 9
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());
						}
					}
				}

			}
		}
Exemplo n.º 10
0
		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();
		}
Exemplo n.º 11
0
		public void SortPromoterNotes(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
				{
					if (c.ManualNote.Length > 0)
					{
						SalesCall scNote = new SalesCall();
						scNote.DuplicateGuid = Guid.NewGuid();
						scNote.UsrK = Usr.Current.K;
						scNote.PromoterK = c.K;
						scNote.DateTimeStart = DateTime.Now;
						scNote.DateTimeEnd = scNote.DateTimeStart;
						scNote.Duration = 0;
						scNote.Dismissed = true;
						scNote.InProgress = false;
						scNote.Direction = SalesCall.Directions.Outgoing;
						if (c.EffectiveSalesStatus.Equals(Promoter.SalesStatusEnum.Active))
							scNote.Type = SalesCall.Types.Active;
						else if (c.EffectiveSalesStatus.Equals(Promoter.SalesStatusEnum.Proactive))
							scNote.Type = SalesCall.Types.ProactiveFollowUp;
						else
							scNote.Type = SalesCall.Types.Cold;
						scNote.IsCall = false;
						scNote.Note = c.ManualNote;
						scNote.Effective = true;
						scNote.Update();
					}
					// Do work here!
					//c.Update();

					if (count % 10 == 0)
						Cambro.Web.Helpers.WriteAlert("Done " + 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();
		}
Exemplo n.º 12
0
		public void UpdatePromoterRandom(object o, System.EventArgs e)
		{
			Cambro.Web.Helpers.WriteAlertHeader();

			Cambro.Web.Helpers.WriteAlert("Selecting Promoters...", 1);
			Query q = new Query();
			PromoterSet bs = new PromoterSet(q);
			Random r = new Random();
			for (int count = 0; count < bs.Count; count++)
			{
				Promoter c = bs[count];

				try
				{
					// Do work here!
					c.OfferType = Promoter.OfferTypes.None;
					c.AccessCodeRandom = r.Next(1000, 9999).ToString() + r.Next(1000, 9999).ToString();
					c.Update();

					if (count % 10 == 0)
						Cambro.Web.Helpers.WriteAlert("Done " + 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();
		}
Exemplo n.º 13
0
		public static void SendPromoterEmailFromJason(string[] args)
		{

			Console.WriteLine("============");
			Console.WriteLine("SendPromoterEmailFromJason SPECIAL");
			Console.WriteLine("============");

			if (args.Length == 0)
			{
				Console.WriteLine("Press any key...");
				Console.ReadLine();
			}

			Q loadBalancer = args.Length == 2 ? new StringQueryCondition(" ([Promoter].[K] % " + int.Parse(args[1]).ToString() + " = " + ((int)(int.Parse(args[0]) - 1)).ToString() + ") ") : new Q(true);

			Console.WriteLine("Selecting...", 1);
			Query q = new Query();
			q.QueryCondition = new And(
				new Q(Promoter.Columns.Status, QueryOperator.NotEqualTo, Promoter.StatusEnum.Disabled),
				loadBalancer
			);
			if (Vars.DevEnv)
				q.TopRecords = 10;
			PromoterSet bs = new PromoterSet(q);
			Console.WriteLine("Found " + bs.Count.ToString("#,##0") + " item(s)...", 1);
			List<string> emails = new List<string>();
			for (int count = 0; count < bs.Count; count++)
			{
				Promoter c = bs[count];

				try
				{

					foreach (Usr u in c.AdminUsrs)
					{
						if (!emails.Contains(u.Email) && !u.EmailHold)
							emails.Add(u.Email);
					}

					if (count % 10 == 0)
						Console.WriteLine("Done " + count + "/" + bs.Count, 2);

				}
				catch (Exception ex)
				{
					Console.WriteLine("Exception " + count + "/" + bs.Count + " - " + ex.ToString(), 3);
				}

				bs.Kill(count);

			}
			Console.WriteLine("Starting to send {0} emails...", emails.Count.ToString("#,##0"));

			System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient();
			client.Host = Common.Properties.GetDefaultSmtpServer();
			int count1 = 0;
			foreach (string email in emails)
			{
				try
				{




					string body = @"Hello Promoters,

As you will have seen if you have been on the site this last week, we have gone live with our Facebook Connect which uses login details from Facebook to create accounts for new Don't Stay In users.

This now means that new members can join DSI in about 3 or 4 clicks, and the early signs are looking good with DSI getting a higher percentage of visitors now signing up.

But now something for you, the promoters who are taking the time to post events on DSI...

From now, when DSI clubbers add their names as attending your DSI events, we'll drop a little message on their facebook wall to say that they're attending and link it back to the DSI event page. This has never been more of an opportunity for you to seal the ticket sale by adding a few ticket allocations to your DSI event when you set it up.

We'll be back soon with more feature news as the Facebook Connect project begins to unfold even more.

 

-- 
Jason Willans
Senior Account Manager
Direct Line: +44 (0) 207 0990 207

DontStayIn 
Development Hell Ltd.
90-92 Pentonville Rd
London
N1 9HS
";
					string subject = "Promoter notice - A new feature for your event promotions";
					//string subject = "DSI Promoter Roundup - February 2011";
					string from = "*****@*****.**";

					System.Net.Mail.MailMessage m = new System.Net.Mail.MailMessage();
					m.Subject = subject;
					m.Body = body;//.Replace("\n", "\n\r");
					m.From = new System.Net.Mail.MailAddress(from);
					if (Vars.DevEnv)
						m.To.Add("*****@*****.**");
					else
						m.To.Add(email);

					m.IsBodyHtml = false;

					client.Send(m);

					if (count1 % 10 == 0)
						Console.WriteLine("Done " + count1 + "/" + bs.Count, 2);
				}
				catch (Exception ex)
				{
					Console.WriteLine("Exception " + count1 + "/" + emails.Count + " - " + ex.ToString(), 3);
				}
				count1++;
			}

			Console.WriteLine("All done!");
			Console.ReadLine();
		}
Exemplo n.º 14
0
		protected void Page_Load(object sender, EventArgs e)
		{
			int BagMaxWeight = 10000;
			System.Collections.Generic.Dictionary<string, int> Weight = new System.Collections.Generic.Dictionary<string, int>();
			Weight["A"] = 100;
			Weight["B"] = 500;
			Weight["C"] = 500;
			Weight["D"] = 500;
			Weight["E"] = 500;
			Weight["F"] = 20;

			int ItemsA = 0, ItemsB = 0, ItemsC = 0, ItemsD = 0, ItemsE = 0, ItemsF = 0;

			Usr.KickUserIfNotAdmin("Only admin!");
			Query q = new Query();
			q.QueryCondition = new Or(
				new Q(Usr.Columns.CardStatus, Usr.CardStatusEnum.New),
				new Q(Usr.Columns.CardStatus, Usr.CardStatusEnum.PrintingWelcomePack),
				new Q(Usr.Columns.CardStatus, Usr.CardStatusEnum.NeedCards),
				new Q(Usr.Columns.CardStatus, Usr.CardStatusEnum.PrintingRefill)
			);
			q.TableElement = new Join(Usr.Columns.AddressCountryK, Country.Columns.K);
			q.OrderBy = new OrderBy(
				new OrderBy("(CASE [Country].[PostageZone] WHEN 0 THEN 1 WHEN 4 THEN 2 WHEN 3 THEN 3 WHEN 1 THEN 4 WHEN 2 THEN 5 END)"),
				new OrderBy("(CASE [Usr].[CardStatus] WHEN 3 THEN 1 WHEN 5 THEN 2 WHEN 4 THEN 3 WHEN 1 THEN 4 WHEN 6 THEN 5 WHEN 2 THEN 6 WHEN 0 THEN 7 END)"),
				new OrderBy(Usr.Columns.SpottingsTotal, OrderBy.OrderDirection.Descending)
			);
			UsrSet us = new UsrSet(q);

			//Query qMediaPacks = new Query();
			//qMediaPacks.QueryCondition = new Q(Promoter.Columns.LetterStatus, Promoter.LetterStatusEnum.Printing);
			//qMediaPacks.ReturnCountOnly = true;
			//PromoterSet psMediaPacks = new PromoterSet(qMediaPacks);
			Query qPromoterLetters = new Query();
			qPromoterLetters.QueryCondition = new Q(Promoter.Columns.LetterStatus, Promoter.LetterStatusEnum.Printing);
			qPromoterLetters.ReturnCountOnly = true;
			PromoterSet psPromoterLetters = new PromoterSet(qPromoterLetters);
			ItemsF = psPromoterLetters.Count;


			int totalLabels = us.Count + ItemsF;

			StringBuilder s = new StringBuilder();
			Usr u;
			s.Append("<body topmargin=\"0\" bottommargin=\"0\" leftmargin=\"0\" rightmargin=\"0\">");
			for (int count = 0; count < totalLabels || (count % 8) != 0; count++)
			{
				bool isBlank = false;

				if (count < us.Count)
					u = us[count];
				else
				{
					u = null;
					isBlank = count < (us.Count + ItemsF);
				}


				if (count % 2 == 0 && count>0)
				{
					s.Append("</tr>");
				}

				if (count % 8 == 0)
				{
					if (count > 0)
						s.Append("</table></div>\n");

					s.Append("<div style=\"page-break-after:always;\"><table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" height=\"100%\">");
				}

				if (count % 2 == 0)
				{
					s.Append("\n<tr>");
				}

				string padding = "";
				if (count % 2 != 0)
				{
					padding = " style=\"padding-left:10px;\"";
				}


				if (isBlank)
				{
					s.Append("<td width=\"50%\" height=\"25%\"" + padding + ">");
					s.Append("<table width=\"95%\" height=\"90%\" style=\"margin:10px;\">");
					s.Append("<tr>");
					s.Append("<td rowspan=\"2\" valign=\"bottom\">");
					s.Append("&nbsp;");
					s.Append("</td>");
					s.Append("<td align=\"right\" valign=\"top\" colspan=\"2\" style=\"padding-top:10px;\">");
					s.Append("<img src=\"/gfx/mail-1st-class-dh.gif\" width=\"135\"/>");
					s.Append("</td>");
					s.Append("</tr>");
					s.Append("<tr>");
					s.Append("<td align=\"center\" valign=\"bottom\" width=\"75\">");
					s.Append("<img src=\"/gfx/mail-format-envelope-a5.gif\" width=\"75\"/>");
					s.Append("</td>");
					s.Append("<td align=\"center\" valign=\"bottom\" width=\"75\">");
					s.Append("<img src=\"/gfx/mail-symbol-f.gif\" width=\"75\"/>");
					s.Append("</td>");
					s.Append("</tr>");
					s.Append("</table>");
					s.Append("</td>");
				}
				else if (u == null)
				{
					s.Append("<td width=\"50%\" height=\"25%\"" + padding + "></td>");
				}
				else
				{
					s.Append("<td width=\"50%\" height=\"25%\"" + padding + ">");
					s.Append("<table width=\"95%\" height=\"90%\" style=\"margin:10px;\">");
					s.Append("<tr>");
					s.Append("<td rowspan=\"2\" valign=\"bottom\">");
					#region Address
					s.Append(u.FirstName);
					s.Append(" ");
					s.Append(u.LastName);
					s.Append("<br>");
					s.Append(u.AddressStreet);
					s.Append("<br>");
					if (u.AddressArea.Length > 0)
					{
						s.Append(u.AddressArea);
						s.Append("<br>");
					}
					s.Append(u.AddressTown.ToUpper());
					s.Append("<br>");
					s.Append(u.AddressCounty.ToUpper());
					s.Append("<br>");
					s.Append(u.AddressPostcode.ToUpper());
					s.Append("<br>");
					s.Append(u.AddressCountry.Name.ToUpper());
					s.Append("<br>");
					#endregion
					s.Append("</td>");
					s.Append("<td align=\"right\" valign=\"top\" colspan=\"2\" style=\"padding-top:10px;\">");
					#region Stamp PPI
					//Removed 2008-12-11 - now we only send large packs.
					//if (u.AddressCountryK == 224 && (u.CardStatus.Equals(Usr.CardStatusEnum.New) || u.CardStatus.Equals(Usr.CardStatusEnum.PrintingWelcomePack)))
					//{
					//    //2nd class stamp
					//    s.Append("<img src=\"/gfx/mail-2nd-class-dh.gif\" width=\"135\"/>");
					//}
					//else
					if (u.AddressCountryK == 224)
					{
						//1st class stamp
						//s.Append("<img src=\"/gfx/mail-1st-class-dh.gif\" width=\"135\"/>");

						//2nd class stamp
						s.Append("<img src=\"/gfx/mail-2nd-class-dh.gif\" width=\"135\"/>");
					}
					else
					{
						//1st class stamp with airmail mark
						s.Append("<img src=\"/gfx/mail-1st-class-airmail-dh.gif\" width=\"135\"/>");
					}
					#endregion
					s.Append("</td>");
					s.Append("</tr>");
					s.Append("<tr>");
					s.Append("<td align=\"center\" valign=\"bottom\" width=\"75\">");
					#region Packaging format symbol
					//Removed 2008-12-11 - now we only send large packs.
					//if (u.AddressCountryK == 224 && (u.CardStatus.Equals(Usr.CardStatusEnum.New) || u.CardStatus.Equals(Usr.CardStatusEnum.PrintingWelcomePack)))
					//{
					//	//envelope
					//	s.Append("<img src=\"/gfx/mail-format-envelope-a5.gif\" width=\"75\"/><br>100g");
					//}
					//else
					//{
						//box
						s.Append("<img src=\"/gfx/mail-format-box.gif\" width=\"75\"/><br>500g");
					//}
					#endregion
					s.Append("</td>");
					s.Append("<td align=\"center\" valign=\"bottom\" width=\"75\">");
					#region Mail seperation symbol
					//Removed 2008-12-11 - now we only send large packs.
					//if (u.AddressCountryK == 224 && (u.CardStatus.Equals(Usr.CardStatusEnum.New) || u.CardStatus.Equals(Usr.CardStatusEnum.PrintingWelcomePack)))
					//{
					//	//symbol A
					//	ItemsA++;
					//	s.Append("<img src=\"/gfx/mail-symbol-a.gif\" width=\"75\"/>");
					//}
					//else 
					if (u.AddressCountryK == 224)
					{
						//symbol B
						ItemsB++;
						s.Append("<img src=\"/gfx/mail-symbol-b.gif\" width=\"75\"/>");
					}
					else if (u.AddressCountry.PostageZone.Equals(Country.PostageZones.WesternEurope))
					{
						//symbol C
						ItemsC++;
						s.Append("<img src=\"/gfx/mail-symbol-c.gif\" width=\"75\"/>");
					}
					else if (u.AddressCountry.PostageZone.Equals(Country.PostageZones.RestOfEurope))
					{
						//symbol D
						ItemsD++;
						s.Append("<img src=\"/gfx/mail-symbol-d.gif\" width=\"75\"/>");
					}
					else if (u.AddressCountry.PostageZone.Equals(Country.PostageZones.World1) || u.AddressCountry.PostageZone.Equals(Country.PostageZones.World2))
					{
						//symbol E
						ItemsE++;
						s.Append("<img src=\"/gfx/mail-symbol-e.gif\" width=\"75\"/>");
					}
					#endregion
					s.Append("<br>&nbsp;</td>");
					s.Append("</tr>");
					s.Append("</table>");
					s.Append("</td>");

					if (u.CardStatus.Equals(Usr.CardStatusEnum.New))
						u.CardStatus = Usr.CardStatusEnum.PrintingWelcomePack;
					else if (u.CardStatus.Equals(Usr.CardStatusEnum.NeedCards))
						u.CardStatus = Usr.CardStatusEnum.PrintingRefill;
					u.Update();
				}
			}
			s.Append("</tr></table></div>");
			
			int BagsA = (int)Math.Ceiling(ItemsA * (double)Weight["A"] / (double)BagMaxWeight);
			int BagsB = (int)Math.Ceiling(ItemsB * (double)Weight["B"] / (double)BagMaxWeight);
			int BagsC = (int)Math.Ceiling(ItemsC * (double)Weight["C"] / (double)BagMaxWeight);
			int BagsD = (int)Math.Ceiling(ItemsD * (double)Weight["D"] / (double)BagMaxWeight);
			int BagsE = (int)Math.Ceiling(ItemsE * (double)Weight["E"] / (double)BagMaxWeight);
			int BagsF = (int)Math.Ceiling(ItemsF * (double)Weight["F"] / (double)BagMaxWeight);

			s.Append("<div style=\"font-size:30px\">");
			s.Append("<p style=\"margin-bottom:60px;\"><img src=\"/gfx/mail-symbol-a.gif\" width=\"75\" align=\"middle\"/><img src=\"/gfx/mail-format-envelope-a5.gif\" width=\"70\" align=\"middle\" style=\"margin-right:30px;\"/> " + ItemsA.ToString() + " item" + (ItemsA == 1 ? "" : "s") + " = " + BagsA.ToString() + " bag" + (BagsA == 1 ? "" : "s") + "</p>");
			s.Append("<p style=\"margin-bottom:60px;\"><img src=\"/gfx/mail-symbol-b.gif\" width=\"75\" align=\"middle\"/><img src=\"/gfx/mail-format-box.gif\" width=\"70\" align=\"middle\" style=\"margin-right:30px;\"/> " + ItemsB.ToString() + " item" + (ItemsB == 1 ? "" : "s") + " = " + BagsB.ToString() + " bag" + (BagsB == 1 ? "" : "s") + "</p>");
			s.Append("<p style=\"margin-bottom:60px;\"><img src=\"/gfx/mail-symbol-c.gif\" width=\"75\" align=\"middle\"/><img src=\"/gfx/mail-format-box.gif\" width=\"70\" align=\"middle\" style=\"margin-right:30px;\"/> " + ItemsC.ToString() + " item" + (ItemsC == 1 ? "" : "s") + " = " + BagsC.ToString() + " bag" + (BagsC == 1 ? "" : "s") + "</p>");
			s.Append("<p style=\"margin-bottom:60px;\"><img src=\"/gfx/mail-symbol-d.gif\" width=\"75\" align=\"middle\"/><img src=\"/gfx/mail-format-box.gif\" width=\"70\" align=\"middle\" style=\"margin-right:30px;\"/> " + ItemsD.ToString() + " item" + (ItemsD == 1 ? "" : "s") + " = " + BagsD.ToString() + " bag" + (BagsD == 1 ? "" : "s") + "</p>");
			s.Append("<p style=\"margin-bottom:60px;\"><img src=\"/gfx/mail-symbol-e.gif\" width=\"75\" align=\"middle\"/><img src=\"/gfx/mail-format-box.gif\" width=\"70\" align=\"middle\" style=\"margin-right:30px;\"/> " + ItemsE.ToString() + " item" + (ItemsE == 1 ? "" : "s") + " = " + BagsE.ToString() + " bag" + (BagsE == 1 ? "" : "s") + "</p>");
			s.Append("<p style=\"margin-bottom:60px;\"><img src=\"/gfx/mail-symbol-f.gif\" width=\"75\" align=\"middle\"/><img src=\"/gfx/mail-format-envelope-a4.gif\" width=\"70\" align=\"middle\" style=\"margin-right:30px;\"/> " + ItemsF.ToString() + " item" + (ItemsF == 1 ? "" : "s") + " = " + BagsF.ToString() + " bag" + (BagsF == 1 ? "" : "s") + "</p>");
			s.Append("</div>");
			s.Append("</body>");
			
			Response.Clear();
			Response.Write(s.ToString());
			Response.Flush();
			Response.End();
		}
Exemplo n.º 15
0
		public void DaveIgnore(object o, System.EventArgs e)
		{
			Usr Dave = new Usr(4);
			Cambro.Web.Helpers.WriteAlertHeader();

			Cambro.Web.Helpers.WriteAlert("Selecting...", 1);
			Query q = new Query();
			if (Vars.DevEnv)
				q.TopRecords = 50;
			PromoterSet bs = new PromoterSet(q);
			for (int count = 0; count < bs.Count; count++)
			{
				Promoter p = bs[count];

				// Do work here!
				try
				{
					Thread t = new Thread(p.QuestionsThreadK);

					ThreadUsr tu = t.GetThreadUsr(Dave);
					tu.ChangeStatus(ThreadUsr.StatusEnum.Ignore, DateTime.Now, true, true);
					if (count % 100 == 0)
						Cambro.Web.Helpers.WriteAlert("Done " + count + "/" + bs.Count + " - " + p.UrlName, 2);
				}
				catch
				{
					Cambro.Web.Helpers.WriteAlert("Done " + count + "/" + bs.Count + " - EXCEPTION! " + p.UrlName, 3);
				}

				bs.Kill(count);

			}
			Cambro.Web.Helpers.WriteAlert("Done!", 4);
			Cambro.Web.Helpers.WriteAlertFooter("/admin/promoterpm");
		}
Exemplo n.º 16
0
		public void SendComment(object o, System.EventArgs e)
		{
			Cambro.Web.Helpers.WriteAlertHeader();
			Cambro.Web.Helpers.WriteAlert("Selecting...", 1);

			Query q = new Query();
			if (Vars.DevEnv)
				q.TopRecords=50;

			q.QueryCondition = new Or(
				new Q(Promoter.Columns.LastMessage, QueryOperator.IsNull, null),
				new Q(Promoter.Columns.LastMessage, QueryOperator.NotEqualTo, int.Parse(MessageId.Text))
			);

			q.OrderBy = new OrderBy(Promoter.Columns.K);


			PromoterSet bs = new PromoterSet(q);
			

			Cambro.Web.Helpers.WriteAlert("Done selecting...", 1);


			for (int count = 0; count < bs.Count; count++)
			{
				Promoter p = bs[count];

				Thread t = new Thread(p.QuestionsThreadK);

				Comment.Maker m = t.GetCommentMaker();
				m.Body = CommentTextBox.Text;
				m.DuplicateGuid = Guid.NewGuid();
				m.PostingUsr = Usr.Current;
				m.CurrentThreadUsr = t.GetThreadUsr(Usr.Current);
				m.RunAsync = false;
				m.Post(null);

				p.LastMessage = int.Parse(MessageId.Text);
				p.Update();

				if (count % 10 == 0)
					Cambro.Web.Helpers.WriteAlert(count.ToString() + "/" + bs.Count + " - (k=" + p.K + ")" + p.Name, 2);

				bs.Kill(count);

			}
			Cambro.Web.Helpers.WriteAlert("Done!", 3);
			Cambro.Web.Helpers.WriteAlertFooter("/admin/promoterpm");

			CommentTextBox.Text = "";
		}
Exemplo n.º 17
0
		public UrlPartTypes ProcessFilterPart(ref int currentIndex, string[] urlParts)
		{
			if (HasYearFilter && urlParts[currentIndex].Equals("tickets"))
			{
				#region tickets calendar
				PageType = PageTypes.Pages;
				PageName = "CalendarTickets";
				CurrentApplication = "tickets";
				currentIndex++;
				return UrlPartTypes.Application;
				#endregion
			}
			else if (HasYearFilter && urlParts[currentIndex].Equals("free"))
			{
				#region Free Guestlist calendar
				PageType = PageTypes.Pages;
				PageName = "CalendarFreeGuestlist";
				CurrentApplication = "free";
				currentIndex++;
				return UrlPartTypes.Application;
				#endregion
			}
			else if (urlParts[currentIndex].Equals("tags"))
			{
				#region tags
				PageType = PageTypes.Pages;
				PageName = "TagSearch";
				CurrentApplication = "tags";
				HasTagFilter = true;

				currentIndex++;
				if (urlParts.Length > currentIndex)
				{

					CurrentApplication = "tags/" + urlParts[currentIndex];

					foreach (string s in urlParts[currentIndex].Split('-'))
					{
						if (!s.Equals("all"))
							TagFilter.Add(Cambro.Web.Helpers.UrlTextDeSerialize(s));
					}

					currentIndex++;
				}
				return UrlPartTypes.Application;
				#endregion
			}
			else if ((HasBrandObjectFilter || HasVenueObjectFilter) && (urlParts[currentIndex].Equals("tickets") || urlParts[currentIndex].Equals("photos")))
			{
				#region Styled page
				currentIndex++;
				PageType = PageTypes.Styled;
				PageName = "Home";
				if (urlParts.Length > currentIndex &&
					YearRegex.IsMatch(urlParts[currentIndex]))
				{
					#region //year and month
					int year = int.Parse(urlParts[currentIndex]);
					if (year > 1990 && year < 2030)
					{
						HasYearFilter = true;
						DateFilter = new DateTime(year, 1, 1);
						PageName = "Calendar";
						currentIndex++;
						if (urlParts.Length > currentIndex &&
							MonthRegex.IsMatch(urlParts[currentIndex]))
						{
							int month = MonthNumber(urlParts[currentIndex]);
							HasMonthFilter = true;
							DateFilter = new DateTime(year, month, 1);
							currentIndex++;
						}
						return UrlPartTypes.Application;
					}
					#endregion
				}
				else if (urlParts.Length > currentIndex &&
					MonthRegex.IsMatch(urlParts[currentIndex]))
				{
					#region //month only - infer the year
					int requestedMonth = MonthNumber(urlParts[currentIndex]);
					HasYearFilter = true;
					HasMonthFilter = true;
					int requestedMonthIndex = (DateTime.Today.Year * 12) + requestedMonth;
					int currentMonthIndex = (DateTime.Today.Year * 12) + DateTime.Today.Month;
					DateTime d = new DateTime(DateTime.Today.Year, requestedMonth, 1);

					if (currentMonthIndex - requestedMonthIndex > 4)
					{
						d = new DateTime(DateTime.Today.Year + 1, requestedMonth, 1);
					}
					else if (currentMonthIndex - requestedMonthIndex < -7)
					{
						d = new DateTime(DateTime.Today.Year - 1, requestedMonth, 1);
					}

					DateFilter = d;
					PageName = "Calendar";
					currentIndex++;
					return UrlPartTypes.Application;
					#endregion
				}
				else if (urlParts.Length > currentIndex &&
					urlParts[currentIndex].ToLower().Equals("calendar"))
				{
					#region //todays month
					DateFilter = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1);
					PageName = "Calendar";
					currentIndex++;
					return UrlPartTypes.Application;
					#endregion
				}
				else if (urlParts.Length > currentIndex &&
					NumericRegex.IsMatch(urlParts[currentIndex]))
				{
					#region //event id
					PageName = "EventDetail";
					return UrlPartTypes.Application;
					#endregion
				}
				return UrlPartTypes.ObjectFilter;
				#endregion
			}
			else if (urlParts[currentIndex].Equals("parties"))
			{
				#region brand
				currentIndex++;
				Query brandQuery = new Query();
				brandQuery.NoLock = true;
				brandQuery.Columns = new ColumnSet(Brand.Columns.K);
				brandQuery.QueryCondition = new Q(Brand.Columns.UrlName, urlParts[currentIndex]);
				BrandSet bs = new BrandSet(brandQuery);
				if (bs.Count > 0)
				{
					HasObjectFilter = true;
					ObjectFilterType = Model.Entities.ObjectType.Brand;
					ObjectFilterK = bs[0].K;
					PageType = PageTypes.Application;
					PageName = "Home";
					CurrentFilter += "/parties/" + urlParts[currentIndex];
					currentIndex++;
					return UrlPartTypes.ObjectFilter;
				}
				return UrlPartTypes.Null;
				#endregion
			}
			else if (urlParts[currentIndex].Equals("groups"))
			{
				#region group
				currentIndex++;
				if (urlParts.Length > currentIndex)
				{
					string groupUrlName = urlParts[currentIndex];
					if (urlParts[currentIndex].Equals("parties"))
					{
						currentIndex++;
						groupUrlName = "parties/" + urlParts[currentIndex];
					}
					Query groupQuery = new Query();
					groupQuery.NoLock = true;
					groupQuery.Columns = new ColumnSet(Bobs.Group.Columns.K);
					groupQuery.QueryCondition = new Q(Bobs.Group.Columns.UrlName, groupUrlName);
					GroupSet gs = new GroupSet(groupQuery);
					if (gs.Count > 0)
					{
						HasObjectFilter = true;
						ObjectFilterType = Model.Entities.ObjectType.Group;
						ObjectFilterK = gs[0].K;
						PageType = PageTypes.Application;
						PageName = "Home";
						CurrentFilter += "/groups/" + groupUrlName;
						currentIndex++;
						return UrlPartTypes.ObjectFilter;
					}
				}
				PageType = PageTypes.Pages;
				PageName = "GroupBrowser";
				CurrentApplication = "groups";
				return UrlPartTypes.Application;
				#endregion
			}
			else if (!HasObjectFilter && urlParts[currentIndex].Equals("promoters"))
			{
				#region promoter
				currentIndex++;
				Query promoterQuery = new Query();
				promoterQuery.NoLock = true;
				promoterQuery.Columns = new ColumnSet(Promoter.Columns.K);
				promoterQuery.QueryCondition = new Q(Promoter.Columns.UrlName, urlParts[currentIndex]);
				PromoterSet ps = new PromoterSet(promoterQuery);
				if (ps.Count > 0)
				{
					HasObjectFilter = true;
					ObjectFilterType = Model.Entities.ObjectType.Promoter;
					ObjectFilterK = ps[0].K;
					PageType = PageTypes.Application;
					PageName = "Home";
					CurrentFilter += "/promoters/" + urlParts[currentIndex];
					currentIndex++;
					return UrlPartTypes.ObjectFilter;
				}
				return UrlPartTypes.Null;
				#endregion
			}
			else if (!HasObjectFilter && urlParts[currentIndex].Equals("members"))
			{
				#region members - usr
				currentIndex++;
				if (urlParts[currentIndex].Length > 0)
				{
					Usr usr = Usr.GetFromNickName(urlParts[currentIndex]);
					if (usr != null)
					{
						HasObjectFilter = true;
						ObjectFilterType = Model.Entities.ObjectType.Usr;
						ObjectFilterK = usr.K;
						PageType = PageTypes.Application;
						PageName = "Home";
						CurrentFilter += "/members/" + urlParts[currentIndex];
						currentIndex++;
						return UrlPartTypes.ObjectFilter;
					}
					//Query usrQuery = new Query();
					//usrQuery.NoLock = true;
					//usrQuery.Columns = new ColumnSet(Usr.Columns.K);
					//usrQuery.QueryCondition = new Q(Usr.Columns.NickName, urlParts[currentIndex]);
					//UsrSet us = new UsrSet(usrQuery);
					//if (us.Count > 0)
					//{
					//    HasObjectFilter = true;
					//    ObjectFilterType = Model.Entities.ObjectType.Usr;
					//    ObjectFilterK = us[0].K;
					//    PageType = PageTypes.Application;
					//    PageName = "Home";
					//    CurrentFilter += "/members/" + urlParts[currentIndex];
					//    currentIndex++;
					//    return UrlPartTypes.ObjectFilter;
					//}
				}
				return UrlPartTypes.Null;
				#endregion
			}
			else if (urlParts[currentIndex].StartsWith("event-"))
			{
				#region event
				try
				{
					Event ev = new Event(int.Parse(urlParts[currentIndex].Split('-')[1]));
					HasObjectFilter = true;
					ObjectFilterType = Model.Entities.ObjectType.Event;
					ObjectFilterK = ev.K;
					PageType = PageTypes.Application;
					PageName = "Home";
					CurrentFilter += "/" + urlParts[currentIndex];
					currentIndex++;
					return UrlPartTypes.ObjectFilter;
				}
				catch
				{
					currentIndex++;
				}
				return UrlPartTypes.Null;
				#endregion
			}
			else if (urlParts[currentIndex].StartsWith("gallery-"))
			{
				#region gallery
				try
				{
					Gallery g = new Gallery(int.Parse(urlParts[currentIndex].Split('-')[1]));
					HasObjectFilter = true;
					PageType = PageTypes.Application;
					PageName = "Home";
					ObjectFilterType = Model.Entities.ObjectType.Gallery;
					ObjectFilterK = g.K;
					CurrentFilter += "/" + urlParts[currentIndex];
					currentIndex++;
					return UrlPartTypes.ObjectFilter;
				}
				catch
				{
					currentIndex++;
				}
				return UrlPartTypes.Null;
				#endregion
			}
			else if (urlParts[currentIndex].StartsWith("photo-"))
			{
				#region photo
				try
				{
					Photo p = new Photo(int.Parse(urlParts[currentIndex].Split('-')[1]));
					HasObjectFilter = true;
					PageType = PageTypes.Application;
					PageName = "Home";
					ObjectFilterType = Model.Entities.ObjectType.Photo;
					ObjectFilterK = p.K;
					CurrentFilter += "/" + urlParts[currentIndex];
					currentIndex++;
					return UrlPartTypes.ObjectFilter;
				}
				catch
				{
					currentIndex++;
				}
				return UrlPartTypes.Null;
				#endregion
			}
			else if (urlParts[currentIndex].StartsWith("article-"))
			{
				#region article
				try
				{
					Article a = new Article(int.Parse(urlParts[currentIndex].Split('-')[1]));
					HasObjectFilter = true;
					PageType = PageTypes.Application;
					PageName = "Home";
					ObjectFilterType = Model.Entities.ObjectType.Article;
					ObjectFilterK = a.K;
					CurrentFilter += "/" + urlParts[currentIndex];
					currentIndex++;
					return UrlPartTypes.ObjectFilter;
				}
				catch
				{
					currentIndex++;
				}
				return UrlPartTypes.Null;
				#endregion
			}
			else if (GetMusicTypeK(urlParts[currentIndex].ToLower()) > 0)
			{
				#region music filter
				this.HasMusicFilter = true;
				this.MusicFilterK = GetMusicTypeK(urlParts[currentIndex].ToLower());
				CurrentFilter += "/" + urlParts[currentIndex].ToLower();
				currentIndex++;
				return UrlPartTypes.MusicFilter;
				#endregion
			}
			else if (GetThemeK(urlParts[currentIndex].ToLower()) > 0)
			{
				#region theme filter
				this.HasThemeFilter = true;
				this.ThemeFilterK = GetThemeK(urlParts[currentIndex].ToLower());
				CurrentFilter += "/" + urlParts[currentIndex].ToLower();
				currentIndex++;
				return UrlPartTypes.ThemeFilter;
				#endregion
			}
			else if (GetCountryK(urlParts[currentIndex].ToLower()) > 0)
			{
				#region Lookup country / place / venue
				HasObjectFilter = true;
				ObjectFilterType = Model.Entities.ObjectType.Country;
				ObjectFilterK = GetCountryK(urlParts[currentIndex].ToLower());
				PageType = PageTypes.Application;
				PageName = "Home";
				CurrentFilter += "/" + urlParts[currentIndex].ToLower();
				currentIndex++;
				int countryK = this.ObjectFilterK;

				if (urlParts.Length > currentIndex)
				{
					Country country = new Country(countryK);
					Q regionQ = new Q(true);
					if (country.UseRegion)
					{
						Query qRegion = new Query();
						qRegion.NoLock = true;
						qRegion.Columns = new ColumnSet(Region.Columns.K);
						qRegion.TopRecords = 1;
						qRegion.QueryCondition = new And(
							new Q(Region.Columns.CountryK, countryK),
							new Q(Region.Columns.Abbreviation, urlParts[currentIndex]));
						RegionSet rs = new RegionSet(qRegion);
						if (rs.Count > 0)
						{
							HasObjectFilter = true;
							ObjectFilterType = Model.Entities.ObjectType.Region;
							ObjectFilterK = rs[0].K;
							PageType = PageTypes.Application;
							PageName = "Home";
							int regionK = ObjectFilterK;
							regionQ = new Q(Place.Columns.RegionK, regionK);
							CurrentFilter += "/" + urlParts[currentIndex].ToLower();

							currentIndex++;

							if (!(urlParts.Length > currentIndex))
								return UrlPartTypes.ObjectFilter;
						}


					}
					#region Lookup place
					Query placeQuery = new Query();
					placeQuery.NoLock = true;
					placeQuery.Columns = new ColumnSet(Place.Columns.K);
					placeQuery.QueryCondition = new And(
						new Q(Place.Columns.Enabled, true),
						new Q(Place.Columns.CountryK, countryK),
						new Q(Place.Columns.UrlName, urlParts[currentIndex].ToLower()),
						regionQ
					);
					PlaceSet ps = new PlaceSet(placeQuery);
					if (ps.Count > 0)
					{
						HasObjectFilter = true;
						ObjectFilterType = Model.Entities.ObjectType.Place;
						ObjectFilterK = ps[0].K;
						PageType = PageTypes.Application;
						PageName = "Home";
						CurrentFilter += "/" + urlParts[currentIndex].ToLower();
						currentIndex++;
						int placeK = this.ObjectFilterK;

						if (urlParts.Length > currentIndex)
						{
							#region Lookup venue
							Query venueQuery = new Query();
							venueQuery.NoLock = true;
							venueQuery.Columns = new ColumnSet(Venue.Columns.K);
							venueQuery.QueryCondition = new And(
								new Q(Venue.Columns.PlaceK, placeK),
								new Q(Venue.Columns.UrlName, urlParts[currentIndex].ToLower())
								);
							VenueSet vs = new VenueSet(venueQuery);
							if (vs.Count > 0)
							{
								HasObjectFilter = true;
								ObjectFilterType = Model.Entities.ObjectType.Venue;
								ObjectFilterK = vs[0].K;
								PageType = PageTypes.Application;
								PageName = "Home";
								CurrentFilter += "/" + urlParts[currentIndex].ToLower();
								currentIndex++;
								int venueK = this.ObjectFilterK;
							}
							#endregion
						}
					}
					#endregion
				}
				return UrlPartTypes.ObjectFilter;
				#endregion
			}
			else if (YearRegex.IsMatch(urlParts[currentIndex]))
			{
				#region year / month / day
				int year = int.Parse(urlParts[currentIndex]);
				if (year > 1990 && year < 2030)
				{
					HasYearFilter = true;
					DateFilter = new DateTime(year, 1, 1);
					PageType = PageTypes.Pages;
					PageName = "Calendar";
					CurrentFilter += "/" + urlParts[currentIndex];
					currentIndex++;
					if (urlParts.Length > currentIndex && MonthRegex.IsMatch(urlParts[currentIndex]))
					{
						int month = MonthNumber(urlParts[currentIndex]);
						HasMonthFilter = true;
						DateFilter = new DateTime(year, month, 1);
						PageType = PageTypes.Pages;
						PageName = "Calendar";
						CurrentFilter += "/" + urlParts[currentIndex];
						currentIndex++;
						if (urlParts.Length > currentIndex && DayRegex.IsMatch(urlParts[currentIndex]))
						{
							int day = int.Parse(urlParts[currentIndex]);
							try
							{
								DateFilter = new DateTime(year, month, day);
								HasDayFilter = true;
								PageType = PageTypes.Pages;
								PageName = "Calendar";
								CurrentFilter += "/" + urlParts[currentIndex];
								currentIndex++;
							}
							catch
							{
								currentIndex++;
							}
						}
					}
					return UrlPartTypes.DateFilter;
				}
				else
					return UrlPartTypes.Null;
				#endregion
			}
			else if (urlParts[currentIndex].Equals("chat") || urlParts[currentIndex].Equals("messages"))
			{
				#region chat application
				PageType = PageTypes.Pages;
				PageName = "Chat";
				CurrentApplication = "chat";
				currentIndex++;
				if (ObjectFilterType.Equals(Model.Entities.ObjectType.Usr))
				{
					PageType = PageTypes.PagesFolder;
					PageFolder = "Usrs";
					PageName = "MyComments";
					CurrentApplication = "chat";
				}
				return UrlPartTypes.Application;
				#endregion
			}
			else if (urlParts[currentIndex].Equals("archive"))
			{
				#region archive application
				PageType = PageTypes.Pages;
				PageName = "Archive";
				CurrentApplication = "archive";
				currentIndex++;
				return UrlPartTypes.Application;
				#endregion
			}
			else if (urlParts[currentIndex].Equals("hottickets"))
			{
				#region hot tickets application
				PageType = PageTypes.Pages;
				PageName = "HotTickets";
				CurrentApplication = "hottickets";
				currentIndex++;
				return UrlPartTypes.Application;
				#endregion
			}
			else if (urlParts[currentIndex].Equals("home"))
			{
				#region home application
				CurrentApplication = "home";
				currentIndex++;
				return UrlPartTypes.Application;
				#endregion
			}
			else if (HasUsrObjectFilter && urlParts[currentIndex].Equals("photosof"))
			{
				#region photosof page
				currentIndex++;
				PageType = PageTypes.Application;
				PageName = "photosof";
				CurrentApplication = "photosof/" + urlParts[currentIndex].ToLower();
				currentIndex++;
				return UrlPartTypes.Application;
				#endregion
			}
			else
			{
				if (urlParts.Length > currentIndex)
				{
					if (!PageType.Equals(PageTypes.Styled))
						PageType = PageTypes.Application;
					PageName = urlParts[currentIndex].ToLower();
					CurrentApplication = urlParts[currentIndex].ToLower();
					currentIndex++;
					return UrlPartTypes.Application;
				}
				else
				{
					currentIndex++;
					return UrlPartTypes.Null;
				}
			}
		}
Exemplo n.º 18
0
		public void FixPromoterQuestions(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);
					t.Subject = c.Name + " promoter questions";
					t.Update();
					// Do work here!
					//c.Update();

					if (count % 10 == 0)
						Cambro.Web.Helpers.WriteAlert("Done " + 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();
		}
Exemplo n.º 19
0
		public void AddMailNotes(object o, System.EventArgs e)
		{
			Cambro.Web.Helpers.WriteAlertHeader();

			Cambro.Web.Helpers.WriteAlert("Selecting xxx...", 1);
			Query q = new Query();
			q.QueryCondition = new Q(Promoter.Columns.LetterStatus, Promoter.LetterStatusEnum.Posted);
			PromoterSet bs = new PromoterSet(q);
			Usr dsi = new Usr(8);
			for (int count = 0; count < bs.Count; count++)
			{
				Promoter c = bs[count];

				try
				{
					c.LetterStatus = Promoter.LetterStatusEnum.Posted;
					c.SalesHold = false;
					c.SalesNextCall = DateTime.Today.AddDays(7);
					c.Update();
					c.AddNote("Sent media pack (with " + c.LetterType + " letter)", Guid.NewGuid(), dsi);
				
					// Do work here!
					c.Update();

					if (count % 10 == 0)
						Cambro.Web.Helpers.WriteAlert("Done " + 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();
		}
Exemplo n.º 20
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();
Exemplo n.º 21
0
		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();
		}
Exemplo n.º 22
0
		private void SalesUsrAlarmPanelSetup()
		{
			if (Usr.Current != null && Usr.Current.SalesTeam > 0)
			{
				Query promoterAlarmQuery = new Query(new And(new Q(Promoter.Columns.Alarm, true),
															 new Q(Promoter.Columns.SalesNextCall, QueryOperator.LessThanOrEqualTo, DateTime.Now),
															 new Q(Promoter.Columns.SalesUsrK, Usr.Current.K)));
				promoterAlarmQuery.Columns = new ColumnSet(Promoter.Columns.K, Promoter.Columns.Name, Promoter.Columns.UrlName, Promoter.Columns.SalesNextCall, Promoter.Columns.Alarm);
				promoterAlarmQuery.OrderBy = new OrderBy(Promoter.Columns.SalesNextCall);
				PromoterSet alarmedPromoters = new PromoterSet(promoterAlarmQuery);

				this.SalesUsrAlarmPanel.Visible = alarmedPromoters.Count > 0;
				if (alarmedPromoters.Count > 0)
				{
					this.SalesUsrAlarmGridView.ShowFooter = alarmedPromoters.Count > 1;
					this.SalesUsrAlarmGridView.DataSource = alarmedPromoters;
					this.SalesUsrAlarmGridView.DataBind();
					if (alarmedPromoters.Count > 10)
					{
						SalesUsrAlarmPanelInner.Style["height"] = "300px";
						SalesUsrAlarmPanelInner.Style["overflow"] = "auto";
					}
				}
			}
			else
			{
				SalesUsrAlarmPanel.Visible = false;
			}
		}
Exemplo n.º 23
0
		public void SendPromoterIntros(object o, System.EventArgs e)
		{
			Cambro.Web.Helpers.WriteAlertHeader();

			Cambro.Web.Helpers.WriteAlert("Selecting inactive promoters...", 1);
			Query q = new Query();
			q.QueryCondition = new Q(Promoter.Columns.Status, Promoter.StatusEnum.Enabled);
			//q.QueryCondition=???
			if (Vars.DevEnv)
				q.TopRecords = 100;
			PromoterSet bs = new PromoterSet(q);
			for (int count = 0; count < bs.Count; count++)
			{
				Promoter c = bs[count];

				try
				{
					foreach (Usr u in c.AdminUsrs)
					{
						Mailer m = new Mailer();
						m.UsrRecipient = u;
						m.Subject = "We've enabled your DontStayIn promoter account!";
						m.RedirectUrl = c.Url();
						m.Body = @"
<p>
You recently signed up as a promoter on DontStayIn. We've now enabled your 
account, so all the features are now available!
</p>

<p>
<b>Just click the 'Promoters' button at the top of the page to see all the new options.</b>
</p>

<p>
We're still available if you get stuck or need something explained. Just give us a call on 
0207 835 5599.
</p>
";
						m.Send();
					}

					if (count % 10 == 0)
						Cambro.Web.Helpers.WriteAlert("Done " + 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();
		}
		protected void Page_Load(object sender, EventArgs e)
		{
			//throw new Exception("paused!");
			Usr.KickUserIfNotAdmin("");

			StringBuilder sb = new StringBuilder();
			#region Top HTML
			sb.Append(@"
<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN"">
<html>
	<head>
		<style>
			P{
				text-align:justify;
				font-size:10pt;
				margin-top:2mm;
				margin-bottom:2mm;
				margin-left:10mm;
				margin-right:10mm;
			}
			P.Address{
				margin-left:15mm;
			}
			P.Big{
				font-family:Verdana;
				text-align:center; 
				font-size:10pt; 
				font-weight:bold;
			}
			Div.PageDiv{
				page-break-after:always;
				padding-top:3cm;
				padding-left:1cm;
				padding-right:1cm;
				padding-bottom:0cm;
			}
		</style>
	</head>
	<body topmargin=""0"" bottommargin=""0"" leftmargin=""0"" rightmargin=""0"">");
			#endregion

			#region Promoter intro letters (with media packs)

			sb.Append(@"<div class=""PageDiv"" style=""page-break-after:always;"">Promoter letters to be posted with media packs</div>");

			#region Venue
			string Venue = @"<div class=""PageDiv"" style=""page-break-after:always;"">
<p class=""Address"">
	[ADDRESS]
</p>
<p style=""margin-top:6mm;"">
	Dear [SALUTATION],
</p>
<p>
	DontStayIn (www.dontstayin.com) is the number one clubbing and social events site in the UK. We now have nearly half a million members, with thousands more joining each day. Our website offers endless opportunities to promote your events to the people who really matter.
</p>
<p>
	We have set your venue up with a free community page where you can list your events, upload photos, write articles about events & DJ’s, run competitions and even organise your guest list. Most importantly you give your regulars the chance to meet each other online, and grow your community outside of the venue.
</p>
<p>
	Please find enclosed some stickers for your venue - these encourage people to upload pictures from your events. This is a great way to increase your exposure on the site, and generate more interest in your future events.
</p>
<p>
	We have many promotional tools to attract our members to your venue, the most effective being flyer banners. Flyer banners are more effective than normal paper flyers for a variety of reasons, the most important being targeting. You can target your flyer banners by location and music type, so if you’re running a London house music event, we won’t be showing your banner to hip-hop fans in Manchester! You have instant statistics on how many views and clicks your banner is getting, and you can update it daily to ensure that your advertising message stays fresh. Finally flyer banners are much more cost effective than printed flyers - you don’t need to pay for printing or distribution.
</p>
<p>
	As a new venue on our site we have a great offer to help you increase your exposure:
</p>
<p class=""Big"">
	We will double whatever you spend on advertising<span style=""font-family:Times New Roman; font-weight:normal;"">*</span>
</p>
<p>
	To activate this offer and the many free tools we provide, please visit:
</p>
<p class=""Big"">
	dontstayin.com/offer
</p>
<p>
	You’ll be asked to enter an access code:
</p>
<p class=""Big"">
	[ACCESS-CODE]
</p>
<p>
	If you have any questions about how to use the site or how to increase your exposure just give our team a call on 0207 835 5599.
</p>
<p>
	Yours faithfully,
</p>
<img src=""/gfx/fabe-sig.gif"" height=""75"" style=""margin-top:-10px; margin-bottom:-10px; margin-left:50px;"" />
<p>
	Fabe Bustillos<br />
	[email protected]
</p>
<p>
	* Offer expires one month after activation, and is available for event or venue banners only. Not to be combined with any other offer or discount.
</p>
</div>";
			#endregion
			#region Old
			string Old = @"<div class=""PageDiv"" style=""page-break-after:always;"">
<p class=""Address"">
	[ADDRESS]
</p>
<p style=""margin-top:6mm;"">
	Dear [SALUTATION],
</p>
<p>
	You have a promoter account on www.dontstayin.com, but haven’t used it in a while. DontStayIn is the number one clubbing and social events site in the UK. We now have nearly half a million members, with thousands more joining each day. Our website offers endless opportunities to promote your events to the people who really matter.
</p>
<p>
	The most effective promotional tools we offer for events and venues are flyer banners. Flyer banners are more effective than normal paper flyers for a variety of reasons, the most important being targeting. You can target your flyer banners by location and music type, so if you’re running a London house music event, we won’t be showing your banner to hip-hop fans in Manchester! You have instant statistics on how many views and clicks your banner is getting, and you can update it daily to ensure that your advertising message stays fresh. Finally flyer banners are much more cost effective than printed flyers – you don’t need to pay for printing or distribution.
</p>
<p>
	We have a great offer to give your promotion a boost:
</p>
<p class=""Big"">
	We will double whatever you spend on advertising<span style=""font-family:Times New Roman; font-weight:normal;"">*</span>
</p>
<p>
	To activate this offer and the many free tools we provide, please visit:
</p>
<p class=""Big"">
	dontstayin.com/offer
</p>
<p>
	You’ll be asked to enter an access code:
</p>
<p class=""Big"">
	[ACCESS-CODE]
</p>
<p>
	If you have any questions about how to use the site or how to increase your exposure just give our team a call on 0207 835 5599.
</p>
<p>
	Yours faithfully,
</p>
<img src=""/gfx/fabe-sig.gif"" height=""75"" style=""margin-top:-10px; margin-bottom:-10px; margin-left:50px;"" />
<p>
	Fabe Bustillos<br />
	[email protected]
</p>
<p>
	* Offer expires one month after activation, and is available for event or venue banners only. Not to be combined with any other offer or discount.
</p>
</div>";
			#endregion
			#region New
			string New = @"<div class=""PageDiv"" style=""page-break-after:always;"">
<p class=""Address"">
	[ADDRESS]
</p>
<p style=""margin-top:6mm;"">
	Dear [SALUTATION],
</p>
<p>
	You recently created a promoter account on www.dontstayin.com. DontStayIn is the number one clubbing and social events site in the UK. We now have nearly half a million members, with thousands more joining each day. Our website offers endless opportunities to promote your events to the people who really matter. 
</p>
<p>
	The most effective promotional tools we offer for events and venues are flyer banners. Flyer banners are more effective than normal paper flyers for a variety of reasons, the most important being targeting. You can target your flyer banners by location and music type, so if you’re running a London house music event, we won’t be showing your banner to hip-hop fans in Manchester! You have instant statistics on how many views and clicks your banner is getting, and you can update it daily to ensure that your advertising message stays fresh. Finally flyer banners are much more cost effective than printed flyers – you don’t need to pay for printing or distribution.
</p>
<p>
	As a new promoter we have a great offer to help you increase your exposure:
</p>
<p class=""Big"">
	We will double whatever you spend on advertising<span style=""font-family:Times New Roman; font-weight:normal;"">*</span>
</p>
<p>
	To activate this offer and the many free tools we provide, please visit:
</p>
<p class=""Big"">
	dontstayin.com/offer
</p>
<p>
	You’ll be asked to enter an access code:
</p>
<p class=""Big"">
	[ACCESS-CODE]
</p>
<p>
	If you have any questions about how to use the site or how to increase your exposure just give our team a call on 0207 835 5599.
</p>
<p>
	Yours faithfully,
</p>
<img src=""/gfx/fabe-sig.gif"" height=""75"" style=""margin-top:-10px; margin-bottom:-10px; margin-left:50px;"" />
<p>
	Fabe Bustillos<br />
	[email protected]
</p>
<p>
	* Offer expires one month after activation, and is available for event or venue banners only. Not to be combined with any other offer or discount.
</p>
</div>";
			#endregion
			#region Active
			string Active = @"<div class=""PageDiv"" style=""page-break-after:always;"">
<p class=""Address"">
	[ADDRESS]
</p>
<p style=""margin-top:6mm;"">
	Dear [SALUTATION],
</p>
<p>
	You are a valued member of the DontStayIn promoter community. This is a quick letter to catch up and let you know we’re the number one clubbing and social events site in the UK. We now have nearly half a million members, with thousands more joining each day. Our website is becoming an even more important tool to promote your events to the people who really matter.
</p>
<p>
	The most effective promotional tools we offer for events and venues are flyer banners. Flyer banners are more effective than normal paper flyers for a variety of reasons, the most important being targeting. You can target your flyer banners by location and music type, so if you’re running a London house music event, we won’t be showing your banner to hip-hop fans in Manchester! You have instant statistics on how many views and clicks your banner is getting, and you can update it daily to ensure that your advertising message stays fresh. Finally flyer banners are much more cost effective than printed flyers – you don’t need to pay for printing or distribution.
</p>
<p>
	As a valued promoter we have a great offer to help you increase your exposure:
</p>
<p class=""Big"">
	We will double whatever you spend on advertising<span style=""font-family:Times New Roman; font-weight:normal;"">*</span>
</p>
<p>
	To activate this offer and the many free tools we provide, please visit:
</p>
<p class=""Big"">
	dontstayin.com/offer
</p>
<p>
	You’ll be asked to enter an access code:
</p>
<p class=""Big"">
	[ACCESS-CODE]
</p>
<p>
	If you have any questions about how to use the site or how to increase your exposure just give our team a call on 0207 835 5599.
</p>
<p>
	Yours faithfully,
</p>
<img src=""/gfx/fabe-sig.gif"" height=""75"" style=""margin-top:-10px; margin-bottom:-10px; margin-left:50px;"" />
<p>
	Fabe Bustillos<br />
	[email protected]
</p>
<p>
	* Offer expires one month after activation, and is available for event or venue banners only. Not to be combined with any other offer or discount.
</p>
</div>";
			#endregion
			#region TicketsDomain
			string TicketsDomain = @"<div class=""PageDiv"" style=""page-break-after:always;"">
<p class=""Address"">
	[ADDRESS]
</p>
<p style=""margin-top:6mm;"">
	Dear [SALUTATION],
</p>
<p>
	Merry Christmas from everyone at DontStayIn! 
</p>
<p>
	You are one of the top promoters on our site, and to say thank you for your continued support we would like to give you possibly the best present you’ll ever receive!
</p>
<p>
	We’ve registered your very own domain name for selling tickets:
</p>
<p class=""Big"">
	[DOMAINS]
</p>
<p>
	If you go to it now, it’ll take you to your new “hot tickets” page on DontStayIn. You can start putting it on your flyers straight away, and get your customers straight to your tickets.
</p>
<p>
	What’s more, we’re currently working on creating you a customised micro-site! This will sell your tickets without looking like DontStayIn – it will have your logo and colour-scheme. We’ll phone you when this bit is ready to make sure you’re happy with it!
</p>
<p>
	If you’re not already selling tickets on DontStayIn, it literally takes three clicks to start. Click the Promoters button at the top of the site to begin.
</p>
<p>
	If there’s anything you’re unsure about, or you’d like us to show you how to sell tickets, just give me a quick ring on 0207 835 5599.
</p>
<img src=""/gfx/sig-[SALESUSRSIG].gif"" width=""120"" style=""margin-top:-10px; margin-bottom:-10px; margin-left:50px;"" />
<p>
	[SALESUSRNAME] ([SALESUSREMAIL])
</p>
<p>
	Your account manager.
</p>
</div>";
			#endregion

			Query q = new Query();
			q.QueryCondition = new Q(Domain.Columns.RedirectApp, "hottickets");
			q.TableElement = new Join(Promoter.Columns.K, Domain.Columns.PromoterK);
			q.Distinct = true;
			q.DistinctColumn = Promoter.Columns.K;
			PromoterSet ps = new PromoterSet(q);

			foreach (Promoter p in ps)
			{
				string s = TicketsDomain;

				//address
				string Address = "";
				if (p.ContactName.Length > 0)
					Address += p.ContactName + "<br />";
				Address += p.Name + "<br />";
				if (p.AddressStreet.Length > 0)
					Address += p.AddressStreet + "<br />";
				if (p.AddressArea.Length > 0)
					Address += p.AddressArea + "<br />";
				if (p.AddressTown.Length > 0)
					Address += p.AddressTown + "<br />";
				Address += p.AddressCounty.ToUpper() + " " + p.AddressPostcode;

				s = s.Replace("[ADDRESS]", Address);

				string Salutation = "Sir or Madam";
				if (p.ContactName.Length > 0 && !p.ContactName.Equals("Events manager"))
				{
					if (p.ContactName.Contains(" "))
						Salutation = p.ContactName.Split(' ')[0];
					else
						Salutation = p.ContactName;
				}
				s = s.Replace("[SALUTATION]", Salutation);

				Query q1 = new Query();
				q1.QueryCondition = new And(new Q(Domain.Columns.RedirectApp, "hottickets"), new Q(Domain.Columns.PromoterK, p.K));
				DomainSet ds = new DomainSet(q1);
				string domains = "";
				foreach (Domain d in ds)
				{
					domains += domains.Length == 0 ? "" : "<br>";
					domains += "www." + d.DomainName;
				}
				s = s.Replace("[DOMAINS]", domains);

				try
				{
					s = s.Replace("[SALESUSRSIG]", p.SalesUsr.NickName.ToLower());
					s = s.Replace("[SALESUSRNAME]", p.SalesUsr.FullName);
					if (p.SalesUsrK == 1)
						s = s.Replace("[SALESUSREMAIL]", "*****@*****.**");
					else
						s = s.Replace("[SALESUSREMAIL]", p.SalesUsr.Email);
				}
				catch { }



				//s = s.Replace("[ACCESS-CODE]", p.K.ToString("0000") + " - " + p.AccessCodeRandom.Substring(0, 4) + " - " + p.AccessCodeRandom.Substring(4, 4));
				p.LetterStatus = Promoter.LetterStatusEnum.Printing;
				p.Update();
				sb.Append(s);
			}
			#endregion

			#region Bottom HTML
			sb.Append(@"
	</body>
</html>");
			#endregion
			Response.Clear();
			Response.Write(sb.ToString());
			Response.Flush();
			Response.End();
		}
Exemplo n.º 25
0
		public void FixAllPromoterQuestionsThreads(object o, System.EventArgs e)
		{
			Cambro.Web.Helpers.WriteAlertHeader();

			Cambro.Web.Helpers.WriteAlert("Selecting promoters...", 1);
			Query q = new Query(new Q(Promoter.Columns.K, QueryOperator.GreaterThan, 1));
			q.Columns = new ColumnSet(Promoter.Columns.K, Promoter.Columns.SalesUsrK, Promoter.Columns.QuestionsThreadK, Promoter.Columns.Name);
			//q.QueryCondition=???
			PromoterSet promoters = new PromoterSet(q);

			for (int count = 0; count < promoters.Count; count++)
			{
				try
				{
					promoters[count].FixQuestionsThreadUsrs();
					
					if (count % 10 == 0)
						Cambro.Web.Helpers.WriteAlert("Done " + promoters[count].Name + " - " + count + "/" + promoters.Count, 2);
				}
				catch (Exception ex)
				{
					Cambro.Web.Helpers.WriteAlert("Exception " + count + "/" + promoters.Count + " - " + ex.ToString(), 3);
				}
			}
			Cambro.Web.Helpers.WriteAlert("Done!", 4);
			Cambro.Web.Helpers.WriteAlertFooter();
		}
Exemplo n.º 26
0
		/// <summary>
		/// Sends email to all admin users for each promoter account that has a negative balance.
		/// </summary>
		/// <param name="monthYear">Month and year of statement to link to in email</param>
		public static void EmailAllPromoterOutstandingStatements(DateTime monthYear)
		{
			// Make datetime the last day (23:59:59.999) of the given month
			DateTime lastDayOfMonthYear = Utilities.GetEndOfMonth(monthYear);

			try
			{
				// Replacing CreatedDateTime with TaxDateTime, as per Gee's request for OASIS v1.5
				Query promoterOutstandingQuery = new Query(
					new And(
						new Or(
							new And(
								new Q(Invoice.Columns.Type, Invoice.Types.Invoice),
								new Q(Invoice.Columns.TaxDateTime, QueryOperator.LessThanOrEqualTo, lastDayOfMonthYear),
								new Q(Invoice.Columns.Paid, false)),
							new And(new Q(Transfer.Columns.Type, Transfer.TransferTypes.Payment),
								new Q(Transfer.Columns.IsFullyApplied, false),
								new Q(Transfer.Columns.DateTimeCreated, QueryOperator.LessThanOrEqualTo, lastDayOfMonthYear),
								new Q(Transfer.Columns.Status, Transfer.StatusEnum.Success)),
							new And(new Q(Transfer.Columns.Type, Transfer.TransferTypes.Refund),
								new Q(Transfer.Columns.TransferRefundedK, 0),
								new Q(Transfer.Columns.DateTimeCreated, QueryOperator.LessThanOrEqualTo, lastDayOfMonthYear),
								new Or(new Q(Transfer.Columns.Status, Transfer.StatusEnum.Pending),
									new Q(Transfer.Columns.Status, Transfer.StatusEnum.Success))
								)
							)
						),
						new Q(Promoter.Columns.SuspendReminderEmails, false
					)
				);
				promoterOutstandingQuery.TableElement = new Join(Promoter.Columns.K, Invoice.Columns.PromoterK, QueryJoinType.Left);
				promoterOutstandingQuery.TableElement = new Join(promoterOutstandingQuery.TableElement, new TableElement(TablesEnum.Transfer), QueryJoinType.Left, Promoter.Columns.K, Transfer.Columns.PromoterK);
				promoterOutstandingQuery.Distinct = true;
				promoterOutstandingQuery.DistinctColumn = Promoter.Columns.K;

				PromoterSet promoters = new PromoterSet(promoterOutstandingQuery);

				foreach (Promoter promoter in promoters)
				{
					if (promoter.SuspendReminderEmails)
					{
						continue;
					}
					try
					{
						// first try to apply any available money to unpaid invoices.
						promoter.ApplyAvailableMoneyToUnpaidInvoices();
						// Dont need to send statements to promoters with balance == zero
						decimal promoterBalance = promoter.GetBalance();
						// We only send out statements to promoters who owe us money, as per Gee 15/11/06
						if (Math.Round(promoterBalance, 2) < 0)
						{
							Mailer mailer = new Mailer();
							mailer.TemplateType = Mailer.TemplateTypes.AnotherSiteUser;
							mailer.Subject = "DontStayIn statement of outstanding funds for " + monthYear.ToString("MMM yyyy") + " for " + promoter.Name;

							mailer.Body = "<h2>DontStayIn statement of outstanding funds for " + monthYear.ToString("MMM yyyy") + "</h2>";
							mailer.Body += promoter.LinkEmailFull;
							mailer.Body += "<p><b>Account balance: " + Utilities.MoneyToHTML(Math.Abs(promoterBalance)) + "</b></p>";
							mailer.Body += @"<p><a href=""[LOGIN(" + promoter.UrlStatementReport(monthYear) + "\")]>Statement for " + monthYear.ToString("MMM yyyy") + "</a></p>";
							mailer.Body += @"<p><a href=""[LOGIN(" + promoter.UrlApp("invoices", "pay", "true") + "\")]>Please pay invoices now</a>.</p>";

							mailer.Attachments.Add(new System.Net.Mail.Attachment(promoter.GenerateMonthlyStatementMemoryStream(monthYear.Month, monthYear.Year, false), "DontStayIn Statement for " + monthYear.ToString("MMM yyyy") + ".doc", "application/word"));

							if (!Vars.DevEnv)
							{
								foreach (Usr usr in promoter.AdminUsrs)
								{
									try
									{
										mailer.UsrRecipient = usr;
										mailer.Send();
									}
									catch (Exception ex)
									{
										string additionalDetails = "Occurred in Utilities.EmailAllPromoterOutstandingStatements(): Usr K= ";
										if (usr != null)
											additionalDetails += usr.K.ToString();
										else
											additionalDetails += "null";
										List<IBobAsHTML> bobsAsHtml = new List<IBobAsHTML>();
										bobsAsHtml.Add(promoter);
										bobsAsHtml.Add(usr);
										EmailException(ex, additionalDetails, bobsAsHtml);
									}
								}
							}
							if (!Vars.DevEnv && promoter.AccountsEmail != null && promoter.AccountsEmail.Length > 0)
							{
								try
								{
									string body = "";
									body = "<h2>DontStayIn statement of outstanding funds for " + monthYear.ToString("MMM yyyy") + "</h2>";
									body += @"<p>Account: " + promoter.Name + " - <b>Account balance: " + Utilities.MoneyToHTML(Math.Abs(promoterBalance)) + "</b></p>";
									body += @"<p>Statement for " + monthYear.ToString("MMM yyyy") + "</p>";
									body += @"<p>Please pay invoices now.</p>";

									Utilities.EmailToNonUser(promoter.AccountsEmail, mailer.Subject, body, mailer.Attachments.ToArray());
								}
								catch (Exception ex)
								{
									string additionalDetails = "Occurred in Utilities.EmailAllPromoterOutstandingStatements(): Promoter.AccountsEmail = " + promoter.AccountsEmail;
									EmailException(ex, additionalDetails, promoter);
								}
							}

							// Change for internal use
							mailer.UsrRecipient = null;
							mailer.TemplateType = Mailer.TemplateTypes.AdminNote;

							if (Vars.DevEnv)
								mailer.Subject = "TEST - " + mailer.Subject;
							mailer.To = "*****@*****.**";
							mailer.Send();
						}
					}
					catch (Exception ex)
					{
						string additionalDetails = "Occurred in Utilities.EmailAllPromoterOutstandingStatements(): Promoter K= ";
						if (promoter != null)
							additionalDetails += promoter.K.ToString();
						else
							additionalDetails += "null";
						EmailException(ex, additionalDetails, promoter);
					}
				}
			}
			catch (Exception ex)
			{
				EmailException(ex, "Occurred in Utilities.EmailAllPromoterOutstandingStatements()");
			}
		}
Exemplo n.º 27
0
		public static void EmailPromotersListingsReminder()
		{
			Console.WriteLine("Utilities.EmailPromotersListingsReminder();");


			Query q = new Query();
			q.QueryCondition = new Q(Promoter.Columns.Status, QueryOperator.NotEqualTo, Promoter.StatusEnum.Disabled);
			if (Vars.DevEnv)
				q.TopRecords = 10;
			PromoterSet bs = new PromoterSet(q);
			List<int> ks = new List<int>();

			for (int count = 0; count < bs.Count; count++)
			{
				Promoter c = bs[count];

				try
				{
					foreach (Usr u in c.AdminUsrs)
					{
						if (!ks.Contains(u.K))
						{
							ks.Add(u.K);
							
							Mailer mailer = new Mailer();
							mailer.TemplateType = Mailer.TemplateTypes.AnotherSiteUser;
							mailer.Subject = "DSI LISTINGS DEADLINE - Wednesday 9AM! Get your events mailed to 200,000 clubbers for FREE!";

							mailer.Body = @"<p>Club promoters!</p>
<p>Make sure you have your events listed on Don't Stay In <b>before Wednesday at 9AM</b>. If you get your event listed before then, it will go into our weekly round-up of events being sent out to 200,000 raving revellers.</p>
<p>If you want your event included in this week's FREE mailer, then all you need to do is <a href=""[LOGIN(/pages/events/edit)]"">list your event here</a>.</p>
<p>It's free and only takes 2 minutes. You can always come back later if you want to tart it up a bit.</p>
<p>Cheers,</p>
<p>The DSI Team</p>";
							mailer.RedirectUrl = "/pages/events/edit";
							mailer.UsrRecipient = u;
							mailer.Send();
							Console.WriteLine("sent to {0}", u.Email);

						}
					}

					//if (count % 10 == 0)
					Console.WriteLine("Done " + count + "/" + bs.Count + " " + c.UrlName, 2);

				}
				catch (Exception ex)
				{
					Console.WriteLine("Exception " + count + "/" + bs.Count + " - " + ex.ToString(), 3);
				}

				bs.Kill(count);

			}

			Console.WriteLine("All done!");
			Console.ReadLine();
		}
Exemplo n.º 28
0
		public void CreateUniqueUrlName()
		{
			string urlName = UrlInfo.GetUrlName(this.Name);
			if (urlName.Length==0)
				urlName = "promoter-"+this.K.ToString();
			if (UrlInfo.IsReservedString(urlName))
				urlName = "promoter-"+urlName;

			PromoterSet ps = null;
			int namePost = 0;
			string newName = urlName;
			while (ps==null || ps.Count>0)
			{
				if (namePost>0)
					newName = urlName+"-"+namePost.ToString();
				Query q = new Query();
				q.NoLock=true;
				q.ReturnCountOnly=true;
				q.QueryCondition=new And(
					new Q(Promoter.Columns.UrlName,newName),
					new Q(Promoter.Columns.K,QueryOperator.NotEqualTo,this.K)
				);
				ps = new PromoterSet(q);
				namePost++;
			}
			
			this.UrlName = newName;
			this.Update();

			Utilities.UpdateChildUrlFragmentsJob job = new Utilities.UpdateChildUrlFragmentsJob(Model.Entities.ObjectType.Promoter, this.K, true);
			job.ExecuteAsynchronously();
		}
Exemplo n.º 29
0
		public static void EmailAllPromotersWithTicketsAndUnknownVatStatus()
		{
			Query q = new Query(new Or(new Q(Promoter.Columns.VatStatus, Promoter.VatStatusEnum.Unknown),
									   new Q(Promoter.Columns.VatStatus, QueryOperator.IsNull, null)));
			
			q.TableElement = new Join(Promoter.Columns.K, TicketRun.Columns.PromoterK);
			q.Distinct = true;
			q.DistinctColumn = Promoter.Columns.K;
			q.OrderBy = new OrderBy(Promoter.Columns.K);

			PromoterSet promoters = new PromoterSet(q);
			Random r = new Random();
			foreach (Promoter promoter in promoters)
			{
				System.Net.Mail.SmtpClient c = new System.Net.Mail.SmtpClient();
				c.Host = Common.Properties.GetDefaultSmtpServer(r);

				System.Net.Mail.MailMessage m = new System.Net.Mail.MailMessage();

				m.Body = "<p>Promoter: " + promoter.Name + @",<br><br>
								You have recently set up to sell tickets to your event on dontstayin.com, but in order to sell tickets for you correctly, we need to know whether you are registered for VAT.
								<br><br>								 
								It’s really important to let us know as soon as possible your VAT registration status, and if you are registered, your VAT registration number, so that you can continue to sell tickets on the site.
								<br><br>
								If you are not VAT registered, please reply to this email and let us know that this is the case. 
								<br><br>
								Thanks very much for your help.
								<br><br>
								Regards,
								<br><br>
								Tim</p>";
				m.Body += TimAylottSignatureHTML();

				m.From = new System.Net.Mail.MailAddress(Vars.EMAIL_ADDRESS_ACCOUNTS);
				m.IsBodyHtml = true;

				m.Subject = "Promoter: " + promoter.Name + ", VAT status unknown";

				if (promoter.K != 100 && promoter.K != 24)
				{
					m.To.Clear();

					if (Vars.DevEnv || Vars.IsBeta)
					{
						m.Subject = "Test - " + m.Subject;
						m.Subject += " (" + DateTime.Now.ToString() + ")";
						m.To.Add(Vars.EMAIL_ADDRESS_DEV_TEAM);
						m.From = new System.Net.Mail.MailAddress(Vars.EMAIL_ADDRESS_ACCOUNTS);
					}
					else
					{
						foreach (Usr adminUsr in promoter.AdminUsrs)
						{							
							m.To.Add(adminUsr.Email);
						}
						m.CC.Add(Vars.EMAIL_ADDRESS_ACCOUNTS);
					}
					
					c.Send(m);

					Log.Increment(Log.Items.EmailsSent);
				}				
			}
		}
Exemplo n.º 30
0
		protected void Upload(object sender, EventArgs eventArgs)
		{
			int BagMaxWeight = 10000;
			System.Collections.Generic.Dictionary<string,int> Weight = new System.Collections.Generic.Dictionary<string,int>();
			Weight["A"] = 100;
			Weight["B"] = 500;
			Weight["C"] = 500;
			Weight["D"] = 500;
			Weight["E"] = 500;
			Weight["F"] = 20;

			#region Calculate mailing quantities
			int ItemsA, ItemsB, ItemsC, ItemsD, ItemsE, ItemsF = 0;

			#region UK 100g large letter 2nd class
			if (true)
			{
				//Query q = new Query();
				//q.QueryCondition = new And(
				//    new Q(Usr.Columns.CardStatus, Usr.CardStatusEnum.PrintingWelcomePack),
				//    new Q(Usr.Columns.AddressCountryK, 224)
				//);
				//q.ReturnCountOnly = true;
				//UsrSet us = new UsrSet(q);
				//ItemsA = us.Count;
				ItemsA = 0;
			}
			#endregion

			#region UK 500g large-letter 1st class
			if (true)
			{
				Query q = new Query();
				q.QueryCondition = new And(
					new Or(new Q(Usr.Columns.CardStatus, Usr.CardStatusEnum.PrintingRefill),new Q(Usr.Columns.CardStatus, Usr.CardStatusEnum.PrintingWelcomePack)),
					new Q(Usr.Columns.AddressCountryK, 224)
				);
				q.ReturnCountOnly = true;
				UsrSet us = new UsrSet(q);
				ItemsB = us.Count;
			}
			#endregion

			#region Western europe 500g large-letter 1st class format sort
			if (true)
			{
				Query q = new Query();
				q.QueryCondition = new And(
					new Or(
						new Q(Usr.Columns.CardStatus, Usr.CardStatusEnum.PrintingWelcomePack),
						new Q(Usr.Columns.CardStatus, Usr.CardStatusEnum.PrintingRefill)
					),
					new Q(Bobs.Country.Columns.PostageZone, Bobs.Country.PostageZones.WesternEurope)
				);
				q.TableElement = new Join(Usr.Columns.AddressCountryK, Bobs.Country.Columns.K);
				q.ReturnCountOnly = true;
				UsrSet us = new UsrSet(q);
				ItemsC = us.Count;
			}
			#endregion

			#region Europe 500g large-letter 1st class zone sort
			if (true)
			{
				Query q = new Query();
				q.QueryCondition = new And(
					new Or(
						new Q(Usr.Columns.CardStatus, Usr.CardStatusEnum.PrintingWelcomePack),
						new Q(Usr.Columns.CardStatus, Usr.CardStatusEnum.PrintingRefill)
					),
					new Q(Bobs.Country.Columns.PostageZone, Bobs.Country.PostageZones.RestOfEurope)
				);
				q.TableElement = new Join(Usr.Columns.AddressCountryK, Bobs.Country.Columns.K);
				q.ReturnCountOnly = true;
				UsrSet us = new UsrSet(q);
				ItemsD = us.Count;
			}
			#endregion

			#region Rest of world 500g large-letter 1st class zone sort
			if (true)
			{
				Query q = new Query();
				q.QueryCondition = new And(
					new Or(
						new Q(Usr.Columns.CardStatus, Usr.CardStatusEnum.PrintingWelcomePack),
						new Q(Usr.Columns.CardStatus, Usr.CardStatusEnum.PrintingRefill)
					),
					new Or(
						new Q(Bobs.Country.Columns.PostageZone, Bobs.Country.PostageZones.World1),
						new Q(Bobs.Country.Columns.PostageZone, Bobs.Country.PostageZones.World2)
					)
				);
				q.TableElement = new Join(Usr.Columns.AddressCountryK, Bobs.Country.Columns.K);
				q.ReturnCountOnly = true;
				UsrSet us = new UsrSet(q);
				ItemsE = us.Count;
			}
			#endregion

			#region UK Promoter letters (letter, 20g)
			if (true)
			{
				Query q = new Query();
				q.QueryCondition = new Q(Promoter.Columns.LetterStatus, Promoter.LetterStatusEnum.Printing);
				q.ReturnCountOnly = true;
				PromoterSet ps = new PromoterSet(q);
				ItemsF = ps.Count;
			}
			#endregion
			#endregion

			#region Calculate number of bags
			int BagsA = (int)Math.Ceiling(ItemsA * (double)Weight["A"] / (double)BagMaxWeight);
			int BagsB = (int)Math.Ceiling(ItemsB * (double)Weight["B"] / (double)BagMaxWeight);
			int BagsC = (int)Math.Ceiling(ItemsC * (double)Weight["C"] / (double)BagMaxWeight);
			int BagsD = (int)Math.Ceiling(ItemsD * (double)Weight["D"] / (double)BagMaxWeight);
			int BagsE = (int)Math.Ceiling(ItemsE * (double)Weight["E"] / (double)BagMaxWeight);
			int BagsF = (int)Math.Ceiling(ItemsF * (double)Weight["F"] / (double)BagMaxWeight);
			#endregion

			#region Get codes
			string CodeA = GetCode("STL", "01", Weight["A"], ItemsA, BagsA, "S", "L", "");
			string CodeB = GetCode("CRL", "01", Weight["B"], ItemsB, BagsB, "F", "F", "");
			string CodeC = GetCode("OF1", "01", Weight["C"], ItemsC, BagsC, "F", "F", "WEU");
			string CodeD = GetCode("OZ1", "01", Weight["D"], ItemsD, BagsD, "F", "F", "EUR");
			string CodeE = GetCode("OZ1", "01", Weight["E"], ItemsE, BagsE, "F", "F", "ROW");
			string CodeF = GetCode("STL", "01", Weight["F"], ItemsF, BagsF, "F", "L", "");
			#endregion

			#region Test (Removed)
		//	to test
			//Response.Write("<pre>");
			//Response.Write(CodeA);
			//Response.Write("\n");
			//Response.Write(CodeB);
			//Response.Write("\n");
			//Response.Write(CodeC);
			//Response.Write("\n");
			//Response.Write(CodeD);
			//Response.Write("\n");
			//Response.Write(CodeE);
			//Response.Write("\n");
			//Response.Write("</pre>");
			//return;
			#endregion

			#region Get transaction id's
			string TransactionA = "", TransactionB = "", TransactionC = "", TransactionD = "", TransactionE = "", TransactionF = "";
			if (ItemsA > 0)
				TransactionA = CreateTransaction(CodeA);
			if (ItemsB > 0)
				TransactionB = CreateTransaction(CodeB);
			if (ItemsC > 0)
				TransactionC = CreateTransaction(CodeC);
			if (ItemsD > 0)
				TransactionD = CreateTransaction(CodeD);
			if (ItemsE > 0)
				TransactionE = CreateTransaction(CodeE);
			if (ItemsF > 0)
				TransactionF = CreateTransaction(CodeF);
			#endregion

			#region Confirm transactions and get docket numbers
			string DocketA = "", DocketB = "", DocketC = "", DocketD = "", DocketE = "", DocketF = "";
			if (ItemsA > 0)
				DocketA = ConfirmTransaction(TransactionA);
			if (ItemsB > 0)
				DocketB = ConfirmTransaction(TransactionB);
			if (ItemsC > 0)
				DocketC = ConfirmTransaction(TransactionC);
			if (ItemsD > 0)
				DocketD = ConfirmTransaction(TransactionD);
			if (ItemsE > 0)
				DocketE = ConfirmTransaction(TransactionE);
			if (ItemsF > 0)
				DocketF = ConfirmTransaction(TransactionF);
			#endregion

			Response.Write("<body topmargin=\"0\" bottommargin=\"0\" leftmargin=\"0\" rightmargin=\"0\">");

			#region Create bag labels list
			List<BagLabelInfo> BagLabels = new List<BagLabelInfo>();
			for (int bagNumber=1; bagNumber<=BagsA; bagNumber++)
				BagLabels.Add(new BagLabelInfo("A", bagNumber, BagsA, DocketA));
			for (int bagNumber=1; bagNumber<=BagsB; bagNumber++)
				BagLabels.Add(new BagLabelInfo("B", bagNumber, BagsB, DocketB));
			for (int bagNumber=1; bagNumber<=BagsC; bagNumber++)
				BagLabels.Add(new BagLabelInfo("C", bagNumber, BagsC, DocketC));
			for (int bagNumber=1; bagNumber<=BagsD; bagNumber++)
				BagLabels.Add(new BagLabelInfo("D", bagNumber, BagsD, DocketD));
			for (int bagNumber=1; bagNumber<=BagsE; bagNumber++)
				BagLabels.Add(new BagLabelInfo("E", bagNumber, BagsE, DocketE));
			for (int bagNumber = 1; bagNumber <= BagsF; bagNumber++)
				BagLabels.Add(new BagLabelInfo("F", bagNumber, BagsF, DocketF));
			#endregion

			#region Write bag tag labels
			StringBuilder s = new StringBuilder();
			BagLabelInfo b;
			for (int count = 0; count < BagLabels.Count || (count % 8) != 0; count++)
			{
				if (count < BagLabels.Count)
					b = BagLabels[count];
				else
					b = null;

				if (count % 2 == 0 && count > 0)
				{
					s.Append("</tr>");
				}

				if (count % 8 == 0)
				{
					if (count > 0)
						s.Append("</table></div>");

					s.Append("<div style=\"page-break-after:always;\"><table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" height=\"100%\">");
				}

				if (count % 2 == 0)
				{
					s.Append("<tr>");
				}

				string padding = "";
				if (count % 2 != 0)
				{
					padding = " style=\"padding-left:10px;\"";
				}


				if (b == null)
					s.Append("<td width=\"50%\" height=\"25%\"" + padding + "></td>");
				else
				{
					s.Append("<td width=\"50%\" height=\"25%\"" + padding + ">");

					s.Append("<table width=\"95%\" height=\"90%\" style=\"margin:10px;\">");
					s.Append("<tr>");
					s.Append("<td valign=\"top\">");
					s.Append("Docket: " + b.DocketNumber + "<br>");
					s.Append("Account: 043767000<br>");
					s.Append("Poster: Development Hell Limited,<br>Greenhill House, Thorpe Road,<br>Peterborough, PE3 6RU<br>UNITED KINGDOM<br>");
					#region Zone
					if (b.FormatCode.Equals("C"))
						s.Append("<b>Zone: Western Europe</b><br>");
					else if (b.FormatCode.Equals("D"))
						s.Append("<b>Zone: Rest of Europe</b><br>");
					else if (b.FormatCode.Equals("E"))
						s.Append("<b>Zone: Rest of World</b><br>");
					else
						s.Append("<br>");
					#endregion
					#region Format
					if (b.FormatCode.Equals("F") || b.FormatCode.Equals("A"))
						s.Append("<b>Format: Letter</b><br>");
					else if (b.FormatCode.Equals("B"))
						s.Append("<b>Format: Large letter</b><br>");
					else
						s.Append("<b>Format: G</b><br>"); //P=Letter, G=Large letter, E=Packet
					#endregion
					s.Append("<br><br><br>");
					#region Tag helper
					if (b.FormatCode.Equals("A"))
						s.Append("(green, 2nd class tag)");
					else if (b.FormatCode.Equals("F"))
						s.Append("(red, 1st class tag)");
					else if (b.FormatCode.Equals("B"))
						s.Append("(red, 1st class tag)");
					else
						s.Append("(large white international tag)");
					#endregion
					s.Append("</td>");
					s.Append("<td align=\"right\" valign=\"top\">");
					s.Append("<b>Bag:<br>" + b.BagNumber + " of " + b.TotalBags + "</b><br><br>");
					#region Mail seperation symbol
					s.Append("<img src=\"/gfx/mail-symbol-" + b.FormatCode.ToLower() + ".gif\" width=\"35\"/><br>");
					#endregion
					#region Packaging format symbol
					if (b.FormatCode.Equals("A") || b.FormatCode.Equals("F"))
						s.Append("<img src=\"/gfx/mail-format-envelope-a5.gif\" width=\"30\"/>");
					else
						s.Append("<img src=\"/gfx/mail-format-box.gif\" width=\"30\"/>");
					#endregion

					s.Append("</td>");
					s.Append("</tr>");
					s.Append("</table>");

					s.Append("</td>");
				}
			}
			s.Append("</tr></table></div>");

			Response.Write(s.ToString());
			#endregion

			#region Reset database (only on live site)
			if (!Vars.DevEnv)
			{
				Query q = new Query();
				q.NoLock = true;
				q.QueryCondition = new Or(
					new Q(Usr.Columns.CardStatus, Usr.CardStatusEnum.PrintingWelcomePack),
					new Q(Usr.Columns.CardStatus, Usr.CardStatusEnum.PrintingRefill));
				UsrSet us = new UsrSet(q);
				foreach (Usr u in us)
				{
					if (u.CardStatus.Equals(Usr.CardStatusEnum.PrintingWelcomePack))
					{
						u.CardStatus = Usr.CardStatusEnum.WelcomePackInPost;
						if (u.AddressCountryK == 224)
							u.TotalCardsSent += 60;
						else
							u.TotalCardsSent += 360;
					}
					else
					{
						u.CardStatus = Usr.CardStatusEnum.CardsInPost;
						u.TotalCardsSent += 360;
					}

					u.Update();
				}

				Query q1 = new Query();
				q1.QueryCondition = new Q(Promoter.Columns.LetterStatus, Promoter.LetterStatusEnum.Printing);
				PromoterSet ps = new PromoterSet(q1);
				Usr dsi = new Usr(8);
				foreach (Promoter p in ps)
				{
					p.LetterStatus = Promoter.LetterStatusEnum.Posted;
					p.SalesHold = false;
					p.SalesNextCall = DateTime.Today.AddDays(5);
					p.Update();
					p.AddNote("Sent tickets domain intro letter", Guid.NewGuid(), dsi);
				}

			}
			#endregion

			#region Log mailing
			Log.Increment(Log.Items.MailUkSmall, ItemsA);
			Log.Increment(Log.Items.MailUkLarge, ItemsB);
			Log.Increment(Log.Items.MailWestEurope, ItemsC);
			Log.Increment(Log.Items.MailRestEurope, ItemsD);
			Log.Increment(Log.Items.MailRestWorld, ItemsE);
			Log.Increment(Log.Items.MailPromoterLetters, ItemsF);
			#endregion

			Response.Write("</body>");

			Response.End();

			

		}