public static void SaveUserMaps(UserMaps usrMaps) { try { string sql = "delete from user_maps where user_guid='" + usrMaps.User + "'"; using (NpgsqlConnection connection = new NpgsqlConnection(strPostGISConnection)) { connection.Open(); using (NpgsqlCommand command = new NpgsqlCommand(sql, connection)) { int rows = command.ExecuteNonQuery(); } int n = 0; foreach (UserMapPreference map in usrMaps.maps) { n++; sql = "insert into user_maps values('" + usrMaps.User + "','" + n.ToString() + "','" + map.MapName + "'," + map.MinZoom.ToString() + "," + map.MaxZoom.ToString() + "," + "0,0)"; using (NpgsqlCommand command = new NpgsqlCommand(sql, connection)) { int rows = command.ExecuteNonQuery(); } } } } catch (Exception ex) { } }
public async void AddUserMaps(View view) { if (client == null || string.IsNullOrWhiteSpace(textNewToDo.Text)) { return; } // Create a new item var usermap = new UserMaps { //Text = textNewToDo.Text //add collum = value //for each collumn //leave complete it is nessecary for the localdb Complete = false }; try { await usermapsTable.InsertAsync(usermap); // insert the new item into the local database await SyncAsync(); // send changes to the mobile service if (!usermap.Complete) { adapter.Add(usermap); } } catch (Exception e) { CreateAndShowDialog(e, "Error"); } //textNewToDo.Text = ""; }
public static void SaveUserMaps(UserMaps usrMaps) { try { string sql = "delete from user_maps where user_guid='" + usrMaps.User + "'"; using (NpgsqlConnection connection = new NpgsqlConnection(strPostGISConnection)) { connection.Open(); using (NpgsqlCommand command = new NpgsqlCommand(sql, connection)) { int rows = command.ExecuteNonQuery(); } int n = 0; foreach (UserMapPreference map in usrMaps.maps) { n++; sql = "insert into user_maps values('" + usrMaps.User + "','" + n.ToString() + "','" + map.MapName + "'," + map.MinZoom.ToString()+"," + map.MaxZoom.ToString()+","+"0,0)"; using (NpgsqlCommand command = new NpgsqlCommand(sql, connection)) { int rows = command.ExecuteNonQuery(); } } } } catch (Exception ex) { } }
private async void cmdSaveUser_Click(object sender, RoutedEventArgs e) { ApplyNewLayout(); List <WMSProviderSelectedMaps> Maps = (List <WMSProviderSelectedMaps>)dataGridLayerName.ItemsSource; UserMaps usermaps = new UserMaps(); List <UserMapPreference> MapPreferenceList = new List <UserMapPreference>(); foreach (WMSProviderSelectedMaps SelectedMap in Maps) { if (SelectedMap.isSelected) { UserMapPreference userMapInfo = new UserMapPreference(); userMapInfo.MapName = SelectedMap.MapName; userMapInfo.MaxZoom = SelectedMap.UserMaxZoom; userMapInfo.MinZoom = SelectedMap.UserMinZoom; MapPreferenceList.Add(userMapInfo); } } usermaps.maps = MapPreferenceList.ToArray <UserMapPreference>(); usermaps.User = VMMainViewModel.Instance.UserName; // usermaps = await SAGSignalR.GetUserMaps(VMMainViewModel.Instance.SimulationHubProxy, UserName); try { if (VMMainViewModel.Instance.SimulationHubProxy != null) { await SAGSignalR.SaveUserMaps(VMMainViewModel.Instance.SimulationHubProxy, usermaps); } } catch (Exception ex) { } //MapInfo.UserMapList = usermapDictionary.Values.ToArray<UserMapLayerInfo>(); //MapList.Add(MapInfo); //if (UserSession.ClientSideObject.m_GameManagerProxy != null) //{ // UserSession.ClientSideObject.m_GameManagerProxy.SetUserMapInfoCustomProvider(MapList.ToArray<UserMapInfo>()); //} }
public async Task CheckUserMaps(UserMaps usermap) { if (client == null) { return; } // Set the item as completed and update it in the table usermap.Complete = true; try { await usermapsTable.UpdateAsync(usermap); // update the new item in the local database await SyncAsync(); // send changes to the mobile service if (usermap.Complete) { adapter.Remove(usermap); } } catch (Exception e) { CreateAndShowDialog(e, "Error"); } }
protected override void PostDeserialize() { base.PostDeserialize(); foreach (var bot in Bots) { // Link up inheritance first if (!string.IsNullOrEmpty(bot.BasedOn)) { var baseBot = Bots.FirstOrDefault(b => b.Id == bot.BasedOn); if (baseBot == null) { throw new TfsNotificationRelayException(String.Format("Unknown basedOn ({0}) for bot {1}", bot.BasedOn, bot.Id)); } bot.BaseBot = baseBot; } var text = this.Texts.FirstOrDefault(t => t.Id == bot.TextId); if (text == null) { throw new TfsNotificationRelayException(String.Format("Unknown textId ({0}) for bot {1}", bot.TextId, bot.Id)); } bot.Text = text; if (!string.IsNullOrEmpty(bot.UserMapId)) { var userMap = UserMaps.FirstOrDefault(m => m.Id == bot.UserMapId); if (userMap == null) { throw new TfsNotificationRelayException(String.Format("Unknown userMapId ({0}) for bot {1}", bot.UserMapId, bot.Id)); } bot.UserMap = userMap; } else { bot.UserMap = new UserMapElement(); } } }
public static UserMaps GetUserMaps(string userName) { try { UserMaps maps = new UserMaps(); maps.User = userName; List<UserMapPreference> MapPreferenceList = new List<UserMapPreference>(); string sql = "select * from user_maps where user_guid= '" + userName + "' Order By layer_order "; using (NpgsqlConnection connection = new NpgsqlConnection(strPostGISConnection)) using (NpgsqlDataAdapter da = new NpgsqlDataAdapter(sql, connection)) { DataSet ds = new DataSet(); DataTable dt = new DataTable(); ds.Reset(); da.Fill(ds); dt = ds.Tables[0]; foreach (DataRow row in dt.Rows) { UserMapPreference MapPreference = new UserMapPreference(); MapPreference.MapName = row["map_name"].ToString(); MapPreference.MinZoom = System.Convert.ToInt32(row["min_zoom"]); MapPreference.MaxZoom = System.Convert.ToInt32(row["max_zoom"]); MapPreferenceList.Add(MapPreference); } maps.maps = MapPreferenceList.ToArray<UserMapPreference>(); return maps; } } catch (Exception ex) { } return null; }
public static UserMaps GetUserMaps(string userName) { try { UserMaps maps = new UserMaps(); maps.User = userName; List <UserMapPreference> MapPreferenceList = new List <UserMapPreference>(); string sql = "select * from user_maps where user_guid= '" + userName + "' Order By layer_order "; using (NpgsqlConnection connection = new NpgsqlConnection(strPostGISConnection)) using (NpgsqlDataAdapter da = new NpgsqlDataAdapter(sql, connection)) { DataSet ds = new DataSet(); DataTable dt = new DataTable(); ds.Reset(); da.Fill(ds); dt = ds.Tables[0]; foreach (DataRow row in dt.Rows) { UserMapPreference MapPreference = new UserMapPreference(); MapPreference.MapName = row["map_name"].ToString(); MapPreference.MinZoom = System.Convert.ToInt32(row["min_zoom"]); MapPreference.MaxZoom = System.Convert.ToInt32(row["max_zoom"]); MapPreferenceList.Add(MapPreference); } maps.maps = MapPreferenceList.ToArray <UserMapPreference>(); return(maps); } } catch (Exception ex) { } return(null); }
public async Task <Exception> InitMapsAsync() { try { UserMaps usermaps = null; this.strWMSGeoserverUrl = ConfigurationManager.AppSettings["WMSGeoserver"]; string strMapCache_Path = ConfigurationManager.AppSettings["MapCache_Path"]; string strMapCacheEnable = ConfigurationManager.AppSettings["MapCacheEnable"]; bool MapCacheEnable = false; if (string.IsNullOrEmpty(strMapCacheEnable) == false) { if (strMapCacheEnable.ToLower() == "false") { MapCacheEnable = false; } else { MapCacheEnable = true; } } // string strWMSGeoserverUrl = ConfigurationManager.AppSettings["WMSGeoserver"]; if (string.IsNullOrEmpty(strWMSGeoserverUrl)) { return(null); } WMSCapabilities Capabilities = await WMSProviderBase.WMSCapabilitiesRetrieve(strWMSGeoserverUrl); if (Capabilities != null && Capabilities.Error == null) { List <WMSProviderBase> overlays = new List <WMSProviderBase>(); WMSProviderBase MapProvider = null; if (VMMainViewModel.Instance.SimulationHubProxy != null) { usermaps = await SAGSignalR.GetUserMaps(VMMainViewModel.Instance.SimulationHubProxy, UserName); UserParameters userParameters = await SAGSignalR.GetUserParameters(VMMainViewModel.Instance.SimulationHubProxy, UserName); if (usermaps != null) { foreach (UserMapPreference info in usermaps.maps) { if (overlays.Exists(t => t.Name == info.MapName)) { continue; } bool isExist = Capabilities.Layers.Exists(t => t.MapName == info.MapName); if (isExist) { WMSProviderBase provider = new WMSProviderBase(info.MapName); provider.Init(strWMSGeoserverUrl, info.MapName, "png"); provider.MinZoom = info.MinZoom; provider.MaxZoom = info.MaxZoom; overlays.Add(provider); if (MapProvider == null) { MapProvider = provider; } } } } if (MapProvider != null) { MapProvider.overlays = overlays.ToArray(); p_objMap.MapProvider = MapProvider; if (MapCacheEnable && string.IsNullOrEmpty(strMapCache_Path) == false) { p_objMap.Manager.Mode = AccessMode.ServerAndCache; p_objMap.CacheLocation = strMapCache_Path; } // p_objMap.Manager.Mode = AccessMode.ServerOnly; //TEMP // p_objMap.Manager.Mode = AccessMode.ServerAndCache; p_objMap.Manager.MemoryCache.Capacity = 44; p_objMap.Zoom = 10; if (userParameters != null) { p_objMap.Position = new PointLatLng(userParameters.MapHomeCenterY, userParameters.MapHomeCenterX); p_objMap.Zoom = userParameters.MapHomeZoom; } p_objMap.ShowTileGridLines = false; p_objMap.InvalidateVisual(true); } // p_objMap.enGMapProvider = enGMapProviders.WMSCustomProvider; } } return(Capabilities.Error); } catch (Exception ex) { return(ex); } return(null); }
public async void SetData() { string strWMSGeoserverUrl = ConfigurationManager.AppSettings["WMSGeoserver"]; if (string.IsNullOrEmpty(strWMSGeoserverUrl)) { return; } WMSCapabilities Capabilities = await WMSProviderBase.WMSCapabilitiesRetrieve(strWMSGeoserverUrl); List <WMSProviderSelectedMaps> HelperList = new List <WMSProviderSelectedMaps>(); if (Capabilities != null) { //List<GMap.NET.MapProviders.GMapProvider> Layers = null; // Layers = UserSession.ClientSideObject.GetGMapLayers(); UserMaps Layers = await SAGSignalR.GetUserMaps(VMMainViewModel.Instance.SimulationHubProxy, VMMainViewModel.Instance.UserName); int n = 1000; foreach (CustomImageInfo Info in Capabilities.Layers) { n++; WMSProviderSelectedMaps map = new WMSProviderSelectedMaps(); map.MapName = Info.MapName; map.isSelected = false; map.SeqNumber = n; map.UserMinZoom = 0; map.UserMaxZoom = 24; HelperList.Add(map); } if (Layers != null) { for (int i = 0; i < Layers.maps.Length; i++) { UserMapPreference layer = Layers.maps[i]; WMSProviderSelectedMaps map = HelperList.Where(l => l.MapName == layer.MapName).SingleOrDefault(); if (map != null) { map.SeqNumber = i; map.isSelected = true; map.UserMinZoom = layer.MinZoom; map.UserMaxZoom = (int)layer.MaxZoom; } } } HelperList.Sort(delegate(WMSProviderSelectedMaps Struct1, WMSProviderSelectedMaps Struct2) { int Compare = 0; if (Struct2.SeqNumber < Struct1.SeqNumber) { Compare = 1; } else if (Struct2.SeqNumber == Struct1.SeqNumber) { Compare = 0; } else { Compare = -1; } return(Compare); }); } dataGridLayerName.ItemsSource = null; dataGridLayerName.ItemsSource = HelperList; }