public void PanelStartAddButtonClick(object o, System.EventArgs e) { if (Page.IsValid) { EventSet evs = new EventSet( new Query( new And( new Q(Event.Columns.VenueK, SelectedEvent.VenueK), new Q(Event.Columns.DateTime, NewDateCalendar.SelectedDate) ) ) ); if (evs.Count > 0) { PanelConflictCheckbox.Checked = false; ChangePanel(PanelConflict); } else { int newK = DuplicateEvent(); this.ViewState["NewEventK"] = newK; BindPanelReview(newK); ChangePanel(PanelReview); } } }
private void Page_Load(object sender, System.EventArgs e) { if (!Page.IsPostBack) { if (OtherEvent != null) { EventSet current = new EventSet(new Query(new Q(Event.Columns.K, CurrentEvent.K))); CurrentEventDataList.DataSource = current; CurrentEventDataList.ItemTemplate = this.LoadTemplate("/Templates/Events/Guestlist.ascx"); CurrentEventDataList.DataBind(); EventSet other = new EventSet(new Query(new Q(Event.Columns.K, OtherEvent.K))); OtherEventDataList.DataSource = other; OtherEventDataList.ItemTemplate = this.LoadTemplate("/Templates/Events/Guestlist.ascx"); OtherEventDataList.DataBind(); } else { Usr.Current.Guestlist(CurrentEvent.K, true, null); Response.Redirect(CurrentEvent.Url()); } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (!CurrentPromoter.WillCheckCardsForPurchasedTickets) { throw new Exception("Not for you"); } ContainerPage.SetPageTitle("Confirm Card Details"); Query q = Event.GetEventsWithTicketsQuery(CurrentPromoter, DateTime.Today.AddDays(-14), DateTime.Today); q.OrderBy = new OrderBy(Event.Columns.K, OrderBy.OrderDirection.Descending); EventSet es = new EventSet(q); if (es.Count > 0) { this.uiEvents.DataSource = es; this.uiEvents.DataTextField = "Name"; this.uiEvents.DataValueField = "K"; this.uiEvents.DataBind(); this.uiEvents.Items.Insert(0, new ListItem("", "")); this.uiSelect.Visible = true; this.uiNoEvents.Visible = false; } else { this.uiSelect.Visible = false; this.uiNoEvents.Visible = true; } } this.uiSomeWrongLabel.Visible = false; }
private void LoadCurrentEventsWithTickets() { Query currentEventsWithTicketsQuery = new Query(new And(new Q(Bobs.TicketRun.Columns.PromoterK, CurrentPromoter.K), new Q(Bobs.TicketRun.Columns.EndDateTime, QueryOperator.GreaterThanOrEqualTo, DateTime.Today.AddDays(-5)), new Q(Bobs.TicketRun.Columns.SoldTickets, QueryOperator.GreaterThan, 0))); currentEventsWithTicketsQuery.TableElement = Bobs.TicketRun.EventJoin; currentEventsWithTicketsQuery.GroupBy = new GroupBy(new GroupBy(Event.Columns.K), new GroupBy(Event.Columns.DateTime), new GroupBy(Event.Columns.Name)); currentEventsWithTicketsQuery.OrderBy = new OrderBy(Event.Columns.DateTime); // currentEventsWithTicketsQuery.ExtraSelectElements.Add("TicketsSold", "SUM([TicketRun].[SoldTickets])"); currentEventsWithTicketsQuery.Columns = new ColumnSet(Event.Columns.K, Event.Columns.Name); EventSet currentEventsWithTickets = new EventSet(currentEventsWithTicketsQuery); this.NoTicketsP.Visible = false; if (currentEventsWithTickets.Count == 0) { this.NoTicketsP.Visible = true; this.HasTicketsP.Visible = false; } else if (currentEventsWithTickets.Count == 1) { // redirect to doorlist popup page Response.Redirect(currentEventsWithTickets[0].DoorlistUrl); } else { this.EventDropDownList.Items.Clear(); foreach (Event ticketEvent in currentEventsWithTickets) { this.EventDropDownList.Items.Add(new ListItem(ticketEvent.Name, ticketEvent.K.ToString())); } } }
private void NotifyEventSetUpdated(EventSet eventSet, IList <EventDetails> events) { var lastEvent = events.Last(); var notification = new EventSetUpdateNotification { Id = eventSet.Id, ResourceId = eventSet.ResourceId, Level = eventSet.Level, Comment = eventSet.Comment, CompletedNote = eventSet.CompletedNote, CountDelta = events.Count, EventLastReadTime = eventSet.LastReadTime, Owner = eventSet.Owner, Status = eventSet.Status, LastReadTime = eventSet.LastUpdateTime, AcceptedBy = eventSet.AcceptedBy, AcceptedTime = eventSet.AcceptedTime, Value = lastEvent.Value, CompletedTime = eventSet.CompletedTime, AssociatedParameterValue = lastEvent.AssociatedParameterValue, FailureMode = eventSet.FailureMode }; notificationService.NotifyEventSetUpdated(notification); events.ToList().ForEach(@event => NotifyEventArrived(eventSet.Id, @event)); }
public EventSet GetPendingOutboundEvent(int wait) { _lastClientMessage = DateTime.Now; EventSet result = OnGetPendingOutboundEvent(wait); return(result); }
public override Event Read(ref Utf8JsonReader reader, Type _, JsonSerializerOptions options) { if (JsonDocument.TryParseValue(ref reader, out var doc) && doc.RootElement.TryGetProperty(sTypePropertyName, out var typeProperty) && doc.RootElement.TryGetProperty(sDetailTypePropertyName, out var detailTypeProperty)) { var type = typeProperty.Deserialize <EventType>(options); var detailType = detailTypeProperty.GetString() ?? string.Empty; // Try to parse EventSet. if (!EventSet.TryFromKey((type, detailType), out var set)) { // Handle unknown `detail_type` events, but the `type` must be one of the four. set = type switch { EventType.Meta => EventSet.NewMeta(detailType, typeof(EventMeta)), EventType.Message => EventSet.NewMessage(detailType, typeof(EventMessage)), EventType.Notice => EventSet.NewNotice(detailType, typeof(EventNotice)), EventType.Request => EventSet.NewRequest(detailType, typeof(EventRequest)), // `type` is unknown, not supported yet. _ => throw new NotSupportedException( $"{nameof(EventType)} {typeProperty.GetRawText()} is not supported by {nameof(JsonEventConverter)}.") }; } var post = doc.Deserialize(set !.ClassType, options); if (post is Event ev) { return(ev); } } throw new JsonException(); }
void add_event_set(EventSet set) { lock (queue_monitor) { queue.Enqueue(set); Monitor.Pulse(queue_monitor); } }
private void AddNewEvent(object sender, RoutedEventArgs e) { string name = this.AddEventName.Text; DateTime dateS = this.AddEventDate.SelectedDate.GetValueOrDefault(); DateTime hour = this.AddEventTime.Time; if (dateS == null || hour == null || name == string.Empty) { MessageBox.Show("Please enter a valid date and/or name"); return; } DateTime date = new DateTime(dateS.Year, dateS.Month, dateS.Day, hour.Hour, hour.Minute, hour.Second); EventSet ev = new EventSet(); ev.DateOfEvent = date; ev.Name = name; EventSet inserted = this._eventVm.InsertEvent(ev); if (inserted == null) { MessageBox.Show("Name already exists, please choose another one"); return; } ShowMainWindow(inserted.ID_Event); }
private void ReceiveThread() { Thread.Sleep(3000); _vm.Resume(); while (_isRunning) { try { EventSet set = _vm.GetNextEventSet(); var type = set.Events.First().EventType; if (type != EventType.TypeLoad) { Debug.Print($"Event : {set.Events.Select(e => e.EventType).StringJoin(",")}"); } foreach (Event ev in set.Events) { HandleEventSet(ev); } } catch (VMNotSuspendedException) { } } }
internal void StartDebugging() { if (_vm != null) { return; } _vm = VirtualMachineManager.Connect(new IPEndPoint(_ipAddress, 11000)); _vm.EnableEvents(EventType.AssemblyLoad, EventType.ThreadStart, EventType.ThreadDeath, EventType.AssemblyUnload, EventType.UserBreak, EventType.Exception, EventType.UserLog, EventType.KeepAlive, EventType.TypeLoad); EventSet set = _vm.GetNextEventSet(); if (set.Events.OfType <VMStartEvent>().Any()) { _mainThread = new MonoThread(this, _engine, set.Events[0].Thread); _engine.Events.ThreadStarted(_mainThread); Task.Factory.StartNew(ReceiveThread, TaskCreationOptions.LongRunning); } else { throw new Exception("Didnt get VMStart-Event!"); } }
protected override ProcessMessagesResult OnProcessMessageEnd(MessageSet messageSet, bool messageWasProcessed) { if (!messageWasProcessed) { return(new ProcessMessagesResult { EventSet = null, Pending = true }); } bool hasMouseMoveMsg = false; foreach (Message m in messageSet.Messages) { if (m is MouseMoveMessage) { hasMouseMoveMsg = true; break; } } EventSet ev = GetPendingOutboundEvent(hasMouseMoveMsg ? 100 : 0); return(new ProcessMessagesResult { EventSet = ev, Pending = false }); }
public override object VisitInterfaceDecl(PParser.InterfaceDeclContext context) { // TYPE name=Iden var mInterface = (Interface)nodesToDeclarations.Get(context); // LPAREN type? RPAREN mInterface.PayloadType = ResolveType(context.type()); IEventSet eventSet; if (context.RECEIVES() == null) { eventSet = CurrentScope.UniversalEventSet; } else { eventSet = new EventSet(); if (context.nonDefaultEventList()?._events is IList <PParser.NonDefaultEventContext> events) { foreach (var eventContext in events) { eventSet.AddEvent((PEvent)Visit(eventContext)); } } } mInterface.ReceivableEvents = eventSet; return(mInterface); }
public void testEventSetForWholeYears() { // Testing that catastrophe events are split correctly for periods of whole years EventSet catRisk = new EventSet(sampleEvents, eventsStart, eventsEnd); CatSimulation simulation = catRisk.newSimulation(new Date(1, Month.January, 2015), new Date(31, Month.December, 2015)); QAssert.Require(simulation); List <KeyValuePair <Date, double> > path = new List <KeyValuePair <Date, double> >(); QAssert.Require(simulation.nextPath(path)); QAssert.AreEqual(0, path.Count); QAssert.Require(simulation.nextPath(path)); QAssert.AreEqual(1, path.Count); QAssert.AreEqual(new Date(1, Month.February, 2015), path[0].Key); QAssert.AreEqual(100, path[0].Value); QAssert.Require(simulation.nextPath(path)); QAssert.AreEqual(1, path.Count); QAssert.AreEqual(new Date(1, Month.July, 2015), path[0].Key); QAssert.AreEqual(150, path[0].Value); QAssert.Require(simulation.nextPath(path)); QAssert.AreEqual(1, path.Count); QAssert.AreEqual(new Date(5, Month.January, 2015), path[0].Key); QAssert.AreEqual(50, path[0].Value); QAssert.Require(!simulation.nextPath(path)); }
private void ReceiveThread() { Thread.Sleep(3000); _vm.Resume(); while (_isRunning) { try { EventSet set = _vm.GetNextEventSet(); bool resume = false; foreach (Event ev in set.Events) { logger.Trace(ev); resume = resume || HandleEventSet(ev); } if (resume && _vm != null) { _vm.Resume(); } } catch (VMNotSuspendedException) { } } }
internal void StartDebugging() { if (_vm != null) { return; } _vm = VirtualMachineManager.Connect(new IPEndPoint(_ipAddress, GlobalConfig.Current.DebuggerAgentPort)); _vm.EnableEvents(EventType.AssemblyLoad, EventType.ThreadStart, EventType.ThreadDeath, EventType.AssemblyUnload, EventType.UserBreak, EventType.Exception, EventType.UserLog, EventType.KeepAlive, EventType.TypeLoad); EventSet set = _vm.GetNextEventSet(); if (set.Events.OfType <VMStartEvent>().Any()) { //TODO: review by techcap _mainThread = new AD7Thread(_engine, new DebuggedThread(set.Events[0].Thread, _engine)); _engine.Callback.ThreadStarted(_mainThread); Task.Factory.StartNew(ReceiveThread, TaskCreationOptions.LongRunning); } else { throw new Exception("Didnt get VMStart-Event!"); } }
private static bool VerifyUpdatedEventSet(this EventSet eventSet, EventDetails sourceEvent, int expectedEventCount, DateTime currentTime) { eventSet.EventsCount.Should().Be(expectedEventCount); eventSet.LastReadTime.Should().Be(sourceEvent.ReadTime); eventSet.LastUpdateTime.Should().Be(currentTime); return(true); }
public void Publish(string channelName, Payload[] payloads) { EventSet eventSet = new EventSet { ChannelName = channelName, Payloads = payloads }; bool shouldPublish = false; lock (this) { if (State == PublishState.PermError) { throw new Microsoft.Csa.SharedObjects.ClientDisconnectedException("Publish called on EventLinkClient in a permanent error state."); } this.outgoingQueue.Enqueue(eventSet); if (State == PublishState.Idle) { shouldPublish = true; } OnPublish(); } if (shouldPublish) { PublishEvents(); } }
public HideEventModuleExpr(ParserRuleContext sourceNode, IEnumerable <PEvent> events, IPModuleExpr module) { SourceLocation = sourceNode; HideEvents = new EventSet(); HideEvents.AddEvents(events); ComponentModule = module; ModuleInfo = null; }
public MainWindowImpl(int idEvent) { this._idEvent = idEvent; this._dbEntities = new DbEntities(); this._dbEntities.SetIdEvent(idEvent); EventSet thisEvent = this._dbEntities.GetEventById(idEvent); this.EventTitle = thisEvent.Name + " - " + thisEvent.DateOfEvent.ToString(); }
public void Create(EventSet _event) { using (var db = new osu2008Entities1()) { var _entity = _event; db.Set <EventSet>().Add(_entity); db.SaveChanges(); } }
public void EventsMadeFromSetContainKeyGivenToConstructor(string apiKey) { var set = new EventSet(apiKey); var @event = set.NewEvent(); Assert.Equal(apiKey, @event.ApiKey); set.Add(@event); Assert.Equal(1, set.GetEvents().Count); }
public async Task <InvokeResult> AddEventSetAsync(EventSet eventSet, EntityHeader org, EntityHeader user) { await AuthorizeAsync(eventSet, AuthorizeResult.AuthorizeActions.Create, user, org); ValidationCheck(eventSet, Actions.Create); await _eventSetRepo.AddEventSetAsync(eventSet); return(InvokeResult.Success); }
internal void StartDebugging() { DebugHelper.TraceEnteringMethod(); if (_vm != null) { return; } try { BeginConnect(); _vm.EnableEvents( EventType.VMStart, EventType.VMDeath, EventType.ThreadStart, EventType.ThreadDeath, EventType.AppDomainCreate, EventType.AppDomainUnload, //EventType.MethodEntry, //EventType.MethodExit, EventType.AssemblyLoad, EventType.AssemblyUnload, //EventType.Breakpoint, // Not allowed via EnableEvents //EventType.Step, EventType.TypeLoad, EventType.Exception, EventType.KeepAlive, EventType.UserBreak, EventType.UserLog, EventType.VMDisconnect ); EventSet set = _vm.GetNextEventSet(); if (set.Events.OfType <VMStartEvent>().Any()) { foreach (Event ev in set.Events) { HandleEventSet(ev); } _startVMEvent.Reset(); Task.Factory.StartNew(ReceiveThread, TaskCreationOptions.LongRunning); } else { throw new Exception("Didnt get VMStart-Event!"); } } catch (Exception ex) { HostOutputWindowEx.LogInstance.WriteLine(ex.Message); throw; } }
public ActionResult Create(Guid id, EventViewModel data) { EventSet e = new EventSet(id); data.ModuleID = id; int EventSerial = e.Add(data); return(RedirectToAction("Index", new { id = data.ModuleID })); }
public void WhenThresholdOccurredBeforeSecondEvent_EventSetShouldBeUpdatedAndNewEventSetsShouldBeCreatedForSecondEvent() { var processType = new EventSetProcessType { Level = (byte)EventLevel.Critical, Threshold = TimeSpan.FromMinutes(5) }; processTypeManagerMock.Setup(obj => obj.GetProcessTypeAsync( It.Is <int>(i => i == criticalEvent.EventTypeId), It.Is <EventTypeCategory>(i => i == criticalEvent.Category))) .Returns(Task.FromResult(processType)) .Verifiable(); var eventSet = new EventSet { LastReadTime = currentTime.AddMinutes(-7), TypeCode = GetCriticalEventsetTypeCode() }; var events = new[] { criticalEvent .Clone() .WithReadTime(currentTime.AddMinutes(-6)), criticalEvent }; repositoryMock.Setup(obj => obj.FindLastEventSetsByTypeCodesAsync( It.Is <IList <long> >(typeCodes => typeCodes.SequenceEqual(new[] { GetCriticalEventsetTypeCode() })))) .Returns(Task.FromResult <IList <EventSet> >(new[] { eventSet })) .Verifiable(); repositoryMock.Setup(obj => obj.ApplyChangesAsync( It.IsAny <IList <EventSet> >(), It.IsAny <IList <EventSet> >())) .Returns(Task.CompletedTask) .Verifiable(); long newEventSetId = 15345; identityManagementServiceMock.Setup(obj => obj.GetNextLongIdsAsync(It.IsAny <string>(), 1)) .Returns(Task.FromResult <IList <long> >(new[] { newEventSetId })) .Verifiable(); var result = storageProcessor.InvokeSync(events); result.Should().HaveCount(2); result[0].VerifyEventSetCreated(newEventSetId, events.Last(), EventLevel.Critical, currentTime); result[1].VerifyEventSetUpdated(events.First(), 1, currentTime); VerifyMocks(); }
private void EventConfirm(object sender, RoutedEventArgs e) { EventSet selected = this._eventVm.GetEventById(this._eventVm.SelectedEvent); if (selected == null) { return; } ShowMainWindow(selected.ID_Event); }
public EventModel(EventSet events) { this.Creator = events.Creator; this.EndDate = events.EndDate; this.EventId = events.EventId; this.Name = events.Name; this.StartDate = events.StartDate; this.UserSets = events.UserSets; this.events = new HashSet <EventSet>(); }
public async Task <InvokeResult> UpdateEventSetAsync(EventSet eventSet, EntityHeader org, EntityHeader user) { await AuthorizeAsync(eventSet, AuthorizeResult.AuthorizeActions.Update, user, org); ValidationCheck(eventSet, Actions.Update); eventSet.LastUpdatedBy = user; eventSet.LastUpdatedDate = DateTime.Now.ToJSONString(); await _eventSetRepo.UpdateEventSetAsync(eventSet); return(InvokeResult.Success); }
private void NotifyEventSetCreated(EventSet eventSet) { var notification = new EventSetAppearingNotification { Id = eventSet.Id, EventTypeId = eventSet.EventTypeId, ResourceId = eventSet.ResourceId }; notificationService.NotifyEventSetCreated(notification); }
private Scope(ITranslationErrorHandler handler, Scope parent = null) { this.handler = handler; parent?.children.Remove(this); Parent = parent; parent?.children.Add(this); EventSet eventSetWithHalt = new EventSet(); eventSetWithHalt.AddEvent(new PEvent("halt", null)); UniversalEventSet = parent == null ? eventSetWithHalt : parent.UniversalEventSet; }
protected void Generate(object sender, EventArgs eventArgs) { DateTime issueDate = new DateTime(long.Parse(IssueDrop.SelectedValue)); DateTime min = new DateTime(issueDate.AddMonths(-1).Year, issueDate.AddMonths(-1).Month, 10); DateTime max = new DateTime(issueDate.AddMonths(1).Year, issueDate.AddMonths(1).Month, 1).AddDays(-1); Query q = new Query(); q.TableElement = Bobs.Event.VenueAllJoin; q.QueryCondition = new And( new Q(Bobs.Event.Columns.DateTime, QueryOperator.GreaterThanOrEqualTo, min), new Q(Bobs.Event.Columns.DateTime, QueryOperator.LessThanOrEqualTo, max), placeQ ); EventSet es = new EventSet(q); Response.Clear(); Response.ContentType = "application/csv"; foreach (Bobs.Event e in es) { Response.Write(""); Response.Write("[venue id?]" + "\t");//MMV09299 Response.Write(e.Venue.Place.Name + "\t");//London Response.Write(e.Venue.Place.Name + "\t");//london Response.Write(e.Venue.Capacity.ToString("#,##0") + "\t");//[capacity] Response.Write("[venue address 1]" + "\t");//Old QueenÕs Head Response.Write("[venue address 2]" + "\t");//44 Essex Road, N1 Response.Write("[event id?]" + "\t");//MMN09724 Response.Write((e.Brands.Count > 0 ? e.Brands[0].Name.TruncateWithDots(30) : e.Name.TruncateWithDots(30)) + "\t");//Apocalypso Response.Write(e.DateTime.ToString("dddd") + "\t");//Friday Response.Write("[start-time]" + "\t");//8pm Response.Write("[end-time]" + "\t");//2am Response.Write("[price]" + "\t");//£4 Response.Write("[phone]" + "\t");//020 7354 9993 Response.Write("[???]" + "\t");//[???] Response.Write("[web address]" + "\t");//www.theoldqueenshead.com Response.Write("[main brand description]" + "\t");//Electro and indie dance at this party boozer. Response.Write("[mixmag offer]" + "\t");//HALF PRICE Response.Write(e.DateTime.ToString("dd/mm/yyyy") + "\t");//29/05/2009 Response.Write(e.DateTime.ToString("d/m") + "\t");//29/5 Response.Write(e.ShortDetailsHtml.Replace("\r", string.Empty).Replace("\n", string.Empty).TruncateWithDots(40) + "\t");//Dekker & Johan Response.Write("[???]" + "\t");//[???] Response.Write("[???]" + "\t");//[???] Response.Write("[???]" + "\t");//[???] Response.Write("[locality?]");//Angel Response.Write("\n"); } Response.Flush(); Response.Close(); Response.End(); }
public void WhenCurrentAutocompleteTimeOccurredAndStatusIsRejected_NewEventSetShouldBeCreated() { var processType = new EventSetProcessType { Level = (byte)EventLevel.Critical, Threshold = TimeSpan.FromMinutes(10), AutoComplete = true, AutoCompleteTimeout = TimeSpan.FromSeconds(9) }; processTypeManagerMock.Setup(obj => obj.GetProcessTypeAsync( It.Is <int>(i => i == criticalEvent.EventTypeId), It.Is <EventTypeCategory>(i => i == criticalEvent.Category))) .Returns(Task.FromResult(processType)) .Verifiable(); var eventSet = new EventSet { LastReadTime = currentTime.AddMinutes(-1), AcceptedTime = currentTime.AddMinutes(-1), Status = (byte)EventSetStatus.Rejected, TypeCode = GetCriticalEventsetTypeCode() }; repositoryMock.Setup(obj => obj.FindLastEventSetsByTypeCodesAsync( It.Is <IList <long> >(typeCodes => typeCodes.SequenceEqual(new[] { GetCriticalEventsetTypeCode() })))) .Returns(Task.FromResult <IList <EventSet> >(new[] { eventSet })) .Verifiable(); repositoryMock.Setup(obj => obj.ApplyChangesAsync( It.Is <IList <EventSet> >(sets => sets.Count == 1), It.Is <IList <EventSet> >(sets => sets.Count == 0))) .Returns(Task.CompletedTask) .Verifiable(); long newEventSetId = 15345; identityManagementServiceMock.Setup(obj => obj.GetNextLongIdsAsync(It.IsAny <string>(), 1)) .Returns(Task.FromResult <IList <long> >(new[] { newEventSetId })) .Verifiable(); var result = storageProcessor.InvokeSync(new[] { criticalEvent }); result.Should().HaveCount(1); result.First().VerifyEventSetCreated(newEventSetId, criticalEvent, EventLevel.Critical, currentTime); VerifyMocks(); }
public static void RegisterEvent(EventSet evt) { if (true == IsInvoking) { return; } if (Utils.IsNull(evt)) { Dbg.LogE($"Logic Event Tuple is null. Check RegisterEvent()"); } logicEventSet.Add(evt); }
public override bool IsAssignableFrom(PLanguageType otherType) { if (otherType is PermissionType permission) { EventSet eventSet1 = new EventSet(); EventSet eventSet2 = new EventSet(); eventSet1.AddEvents(otherType.AllowedPermissions.Value); eventSet2.AddEvents(AllowedPermissions.Value); return eventSet1.IsSame(eventSet2); } return false; }
void BindEvents() { Query q = new Query(); q.QueryCondition = new Q(Promoter.Columns.K, CurrentPromoter.K); q.NoLock = true; q.Distinct = true; q.DistinctColumn = Event.Columns.K; q.TableElement = Event.PromoterJoinWithVenue; q.OrderBy = Event.PastEventOrder; EventSet es = new EventSet(q); EventsGridView.AllowPaging = (es.Count > EventsGridView.PageSize); EventsGridView.DataSource = es; EventsGridView.DataBind(); }
void BindEvents() { Query q = new Query(); q.QueryCondition = new Q(Event.Columns.OwnerUsrK, Usr.Current.K); q.OrderBy = Event.PastEventOrder; EventSet es = new EventSet(q); if (es.Count > 0) { EventsDataGrid.AllowPaging = (es.Count > EventsDataGrid.PageSize); EventsDataGrid.DataSource = es; EventsDataGrid.DataBind(); } else EventsPanel.Visible = false; }
protected void Page_Load(object sender, EventArgs eA) { Query q = new Query(); q.TopRecords = 1; q.QueryCondition = new Q(Bobs.Event.Columns.Pic, QueryOperator.NotEqualTo, Guid.Empty); q.OrderBy = new OrderBy(OrderBy.OrderDirection.Random); EventSet es = new EventSet(q); IPic pic = (IPic)es[0]; Response.ContentType = "image/jpg"; Response.Clear(); if (pic.PicMiscK > 0 && pic.PicMisc != null) { Bobs.Cropper c = new Bobs.Cropper(); //c.ImageUrl = e.PicMisc.; c.ImageGuid = pic.PicMisc.Guid; c.ImageStore = Storage.Stores.Pix; c.SetState(pic.PicState); double factor = 1.79; int minDimension = pic.PicMisc.Height > pic.PicMisc.Width ? pic.PicMisc.Width : pic.PicMisc.Height; if (minDimension < (int)(100 * factor)) { factor = factor * ((double)minDimension / (double)(int)(100 * factor)); } c.CropHeight = 179; c.CropWidth = 179; c.Zoom = c.Zoom * 1.79; c.ResetStateToEnsureImageIsWithinCropArea(); Response.BinaryWrite(c.GetBytes()); } else { byte[] b = Storage.GetFromStore(Storage.Stores.Pix, pic.Pic, "jpg"); Response.BinaryWrite(b); } Response.Flush(); Response.End(); }
protected void bind() { Query q = new Query(); q.TableElement = Event.PromoterJoinAllWithVenue; q.CacheDuration = TimeSpan.FromHours(1); q.QueryCondition = new And( new StringQueryCondition("(select count(*) from [Invoice] where [Invoice].[PromoterK] = [Promoter].[K]) = 0"), new Q(Promoter.Columns.K, QueryOperator.GreaterThan, 0), Event.FutureEventsQueryCondition ); q.OrderBy = Event.FutureEventOrder; q.TopRecords = 1000; q.Distinct = true; q.DistinctColumn = Event.Columns.K; EventSet es = new EventSet(q); StringBuilder sb = new StringBuilder(); foreach (Event e in es) { bool doneOne = false; sb.Append("<p>"); sb.Append(e.FriendlyHtml(true, true, true, true, true, 50)); sb.Append(" - ["); sb.Append(e.Venue.Capacity.ToString("#,##0")); sb.Append("] - "); if (e.Venue.PromoterK > 0) { if (e.Venue.Promoter.ChildInvoices().Count == 0) { appendPromoter(sb, e.Venue.Promoter, doneOne); doneOne = true; } } foreach (Brand b in e.Brands) { if (b.PromoterK > 0 && b.PromoterK != e.Venue.PromoterK) { if (b.Promoter.ChildInvoices().Count == 0) { appendPromoter(sb, b.Promoter, doneOne); doneOne = true; } } } sb.Append("</p>"); } Ph.Controls.Add(new LiteralControl(sb.ToString())); }
private void EventLinkEventsReceived(EventSet[] eventSets) { if (eventSets == null) { return; } var payloads = from es in eventSets from payload in es.Payloads select payload; foreach (Payload p in payloads) { Debug.WriteLine("Receiving Payload: {0} on channel {1}: {2}", p.PayloadType, this.ChannelName, p.ToJsonString()); } this.OnEventsReceived(payloads); }
//protected bool TicketRunHasDescription //{ // get // { // return CurrentTicket.ExtraSelectElements["TicketRunDescription"] != DBNull.Value && ((string)CurrentTicket.ExtraSelectElements["TicketRunDescription"]).Length > 0; // } //} #region Methods public void LoadMyTickets() { eventsWithMyTickets = Usr.Current.EventsWithTickets(this.SelectedDateRange, this.PageNumber, this.RecordsPerPage); ViewState["EventTicketsCounter"] = "0"; this.MyEventTicketsRepeater.DataSource = eventsWithMyTickets; this.MyEventTicketsRepeater.DataBind(); HasTickets.Visible = eventsWithMyTickets.Count > 0; NoTickets.Visible = !HasTickets.Visible; this.SelectAllDateRangeLinkButton.Enabled = !SelectedDateRange.Equals(Utilities.DateRange.All); this.SelectCurrentDateRangeLinkButton.Enabled = !SelectedDateRange.Equals(Utilities.DateRange.Current); this.SelectPastDateRangeLinkButton.Enabled = !SelectedDateRange.Equals(Utilities.DateRange.Old); }
private void BindEventsList(EventSet events) { DateTime currentDateTime = DateTime.MinValue; int currentEventK = 0; foreach (Event e in events) { if (currentEventK != e.K) { currentEventK = e.K; if (currentDateTime != e.DateTime) { currentDateTime = e.DateTime; this.Controls.Add(CreateDateRow(e.DateTime)); } this.Controls.Add(CreateEventRow(e)); } } }
public void LoadMyTickets() { eventsWithMyTickets = ThisUsr.EventsWithTickets(this.SelectedDateRange, this.PageNumber, this.RecordsPerPage); // TicketSet myTickets = Usr.Current.Tickets(this.SelectedDateRange, this.PageNumber, this.RecordsPerPage); //MyTicketsRepeater.ItemTemplate = this.LoadTemplate("/Templates/Usrs/EventTicketsList.ascx"); //TicketEventDataList.ItemTemplate = this.LoadTemplate("/Templates/Events/UsrPageAttendedList.ascx"); this.MyTicketsPanel.Visible = true; ViewState["EventTicketsCounter"] = "0"; this.MyEventTicketsRepeater.DataSource = eventsWithMyTickets; this.MyEventTicketsRepeater.DataBind(); uiHasETickets.Visible = eventsWithMyTickets.Count > 0; NoTickets.Visible = !uiHasETickets.Visible; this.SelectAllDateRangeLinkButton.Enabled = !SelectedDateRange.Equals(Utilities.DateRange.All); this.SelectCurrentDateRangeLinkButton.Enabled = !SelectedDateRange.Equals(Utilities.DateRange.Current); this.SelectPastDateRangeLinkButton.Enabled = !SelectedDateRange.Equals(Utilities.DateRange.Old); }
public void UpdateEventCount(Transaction transaction) { Query q = new Query(); q.QueryCondition = new Q(Event.Columns.OwnerUsrK, this.K); q.ReturnCountOnly = true; EventSet es = new EventSet(q); this.EventCount = es.Count; this.Update(transaction); }
public void DeleteAll(Transaction transaction) { if (!this.Bob.DbRecordExists) return; //Events EventSet es = new EventSet(new Query(new Q(Event.Columns.VenueK,this.K))); foreach(Event e in es) e.DeleteAll(transaction); Delete CommentAlertDelete = new Delete( TablesEnum.CommentAlert, new And( new Q(CommentAlert.Columns.ParentObjectK,this.K), new Q(CommentAlert.Columns.ParentObjectType,Model.Entities.ObjectType.Venue) ) ); CommentAlertDelete.Run(transaction); //Threads ThreadSet ts = new ThreadSet( new Query( new And( new Q(Thread.Columns.ParentObjectType,Model.Entities.ObjectType.Venue), new Q(Thread.Columns.ParentObjectK,this.K) ) ) ); foreach (Thread t in ts) t.DeleteAll(transaction); //Articles ArticleSet ars = new ArticleSet(new Query(new Q(Article.Columns.VenueK, this.K))); foreach (Article a in ars) a.DeleteAll(transaction); 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); } this.Place.UpdateTotalEvents(transaction); }
void BindBoards() { if (HotTopicsCountry == null) { HotTopicsHomeCountryLink.InnerText = HotTopicsHomeCountryLink.InnerText.Replace("???", Country.Current.FriendlyName); HotTopicsHomeCountryLink.HRef = Country.Current.UrlHotTopics(); HotTopicsCountryPanel.Visible = false; HotTopicsWorldwidePanel.Visible = true; SetPageTitle("Hot forums worldwide"); } else { HotTopicsCountryLink.InnerText = HotTopicsCountry.FriendlyName; HotTopicsCountryLink.HRef = HotTopicsCountry.Url(); HotTopicsCountryPanel.Visible = true; HotTopicsWorldwidePanel.Visible = false; SetPageTitle("Hot forums in " + HotTopicsCountry.FriendlyName); } Q HotTopicsCountryPlaceFilter = new Q(true); Q HotTopicsCountryThreadFilter = new Q(true); if (HotTopicsCountry != null) { HotTopicsCountryPlaceFilter = new Q(Place.Columns.CountryK, HotTopicsCountry.K); HotTopicsCountryThreadFilter = new Q(Thread.Columns.CountryK, HotTopicsCountry.K); } Query qPlace = new Query(); qPlace.TopRecords = 20; qPlace.QueryCondition = new And( new Q(Place.Columns.TotalComments, QueryOperator.GreaterThan, 0), HotTopicsCountryPlaceFilter ); qPlace.OrderBy = new OrderBy("(TotalComments - (Population/12.0)) DESC"); PlaceSet ts = new PlaceSet(qPlace); if (ts.Count > 0) { BoardPlaceDataGrid.DataSource = ts; BoardPlaceDataGrid.DataBind(); } else BoardPlacePanel.Visible = false; Query qEvent = new Query(); qEvent.TopRecords = 20; qEvent.TableElement = Event.PlaceAllJoin; qEvent.QueryCondition = new And( new Q(Event.Columns.TotalComments, QueryOperator.GreaterThan, 0), HotTopicsCountryPlaceFilter ); qEvent.OrderBy = new OrderBy("(Event.TotalComments - (CASE SIGN(DATEDIFF(day, Event.DateTime, GetDate())*2) WHEN 1 THEN DATEDIFF(day, Event.DateTime, GetDate())*2 WHEN 0 THEN 0 ELSE 0 END)) DESC"); EventSet es = new EventSet(qEvent); if (es.Count > 0) { BoardEventDataGrid.DataSource = es; BoardEventDataGrid.DataBind(); } else BoardEventPanel.Visible = false; Query qThread = new Query(); qThread.TopRecords = 20; qThread.QueryCondition = new And( new Q(Thread.Columns.TotalComments, QueryOperator.GreaterThan, 2), new Q(Thread.Columns.Enabled, true), new Q(Thread.Columns.Private, false), new Q(Thread.Columns.GroupPrivate, false), new Q(Thread.Columns.PrivateGroup, false), HotTopicsCountryThreadFilter, new Q(Thread.Columns.HideFromHighlights, false) ); qThread.OrderBy = Thread.HotTopicsOrderBy; ThreadSet threadSet = new ThreadSet(qThread); if (threadSet.Count > 0) { BoardThreadDataGrid.DataSource = threadSet; BoardThreadDataGrid.DataBind(); } else BoardThreadPanel.Visible = false; }
private void SetupPromoterEvents() { if (CurrentPromoter != null) { this.NonEventSpecificDiv.Visible = true; Query promoterEventsQuery = new Query(new And(new Q(Promoter.Columns.K, CurrentPromoter.K), new Q(Event.Columns.DateTime, QueryOperator.GreaterThanOrEqualTo, DateTime.Today))); promoterEventsQuery.Columns = new ColumnSet(Event.Columns.Name, Event.Columns.K, Event.Columns.DateTime); promoterEventsQuery.TableElement = Event.PromoterJoinWithVenue; promoterEventsQuery.OrderBy = Event.FutureEventOrder; promoterEventsQuery.NoLock = true; promoterEventsQuery.Distinct = true; promoterEventsQuery.DistinctColumn = Event.Columns.K; EventSet promoterEvents = new EventSet(promoterEventsQuery); this.NoEventsPanel.Visible = promoterEvents.Count == 0; this.HasEventsPanel.Visible = !this.NoEventsPanel.Visible; this.AddEditTicketRunPanel.Visible = promoterEvents.Count > 0; List<Event> promoterEventList = new List<Event>(); promoterEvents.Reset(); foreach (Event promoterEvent in promoterEvents) promoterEventList.Add(promoterEvent); SetupEventDropDownList(promoterEventList); } }
public int EventsCount() { Query q = new Query(); q.NoLock = true; q.TableElement=Event.BrandJoin; q.QueryCondition=new Q(Brand.Columns.K,this.K); q.ReturnCountOnly=true; EventSet es = new EventSet(q); int i = es.Count; return i; }
public Event HasSingleEvent(int Year, int Month, int Day) { Query q = new Query(); q.NoLock=true; q.Columns=new ColumnSet(Event.Columns.K,Event.Columns.VenueK,Event.Columns.DateTime); Q DateTimeQ = null; if (Year>0 && Month>0 && Day>0) DateTimeQ = new Q(Event.Columns.DateTime,new DateTime(Year,Month,Day)); else if (Year>0 && Month>0) DateTimeQ = new And( new Q(Event.Columns.DateTime,QueryOperator.GreaterThanOrEqualTo,new DateTime(Year,Month,1)), new Q(Event.Columns.DateTime,QueryOperator.LessThan,new DateTime(Year,Month,1).AddMonths(1))); else if (Year>0) DateTimeQ = new And( new Q(Event.Columns.DateTime,QueryOperator.GreaterThanOrEqualTo,new DateTime(Year,1,1)), new Q(Event.Columns.DateTime,QueryOperator.LessThan,new DateTime(Year,1,1).AddYears(1))); q.TopRecords=2; q.TableElement=Event.BrandJoin; q.QueryCondition=new And(new Q(Brand.Columns.K,this.K),DateTimeQ); EventSet es = new EventSet(q); if (es.Count==1) return es[0]; else return null; }
public EventSet EventsAttended(ColumnSet cs, int topRecords) { if (eventsAttended == null) { Query q = new Query(); q.QueryCondition = new Q(Usr.Columns.K, this.K); q.TableElement = Event.UsrAttendedJoin; if (cs != null) q.Columns = cs; if (topRecords > 0) q.TopRecords = topRecords; eventsAttended = new EventSet(q); } return eventsAttended; }
void BindEvents() { Query q = new Query(); q.QueryCondition = new And(new Q(Event.Columns.HasGuestlist, true), new Q(Event.Columns.GuestlistPromoterK, CurrentPromoter.K)); q.NoLock = true; q.OrderBy = Event.PastEventOrder; EventSet es = new EventSet(q); if (es.Count > 0) { EventsDataGrid.AllowPaging = (es.Count > EventsDataGrid.PageSize); EventsDataGrid.DataSource = es; EventsDataGrid.DataBind(); } else { NoGuestlistsLabel.Visible = true; EventsDataGrid.Visible = false; } }
public void DeleteAll(Transaction transaction) { if (!this.Bob.DbRecordExists) return; Query qUsrEventGuestlist = new Query(); qUsrEventGuestlist.QueryCondition = new Q(UsrEventGuestlist.Columns.UsrK, this.K); UsrEventGuestlistSet uegs = new UsrEventGuestlistSet(qUsrEventGuestlist); foreach (UsrEventGuestlist ueg in uegs) { ueg.Delete(transaction); ueg.Event.UpdateGuestlistCount(transaction); } //Promoters Query PromoterQ = new Query(); PromoterQ.TableElement = Promoter.UsrJoin; PromoterQ.QueryCondition = new Q(Usr.Columns.K, this.K); PromoterSet promoters = new PromoterSet(PromoterQ); Delete PromoterUsrDelete = new Delete( TablesEnum.PromoterUsr, new Q(PromoterUsr.Columns.UsrK, this.K) ); PromoterUsrDelete.CommandTimeout = 3600; PromoterUsrDelete.Run(transaction); foreach (Promoter p in promoters) { p.AdminUsrs = null; if (p.AdminUsrs.Count == 0) { p.DeleteAll(transaction); } else if (p.PrimaryUsrK == this.K) { p.PrimaryUsrK = p.AdminUsrs[0].K; p.Update(transaction); } } //UsrPlaceVisit Delete UsrPlaceVisitDelete = new Delete( TablesEnum.UsrPlaceVisit, new Q(UsrPlaceVisit.Columns.UsrK, this.K) ); UsrPlaceVisitDelete.CommandTimeout = 3600; UsrPlaceVisitDelete.Run(transaction); //UsrEventAttended Delete UsrEventAttendedDelete = new Delete( TablesEnum.UsrEventAttended, new Q(UsrEventAttended.Columns.UsrK, this.K) ); UsrEventAttendedDelete.CommandTimeout = 3600; UsrEventAttendedDelete.Run(transaction); //UsrPhotoFavourite Delete UsrPhotoFavouriteDelete = new Delete( TablesEnum.UsrPhotoFavourite, new Q(UsrPhotoFavourite.Columns.UsrK, this.K) ); UsrPhotoFavouriteDelete.CommandTimeout = 3600; UsrPhotoFavouriteDelete.Run(transaction); //UsrPhotoMe PhotoSet psMe = this.PhotosMe(new ColumnSet(Photo.Columns.K, Photo.Columns.EventK, Photo.Columns.FirstUsrK, Photo.Columns.UsrCount), 0); foreach (Photo p in psMe) { this.PhotoMe(p, false, transaction); } //UsrMusicTypeFavourite Delete UsrMusicTypeFavouriteDelete = new Delete( TablesEnum.UsrMusicTypeFavourite, new Q(UsrMusicTypeFavourite.Columns.UsrK, this.K) ); UsrMusicTypeFavouriteDelete.CommandTimeout = 3600; UsrMusicTypeFavouriteDelete.Run(transaction); //Buddy / Buddy reverse; BuddySet bs = new BuddySet(new Query(new Or(new Q(Buddy.Columns.UsrK, this.K), new Q(Buddy.Columns.BuddyUsrK, this.K)))); foreach (Buddy b in bs) b.DeleteAll(transaction); //ChatMessageFrom // Delete ChatMessageFromDelete = new Delete( // TablesEnum.ChatMessage, // new Q(ChatMessage.Columns.FromUsrK,this.K) // ); // ChatMessageFromDelete.Run(transaction); //ChatMessageTo // Delete ChatMessageToDelete = new Delete( // TablesEnum.ChatMessage, // new Q(ChatMessage.Columns.ToUsrK, this.K) // ); // ChatMessageToDelete.Run(transaction); //UsrDate Delete UsrDateDelete = new Delete( TablesEnum.UsrDate, new Or(new Q(UsrDate.Columns.UsrK, this.K), new Q(UsrDate.Columns.DateUsrK, this.K)) ); UsrDateDelete.CommandTimeout = 3600; UsrDateDelete.Run(transaction); //Owners - Event EventSet esOwner = new EventSet(new Query(new Q(Event.Columns.OwnerUsrK, this.K))); foreach (Event e in esOwner) { e.OwnerUsrK = 8; e.Update(transaction); } BrandSet bsOwner = new BrandSet(new Query(new Q(Brand.Columns.OwnerUsrK, this.K))); foreach (Brand b in bsOwner) { b.OwnerUsrK = 8; b.Update(transaction); } //Owners - Venue VenueSet vsOwner = new VenueSet(new Query(new Q(Venue.Columns.OwnerUsrK, this.K))); foreach (Venue v in vsOwner) { v.OwnerUsrK = 8; v.Update(transaction); } //Remove EnabledByUsrK in Photos that this usr has enabled PhotoSet pEnableds = new PhotoSet(new Query(new Q(Photo.Columns.EnabledByUsrK, this.K))); foreach (Photo p in pEnableds) { p.EnabledByUsrK = 0; p.Update(transaction); } //ThreadUsr Delete ThreadUsrDelete = new Delete( TablesEnum.ThreadUsr, new Or(new Q(ThreadUsr.Columns.UsrK, this.K), new Q(ThreadUsr.Columns.InvitingUsrK, this.K)) ); ThreadUsrDelete.CommandTimeout = 3600; ThreadUsrDelete.Run(transaction); //CommentAlert Delete CommentAlertDelete = new Delete( TablesEnum.CommentAlert, new Q(CommentAlert.Columns.UsrK, this.K) ); CommentAlertDelete.CommandTimeout = 3600; CommentAlertDelete.Run(transaction); //GroupUsr Delete GroupUsrDelete = new Delete( TablesEnum.GroupUsr, new Q(GroupUsr.Columns.UsrK, this.K) ); GroupUsrDelete.CommandTimeout = 3600; GroupUsrDelete.Run(transaction); //Threads? ThreadSet ts = new ThreadSet(new Query(new Q(Thread.Columns.UsrK, this.K))); foreach (Thread t in ts) t.DeleteAll(transaction); Bobs.Update uLastPostUsrK = new Bobs.Update(); uLastPostUsrK.Changes.Add(new Assign(Thread.Columns.LastPostUsrK, 0)); uLastPostUsrK.Table = TablesEnum.Thread; uLastPostUsrK.Where = new Q(Thread.Columns.LastPostUsrK, this.K); uLastPostUsrK.CommandTimeout = 3600; uLastPostUsrK.Run(transaction); Bobs.Update uFirstParticipantUsrK = new Bobs.Update(); uFirstParticipantUsrK.Changes.Add(new Assign(Thread.Columns.FirstParticipantUsrK, 0)); uFirstParticipantUsrK.Table = TablesEnum.Thread; uFirstParticipantUsrK.Where = new Q(Thread.Columns.FirstParticipantUsrK, this.K); uFirstParticipantUsrK.CommandTimeout = 3600; uFirstParticipantUsrK.Run(); //Comments? CommentSet cs = new CommentSet(new Query(new Q(Comment.Columns.UsrK, this.K))); foreach (Comment c in cs) c.DeleteAll(transaction); //PhotoReview ??? PhotoReviewSet prs = new PhotoReviewSet(new Query(new Q(PhotoReview.Columns.UsrK, this.K))); foreach (PhotoReview pr in prs) { pr.Delete(transaction); pr.Photo.UpdateStats(transaction); } //Galleries GallerySet gs = new GallerySet(new Query(new Q(Gallery.Columns.OwnerUsrK, this.K))); foreach (Gallery g in gs) g.DeleteAll(transaction); //Photos PhotoSet ps = new PhotoSet(new Query(new Q(Photo.Columns.UsrK, this.K))); foreach (Photo p in ps) p.DeleteAll(transaction); //Aticles ArticleSet ars = new ArticleSet(new Query(new Q(Article.Columns.OwnerUsrK, this.K))); foreach (Article a in ars) a.DeleteAll(transaction); int k = this.K; //Usr-AddedByUsrK UsrSet usrsAddedByUsr = new UsrSet(new Query(new Q(Usr.Columns.AddedByUsrK, this.K))); foreach (Usr u in usrsAddedByUsr) { u.AddedByUsrK = 0; u.Update(transaction); } Guid oldPic = this.Pic; //Usr this.Delete(transaction); if (oldPic != Guid.Empty) Storage.RemoveFromStore(Storage.Stores.Pix, oldPic, "jpg"); }
public void UpdateChildUrlFragments(bool Cascade) { Update uEvents = new Update(); uEvents.Table=TablesEnum.Event; uEvents.Changes.Add(new Assign(Event.Columns.UrlFragment,UrlFilterPart)); uEvents.Where=new Q(Event.Columns.VenueK,this.K); uEvents.Run(); if (Cascade) { Query q = new Query(); q.NoLock=true; q.QueryCondition=new Q(Event.Columns.VenueK,this.K); q.Columns=new ColumnSet( Event.Columns.K, Event.Columns.UrlFragment, Event.Columns.VenueK, Event.Columns.DateTime); EventSet es = new EventSet(q); foreach (Event e in es) { try { Utilities.UpdateChildUrlFragmentsJob job = new Utilities.UpdateChildUrlFragmentsJob(Model.Entities.ObjectType.Event, e.K, true); job.ExecuteAsynchronously(); } catch(Exception ex) { if (Vars.DevEnv) throw ex; } } } Update uThreads = new Update(); uThreads.Table=TablesEnum.Thread; uThreads.Changes.Add(new Assign(Thread.Columns.UrlFragment,UrlFilterPart)); uThreads.Where=new And( new Q(Thread.Columns.ParentObjectType,Model.Entities.ObjectType.Venue), new Q(Thread.Columns.ParentObjectK,this.K)); uThreads.Run(); Update uArticles = new Update(); uArticles.Table=TablesEnum.Article; uArticles.Changes.Add(new Assign(Article.Columns.UrlFragment,UrlFilterPart)); uArticles.Where=new And( new Q(Article.Columns.ParentObjectType,Model.Entities.ObjectType.Venue), new Q(Article.Columns.ParentObjectK,this.K)); uArticles.Run(); if (Cascade) { Query q = new Query(); q.NoLock=true; q.QueryCondition=new And( new Q(Article.Columns.ParentObjectType,Model.Entities.ObjectType.Venue), new Q(Article.Columns.ParentObjectK,this.K)); q.Columns=new ColumnSet( Article.Columns.K, Article.Columns.UrlFragment, Article.Columns.ParentObjectK, Article.Columns.ParentObjectType); ArticleSet aSet = new ArticleSet(q); foreach (Article a in aSet) { try { Utilities.UpdateChildUrlFragmentsJob job = new Utilities.UpdateChildUrlFragmentsJob(Model.Entities.ObjectType.Article, a.K, true); job.ExecuteAsynchronously(); } catch(Exception ex) { if (Vars.DevEnv) throw ex; } } } }
public void EventsAttended_Load(object o, System.EventArgs e) { if (ThisUsr != null && !ThisUsr.IsSkeleton) { Query q = new Query(); q.NoLock = true; q.TableElement = Templates.Events.UsrPageAttendedList.PerformJoins(Event.UsrAttendedJoin); q.Columns = Templates.Events.UsrPageAttendedList.Columns; q.QueryCondition = new And( new Q(Usr.Columns.K, UsrK), Event.PreviousEventsQueryCondition); q.OrderBy = new OrderBy(Bobs.Event.Columns.DateTime, OrderBy.OrderDirection.Descending); q.TopRecords = 10; EventSet es = new EventSet(q); if (es.Count == 0) { EventsAttendedPanel.Visible = false; } else { EventsAttendedPanel.Visible = true; EventsAttendedDataList.DataSource = es; EventsAttendedDataList.ItemTemplate = this.LoadTemplate("/Templates/Events/UsrPageAttendedList.ascx"); EventsAttendedDataList.DataBind(); } } }
public Event WhereAmI(DateTime dateTime) { //First try to match exactly Q eventStartTime = null; if (dateTime.Hour < 10) { //before 9:00am - morning //all day event today OR evening event yesterday OR morning event today eventStartTime = new Or( new And( new Q(Event.Columns.DateTime, dateTime.Date.AddDays(-1)), new Q(Event.Columns.StartTime, Event.StartTimes.Evening) ), new And( new Q(Event.Columns.DateTime, dateTime.Date), new Q(Event.Columns.StartTime, Event.StartTimes.Morning) ) ); } else if (dateTime.Hour < 18) { //before 6:00pm but after 10:00am - late morning / early afternoon //all day event today OR morning event today OR daytime event today eventStartTime = new Or( new And( new Q(Event.Columns.DateTime, dateTime.Date), new Q(Event.Columns.StartTime, Event.StartTimes.Morning) ), new And( new Q(Event.Columns.DateTime, dateTime.Date), new Q(Event.Columns.StartTime, Event.StartTimes.Daytime) ) ); } else if (dateTime.Hour < 20) { //before 8:00pm but after 6:00pm - afternoon / evening //all day event today OR daytime event today OR evening event today eventStartTime = new Or( new And( new Q(Event.Columns.DateTime, dateTime.Date), new Q(Event.Columns.StartTime, Event.StartTimes.Daytime) ), new And( new Q(Event.Columns.DateTime, dateTime.Date), new Q(Event.Columns.StartTime, Event.StartTimes.Evening) ) ); } else { //after 8pm - evening - all day event today OR evening event today eventStartTime = new And( new Q(Event.Columns.DateTime, dateTime.Date), new Q(Event.Columns.StartTime, Event.StartTimes.Evening) ); } Query qExact = new Query(); qExact.TableElement = Event.UsrAttendedJoin; qExact.QueryCondition = new And( new Q(Usr.Columns.K, this.K), eventStartTime ); EventSet esExact = new EventSet(qExact); if (esExact.Count > 1) return null; else if (esExact.Count == 1) return esExact[0]; else { //loose matching //Any event today or yesterday eventStartTime = new Or( new Q(Event.Columns.DateTime, dateTime.Date), new Q(Event.Columns.DateTime, dateTime.Date.AddDays(-1)) ); Query qLoose = new Query(); qLoose.TableElement = Event.UsrAttendedJoin; qLoose.QueryCondition = new And( new Q(Usr.Columns.K, this.K), eventStartTime ); EventSet esLoose = new EventSet(qLoose); if (esLoose.Count > 1) return null; else if (esLoose.Count == 1) return esLoose[0]; else { //very loose matching //any event tomorrow, today, yesterday, or the day before eventStartTime = new Or( new Q(Event.Columns.DateTime, dateTime.Date.AddDays(1)), new Q(Event.Columns.DateTime, dateTime.Date), new Q(Event.Columns.DateTime, dateTime.Date.AddDays(-1)), new Q(Event.Columns.DateTime, dateTime.Date.AddDays(-2)) ); Query qVeryLoose = new Query(); qVeryLoose.TableElement = Event.UsrAttendedJoin; qVeryLoose.QueryCondition = new And( new Q(Usr.Columns.K, this.K), eventStartTime ); EventSet esVeryLoose = new EventSet(qVeryLoose); if (esVeryLoose.Count > 1) return null; else if (esVeryLoose.Count == 1) return esVeryLoose[0]; else return null; } } }
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 = "< " + firstOfMonth.AddDays(-1).ToString("MMMM"); BackLink1.InnerHtml = "< " + 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") + " >"; NextLink1.InnerHtml = lastOfMonth.AddDays(1).ToString("MMMM") + " >"; 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 = "< " + latest.ArchiveDateTime.ToString("MMMM"); BackLink1.InnerHtml = "< " + latest.ArchiveDateTime.ToString("MMMM"); if (latest.ArchiveDateTime.Year != ContainerPage.Url.DateFilter.Year) { BackLink.InnerHtml = "< " + latest.ArchiveDateTime.ToString("MMMM") + " " + latest.ArchiveDateTime.Year.ToString(); BackLink1.InnerHtml = "< " + 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") + " >"; NextLink1.InnerHtml = first.ArchiveDateTime.ToString("MMMM") + " >"; if (first.ArchiveDateTime.Year != ContainerPage.Url.DateFilter.Year) { NextLink.InnerHtml = first.ArchiveDateTime.ToString("MMMM") + " " + first.ArchiveDateTime.Year.ToString() + " >"; NextLink1.InnerHtml = first.ArchiveDateTime.ToString("MMMM") + " " + first.ArchiveDateTime.Year.ToString() + " >"; } } 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 } }
public void StripAll() { Query qUsrEventGuestlist = new Query(); qUsrEventGuestlist.QueryCondition = new Q(UsrEventGuestlist.Columns.UsrK, this.K); UsrEventGuestlistSet uegs = new UsrEventGuestlistSet(qUsrEventGuestlist); foreach (UsrEventGuestlist ueg in uegs) { ueg.Delete(); ueg.Update(); ueg.Event.UpdateGuestlistCount(); } //UsrPlaceVisit Delete UsrPlaceVisitDelete = new Delete( TablesEnum.UsrPlaceVisit, new Q(UsrPlaceVisit.Columns.UsrK, this.K) ); UsrPlaceVisitDelete.Run(); //UsrEventAttended Delete UsrEventAttendedDelete = new Delete( TablesEnum.UsrEventAttended, new Q(UsrEventAttended.Columns.UsrK, this.K) ); UsrEventAttendedDelete.Run(); //UsrPhotoFavourite Delete UsrPhotoFavouriteDelete = new Delete( TablesEnum.UsrPhotoFavourite, new Q(UsrPhotoFavourite.Columns.UsrK, this.K) ); UsrPhotoFavouriteDelete.Run(); //UsrPhotoMe Delete UsrPhotoMeDelete = new Delete( TablesEnum.UsrPhotoMe, new Q(UsrPhotoMe.Columns.UsrK, this.K) ); UsrPhotoMeDelete.Run(); //UsrMusicTypeFavourite Delete UsrMusicTypeFavouriteDelete = new Delete( TablesEnum.UsrMusicTypeFavourite, new Q(UsrMusicTypeFavourite.Columns.UsrK, this.K) ); UsrMusicTypeFavouriteDelete.Run(); //Buddy / Buddy reverse; BuddySet bs = new BuddySet(new Query(new Or(new Q(Buddy.Columns.UsrK, this.K), new Q(Buddy.Columns.BuddyUsrK, this.K)))); foreach (Buddy b in bs) b.DeleteAll(null); //UsrDate Delete UsrDateDelete = new Delete( TablesEnum.UsrDate, new Or(new Q(UsrDate.Columns.UsrK, this.K), new Q(UsrDate.Columns.DateUsrK, this.K)) ); UsrDateDelete.Run(); //Owners - Event EventSet esOwner = new EventSet(new Query(new Q(Event.Columns.OwnerUsrK, this.K))); foreach (Event e in esOwner) { e.DeleteAllUsr(Usr.Current); //e.OwnerUsrK=4; //e.Update(); } BrandSet bsOwner = new BrandSet(new Query(new Q(Brand.Columns.OwnerUsrK, this.K))); foreach (Brand b in bsOwner) { b.DeleteAll(null); //b.OwnerUsrK=4; //b.Update(); } //Owners - Venue VenueSet vsOwner = new VenueSet(new Query(new Q(Venue.Columns.OwnerUsrK, this.K))); foreach (Venue v in vsOwner) { v.DeleteAllUsr(Usr.Current); //v.OwnerUsrK=4; //v.Update(); } //PhotoReview ??? PhotoReviewSet prs = new PhotoReviewSet(new Query(new Q(PhotoReview.Columns.UsrK, this.K))); foreach (PhotoReview pr in prs) { pr.Delete(); pr.Update(); pr.Photo.UpdateStats(null); } //Galleries GallerySet gs = new GallerySet(new Query(new Q(Gallery.Columns.OwnerUsrK, this.K))); foreach (Gallery g in gs) g.DeleteAll(null); //Photos PhotoSet ps = new PhotoSet(new Query(new Q(Photo.Columns.UsrK, this.K))); foreach (Photo p in ps) p.DeleteAll(null); //Aticles ArticleSet ars = new ArticleSet(new Query(new Q(Article.Columns.OwnerUsrK, this.K))); foreach (Article a in ars) a.DeleteAll(null); Guid oldPic = Pic; this.PicPhotoK = 0; this.PicState = ""; this.Pic = Guid.Empty; this.PicOriginal = Guid.Empty; //this.NickName=Usr.GetCompliantNickName("user-"+this.K.ToString()); this.PersonalStatement = ""; this.IsSingle = false; this.EnhancedSecurity = true; this.IsSpotter = false; Random r = new Random(); this.LoginString = Cambro.Misc.Utility.GenRandomText(6, r); this.SetPassword(Cambro.Misc.Utility.GenRandomText(10, r), false); int k = this.K; //Usr this.Update(); if (oldPic != Guid.Empty) Storage.RemoveFromStore(Storage.Stores.Pix, oldPic, "jpg"); }
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; } }
public void MergeAndDelete(Venue merge) { if (this.K == merge.K) throw new DsiUserFriendlyException("Can't merge a venue into itself!"); Cambro.Web.Helpers.WriteAlertHeader(); //throw new Exception("This function isn't finished yet!"); Cambro.Web.Helpers.WriteAlert("Starting merge...", true); #region Promoter Cambro.Web.Helpers.WriteAlert("Merging promoter...", true); if (merge.PromoterK > 0 && merge.PromoterStatus.Equals(Venue.PromoterStatusEnum.Confirmed) && merge.Promoter.IsEnabled) { this.PromoterK = merge.PromoterK; this.PromoterStatus = Venue.PromoterStatusEnum.Confirmed; } else if (this.PromoterK == 0 && merge.PromoterK > 0) { this.PromoterK = merge.PromoterK; this.PromoterStatus = merge.PromoterStatus; } Cambro.Web.Helpers.WriteAlert("Done merging promoter..."); #endregion #region Articles if (true) { Cambro.Web.Helpers.WriteAlert("Moving articles...", true); Query q = new Query(); q.QueryCondition = new And(new Q(Article.Columns.ParentObjectType, Model.Entities.ObjectType.Venue),new Q(Article.Columns.ParentObjectK, merge.K)); ArticleSet ars = new ArticleSet(q); foreach (Article a in ars) { Cambro.Web.Helpers.WriteAlert("Moving article " + a.K + "..."); a.ParentObjectK = this.K; a.VenueK = this.K; if (a.Relevance <= Model.Entities.Article.RelevanceEnum.Place) a.PlaceK = this.PlaceK; else a.PlaceK = 0; if (a.Relevance <= Model.Entities.Article.RelevanceEnum.Country) a.CountryK = this.Place.CountryK; else a.CountryK = 0; a.UrlFragment = this.UrlFilterPart; a.Update(); #region Threads if (true) { Update u = new Update(); u.Table = TablesEnum.Thread; u.Where = new Q(Thread.Columns.ArticleK, a.K); u.Changes.Add(new Assign(Thread.Columns.UrlFragment, a.UrlFilterPart)); u.Changes.Add(new Assign(Thread.Columns.VenueK, this.K)); u.Changes.Add(new Assign(Thread.Columns.PlaceK, this.PlaceK)); u.Changes.Add(new Assign(Thread.Columns.CountryK, this.Place.CountryK)); u.Run(); } #endregion #region Galleries if (true) { Update u = new Update(); u.Table = TablesEnum.Gallery; u.Where = new Q(Gallery.Columns.ArticleK, a.K); u.Changes.Add(new Assign(Gallery.Columns.UrlFragment, a.UrlFilterPart)); u.Run(); } #endregion #region Photos if (true) { Update u = new Update(); u.Table = TablesEnum.Photo; u.Where = new Q(Photo.Columns.ArticleK, a.K); u.Changes.Add(new Assign(Photo.Columns.UrlFragment, a.UrlFilterPart)); u.Run(); } #endregion } Cambro.Web.Helpers.WriteAlert("Done moving articles...", true); } #endregion #region Events if (true) { Cambro.Web.Helpers.WriteAlert("Moving events...", true); EventSet es = new EventSet(new Query(new Q(Event.Columns.VenueK, merge.K))); int count = 0; foreach (Event ev in es) { count++; Cambro.Web.Helpers.WriteAlert("Moving event "+ev.K+" ("+count+" / "+es.Count+")..."); ev.ChangeVenue(this.K, true); } Cambro.Web.Helpers.WriteAlert("Done moving events..."); } #endregion #region Thread ParentObjects if (true) { Cambro.Web.Helpers.WriteAlert("Merging topics (1/2)...", true); Update u = new Update(); u.Table = TablesEnum.Thread; u.Where = new And( new Q(Thread.Columns.ParentObjectType, Model.Entities.ObjectType.Venue), new Q(Thread.Columns.ParentObjectK, merge.K)); u.Changes.Add(new Assign(Thread.Columns.ParentObjectK, this.K)); u.Run(); Cambro.Web.Helpers.WriteAlert("Done merging topics (1/2)..."); } #endregion #region Thread if (true) { Cambro.Web.Helpers.WriteAlert("Merging topics (2/2)...", true); Update u = new Update(); u.Table = TablesEnum.Thread; u.Where = new And( new Q(Thread.Columns.VenueK, merge.K), new Q(Thread.Columns.EventK, 0), new Q(Thread.Columns.ArticleK, 0)); u.Changes.Add(new Assign(Thread.Columns.VenueK, this.K)); u.Changes.Add(new Assign(Thread.Columns.UrlFragment, this.UrlFilterPart)); u.Run(); Cambro.Web.Helpers.WriteAlert("Done merging topics (2/2)..."); } #endregion #region Pic if (!this.HasPic) { Cambro.Web.Helpers.WriteAlert("Merging picture...", true); this.Pic = merge.Pic; this.PicMiscK = merge.PicMiscK; this.PicPhotoK = merge.PicPhotoK; this.PicState = merge.PicState; merge.Pic = Guid.Empty; merge.PicMiscK = 0; merge.PicPhotoK = 0; merge.PicState = ""; merge.Update(); Cambro.Web.Helpers.WriteAlert("Done merging picture..."); } #endregion this.AdminNote += "Venue " + merge.K + " was merged with this one " + DateTime.Now.ToString() + ". The admin note from venue " + merge.K + " is:\n********************\n" + merge.AdminNote + "\n********************\n"; this.Update(); int mergePlaceK = merge.PlaceK; Cambro.Web.Helpers.WriteAlert("Deleting old venue...", true); merge.DeleteAll(null); Cambro.Web.Helpers.WriteAlert("Done deleting old venue..."); if (mergePlaceK != this.PlaceK) { Place mergePlace = new Place(mergePlaceK); Cambro.Web.Helpers.WriteAlert("Updating stats for old place...", true); mergePlace.UpdateTotalComments(null); mergePlace.UpdateTotalEvents(null); Cambro.Web.Helpers.WriteAlert("Done updating stats for old place..."); } Cambro.Web.Helpers.WriteAlert("Updating stats for new venue...", true); this.UpdateTotalComments(null); this.UpdateTotalEvents(null); Cambro.Web.Helpers.WriteAlert("Done updating stats for new venue..."); this.Update(); Cambro.Web.Helpers.WriteAlert("Done merging venues!", true); }
public void UpdateTotalEvents(Transaction transaction) { Query q = new Query(); q.QueryCondition=new Q(Event.Columns.VenueK,this.K); q.ReturnCountOnly=true; EventSet allEvents = new EventSet(q); this.TotalEvents = allEvents.Count; this.Update(transaction); this.Place.UpdateTotalEvents(transaction); }