private static int Comparison(CompSet set1, CompSet set2)
        {
            var list1  = set1.getComponents();
            var list2  = set2.getComponents();
            var length = list1.Count < list2.Count ? list1.Count : list2.Count;

            for (var i = 0; i < length; i++)
            {
                if (list1[i].Id > list2[i].Id)
                {
                    return(1);
                }
                if (list1[i].Id < list2[i].Id)
                {
                    return(-1);
                }
            }

            if (list1.Count == list2.Count)
            {
                return(0);
            }

            return(list1.Count < list2.Count ? 1 : -1);
        }
示例#2
0
        //return the conflict
        private static CompSet conflictMinstComponent(CompSet conflict, Gate gate)
        {
            if (conflict == null || conflictConatinsComponent(conflict, gate) == false)
            {
                return(conflict);
            }
            List <Gate> gates = conflict.getComponents();

            gates = removeGateFromSet(gates, gate);

            Conflict retValConflict = new Conflict(gates);

            return(retValConflict);
        }
示例#3
0
            int IComparable <Rl> .CompareTo(Rl other)
            {
                //11/8                if (Flag && !other.Flag) return -1;
                //11/8                if (!Flag && other.Flag) return 1;
                int result = -CompSet.CompareTo(other.CompSet);

                if (result == 0)
                {
                    result = Supplier.CompareTo(other.Supplier);
                }
                if (result == 0)
                {
                    result = RuleText.CompareTo(other.RuleText);
                }
                return(result);
            }
示例#4
0
        //returns true of the conflict (i.e. Compset) contains gate, or false otherwise
        private static bool conflictConatinsComponent(CompSet conflict, Gate gate)
        {
            if (conflict == null)
            {
                return(false);
            }
            List <Gate> gates = conflict.getComponents();

            foreach (Gate g in gates)
            {
                if (g != null && g.CompareTo(gate) == 0)
                {
                    return(true);
                }
            }
            return(false);
        }
示例#5
0
        //Creates a new conflict set with the conflicts that contain the gate
        //{ c\gate | c in conflicts }
        public static ConflictSet ConflictsMinusComponent(ConflictSet conflicts, Gate gate)
        {
            ConflictSet     retValConflictSet   = new ConflictSet();
            List <Conflict> retValConflictsList = new List <Conflict>();

            if (conflicts == null)
            {
                return(retValConflictSet);
            }
            List <CompSet> conflictsList = conflicts.getSets();

            foreach (CompSet conflict in conflictsList)
            {
                CompSet conflictMinusGate = conflictMinstComponent(conflict, gate);
                retValConflictsList.Add((Conflict)conflictMinusGate);
            }
            retValConflictSet.Conflicts = retValConflictsList;
            return(retValConflictSet);
        }
示例#6
0
        public void UT_CompSet_init()
        {
            string      LoadDescriptor = "M:1; опис:3; профиль:2; цена: 4; Ед: руб/т";
            List <Comp> comps          = new List <Comp>()
            {
                new Comp(new DP("Prf:I10")),
                new Comp(new DP("Prf:I20"))
            };
            Supl    supl = new Supl("СтальХолдинг", init: false);
            CompSet cs   = new CompSet("Балка", supl, LoadDescriptor, comps);

            Assert.AreEqual("Балка", cs.name);
            Assert.AreEqual("1", cs.csDP.dpar[SType.Material]);
            Assert.AreEqual("2", cs.csDP.dpar[SType.Profile]);
            Assert.AreEqual("3", cs.csDP.dpar[SType.Description]);
            Assert.AreEqual("4", cs.csDP.dpar[SType.Price]);
            Assert.AreEqual("СтальХолдинг", cs.Supplier.Name);
            Assert.AreEqual(2, cs.Components.Count);
            Assert.AreEqual("I10", cs.Components[0].Str(SType.Profile));
            Assert.AreEqual("I20", cs.Components[1].Str(SType.Profile));
        }
示例#7
0
        public void UT_CompSet_init_Naive()
        {
            boot.Init();
            Mod mod = new Mod();

            // test 0: бетон -> должен быть DP[UNIT_Vol]
            Supl    spl = new Supl("ГК Монолит СПб");
            CompSet csb = new CompSet("Товарный бетон", spl);

            Assert.IsNotNull(csb);
            Assert.IsNotNull(csb.csDP);
            Assert.AreEqual(4, csb.csDP.dpStr.Count);
            Assert.IsTrue(csb.csDP.dpar.ContainsKey(SType.UNIT_Vol));

            // test 1: after bug "Ед: руб/т" не попадал в compDP -> compDP содержит SType.UNIT_Weight
            Supl    supl = new Supl("ЛенСпецСталь");
            CompSet cs   = new CompSet("Полоса", supl);

            Assert.IsTrue(cs.csDP.dpar.ContainsKey(SType.UNIT_Weight));


            // test 2: Check if all Rules have CompSet with Section Unit_
            mod = mod.sr.SetModel(boot, initSupl: true);
            Assert.IsTrue(mod.Rules.Count > 0);
            Rule.Rule r = mod.Rules.ToList()[3];

            foreach (var rule in mod.Rules)
            {
                var  csDP = rule.CompSet.csDP;
                bool bw   = csDP.dpStr.ContainsKey(SType.UNIT_Weight);
                bool bv   = csDP.dpStr.ContainsKey(SType.UNIT_Vol);
                Assert.IsTrue(bw || bv);
            }

            FileOp.AppQuit();
        }
示例#8
0
		public void DeleteAll(Transaction transaction)
		{
			if (!this.Bob.DbRecordExists)
				return;

			//EventBrands
			Delete BrandDelete = new Delete(
				TablesEnum.EventBrand,
				new Q(EventBrand.Columns.BrandK, this.K)
				);
			BrandDelete.Run(transaction);

			CompSet cs = new CompSet(new Query(new Q(Comp.Columns.BrandK, this.K)));
			foreach (Comp c in cs)
			{
				c.BrandK = 0;
				c.LinkType = Comp.LinkTypes.None;
				c.Update();
			}

			try
			{
				this.Group.DeleteAll(transaction);
			}
			catch { }

			Guid oldPic = this.HasPic ? this.Pic : Guid.Empty;
			int oldPicMiscK = this.PicMisc != null ? this.PicMiscK : 0;

			this.Delete(transaction);

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

			if (oldPicMiscK > 0)
			{
				Misc m = new Misc(oldPicMiscK);
				m.DeleteAll(transaction);
			}
		}
		private void Page_Load(object sender, System.EventArgs e)
		{
			if (this.Visible)
			{
				string name = "";
				if (Type.Equals(ArchiveObjectType.Gallery))
				{
					name = "Galleries";
					TitleSpan.InnerHtml = "galleries";
				}
				else if (Type.Equals(ArchiveObjectType.Article))
				{
					if (IsMixmagArchive)
					{
						name = "Mixmag articles";
						TitleSpan.InnerHtml = " <a href=\"/pages/mixmag\"><img src=\"/gfx/logo-mixmag-small.png\" border=\"0\" align=\"absmiddle\" width=\"100\" height=\"22\"></a> articles";
					}
					else
					{
						name = "Articles";
						TitleSpan.InnerHtml = "articles";
					}
				}
				else if (Type.Equals(ArchiveObjectType.Comp))
				{
					name = "Competitions";
					TitleSpan.InnerHtml = "competitions";
				}
				else if (Type.Equals(ArchiveObjectType.News))
				{
					name = "News";
					TitleSpan.InnerHtml = "news";
				}
				else if (Type.Equals(ArchiveObjectType.Review))
				{
					name = "Reviews";
					TitleSpan.InnerHtml = "reviews";
				}
				else if (Type.Equals(ArchiveObjectType.Guestlist))
				{
					name = "Guestlists";
					TitleSpan.InnerHtml = "guestlists";
				}

				name += " archive";
				TitleSpan.InnerHtml += " archive";

				if (ContainerPage.Url.HasObjectFilter && ContainerPage.Url.ObjectFilterBob is IHasArchive)
					name += " for " + ((IName)ContainerPage.Url.ObjectFilterBob).FriendlyName;

				if (ContainerPage.Url.HasCountryObjectFilter)
				{
					TitleSpan.InnerHtml += " for <a href=\"" + ContainerPage.Url.ObjectFilterCountry.Url() + "\">" + ContainerPage.Url.ObjectFilterCountry.FriendlyName + "</a>";
				}
				else if (ContainerPage.Url.HasPlaceObjectFilter)
				{
					TitleSpan.InnerHtml += " for <a href=\"" + ContainerPage.Url.ObjectFilterPlace.Url() + "\">" + ContainerPage.Url.ObjectFilterPlace.Name + "</a>";
				}
				else if (ContainerPage.Url.HasVenueObjectFilter)
				{
					TitleSpan.InnerHtml += " for <a href=\"" + ContainerPage.Url.ObjectFilterVenue.Url() + "\">" + ContainerPage.Url.ObjectFilterVenue.Name + "</a> in <a href=\"" + ContainerPage.Url.ObjectFilterVenue.Place.Url() + "\">" + ContainerPage.Url.ObjectFilterVenue.Place.Name + "</a>";
				}
				else if (ContainerPage.Url.HasObjectFilter && ContainerPage.Url.ObjectFilterBob is IPage && ContainerPage.Url.ObjectFilterBob is IName)
				{
					TitleSpan.InnerHtml += " for <a href=\"" + ((IPage)ContainerPage.Url.ObjectFilterBob).Url() + "\">" + ((IName)ContainerPage.Url.ObjectFilterBob).Name + "</a>";
				}

				name += " - " + ContainerPage.Url.DateFilter.ToString("MMMM") + " " + ContainerPage.Url.DateFilter.Year.ToString();

				Header.InnerText = name;
				ContainerPage.SetPageTitle(name);

				#region firstCellDate, lastCellDate
				DateTime firstOfMonth = new DateTime(ContainerPage.Url.DateFilter.Year, ContainerPage.Url.DateFilter.Month, 1);
				DateTime firstCellDate = firstOfMonth.AddDays(-(int)firstOfMonth.DayOfWeek + 1);
				if (firstOfMonth.DayOfWeek.Equals(DayOfWeek.Sunday))
					firstCellDate = firstOfMonth.AddDays(-6);

				DateTime lastOfMonth = firstOfMonth.AddDays(System.DateTime.DaysInMonth(ContainerPage.Url.DateFilter.Year, ContainerPage.Url.DateFilter.Month) - 1);
				int daysToAdd = 7 - (int)lastOfMonth.DayOfWeek;
				if (daysToAdd == 7)
					daysToAdd = 0;
				DateTime lastCellDate = lastOfMonth.AddDays(daysToAdd);
				if (lastOfMonth.DayOfWeek.Equals(DayOfWeek.Sunday))
					lastCellDate = lastOfMonth;
				#endregion

				Query queryAll = new Query();
				queryAll.QueryCondition = new And(
					ObjectFilter,
					GeneralFilter,
					new Q(DateColumn, QueryOperator.GreaterThanOrEqualTo, firstCellDate),
					new Q(DateColumn, QueryOperator.LessThan, lastCellDate.AddDays(1))
				);
				queryAll.OrderBy = OrderBy;
				queryAll.TableElement = TableElement;

				BobSet bs = null;
				if (Type.Equals(ArchiveObjectType.Gallery))
					bs = new GallerySet(queryAll);
				else if (Type.Equals(ArchiveObjectType.Article))
					bs = new ArticleSet(queryAll);
				else if (Type.Equals(ArchiveObjectType.Comp))
					bs = new CompSet(queryAll);
				else if (Type.Equals(ArchiveObjectType.News) || Type.Equals(ArchiveObjectType.Review))
					bs = new ThreadSet(queryAll);
				else if (Type.Equals(ArchiveObjectType.Guestlist))
					bs = new EventSet(queryAll);

				ItemsHiddenP.Visible = bs.Count > 150;

				if (ContainerPage.Url.HasDayFilter)
				{
					Query queryDay = new Query();
					queryDay.QueryCondition = new And(
						ObjectFilter,
						GeneralFilter,
						new Q(DateColumn, QueryOperator.GreaterThanOrEqualTo, ContainerPage.Url.DateFilter),
						new Q(DateColumn, QueryOperator.LessThan, ContainerPage.Url.DateFilter.AddDays(1))
					);
					queryDay.OrderBy = OrderBy;
					queryDay.TableElement = TableElement;

					if (Type.Equals(ArchiveObjectType.Gallery))
						DayRepeater.DataSource = new GallerySet(queryDay);
					else if (Type.Equals(ArchiveObjectType.Article))
						DayRepeater.DataSource = new ArticleSet(queryDay);
					else if (Type.Equals(ArchiveObjectType.Comp))
						DayRepeater.DataSource = new CompSet(queryDay);
					else if (Type.Equals(ArchiveObjectType.News) || Type.Equals(ArchiveObjectType.Review))
						DayRepeater.DataSource = new ThreadSet(queryDay);
					else if (Type.Equals(ArchiveObjectType.Guestlist))
						DayRepeater.DataSource = new EventSet(queryDay);

					DayRepeater.DataBind();
				}
				else
					DayItemsP.Visible = false;


				Arch.ShowCountry = ShowCountry;
				Arch.ShowPlace = ShowPlace;
				Arch.ShowVenue = ShowVenue;
				Arch.ShowEvent = ShowEvent;
				Arch.Objects = bs;
				Arch.Type = Type;
				Arch.Month = ContainerPage.Url.DateFilter.Month;
				Arch.StartDate = firstCellDate;
				Arch.EndDate = lastCellDate;

				MonthNameLabel.Text = firstOfMonth.ToString("MMMM") + " " + ContainerPage.Url.DateFilter.Year.ToString();
				MonthNameLabel1.Text = firstOfMonth.ToString("MMMM") + " " + ContainerPage.Url.DateFilter.Year.ToString();

				BackLink.InnerHtml = "&lt; " + firstOfMonth.AddDays(-1).ToString("MMMM");
				BackLink1.InnerHtml = "&lt; " + firstOfMonth.AddDays(-1).ToString("MMMM");
				BackLink.HRef = Link(firstOfMonth.AddDays(-1).Year, firstOfMonth.AddDays(-1).Month, 0, Type);
				BackLink1.HRef = Link(firstOfMonth.AddDays(-1).Year, firstOfMonth.AddDays(-1).Month, 0, Type);

				NextLink.InnerHtml = lastOfMonth.AddDays(1).ToString("MMMM") + " &gt;";
				NextLink1.InnerHtml = lastOfMonth.AddDays(1).ToString("MMMM") + " &gt;";
				NextLink.HRef = Link(lastOfMonth.AddDays(1).Year, lastOfMonth.AddDays(1).Month, 0, Type);
				NextLink1.HRef = Link(lastOfMonth.AddDays(1).Year, lastOfMonth.AddDays(1).Month, 0, Type);

				#region Set up back / next buttons
				if (bs.Count == 0)
				{
					#region moreFutureBs
					Query moreFutureQuery = new Query();
					moreFutureQuery.QueryCondition = new And(
						ObjectFilter,
						GeneralFilter,
						new Q(DateColumn, QueryOperator.GreaterThanOrEqualTo, new DateTime(lastOfMonth.AddDays(1).Year, lastOfMonth.AddDays(1).Month, 1))
						);
					moreFutureQuery.TopRecords = 1;
					moreFutureQuery.OrderBy = new OrderBy(DateColumn, OrderBy.OrderDirection.Ascending);
					moreFutureQuery.TableElement = TableElement;
					BobSet moreFutureBs = null;
					if (Type.Equals(ArchiveObjectType.Gallery))
						moreFutureBs = new GallerySet(moreFutureQuery);
					else if (Type.Equals(ArchiveObjectType.Article))
						moreFutureBs = new ArticleSet(moreFutureQuery);
					else if (Type.Equals(ArchiveObjectType.Comp))
						moreFutureBs = new CompSet(moreFutureQuery);
					else if (Type.Equals(ArchiveObjectType.News) || Type.Equals(ArchiveObjectType.Review))
						moreFutureBs = new ThreadSet(moreFutureQuery);
					else if (Type.Equals(ArchiveObjectType.Guestlist))
						moreFutureBs = new EventSet(moreFutureQuery);
					#endregion
					#region morePastBs
					Query morePastQuery = new Query();
					morePastQuery.QueryCondition = new And(
						ObjectFilter,
						GeneralFilter,
						new Q(DateColumn, QueryOperator.LessThan, new DateTime(ContainerPage.Url.DateFilter.Year, ContainerPage.Url.DateFilter.Month, 1))
					);
					morePastQuery.TopRecords = 1;
					morePastQuery.OrderBy = new OrderBy(DateColumn, OrderBy.OrderDirection.Descending);
					morePastQuery.TableElement = TableElement;
					BobSet morePastBs = null;
					if (Type.Equals(ArchiveObjectType.Gallery))
						morePastBs = new GallerySet(morePastQuery);
					else if (Type.Equals(ArchiveObjectType.Article))
						morePastBs = new ArticleSet(morePastQuery);
					else if (Type.Equals(ArchiveObjectType.Comp))
						morePastBs = new CompSet(morePastQuery);
					else if (Type.Equals(ArchiveObjectType.News) || Type.Equals(ArchiveObjectType.Review))
						morePastBs = new ThreadSet(morePastQuery);
					else if (Type.Equals(ArchiveObjectType.Guestlist))
						morePastBs = new EventSet(morePastQuery);
					#endregion

					if (morePastBs.Count == 0)
					{
						BackLink.HRef = "";
						BackLink1.HRef = "";
						BackLink.Disabled = true;
						BackLink1.Disabled = true;
					}
					else
					{
						IArchive latest = (IArchive)morePastBs.GetFromIndex(0);
						BackLink.HRef = Link(latest.ArchiveDateTime.Year, latest.ArchiveDateTime.Month, 0, Type);
						BackLink1.HRef = Link(latest.ArchiveDateTime.Year, latest.ArchiveDateTime.Month, 0, Type);
						BackLink.InnerHtml = "&lt; " + latest.ArchiveDateTime.ToString("MMMM");
						BackLink1.InnerHtml = "&lt; " + latest.ArchiveDateTime.ToString("MMMM");
						if (latest.ArchiveDateTime.Year != ContainerPage.Url.DateFilter.Year)
						{
							BackLink.InnerHtml = "&lt; " + latest.ArchiveDateTime.ToString("MMMM") + " " + latest.ArchiveDateTime.Year.ToString();
							BackLink1.InnerHtml = "&lt; " + latest.ArchiveDateTime.ToString("MMMM") + " " + latest.ArchiveDateTime.Year.ToString();
						}
					}

					if (moreFutureBs.Count == 0)
					{
						NextLink.HRef = "";
						NextLink1.HRef = "";
						NextLink.Disabled = true;
						NextLink1.Disabled = true;
					}
					else
					{
						IArchive first = (IArchive)moreFutureBs.GetFromIndex(0);
						NextLink.HRef = Link(first.ArchiveDateTime.Year, first.ArchiveDateTime.Month, 0, Type);
						NextLink1.HRef = Link(first.ArchiveDateTime.Year, first.ArchiveDateTime.Month, 0, Type);
						NextLink.InnerHtml = first.ArchiveDateTime.ToString("MMMM") + " &gt;";
						NextLink1.InnerHtml = first.ArchiveDateTime.ToString("MMMM") + " &gt;";
						if (first.ArchiveDateTime.Year != ContainerPage.Url.DateFilter.Year)
						{
							NextLink.InnerHtml = first.ArchiveDateTime.ToString("MMMM") + " " + first.ArchiveDateTime.Year.ToString() + " &gt;";
							NextLink1.InnerHtml = first.ArchiveDateTime.ToString("MMMM") + " " + first.ArchiveDateTime.Year.ToString() + " &gt;";
						}
					}
					if (BackLink.Disabled)
						BackLink.Attributes["class"] = "DisabledAnchor";
					if (BackLink1.Disabled)
						BackLink1.Attributes["class"] = "DisabledAnchor";
					if (NextLink.Disabled)
						NextLink.Attributes["class"] = "DisabledAnchor";
					if (NextLink1.Disabled)
						NextLink1.Attributes["class"] = "DisabledAnchor";
				}
				#endregion
			}
		}
示例#10
0
		public DeleteReturnStatus DeleteAllUsr(Usr u)
		{
			if (!u.IsSuper && u.K!=this.OwnerUsrK)
				return DeleteReturnStatus.FailNoPermission;

			if (this.PromoterK>0 && this.PromoterStatus.Equals(Venue.PromoterStatusEnum.Confirmed))
				return DeleteReturnStatus.FailPromoter;

			if (this.TotalComments>10)
			{
				Mailer smComments = new Mailer();
				smComments.Body+="<p><a href=\"http://"+Vars.DomainName+u.Url()+"\">"+u.NickNameSafe+"</a> ("+u.Email+") attempted to delete venue "+this.K+" (<a href=\"http://"+Vars.DomainName+this.Url()+"\">"+this.FriendlyName+"</a>).</p>";
				smComments.Body+="<p>This operation failed because "+this.Name+" has "+this.TotalComments+" comments.</p>";
				smComments.Subject="Delete venue operation failed because too many comments in venue";
				smComments.TemplateType=Mailer.TemplateTypes.AdminNote;
				smComments.To = "*****@*****.**";
				smComments.Send();
				return DeleteReturnStatus.FailComments;
			}

			if (this.Events.Count>3)
			{
				Mailer smEvents = new Mailer();
				smEvents.Body+="<p><a href=\"http://"+Vars.DomainName+u.Url()+"\">"+u.NickNameSafe+"</a> ("+u.Email+") attempted to delete venue "+this.K+" (<a href=\"http://"+Vars.DomainName+this.Url()+"\">"+this.FriendlyName+"</a>).</p>";
				smEvents.Body+="<p>This operation failed because "+this.Name+" has "+this.Events.Count+" events.</p>";
				smEvents.Subject="Delete venue operation failed because too many events";
				smEvents.TemplateType=Mailer.TemplateTypes.AdminNote;
				smEvents.To = "*****@*****.**";
				smEvents.Send();
				return DeleteReturnStatus.FailEvents;
			}

			int totalPhotos = 0;
			foreach (Event ev in this.Events)
			{
				totalPhotos += ev.TotalPhotos;
			}
			if (totalPhotos>5)
			{
				Mailer smPhotos = new Mailer();
				smPhotos.Body+="<p><a href=\"http://"+Vars.DomainName+u.Url()+"\">"+u.NickNameSafe+"</a> ("+u.Email+") attempted to delete venue "+this.K+" (<a href=\"http://"+Vars.DomainName+this.Url()+"\">"+this.FriendlyName+"</a>).</p>";
				smPhotos.Body+="<p>This operation failed because events at "+this.Name+" have "+totalPhotos+" photos.</p>";
				smPhotos.Subject="Delete venue operation failed because too many photos in events";
				smPhotos.TemplateType=Mailer.TemplateTypes.AdminNote;
				smPhotos.To = "*****@*****.**";
				smPhotos.Send();
				return DeleteReturnStatus.FailPhotos;
			}


			//banners?
			Query qBanners = new Query();
			qBanners.TableElement=new Join(Banner.Columns.EventK, Event.Columns.K);
			qBanners.QueryCondition=new Q(Event.Columns.VenueK,this.K);
			qBanners.ReturnCountOnly=true;
			BannerSet bs = new BannerSet(qBanners);
			if (bs.Count>0)
			{
				Mailer smBanner = new Mailer();
				smBanner.Body+="<p><a href=\"http://"+Vars.DomainName+u.Url()+"\">"+u.NickNameSafe+"</a> ("+u.Email+") attempted to delete venue "+this.K+" (<a href=\"http://"+Vars.DomainName+this.Url()+"\">"+this.FriendlyName+"</a>).</p>";
				smBanner.Body+="<p>This operation failed because "+this.Name+" has "+bs.Count+" banner"+(bs.Count==1?"":"s")+".</p>";
				smBanner.Subject="Delete venue operation failed because venue has a banner";
				smBanner.TemplateType=Mailer.TemplateTypes.AdminNote;
				smBanner.To = "*****@*****.**";
				smBanner.Send();
				return DeleteReturnStatus.FailPromoter;
			}
			//guestlists?
			Query qGuestlists = new Query();
			qGuestlists.QueryCondition=new And(new Q(Event.Columns.HasGuestlist,true),new Q(Event.Columns.VenueK,this.K));
			qGuestlists.ReturnCountOnly=true;
			EventSet es = new EventSet(qGuestlists);
			if (es.Count>0)
			{
				Mailer smGuestlist = new Mailer();
				smGuestlist.Body+="<p><a href=\"http://"+Vars.DomainName+u.Url()+"\">"+u.NickNameSafe+"</a> ("+u.Email+") attempted to delete venue "+this.K+" (<a href=\"http://"+Vars.DomainName+this.Url()+"\">"+this.FriendlyName+"</a>).</p>";
				smGuestlist.Body+="<p>This operation failed because "+this.Name+" has "+es.Count+" guestlist"+(es.Count==1?"":"s")+".</p>";
				smGuestlist.Subject="Delete venue operation failed because venue has a guestlist";
				smGuestlist.TemplateType=Mailer.TemplateTypes.AdminNote;
				smGuestlist.To = "*****@*****.**";
				smGuestlist.Send();
				return DeleteReturnStatus.FailPromoter;
			}
			//competitions?
			Query qComp = new Query();
			qComp.TableElement=new Join(Comp.Columns.EventK, Event.Columns.K);
			qComp.QueryCondition=new Q(Event.Columns.VenueK,this.K);
			qComp.ReturnCountOnly=true;
			CompSet cs = new CompSet(qComp);
			if (cs.Count>0)
			{
				Mailer smComp = new Mailer();
				smComp.Body+="<p><a href=\"http://"+Vars.DomainName+u.Url()+"\">"+u.NickNameSafe+"</a> ("+u.Email+") attempted to delete venue "+this.K+" (<a href=\"http://"+Vars.DomainName+this.Url()+"\">"+this.FriendlyName+"</a>).</p>";
				smComp.Body+="<p>This operation failed because "+this.Name+" has "+cs.Count+" competition"+(cs.Count==1?"":"s")+".</p>";
				smComp.Subject="Delete venue operation failed because venue has a competition";
				smComp.TemplateType=Mailer.TemplateTypes.AdminNote;
				smComp.To = "*****@*****.**";
				smComp.Send();
				return DeleteReturnStatus.FailPromoter;
			}
			//dontations?
			Query qDonated = new Query();
			qDonated.QueryCondition=new And(new Q(Event.Columns.VenueK,this.K),new Q(Event.Columns.Donated,true));
			qDonated.ReturnCountOnly=true;
			EventSet esDon = new EventSet(qDonated);
			if (esDon.Count>0)
			{
				Mailer smDonate = new Mailer();
				smDonate.Body+="<p><a href=\"http://"+Vars.DomainName+u.Url()+"\">"+u.NickNameSafe+"</a> ("+u.Email+") attempted to delete venue "+this.K+" (<a href=\"http://"+Vars.DomainName+this.Url()+"\">"+this.FriendlyName+"</a>).</p>";
				smDonate.Body+="<p>This operation failed because "+this.Name+" has "+esDon.Count+" events with donations.</p>";
				smDonate.Subject="Delete venue operation failed because venue has an event donation";
				smDonate.TemplateType=Mailer.TemplateTypes.AdminNote;
				smDonate.To = "*****@*****.**";
				smDonate.Send();
				return DeleteReturnStatus.FailPromoter;
			}
            //ticket runs?
            Query qTicketRuns = new Query();
            qTicketRuns.QueryCondition = new Q(Event.Columns.VenueK, this.K);
            qTicketRuns.TableElement = new Join(Event.Columns.VenueK, Venue.Columns.K);
            qTicketRuns.ReturnCountOnly = true;
            EventSet esTix = new EventSet(qTicketRuns);
            if (esTix.Count > 0)
            {
                Mailer smDonate = new Mailer();
                smDonate.Body += "<p><a href=\"http://" + Vars.DomainName + u.Url() + "\">" + u.NickNameSafe + "</a> (" + u.Email + ") attempted to delete venue " + this.K + " (<a href=\"http://" + Vars.DomainName + this.Url() + "\">" + this.FriendlyName + "</a>).</p>";
                smDonate.Body += "<p>This operation failed because " + this.Name + " has " + esTix.Count + " events with ticket runs.</p>";
                smDonate.Subject = "Delete venue operation failed because venue has at least one event with a ticket run";
                smDonate.TemplateType = Mailer.TemplateTypes.AdminNote;
                smDonate.To = "*****@*****.**";
                smDonate.Send();
                return DeleteReturnStatus.FailPromoter;
            }

			try
			{
				Bobs.Delete.DeleteAll(this);

				//Mailer smDone = new Mailer();
				//smDone.Body+="<p><a href=\"http://"+Vars.DomainName+u.Url()+"\">"+u.NickNameSafe+"</a> ("+u.Email+") deleted venue "+this.K+" (<a href=\"http://"+Vars.DomainName+this.Url()+"\">"+this.FriendlyName+"</a>).</p>";
				//smDone.Subject="Venue "+this.K.ToString()+" deleted";
				//smDone.TemplateType=Mailer.TemplateTypes.AdminNote;
				//smDone.To = "*****@*****.**";
				//smDone.Send();

				return DeleteReturnStatus.Success;
			}
			catch(Exception ex)
			{
			
				Mailer smException = new Mailer();
				smException.Body+="<p><a href=\"http://"+Vars.DomainName+u.Url()+"\">"+u.NickNameSafe+"</a> ("+u.Email+") attempted to delete venue "+this.K+" (<a href=\"http://"+Vars.DomainName+this.Url()+"\">"+this.FriendlyName+"</a>).</p>";
				smException.Body+="<p>This operation failed because of an unhandled exception:</p><p>"+ex.ToString()+"</p>";
				smException.Subject="Delete venue operation failed because of exception";
				smException.TemplateType=Mailer.TemplateTypes.AdminNote;
				smException.To="*****@*****.**";
				smException.Send();
				return DeleteReturnStatus.FailException;
			}
		}
示例#11
0
		private void Page_Load(object sender, System.EventArgs e)
		{
			Response.ContentType = "text/xml";
			Response.Clear();
			Response.Buffer = false;

			XmlTextWriter x = new XmlTextWriter(Response.OutputStream, Encoding.UTF8);
			x.Formatting = Formatting.Indented;
			x.WriteRaw("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");

			string dateFormat = "yyyy-MM-ddTHH:mm:sszzz";

			if (Request.QueryString[0].Equals("index"))
			{
				#region sitemapindex
				x.WriteStartElement("sitemapindex");
				x.WriteAttributeString("xmlns", "http://www.google.com/schemas/sitemap/0.84");

				if (true)
				{
					#region sitemap - countries
					x.WriteStartElement("sitemap");
					x.WriteElementString("loc", "http://www.dontstayin.com/sitemapxml?country");
					Query q = new Query();
					q.QueryCondition = new And(
						new Q(Thread.Columns.Private, false),
						new Q(Thread.Columns.PrivateGroup, false),
						new Q(Thread.Columns.GroupPrivate, false)
						);
					q.OrderBy = new OrderBy(Thread.Columns.LastPost, OrderBy.OrderDirection.Descending);
					q.TopRecords = 1;
					ThreadSet bobset = new ThreadSet(q);
					if (bobset.Count > 0)
						x.WriteElementString("lastmod", bobset[0].LastPost.ToString(dateFormat));
					x.WriteEndElement();	//sitemap
					#endregion
				}

				if (true)
				{
					#region sitemap - place
					x.WriteStartElement("sitemap");
					x.WriteElementString("loc", "http://www.dontstayin.com/sitemapxml?place");

					Query q = new Query();
					q.OrderBy = new OrderBy(Place.Columns.LastPost, OrderBy.OrderDirection.Descending);
					q.TopRecords = 1;
					PlaceSet bobset = new PlaceSet(q);
					if (bobset.Count > 0)
						x.WriteElementString("lastmod", bobset[0].LastPost.ToString(dateFormat));

					x.WriteEndElement();	//sitemap
					#endregion
				}

				if (true)
				{
					#region sitemap - venue
					x.WriteStartElement("sitemap");
					x.WriteElementString("loc", "http://www.dontstayin.com/sitemapxml?venue");

					Query q = new Query();
					q.OrderBy = new OrderBy(Venue.Columns.LastPost, OrderBy.OrderDirection.Descending);
					q.TopRecords = 1;
					VenueSet bobset = new VenueSet(q);
					if (bobset.Count > 0)
						x.WriteElementString("lastmod", bobset[0].LastPost.ToString(dateFormat));

					x.WriteEndElement();	//sitemap
					#endregion
				}

				if (true)
				{
					#region sitemap - event
					x.WriteStartElement("sitemap");
					x.WriteElementString("loc", "http://www.dontstayin.com/sitemapxml?event");

					Query q = new Query();
					q.OrderBy = new OrderBy(Event.Columns.LastPost, OrderBy.OrderDirection.Descending);
					q.TopRecords = 1;
					EventSet bobset = new EventSet(q);
					if (bobset.Count > 0)
						x.WriteElementString("lastmod", bobset[0].LastPost.ToString(dateFormat));

					x.WriteEndElement();	//sitemap
					#endregion
				}

				if (true)
				{
					#region sitemap - thread
					x.WriteStartElement("sitemap");
					x.WriteElementString("loc", "http://www.dontstayin.com/sitemapxml?thread");

					Query q = new Query();
					q.QueryCondition = new And(
						new Q(Thread.Columns.Private, false),
						new Q(Thread.Columns.PrivateGroup, false),
						new Q(Thread.Columns.GroupPrivate, false)
						);
					q.OrderBy = new OrderBy(Thread.Columns.LastPost, OrderBy.OrderDirection.Descending);
					q.TopRecords = 1;
					ThreadSet bobset = new ThreadSet(q);
					if (bobset.Count > 0)
						x.WriteElementString("lastmod", bobset[0].LastPost.ToString(dateFormat));

					x.WriteEndElement();	//sitemap
					#endregion
				}

				if (true)
				{
					#region sitemap - photo
					x.WriteStartElement("sitemap");
					x.WriteElementString("loc", "http://www.dontstayin.com/sitemapxml?photo");

					Query q = new Query();
					q.QueryCondition = Photo.EnabledQueryCondition;
					q.OrderBy = new OrderBy(Photo.Columns.EnabledDateTime, OrderBy.OrderDirection.Descending);
					q.TopRecords = 1;
					PhotoSet bobset = new PhotoSet(q);
					if (bobset.Count > 0)
						x.WriteElementString("lastmod", bobset[0].EnabledDateTime.ToString(dateFormat));

					x.WriteEndElement();	//sitemap
					#endregion
				}

				if (true)
				{
					#region sitemap - usr
					x.WriteStartElement("sitemap");
					x.WriteElementString("loc", "http://www.dontstayin.com/sitemapxml?usr");
					x.WriteEndElement();	//sitemap
					#endregion
				}

				if (true)
				{
					#region sitemap - article
					x.WriteStartElement("sitemap");
					x.WriteElementString("loc", "http://www.dontstayin.com/sitemapxml?article");

					Query q = new Query();
					q.QueryCondition = Article.EnabledQueryCondition;
					q.OrderBy = new OrderBy(Article.Columns.EnabledDateTime, OrderBy.OrderDirection.Descending);
					q.TopRecords = 1;
					ArticleSet bobset = new ArticleSet(q);
					if (bobset.Count > 0)
						x.WriteElementString("lastmod", bobset[0].EnabledDateTime.ToString(dateFormat));

					x.WriteEndElement();	//sitemap
					#endregion
				}

				if (true)
				{
					#region sitemap - comp
					x.WriteStartElement("sitemap");
					x.WriteElementString("loc", "http://www.dontstayin.com/sitemapxml?comp");
					x.WriteEndElement();	//sitemap
					#endregion
				}

				if (true)
				{
					#region sitemap - brand
					x.WriteStartElement("sitemap");
					x.WriteElementString("loc", "http://www.dontstayin.com/sitemapxml?brand");

					Query q = new Query();
					q.OrderBy = new OrderBy(Brand.Columns.LastPost, OrderBy.OrderDirection.Descending);
					q.TopRecords = 1;
					BrandSet bobset = new BrandSet(q);
					if (bobset.Count > 0)
						x.WriteElementString("lastmod", bobset[0].LastPost.ToString(dateFormat));

					x.WriteEndElement();	//sitemap
					#endregion
				}


				if (true)
				{
					#region sitemap - group
					x.WriteStartElement("sitemap");
					x.WriteElementString("loc", "http://www.dontstayin.com/sitemapxml?group");

					Query q = new Query();
					q.QueryCondition = new And(
						new Q(Group.Columns.BrandK, 0),
						new Q(Group.Columns.PrivateGroupPage, false));
					q.OrderBy = new OrderBy(Group.Columns.LastPost, OrderBy.OrderDirection.Descending);
					q.TopRecords = 1;
					GroupSet bobset = new GroupSet(q);
					if (bobset.Count > 0)
						x.WriteElementString("lastmod", bobset[0].LastPost.Value.ToString(dateFormat));

					x.WriteEndElement();	//sitemap
					#endregion
				}

				x.WriteEndElement();	//sitemapindex
				#endregion
			}
			else
			{
				#region urlset
				x.WriteStartElement("urlset");
				x.WriteAttributeString("xmlns", "http://www.google.com/schemas/sitemap/0.84");

				#region Countries
				if (Request.QueryString[0].Equals("country"))
				{
					if (true)
					{
						#region url
						x.WriteStartElement("url");
						x.WriteElementString("loc", "http://www.dontstayin.com/");
						Query q = new Query();
						q.QueryCondition = new And(
							new Q(Thread.Columns.Private, false),
							new Q(Thread.Columns.PrivateGroup, false),
							new Q(Thread.Columns.GroupPrivate, false)
							);
						q.OrderBy = new OrderBy(Thread.Columns.LastPost, OrderBy.OrderDirection.Descending);
						q.TopRecords = 1;
						ThreadSet bobset = new ThreadSet(q);
						if (bobset.Count > 0)
							x.WriteElementString("lastmod", bobset[0].LastPost.ToString(dateFormat));
						x.WriteElementString("changefreq", "hourly");
						x.WriteEndElement();	//url
						#endregion
					}

					if (true)
					{
						Query q = new Query();
						q.QueryCondition = new Q(Country.Columns.TotalEvents, QueryOperator.GreaterThan, 0);
						q.OrderBy = new OrderBy(Country.Columns.TotalEvents, OrderBy.OrderDirection.Descending);
						q.Columns = new ColumnSet(Country.LinkColumns, Country.Columns.TotalEvents);
						if (Vars.DevEnv)
							q.TopRecords = 10;
						CountrySet bobset = new CountrySet(q);
						for (int i = 0; i < bobset.Count; i++)
						{
							Country p = bobset[i];
							#region url
							x.WriteStartElement("url");
							x.WriteElementString("loc", "http://www.dontstayin.com" + p.Url());
							if (p.TotalEvents > 100)
								x.WriteElementString("changefreq", "hourly");
							else if (p.TotalEvents > 20)
								x.WriteElementString("changefreq", "daily");
							else if (p.TotalEvents > 10)
								x.WriteElementString("changefreq", "weekly");
							else
								x.WriteElementString("changefreq", "monthly");
							x.WriteEndElement();	//url
							#endregion
							bobset.Kill(i);
						}
					}
				}
				#endregion

				#region Places
				if (Request.QueryString[0].Equals("place"))
				{
					Query q = new Query();
					q.QueryCondition = new Or(
						new Q(Place.Columns.TotalComments, QueryOperator.GreaterThan, 0),
						new Q(Place.Columns.TotalEvents, QueryOperator.GreaterThan, 0));
					q.OrderBy = new OrderBy(Place.Columns.TotalComments, OrderBy.OrderDirection.Descending);
					q.Columns = new ColumnSet(Place.LinkColumns, Place.Columns.LastPost);
					if (Vars.DevEnv)
						q.TopRecords = 10;
					else
						q.TopRecords = 40000;
					PlaceSet bobset = new PlaceSet(q);
					for (int i = 0; i < bobset.Count; i++)
					{
						Place p = bobset[i];
						#region url
						x.WriteStartElement("url");
						x.WriteElementString("loc", "http://www.dontstayin.com" + p.Url());
						if (p.LastPost != DateTime.MinValue)
						{
							x.WriteElementString("lastmod", p.LastPost.ToString(dateFormat));
							TimeSpan ts = DateTime.Now.Subtract(p.LastPost);
							if (ts.TotalHours < 24)
								x.WriteElementString("changefreq", "hourly");
							else if (ts.TotalDays < 7)
								x.WriteElementString("changefreq", "daily");
							else if (ts.TotalDays < 30)
								x.WriteElementString("changefreq", "weekly");
							else
								x.WriteElementString("changefreq", "monthly");
						}
						else
							x.WriteElementString("changefreq", "monthly");
						x.WriteEndElement();	//url
						#endregion
						bobset.Kill(i);
					}
				}
				#endregion

				#region Venues
				if (Request.QueryString[0].Equals("venue"))
				{
					Query q = new Query();
					q.OrderBy = new OrderBy(Venue.Columns.TotalEvents, OrderBy.OrderDirection.Descending);
					q.Columns = new ColumnSet(Venue.LinkColumns, Venue.Columns.LastPost, Venue.Columns.TotalEvents);
					if (Vars.DevEnv)
						q.TopRecords = 10;
					else
						q.TopRecords = 40000;
					VenueSet bobset = new VenueSet(q);
					for (int i = 0; i < bobset.Count; i++)
					{
						Venue v = bobset[i];
						#region url
						x.WriteStartElement("url");
						x.WriteElementString("loc", "http://www.dontstayin.com" + v.Url());
						if (v.LastPost != DateTime.MinValue)
						{
							x.WriteElementString("lastmod", v.LastPost.ToString(dateFormat));
							TimeSpan ts = DateTime.Now.Subtract(v.LastPost);
							if (ts.TotalHours < 24)
								x.WriteElementString("changefreq", "hourly");
							else if (ts.TotalDays < 7)
								x.WriteElementString("changefreq", "daily");
							else if (ts.TotalDays < 30)
								x.WriteElementString("changefreq", "weekly");
							else
								x.WriteElementString("changefreq", "monthly");
						}
						else if (v.TotalEvents > 10)
							x.WriteElementString("changefreq", "weekly");
						else
							x.WriteElementString("changefreq", "monthly");

						x.WriteEndElement();	//url
						#endregion
						bobset.Kill(i);
					}
				}
				#endregion

				#region Events
				if (Request.QueryString[0].Equals("event"))
				{
					Query q = new Query();
					q.OrderBy = new OrderBy(Event.Columns.LastPost, OrderBy.OrderDirection.Descending);
					q.Columns = new ColumnSet(Event.LinkColumns, Event.Columns.LastPost, Event.Columns.DateTime);
					if (Vars.DevEnv)
						q.TopRecords = 10;
					else
						q.TopRecords = 40000;
					EventSet bobset = new EventSet(q);
					for (int i = 0; i < bobset.Count; i++)
					{
						Event ev = bobset[i];
						#region url
						x.WriteStartElement("url");
						x.WriteElementString("loc", "http://www.dontstayin.com" + ev.Url());
						if (ev.LastPost != DateTime.MinValue)
						{
							x.WriteElementString("lastmod", ev.LastPost.ToString(dateFormat));
							TimeSpan ts = DateTime.Now.Subtract(ev.LastPost);
							if (ts.TotalHours < 24)
								x.WriteElementString("changefreq", "hourly");
							else if (ts.TotalDays < 7)
								x.WriteElementString("changefreq", "daily");
							else if (ts.TotalDays < 30)
								x.WriteElementString("changefreq", "weekly");
							else
								x.WriteElementString("changefreq", "monthly");
						}
						else
							x.WriteElementString("changefreq", "monthly");
						x.WriteEndElement();	//url
						#endregion
						bobset.Kill(i);
					}
				}
				#endregion

				#region Threads
				if (Request.QueryString[0].Equals("thread"))
				{
					Query q = new Query();
					q.QueryCondition = new And(
						new Q(Thread.Columns.Private, false),
						new Q(Thread.Columns.PrivateGroup, false),
						new Q(Thread.Columns.GroupPrivate, false)
					);
					q.Columns = new ColumnSet(Thread.Columns.K, Thread.Columns.UrlFragment, Thread.Columns.TotalComments, Thread.Columns.LastPost);
					q.OrderBy = new OrderBy(Thread.Columns.LastPost, OrderBy.OrderDirection.Descending);
					if (Vars.DevEnv)
						q.TopRecords = 10;
					else
						q.TopRecords = 40000;
					ThreadSet bobset = new ThreadSet(q);
					for (int i = 0; i < bobset.Count; i++)
					{
						Thread t = bobset[i];
						#region url
						x.WriteStartElement("url");
						if (t.LastPage == 1)
							x.WriteElementString("loc", "http://www.dontstayin.com" + t.Url());
						else
							x.WriteElementString("loc", "http://www.dontstayin.com" + t.Url("c", t.LastPage.ToString()));
						x.WriteElementString("lastmod", t.LastPost.ToString(dateFormat));
						TimeSpan ts = DateTime.Now.Subtract(t.LastPost);
						if (ts.TotalHours < 24)
							x.WriteElementString("changefreq", "hourly");
						else if (ts.TotalDays < 7)
							x.WriteElementString("changefreq", "daily");
						else if (ts.TotalDays < 30)
							x.WriteElementString("changefreq", "weekly");
						else
							x.WriteElementString("changefreq", "monthly");
						x.WriteEndElement();	//url
						#endregion
						bobset.Kill(i);
					}
				}
				#endregion

				#region Photos
				if (Request.QueryString[0].Equals("photo"))
				{
					Query q = new Query();
					q.QueryCondition = Photo.EnabledQueryCondition;
					q.Columns = new ColumnSet(Photo.Columns.K, Photo.Columns.UrlFragment, Photo.Columns.EventK, Photo.Columns.ArticleK);
					q.OrderBy = new OrderBy(Photo.Columns.EnabledDateTime, OrderBy.OrderDirection.Descending);
					if (Vars.DevEnv)
						q.TopRecords = 10;
					else
						q.TopRecords = 50000;
					PhotoSet bobset = new PhotoSet(q);
					for (int i = 0; i < bobset.Count; i++)
					{
						Photo p = bobset[i];
						#region url
						x.WriteStartElement("url");
						x.WriteElementString("loc", "http://www.dontstayin.com" + p.Url());
						x.WriteEndElement();	//url
						#endregion
						bobset.Kill(i);
					}
				}
				#endregion

				#region Usrs
				if (Request.QueryString[0].Equals("usr"))
				{
					Query q = new Query();
					q.QueryCondition = new And(
						new Q(Usr.Columns.IsSkeleton, false),
						new Q(Usr.Columns.IsEmailVerified, true),
						new Or(
						new Q(Usr.Columns.Pic, QueryOperator.NotEqualTo, Guid.Empty),
						new Q(Usr.Columns.CommentCount, QueryOperator.NotEqualTo, 0)
						)
					);
					q.Columns = new ColumnSet(Usr.Columns.NickName);
					q.OrderBy = new OrderBy(Usr.Columns.DateTimeLastPageRequest, OrderBy.OrderDirection.Descending);
					if (Vars.DevEnv)
						q.TopRecords = 10;
					else
						q.TopRecords = 50000;
					UsrSet bobset = new UsrSet(q);
					for (int i = 0; i < bobset.Count; i++)
					{
						Usr u = bobset[i];
						#region url
						x.WriteStartElement("url");
						x.WriteElementString("loc", "http://www.dontstayin.com" + u.Url());
						x.WriteEndElement();	//url
						#endregion
						bobset.Kill(i);
					}
				}
				#endregion

				#region Articles
				if (Request.QueryString[0].Equals("article"))
				{
					Query q = new Query();
					q.QueryCondition = Article.EnabledQueryCondition;
					q.Columns = new ColumnSet(Article.Columns.UrlFragment,
					Article.Columns.ParentObjectK,
					Article.Columns.ParentObjectType, Article.Columns.K);
					q.OrderBy = new OrderBy(Article.Columns.EnabledDateTime, OrderBy.OrderDirection.Descending);
					if (Vars.DevEnv)
						q.TopRecords = 10;
					else
						q.TopRecords = 50000;
					ArticleSet bobset = new ArticleSet(q);
					for (int i = 0; i < bobset.Count; i++)
					{
						Article a = bobset[i];
						#region url
						x.WriteStartElement("url");
						x.WriteElementString("loc", "http://www.dontstayin.com" + a.Url());
						x.WriteEndElement();	//url
						#endregion
						bobset.Kill(i);
					}
				}
				#endregion

				#region Competitions
				if (Request.QueryString[0].Equals("comp"))
				{
					Query q = new Query();
					q.QueryCondition = new Q(Comp.Columns.Status, Comp.StatusEnum.Enabled);
					q.Columns = new ColumnSet(Comp.Columns.K);
					q.OrderBy = new OrderBy(Comp.Columns.DateTimeClose, OrderBy.OrderDirection.Descending);
					if (Vars.DevEnv)
						q.TopRecords = 10;
					else
						q.TopRecords = 50000;
					CompSet bobset = new CompSet(q);
					for (int i = 0; i < bobset.Count; i++)
					{
						Comp c = bobset[i];
						#region url
						x.WriteStartElement("url");
						x.WriteElementString("loc", "http://www.dontstayin.com" + c.Url());
						x.WriteEndElement();	//url
						#endregion
						bobset.Kill(i);
					}
				}
				#endregion

				#region Brands
				if (Request.QueryString[0].Equals("brand"))
				{
					Query q = new Query();
					q.OrderBy = new OrderBy(Brand.Columns.LastPost, OrderBy.OrderDirection.Descending);
					q.Columns = new ColumnSet(Brand.LinkColumns, Brand.Columns.LastPost);
					if (Vars.DevEnv)
						q.TopRecords = 10;
					else
						q.TopRecords = 40000;
					BrandSet bobset = new BrandSet(q);
					for (int i = 0; i < bobset.Count; i++)
					{
						Brand b = bobset[i];
						#region url
						x.WriteStartElement("url");
						x.WriteElementString("loc", "http://www.dontstayin.com" + b.Url());
						if (b.LastPost > DateTime.MinValue)
						{
							x.WriteElementString("lastmod", b.LastPost.ToString(dateFormat));
							TimeSpan ts = DateTime.Now.Subtract(b.LastPost);
							if (ts.TotalHours < 24)
								x.WriteElementString("changefreq", "hourly");
							else if (ts.TotalDays < 7)
								x.WriteElementString("changefreq", "daily");
							else if (ts.TotalDays < 30)
								x.WriteElementString("changefreq", "weekly");
							else
								x.WriteElementString("changefreq", "monthly");
						}
						else
							x.WriteElementString("changefreq", "monthly");
						x.WriteEndElement();	//url
						#endregion
						bobset.Kill(i);
					}
				}
				#endregion

				#region Groups
				if (Request.QueryString[0].Equals("group"))
				{
					Query q = new Query();
					q.QueryCondition = new And(
						new Q(Group.Columns.BrandK, 0),
						new Q(Group.Columns.PrivateGroupPage, false));
					q.OrderBy = new OrderBy(Group.Columns.LastPost, OrderBy.OrderDirection.Descending);
					q.Columns = new ColumnSet(Group.Columns.BrandK, Group.Columns.UrlName, Group.Columns.LastPost);
					if (Vars.DevEnv)
						q.TopRecords = 10;
					else
						q.TopRecords = 40000;
					GroupSet bobset = new GroupSet(q);
					for (int i = 0; i < bobset.Count; i++)
					{
						Group g = bobset[i];
						#region url
						x.WriteStartElement("url");
						x.WriteElementString("loc", "http://www.dontstayin.com" + g.Url());
						if (g.LastPost.HasValue && g.LastPost > DateTime.MinValue)
						{
							x.WriteElementString("lastmod", g.LastPost.Value.ToString(dateFormat));
							TimeSpan ts = DateTime.Now.Subtract(g.LastPost.Value);
							if (ts.TotalHours < 24)
								x.WriteElementString("changefreq", "hourly");
							else if (ts.TotalDays < 7)
								x.WriteElementString("changefreq", "daily");
							else if (ts.TotalDays < 30)
								x.WriteElementString("changefreq", "weekly");
							else
								x.WriteElementString("changefreq", "monthly");
						}
						else
							x.WriteElementString("changefreq", "monthly");
						x.WriteEndElement();	//url
						#endregion
						bobset.Kill(i);
					}
				}
				#endregion

				x.WriteEndElement();	//urlset
				#endregion
			}
			x.Flush();
			x.Close();
			Response.End();

		}
示例#12
0
		void BindComp()
		{
			Query q = new Query();
			q.QueryCondition = new Q(Comp.Columns.PromoterK, CurrentPromoter.K);
			q.NoLock = true;
			q.OrderBy = new OrderBy(Comp.Columns.DateTimeClose, OrderBy.OrderDirection.Descending);
			CompSet cs = new CompSet(q);
			CompDataGrid.AllowPaging = (cs.Count > CompDataGrid.PageSize);
			CompDataGrid.DataSource = cs;
			CompDataGrid.DataBind();
		}
示例#13
0
		public static void SendPromoterReminders()
		{
			Query q = new Query();
			q.QueryCondition=new Q(Comp.Columns.Status,Comp.StatusEnum.New);
			CompSet cs = new CompSet(q);
			foreach (Comp c in cs)
			{
				try
				{
					Mailer sm = new Mailer();
					sm.TemplateType=Mailer.TemplateTypes.AnotherSiteUser;
					sm.UsrRecipient=c.Owner;
					sm.Subject="You have a DontStayIn competition that needs to be published!";
					sm.Body="<p>You've recently added a competition to DontStayIn using your promoter account, but it's not been published. You should publish your competition AS SOON as the details are finished - DO NOT wait until the opening date.</p>";
					sm.RedirectUrl=c.Promoter.UrlApp("competitions");
					sm.Send();
				}
				catch
				{
					Mailer admin = new Mailer();
					admin.TemplateType=Mailer.TemplateTypes.AdminNote;
					admin.Body = "<p>Exception sending new competition reminder</p>";
					admin.Subject = "Exception sending new competition reminder";
					admin.To = "*****@*****.**";
					admin.Send();
				}
			}
		}
示例#14
0
		public string PromoterHtmlCompetition(Promoter p)
		{
			Query q = new Query();
			q.QueryCondition = new And(new Q(Comp.Columns.EventK, this.K), new Q(Comp.Columns.Status, Comp.StatusEnum.Enabled));
			q.ReturnCountOnly = true;
			CompSet cs = new CompSet(q);
			return TickCrossHtml(cs.Count > 0);
		}
示例#15
0
		public DeleteReturnStatus DeleteAllUsr(Usr u)
		{
			if (!u.IsSuper && u.K != this.OwnerUsrK)
				return DeleteReturnStatus.FailNoPermission;

			if (this.TotalComments > 10)
			{
				Mailer smComments = new Mailer();
				smComments.Body += "<p><a href=\"http://" + Vars.DomainName + u.Url() + "\">" + u.NickNameSafe + "</a> (" + u.Email + ") attempted to delete event " + this.K + " (<a href=\"http://" + Vars.DomainName + this.Url() + "\">" + this.FriendlyName + "</a>).</p>";
				smComments.Body += "<p>This operation failed because " + this.Name + " has " + this.TotalComments + " comments.</p>";
				smComments.Subject = "Delete event operation failed because too many comments in event";
				smComments.TemplateType = Mailer.TemplateTypes.AdminNote;
				smComments.To = "*****@*****.**";
				smComments.Send();
				return DeleteReturnStatus.FailComments;
			}

			if (this.TotalPhotos > 5)
			{
				Mailer smPhotos = new Mailer();
				smPhotos.Body += "<p><a href=\"http://" + Vars.DomainName + u.Url() + "\">" + u.NickNameSafe + "</a> (" + u.Email + ") attempted to delete event " + this.K + " (<a href=\"http://" + Vars.DomainName + this.Url() + "\">" + this.FriendlyName + "</a>).</p>";
				smPhotos.Body += "<p>This operation failed because " + this.Name + " has " + this.TotalPhotos + " photos.</p>";
				smPhotos.Subject = "Delete event operation failed because too many photos in event";
				smPhotos.TemplateType = Mailer.TemplateTypes.AdminNote;
				smPhotos.To = "*****@*****.**";
				smPhotos.Send();
				return DeleteReturnStatus.FailPhotos;
			}

			//banners?
			Query qBanners = new Query();
			qBanners.QueryCondition = new Q(Banner.Columns.EventK, this.K);
			qBanners.ReturnCountOnly = true;
			BannerSet bs = new BannerSet(qBanners);
			if (bs.Count > 0)
			{
				Mailer smBanner = new Mailer();
				smBanner.Body += "<p><a href=\"http://" + Vars.DomainName + u.Url() + "\">" + u.NickNameSafe + "</a> (" + u.Email + ") attempted to delete event " + this.K + " (<a href=\"http://" + Vars.DomainName + this.Url() + "\">" + this.FriendlyName + "</a>).</p>";
				smBanner.Body += "<p>This operation failed because " + this.Name + " has " + bs.Count + " banner" + (bs.Count == 1 ? "" : "s") + ".</p>";
				smBanner.Subject = "Delete event operation failed because event has a banner";
				smBanner.TemplateType = Mailer.TemplateTypes.AdminNote;
				smBanner.To = "*****@*****.**";
				smBanner.Send();
				return DeleteReturnStatus.FailPromoter;
			}
			//guestlists?
			if (this.HasGuestlist)
			{
				Mailer smGuestlists = new Mailer();
				smGuestlists.Body += "<p><a href=\"http://" + Vars.DomainName + u.Url() + "\">" + u.NickNameSafe + "</a> (" + u.Email + ") attempted to delete event " + this.K + " (<a href=\"http://" + Vars.DomainName + this.Url() + "\">" + this.FriendlyName + "</a>).</p>";
				smGuestlists.Body += "<p>This operation failed because " + this.Name + " has a guestlist.</p>";
				smGuestlists.Subject = "Delete event operation failed because event has a guestlist";
				smGuestlists.TemplateType = Mailer.TemplateTypes.AdminNote;
				smGuestlists.To = "*****@*****.**";
				smGuestlists.Send();
				return DeleteReturnStatus.FailPromoter;
			}
			//competitions?
			Query qComp = new Query();
			qComp.QueryCondition = new Q(Comp.Columns.EventK, this.K);
			qComp.ReturnCountOnly = true;
			CompSet cs = new CompSet(qComp);
			if (cs.Count > 0)
			{
				Mailer smComp = new Mailer();
				smComp.Body += "<p><a href=\"http://" + Vars.DomainName + u.Url() + "\">" + u.NickNameSafe + "</a> (" + u.Email + ") attempted to delete event " + this.K + " (<a href=\"http://" + Vars.DomainName + this.Url() + "\">" + this.FriendlyName + "</a>).</p>";
				smComp.Body += "<p>This operation failed because " + this.Name + " has " + cs.Count + " competition" + (cs.Count == 1 ? "" : "s") + ".</p>";
				smComp.Subject = "Delete event operation failed because event has a competition";
				smComp.TemplateType = Mailer.TemplateTypes.AdminNote;
				smComp.To = "*****@*****.**";
				smComp.Send();
				return DeleteReturnStatus.FailPromoter;
			}
			//ticket runs?
			if (this.TicketRuns.Count > 0)
			{
				string ticketRuns = (this.TicketRuns.Count > 1 ? "ticket runs" : "a ticket run");
				Mailer smTicketRuns = new Mailer();
				smTicketRuns.Body += "<p><a href=\"http://" + Vars.DomainName + u.Url() + "\">" + u.NickNameSafe + "</a> (" + u.Email + ") attempted to delete event " + this.K + " (<a href=\"http://" + Vars.DomainName + this.Url() + "\">" + this.FriendlyName + "</a>).</p>";
				smTicketRuns.Body += "<p>This operation failed because " + this.Name + " has " + ticketRuns + ".</p>";
				smTicketRuns.Subject = "Delete event operation failed because event has " + ticketRuns;
				smTicketRuns.TemplateType = Mailer.TemplateTypes.AdminNote;
				smTicketRuns.To = "*****@*****.**";
				smTicketRuns.Send();
				return DeleteReturnStatus.FailPromoter;
			}
			if (this.Donated)
			{
				Mailer smDonated = new Mailer();
				smDonated.Body += "<p><a href=\"http://" + Vars.DomainName + u.Url() + "\">" + u.NickNameSafe + "</a> (" + u.Email + ") attempted to delete event " + this.K + " (<a href=\"http://" + Vars.DomainName + this.Url() + "\">" + this.FriendlyName + "</a>).</p>";
				smDonated.Body += "<p>This operation failed because the event has donated.</p>";
				smDonated.Subject = "Delete event operation failed because event has a donation";
				smDonated.TemplateType = Mailer.TemplateTypes.AdminNote;
				smDonated.To = "*****@*****.**";
				smDonated.Send();
				return DeleteReturnStatus.FailPromoter;
			}

			if (this.TotalPhotos > 5)
			{
				Mailer smPhotos = new Mailer();
				smPhotos.Body += "<p><a href=\"http://" + Vars.DomainName + u.Url() + "\">" + u.NickNameSafe + "</a> (" + u.Email + ") attempted to delete event " + this.K + " (<a href=\"http://" + Vars.DomainName + this.Url() + "\">" + this.FriendlyName + "</a>).</p>";
				smPhotos.Body += "<p>This operation failed because " + this.Name + " has " + this.TotalPhotos + " photos.</p>";
				smPhotos.Subject = "Delete event operation failed because too many photos in event";
				smPhotos.TemplateType = Mailer.TemplateTypes.AdminNote;
				smPhotos.To = "*****@*****.**";
				smPhotos.Send();
				return DeleteReturnStatus.FailPhotos;
			}

			try
			{
				Bobs.Delete.DeleteAll(this);
				//Mailer smDone = new Mailer();
				//smDone.Body+="<p><a href=\"http://"+Vars.DomainName+u.Url()+"\">"+u.NickNameSafe+"</a> ("+u.Email+") deleted event "+this.K+" (<a href=\"http://"+Vars.DomainName+this.Url()+"\">"+this.FriendlyName+"</a>).</p>";
				//smDone.Subject="Event "+this.K.ToString()+" deleted";
				//smDone.TemplateType=Mailer.TemplateTypes.AdminNote;
				//smDone.To="*****@*****.**";
				//smDone.Send();

				return DeleteReturnStatus.Success;
			}
			catch (Exception ex)
			{
				Mailer smException = new Mailer();
				smException.Body += "<p><a href=\"http://" + Vars.DomainName + u.Url() + "\">" + u.NickNameSafe + "</a> (" + u.Email + ") attempted to delete event " + this.K + " (<a href=\"http://" + Vars.DomainName + this.Url() + "\">" + this.FriendlyName + "</a>).</p>";
				smException.Body += "<p>This operation failed because of an unhandled exception:</p><p>" + ex.ToString() + "</p>";
				smException.Subject = "Delete event operation failed because of exception";
				smException.TemplateType = Mailer.TemplateTypes.AdminNote;
				smException.To = "*****@*****.**";
				smException.Send();
				return DeleteReturnStatus.FailException;
			}
		}
示例#16
0
		void CompListBind()
		{
			if (EnsureSecure)
			{
				Query q = new Query();
				q.QueryCondition = new Q(Comp.Columns.EventK, CurrentEvent.K);
				q.OrderBy = new OrderBy(Comp.Columns.DateTimeAdded, OrderBy.OrderDirection.Descending);
				CompSet cs = new CompSet(q);
				CompPanel.Visible = cs.Count > 0;
				NoCompPanel.Visible = cs.Count == 0;
				if (cs.Count > 0)
				{
					CompDataGrid.AllowPaging = cs.Count > CompDataGrid.PageSize;
					CompDataGrid.DataSource = cs;
					CompDataGrid.DataBind();
				}
			}
		}
示例#17
0
		public void CompPanel_Load(object o, System.EventArgs e)
		{
			if (OnlyShowThreads)
			{
				CompPanel.Visible = false;
				return;
			}

			Q RelevanceQ = null;
			if (Discussable == null)
				RelevanceQ = new Q(true);
			else if (Discussable.UsedDiscussable is Event)
				RelevanceQ = new Q(Comp.Columns.EventK, Discussable.UsedDiscussable.K);
			else if (Discussable.UsedDiscussable is Venue)
				RelevanceQ = new Q(Event.Columns.VenueK, Discussable.UsedDiscussable.K);
			else if (Discussable.UsedDiscussable is Place)
				RelevanceQ = new Q(Venue.Columns.PlaceK, Discussable.UsedDiscussable.K);
			else if (Discussable.UsedDiscussable is Country)
				RelevanceQ = new Q(Place.Columns.CountryK, Discussable.UsedDiscussable.K);
			else if (Discussable.UsedDiscussable is Brand)
				RelevanceQ = new Or(
					new Q(Brand.Columns.K, Discussable.UsedDiscussable.K),
					new Q(Comp.Columns.BrandK, Discussable.UsedDiscussable.K));
			else if (Discussable.UsedDiscussable is Group)
				RelevanceQ = new Q(Group.Columns.K, Discussable.UsedDiscussable.K);

			TableElement t = new TableElement(TablesEnum.Comp);
			if (Discussable != null && Discussable.UsedDiscussable is Venue)
				t = new Join(Comp.Columns.EventK, Event.Columns.K);
			else if (Discussable != null && Discussable != null && Discussable.UsedDiscussable is Place)
				t = new Join(new Join(Comp.Columns.EventK, Event.Columns.K), new TableElement(TablesEnum.Venue), QueryJoinType.Inner, Event.Columns.VenueK, Venue.Columns.K);
			else if (Discussable != null && Discussable.UsedDiscussable is Country)
				t = new Join(
						new Join(
							new JoinLeft(Comp.Columns.EventK, Event.Columns.K),
							new TableElement(TablesEnum.Venue),
							QueryJoinType.Left,
							Event.Columns.VenueK,
							Venue.Columns.K),
						new TableElement(TablesEnum.Place),
						QueryJoinType.Left,
						Venue.Columns.PlaceK,
						Place.Columns.K);
			else if (Discussable != null && Discussable.UsedDiscussable is Brand)
				t = new Join(new TableElement(TablesEnum.Comp), Event.BrandJoin, QueryJoinType.Left, Comp.Columns.EventK, Event.Columns.K);
			else if (Discussable != null && Discussable.UsedDiscussable is Group)
				t = new Join(new TableElement(TablesEnum.Comp), Event.GroupJoin, QueryJoinType.Inner, Comp.Columns.EventK, Event.Columns.K);

			t = Templates.Comps.Latest.PerformJoins(t);

			Query q = new Query();
			q.Columns = Templates.Comps.Latest.Columns;

			q.QueryCondition = new And(
				new Q(Comp.Columns.Status, Comp.StatusEnum.Enabled),
				new Q(Comp.Columns.DateTimeClose, QueryOperator.GreaterThan, DateTime.Now),
				new Q(Comp.Columns.DateTimeStart, QueryOperator.LessThan, DateTime.Now),
				RelevanceQ
				);
			q.OrderBy = new OrderBy(new OrderBy(Comp.Columns.PrizeValueRange, OrderBy.OrderDirection.Descending), new OrderBy(OrderBy.OrderDirection.Random));
			q.TopRecords = Items;
			q.TableElement = t;
			CompSet cs = new CompSet(q);

			if (cs.Count == 0)
				CompPanel.Visible = false;
			else
			{
				CompPanel.Visible = true;
				CompDataList.DataSource = cs;
				CompDataList.ItemTemplate = this.LoadTemplate("/Templates/Comps/Latest.ascx");
				CompDataList.DataBind();

				if (Discussable == null)
					CompArchiveAnchor.HRef = Archive.GetUrl(DateTime.Now.Year, DateTime.Now.Month, 0, ArchiveObjectType.Comp, new string[] { }, "");
				else if (Discussable.UsedDiscussable is IHasArchive && cs.Count == Items)
					CompArchiveAnchor.HRef = ((IHasArchive)Discussable.UsedDiscussable).UrlArchiveDate(DateTime.Now.Year, DateTime.Now.Month, 0, ArchiveObjectType.Comp);
				else
				{
					CompArchiveDiv.Visible = false;
					CompPanelInner.Attributes["class"] = "LatestPanel Big CleanLinks";
				}
			}
		}
示例#18
0
		public static int PickAllWinners()
		{
			//First lets get the competitions done with.
			Query q = new Query();
			q.QueryCondition=new And(
					new Q(Comp.Columns.Status,Comp.StatusEnum.Enabled),
					new Q(Comp.Columns.DateTimeClose,QueryOperator.LessThanOrEqualTo, DateTime.Now),
					new Or(
						new Q(Comp.Columns.WinnersPicked,false),
						new Q(Comp.Columns.WinnersPicked,QueryOperator.IsNull,null)
					),
					new Or(
						new Q(Comp.Columns.IsHtmlOverride,false),
						new Q(Comp.Columns.IsHtmlOverride,QueryOperator.IsNull,null)
					)
				);
			if (Vars.DevEnv)
				q.TopRecords=10;
			CompSet cs = new CompSet(q);
			int i=0;
			foreach (Comp c in cs)
			{
				string subject = "";
				string body = "";
				try
				{
					c.PickWinners();
					i++;
					subject = "Drawing competition...";
					body = "<h1>Drawing competition...</h1><p>"+c.Name+" (CompK="+c.K.ToString()+")</p><p>There were "+c.Entries.ToString()+" entries.</p>";
				}
				catch
				{

					subject = "FAILED drawing competition...";
					body = "<h1>FAILED drawing competition...</h1><p>" + c.Name + " (CompK=" + c.K.ToString() + ")</p><p>Check all details and re-draw!!!</p>";

					Mailer admin = new Mailer();
					admin.TemplateType = Mailer.TemplateTypes.AdminNote;
					admin.Body = body;
					admin.Subject = subject;
					admin.To = "*****@*****.**";
					admin.Send();
					
				}
				
			}
			return i;
		}