示例#1
0
        // [ValidateAntiForgeryToken]
        public async Task <IActionResult> Edit(int id, [Bind("Lat,Long,IsLunarLocation,ContactDetail,ID,LocationName,BuildingNO,StreetAddress,Locality,Region,PostCode,CountryCode")] EventLocation eventLocation)
        {
            if (id != eventLocation.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(eventLocation);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EventLocationExists(eventLocation.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(eventLocation));
        }
        public async Task StatusLoadAndSafe_HappyPath(PersistenceLayerProvider layerProvider)
        {
            var statusRepository = layerProvider.StatusRepository;

            List <EventsPublishedByService> services = new List <EventsPublishedByService> {
                EventsPublishedByService.Reachable(new ServiceEndPoint(new Uri("http://service1.de"), "Name1"), new []
                {
                    new EventSchema("Event1"),
                    new EventSchema("Event2"),
                    new EventSchema("Event3")
                })
            };
            var subscribedEventCollection = new EventsSubscribedByService(
                new []
            {
                new EventSchema("Event1"),
                new EventSchema("Event2")
            },
                new [] { new ReadModelSubscription("Rm1", new EventSchema("Event3")) });
            var eventLocation = new EventLocation(services, subscribedEventCollection);

            await statusRepository.SaveEventLocation(eventLocation);

            var location = await statusRepository.GetEventLocation();

            var microwaveServiceNodes = location.Services.ToList();

            Assert.IsNotNull(microwaveServiceNodes);
            Assert.AreEqual(1, microwaveServiceNodes.Count);
            Assert.AreEqual(2, microwaveServiceNodes[0].SubscribedEvents.Count());
            Assert.AreEqual(1, microwaveServiceNodes[0].ReadModels.Count());
            Assert.IsTrue(!location.UnresolvedEventSubscriptions.Any());
            Assert.IsTrue(!location.UnresolvedReadModeSubscriptions.Any());
        }
        public async Task StatusLoadAndSafe_OneUnresolvedReadModel(PersistenceLayerProvider layerProvider)
        {
            var statusRepository = layerProvider.StatusRepository;

            List <EventsPublishedByService> services = new List <EventsPublishedByService> {
                EventsPublishedByService.Reachable(new ServiceEndPoint(new Uri("http://service1.de"), "Name1"), new []
                {
                    new EventSchema("Event1"),
                    new EventSchema("Event2")
                })
            };
            var subscribedEventCollection = new EventsSubscribedByService(
                new []
            {
                new EventSchema("Event1"),
                new EventSchema("Event2")
            },
                new [] { new ReadModelSubscription("Rm1", new EventSchema("Event3")) });
            var eventLocation = new EventLocation(services, subscribedEventCollection);

            await statusRepository.SaveEventLocation(eventLocation);

            await statusRepository.SaveEventLocation(eventLocation);

            var location = await statusRepository.GetEventLocation();

            Assert.AreEqual("Rm1", location.UnresolvedReadModeSubscriptions.Single().ReadModelName);
            Assert.AreEqual("Event3", location.UnresolvedReadModeSubscriptions.Single().GetsCreatedOn.Name);
            Assert.IsTrue(!location.UnresolvedEventSubscriptions.Any());
        }
        public static EventLocation CreateLocation(EventLocation location, int creator)
        {
            var db = ApplicationContext.Current.DatabaseContext.Database;

            var args = new LocationCreatingEventArgs {
                Location = location
            };

            OnCreating(args);

            if (args.Cancel)
            {
                return(location);
            }

            db.Save(location);

            //Update usersettings and add the newly created calendar to the allowed calendar
            SecurityService.AddLocationToUser(creator, location.Id);

            var args2 = new LocationCreatedEventArgs {
                Location = location
            };

            OnCreated(args2);

            return(location);
        }
示例#5
0
    private static List <EventLocation> GetEventLocation()
    {
        List <EventLocation> locationList = new List <EventLocation>();

#if UNITY_EDITOR
        StackTrace   stackTrace  = new StackTrace(true);    // get call stack
        StackFrame[] stackFrames = stackTrace.GetFrames();  // get method calls (frames)

        // TODO: should move to log window?
        int i = 0;
        foreach (StackFrame stackFrame in stackFrames)
        {
            if (i >= 2)
            {
                string filepath = stackFrame.GetFileName();
                if (filepath == null || filepath.Contains("EventLogger.cs"))
                {
                    continue;
                }

                System.Reflection.MethodBase methodBase = stackFrame.GetMethod();

                EventLocation location = new EventLocation();
                //location.method += methodBase.DeclaringType.Name + ":" + methodBase.Name;
                location.method   = string.Format("{0}:{1}", methodBase.DeclaringType.Name, methodBase.Name);
                location.filepath = stackFrame.GetFileName();
                location.line     = stackFrame.GetFileLineNumber();
                locationList.Add(location);
            }
            i++;
        }
#endif // UNITY_EDITOR
        return(locationList);
    }
示例#6
0
        /// <summary>
        /// Load background image, connect to the database and fill comboboxes
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void frmOrganizeEvent_Load(object sender, EventArgs e)
        {
            this.BackgroundImage = global::AuntRosieApplication.Properties.Resources.background2;
            String DatabasePath = System.IO.Directory.GetCurrentDirectory();
            int    x            = DatabasePath.IndexOf("bin");

            DatabasePath = DatabasePath.Substring(0, x - 1);
            String conStr = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=" + DatabasePath +
                            @"\AuntRosieDB.mdf;Integrated Security=True;Connect Timeout=30";
            DBConnector conn = new DBConnector(conStr);

            RosieEntity.Connector = conn;

            foreach (EventLocation location in EventLocation.GetLocations())
            {
                cmbLocations.Items.Add(location);
            }

            if (cmbLocations.Items.Count > 0)
            {
                cmbLocations.SelectedIndex = 0;
            }

            foreach (KeyValuePair <string, EventType> item in types)
            {
                cmbTypes.Items.Add(item);
            }
            dgEvents.DataSource = eventSource;
            addDeleteButtonToGrid();
            cmbTypes.SelectedIndex = 0;
            cmbTypes.DisplayMember = "Key";
        }
        public async Task <IActionResult> Edit(int id, [Bind("EventId,LocationId")] EventLocation eventLocation)
        {
            if (id != eventLocation.EventId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(eventLocation);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EventLocationExists(eventLocation.EventId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EventId"]    = new SelectList(_context.Events, "EventId", "EventId", eventLocation.EventId);
            ViewData["LocationId"] = new SelectList(_context.Locations, "LocationId", "LocationId", eventLocation.LocationId);
            return(View(eventLocation));
        }
        private void Boom(IEnumerable <TimeEventAppointment> appts, Event e, EventCreator eventCreator, IEnumerable <Event> patternExceptionEvents)
        {
            _session.BeginTransaction();

            foreach (var newEvent in appts.Select(a => eventCreator.CreateEvent(a, e)))
            {
                foreach (var el in e.EventLocations)
                {
                    var newEl = new EventLocation(_session)
                    {
                        Event    = newEvent,
                        Location = el.Location
                    };
                    newEl.Save();

                    foreach (var newLe in el.Educators.Select(le => new LocationEducator(_session)
                    {
                        Educator = le.Educator,
                        EducatorEmployment = le.EducatorEmployment,
                        EventLocation = newEl
                    }))
                    {
                        newLe.Save();
                    }
                }
            }
            _session.Delete(patternExceptionEvents);
            _session.Save(patternExceptionEvents);
            e.Delete();
            _session.CommitTransaction();
        }
示例#9
0
        private async Task <int> GetEventLocationId(int id, EventLocation eventLocation)
        {
            if (id > default(int))
            {
                return(id);
            }

            if (eventLocation.Id > default(int))
            {
                return(eventLocation.Id);
            }

            // Load the event location by address and suburb if we do not have an Id
            var location = await _eventLocationRepository.First(el => el.Address.Equals(eventLocation.Address) && el.Suburb.Equals(eventLocation.Suburb));

            if (location != null)
            {
                return(location.Id);
            }
            else
            {
                // If it does not exist, then create a new location
                await _eventLocationRepository.Add(eventLocation);

                return(eventLocation.Id);
            }
        }
        public void SubscribedEventPropertiesArePropertiesOfConsumingService()
        {
            var eventLocation = new EventLocation(
                new List <EventsPublishedByService>
            {
                EventsPublishedByService.Reachable(
                    new ServiceEndPoint(new Uri("http://jeah.de")), new []
                {
                    new EventSchema("Event2",
                                    new [] { new PropertyType("VorName", "String"),
                                             new PropertyType("LastName", "Int") })
                })
            },
                new EventsSubscribedByService(
                    new List <EventSchema> {
                new EventSchema("Event2", new [] { new PropertyType("VorName", "String"), })
            },
                    new [] { new ReadModelSubscription("ReadModel2", new EventSchema("Event1")) }));

            var serviceAfter2 = eventLocation.GetServiceForEvent(typeof(Event2));

            Assert.AreEqual(nameof(Event2), serviceAfter2.SubscribedEvents.Single().Name);
            Assert.AreEqual("VorName", serviceAfter2.SubscribedEvents.Single().Properties.Single().Name);
            Assert.AreEqual("String", serviceAfter2.SubscribedEvents.Single().Properties.Single().Type);
        }
示例#11
0
        public bool Delete()
        {
            //Code that will execute when deleting
            EventLocation c = this._db.SingleOrDefault <EventLocation>(ParentID);

            this._db.Delete(c);
            return(true);
        }
 private void CopyAndMarshal(ref EventParameters pEventParams)
 {
     CommandID         = pEventParams.Params.CommandID;
     CommandName       = Marshal.PtrToStringUni(pEventParams.Params.CommandName);       //PCWStr
     ParentCommandID   = pEventParams.Params.ParentCommandID;
     ParentCommandName = Marshal.PtrToStringUni(pEventParams.Params.ParentCommandName); //PCWStr
     SelectionIndex    = pEventParams.Params.SelectionIndex;
     Location          = pEventParams.Params.Location;
 }
        private string GetLocationDisplayName(EventLocation eventLocation)
        {
            string displayName = eventLocation.Location.GetDisplayName2ByLanguage(language);

            if (language == LanguageCode.English && String.IsNullOrEmpty(displayName))
            {
                displayName = eventLocation.Location.GetDisplayName2ByLanguage(LanguageCode.Russian);
            }
            return(displayName);
        }
        public async Task <EventLocation> Add(EventLocation viewModel)
        {
            var model = _mapper.Map <EventLocationEntity>(viewModel);

            _context.EventLocations.Add(model);
            await _context.SaveChangesAsync();

            _mapper.Map(model, viewModel);
            return(viewModel);
        }
        public ActionResult GetEventDetails(int id, int type = 0)
        {
            EventLocation     l   = null;
            EventDetailsModel evm = null;

            if (type == 0)
            {
                CalendarEntry e = ApplicationContext.DatabaseContext.Database.Single <CalendarEntry>("SELECT * FROM ec_events WHERE id=@0", id);
                if (e.locationId != 0)
                {
                    l = ApplicationContext.DatabaseContext.Database.Single <EventLocation>("SELECT * FROM ec_locations WHERE id = @0", e.locationId);
                }
                evm = new EventDetailsModel()
                {
                    Title       = e.title,
                    Description = e.description,
                    LocationId  = e.locationId,
                    Location    = l
                };
                if (null != e.start)
                {
                    evm.StartDate = ((DateTime)e.start).ToString("F", CultureInfo.CurrentCulture);
                }
                if (null != e.end)
                {
                    evm.EndDate = ((DateTime)e.end).ToString("F", CultureInfo.CurrentCulture);
                }
            }
            else if (type == 1)
            {
                RecurringEvent e = ApplicationContext.DatabaseContext.Database.Single <RecurringEvent>("SELECT * FROM ec_recevents WHERE id=@0", id);
                if (e.locationId != 0)
                {
                    l = ApplicationContext.DatabaseContext.Database.Single <EventLocation>("SELECT * FROM ec_locations WHERE id = @0", e.locationId);
                }
                Schedule schedule = new Schedule(new Event()
                {
                    Title                  = e.title,
                    DaysOfWeekOptions      = (DayOfWeekEnum)e.day,
                    FrequencyTypeOptions   = (FrequencyTypeEnum)e.frequency,
                    MonthlyIntervalOptions = (MonthlyIntervalEnum)e.monthly_interval
                });

                evm = new EventDetailsModel()
                {
                    Title       = e.title,
                    Description = e.description,
                    LocationId  = e.locationId,
                    Location    = l,
                    StartDate   = ((DateTime)schedule.NextOccurrence(DateTime.Now)).ToString("F", CultureInfo.CurrentCulture)
                };
            }

            return(PartialView("EventDetails", evm));
        }
示例#16
0
        private static void GenEvents(int nRecords)
        {
            List <EventLocation> locations = EventLocation.GetLocations();
            DateTime             lastDate  = DateTime.Now.AddDays(1);

            foreach (EventLocation location in locations)
            {
                lastDate = GenEvent(nRecords, location, lastDate);
            }
            //Faker.Company.Name()
        }
示例#17
0
 private void cmbEventName_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (cmbEventName.SelectedItem != null)
     {
         DBConnector conn = new DBConnector(Classes.DBMethod.GetConnectionString());
         RosieEntity.Connector = conn;
         RosieEvent    rosieEvent = RosieEvent.Retrieve(long.Parse(DBMethod.GetSelectedItemID(cmbEventName)));
         EventLocation locEvent   = EventLocation.Retrieve(rosieEvent.LocationId);
         lblEventLocation.Text += locEvent.Address.ToString();
     }
 }
示例#18
0
        // [ValidateAntiForgeryToken]
        public async Task <IActionResult> Create([Bind("Lat,Long,IsLunarLocation,ContactDetail,ID,LocationName,BuildingNO,StreetAddress,Locality,Region,PostCode,CountryCode")] EventLocation eventLocation)
        {
            if (ModelState.IsValid)
            {
                _context.Add(eventLocation);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(eventLocation));
        }
 public EventLocation PostSave(EventLocation location)
 {
     if (location.Id > 0)
     {
         return(LocationService.UpdateLocation(location));
     }
     else
     {
         return(LocationService.CreateLocation(location, Security.GetUserId()));
     }
 }
 public ActionResult EditLocation(EventLocation el)
 {
     if (!ModelState.IsValid)
     {
         TempData["StatusEditLocation"] = "Invalid";
         return(View(el));
     }
     TempData["StatusEditLocation"] = "Valid";
     this._db.Update(el);
     return(View(el));
 }
示例#21
0
 /// <summary>
 /// Load event into form
 /// </summary>
 /// <param name="ev"></param>
 private void loadEvent(RosieEvent ev)
 {
     if (ev != null)
     {
         txtEventName.Text = ev.Name;
         EventLocation locToBeSelected = findEquivalentInCombobox(ev.EventLocation);
         if (locToBeSelected != null)
         {
             cmbLocations.SelectedItem = locToBeSelected;
         }
     }
 }
示例#22
0
        /// <summary>
        /// Find equivalent location in the location combobox
        /// </summary>
        /// <param name="loc"></param>
        /// <returns></returns>

        private EventLocation findEquivalentInCombobox(EventLocation loc)
        {
            foreach (EventLocation cmbLoc in cmbLocations.Items)
            {
                if (cmbLoc.ToString() == loc.ToString())
                {
                    return(cmbLoc);
                }
            }

            return(null);
        }
 /// <summary>
 /// Add/ edit event locations
 /// </summary>
 /// <param name="location"></param>
 /// <returns></returns>
 public int AddEventLocation(EventLocation location)
 {
     var context = new dbDataContext();
     var loc = context.tbl_EventLocations.FirstOrDefault(t => t.EventLocationId == location.EventLocationId) ?? new tbl_EventLocation();
     loc.Active = true;
     loc.EventLocation = location.Location;
     if (loc.EventLocationId <= 0)
     {
         context.tbl_EventLocations.InsertOnSubmit(loc);
     }
     context.SubmitChanges();
     return loc.EventLocationId;
 }
        public async Task <IActionResult> Create([Bind("EventId,LocationId")] EventLocation eventLocation)
        {
            if (ModelState.IsValid)
            {
                _context.Add(eventLocation);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EventId"]    = new SelectList(_context.Events, "EventId", "EventId", eventLocation.EventId);
            ViewData["LocationId"] = new SelectList(_context.Locations, "LocationId", "LocationId", eventLocation.LocationId);
            return(View(eventLocation));
        }
示例#25
0
        public async Task <EventLocation> GetEventLocation()
        {
            if (_cache.HasValue)
            {
                return(_cache.GetValue());
            }
            var mongoCollection = _database.GetCollection <EventLocationDbo>(StatusDbName);
            var location        = await mongoCollection.FindSync(e => e.Id == nameof(EventLocation)).SingleOrDefaultAsync();

            return(location == null?EventLocation.Default() : new EventLocation(location.Services.Select(s =>
                                                                                                         MicrowaveServiceNode.Create(s.ServiceEndPoint, s.SubscribedEvents, s.ReadModels)), location
                                                                                .UnresolvedEventSubscriptions, location.UnresolvedReadModeSubscriptions));
        }
        public Event(JsonObject jsonObject)
        {
            Id          = jsonObject.Get <int> ("id");
            DisplayName = jsonObject.Get <String> ("displayName");
            Type        = jsonObject.Get <String> ("type");
            Popularity  = jsonObject.Get <Double> ("popularity");
            Uri         = jsonObject.Get <String> ("uri");
            Location    = new EventLocation(jsonObject.Get <JsonObject> ("location"));

            var start = jsonObject.Get <JsonObject> ("start");

            StartDateTime = GetDateTime(start.Get <String> ("date"), start.Get <String> ("time"));
        }
示例#27
0
        private static void Boom(IEnumerable <TimeEventAppointment> appts, NormalEventCreator normalEventCreator, SchedulerStorage storage)
        {
            _session.BeginTransaction();

            var timeEventAppointments = appts as TimeEventAppointment[] ?? appts.ToArray();

            foreach (var appt in timeEventAppointments)
            {
                Event e;
                if (appt.Type == AppointmentType.Occurrence)
                {
                    e = appt.RecurrencePattern.GetSourceObject(storage) as Event;
                }
                else
                {
                    e = appt.GetSourceObject(storage) as Event;
                    if (e == null)
                    {
                        Console.WriteLine($"Не найден исходный объект события. Тип: {appt.Type}");
                        continue;
                    }
                }
                var newEvent = normalEventCreator.CreateEvent(appt, e);
                foreach (var el in e.EventLocations)
                {
                    var newEl = new EventLocation(_session)
                    {
                        Event    = newEvent,
                        Location = el.Location
                    };
                    newEl.Save();

                    foreach (var newLe in el.Educators.Select(le => new LocationEducator(_session)
                    {
                        Educator = le.Educator,
                        EducatorEmployment = le.EducatorEmployment,
                        EventLocation = newEl
                    }))
                    {
                        newLe.Save();
                    }
                }
            }
            _session.CommitTransaction();
            if (timeEventAppointments.Length > 0)
            {
                Console.WriteLine($"{timeEventAppointments.Length} Normals added");
            }
            GC.Collect();
        }
示例#28
0
        public ServiceResult Save(EventLocation geo)
        {
            if (geo == null)
            {
                return(ServiceResponse.Error("No location information sent."));
            }

            EventLocation dbLocation = null;

            using (var context = new GreenWerxDbContext(this._connectionKey))
            {
                if (!string.IsNullOrWhiteSpace(geo.UUID))
                {
                    var tmp = this.GetEventLocation(geo.UUID);
                    if (tmp.Code != 200)
                    {
                        return(tmp);
                    }

                    dbLocation = (EventLocation)tmp.Result;
                }
                else
                {
                    geo.UUID = Guid.NewGuid().ToString("N");
                }

                geo.Name = geo.Name.Trim();
                if (dbLocation == null)
                {
                    return(InsertEventLocation(geo));
                }
            }

            // geo = ObjectHelper.Merge<EventLocation>(dbLocation, geo);
            dbLocation.Name        = geo.Name.Trim();
            dbLocation.Country     = geo.Country;
            dbLocation.Postal      = geo.Postal;
            dbLocation.State       = geo.State;
            dbLocation.City        = geo.City;
            dbLocation.Longitude   = geo.Longitude;
            dbLocation.Latitude    = geo.Latitude;
            dbLocation.isDefault   = geo.isDefault;
            dbLocation.Description = geo.Description;
            dbLocation.Category    = geo.Category;
            dbLocation.Address1    = geo.Address1?.Trim();
            dbLocation.Address2    = geo.Address2?.Trim();
            dbLocation.TimeZone    = geo.TimeZone;
            dbLocation.Email       = geo.Email;
            return(UpdateEventLocation(dbLocation));
        }
示例#29
0
        public async Task DiscoverConsumingServices()
        {
            var allServices = new List <EventsPublishedByService>();

            foreach (var serviceAddress in _serviceBaseAddressCollection)
            {
                var publishedEventTypes = await _discoveryRepository.GetPublishedEventTypes(serviceAddress);

                allServices.Add(publishedEventTypes);
            }

            var eventLocation = new EventLocation(allServices, _eventsSubscribedByService);
            await _statusRepository.SaveEventLocation(eventLocation);
        }
 public static void AssertEventLocation(EventLocation expected, EventLocation actual)
 {
     AssertNullOrNotNull(expected, actual);
     Assert.AreEqual(expected.Id, actual.Id);
     Assert.AreEqual(expected.Name, actual.Name);
     Assert.AreEqual(expected.Address, actual.Address);
     Assert.AreEqual(expected.Town, actual.Town);
     Assert.AreEqual(expected.State, actual.State);
     Assert.AreEqual(expected.Postcode, actual.Postcode);
     Assert.AreEqual(expected.Region, actual.Region);
     Assert.AreEqual(expected.Country, actual.Country);
     Assert.AreEqual(expected.Latitude, actual.Latitude);
     Assert.AreEqual(expected.Longitude, actual.Longitude);
 }
        public async Task <EventLocation> Update(EventLocation viewModel)
        {
            if (viewModel.Id == null)
            {
                throw new ArgumentNullException(nameof(viewModel.Id));
            }
            var data = await _context.EventLocations.FirstOrDefaultAsync(c => c.Id == viewModel.Id);

            _mapper.Map(viewModel, data);
            _context.Update(data);
            await _context.SaveChangesAsync();

            return(viewModel);
        }
示例#32
0
    /// <summary>
    /// This function save the qualification
    /// </summary>
    private void Save()
    {
        var eventLocation = new EventLocation
        {
            Location = txtEventLocation.Text,
        };

        var id = new EventLocations().AddEventLocation(eventLocation);

        //clear text box and load qualifications
        txtEventLocation.Text = "";

        //load qualifications
        LoadEventLocations();
    }