Exemplo n.º 1
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.º 2
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();
		}
Exemplo n.º 3
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.º 4
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.º 5
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.º 6
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.º 7
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.º 8
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.º 9
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.º 10
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.º 11
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.º 12
0
		public static void CreatePromoterXml(int promoterK)
		{
			string fileSystemPath = "";

			Query qu = new Query();
			qu.QueryCondition = new Q(Promoter.Columns.Status, QueryOperator.NotEqualTo, Promoter.StatusEnum.Disabled);
			qu.OrderBy = new OrderBy(Promoter.Columns.Name);
			if (promoterK > 0)
			{
				qu.QueryCondition = new And(qu.QueryCondition, new Q(Promoter.Columns.K, promoterK));
				fileSystemPath = @"\\jabba\d$\Shared\Maximizer\Promoters\" + promoterK.ToString() + ".mxi";
				
				string fileSystemPathBatch = "";
				fileSystemPathBatch = @"\\jabba\d$\Shared\Maximizer\Promoters\import-" + promoterK.ToString() + ".bat";

				File.Delete(fileSystemPathBatch);

				using (StreamWriter swBatch = new StreamWriter(fileSystemPathBatch))
				{
					swBatch.Write(@"""c:\Program Files\Maximizer\Maxwin.exe"" /DATABASE ""DontStayIn"" /USERID ""MASTER"" /PASSWORD ""author72insert"" /FILE=""Z:\Maximizer\Promoters\" + promoterK.ToString() + @".mxi""");
				}

			}
			else
			{
				if (Vars.DevEnv)
					fileSystemPath = @"C:\inetpub\DontStayIn\PromoterXmlTmp\promoters.mxi";
				else
					fileSystemPath = @"\\" + Vars.ExtraIp + @"\d$\DontStayIn\Live\DontStayInTemp\promoters.mxi";
			}

			PromoterSet ps = new PromoterSet(qu);

			File.Delete(fileSystemPath);

			using (FileStream fs = File.OpenWrite(fileSystemPath))
			{
				XmlTextWriter x = new XmlTextWriter(fs, System.Text.Encoding.UTF8);
				x.Formatting = Formatting.Indented;

				#region AllData
				x.WriteStartElement("AllData");
				#region DetailDef NickName
				x.WriteStartElement("DetailDef");
				x.WriteAttributeString("Name", "NickName");
				x.WriteAttributeString("Type", "String");
				x.WriteAttributeString("Length", "20");
				x.WriteAttributeString("Companies", "No");
				x.WriteAttributeString("Individuals", "No");
				x.WriteAttributeString("Contacts", "Yes");
				x.WriteEndElement();	//DetailDef
				#endregion
				#region DetailDef Brands
				x.WriteStartElement("DetailDef");
				x.WriteAttributeString("Name", "Brands");
				x.WriteAttributeString("Type", "String");
				x.WriteAttributeString("Length", "255");
				x.WriteAttributeString("Companies", "Yes");
				x.WriteAttributeString("Individuals", "No");
				x.WriteAttributeString("Contacts", "No");
				x.WriteEndElement();	//DetailDef
				#endregion
				#region DetailDef Venues
				x.WriteStartElement("DetailDef");
				x.WriteAttributeString("Name", "Venues");
				x.WriteAttributeString("Type", "String");
				x.WriteAttributeString("Length", "255");
				x.WriteAttributeString("Companies", "Yes");
				x.WriteAttributeString("Individuals", "No");
				x.WriteAttributeString("Contacts", "No");
				x.WriteEndElement();	//DetailDef
				#endregion
				#region DetailDef Discount
				x.WriteStartElement("DetailDef");
				x.WriteAttributeString("Name", "Discount");
				x.WriteAttributeString("Type", "Number");
				x.WriteAttributeString("Length", "0");
				x.WriteAttributeString("Companies", "Yes");
				x.WriteAttributeString("Individuals", "No");
				x.WriteAttributeString("Contacts", "No");
				x.WriteEndElement();	//DetailDef
				#endregion
				#region DetailDef Enabled
				x.WriteStartElement("DetailDef");
				x.WriteAttributeString("Name", "Enabled");
				x.WriteAttributeString("Type", "Number");
				x.WriteAttributeString("Length", "0");
				x.WriteAttributeString("Companies", "Yes");
				x.WriteAttributeString("Individuals", "No");
				x.WriteAttributeString("Contacts", "No");
				x.WriteEndElement();	//DetailDef
				#endregion
				#region DetailDef SignedUp
				x.WriteStartElement("DetailDef");
				x.WriteAttributeString("Name", "SignedUp");
				x.WriteAttributeString("Type", "Date");
				x.WriteAttributeString("Length", "0");
				x.WriteAttributeString("Companies", "Yes");
				x.WriteAttributeString("Individuals", "No");
				x.WriteAttributeString("Contacts", "No");
				x.WriteEndElement();	//DetailDef
				#endregion
				#region DetailDef Revenue
				x.WriteStartElement("DetailDef");
				x.WriteAttributeString("Name", "Revenue");
				x.WriteAttributeString("Type", "Number");
				x.WriteAttributeString("Length", "2");
				x.WriteAttributeString("Companies", "Yes");
				x.WriteAttributeString("Individuals", "No");
				x.WriteAttributeString("Contacts", "No");
				x.WriteEndElement();	//DetailDef
				#endregion
				#region DetailDef ClientsPerMonth
				x.WriteStartElement("DetailDef");
				x.WriteAttributeString("Name", "ClientsPerMonth");
				x.WriteAttributeString("Type", "Number");
				x.WriteAttributeString("Length", "0");
				x.WriteAttributeString("Companies", "Yes");
				x.WriteAttributeString("Individuals", "No");
				x.WriteAttributeString("Contacts", "No");
				x.WriteEndElement();	//DetailDef
				#endregion
				for (DateTime d = new DateTime(2005, 1, 1); d < new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1); d = d.AddMonths(1))
				{
					#region DetailDef Sales\Revenue YYYY-MM
					x.WriteStartElement("DetailDef");
					x.WriteAttributeString("Name", "Sales\\Revenue " + d.ToString("yyyy-MM"));
					x.WriteAttributeString("Type", "Number");
					x.WriteAttributeString("Length", "2");  // ********
					x.WriteAttributeString("Companies", "Yes");
					x.WriteAttributeString("Individuals", "No");
					x.WriteAttributeString("Contacts", "No");
					x.WriteEndElement();	//DetailDef
					#endregion
				}
				for (int count = 0; count < ps.Count; count++)
				{
					Promoter p = ps[count];

					//if (count % 10 == 0)
					Cambro.Web.Helpers.WriteAlert("Processing promoter (" + count + "/" + ps.Count + "): " + p.UrlName, 1);

					#region Company
					x.WriteStartElement("Company");
					x.WriteElementString("Name", Cambro.Misc.Utility.Snip(p.Name, 41));
					x.WriteElementString("Id", "Promoter-" + p.K);
					x.WriteElementString("Website", "http://www.dontstayin.com" + p.Url());
					#region Phone
					x.WriteStartElement("Phone");
					x.WriteElementString("Number", PromoterXmlFixPhone(p.PhoneNumber));
					x.WriteEndElement();	//Phone
					#endregion
					try
					{
						string email = p.PrimaryUsr.Email;
						#region Email
						x.WriteStartElement("Email");
						x.WriteElementString("Address", email);
						x.WriteEndElement();	//Email
						#endregion
					}
					catch
					{

					}

					#region Address
					x.WriteStartElement("Address");
					x.WriteElementString("AddressLine1", p.AddressStreet);
					x.WriteElementString("AddressLine2", p.AddressArea);
					x.WriteElementString("City", p.AddressTown);
					x.WriteElementString("StateProvince", p.AddressCounty);
					x.WriteElementString("Country", p.AddressCountry.Name);
					x.WriteElementString("ZipCode", p.AddressPostcode.ToUpper());
					x.WriteEndElement();	//Address
					#endregion

					#region DetailDate SignedUp
					x.WriteStartElement("DetailDate");
					x.WriteAttributeString("Name", "SignedUp");
					x.WriteString(p.DateTimeSignUp.ToString("yyyy-MM-dd"));
					x.WriteEndElement();	//DetailDate
					#endregion

					#region DetailNumber Discount
					x.WriteStartElement("DetailNumber");
					x.WriteAttributeString("Name", "Discount");
					double discount = (1 - p.PricingMultiplier) * 100;
					x.WriteString(discount.ToString("0"));
					x.WriteEndElement();	//DetailString
					#endregion


					int ClientsPerMonth = 0;
					if (true)
					{
						//First event...
						Query qFirstEvent = new Query();
						qFirstEvent.TableElement = Event.PromoterJoinWithVenue;
						qFirstEvent.TopRecords = 1;
						qFirstEvent.QueryCondition = new Q(Promoter.Columns.K, p.K);
						qFirstEvent.OrderBy = new OrderBy(Event.Columns.DateTime);
						EventSet esFirstEvent = new EventSet(qFirstEvent);
						DateTime FirstEventDateTime = DateTime.Now;
						if (esFirstEvent.Count > 0)
						{
							Query q = new Query();
							q.Columns = new ColumnSet();
							q.ExtraSelectElements.Add("Capacity", "sum([Event].[Capacity])");
							q.TableElement = Event.PromoterJoinWithVenue;
							q.QueryCondition = new And(new Q(Promoter.Columns.K, p.K), new Q(Event.Columns.DateTime, QueryOperator.LessThanOrEqualTo, DateTime.Now));
							if (esFirstEvent[0].DateTime < DateTime.Now.AddMonths(-3))
							{
								FirstEventDateTime = DateTime.Now.AddMonths(-3);
								q.QueryCondition = new And(q.QueryCondition, new Q(Event.Columns.DateTime, QueryOperator.GreaterThan, DateTime.Now.AddMonths(-3)));
							}
							else
								FirstEventDateTime = esFirstEvent[0].DateTime;
							EventSet es = new EventSet(q);

							if (es.Count > 0)
							{
								try
								{
									int capacity = (int)es[0].ExtraSelectElements["Capacity"];
									TimeSpan ts = DateTime.Now - FirstEventDateTime;
									double capPerDay = (double)capacity / ts.TotalDays;
									double capPerMonth = capPerDay * 30;
									ClientsPerMonth = (int)capPerMonth;
								}
								catch
								{

								}
							}
						}
					}

					#region DetailNumber
					x.WriteStartElement("DetailNumber");
					x.WriteAttributeString("Name", "ClientsPerMonth");
					x.WriteString(ClientsPerMonth.ToString());
					x.WriteEndElement();	//DetailNumber
					#endregion

					#region DetailNumber
					x.WriteStartElement("DetailNumber");
					x.WriteAttributeString("Name", "Enabled");
					x.WriteString(p.Status.Equals(Promoter.StatusEnum.Active) ? "1" : "0");
					x.WriteEndElement();	//DetailNumber
					#endregion

					double totalRevenue = 0.0;
					if (true)
					{
						Query q = new Query();
						q.ExtraSelectElements.Add("sum", "SUM(Total)");
						q.ExtraSelectElements.Add("year", "YEAR(PaidDateTime)");
						q.ExtraSelectElements.Add("month", "MONTH(PaidDateTime)");
						q.QueryCondition = new Q(Invoice.Columns.PromoterK, p.K);
						q.GroupBy = new GroupBy("YEAR(PaidDateTime), MONTH(PaidDateTime)");
						q.OrderBy = new OrderBy("YEAR(PaidDateTime) DESC, MONTH(PaidDateTime) DESC");
						q.Columns = new ColumnSet();
						InvoiceSet ins = new InvoiceSet(q);

						foreach (Invoice i in ins)
						{
							try
							{
								double revenue = (double)i.ExtraSelectElements["sum"];
								totalRevenue += revenue;
								int month = (int)i.ExtraSelectElements["month"];
								int year = (int)i.ExtraSelectElements["year"];

								#region DetailNumber
								x.WriteStartElement("DetailNumber");
								x.WriteAttributeString("Name", "Sales\\Revenue " + year.ToString("0000") + "-" + month.ToString("00"));
								x.WriteString(revenue.ToString("0.00"));
								x.WriteEndElement();	//DetailNumber
								#endregion

							}
							catch { }
						}
					}

					#region DetailNumber
					x.WriteStartElement("DetailNumber");
					x.WriteAttributeString("Name", "Revenue");
					x.WriteString(totalRevenue.ToString("0.00"));
					x.WriteEndElement();	//DetailNumber
					#endregion


					if (p.ConfirmedBrands.Count > 0)
					{
						#region DetailString
						x.WriteStartElement("DetailString");
						x.WriteAttributeString("Name", "Brands");
						bool done = false;
						foreach (Brand b in p.ConfirmedBrands)
						{
							x.WriteString((done ? ", " : "") + b.Name);
							done = true;
						}
						x.WriteEndElement();	//DetailString
						#endregion
					}
					if (p.ConfirmedVenues.Count > 0)
					{
						#region DetailString
						x.WriteStartElement("DetailString");
						x.WriteAttributeString("Name", "Venues");
						bool done = false;
						foreach (Venue v in p.ConfirmedVenues)
						{
							x.WriteString((done ? ", " : "") + v.FriendlyName);
							done = true;
						}
						x.WriteEndElement();	//DetailString
						#endregion
					}

					foreach (Usr u in p.AdminUsrs)
					{
						#region Contact
						x.WriteStartElement("Contact");
						x.WriteElementString("FirstName", u.FirstName);
						x.WriteElementString("LastName", u.LastName);
						x.WriteElementString("Website", "http://www.dontstayin.com" + u.Url());
						if (u.Mobile.Length > 0)
						{
							#region Phone
							x.WriteStartElement("Phone");
							x.WriteElementString("Number", "+" + u.Mobile);
							x.WriteElementString("Description", "Mobile");
							x.WriteEndElement();	//Phone
							#endregion
						}
						#region Email
						x.WriteStartElement("Email");
						x.WriteElementString("Address", u.Email);
						x.WriteEndElement();	//Email
						#endregion
						#region DetailString
						x.WriteStartElement("DetailString");
						x.WriteAttributeString("Name", "NickName");
						x.WriteString(u.NickName);
						x.WriteEndElement();	//DetailString
						#endregion
						x.WriteEndElement();	//Contact
						#endregion
					}
					x.WriteEndElement();	//Company

					#endregion

					ps.Kill(count);
				}
				x.WriteEndElement();	//AllData
				#endregion

				x.Flush();
				x.Close();

			}
		}