Ejemplo n.º 1
0
 public CommandsDispatcher(
     IMediator mediator,
     LocationContext LocationContext)
 {
     this._mediator = mediator;
     this._LocationContext = LocationContext;
 }
Ejemplo n.º 2
0
        private void UpdateRequestTelemetry(HttpContext platformContext, LocationContext location)
        {
            string resultIp = null;

            foreach (var clientIpHeaderName in this.HeaderNames)
            {
                var clientIpsFromHeader = platformContext.Request.UnvalidatedGetHeader(clientIpHeaderName);

                if (!string.IsNullOrWhiteSpace(clientIpsFromHeader))
                {
                    WebEventSource.Log.WebLocationIdHeaderFound(clientIpHeaderName);

                    string ip = this.GetIpFromHeader(clientIpsFromHeader);
                    ip = CutPort(ip);
                    if (IsCorrectIpAddress(ip))
                    {
                        resultIp = ip;
                        break;
                    }
                }
            }

            if (!string.IsNullOrEmpty(resultIp))
            {
                location.Ip = resultIp;
            }
            else
            {
                location.Ip = platformContext.Request.GetUserHostAddress();
            }

            WebEventSource.Log.WebLocationIdSet(location.Ip);
        }
Ejemplo n.º 3
0
 public PingRepository(
     LocationContext locatieContext,
     ICache cache
     ) : base(locatieContext)
 {
     this.cache = cache;
 }
Ejemplo n.º 4
0
        public async Task <string> AddIt(LocationContext context, VehicleLocation vehicleLocation)
        {
            _context = context;
            _context.VehicleLocations.Add(vehicleLocation);
            await _context.SaveChangesAsync();

            string vehicleLatLong = "";

            vehicleLatLong += vehicleLocation.VehicleId;
            vehicleLatLong += "#";
            vehicleLatLong += vehicleLocation.Latitude;
            vehicleLatLong += ",";
            vehicleLatLong += vehicleLocation.Longitude;

            vehicleLocation.VehicleLatLong        = vehicleLatLong;
            _context.Entry(vehicleLocation).State = EntityState.Modified;
            _context.VehicleLocations.Update(vehicleLocation);

            try
            {
                await _context.SaveChangesAsync();

                return("Response:{ status: Succes, description: Vehicle data saved}");
            }
            catch (DbUpdateConcurrencyException e)
            {
                return("Look here " + e.Message);
            }
        }
Ejemplo n.º 5
0
 //Makes a list that contains all of the Locations in the Database
 public List <Location> GetAll()
 {
     using (context = new LocationContext())
     {
         return(context.Locations.ToList());
     }
 }
Ejemplo n.º 6
0
        /// <inheritdoc />
        public override bool UpdateContext(IContext context)
        {
            return(this.IsChanged(() =>
            {
                bool changed = false;

                if (this.MarkReady(this.SaveReader.IsReady))
                {
                    // current location
                    var newLocation = this.SaveReader.GetCurrentLocationContext(this.SaveReader.GetCurrentPlayer()) ?? LocationContext.Valley;
                    changed |= newLocation != this.CurrentLocation;
                    this.CurrentLocation = newLocation;

                    // weather values
                    foreach (LocationContext location in CommonHelper.GetEnumValues <LocationContext>())
                    {
                        Weather newWeather = this.SaveReader.GetWeather(location);

                        changed |= newWeather != this.Values[location];
                        this.Values[location] = newWeather;
                    }
                }

                return changed;
            }));
        }
Ejemplo n.º 7
0
 public CoursesController(CourseContext context, LocationContext locationContext, QuestionContext questionContext, AnswerContext answerContext)
 {
     _courseContext   = context;
     _locationContext = locationContext;
     _questionContext = questionContext;
     _answerContext   = answerContext;
 }
Ejemplo n.º 8
0
 /***
 ** Advice = Event + Observation
 ** Event = Fundort
 ** Observation = Fund
 ** Observation = ObservationInfo + optional List of Images
 ***/
 public AdviceController(UserManager <ApplicationUser> userManager, DeterminationContext detContext, InformationContext infContext, ObservationContext obsContext, MappingContext mapContext, LocationContext locContext, PublicContext idoContext)
 {
     _userManager = userManager;
     _obsContext  = obsContext;
     _locContext  = locContext;
     _idoContext  = idoContext;
 }
        public async Task <LocationContext> GetDbContextAsync()
        {
            _credentials ??= await _tokenClient.GetTokenAsync();

            LocationContext context = null;

            // use a delegate to always resolve late (no caching)
            CosmosToken getCredentials() => _credentials;

            // configure EF Core to use Cosmos DB
            var options = new DbContextOptionsBuilder <LocationContext>()
                          .UseCosmos(getCredentials().Endpoint,
                                     getCredentials().Key,
                                     Context.SuperCode,
                                     opt =>
                                     opt.ConnectionMode(Microsoft.Azure.Cosmos.ConnectionMode.Gateway));

            try
            {
                // if credentials are stale this will fail
                context = new LocationContext(options.Options);
            }
            catch
            {
                // try again with fresh credentials
                _credentials = await _tokenClient.GetTokenAsync();

                context = new LocationContext(options.Options);
            }

            // give what we got
            return(context);
        }
Ejemplo n.º 10
0
 public UserSessionRepository(
     LocationContext locatieContext,
     ICache cache
     ) : base(locatieContext)
 {
     this.cache = cache;
 }
 public LocationsController(LocationContext context, QuestionContext questionContext, AnswerContext answerContext, IWebHostEnvironment hostEnvironment)
 {
     _locationContext    = context;
     _questionContext    = questionContext;
     _answerContext      = answerContext;
     _webHostEnvironment = hostEnvironment;
 }
Ejemplo n.º 12
0
 public LocationRepository(
     LocationContext locatieContext,
     ICache cache
     ) : base(locatieContext)
 {
     this.cache = cache;
     utility    = new Utility();
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Changes the context.
 /// </summary>
 /// <param name="locationContext">The location context.</param>
 public void ChangeContext(LocationContext locationContext)
 {
     if (locationContext.Key != CurrentUserContext.Location.Key)
     {
         ChangeContext(
             new CurrentUserContext(CurrentUserContext.Agency, locationContext, CurrentUserContext.Staff, CurrentUserContext.Account));
     }
 }
 public ImmersiveQuizAPI(CourseContext courseContext, LocationContext locationContext, QuestionContext questionContext, AnswerContext answerContext, ScoreContext scoreContext)
 {
     _courseContext   = courseContext;
     _locationContext = locationContext;
     _questionContext = questionContext;
     _answerContext   = answerContext;
     _scoreContext    = scoreContext;
 }
Ejemplo n.º 15
0
 public UIElement Build(IContainer builder, LocationContext ctx)
 {
     if (_builder != null)
     {
         return(CreateByBuilder(builder, ctx));
     }
     return(FromDataTemplate(builder, ctx));
 }
Ejemplo n.º 16
0
        public ActionResult MyCar()
        {
            var db          = new LocationContext();
            var CurrentUser = db.Users.Where(x => x.UserName.Equals(User.Identity.Name)).FirstOrDefault();
            var res         = myService.GetMany().Where(x => x.UserId == CurrentUser.UserID).ToList();

            return(View(res));
        }
Ejemplo n.º 17
0
 public UserService(LocationContext dbContext, UserManager <ApplicationUser> userManager,
                    SignInManager <ApplicationUser> signInManager, IOptions <AppSettings> appSettings)
 {
     _dbContext     = dbContext;
     _userManager   = userManager;
     _signInManager = signInManager;
     _appSettings   = appSettings.Value;
 }
 public UnitOfWorkCommandHandlerDecorator(
     ICommandHandler <T> decorated,
     ILocationUnitOfWork unitOfWork,
     LocationContext locationContext)
 {
     _decorated       = decorated;
     _unitOfWork      = unitOfWork;
     _locationContext = locationContext;
 }
Ejemplo n.º 19
0
 public RideRepository(
     LocationContext locatieContext,
     ICache cache,
     ITagRepository tagRepository
     ) : base(locatieContext)
 {
     this.cache         = cache;
     this.tagRepository = tagRepository;
 }
Ejemplo n.º 20
0
 private static void SeedData(LocationContext locationContext)
 {
     System.Console.WriteLine("Starting Seeding Location db");
     if (locationContext.Database.GetPendingMigrations().Any())
     {
         System.Console.WriteLine("Location db has migrated");
         locationContext.Database.Migrate();
     }
 }
Ejemplo n.º 21
0
 public DayRepository(
     LocationContext locatieContext,
     IPingRepository pingRepository,
     IRideRepository rideRepository
     ) : base(locatieContext)
 {
     this.pingRepository = pingRepository;
     this.rideRepository = rideRepository;
 }
Ejemplo n.º 22
0
        public static void Indexing()
        {
            using (LocationContext dbContext = new LocationContext())
            {
                var customerLocationList = dbContext.CustomerLocations.Where(s => !s.IsDeleted)
                                           .Include(s => s.Customer)
                                           .Select(s => new CustomerModel
                {
                    CustomerId   = s.CustomerId,
                    CustomerName = s.Customer.Name,
                    LocationId   = s.Id,
                    LocationName = s.Name,
                    Location     = new GeoLocation(Convert.ToDouble(s.Latitude), Convert.ToDouble(s.Longitude))
                }).ToList();


                var defaultIndex = "customerlocation";
                var client       = new ElasticClient();

                if (client.IndexExists(defaultIndex).Exists)
                {
                    client.DeleteIndex(defaultIndex);
                }

                if (!elasticClient.IndexExists("location_alias").Exists)
                {
                    client.CreateIndex(defaultIndex, c => c
                                       .Mappings(m => m
                                                 .Map <CustomerModel>(mm => mm
                                                                      .AutoMap()
                                                                      )
                                                 ).Aliases(a => a.Alias("location_alias"))
                                       );
                }

                // Insert Data Classic
                // for (int i = 0; i < customerLocationList.Count; i++)
                //     {
                //         var item = customerLocationList[i];
                //         elasticClient.Index<CustomerModel>(item, idx => idx.Index("customerlocation").Id(item.LocationId));
                //     }

                // Bulk Insert
                var bulkIndexer = new BulkDescriptor();

                foreach (var document in customerLocationList)
                {
                    bulkIndexer.Index <CustomerModel>(i => i
                                                      .Document(document)
                                                      .Id(document.LocationId)
                                                      .Index("customerlocation"));
                }

                elasticClient.Bulk(bulkIndexer);
            }
        }
Ejemplo n.º 23
0
 public StatsRepository(
     LocationContext db,
     ITagRepository tagRepository,
     ICache cache
     )
 {
     this.tagRepository = tagRepository;
     this.db            = db;
     this.cache         = cache;
 }
Ejemplo n.º 24
0
 public ActionResult LocationRemove(Location location)
 {
     using (locationContext = new LocationContext())
     {
         Location toRemove = locationContext.Locations.Find(location.Id);
         locationContext.Locations.Remove(toRemove);
         locationContext.SaveChanges();
         return(View("~/Views/Admin/Locations.cshtml"));
     }
 }
Ejemplo n.º 25
0
        //Line Chart
        public ActionResult GetData()
        {
            LocationContext context = new LocationContext();

            var query = context.Bookings.Include("User")
                        .GroupBy(p => p.BookingRequestDate.Month)
                        .Select(g => new { name = g.Key, count = g.Count() }).ToList();

            return(Json(query, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 26
0
 private void UpdateClientIp(LocationContext location, IOperationContext operation)
 {
     if (operation.HasIncomingMessageProperty(RemoteEndpointMessageProperty.Name))
     {
         var property = (RemoteEndpointMessageProperty)
                        operation.GetIncomingMessageProperty(RemoteEndpointMessageProperty.Name);
         location.Ip = property.Address;
         WcfEventSource.Log.LocationIdSet(location.Ip);
     }
 }
Ejemplo n.º 27
0
        public ActionResult MapView(float latitude, float longitude)
        {
            var sourcePoint = CreatePoint(latitude, longitude);
            var context     = new LocationContext();
            // find any locations within 15 kilometers ordered by distance
            var locations = context.Locations.Where(loc => loc.GeoLocation.Distance(sourcePoint) < 15000)
                            .OrderBy(loc => loc.GeoLocation.Distance(sourcePoint)).ToList();

            return(View(locations));
        }
Ejemplo n.º 28
0
 public UserRepository(
     LocationContext locatieContext,
     IUserSessionRepository userSessionRepository,
     ICache cache,
     Microsoft.Extensions.Options.IOptions <AppSettings> options
     ) : base(locatieContext)
 {
     this.cache = cache;
     this.userSessionRepository = userSessionRepository;
     this.options = options;
 }
 protected override void Seed(LocationContext context)
 {
     context.Countries.SeedFromResource("SeedingDataFromCSV.Domain.SeedData.countries.csv", c => c.Code);
     context.SaveChanges();
     context.ProvinceStates.SeedFromResource("SeedingDataFromCSV.Domain.SeedData.provincestates.csv", p => p.Code,
                                             new CsvColumnMapping <ProvinceState>("CountryCode", (state, countryCode) =>
     {
         state.Country = context.Countries.Single(c => c.Code == countryCode);
     })
                                             );
 }
Ejemplo n.º 30
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CurrentUserContext"/> class.
 /// </summary>
 /// <param name="agencyContext">The agency context.</param>
 /// <param name="locationContext">The location context.</param>
 /// <param name="staffContext">The staff context.</param>
 /// <param name="accountContext">The account context.</param>
 public CurrentUserContext(
     AgencyContext agencyContext,
     LocationContext locationContext,
     StaffContext staffContext,
     AccountContext accountContext )
 {
     Agency = agencyContext;
     Location = locationContext;
     Staff = staffContext;
     Account = accountContext;
 }
Ejemplo n.º 31
0
        public async Task <string> DoesItExist(LocationContext context, VehicleLocation vehicleLocation)
        {
            _context = context;
            var response = await _context.VehicleLocations.SingleOrDefaultAsync(m => m.VehicleLatLong == vehicleLocation.VehicleLatLong);

            if (response == null)
            {
                return("1");
            }
            return("0");
        }
Ejemplo n.º 32
0
        public string GetModel(ConvertServiceRequest request)
        {
            _locationContext = ResolveLocationContext(request);

            if (!string.IsNullOrEmpty(request.Data))
                _viewModel = CommonUtils.JsonDeserialize<AdminSettingsViewModel>(request.Data);
            else
                CreateInitialViewModel();

            // Handle special commands
            var command = request.Parameters.ContainsKey("Command") ? request.Parameters["Command"] : null;

            switch (command)
            {
                case "InheritSettings":
                    InheritSettings(_locationContext.Id, "Organizational Units");
                    InheritSettings(_locationContext.Id, "Lead Management");
                    _viewModel.SetSuccessMessage("Settings Successfully Inherited");
                    break;
                case "ChangeCmsType":
                    var existingGroup = _viewModel.SettingGroups.Single(g => g.Name == _cmsIntegrationSettingsGroupName);
                    var updatedGroup = BuildCmsIntegrationSettings(CommonUtils.GetFieldValue(existingGroup.Fields, "CmsType"));
                    existingGroup.Fields = updatedGroup.Fields;
                    return CommonUtils.JsonSerialize(_viewModel);
                case "RefreshSiteSearchIndex":
                    ProcessOneWayRequest(new UpdateAllLocationsG2RecordRequest());
                    _viewModel.SetSuccessMessage("The Site Search index is being updated in the background. Changes should become visible within a few minutes.");
                    return CommonUtils.JsonSerialize(_viewModel);
            }

            // Load latest settings
            _searchSettings = ProcessRequest<ReadOrgUnitSearchSettingsResponse>(new ReadOrgUnitSearchSettingsRequest() { OrgUnitContextId = _locationContext.Id });

            // Handle settings save request
            if (!string.IsNullOrEmpty(request.Data) && string.IsNullOrEmpty(command))
            {
                Save();
                _viewModel.SetSuccessMessage("Settings Successfully Saved");
            }

            LoadPage(request);

            return CommonUtils.JsonSerialize(_viewModel);
        }
Ejemplo n.º 33
0
	public LocationContext location() {
		LocationContext _localctx = new LocationContext(Context, State);
		EnterRule(_localctx, 84, RULE_location);
		int _la;
		try {
			EnterOuterAlt(_localctx, 1);
			{
			State = 1321; k_location();
			State = 1325;
			ErrorHandler.Sync(this);
			_la = TokenStream.La(1);
			while (_la==SCOL) {
				{
				{
				State = 1322; locparam();
				}
				}
				State = 1327;
				ErrorHandler.Sync(this);
				_la = TokenStream.La(1);
			}
			State = 1328; Match(COL);
			State = 1329; text();
			State = 1330; Match(CRLF);
			}
		}
		catch (RecognitionException re) {
			_localctx.exception = re;
			ErrorHandler.ReportError(this, re);
			ErrorHandler.Recover(this, re);
		}
		finally {
			ExitRule();
		}
		return _localctx;
	}
 void Initialize()
 {
     if (String.IsNullOrEmpty(MasterDatabaseDirectory)) throw new ApplicationException("MasterDatabaseDirectory cannot be null or empty");
     if (!Directory.Exists(MasterDatabaseDirectory))
     {
         Directory.CreateDirectory(MasterDatabaseDirectory);
         Directory.CreateDirectory(Path.Combine(MasterDatabaseDirectory, "locations"));
         Directory.CreateDirectory(Path.Combine(MasterDatabaseDirectory, "scenarios"));
     }
     //System.Data.Entity.Database.SetInitializer(new Initializer());
     var connection = new SqlCeConnectionFactory("System.Data.SqlServerCe.4.0").CreateConnection(Path.Combine(MasterDatabaseDirectory, "esme.db"));
     Context = new LocationContext(connection, true);
     Refresh();
     OnPropertyChanged("Locations");
     OnPropertyChanged("Scenarios");
 }