/// <summary> /// Initialize the login screen GUI if we have internet access. /// If not, all UI fields are set to inactive. /// </summary> public void Initialize() { // Initilize the form and fill all combo box. bool internetAvailable = NetworkUtility.IsCDNAvailable(); if (NetworkUtility.IsCDNAvailable()) { InitializeToProvider("STL Test"); InternetUnavailableGrid.Visibility = Visibility.Collapsed; } else { InternetUnavailableGrid.Visibility = Visibility.Visible; } ProviderComboBox.IsEnabled = internetAvailable; LoginCmd.IsEnabled = internetAvailable; UserNameBox.IsEnabled = internetAvailable; PasswdBox.IsEnabled = internetAvailable; TransportComboBox.IsEnabled = internetAvailable; AuthIDBox.IsEnabled = internetAvailable; OutboundProxyServerBox.IsEnabled = internetAvailable; HostPortBox.IsEnabled = internetAvailable; AutoLoginBox.IsEnabled = internetAvailable; // Controls whether or not to check the account list // cached file for current account information. _accountNotYetLoaded = true; }
public void Send() { string message = isServer ? "I am server. " + BigString() : "I am client. " + BigString(); Buffer buffer = Buffer.Create(); BinaryWriter writer = buffer.BeginPacket(Packet.Empty); writer.Write(message); buffer.EndPacket(); Debug.Log("Buffer size: " + buffer.size); if (!isReliable) { UdpProtocol.Send(buffer, NetworkUtility.ResolveEndPoint(ServerExternalIP, UDPPort)); } else { if (!isServer) { TcpProtocol.SendTcpPacket(buffer); } else { TcpProtocol.SendToClient(0, buffer); } } }
public void DownLoadData() { string[] maCks = FileUtility.ReadAllMack(); int length = maCks.Length; string startQuy = "Q" + Constants.QUY_HIEN_TAI; totalResultVndirect = new List <StringBuilder>(); for (int i = 0; i < length; i++) { string mack = maCks[i]; for (int j = 0; j < 3; j++) // Vòng for duyệt cho 3 năm { string param1 = "searchObject.fiscalQuarter=" + startQuy; string param2 = "&searchObject.fiscalYear=" + (Constants.NAM_HIEN_TAI - j); string myParameters = param1 + param2 + "& searchObject.moneyRate=1&searchObject.numberTerm=4"; string url = "https://www.vndirect.com.vn/portal/bang-can-doi-ke-toan/" + mack + ".shtml"; string resultCanDoiKeToan = NetworkUtility.SendPostRequest(url, myParameters); ReadBangCanDoiKeToan(resultCanDoiKeToan, mack); string url2 = "https://www.vndirect.com.vn/portal/bao-cao-ket-qua-kinh-doanh/" + mack + ".shtml"; string resultKQKD = NetworkUtility.SendAjaxRequestForVndirec(url2, myParameters); ReadKQKD(resultKQKD, mack); Console.WriteLine("{0}", i * 3 + j); // write result to total result for (int k = 0; k < listResult.Count; k++) { totalResultVndirect.Add(listResult[k]); } } ReportProgress(i * 100 / length); } // write result to text file FileUtility.WriteResultToTextFile(totalResultVndirect, Constants.CONTENT_RESULT_VNDIRECT_FILE_NAME); }
void Update() { if (!hasStarted) { return; } // Listen for network messages int recHostId; int connectionId; int channelId; byte[] recBuffer = new byte[1024]; int bufferSize = 1024; int dataSize; byte error; NetworkEventType recData = NetworkTransport.Receive(out recHostId, out connectionId, out channelId, recBuffer, bufferSize, out dataSize, out error); switch (recData) { case NetworkEventType.DisconnectEvent: OnNetworkDisconnectEvent(); break; case NetworkEventType.DataEvent: NetworkUtility.HandleNetworkDataEvent(recBuffer, dataSize); break; } }
/////////////// Initialize window public ConsoleWindow() { InitializeComponent(); if (!LocalUserSession.LoggedIn) { // User not logged in, display login window instead } else { // Initialize the server components nt = new NetworkUtility(commPort, null); nt.StartServer(); nt.ClientConnect += OnClientConnectedEvent; //nt.Cmd.SimUpdateEvent += OnSimUpdateEvent; //nt.CmdAdmin.SimUpdateEvent += OnSimUpdateEvent; db = new SQLiteController(); bs = db.PullBusinessSettings(); SetTheme(); systemClock = new Thread(() => RunClock()); //RunLockoutTimerThread(); consoleAreaPanel.Click += ((sender, e) => consoleAreaPanel.Focus()); UpdateUser(); contextMenuStrip1.Closed += ((sender, e) => profileVisible = false); consoleAreaPanel.SizeChanged += InitialSimDisplayLoad; systemClock.Start(); } }
bool SaveSettings() { IPAddress presenceAddress; if (!NetworkUtility.TryParseAddress(settingsVm.ConnectionSettings.PresenceAddress, out presenceAddress)) { MessageBox.Show(Translation.Instance.SettingsWindow_Error_InvalidPresenceIP, Translation.Instance.Error, MessageBoxButton.OK, MessageBoxImage.Exclamation); return(false); } settingsVm.ContactSettings.ContactListSortField = (ContactListSortField)cmbSortField.SelectedItem; settingsVm.ContactSettings.ContactListView = (ContactListView)cmbContactsView.SelectedItem; settingsVm.Update(); if (currentUser != null) { currentUser.DisplayName = settingsVm.PersonalSettings.DisplayName; currentUser.Properties.DisplayMessage = settingsVm.PersonalSettings.DisplayMessage; currentUser.Properties.DisplayImage = settingsVm.PersonalSettings.DisplayImage; currentUser.Properties.EmailAddress = settingsVm.PersonalSettings.EmailAddress; } TrayPopup.Instance.Enabled = settingsVm.GeneralSettings.ShowPopups; AudioAlert.Instance.Enabled = settingsVm.GeneralSettings.AudioAlerts; SquiggleContext.Current.ChatClient.EnableLogging = settingsVm.GeneralSettings.EnableStatusLogging; SetRunAtStartup(settingsVm.GeneralSettings.RunAtStartup); SettingsProvider.Current.Save(); return(true); }
public async Task InitializeAccountSettingsAsync() { SettingsProvider.AccountModel = new AccountModel(); AccountModel loadedAccountModel = null; var networkConnected = await NetworkUtility.CheckInternetConnectionAsync(); if (networkConnected) { loadedAccountModel = await LoadServerAccountSettingsAsync(); } else if (!networkConnected || loadedAccountModel == null) { loadedAccountModel = LoadLocalAccountSettings(); } if (loadedAccountModel == null) { return; } SettingsProvider.AccountModel = new AccountModel { UserName = loadedAccountModel.UserName, Email = loadedAccountModel.Email, LicenseType = loadedAccountModel.LicenseType, LicenseExpirationDate = loadedAccountModel.LicenseExpirationDate, }; }
void LoadSettings() { SettingsProvider.Current.Load(); settingsVm = new SettingsViewModel(SettingsProvider.Current.Settings); settingsVm.ConnectionSettings.AllIPs.AddRange(NetworkUtility.GetLocalIPAddresses().Select(ip => ip.ToString())); settingsVm.GeneralSettings.RunAtStartup = GetRunAtStartup(); cmbSortField.SelectedItem = settingsVm.ContactSettings.ContactListSortField; cmbContactsView.SelectedItem = settingsVm.ContactSettings.ContactListView; if (currentUser == null) { settingsVm.PersonalSettings.DisplayName = SettingsProvider.Current.Settings.PersonalSettings.DisplayName; settingsVm.PersonalSettings.GroupName = SettingsProvider.Current.Settings.PersonalSettings.GroupName; settingsVm.PersonalSettings.DisplayMessage = SettingsProvider.Current.Settings.PersonalSettings.DisplayMessage; settingsVm.PersonalSettings.DisplayImage = SettingsProvider.Current.Settings.PersonalSettings.DisplayImage; settingsVm.PersonalSettings.EmailAddress = SettingsProvider.Current.Settings.PersonalSettings.EmailAddress; } else { settingsVm.PersonalSettings.DisplayName = currentUser.DisplayName; settingsVm.PersonalSettings.GroupName = currentUser.Properties.GroupName; settingsVm.PersonalSettings.DisplayMessage = currentUser.Properties.DisplayMessage; settingsVm.PersonalSettings.DisplayImage = currentUser.Properties.DisplayImage; settingsVm.PersonalSettings.EmailAddress = currentUser.Properties.EmailAddress; } }
public override int NativeToInteger(object value, ComponentDataFromEntity <NetworkSyncState> networkSyncStateEntities) { Entity entity = (Entity)value; NetworkSyncState networkSynchState = networkSyncStateEntities[entity]; return(NetworkUtility.GetNetworkEntityHash(networkSynchState.actorId, networkSynchState.networkId)); }
protected void WriteDataAndEndWriteData(Type dataType, object data, int ackNumber) { this.SeekPos = 18L; if (data != null) { try { Serializer.NonGeneric.Serialize(this.memoryStream, data); } catch (Exception ex) { Debug.LogError(NetBuffer.CreateStackTrace(string.Format("protobuf序列化失败,opCode为{0}", NetworkUtility.GetSendPacketsType(dataType)))); throw ex; } } else { Debug.LogError(NetBuffer.CreateStackTrace(string.Format("数据包为空,opCode为{0}", NetworkUtility.GetSendPacketsType(dataType)))); } if (this.memoryStream.get_Position() > 1048576L) { Debug.LogError(NetBuffer.CreateStackTrace(string.Format("数据包过大,请迅速通知程序: {0}-{1}", dataType.get_Name(), this.memoryStream.get_Position()))); } else { this.WriteDataHeadAndEndWriteData(NetworkUtility.GetSendPacketsType(dataType), (int)this.memoryStream.get_Position(), ackNumber); } }
public TcpStateStatisticsByProcesses GetStatisticsByTCPv6() { var stat = new Dictionary <int, TcpStateStatistics>(); NetworkUtility.GetAllTcpStats(AddressFamily.AF_INET6, stat); return(new TcpStateStatisticsByProcesses(stat)); }
public async Task <IActionResult> UploadFile([FromForm] IFormFile file, [FromForm] string host) { try { using (var memoryStream = new MemoryStream()) { file.OpenReadStream().CopyTo(memoryStream); var policies = _manager.Redis.GetHostWildcards(host); var shortReport = await _manager.VirusTotal.GetShortReportFromFileBytesAsync(memoryStream.ToArray()); await _manager.Logstash.SendEventAsync(new EventDrop(host, shortReport.md5, shortReport.full_class)); var restrictingPolicy = await NetworkUtility.GetRestrictingPolicy(policies, shortReport.full_class.ToLower()); if (file != null && restrictingPolicy != "") { await _manager.RegisterIncident(file, host, shortReport, restrictingPolicy); return(Ok(_response.SetStatus(true, "OK. Incident registered"))); } return(Ok(_response.SetStatus(true, "OK."))); } } catch (Exception e) { return(BadRequest(_response.SetStatus(false, $"NOK. {e.Message}, {e.StackTrace}"))); } }
public object[] TryReadAsDataPacket(out short opCode) { opCode = this.ReadShortAt(4); short num = this.ReadShortAt(6); Type recvType = NetworkUtility.GetRecvType(opCode); if (recvType == null) { Debug.LogError(NetBuffer.CreateStackTrace("通过opCode没找到对应的protobuf类型:" + opCode)); return(null); } int num2 = this.ReadIntAt(0); if (num2 >= 18) { this.SeekPos = 18L; try { this.memoryStream.SetLength((long)num2); object obj = Serializer.NonGeneric.Deserialize(recvType, this.memoryStream); return(new object[] { num, obj }); } catch (Exception ex) { Debug.LogError(NetBuffer.CreateStackTrace(string.Format("protobuf反序列化失败,opCode为{0}", opCode))); throw ex; } } Debug.LogError(NetBuffer.CreateStackTrace(string.Format("包长不对,包长为{0},opCode:{1}", num2, opCode))); return(null); }
public static BasicMLDataSet CreateEvaluationSetAndLoad(string @fileName, int startLine, int HowMany, int WindowSize, int outputsize) { List <double> Opens = QuickCSVUtils.QuickParseCSV(fileName, "Open", startLine, HowMany); List <double> High = QuickCSVUtils.QuickParseCSV(fileName, "High", startLine, HowMany); // List<double> Low = QuickCSVUtils.QuickParseCSV(fileName, "Low", startLine, HowMany); List <double> Close = QuickCSVUtils.QuickParseCSV(fileName, "Close", startLine, HowMany); List <double> Volume = QuickCSVUtils.QuickParseCSV(fileName, 5, startLine, HowMany); double[] Ranges = NetworkUtility.CalculateRanges(Opens.ToArray(), Close.ToArray()); IMLDataPair aPairInput = TrainerHelper.ProcessPairs(NetworkUtility.CalculatePercents(Opens.ToArray()), NetworkUtility.CalculatePercents(Opens.ToArray()), WindowSize, outputsize); IMLDataPair aPairInput3 = TrainerHelper.ProcessPairs(NetworkUtility.CalculatePercents(Close.ToArray()), NetworkUtility.CalculatePercents(Close.ToArray()), WindowSize, outputsize); IMLDataPair aPairInput2 = TrainerHelper.ProcessPairs(NetworkUtility.CalculatePercents(High.ToArray()), NetworkUtility.CalculatePercents(High.ToArray()), WindowSize, outputsize); IMLDataPair aPairInput4 = TrainerHelper.ProcessPairs(NetworkUtility.CalculatePercents(Volume.ToArray()), NetworkUtility.CalculatePercents(Volume.ToArray()), WindowSize, outputsize); IMLDataPair aPairInput5 = TrainerHelper.ProcessPairs(NetworkUtility.CalculatePercents(Ranges.ToArray()), NetworkUtility.CalculatePercents(Ranges.ToArray()), WindowSize, outputsize); List <IMLDataPair> listData = new List <IMLDataPair>(); listData.Add(aPairInput); listData.Add(aPairInput2); listData.Add(aPairInput3); listData.Add(aPairInput4); listData.Add((aPairInput5)); var minitrainning = new BasicMLDataSet(listData); return(minitrainning); }
async void OnLoaded(object sender, RoutedEventArgs e) { var messageRegistrar = new MessageRegistrar(); var key = messageRegistrar.RegisterMessageFactory <TestGuidMessage>( () => new TestGuidMessage()); messageRegistrar.RegisterMessageHandler <TestGuidMessage>(key, async msg => { var testMessage = msg as TestGuidMessage; await this.DispatchAsync( () => { if (!this.remoteAddresses.Contains(testMessage.Id)) { this.remoteAddresses.Add(testMessage.Id); this.SourceCount++; } this.ReceivedCount++; } ); } ); this.IPAddress = NetworkUtility.GetConnectedIpAddresses(false).First().ToString(); this.MessageId = Guid.NewGuid(); this.messageService = new MessageService( messageRegistrar, ipAddress.ToString()); this.messageService.Open(); }
public static void FlushLog() { if (logDataBuffer.Length == 0) { return; } string logDir = Application.persistentDataPath + "/log"; if (!Directory.Exists(logDir)) { Directory.CreateDirectory(logDir); } string logFile = string.Format("{0}/gamelog_{1}_{2}.log", logDir, NetworkUtility.GetMacAddress(), DateTime.Now.ToString("yyyyMMddHH")); if (!File.Exists(logFile)) { File.Create(logFile); } using (FileStream stream = new FileStream(logFile, FileMode.Append)) { if (stream != null) { byte[] logData = System.Text.Encoding.Default.GetBytes(logDataBuffer.ToString()); stream.Write(logData, 0, logData.Length); stream.Flush(); logDataBuffer.Length = 0; logDataBuffer.Capacity = logBufferSize; } stream.Close(); } }
public void ReadFrom(Properties.Settings settings, ConfigReader reader) { PresenceAddress = reader.GetSetting(SettingKey.PresenceAddress, DefaultValues.PresenceAddress); BindToIP = settings.BindToIP; bool requiresNewBindToIP = !NetworkUtility.IsValidLocalIP(BindToIP); if (requiresNewBindToIP) { var ip = NetworkUtility.GetLocalIPAddress(); BindToIP = ip == null ? String.Empty : ip.ToString(); } ClientID = settings.ClientID; if (String.IsNullOrEmpty(ClientID)) { ClientID = Guid.NewGuid().ToString(); } ChatPort = reader.GetSetting(SettingKey.ChatPort, DefaultValues.ChatPort); KeepAliveTime = reader.GetSetting(SettingKey.KeepAliveTime, DefaultValues.KeepAliveTime); PresencePort = reader.GetSetting(SettingKey.PresencePort, DefaultValues.PresencePort); PresenceCallbackPort = reader.GetSetting(SettingKey.PresenceCallbackPort, DefaultValues.PresenceCallbackPort); }
public ActionResult Index(string host) { bool result = NetworkUtility.CanPing(host, 10000); string message = result == true? "up and runing": "not reachable"; return(new OkObjectResult($"Host {host} is {message}!")); }
public BannerController(ICmsService cmsService, NetworkUtility networkUtility) { Contract.Requires(cmsService != null); Contract.Requires(networkUtility != null); _cmsService = cmsService; _networkUtility = networkUtility; }
public MainWindow() { Constants.QUY_HIEN_TAI = 1; Constants.NAM_HIEN_TAI = 2017; InitializeComponent(); scoreView.DataContext = new ScoreViewModel(); dbOperView.SetDataContext(new DbOperViewModel()); NetworkUtility.SettingProxy(); }
public PaymentController(IPaymentApiProxy paymentApiProxy, CultureUtility cultureUtility, NetworkUtility networkUtility, UserContext userContext, Configurations configurations) { _paymentApiProxy = paymentApiProxy; _cultureUtility = cultureUtility; _networkUtility = networkUtility; _userContext = userContext; _configurations = configurations; }
/// <summary> /// Initializes an ServerInfo instance with the specified hostname, port, assembly path, and logging level. /// </summary> /// <param name="hostname">The host name of the server or proxy.</param> /// <param name="port">The network port for the server or proxy.</param> /// <param name="assemblyPath">The assembly path of the server or proxy.</param> /// <param name="logLevel">The logging level for the server or proxy.</param> public ServerInfo(string hostname, int port, string assemblyPath, LogLevel logLevel) { this.HostName = hostname; this.Port = port; this.AssemblyPath = assemblyPath; this.StorageRoot = FileUtility.CompletePath(assemblyPath, false) + "storage\\"; this.LoggingLevel = logLevel; this.ipe = new IPEndPoint(NetworkUtility.Hostname2IPv4Address(HostName), Port); }
public void ConnectTCP() { if (!isServer) { TcpProtocol.OnClientPacketReceived += OnPacketReceived2; TcpProtocol.Connect(NetworkUtility.ResolveEndPoint(ServerExternalIP, TCPPort), NetworkUtility.ResolveEndPoint(ServerInternalIP, TCPPort)); } }
public RegistrationController(IAccountApiProxy accountApiProxy, IUtilityApiProxy utilityApiProxy, NetworkUtility networkUtility) { Contract.Requires(accountApiProxy != null); Contract.Requires(utilityApiProxy != null); Contract.Requires(networkUtility != null); _accountApiProxy = accountApiProxy; _utilityApiProxy = utilityApiProxy; _networkUtility = networkUtility; }
public async Task <bool> CheckLicenseAsync() { bool networkConnection = await NetworkUtility.CheckInternetConnectionAsync(); bool tokenExists = await new LocalLicenseValidator().ValidateAsync(); bool licenseStatus = networkConnection ? await new PersonalLicenseValidator().ValidateAsync() : tokenExists; OnLicenseStatusChanced.Invoke(this, new LicenseEventArgs(licenseStatus, tokenExists)); return(licenseStatus); }
/// <summary> /// Initializes an ServerInfo instance with the specified hostname, port, assembly path, and logging level. /// </summary> /// <param name="hostname">The host name of the server or proxy.</param> /// <param name="port">The network port for the server or proxy.</param> /// <param name="assemblyPath">The assembly path of the server or proxy.</param> /// <param name="storageRoot">The storage root directory of the server or proxy.</param> /// <param name="logLevel">The logging level for the server or proxy.</param> /// <param name="id">The id of the current server.</param> public ServerInfo(string hostname, int port, string assemblyPath, string storageRoot, LogLevel logLevel, string id) { this.HostName = hostname; this.Port = port; this.AssemblyPath = assemblyPath; this.StorageRoot = storageRoot; this.LoggingLevel = logLevel; this.Id = id; this.ipe = new IPEndPoint(NetworkUtility.Hostname2IPv4Address(HostName), Port); }
// Update is called once per frame void Update() { if (SendData) { SendData = false; var data = JsonUtility.ToJson(State); MasterWrite(NetworkUtility.ToNetwork(State)); Debug.Log("Master Sent: " + data); } }
internal ServerInfo(ServerInfo si) { this.HostName = si.HostName; this.Port = si.Port; this.AssemblyPath = si.AssemblyPath; this.StorageRoot = si.StorageRoot; this.LoggingLevel = si.LoggingLevel; this.Id = si.Id; this.ipe = new IPEndPoint(NetworkUtility.Hostname2IPv4Address(HostName), Port); }
private void Awake() { networkUtility = new NetworkUtility(); JObject json = new JObject(); json.Add("ipaddr", networkUtility.GetLocalIP()); json.Add("userId", "M_Chang"); Debug.Log(json.ToString()); Debug.Log(networkUtility.HTTP_POST(json, Config.Config.POST_LOG)); }
public void AddListenEvent <T>(NetCallBackMethod <T> callBack) where T : class { Type typeFromHandle = typeof(T); short recvPacketsType = NetworkUtility.GetRecvPacketsType(typeFromHandle); if (!NetworkService.receivePacketHandler.ContainsKey(recvPacketsType)) { NetworkService.receivePacketHandler.Add(recvPacketsType, new List <NetHandler>()); } NetworkService.receivePacketHandler.get_Item(recvPacketsType).Add(new NetHandler(callBack.get_Method(), callBack.get_Target())); }