public virtual bool IsConnected(Party party, ConnectionProfile connectionProfile) { bool isConnected = false; if (party != null) { switch (connectionProfile) { case ConnectionProfile.Client: isConnected = GetConnectedParties().Values.Contains(party); break; case ConnectionProfile.Owner: isConnected = GetConnectedParties().Keys.Contains(party); break; case ConnectionProfile.Any: isConnected = (GetConnectedParties().Values.Contains(party) || GetConnectedParties().Keys.Contains(party)); break; default: break; } } return(isConnected); }
/// <summary>Snippet for CreateConnectionProfile</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void CreateConnectionProfileRequestObject() { // Create client DataMigrationServiceClient dataMigrationServiceClient = DataMigrationServiceClient.Create(); // Initialize request argument(s) CreateConnectionProfileRequest request = new CreateConnectionProfileRequest { ParentAsConnectionProfileName = ConnectionProfileName.FromProjectLocationConnectionProfile("[PROJECT]", "[LOCATION]", "[CONNECTION_PROFILE]"), ConnectionProfileId = "", ConnectionProfile = new ConnectionProfile(), RequestId = "", }; // Make the request Operation <ConnectionProfile, OperationMetadata> response = dataMigrationServiceClient.CreateConnectionProfile(request); // Poll until the returned long-running operation is complete Operation <ConnectionProfile, OperationMetadata> completedResponse = response.PollUntilCompleted(); // Retrieve the operation result ConnectionProfile result = completedResponse.Result; // Or get the name of the operation string operationName = response.Name; // This name can be stored, then the long-running operation retrieved later by name Operation <ConnectionProfile, OperationMetadata> retrievedResponse = dataMigrationServiceClient.PollOnceCreateConnectionProfile(operationName); // Check if the retrieved long-running operation has completed if (retrievedResponse.IsCompleted) { // If it has completed, then access the result ConnectionProfile retrievedResult = retrievedResponse.Result; } }
public virtual bool IsOnline() { // Whether we have internet connectivity or not ConnectionProfile profile = NetworkInformation.GetInternetConnectionProfile(); return(profile != null && profile.GetNetworkConnectivityLevel() >= NetworkConnectivityLevel.InternetAccess); }
private async void onLaunch() { ConnectionProfile InternetConnectionProfile = NetworkInformation.GetInternetConnectionProfile(); if (InternetConnectionProfile != null) { // there is a connection available to something var network = InternetConnectionProfile.GetNetworkConnectivityLevel(); switch (network) { case NetworkConnectivityLevel.ConstrainedInternetAccess: notConnectedToInternet(); break; case NetworkConnectivityLevel.InternetAccess: if (await checkInternetConnectivity()) { connectedToInternet(); } else { notConnectedToInternet(); } connectedToInternet(); break; case NetworkConnectivityLevel.LocalAccess: break; case NetworkConnectivityLevel.None: break; } } else { //connectivityMaker.Text = "You are connected to: something or nothing, but not to Internet"; notConnectedToInternet(); } }
public void RetrieveNetworkStatus() { try { ConnectionProfile connectionProfile = Windows.Networking.Connectivity.NetworkInformation.GetInternetConnectionProfile(); if (connectionProfile != null) { switch (connectionProfile.NetworkAdapter.IanaInterfaceType) { case 71: case 6: this.NetworkStatus = NetworkStatus.WiFi; break; default: if (connectionProfile.GetConnectionCost().ApproachingDataLimit || connectionProfile.GetConnectionCost().OverDataLimit || connectionProfile.GetConnectionCost().Roaming) { this.NetworkStatus = NetworkStatus.MobileRestricted; break; } this.NetworkStatus = NetworkStatus.MobileUnrestricted; break; } } else { this.NetworkStatus = NetworkStatus.None; } } catch (Exception ex) { Logger.Instance.Error("Cannot retrieve network status", ex); } }
private bool IsInternetConnected() { ConnectionProfile connections = NetworkInformation.GetInternetConnectionProfile(); bool internet = (connections != null) && (connections.GetNetworkConnectivityLevel() == NetworkConnectivityLevel.InternetAccess); return(internet); }
private static bool IsInternetAvailable() { ConnectionProfile internetConnectionProfile = NetworkInformation.GetInternetConnectionProfile(); NetworkInformation.NetworkStatusChanged += NetworkInformation_NetworkStatusChanged; return(internetConnectionProfile != null && internetConnectionProfile.GetNetworkConnectivityLevel() == NetworkConnectivityLevel.InternetAccess); }
public static bool IsInternet() { ConnectionProfile connections = NetworkInformation.GetInternetConnectionProfile(); bool internet = connections != null && connections.GetNetworkConnectivityLevel() == NetworkConnectivityLevel.InternetAccess; return(internet); }
private void CheckInternetConnectivity() { ConnectionProfile InternetConnectionProfile = NetworkInformation.GetInternetConnectionProfile(); if (InternetConnectionProfile == null) { _networkStatus = NetworkStatus.NotReachable; } else { switch (InternetConnectionProfile.GetNetworkConnectivityLevel()) { case NetworkConnectivityLevel.None: case NetworkConnectivityLevel.ConstrainedInternetAccess: case NetworkConnectivityLevel.LocalAccess: _networkStatus = NetworkStatus.NotReachable; break; case NetworkConnectivityLevel.InternetAccess: if (InternetConnectionProfile.IsWlanConnectionProfile) { _networkStatus = NetworkStatus.ReachableViaWiFiNetwork; } else { _networkStatus = NetworkStatus.ReachableViaCarrierDataNetwork; } break; } } }
// // Event handler for Network Status Change event // async void OnNetworkStatusChange(object sender) { string connectionProfileInfo = string.Empty; //network status changed internetProfileInfo = "Network Status Changed: \n\r"; try { // get the ConnectionProfile that is currently used to connect to the Internet ConnectionProfile InternetConnectionProfile = NetworkInformation.GetInternetConnectionProfile(); if (InternetConnectionProfile == null) { await _cd.RunAsync(CoreDispatcherPriority.Normal, () => { rootPage.NotifyUser("Not connected to Internet\n", NotifyType.StatusMessage); }); } else { connectionProfileInfo = GetConnectionProfile(InternetConnectionProfile); await _cd.RunAsync(CoreDispatcherPriority.Normal, () => { rootPage.NotifyUser(connectionProfileInfo, NotifyType.StatusMessage); }); } internetProfileInfo = ""; } catch (Exception ex) { rootPage.NotifyUser("Unexpected exception occurred: " + ex.ToString(), NotifyType.ErrorMessage); } }
private static void ParseConfigurationSettings(AdoDataConnection connection, int deviceID, int profileTaskID) { TableOperations <Device> deviceTable = new TableOperations <Device>(connection); Device device = deviceTable.QueryRecordWhere("ID = {0}", deviceID); Dictionary <string, string> deviceConnectionString = device.ConnectionString.ParseKeyValuePairs(); TableOperations <ConnectionProfile> profileTable = new TableOperations <ConnectionProfile>(connection); ConnectionProfile profile = profileTable.QueryRecordWhere("ID = {0}", deviceConnectionString["connectionProfileID"]); TableOperations <ConnectionProfileTask> profileTaskTable = new TableOperations <ConnectionProfileTask>(connection); profileTaskTable.RootQueryRestriction[0] = profile.ID; ConnectionProfileTask profileTask = profileTaskTable.QueryRecordWhere("ID = {0}", profileTaskID); ConnectionProfileTaskSettings profileTaskSettings = profileTask.Settings; s_baseUrl = deviceConnectionString["baseURL"]; s_serialNumber = deviceConnectionString["serialNumber"]; s_getLocalPath = startTime => { string subFolder = GetSubFolder(device, profile.Name, profileTaskSettings.DirectoryNamingExpression, startTime); return($"{profileTaskSettings.LocalPath}{Path.DirectorySeparatorChar}{subFolder}"); }; }
public HTransportManager(HTransport tranpsport) { this.Transport = tranpsport; this.Transport.onData += Transport_onData; this.Transport.onStatus += Transport_onStatus; ConnectionProfile internetConnectProfile = NetworkInformation.GetInternetConnectionProfile(); if (internetConnectProfile == null) { this.hasNetwork = false; } else { switch (internetConnectProfile.GetNetworkConnectivityLevel()) { case NetworkConnectivityLevel.None: this.hasNetwork = false; break; case NetworkConnectivityLevel.LocalAccess: case NetworkConnectivityLevel.InternetAccess: case NetworkConnectivityLevel.ConstrainedInternetAccess: this.hasNetwork = true; break; } } networkStatusChangedCallback = new NetworkStatusChangedEventHandler(OnNetworkStatusChanged); if (!registeredNetworkStatusNotif) { NetworkInformation.NetworkStatusChanged += networkStatusChangedCallback; registeredNetworkStatusNotif = true; } }
/// <summary> /// Gets the network type. /// </summary> /// <returns>The discovered network type.</returns> public virtual int GetNetworkType() { if (this.networkType.HasValue == true) { return(this.networkType.Value); } ConnectionProfile profile = NetworkInformation.GetInternetConnectionProfile(); try { if (profile == null || profile.NetworkAdapter == null || profile.GetNetworkConnectivityLevel() == NetworkConnectivityLevel.None) { this.networkType = 0; return(0); } } catch (Exception) { // Note: GetNetworkConnectivityLevel() is not supported on WP 8.0 } this.networkType = (int)profile.NetworkAdapter.IanaInterfaceType; return(this.networkType.Value); }
/// <summary> /// Invoked when this page is about to be displayed in a Frame. /// </summary> /// <param name="e">Event data that describes how this page was reached. The Parameter /// property is typically used to configure the page.</param> protected override void OnNavigatedTo(NavigationEventArgs e) { InternetConnectionProfile = NetworkInformation.GetInternetConnectionProfile(); NetworkUsageStates = new NetworkUsageStates(); StartTimePicker.Time -= TimeSpan.FromHours(1); }
private async void OnNetworkStatusChanged(object sender) { ConnectionProfile internetConnectProfile = NetworkInformation.GetInternetConnectionProfile(); if (internetConnectProfile == null) { this.hasNetwork = false; } else { switch (internetConnectProfile.GetNetworkConnectivityLevel()) { case NetworkConnectivityLevel.None: this.hasNetwork = false; break; case NetworkConnectivityLevel.LocalAccess: case NetworkConnectivityLevel.InternetAccess: case NetworkConnectivityLevel.ConstrainedInternetAccess: this.hasNetwork = true; await ThreadPool.RunAsync(TryToConnectDisconnect, WorkItemPriority.High); break; } } }
private void NetworkInformation_NetworkStatusChanged(object sender) { ConnectionProfile internetConnectionProfile = NetworkInformation.GetInternetConnectionProfile(); if (internetConnectionProfile == null) { // No connection _internetConnected = false; _internetThrottled = false; } else { var connectionCost = internetConnectionProfile.GetConnectionCost(); var connectionLevel = internetConnectionProfile.GetNetworkConnectivityLevel(); if (connectionLevel != NetworkConnectivityLevel.InternetAccess) { // No connection _internetConnected = false; _internetThrottled = false; } else if (connectionCost.Roaming || connectionCost.OverDataLimit) { // Connection but throttled _internetConnected = true; _internetThrottled = true; } else { // Full connection _internetConnected = true; _internetThrottled = false; } } }
protected User connect() { // ReSharper disable ConditionIsAlwaysTrueOrFalse // ReSharper disable CSharpWarnings::CS0162 // ReSharper disable HeuristicUnreachableCode if (!TestProperties.RunDatabaseTests) { Assert.Ignore(); } // ReSharper restore HeuristicUnreachableCode // ReSharper restore CSharpWarnings::CS0162 // ReSharper restore ConditionIsAlwaysTrueOrFalse var profile = new ConnectionProfile { Server = TestProperties.Server, Database = TestProperties.Database, IntegratedSecurity = false }; var user = new User(TestProperties.Username, TestProperties.Password, profile); string message; if (!user.Authenticate(out message)) { Assert.Fail("Failed to authenticate: " + message); } return(user); }
private async void Button_Click(object sender, RoutedEventArgs e) { bool ipV4 = false, ipV6 = false; ConnectionProfile internetProfile = NetworkInformation.GetInternetConnectionProfile(); Profiles.Clear(); Profiles.Add("Internet profile: " + internetProfile.ProfileName); var hostNames = NetworkInformation.GetHostNames() .Where(h => h.IPInformation != null && h.IPInformation.NetworkAdapter != null); foreach (HostName hostName in hostNames) { ConnectionProfile hostConnectedProfile = await hostName.IPInformation.NetworkAdapter.GetConnectedProfileAsync(); if (hostConnectedProfile.NetworkAdapter.NetworkAdapterId == internetProfile.NetworkAdapter.NetworkAdapterId) { Profiles.Add("Host adapter: " + hostName.DisplayName); if (hostName.Type == HostNameType.Ipv4) { ipV4 = true; } else if (hostName.Type == HostNameType.Ipv6) { ipV6 = true; } } } IpV4 = ipV4; IpV6 = ipV6; }
/// <summary>Snippet for CreateConnectionProfile</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void CreateConnectionProfile() { // Create client DataMigrationServiceClient dataMigrationServiceClient = DataMigrationServiceClient.Create(); // Initialize request argument(s) string parent = "projects/[PROJECT]/locations/[LOCATION]/connectionProfiles/[CONNECTION_PROFILE]"; ConnectionProfile connectionProfile = new ConnectionProfile(); string connectionProfileId = ""; // Make the request Operation <ConnectionProfile, OperationMetadata> response = dataMigrationServiceClient.CreateConnectionProfile(parent, connectionProfile, connectionProfileId); // Poll until the returned long-running operation is complete Operation <ConnectionProfile, OperationMetadata> completedResponse = response.PollUntilCompleted(); // Retrieve the operation result ConnectionProfile result = completedResponse.Result; // Or get the name of the operation string operationName = response.Name; // This name can be stored, then the long-running operation retrieved later by name Operation <ConnectionProfile, OperationMetadata> retrievedResponse = dataMigrationServiceClient.PollOnceCreateConnectionProfile(operationName); // Check if the retrieved long-running operation has completed if (retrievedResponse.IsCompleted) { // If it has completed, then access the result ConnectionProfile retrievedResult = retrievedResponse.Result; } }
public ItemsPage() { this.InitializeComponent(); ConnectionProfile profile = NetworkInformation.GetInternetConnectionProfile(); if (NetworkCheckHelper.CheckNetwork() == false) { //断网 this.Frame.Navigate(typeof(NoNetworkPage)); return; } else { if (Secret.Count == 0) { try { AddAllItems(); } catch { AddAllItems(); } } } }
public void Run(IBackgroundTaskInstance taskInstance) { Debug.WriteLine("Background " + taskInstance.Task.Name + " Starting..."); taskInstance.Canceled += new BackgroundTaskCanceledEventHandler(OnCanceled); _deferral = taskInstance.GetDeferral(); ConnectionProfile InternetConnectionProfile = NetworkInformation.GetInternetConnectionProfile(); var settings = Windows.Storage.ApplicationData.Current.LocalSettings; var status = ""; switch (InternetConnectionProfile.GetNetworkConnectivityLevel()) { case NetworkConnectivityLevel.None: status = "無連線"; break; case NetworkConnectivityLevel.LocalAccess: status = "本地連線"; break; case NetworkConnectivityLevel.ConstrainedInternetAccess: status = "受限的連線"; break; case NetworkConnectivityLevel.InternetAccess: status = "網際網路連線"; break; } settings.Values["NetworkStatus"] = status; _deferral.Complete(); }
/// <summary> /// This is the click handler for the 'InternetConnectionProfileButton' button. You would replace this with your own handler /// if you have a button or buttons on this page. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void InternetConnectionProfile_Click(object sender, RoutedEventArgs e) { // //Get Internet Connected Profile Information // string connectionProfileInfo = string.Empty; try { ConnectionProfile InternetConnectionProfile = NetworkInformation.GetInternetConnectionProfile(); if (InternetConnectionProfile == null) { rootPage.NotifyUser("Not connected to Internet\n", NotifyType.StatusMessage); } else { connectionProfileInfo = GetConnectionProfile(InternetConnectionProfile); OutputText.Text = connectionProfileInfo; rootPage.NotifyUser("Success", NotifyType.StatusMessage); } } catch (Exception ex) { rootPage.NotifyUser("Unexpected exception occurred: " + ex.ToString(), NotifyType.ErrorMessage); } }
private async Task LoadFilmDetails() { this.gFilmInfo.Visibility = Windows.UI.Xaml.Visibility.Visible; ConnectionProfile InternetConnectionProfile = NetworkInformation.GetInternetConnectionProfile(); ConnectionCost InternetConnectionCost = (InternetConnectionProfile == null ? null : InternetConnectionProfile.GetConnectionCost()); Task <YouTubeUri> tYouTube = null; if (!String.IsNullOrEmpty(SelectedFilm.YoutubeTrailer) && InternetConnectionProfile != null && InternetConnectionProfile.GetNetworkConnectivityLevel() == NetworkConnectivityLevel.InternetAccess && InternetConnectionCost != null && InternetConnectionCost.NetworkCostType == NetworkCostType.Unrestricted) { tYouTube = MyToolkit.Multimedia.YouTube.GetVideoUriAsync(SelectedFilm.YoutubeTrailer, Config.TrailerQuality); } if (tYouTube != null) { try { this.trailerUrl = await tYouTube; } catch { } } this.btnPlay.Visibility = this.btnPlayTrailer.Visibility = (trailerUrl != null ? Windows.UI.Xaml.Visibility.Visible : Windows.UI.Xaml.Visibility.Collapsed); this.mpTrailer.Visibility = Windows.UI.Xaml.Visibility.Collapsed; }
async public Task <Windows.Web.Http.HttpResponseMessage> PostAsync(Windows.Web.Http.HttpStringContent data) { try { _connectionProfile = NetworkInformation.GetInternetConnectionProfile(); NetworkInformation.NetworkStatusChanged += NetworkInformation_NetworkStatusChanged; if (_connectionProfile != null && _connectionProfile.GetNetworkConnectivityLevel() == NetworkConnectivityLevel.InternetAccess) { using (var httpClient = new HttpClient()) { httpClient.DefaultRequestHeaders.Accept.Clear(); httpClient.DefaultRequestHeaders.Accept.Add(new Windows.Web.Http.Headers.HttpMediaTypeWithQualityHeaderValue("application/json")); httpClient.DefaultRequestHeaders.Accept.Add(new Windows.Web.Http.Headers.HttpMediaTypeWithQualityHeaderValue("Content-Type: application/x-www-form-urlencoded")); var token = JsonConvert.DeserializeObject <AccessToken>(ApplicationData.Current.RoamingSettings.Values[Constants.ACCESSTOKEN].ToString()); httpClient.DefaultRequestHeaders.Authorization = new Windows.Web.Http.Headers.HttpCredentialsHeaderValue("Bearer", token.Access_Token); return(await httpClient.PostAsync(new Uri(Constants.APIURL), data)); } } else { await new MessageDialog("no network access").ShowAsync(); return(default(HttpResponseMessage)); } } catch (Exception ex) { new MessageDialog(ex.Message).ShowAsync(); return(default(HttpResponseMessage)); } }
/// <summary>Snippet for UpdateConnectionProfileAsync</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public async Task UpdateConnectionProfileAsync() { // Create client DataMigrationServiceClient dataMigrationServiceClient = await DataMigrationServiceClient.CreateAsync(); // Initialize request argument(s) ConnectionProfile connectionProfile = new ConnectionProfile(); FieldMask updateMask = new FieldMask(); // Make the request Operation <ConnectionProfile, OperationMetadata> response = await dataMigrationServiceClient.UpdateConnectionProfileAsync(connectionProfile, updateMask); // Poll until the returned long-running operation is complete Operation <ConnectionProfile, OperationMetadata> completedResponse = await response.PollUntilCompletedAsync(); // Retrieve the operation result ConnectionProfile result = completedResponse.Result; // Or get the name of the operation string operationName = response.Name; // This name can be stored, then the long-running operation retrieved later by name Operation <ConnectionProfile, OperationMetadata> retrievedResponse = await dataMigrationServiceClient.PollOnceUpdateConnectionProfileAsync(operationName); // Check if the retrieved long-running operation has completed if (retrievedResponse.IsCompleted) { // If it has completed, then access the result ConnectionProfile retrievedResult = retrievedResponse.Result; } }
private async void NetworkStatusChange(object sender) { ConnectionProfile profile = NetworkInformation.GetInternetConnectionProfile(); if (profile != null) { NetworkConnectivityLevel connection = profile.GetNetworkConnectivityLevel(); if (connection == NetworkConnectivityLevel.InternetAccess) { await this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { // There is an active connection QueriesButton.IsEnabled = true; }); return; } } await this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { QueriesButton.IsEnabled = false; if (SubPage.Content.GetType() == typeof(QueriesPage)) { // TODO: Inapp toast feedback NavigateSubPage(typeof(MyPage)); } }); }
private NetworkType GetNetworkType(ConnectionProfile profile) { if (profile == null) { //return new NetworkTypeNone(); return(new NetworkTypeWiFi()); } var level = profile.GetNetworkConnectivityLevel(); if (level == NetworkConnectivityLevel.LocalAccess || level == NetworkConnectivityLevel.None) { //return new NetworkTypeNone(); return(new NetworkTypeWiFi()); } var cost = profile.GetConnectionCost(); if (cost != null && cost.Roaming) { return(new NetworkTypeMobileRoaming()); } else if (profile.IsWlanConnectionProfile) { return(new NetworkTypeWiFi()); } else if (profile.IsWwanConnectionProfile) { return(new NetworkTypeMobile()); } // This is most likely cable connection. //return new NetworkTypeOther(); return(new NetworkTypeWiFi()); }
public void Run(IBackgroundTaskInstance taskInstance) { BackgroundTaskDeferral deferral = taskInstance.GetDeferral(); ConnectionProfile connectionProfile = NetworkInformation.GetInternetConnectionProfile(); if (connectionProfile != null && connectionProfile.ProfileName == "DLUT") { ApplicationDataContainer _appSettings = ApplicationData.Current.LocalSettings; if (_appSettings.Values.ContainsKey("username")) { string name = _appSettings.Values["username"].ToString(); string password = _appSettings.Values["password"].ToString(); if (_appSettings.Values.ContainsKey("notification") && (bool)_appSettings.Values["notification"]) { SendNotification("DLUT已连接,用户名:" + connectionProfile.GetNetworkConnectivityLevel().ToString()); } PostTheData(name, password); } else { SendNotification("请完善用户资料以方便连接,否则关闭后台"); } } deferral.Complete(); }
/// <summary>Snippet for CreateConnectionProfileAsync</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public async Task CreateConnectionProfileResourceNamesAsync() { // Create client DataMigrationServiceClient dataMigrationServiceClient = await DataMigrationServiceClient.CreateAsync(); // Initialize request argument(s) ConnectionProfileName parent = ConnectionProfileName.FromProjectLocationConnectionProfile("[PROJECT]", "[LOCATION]", "[CONNECTION_PROFILE]"); ConnectionProfile connectionProfile = new ConnectionProfile(); string connectionProfileId = ""; // Make the request Operation <ConnectionProfile, OperationMetadata> response = await dataMigrationServiceClient.CreateConnectionProfileAsync(parent, connectionProfile, connectionProfileId); // Poll until the returned long-running operation is complete Operation <ConnectionProfile, OperationMetadata> completedResponse = await response.PollUntilCompletedAsync(); // Retrieve the operation result ConnectionProfile result = completedResponse.Result; // Or get the name of the operation string operationName = response.Name; // This name can be stored, then the long-running operation retrieved later by name Operation <ConnectionProfile, OperationMetadata> retrievedResponse = await dataMigrationServiceClient.PollOnceCreateConnectionProfileAsync(operationName); // Check if the retrieved long-running operation has completed if (retrievedResponse.IsCompleted) { // If it has completed, then access the result ConnectionProfile retrievedResult = retrievedResponse.Result; } }
private void DoLogin() { ConnectionProfile profile = cmbProfile.SelectedItem as ConnectionProfile; if (profile == null) { ErrorMessage("LoginControl.Status.SelectProfile"); return; } Config.SetGlobal("connection.lastprofile", profile.Name); btnCancel.Visibility = Visibility.Hidden; btnLogin.Visibility = Visibility.Hidden; txtUsername.IsEnabled = false; txtPassword.IsEnabled = false; cmbProfile.IsEnabled = false; User user = new User(txtUsername.Text, txtPassword.Password, profile); // Save the last username... profile.LastUser = user.Username; Config.SetGlobal("connection.profiles", _profiles); string format = FindResource("LoginControl.Status.Connecting") as string; lblStatus.Content = String.Format(format, profile.Server); try { detailsGrid.IsEnabled = false; LoginAsync(user, () => { this.InvokeIfRequired(() => { detailsGrid.IsEnabled = true; RaiseEvent(new LoginSuccessfulEventArgs(LoginControl.LoginSuccessfulEvent, user)); }); }, (errorMsg) => { this.InvokeIfRequired(() => { bool authenticate = !profile.IntegratedSecurity && profile.ConnectionType != ConnectionType.Standalone; detailsGrid.IsEnabled = true; btnCancel.Visibility = Visibility.Visible; btnLogin.Visibility = Visibility.Visible; txtUsername.IsEnabled = authenticate; txtPassword.IsEnabled = authenticate; cmbProfile.IsEnabled = true; if (authenticate) { txtPassword.Focus(); txtPassword.SelectAll(); } ErrorMessage("LoginControl.Status.LoginFailed", errorMsg); }); } ); } finally { detailsGrid.IsEnabled = true; } }
public void Add(ConnectionProfile profile) { var existingProfile = Get(profile.Tag); if (existingProfile != null) { int index = Profiles.IndexOf(existingProfile); Profiles.Remove(existingProfile); Profiles.Insert(index, profile); } else { Profiles.Add(profile); } }
public ProfileManager(string path) { Profiles = new List<ConnectionProfile>(); filePath = path + "\\credential.xml"; if (File.Exists(filePath)) { var document = new XmlDocument(); document.LoadXml(File.ReadAllText(filePath)); foreach (XmlNode node in document.GetElementsByTagName("string")) { var profile = new ConnectionProfile(node as XmlElement); Profiles.Add(profile); } } }
public void Reload() { Profiles = new List<ConnectionProfile>(); if (File.Exists(filePath)) { var document = new XmlDocument(); document.LoadXml(File.ReadAllText(filePath)); foreach (XmlNode node in document.GetElementsByTagName("string")) { var profile = new ConnectionProfile(node as XmlElement); Profiles.Add(profile); } } }
public static object InsertInto(this object o, string table, ConnectionProfile connectionProfile = null) { if (connectionProfile == null) connectionProfile = new ConnectionProfile(); DynamicRepository dynamicModel = new DynamicRepository(connectionProfile, table, "Id"); return dynamicModel.Insert(o); }
void before_each() { connectionProfile = new ConnectionProfile { ConnectionString = "" }; seed = new Seed(connectionProfile); }
private void configureConnectionnProfile(ConnectionProfile profile) { profile.AsyncReplay = supAsyncReplay; profile.ServerName = supInternetServerName; profile.PortNumber = supInternetPort; profile.NetworkProtocol = supNetworkProtocol; //connProfile.setProperty("databaseFile", fileNameDB); profile.EncryptionKey = encriptionKey; profile.CacheSize = cacheSize; profile.Save(); // Save to file }
public void connectRepositorySqlAuth(ConnectionProfile repo, string user, string password) { if (repo != null) { if (user != null && password != null) { _userName = user; Repository = new MS_SqlServerIPSerializer(user, password, repo.IPAddress, repo.Port, repo.InitialCatalog, string.Format(REPOSITORY_PREFIX, repo.InitialCatalog)); Definitions = new MS_SqlServerIPSerializer(user, password, repo.IPAddress, repo.Port, repo.TaxonNamesInitialCatalog, string.Format(REPOSITORY_PREFIX, repo.TaxonNamesInitialCatalog)); Synchronization = new MS_SqlServerIPSerializer(user, password, repo.IPAddress, repo.Port, SYNCDB_CATALOG, string.Format(SYNCDB_PREFIX, SYNCDB_CATALOG)); connectRepository(repo); } else _Log.Info("Login Credentials incomplete"); } else _Log.Info("No Connection Configured"); }
private void connectRepository(ConnectionProfile repo) { //Verbindung zum Repository herstellen try { Repository.RegisterTypes(divMobiTypes()); Repository.RegisterType(typeof(UserProxy)); Repository.Activate(); try { String syncIt = "[" + _userName + "].SyncItem"; String fieldSt = "[" + _userName + "].FieldState"; if(!MappingDictionary.Mapping.ContainsKey(typeof(SyncItem))) MappingDictionary.Mapping.Add(typeof(SyncItem), syncIt); if (!MappingDictionary.Mapping.ContainsKey(typeof(FieldState))) MappingDictionary.Mapping.Add(typeof(FieldState), fieldSt); Synchronization.RegisterType(typeof(SyncItem)); Synchronization.RegisterType(typeof(FieldState)); Synchronization.Activate(); } catch// (Exception syncDBEx) { Synchronization = null; MappingDictionary.Mapping.Clear(); } try { //Taxon Serializer erstellen Definitions.RegisterType(typeof(TaxonNames)); Definitions.RegisterType(typeof(PropertyNames)); } catch //(Exception repTaxEx) { Definitions = null; } } catch// (Exception repositoryEx) { Repository = null; } var state = State; if (Repository != null) state |= ConnectionState.ConnectedToRepository; if (Definitions != null) state |= ConnectionState.ConnectedToRepTax; if (Synchronization != null) state |= ConnectionState.ConnectedToSynchronization; State = state; }
public void connectRepositoryWinAuth(ConnectionProfile repo) { if (repo != null) { _userName = Environment.UserName; Repository = new MS_SqlServerWASerializier(repo.IPAddress + "," + repo.Port, repo.InitialCatalog, string.Format(REPOSITORY_PREFIX, repo.InitialCatalog)); Definitions = new MS_SqlServerWASerializier(repo.IPAddress + "," + repo.Port, repo.TaxonNamesInitialCatalog, string.Format(REPOSITORY_PREFIX, repo.TaxonNamesInitialCatalog)); Synchronization = new MS_SqlServerWASerializier(repo.IPAddress + "," + repo.Port, SYNCDB_CATALOG, string.Format(SYNCDB_PREFIX, SYNCDB_CATALOG)); connectRepository(repo); } else _Log.Info("No Connection Configured"); }