private void InitializeServer() { myService = new RandomServerClient(); myService.Endpoint.Address = new EndpointAddress(string.Format("http://{0}:3030", "http://server.pypem.com"));//server.pypem.com//127.0.0.1 myService.InnerChannel.OperationTimeout = new TimeSpan(0, 2, 30); Dispatcher.Invoke(() => this.prBusy.IsActive = false); Dispatcher.Invoke(() => this.IsEnabled = true); }
public MainWindow() { InitializeComponent(); myService = new RandomServerClient(); myService.Endpoint.Address = new EndpointAddress(string.Format("http://{0}:3030", "server.pypem.com"));//server.pypem.com//127.0.0.1 myService.InnerChannel.OperationTimeout = new TimeSpan(0, 2, 30); TimeZone localZone = TimeZone.CurrentTimeZone; TimeSpan currentOffset = localZone.GetUtcOffset(DateTime.Now); this.lbTimeZone.Content = $"UTC{(currentOffset.Hours > 0 ? "+" : "")}{currentOffset.Hours}"; string macAddr = ( from nic in NetworkInterface.GetAllNetworkInterfaces() where nic.OperationalStatus == OperationalStatus.Up select nic.GetPhysicalAddress().ToString() ).FirstOrDefault(); string idRaw = macAddr + "_5.some_stuff_8899211"; string idSHA = SHA.GetSHAString(SHA.GetHash(idRaw)); this.lbID.Text = idSHA; this.myUser = new Info() { user = idSHA, time_zone = currentOffset.Hours }; int rndBase = this.myRandom.Next(65536) * 256; int rndOffset = this.myRandom.Next(Math.Abs((int)DateTime.UtcNow.Ticks % 65536)) + 256; for (int i = 0; i < rndOffset; i++) { this.myRandom.Next(rndBase); } this.computeThread = new Thread(this.Compute); computeThread.Start(null); Console.WriteLine(System.Reflection.Assembly.GetExecutingAssembly().Location); bool startup = Properties.Settings.Default.startup; if (!startup) { if (MessageBox.Show("This program should run at startup, would yoou like to enable this?", "Run at start", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { startup = true; } } if (this.SetStartup(startup)) { this.cbStartup.IsChecked = startup; } Properties.Settings.Default.startup = startup; Properties.Settings.Default.Save(); this.myGlobalData = new List <SQLData>(); this.myLocalData = new List <SQLData>(); this.prBusy.IsActive = true; this.IsEnabled = false; this.myService.BeginGetUserData(this.myUser.user, TimeSpan.FromHours(24), this.GetUserDataCallBack, null); for (int i = -12; i <= 12; i++) { this.cbTimeZoneGlobal.Items.Add($"UTC{(i >= 0 ? "+" : "")}{i}"); } this.cbTimeZoneGlobal.SelectedIndex = this.myUser.time_zone + 12; }