本文整理汇总了C#中Event.Update方法的典型用法代码示例。如果您正苦于以下问题:C# Event.Update方法的具体用法?C# Event.Update怎么用?C# Event.Update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Event
的用法示例。
在下文中一共展示了Event.Update方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RemovingAChildUsingDatabaseRemovesFromChildren
public void RemovingAChildUsingDatabaseRemovesFromChildren()
{
Venue venue = new Venue();
venue.Update();
Venue venue2 = new Venue();
venue2.Update();
Event ev = new Event();
ev.VenueK = venue.K;
ev.Update();
Assert.AreEqual(1, venue.ChildEvents().Count);
ev.VenueK = venue2.K;
ev.Update();
Assert.AreEqual(0, venue.ChildEvents().Count);
}
示例2: OrderBysWork
public void OrderBysWork()
{
Venue venue = new Venue();
venue.Update();
List<Event> events = new List<Event>();
for (int i = 0; i < 10; i++)
{
Event ev = new Event();
ev.VenueK = venue.K;
ev.Update();
events.Add(ev);
}
Event[] childEvents = venue.ChildEvents().AllItems();
Event[] pagedChildEvents = venue.ChildEvents().Page(1, 10);
for (int i = 0; i < events.Count; i++)
{
Assert.AreEqual(events[i].K, childEvents[i].K);
}
var orderBy = new Pair(Event.Columns.K, OrderBy.OrderDirection.Descending);
childEvents = venue.ChildEvents(orderBy).AllItems();
pagedChildEvents = venue.ChildEvents(orderBy).Page(1, 10);
for (int i = 0; i < events.Count; i++)
{
Assert.AreEqual(events[9 - i].K, childEvents[i].K);
}
}
示例3: AddingAChildUsingDatabaseAddsToChildren
public void AddingAChildUsingDatabaseAddsToChildren()
{
Venue venue = new Venue();
venue.Update();
Assert.AreEqual(0, venue.ChildEvents().Count);
Event ev = new Event();
ev.VenueK = venue.K;
ev.Update();
Assert.AreEqual(1, venue.ChildEvents().Count);
}
示例4: PagingWorks
public void PagingWorks()
{
Venue venue = new Venue();
venue.Update();
Random r = new Random();
int pageSize = r.Next(10) + 5;
int numberOfItems = r.Next(50) + 50;
if (numberOfItems % pageSize == 0) { numberOfItems++; }
List<Event> events = new List<Event>();
for (int i = 0; i < numberOfItems; i++)
{
Event ev = new Event();
ev.VenueK = venue.K;
ev.Update();
events.Add(ev);
}
Assert.AreEqual(numberOfItems, venue.ChildEvents().Count);
Assert.AreEqual(pageSize, venue.ChildEvents().Page(1, pageSize).Length);
int highestPageNumber = (int) Math.Ceiling((float) numberOfItems / (float)pageSize);
Assert.AreEqual(numberOfItems % pageSize, venue.ChildEvents().Page(highestPageNumber, pageSize).Length);
}
示例5: UpdateTicketHeatOfEvents
public static void UpdateTicketHeatOfEvents()
{
//UPDATE [Event] set [Event].[TicketHeat] = sumBookingFee FROM
//(SELECT [Ticket].[EventK], SUM([Ticket].[BookingFee]) AS sumBookingFee FROM [Ticket] WHERE [Ticket].[BuyDateTime]>DATEADD(day, -2, GETDATE()) AND [Ticket].[Enabled] = 1 GROUP BY [Ticket].[EventK]) t1
//INNER JOIN [Event] on t1.[EventK] = [Event].[K]
Transaction t = new Transaction();
try
{
Update clear = new Update();
clear.Changes.Add(new Assign(Event.Columns.TicketHeat, 0.0));
clear.Table = TablesEnum.Event;
clear.Where = new Q(Event.Columns.TicketHeat, QueryOperator.GreaterThan, 0.0);
Console.WriteLine("Cleared {0} row(s)", clear.Run(t));
Update up = new Update();
up.Table = TablesEnum.Event;
up.Changes.Add(new Assign.Override(Event.Columns.TicketHeat, "sumBookingFee"));
up.Where = new Q(true);
up.From = new Join(
new Join.StringOverride(
"(SELECT [Ticket].[EventK], SUM([Ticket].[BookingFee]) AS sumBookingFee FROM [Ticket] WHERE [Ticket].[BuyDateTime]>DATEADD(day, -7, GETDATE()) AND [Ticket].[Enabled] = 1 GROUP BY [Ticket].[EventK]) t1"),
new TableElement(TablesEnum.Event),
QueryJoinType.Inner,
new StringQueryCondition("t1.[EventK] = [Event].[K]"));
Console.WriteLine("Updated {0} row(s)", up.Run(t));
t.Commit();
}
catch (Exception ex)
{
t.Rollback();
Utilities.AdminEmailAlert("Exception updating TicketHeat flag on all events", "Exception updating TicketHeat flag on all events", ex);
}
finally
{
t.Close();
}
try
{
Event ev1 = new Event(159336);
ev1.TicketHeat = 1001;
ev1.Update();
}
catch(Exception ex)
{
Utilities.AdminEmailAlert("Exception updating TicketHeat flag on CreamFields 159336", "Exception updating TicketHeat flag on CreamFields 159336", ex);
}
try
{
Event ev2 = new Event(166002);
ev2.TicketHeat = 1000;
ev2.Update();
}
catch (Exception ex)
{
Utilities.AdminEmailAlert("Exception updating TicketHeat flag on CreamFields 166002", "Exception updating TicketHeat flag on CreamFields 166002", ex);
}
}
示例6: MergeAndDelete
public void MergeAndDelete(Event merge)
{
if (this.K == merge.K)
throw new DsiUserFriendlyException("Can't merge event into itself!");
Cambro.Web.Helpers.WriteAlertHeader();
//throw new Exception("This function isn't finished yet!");
Cambro.Web.Helpers.WriteAlert("Starting merge...", 1);
#region Articles
if (true)
{
Query q = new Query();
q.QueryCondition = new Q(Article.Columns.EventK, merge.K);
ArticleSet ars = new ArticleSet(q);
foreach (Article a in ars)
{
Cambro.Web.Helpers.WriteAlert("Merging article " + a.K + "...", 2);
a.ParentObjectK = this.K;
a.EventK = this.K;
if (a.Relevance <= Model.Entities.Article.RelevanceEnum.Venue)
a.VenueK = this.VenueK;
else
a.VenueK = 0;
if (a.Relevance <= Model.Entities.Article.RelevanceEnum.Place)
a.PlaceK = this.Venue.PlaceK;
else
a.PlaceK = 0;
if (a.Relevance <= Model.Entities.Article.RelevanceEnum.Country)
a.CountryK = this.Venue.Place.CountryK;
else
a.CountryK = 0;
a.UrlFragment = this.UrlFilterPartVenueDate;
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.EventK, this.K));
u.Changes.Add(new Assign(Thread.Columns.VenueK, this.VenueK));
u.Changes.Add(new Assign(Thread.Columns.PlaceK, this.Venue.PlaceK));
u.Changes.Add(new Assign(Thread.Columns.CountryK, this.Venue.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 merging articles...", 2);
}
#endregion
#region Banners
if (true)
{
Cambro.Web.Helpers.WriteAlert("Merging banners...", 4);
Update u = new Update();
u.Table = TablesEnum.Banner;
u.Where = new Q(Banner.Columns.EventK, merge.K);
u.Changes.Add(new Assign(Banner.Columns.EventK, this.K));
u.Run();
Cambro.Web.Helpers.WriteAlert("Done merging banners...", 4);
}
#endregion
#region Comp
if (true)
{
Cambro.Web.Helpers.WriteAlert("Merging competitions...", 5);
Update u = new Update();
u.Table = TablesEnum.Comp;
u.Where = new Q(Comp.Columns.EventK, merge.K);
//.........这里部分代码省略.........
示例7: AddEvent
public static Event AddEvent(
string name,
int venueK,
StartTimes? startTime,
DateTime date,
string shortDetails,
string safeLongDetails,
Guid? duplicateGuid,
int? capacity,
Usr usr,
int[] musicTypeKs,
int[] brandKs,
bool spotterRequest,
string spotterRequestName,
string spotterRequestNumber)
{
Event ev = new Event();
Venue venue = new Venue(venueK);
Transaction t = null;//new Transaction();
try
{
ev.AddedDateTime = DateTime.Now;
ev.VenueK = venue.K;
ev.Name = Cambro.Web.Helpers.StripHtml(name).Trim();
ev.StartTime = startTime ?? StartTimes.Evening;;
ev.DateTime = date;
ev.ShortDetailsHtml = Cambro.Misc.Utility.Snip(Cambro.Web.Helpers.StripHtml(shortDetails ?? ""), 500);
ev.LongDetailsHtml = safeLongDetails;
ev.DuplicateGuid = duplicateGuid ?? Guid.NewGuid();
ev.Capacity = capacity ?? venue.Capacity;
ev.AdminNote += "Event added by owner " + DateTime.Now.ToString();
ev.OwnerUsrK = Usr.Current.K;
ev.SpotterRequest = spotterRequest;
ev.SpotterRequestName = spotterRequestName;
ev.SpotterRequestNumber = spotterRequestNumber;
if (!usr.IsSuper)
{
ev.IsNew = true;
ev.ModeratorUsrK = Usr.GetEventModeratorUsrK();
}
ev.InitUrlFragment();
ev.Update(t);
foreach (int musicTypeK in musicTypeKs ?? new int[]{})
{
MusicType mt = new MusicType(musicTypeK);
EventMusicType emt = new EventMusicType();
emt.EventK = ev.K;
emt.MusicTypeK = mt.K;
emt.Update(t);
}
foreach (int brandK in brandKs ?? new int[] { })
{
EventBrand eb = new EventBrand();
eb.BrandK = brandK;
eb.EventK = ev.K;
eb.Update(t);
}
ev.UpdateMusicTypesString(t);
ev.Venue.UpdateTotalEvents(t);
ev.Owner.UpdateEventCount(t);
//t.Commit();
}
catch (Exception ex)
{
//t.Rollback();
ev.DeleteAll(null);
throw ex;
}
finally
{
//t.Close();
}
Mailer sm = new Mailer();
sm.TemplateType = Mailer.TemplateTypes.AnotherSiteUser;
sm.UsrRecipient = Usr.Current;
sm.To = Usr.Current.Email;
sm.Subject = "You've added an event!";
sm.Body += "<p>You've added an event to the DontStayIn events database.</p>";
sm.Body += "<p>Click the link below to view the event:</p>";
sm.Body += "<p><a href=\"[LOGIN(" + ev.Url() + ")]\">" + HttpUtility.HtmlEncode(ev.FriendlyName) + "</a></p>";
sm.Body += "<h2>Make changes</h2>";
sm.Body += "<p>You can make changes or corrections to the event details by clicking the link below:</p>";
sm.Body += "<p><a href=\"[LOGIN(/event-" + ev.K.ToString() + "/edit)]\">Edit your event</a></p>";
sm.Body += "<h2>How about a banner advert?</h2>";
sm.Body += "<p>You can add a banner advert to your event by using the link below:</p>";
//.........这里部分代码省略.........
示例8: WheresWork
public void WheresWork()
{
Venue venue = new Venue();
venue.Update();
List<Event> events = new List<Event>();
for (int i = 0; i < 10; i++)
{
Event ev = new Event();
ev.VenueK = venue.K;
ev.Update();
events.Add(ev);
}
Assert.AreEqual(0, venue.ChildEvents(new Q("1 = 0", null, null)).AllItems().Length);
Assert.AreEqual(0, venue.ChildEvents(new Q("1 = 0", null, null)).Page(1, 10).Length);
}