/// <summary> /// Impostazione contesto chiamante /// </summary> private void SetCallerContext() { // Impostazione del contesto del chiamante in sessione CallerContext callerContext = CallerContext.NewContext(this.Page.Request.Url.AbsoluteUri); callerContext.PageNumber = this.GetListPagingControl().GetPagingContext().PageNumber; }
public static SystemConfig GetSystemConfig(SystemConfigType systemConfigType) { using (var db = new CallerContext()) { return(db.SystemConfigs.Where(x => x.Code == (int)systemConfigType).FirstOrDefault()); } }
public void Arrange() { _controllerContext = new ControllerContext(Mock.Of <HttpContextBase>(), new RouteData(), Mock.Of <ControllerBase>()); _valueProvider = new NameValueCollectionValueProvider(new NameValueCollection(), null); _bindingContext = new ModelBindingContext { ModelName = "", ValueProvider = _valueProvider, ModelMetadata = ModelMetadataProviders.Current.GetMetadataForType(null, typeof(MembershipMessageStub)) }; _callerContextProvider = new Mock <ICallerContextProvider>(); _callerContext = new CallerContext { AccountHashedId = "ABC123", AccountId = 111111, UserRef = Guid.NewGuid() }; _callerContextProvider.Setup(p => p.GetCallerContext()).Returns(_callerContext); _modelBinder = new MessageModelBinder(() => _callerContextProvider.Object); }
public static bool GetPassword(string Account, string Pass) { using (var db = new CallerContext()) { return(db.User.Where(x => x.Name == Account).FirstOrDefault().Password == Pass ? true : false); } }
private void btnBack_Click(object sender, System.EventArgs e) { CallerContext context = CallerContext.GetCallerContext(); context.AdditionalParameters.Add("searchPage", context.PageNumber); Response.Redirect(context.Url); }
protected CallerContext SetTestContext( int subseq = -1, [System.Runtime.CompilerServices.CallerMemberName] string caller = "") { var m = this.GetType().GetMember(caller); if (m.Length != 1) { throw new InvalidOperationException("Unable to resolve single member from caller name"); } LastContext = new CallerContext { Test = this, Name = caller, Member = m[0], TestOrder = TestOrderer.GetTestOrder(m[0]), TestGroup = TestOrderer.GetTestGroup(m[0]), Subsequence = subseq, State = State, }; if (Clients?.Acme != null) { Clients.Acme.BeforeAcmeSign = BeforeAcmeSign; Clients.Acme.BeforeHttpSend = BeforeAcmeSend; Clients.Acme.AfterHttpSend = AfterAcmeSend; } return(LastContext); }
public static void SaveSystemConfig(SystemConfig systemConfig) { using (var db = new CallerContext()) { var obj = db.SystemConfigs.Where(x => x.Code == systemConfig.Code).FirstOrDefault(); obj.Value = systemConfig.Value; db.SaveChanges(); } }
private bool ReportProgress(CallerContext context) { if (context.CancelToken.IsCancellationRequested) { RemoveParsedData(); return(true); } context.ProgressReport(NbReadLines); return(false); }
public void Parse(CallerContext context) { FullyParsed = false; var garbageCollectOldLatencyMode = GCSettings.LatencyMode; try { GCSettings.LatencyMode = GCLatencyMode.LowLatency; RootBlock = new DataBlock(null); IDataElement target = RootBlock; if (ReportProgress(context)) { return; } while (_stream.EndOfStream == false) { if (ReportProgress(context)) { return; } var line = ReadLine(); var splitLine = SplitLine(line); foreach (var subLine in splitLine) { target = target.ProcessLine(subLine); } if (NbReadLines == 5 || _stream.EndOfStream) { CheckFileValidity(); } } if (RootBlock.Children.Count == 0) { throw new InvalidOperationException("Could not read any data. Possibly empty file"); } Map = new Mapping(_rootBlock); FullyParsed = true; } finally { GCSettings.LatencyMode = garbageCollectOldLatencyMode; } }
public EDTTransactionScope(IAccount account, EDTEndpoint endpoint, string remoteHost = null, Context context = Context.Regulator, ICERSRepositoryManager repository = null, int?authenticationRequestID = null, CallerContext callerContext = CallerContext.EDT) { account.CheckNull("account"); Account = account; Context = context; Repository = repository; Endpoint = endpoint; RemoteHost = remoteHost; AuthenticationRequestID = authenticationRequestID; CallerContext = callerContext; Initialize(); }
private string GetCallerUrl() { CallerContext callerContext = CallerContext.GetCallerContext(); string retValue = string.Empty; if (callerContext == null) { retValue = this.BackUrl; } else { callerContext.AdditionalParameters.Add("searchPage", callerContext.PageNumber); retValue = callerContext.Url; } return(retValue); }
/// <summary> /// Messages the received. /// </summary> /// <param name="sender">The sender.</param> /// <param name="args">The args.</param> protected virtual void MessageReceived(object sender, OutputGatewayEventHandlerArgs <TMessage, MessageHeader> args) { InvokeOnMessageReceived(); if (args.Header.CallContext != null && args.Header.CallContext.ContainsKey("DEBUG_MESSAGE")) { Logger.Warn(string.Format("Ha llegado el Mensaje:{0}", args.SerializedMessage)); Logger.Warn(string.Format("Tipo del Mensaje:{0}", args.Header.BodyType)); } Session currentSession = SessionFactory.Create(); if (args.Header.Type == MessageBusType.Reply) { CallerContext requester = args.Header.CallStack.Pop(); if (requester.Identification.Equals(Identification)) { currentSession = requester.Session; } else { Logger.Debug("Reply Message not mine"); return; } } var listTask = new List <Thread>(); //Buscar en los handlers para procesar el mensaje foreach (Type type in HandlerRepository.GetHandlersByMessage(args.Message.GetType())) { Type typeClosure = type; var th = new Thread(() => ExecuteHandler(args, typeClosure, currentSession)); th.Start(); listTask.Add(th); } foreach (var thread in listTask) { thread.Join(TimeSpan.FromMinutes(3)); } }
public ICallerContext GetCallerContext() { if (_httpRequestMessage.Properties.ContainsKey(Key)) { return((CallerContext)_httpRequestMessage.Properties[Key]); } var accountHashedId = GetAccountHashedId(); var accountId = accountHashedId == null ? null : GetAccountId(accountHashedId); var requestContext = new CallerContext { AccountHashedId = accountHashedId, AccountId = accountId, UserRef = null }; _httpRequestMessage.Properties[Key] = requestContext; return(requestContext); }
public ICallerContext GetCallerContext() { if (_httpContext.Items.Contains(Key)) { return(_httpContext.Items[Key] as CallerContext); } var accountHashedId = GetAccountHashedId(); var accountId = accountHashedId == null ? null : GetAccountId(accountHashedId); var userRef = GetUserRef(); var requestContext = new CallerContext { AccountHashedId = accountHashedId, AccountId = accountId, UserRef = userRef }; _httpContext.Items[Key] = requestContext; return(requestContext); }
/// <summary> /// BeforeSendRequest /// </summary> /// <param name="request"></param> /// <param name="channel"></param> /// <returns></returns> public object BeforeSendRequest(ref Message request, IClientChannel channel) { // can we find an existing caller contetx header var existingCallerContextHeaderIndex = request.Headers.FindHeader(Constants.CallerContextHeaderName, Constants.XmlNamespace); var userService = UserService; // if so, remove before adding another if (existingCallerContextHeaderIndex >= 0) { request.Headers.RemoveAt(existingCallerContextHeaderIndex); } var ctx = new CallerContext { EffectiveContracts = userService.Contracts.ToArray(), EffectiveDate = userService.DateTime, EffectiveSite = userService.SiteCode }; request.Headers.Add(MessageHeader.CreateHeader(Constants.CallerContextHeaderName, Constants.XmlNamespace, ctx)); return(null); }
internal CallerContext PrepareContextBeforeProcessing() { var cts = new CancellationTokenSource(); var syncContext = SynchronizationContext.Current; Action <int> progressReport = (i => syncContext.Post(_ => ProgressBar.Increment(1), null)); var context = new CallerContext() { CancelToken = cts.Token, ProgressReport = progressReport }; _cancelAction = () => { SetUiEnable(true); cts.Cancel(); }; ProgressBar.Value = 0; ProgressBar.Minimum = 0; ProgressBar.Maximum = Ck2SaveFile.EstimateNbLines(FilesHandler.SelectedFile); return(context); }
public void Execute(CommandContext context, CallerContext callerContext, string[] args) { context.NotificationService.ShowHelp(); }
public LanguageRuntimeService(CallerContext callerContext) { this._callerContext = callerContext; }
/// <inheritdoc/> public override byte[] TryGetStreamInternal(double left, double top, double right, double bottom, int width, int height, out IEnumerable <IMapObject> mapObjects) { using (var service = new XMapWSServiceImpl(url)) { var mapParams = new MapParams { showScale = false, useMiles = false }; var imageInfo = new ImageInfo { format = ImageFileFormat.GIF, height = height, width = width }; var bbox = new BoundingBox { leftTop = new Point { point = new PlainPoint { x = left, y = top } }, rightBottom = new Point { point = new PlainPoint { x = right, y = bottom } } }; var profile = CustomProfile == null ? "ajax-av" : CustomProfile; var ccProps = new List <CallerContextProperty> { new CallerContextProperty { key = "CoordFormat", value = "PTV_MERCATOR" }, new CallerContextProperty { key = "Profile", value = profile } }; if (!string.IsNullOrEmpty(ContextKey)) { ccProps.Add(new CallerContextProperty { key = "ContextKey", value = ContextKey }); } if (CustomCallerContextProperties != null) { ccProps.AddRange(CustomCallerContextProperties); } var cc = new CallerContext { wrappedProperties = ccProps.ToArray() }; if (!string.IsNullOrEmpty(User) && !string.IsNullOrEmpty(Password)) { service.PreAuthenticate = true; var credentialCache = new System.Net.CredentialCache { { new Uri(url), "Basic", new System.Net.NetworkCredential(User, Password) } }; service.Credentials = credentialCache; } var map = service.renderMapBoundingBox(bbox, mapParams, imageInfo, CustomXMapLayers != null ? CustomXMapLayers.ToArray() : null, true, cc); mapObjects = map.wrappedObjects? .Select(objects => objects.wrappedObjects?.Select(layerObject => (IMapObject) new XMap1MapObject(objects, layerObject))) .Where(objects => objects != null && objects.Any()) .SelectMany(objects => objects); return(map.image.rawImage); } }
static void Main(string[] args) { #region general purpose var rlo = new ResultListOptions() { segments = true, }; var cio = new CountryInfoOptions(); var cc = new CallerContext() { wrappedProperties = new CallerContextProperty[] { new CallerContextProperty() { key = "ProfileXMLSnippet", }, new CallerContextProperty() { key = "Profile", value = "mg-trailer-truck", }, }, }; #endregion #region adr example var adrSnippet = new com.ptvgroup.xserver1.XRouteProfile.Profile() { MajorVersion = "1", MinorVersion = "0", DataCompatibilityVersion = "2", FeatureLayer = new com.ptvgroup.xserver1.XRouteProfile.FeatureLayer() { MajorVersion = "1", MinorVersion = "0", GlobalSettings = new com.ptvgroup.xserver1.XRouteProfile.GlobalSettings() { EnableVehicleDependency = "true", }, Themes = new com.ptvgroup.xserver1.XRouteProfile.Themes() { Theme = new List <com.ptvgroup.xserver1.XRouteProfile.Theme>() { new com.ptvgroup.xserver1.XRouteProfile.Theme() { Enabled = "true", Id = "PTV_TruckAttributes", }, }, }, }, Routing = new com.ptvgroup.xserver1.XRouteProfile.Routing() { MajorVersion = "2", MinorVersion = "0", Vehicle = new com.ptvgroup.xserver1.XRouteProfile.Vehicle() { Load = new com.ptvgroup.xserver1.XRouteProfile.Load() { LoadType = "GOODS", HazardousGoodsType = "HAZARDOUS", TunnelRestrictionCode = "E", }, }, Course = new com.ptvgroup.xserver1.XRouteProfile.Course() { AdditionalDataRules = new com.ptvgroup.xserver1.XRouteProfile.AdditionalDataRules() { Enabled = "true", }, }, } }; var tunnelWps = new WaypointDesc[] { new WaypointDesc() { linkType = LinkType.AUTO_LINKING, wrappedCoords = new Point[] { new Point() { point = new PlainPoint() { x = 520127, y = 6878446, }, }, }, }, new WaypointDesc() { linkType = LinkType.AUTO_LINKING, wrappedCoords = new Point[] { new Point() { point = new PlainPoint() { x = 522578, y = 6861984, }, }, }, }, }; #endregion #region block country var blockBelgiumSnippet = new com.ptvgroup.xserver1.XRouteProfile.Profile() { MajorVersion = "1", MinorVersion = "0", DataCompatibilityVersion = "2", Routing = new com.ptvgroup.xserver1.XRouteProfile.Routing() { MajorVersion = "2", MinorVersion = "0", Algorithm = new com.ptvgroup.xserver1.XRouteProfile.Algorithm() { GeographicRestrictions = new com.ptvgroup.xserver1.XRouteProfile.GeographicRestrictions() { ForbiddenCountry = new List <com.ptvgroup.xserver1.XRouteProfile.ForbiddenCountry>() { new com.ptvgroup.xserver1.XRouteProfile.ForbiddenCountry() { CountryCode = "32", }, }, }, }, }, }; var normallyThroughBelgiumWps = new WaypointDesc[] { new WaypointDesc() { linkType = LinkType.AUTO_LINKING, wrappedCoords = new Point[] { new Point() { point = new PlainPoint() { x = 510724, y = 6734625, }, }, }, }, new WaypointDesc() { linkType = LinkType.AUTO_LINKING, wrappedCoords = new Point[] { new Point() { point = new PlainPoint() { x = 290832, y = 6514732, }, }, }, }, }; #endregion #region emissions var emmisionSnippet = new com.ptvgroup.xserver1.XRouteProfile.Profile() { MajorVersion = "1", MinorVersion = "0", DataCompatibilityVersion = "2", Routing = new com.ptvgroup.xserver1.XRouteProfile.Routing() { MajorVersion = "2", MinorVersion = "0", Vehicle = new com.ptvgroup.xserver1.XRouteProfile.Vehicle() { Physical = new com.ptvgroup.xserver1.XRouteProfile.Physical() { Drive = new com.ptvgroup.xserver1.XRouteProfile.Drive() { DriveType = "MOTORIZED", Emissions = new com.ptvgroup.xserver1.XRouteProfile.Emissions() { EmissionClass = "EURO_6", }, Engine = new com.ptvgroup.xserver1.XRouteProfile.Engine() { BioFuelRatio = "0", FuelConsumption = "32.6", FuelType = "DIESEL", } } } }, }, }; var emmisionWps = new WaypointDesc[] { new WaypointDesc() { linkType = LinkType.AUTO_LINKING, wrappedCoords = new Point[] { new Point() { point = new PlainPoint() { x = 735099, y = 6755798, }, }, }, }, new WaypointDesc() { linkType = LinkType.AUTO_LINKING, wrappedCoords = new Point[] { new Point() { point = new PlainPoint() { x = 1350798, y = 6074131, }, }, }, }, }; var emmissionsRlo = new ResultListOptions() { emissions = new EmissionType() { emissionLevel = EmissionLevel.BASIC, }, hbefaType = new HBEFAType() { version = HBEFAVersion.HBEFA_3_2, }, cenEmissionConfiguration = new CENEmissionConfiguration() { cenVersion = CENVersion.CEN_2012, fleetSpecificAverageFuelConsumption = 32.6, fleetSpecificAverageFuelConsumptionSpecified = true, }, }; #endregion using (var xroute = new XRouteWSClient()) { //var binding = xroute.Endpoint.Binding as BasicHttpBinding; //binding.Security.Mode = BasicHttpSecurityMode.Transport; //binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic; //binding.MaxReceivedMessageSize = 1234567890; //xroute.ClientCredentials.UserName.UserName = "******"; //xroute.ClientCredentials.UserName.Password = ""; //xroute.Endpoint.Address = new EndpointAddress("https://xroute-tln-eu-n.cloud.ptvgroup.com/xroute/ws/XRoute"); ExtendedRoute extendedRoute = null; Console.WriteLine(blockBelgiumSnippet.ToSnippet()); extendedRoute = xroute.calculateExtendedRoute(normallyThroughBelgiumWps, null, null, rlo, cio, cc); Console.WriteLine($"Withouth \"block belgium\" snippet the distance is {extendedRoute.route.info.distance}. It goes through {string.Join(",", extendedRoute.route.wrappedSegments.Select(s => s.iuCode).Distinct())}"); cc.wrappedProperties[0].value = blockBelgiumSnippet.ToSnippet(); extendedRoute = xroute.calculateExtendedRoute(normallyThroughBelgiumWps, null, null, rlo, cio, cc); Console.WriteLine($"Withouth \"block belgium\" snippet the distance is {extendedRoute.route.info.distance}. It goes through {string.Join(",", extendedRoute.route.wrappedSegments.Select(s => s.iuCode).Distinct())}"); Console.WriteLine(); Console.WriteLine(emmisionSnippet.ToSnippet()); cc.wrappedProperties[0].value = emmisionSnippet.ToSnippet(); extendedRoute = xroute.calculateExtendedRoute(emmisionWps, null, null, emmissionsRlo, cio, cc); Console.WriteLine($"Emmisison distance {extendedRoute.route.info.distance}. Fleet based co2eTank2Wheel = {(extendedRoute.route.cenEmissions.fleetSpecific as CENEmissions2012).co2eTank2Wheel}. HBEFA based co2eTank2Wheel = {(extendedRoute.route.cenEmissions.basedOnHBEFA as CENEmissions2012).co2eTank2Wheel}. Pure HBEFA carbonDioxide = {extendedRoute.route.emissions.carbonDioxide} "); Console.WriteLine(); Console.WriteLine(adrSnippet.ToSnippet()); cc.wrappedProperties[0].value = adrSnippet.ToSnippet(); extendedRoute = xroute.calculateExtendedRoute(tunnelWps, null, null, rlo, cio, cc); Console.WriteLine($"With tunnel code {adrSnippet.Routing.Vehicle.Load.TunnelRestrictionCode} the distance is {extendedRoute.route.info.distance}."); adrSnippet.Routing.Vehicle.Load.TunnelRestrictionCode = "D"; cc.wrappedProperties[0].value = adrSnippet.ToSnippet(); extendedRoute = xroute.calculateExtendedRoute(tunnelWps, null, null, rlo, cio, cc); Console.WriteLine($"With tunnel code {adrSnippet.Routing.Vehicle.Load.TunnelRestrictionCode} the distance is {extendedRoute.route.info.distance}."); adrSnippet.Routing.Vehicle.Load.TunnelRestrictionCode = "C"; cc.wrappedProperties[0].value = adrSnippet.ToSnippet(); extendedRoute = xroute.calculateExtendedRoute(tunnelWps, null, null, rlo, cio, cc); Console.WriteLine($"With tunnel code {adrSnippet.Routing.Vehicle.Load.TunnelRestrictionCode} the distance is {extendedRoute.route.info.distance}."); adrSnippet.Routing.Vehicle.Load.TunnelRestrictionCode = "B"; cc.wrappedProperties[0].value = adrSnippet.ToSnippet(); extendedRoute = xroute.calculateExtendedRoute(tunnelWps, null, null, rlo, cio, cc); Console.WriteLine($"With tunnel code {adrSnippet.Routing.Vehicle.Load.TunnelRestrictionCode} the distance is {extendedRoute.route.info.distance}."); adrSnippet.Routing.Vehicle.Load.TunnelRestrictionCode = "NONE"; cc.wrappedProperties[0].value = adrSnippet.ToSnippet(); extendedRoute = xroute.calculateExtendedRoute(tunnelWps, null, null, rlo, cio, cc); Console.WriteLine($"With tunnel code {adrSnippet.Routing.Vehicle.Load.TunnelRestrictionCode} the distance is {extendedRoute.route.info.distance}."); } Console.ReadLine(); }
/// <summary> /// Impostazione contesto chiamante /// </summary> private void SetCallerContext() { // Impostazione del contesto del chiamante in sessione CallerContext.NewContext(this.Page.Request.Url.AbsoluteUri); }
/// <summary> /// Checks if one or n certain layers are available or not. /// </summary> /// <param name="url">The url to the XMap instance.</param> /// <param name="contextKey">The used context key or null if none is used.</param> /// <param name="layers">The layers to check.</param> /// <param name="profile">The profile used to check the availability.</param> /// <param name="expectedErrorCode">The expected error code if the at least one layer does not exist. /// SoapExceptions carrying this error code will be caught and the return value of the method will be false. /// SoapExceptions carrying another error code will not be caught and thus be thrown by this API. /// </param> /// <param name="xServerUser">User name needed for Azure Cloud.</param> /// <param name="xServerPassword">Password needed for Azure Cloud.</param> /// <returns>True if one or n layers are available, false if at least one layer is not available. /// May throw exceptions in case of malformed url or wrong contextKey definition.</returns> public static bool AreXMapLayersAvailable(string url, string contextKey, Layer[] layers, string profile, string expectedErrorCode, string xServerUser = null, string xServerPassword = null) { string key = url + profile; key = layers.Aggregate(key, (current, l) => current + "_" + l.name); if (CheckedXMapLayers.ContainsKey(key) && CheckedXMapLayers[key] != null) { return(CheckedXMapLayers[key].Value); } try { Service = Service ?? new XMapWSServiceImpl(url); if (!string.IsNullOrEmpty(xServerUser) && !string.IsNullOrEmpty(xServerPassword)) { ((SoapHttpClientProtocol)Service).PreAuthenticate = true; ((SoapHttpClientProtocol)Service).Credentials = new CredentialCache { { new Uri(url), "Basic", new NetworkCredential(xServerUser, xServerPassword) } }; } var mapParams = new MapParams { showScale = false, useMiles = false }; var imageInfo = new ImageInfo { format = ImageFileFormat.GIF, height = 32, width = 32 }; var bbox = new BoundingBox { leftTop = new xserver.Point { point = new PlainPoint { x = 0, y = 10 } }, rightBottom = new xserver.Point { point = new PlainPoint { x = 0, y = 10 } } }; var callerContextProps = new List <CallerContextProperty> { new CallerContextProperty { key = "CoordFormat", value = "PTV_MERCATOR" }, new CallerContextProperty { key = "Profile", value = profile } }; if (!string.IsNullOrEmpty(contextKey)) { callerContextProps.Add(new CallerContextProperty { key = "ContextKey", value = contextKey }); } var cc = new CallerContext { wrappedProperties = callerContextProps.ToArray() }; try { Service.renderMapBoundingBox(bbox, mapParams, imageInfo, layers, true, cc); } catch (SoapException se) { if (!se.Code.Name.Equals(expectedErrorCode)) { throw; } CheckedXMapLayers.Add(key, false); return(false); } CheckedXMapLayers.Add(key, true); return(true); } finally { (Service as IDisposable)?.Dispose(); Service = null; } }
/// <summary> /// Impostazione del contesto del chiamante /// </summary> private void SetCallerContext() { CallerContext context = CallerContext.NewContext(this.Page.Request.Url.AbsoluteUri); context.PageNumber = this.GetListPagingControl().GetPagingContext().PageNumber; }
public void Execute(CommandContext context, CallerContext callerContext, string[] args) { // TODO: Discover all commands and pass then here, instead of hardcoding them context.NotificationService.ShowHelp(); }
/// <inheritdoc/> public override byte[] TryGetStreamInternal(double left, double top, double right, double bottom, int width, int height, out IEnumerable <IMapObject> mapObjects) { using (var service = new XMapWSServiceImpl(url)) { if (!string.IsNullOrEmpty(User) && !string.IsNullOrEmpty(Password)) { service.PreAuthenticate = true; service.Credentials = new CredentialCache { { new Uri(url), "Basic", new NetworkCredential(User, Password) } }; } var mapParams = new MapParams { showScale = false, useMiles = false }; var imageInfo = new ImageInfo { format = ImageFileFormat.GIF, height = height, width = width }; var bbox = new BoundingBox { leftTop = new Point { point = new PlainPoint { x = left, y = top } }, rightBottom = new Point { point = new PlainPoint { x = right, y = bottom } } }; var profile = string.Empty; var layers = new List <Layer>(); switch (mode) { case XMapMode.Street: // only streets profile = "ajax-bg"; layers.Add(new StaticPoiLayer { name = "town", visible = false, category = -1, detailLevel = 0 }); layers.Add(new StaticPoiLayer { name = "background", visible = false, category = -1, detailLevel = 0 }); break; case XMapMode.Town: // only labels profile = "ajax-fg"; break; case XMapMode.Custom: // no base layer profile = "ajax-fg"; layers.Add(new StaticPoiLayer { name = "town", visible = false, category = -1, detailLevel = 0 }); layers.Add(new StaticPoiLayer { name = "street", visible = false, category = -1, detailLevel = 0 }); layers.Add(new StaticPoiLayer { name = "background", visible = false, category = -1, detailLevel = 0 }); break; case XMapMode.Background: // only streets and polygons profile = "ajax-bg"; layers.Add(new StaticPoiLayer { name = "town", visible = false, category = -1, detailLevel = 0 }); break; } // add custom xmap layers if (CustomXMapLayers != null) { // remove layers in the local 'layers' which are also defined as custom layers... foreach (var customXMapLayers in CustomXMapLayers) { var xMapLayers = customXMapLayers; // Temporary variable needed for solving closure issues in the next code line foreach (var layer in layers.Where(layer => layer.GetType() == xMapLayers.GetType() && layer.name == xMapLayers.name)) { layers.Remove(layer); break; } } layers.AddRange(CustomXMapLayers); } if (!string.IsNullOrEmpty(CustomProfile)) { profile = CustomProfile; } var callerContextProps = new List <CallerContextProperty> { new CallerContextProperty { key = "CoordFormat", value = "PTV_MERCATOR" }, new CallerContextProperty { key = "Profile", value = profile } }; if (CustomCallerContextProperties != null) { callerContextProps.AddRange(CustomCallerContextProperties); } if (!string.IsNullOrEmpty(ContextKey)) { callerContextProps.Add(new CallerContextProperty { key = "ContextKey", value = ContextKey }); } var cc = new CallerContext { wrappedProperties = callerContextProps.ToArray() }; if (ReferenceTime.HasValue) { mapParams.referenceTime = ReferenceTime.Value.ToString("o"); } service.Timeout = 8000; var map = service.renderMapBoundingBox(bbox, mapParams, imageInfo, layers.ToArray(), true, cc); #if DEBUG if (!BoundingBoxesAreEqual(bbox, map.visibleSection.boundingBox)) { IssueBoundingBoxWarning(bbox, map.visibleSection.boundingBox, width, height, profile); } #endif mapObjects = map.wrappedObjects? .Select(objects => objects.wrappedObjects?.Select(layerObject => new XMap1MapObject(objects, layerObject))) .Where(objects => objects != null && objects.Any()) .SelectMany(objects => objects) .ToArray(); return(map.image.rawImage); } }
public static void Init() { using (var db = new CallerContext()) { if (db.SystemConfigs.Count() == 0) { SystemConfig config = new SystemConfig { Code = (int)SystemConfigType.系統模式, Name = SystemConfigType.系統模式.ToString(), Value = string.Empty }; db.SystemConfigs.Add(config); config = new SystemConfig { Code = (int)SystemConfigType.伺服器位置, Name = SystemConfigType.伺服器位置.ToString(), Value = string.Empty }; db.SystemConfigs.Add(config); config = new SystemConfig { Code = (int)SystemConfigType.伺服器位置連接埠, Name = SystemConfigType.伺服器位置連接埠.ToString(), Value = string.Empty }; db.SystemConfigs.Add(config); config = new SystemConfig { Code = (int)SystemConfigType.MQTT位置, Name = SystemConfigType.MQTT位置.ToString(), Value = string.Empty }; db.SystemConfigs.Add(config); config = new SystemConfig { Code = (int)SystemConfigType.MQTT位置連接埠, Name = SystemConfigType.MQTT位置連接埠.ToString(), Value = string.Empty }; db.SystemConfigs.Add(config); config = new SystemConfig { Code = (int)SystemConfigType.務站, Name = SystemConfigType.務站.ToString(), Value = string.Empty }; db.SystemConfigs.Add(config); config = new SystemConfig { Code = (int)SystemConfigType.取號機, Name = SystemConfigType.取號機.ToString(), Value = string.Empty }; db.SystemConfigs.Add(config); config = new SystemConfig { Code = (int)SystemConfigType.櫃台, Name = SystemConfigType.櫃台.ToString(), Value = string.Empty }; db.SystemConfigs.Add(config); config = new SystemConfig { Code = (int)SystemConfigType.取號機程式位置, Name = SystemConfigType.取號機程式位置.ToString(), Value = string.Empty }; db.SystemConfigs.Add(config); config = new SystemConfig { Code = (int)SystemConfigType.於取號時啟用印表機列印, Name = SystemConfigType.於取號時啟用印表機列印.ToString(), Value = string.Empty }; db.SystemConfigs.Add(config); config = new SystemConfig { Code = (int)SystemConfigType.印表機名稱, Name = SystemConfigType.印表機名稱.ToString(), Value = string.Empty }; db.SystemConfigs.Add(config); config = new SystemConfig { Code = (int)SystemConfigType.登入帳號, Name = SystemConfigType.登入帳號.ToString(), Value = string.Empty }; db.SystemConfigs.Add(config); config = new SystemConfig { Code = (int)SystemConfigType.登入密碼, Name = SystemConfigType.登入密碼.ToString(), Value = string.Empty }; db.SystemConfigs.Add(config); config = new SystemConfig { Code = (int)SystemConfigType.自動登入, Name = SystemConfigType.自動登入.ToString(), Value = false.ToString() }; db.SystemConfigs.Add(config); config = new SystemConfig { Code = (int)SystemConfigType.於Windows開機時自動啟動, Name = SystemConfigType.於Windows開機時自動啟動.ToString(), Value = false.ToString() }; db.SystemConfigs.Add(config); config = new SystemConfig { Code = (int)SystemConfigType.轉換業務優先, Name = SystemConfigType.轉換業務優先.ToString(), Value = false.ToString() }; db.SystemConfigs.Add(config); config = new SystemConfig { Code = (int)SystemConfigType.LED主機偵聽ComPort, Name = SystemConfigType.LED主機偵聽ComPort.ToString(), Value = string.Empty }; db.SystemConfigs.Add(config); config = new SystemConfig { Code = (int)SystemConfigType.LED主機發送ComPort, Name = SystemConfigType.LED主機發送ComPort.ToString(), Value = string.Empty }; db.SystemConfigs.Add(config); config = new SystemConfig { Code = (int)SystemConfigType.啟用LED功能, Name = SystemConfigType.啟用LED功能.ToString(), Value = false.ToString() }; db.SystemConfigs.Add(config); config = new SystemConfig { Code = (int)SystemConfigType.排班資料系統編號, Name = SystemConfigType.排班資料系統編號.ToString(), Value = string.Empty }; db.SystemConfigs.Add(config); config = new SystemConfig { Code = (int)SystemConfigType.護理人員系統編號, Name = SystemConfigType.護理人員系統編號.ToString(), Value = string.Empty }; db.SystemConfigs.Add(config); config = new SystemConfig { Code = (int)SystemConfigType.醫師名稱, Name = SystemConfigType.醫師名稱.ToString(), Value = string.Empty }; db.SystemConfigs.Add(config); config = new SystemConfig { Code = (int)SystemConfigType.醫師英文名稱, Name = SystemConfigType.醫師英文名稱.ToString(), Value = string.Empty }; db.SystemConfigs.Add(config); config = new SystemConfig { Code = (int)SystemConfigType.護理人員名稱, Name = SystemConfigType.護理人員名稱.ToString(), Value = string.Empty }; db.SystemConfigs.Add(config); config = new SystemConfig { Code = (int)SystemConfigType.護理人員英文名稱, Name = SystemConfigType.護理人員英文名稱.ToString(), Value = string.Empty }; db.SystemConfigs.Add(config); db.SaveChanges(); } } }
private void DealerSearch(System.Windows.Point point) { Cursor = Cursors.Wait; mapControl.SetMapLocation(point, 12, srid); reachableObjectLayer.Shapes.Clear(); isochroneLayer.Shapes.Clear(); var waypoint = new WaypointDesc() { linkType = LinkType.NEXT_SEGMENT, wrappedCoords = new XRoute.Point[] { new XRoute.Point() { point = new PlainPoint() { x = point.X, y = point.Y, }, }, }, }; var expansionDesc = new ExpansionDescription() { expansionType = ExpansionType.EXP_TIME, wrappedHorizons = new int[] { 900 }, }; var options = new ReachableObjectsOptions() { expansionDesc = expansionDesc, linkType = LinkType.NEXT_SEGMENT, routingDirection = RoutingDirectionType.FORWARD, geodatasourceLayer = XDealerSample.Properties.Settings.Default.GeoDataSource, }; var cc = new CallerContext() { wrappedProperties = new CallerContextProperty[] { new CallerContextProperty() { key = "CoordFormat", value = "PTV_MERCATOR" }, new CallerContextProperty() { key = "Profile", value = "carfast" }, } }; var isoOptions = new IsochroneOptions() { expansionDesc = expansionDesc, isoDetail = IsochroneDetail.POLYS_ONLY, polygonCalculationMode = PolygonCalculationMode.NODE_BASED, }; ReachableObjects foundObjects = null; Isochrone isochrone = null; using (var xRouteClient = new XRouteWSClient()) { try { foundObjects = xRouteClient.searchForReachableObjects(waypoint, null, null, options, null, cc); } catch (Exception exception) { MessageBox.Show( "Exception while searching for objects.\n\nException type: " + exception.GetType().ToString() + "\nMessage: " + exception.Message); Cursor = null; return; } try { isochrone = xRouteClient.calculateIsochrones(waypoint, null, isoOptions, cc); } catch (Exception exception) { MessageBox.Show( "Exception while calculating isochrone.\n\nException type: " + exception.GetType().ToString() + "\nMessage: " + exception.Message); Cursor = null; return; } } foreach (var foundObject in foundObjects.wrappedReachableObject) { var ball = new Ball() { Height = 10, Width = 10, Tag = [email protected], ToolTip = "", Color = Colors.Blue, }; ball.ToolTipOpening += ball_ToolTipOpening; var winPoint = new System.Windows.Point() { X = [email protected], Y = [email protected], }; ShapeCanvas.SetLocation(ball, winPoint); reachableObjectLayer.Shapes.Add(ball); } var linearRing = new NetTopologySuite.Geometries.LinearRing( isochrone.wrappedIsochrones[0].polys.lineString.wrappedPoints .Select(p => new GeoAPI.Geometries.Coordinate(p.x, p.y)) .ToArray() ); linearRing.Normalize(); var geom = new NetTopologySuite.Geometries.Polygon(linearRing); var bufferedGeom = geom.Buffer(100); var polygon = new MapPolygon() { Points = new PointCollection(bufferedGeom.Boundary.Coordinates.Select(c => new System.Windows.Point(c.X, c.Y))), Fill = new SolidColorBrush(Colors.AliceBlue), Opacity = 0.75, Stroke = new SolidColorBrush(Colors.DarkSlateGray) }; isochroneLayer.Shapes.Add(polygon); Cursor = null; }