public CommandsDispatcher(
     IMediator mediator,
     LocationContext LocationContext)
 {
     this._mediator = mediator;
     this._LocationContext = LocationContext;
 }
Exemple #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);
        }
 public PingRepository(
     LocationContext locatieContext,
     ICache cache
     ) : base(locatieContext)
 {
     this.cache = cache;
 }
Exemple #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);
            }
        }
Exemple #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());
     }
 }
Exemple #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;
            }));
        }
Exemple #7
0
 public CoursesController(CourseContext context, LocationContext locationContext, QuestionContext questionContext, AnswerContext answerContext)
 {
     _courseContext   = context;
     _locationContext = locationContext;
     _questionContext = questionContext;
     _answerContext   = answerContext;
 }
Exemple #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);
        }
Exemple #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;
 }
Exemple #12
0
 public LocationRepository(
     LocationContext locatieContext,
     ICache cache
     ) : base(locatieContext)
 {
     this.cache = cache;
     utility    = new Utility();
 }
Exemple #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;
 }
Exemple #15
0
 public UIElement Build(IContainer builder, LocationContext ctx)
 {
     if (_builder != null)
     {
         return(CreateByBuilder(builder, ctx));
     }
     return(FromDataTemplate(builder, ctx));
 }
Exemple #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));
        }
 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;
 }
 public RideRepository(
     LocationContext locatieContext,
     ICache cache,
     ITagRepository tagRepository
     ) : base(locatieContext)
 {
     this.cache         = cache;
     this.tagRepository = tagRepository;
 }
Exemple #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();
     }
 }
 public DayRepository(
     LocationContext locatieContext,
     IPingRepository pingRepository,
     IRideRepository rideRepository
     ) : base(locatieContext)
 {
     this.pingRepository = pingRepository;
     this.rideRepository = rideRepository;
 }
        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);
            }
        }
 public StatsRepository(
     LocationContext db,
     ITagRepository tagRepository,
     ICache cache
     )
 {
     this.tagRepository = tagRepository;
     this.db            = db;
     this.cache         = cache;
 }
Exemple #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"));
     }
 }
Exemple #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));
        }
Exemple #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);
     }
 }
        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));
        }
Exemple #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);
     })
                                             );
 }
Exemple #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;
 }
Exemple #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");
        }
        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);
        }
	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");
 }