public EventAddress EditAddress(EventAddress _address, string id) { //updateAddress string response = null; string data = null; EventAddress newAdd = null; try { newAdd = new EventAddress(); DataContractJsonSerializer ser = new DataContractJsonSerializer( typeof(EventAddress)); MemoryStream mem = new MemoryStream(); ser.WriteObject(mem, _address); data = Encoding.UTF8.GetString(mem.ToArray(), 0, (int)mem.Length); WebClient webClient = new WebClient(); webClient.Headers["Content-type"] = "application/json"; webClient.Encoding = Encoding.UTF8; response = webClient.UploadString(BASE_URL + "updateAddress/" + id, "PUT", data); newAdd = JsonConvert.DeserializeObject <EventAddress>(response); return(newAdd); } catch { return(null); } }
// todo (dcrenna): remove this as soon as distributed caching is available public IPageOfItems <ScheduleItem> GetScheduleItemsUncachedByUser(EventAddress eventAddress, ScheduleItemFilterCriteria scheduleItemFilterCriteria) { int pageIndex = 0; int pageSize = 50; if (context.RequestDataFormat == RequestDataFormat.Web) { pageIndex = scheduleItemFilterCriteria.PageIndex; pageSize = scheduleItemFilterCriteria.PageSize; } var cacheKey = string.Format("GetScheduleItems-FilterCriteria:{0}", scheduleItemFilterCriteria); var authenticatedUser = context.User.IsAuthenticated && context.User.Cast <UserAuthenticated>() != null; var userId = Guid.Empty; if (authenticatedUser) { userId = context.User.Cast <UserAuthenticated>().ID; cacheKey += String.Concat("-UserID:", userId); } var items = repository.GetScheduleItems(eventAddress, userId, scheduleItemFilterCriteria);//.OrderBy(si => si.Start); var scheduleItems = items.GetPage(pageIndex, pageSize).FillTags(tagService); if (context.RequestDataFormat.IsFeed()) { scheduleItems = scheduleItems.Since(si => si.Modified, context.HttpContext.Request.IfModifiedSince()); } SetScheduleItemUsers(scheduleItems); return(scheduleItems); }
/// <summary> /// Emits an event on the provided address. /// </summary> /// <param name="addr">The event address.</param> /// <param name="data">The event data.</param> /// <exception cref="FormatException">If the event address is invalid.</exception> /// <returns></returns> public async Task EmitAsync(EventAddress addr, object data) { // check if not declared bool declared = false; lock (_declaredEventNamespaces) { declared = _declaredEventNamespaces.Contains(addr.Namespace); } if (!declared) { await DeclareEventAsync(addr).ConfigureAwait(false); } // serialize data payload Event e = new Event(addr.Resource, addr.Name); e.Serialize(data); // serialize ProtobufEventSerializer serializer = new ProtobufEventSerializer(); byte[] body = serializer.SerializeEvent(e); // send event try { await _broker.SendAsync(string.Format("!{0}", addr.Namespace), addr.Name, body, new Dictionary <string, object>() { { EventHeader.HEADER_NAME, new EventHeader(EventHeader.HEADER_VERSION, serializer.Name).ToString() } }, null, null, false).ConfigureAwait(false); } catch (Exception) { } }
public EventAddress getAddressByEventId(string eventid) { int _id = Convert.ToInt32(eventid); try { using (EventrixDBDataContext db = new EventrixDBDataContext()) { Address _address = (from _event in db.MAIN_EVENTs where _event.E_ID.Equals(_id) join add in db.Addresses on _event.AD_Id equals add.AD_Id select add).First(); EventAddress foundAddress = new EventAddress(); foundAddress.ID = _address.AD_Id; foundAddress.STREET = _address.AD_StreetName; foundAddress.CITY = _address.AD_City; foundAddress.PROVINCE = _address.AD_Province; foundAddress.COUNTRY = _address.AD_Country; return(foundAddress); } } catch (Exception) { return(null); } }
public bool EditAddress(int ID) { string strStreet = ""; string strCity = ""; string strProvince = ""; string strCountry = ""; //Validate inputs if (!txtStreet.Text.Equals("")) { strStreet = txtStreet.Text; } if (!txtCity.Text.Equals("")) { strCity = txtCity.Text; } if (!txtProvince.Text.Equals("")) { strProvince = txtProvince.Text; } if (!txtCountry.Text.Equals("")) { strCountry = txtCountry.Text; } EventAddress add = new EventAddress(); add.STREET = strStreet; add.CITY = strCity; add.PROVINCE = strProvince; add.COUNTRY = strCountry; MappingClient mapp = new MappingClient(); EventAddress addID = mapp.EditAddress(add, Convert.ToString(ID)); return(true); }
/// <summary> /// Declares the event, creating the namespace and storing the type for future reference. /// </summary> /// <param name="addr">The event address.</param> /// <note>Currently the only behaviour is to declare the namespace.</note> /// <returns></returns> /// <exception cref="FormatException">If the event address is invalid.</exception> private async Task DeclareEventAsync(EventAddress addr) { // check if already declared lock (_declaredEventNamespaces) { if (_declaredEventNamespaces.Contains(addr.Namespace)) { return; } } // declare exchange int retries = 3; while (retries > 0) { try { await _broker.DeclareExchange(string.Format("!{0}", addr.Namespace), "topic", false, false).ConfigureAwait(false); break; } catch (Exception) { retries--; await Task.Delay(1000).ConfigureAwait(false); } } if (retries == 0) { return; } // add to list lock (_declaredEventNamespaces) { _declaredEventNamespaces.Add(addr.Namespace); } }
public ActionResult Edit(EventAddress eventAddress, string exhibitorSlug) { var userAuthenticated = userService.GetUser(User.Identity.Name); if (userAuthenticated == null || !userAuthenticated.IsInRole("Admin")) { return(null); } var slug = exhibitorSlug.CleanSlug(); Exhibitor exhibitor; if (slug.Equals("New")) { exhibitor = new Exhibitor(Guid.Empty); } else { var exhibitorFilterCriteria = new ExhibitorFilterCriteria { Term = slug }; var result = exhibitorService.GetExhibitors(eventAddress, exhibitorFilterCriteria); exhibitor = result.SingleOrDefault(); } if (exhibitor == null) { return(null); } return(View(new OxiteViewModelItem <Exhibitor>(exhibitor))); }
/// <summary> /// Emits an event on the provided address. /// </summary> /// <param name="addr">The event address.</param> /// <param name="data">The event data.</param> /// <exception cref="FormatException">If the event address is invalid.</exception> /// <returns></returns> public Task EmitAsync(EventAddress addr, object data) { // get namespace Namespace @namespace = GetNamespace(addr.Namespace); return(@namespace.EmitAsync(addr, data)); }
/// <summary> /// Subscribes to events matching the provided name. /// </summary> /// <param name="addr">The event address.</param> /// <returns>The subscription.</returns> public Task <EventSubscription> SubscribeAsync(EventAddress addr) { // get namespace Namespace @namespace = GetNamespace(addr.Namespace); return(@namespace.SubscribeAsync(addr)); }
public ActionResult Remove(EventAddress eventAddress, string exhibitorSlug) { var userAuthenticated = userService.GetUser(User.Identity.Name); if (userAuthenticated == null || !userAuthenticated.IsInRole("Admin")) { return(null); } if (eventAddress == null) { return(null); } var exhibitor = exhibitorService.GetExhibitor(eventAddress, exhibitorSlug.CleanSlug()); if (exhibitor == null) { return(null); } exhibitorService.RemoveExhibitor(eventAddress, exhibitor); return(new RedirectResult(Url.ManageExhibitors())); }
public IPageOfItems <Exhibitor> GetExhibitors(EventAddress eventAddress, ExhibitorFilterCriteria exhibitorFilterCriteria) { var pageIndex = 0; var pageSize = 50; if (context.RequestDataFormat == RequestDataFormat.Web) { pageIndex = exhibitorFilterCriteria.PageIndex; pageSize = exhibitorFilterCriteria.PageSize; } var varyBy = string.Join(",", exhibitorFilterCriteria.ParticipantLevels.ToArray()).Trim(); if (!string.IsNullOrEmpty(exhibitorFilterCriteria.Term)) { varyBy = exhibitorFilterCriteria.Term.Trim(); } return (cache.GetItems <IPageOfItems <Exhibitor>, Exhibitor>( string.Format("GetExhibitors-Event:{0}-{1}", eventAddress != null ? eventAddress.EventName ?? "" : "", varyBy), new CachePartition(pageIndex, pageSize), () => repository.GetExhibitors(eventAddress, exhibitorFilterCriteria).GetPage(pageIndex, pageSize), e => e.GetDependencies() )); }
public ActionResult Schedule(int pageIndex, int pageSize, EventAddress eventAddress, string userName) { var scheduleUser = userService.GetUser(userName); if (scheduleUser == null) { // No user found return(null); } var userID = scheduleUser.ID; var user = context.User != null?context.User.Cast <UserAuthenticated>() : null; var userScheduleIsPublic = userScheduleService.IsUserSchedulePublic(userID); var showSchedule = user != null ? context.User.Name.Equals(userName) ? true : userScheduleIsPublic : userScheduleIsPublic; var scheduleItems = showSchedule ? scheduleItemService.GetScheduleItemsByUser(pageIndex, pageSize, eventAddress, userID) : new PageOfItems <ScheduleItem>(new List <ScheduleItem>(0), 0, 0, 0); ViewData["UserDisplayName"] = scheduleUser.DisplayName; ViewData["UserScheduleIsPublic"] = userScheduleIsPublic; return(View(new OxiteViewModelItems <ScheduleItem>(scheduleItems))); }
public int getAddressID() { string strStreet = ""; string strCity = ""; string strProvince = ""; string strCountry = ""; //Validate inputs if (!txtStreet.Text.Equals("")) { strStreet = txtStreet.Text; } if (!txtCity.Text.Equals("")) { strCity = txtCity.Text; } if (!txtProvince.Text.Equals("")) { strProvince = txtProvince.Text; } if (!txtCountry.Text.Equals("")) { strCountry = txtCountry.Text; } EventAddress add = new EventAddress(); add.STREET = strStreet; add.CITY = strCity; add.PROVINCE = strProvince; add.COUNTRY = strCountry; MappingClient mapp = new MappingClient(); int addID = mapp.createAddress(add); return(addID); }
public OxiteViewModelItems <ScheduleItem> ListByDateRangeAndUser(EventAddress eventAddress, DateRangeAddress dateRangeAddress) { Event evnt = eventService.GetEvent(eventAddress); if (evnt == null) { return(null); } var userAuthenticated = userService.GetUser(currentUser.Name); if (userAuthenticated == null) { return(null); } var userID = userAuthenticated.ID; IEnumerable <ScheduleItem> scheduleItems = scheduleItemService.GetScheduleItemsByTimeSlotAndUser(eventAddress, dateRangeAddress, userID); return(new OxiteViewModelItems <ScheduleItem>(scheduleItems) { Container = evnt }); }
public IQueryable <ScheduleItem> GetScheduleItemsByTag(EventAddress eventAddress, Guid userID, Guid tagID, ScheduleItemFilterCriteria scheduleItemFilterCriteria) { var query = getScheduleItems(eventAddress, userID, scheduleItemFilterCriteria) .Where(si => si.oxite_Conferences_ScheduleItemTagRelationships.Any(sitr => sitr.TagID == tagID)); return(projectScheduleItems(query)); }
public IEnumerable <ScheduleItem> GetScheduleItemsByTimeSlotAndUser(EventAddress address, DateRangeAddress rangeAddress, Guid userID) { // if this is cached, you'll see schedule items on your list that used to be on the list but aren't anymore var result = repository.GetScheduleItemsByTimeSlotAndUser(address, rangeAddress, userID).FillTags(tagService); SetScheduleItemUsers(result); return(result); }
public IQueryable <ScheduleItemTag> GetScheduleItemTags(EventAddress eventAddress) { return (from sitr in context.oxite_Conferences_ScheduleItemTagRelationships join si in context.oxite_Conferences_ScheduleItems on sitr.ScheduleItemID equals si.ScheduleItemID join e in context.oxite_Conferences_Events on si.EventID equals e.EventID group si by new { TagID = sitr.TagID, TagDisplayName = sitr.TagDisplayName, Evnt = e } into results where string.Compare(results.Key.Evnt.EventName, eventAddress.EventName, true) == 0 select new ScheduleItemTag(results.Key.TagID, results.Key.TagDisplayName)); }
public IQueryable <ScheduleItem> GetScheduleItemsByTimeSlot(EventAddress eventAddress, Oxite.Modules.Conferences.Models.DateRangeAddress dateRangeAddress) { var query = from si in context.oxite_Conferences_ScheduleItems join e in context.oxite_Conferences_Events on si.EventID equals e.EventID where string.Compare(e.EventName, eventAddress.EventName, true) == 0 && si.StartTime >= dateRangeAddress.StartDate && si.EndTime <= dateRangeAddress.EndDate select si; return(projectScheduleItems(query)); }
public IQueryable <ScheduleItem> GetScheduleItems(EventAddress eventAddress, string type) { var query = from si in context.oxite_Conferences_ScheduleItems join e in context.oxite_Conferences_Events on si.EventID equals e.EventID where string.Compare(e.EventName, eventAddress.EventName, true) == 0 && string.Compare(si.Type, type, true) == 0 select si; return(projectScheduleItems(query)); }
public IActionResult Add() { List <EventCategory> categories = context.Categories.ToList(); EventAddress eventAddress = new EventAddress(); AddEventViewModel addEventViewModel = new AddEventViewModel(categories, eventAddress); return(View(addEventViewModel)); }
public void RemoveExhibitor(EventAddress eventAddress, Exhibitor exhibitor) { using (var transaction = new TransactionScope()) { repository.RemoveExhibitor(eventAddress, exhibitor); transaction.Complete(); } cache.InvalidateItem(exhibitor); }
public static AddressResponse ToResponse(this EventAddress entity) { return(new AddressResponse { City = entity.City, PostalCode = entity.PostalCode, Street = entity.Street, BuildingNumber = entity.BuildingNumber, LocalNumber = entity.LocalNumber }); }
public IEnumerable <Exhibitor> GetExhibitors(EventAddress eventAddress) { return (cache.GetItems <IEnumerable <Exhibitor>, Exhibitor>( string.Format("GetExhibitors-Event:{0}", eventAddress != null ? eventAddress.EventName ?? "" : ""), () => repository.GetExhibitors(eventAddress, null), e => e.GetDependencies() )); }
public IEnumerable <ScheduleItemTag> GetScheduleItemTags(EventAddress eventAddress) { var result = cache.GetItems <IEnumerable <ScheduleItemTag>, ScheduleItemTag>( string.Format("GetScheduleItemTags-Event:{0}", eventAddress.EventName), () => repository.GetScheduleItemTags(eventAddress).ToList().AsEnumerable().FillTags(tagService), null ); return(result); }
public IQueryable <ScheduleItem> GetScheduleItemsBySpeaker(EventAddress eventAddress, string name) { var query = from si in context.oxite_Conferences_ScheduleItems join sis in context.oxite_Conferences_ScheduleItemSpeakerRelationships on si.ScheduleItemID equals sis.ScheduleItemID join s in context.oxite_Conferences_Speakers on sis.SpeakerID equals s.SpeakerID join e in context.oxite_Conferences_Events on si.EventID equals e.EventID where string.Compare(e.EventName, eventAddress.EventName, true) == 0 && string.Compare(s.SpeakerName, name, true) == 0 select si; return(projectScheduleItems(query)); }
public Exhibitor GetExhibitor(EventAddress eventAddress, string name) { var exhibitorFilterCriteria = new ExhibitorFilterCriteria { Term = name }; var exhibitor = repository.GetExhibitors(eventAddress, exhibitorFilterCriteria) .FirstOrDefault(); return(exhibitor); }
public IQueryable <ScheduleItem> GetScheduleItemsByUser(EventAddress eventAddress, Guid userID) { var query = from siur in context.oxite_Conferences_ScheduleItemUserRelationships join si in context.oxite_Conferences_ScheduleItems on siur.ScheduleItemID equals si.ScheduleItemID join e in context.oxite_Conferences_Events on si.EventID equals e.EventID where string.Compare(e.EventName, eventAddress.EventName, true) == 0 where siur.UserID.Equals(userID) orderby si.StartTime select si; return(projectScheduleItems(query)); }
public IEnumerable <ScheduleItem> GetScheduleItemsByTimeSlot(EventAddress eventAddress, DateRangeAddress dateRangeAddress) { var result = cache.GetItems <IEnumerable <ScheduleItem>, ScheduleItem>( string.Format("GetScheduleItems-Event:{0},Start:{1},End:{2}", eventAddress.EventName, dateRangeAddress.StartDate.ToStringForFeed(), dateRangeAddress.EndDate.ToStringForFeed()), () => repository.GetScheduleItemsByTimeSlot(eventAddress, dateRangeAddress).FillTags(tagService).ToList(), si => si.GetDependencies() ); SetScheduleItemUsers(result); return(result); }
public OxiteViewModelItems <ScheduleItem> Summary(EventAddress eventAddress) { if (!_context.User.IsInRole("Admin")) { return(new OxiteViewModelItems <ScheduleItem>()); } var criteria = new ScheduleItemFilterCriteria { PageIndex = 0, PageSize = 1000000 }; var sessions = _scheduleItemService.GetScheduleItemsUncached(eventAddress, criteria); return(new OxiteViewModelItems <ScheduleItem>(sessions)); }
public IPageOfItems <ScheduleItem> GetScheduleItemsByTag(EventAddress eventAddress, Guid tagID, ScheduleItemFilterCriteria scheduleItemFilterCriteria) { var result = cache.GetItems <IPageOfItems <ScheduleItem>, ScheduleItem>( string.Format("GetScheduleItems-Event:{0},Tag:{1:N},FilterCriteria:{2}", eventAddress.EventName, tagID, scheduleItemFilterCriteria), new CachePartition(scheduleItemFilterCriteria.PageIndex, scheduleItemFilterCriteria.PageSize), () => repository.GetScheduleItemsByTag(eventAddress, context.User.IsAuthenticated && context.User.Cast <UserAuthenticated>() != null ? context.User.Cast <UserAuthenticated>().ID : Guid.Empty, tagID, scheduleItemFilterCriteria).GetPage(scheduleItemFilterCriteria.PageIndex, scheduleItemFilterCriteria.PageSize).FillTags(tagService), si => si.GetDependencies() ); SetScheduleItemUsers(result); return(result); }