private bool StopInternal(bool verbose) { try { Status = WorkingStatus.Stopping; DisableSharing(true); _wlanManager.StopHostedNetwork(); #if TRACE LogExceptions.LogTrace(true, "WLanStop->Done"); #endif if (verbose) { Status = WorkingStatus.Stopped; } return(true); } catch (Exception ex) { LogExceptions.Log(ex); Status = WorkingStatus.StopFailed; return(false); } }
protected void Application_Error(object sender, EventArgs e) { Exception exc = Server.GetLastError(); Response.StatusCode = 500; Response.ContentType = "application/json"; Response.Write("An error happened. Please contact the administrator for more information."); LogExceptions.Log(exc, Request.HttpMethod, Request.Url.AbsoluteUri, ""); }
private void StartInternal() { try { StopInternal(false); Status = WorkingStatus.Starting; // system fixes SystemTweak.TweakTheSystemNotForced(); // setting the options _wlanManager.SetConnectionSettings(ConfigSsid, ConfigMaxPeers); _wlanManager.SetSecondaryKey(ConfigPassword); _wlanManager.StartHostedNetwork(); // save the network id _hostedNetworkInterfaceGuid = _wlanManager.HostedNetworkInterfaceGuid; var connection = GetIcsToShare(); if (connection != null) { ShareConnection(connection); } else { DisableSharing(true); } Status = WorkingStatus.Started; #if TRACE LogExceptions.LogTrace(true, "WLanStart completed, internet is: " + ((connection == null) ? "NULL" : connection.Name)); #endif } catch (Exception ex) { LogExceptions.Log(ex); Status = WorkingStatus.StartFailed; } }
static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e) { LogExceptions.Log(e.Exception); }
private void ShareConnection(IcsConnection icsConnection) { // disable sharing first DisableSharing(false); if (icsConnection == null) { return; } #if TRACE LogExceptions.LogTrace(true, "ShareConnection -> " + icsConnection.Name); #endif Exception failedToSharException = null; // then enabled the sharing for (int i = 1; i < 10; i++) { try { if (_wlanManager.HostedNetworkState != WLAN_HOSTED_NETWORK_STATE.wlan_hosted_network_active) { Thread.Sleep(500); continue; } var privateConnectionGuid = _wlanManager.HostedNetworkInterfaceGuid; _icsManager.EnableIcs(icsConnection.Guid, privateConnectionGuid); // the connected network guid to internet SharedConnection = icsConnection; failedToSharException = null; #if TRACE LogExceptions.LogTrace(true, "ShareConnection.EnableIcs on try no:" + i); #endif return; } catch (Exception ex) { #if DEBUG LogExceptions.Log(ex); #endif failedToSharException = ex; Thread.Sleep(500); } } // if we have reached here that means the connection is failed to share with many tries if (failedToSharException != null) { #if TRACE LogExceptions.LogTrace(true, "ShareConnection is failed -> " + icsConnection.Name, failedToSharException.ToString()); #endif RaiseOnFailedToEnableSharing(icsConnection, failedToSharException); } else { #if TRACE LogExceptions.LogTrace(true, "ShareConnection is failed -> " + icsConnection.Name); #endif } }