public App() { WriteLog("ClearSpace starting", Log.MsgType.Information); UILog.CleanLogFiles(); //if (Utils.ISEnEdition()) { ClearSpace.Properties.Resources.Culture = new System.Globalization.CultureInfo(System.Globalization.CultureInfo.InstalledUICulture.Name); } //else //{ // ClearSpace.Properties.Resources.Culture = new System.Globalization.CultureInfo("zh-CN"); //} //mass data logistic m_mass = new MassData.MassDataManager(true); m_mass.start(); }
public MainWindow() { InitializeComponent(); tipwnd = new switch_net_tip(this); this.VersionInfo.Text = "(v" + UpdateManager.GetCurrentVersion() +")" ; m_httpServsDit = new Dictionary<EndPoint, HTTPClientService>(); cdiscovery = new CloudDiscovery(); if (!CreateBaseFolder()) { return; } if (Utils.ISEnEdition()) { LoadStyleDynamically(@"Style_en-US.xaml"); } else { LoadStyleDynamically(@"Style_zh-CN.xaml"); } CheckVersionUpdate(true); hotspot = new EPHotspotLib.EasyPlusHotspot(); //set own computer name this.text_ComputerName.Text = Utils.getLocalComputerName(); this.OfficialWebsite.Text = Utils.getLocalComputerName(); //set network name Thread thread = new Thread(() => { while (!isClosing) { this.Dispatcher.Invoke(new Action(delegate { setCurNetwork(); })); Thread.Sleep(3000); } }); thread.Start(); //EP softAp start Thread thread1 = new Thread(() => { try { int result = hotspot.StartSoftAP(Utils.GetSoftAPContractName(), "Aa123456", Process.GetCurrentProcess().Id, 0); if(result != 0) uploadMassData(GlobalDef.MassDataItems.Mass_Softap_init_fail_times, "1"); } catch (Exception e) { Console.WriteLine(e.Message); App.WriteLog("start softap error: " + e.Message, Log.MsgType.Error); uploadMassData(GlobalDef.MassDataItems.Mass_Softap_init_fail_times, "1"); } }); thread1.Start(); //shareit foundation Thread t1 = new Thread(() => { cdiscovery.Advertise(); }); t1.Start(); //build broadcast content StringWriter str = new StringWriter(); JsonWriter jw = new JsonTextWriter(str); jw.Formatting = Formatting.Indented; jw.WriteStartObject(); jw.WritePropertyName("cmd"); jw.WriteValue("KSendPCInfo"); jw.WritePropertyName("name"); jw.WriteValue(Utils.getLocalComputerName()); jw.WritePropertyName("version"); jw.WriteValue("1.1"); jw.WritePropertyName("softAp"); jw.WriteValue(Utils.GetSoftAPContractName()); jw.WriteEndObject(); //start udp cmd server asudp = NetworkServiceFactory.GenerateUDPServer("0.0.0.0", GlobalDef.UDPCMDPIPE_PORT, this); if (asudp != null && asudp.init()) asudp.start(); else { App.WriteLog("Udp server init error, try again in 5secs", Log.MsgType.Information); Thread.Sleep(5000); if (asudp != null && asudp.init()) asudp.start(); else { App.WriteLog("Udp server down", Log.MsgType.Information); } } //start broadcast service broadcast = NetworkServiceFactory.GenerateUDPBroadcastService(GlobalDef.BROADCAST_PORT, str.ToString()); if (broadcast != null && broadcast.init()) broadcast.start(); else App.WriteLog("Broadcast service down", Log.MsgType.Information); //start scan softap service scanSoftAp = NetworkServiceFactory.GenerateScanSoftApService(this); scanSoftAp.start(); thumbmgr = new ThumbsManager(); this.DataContext = thumbmgr; mobile_softap_conn_timeout = new System.Windows.Threading.DispatcherTimer(); mobile_softap_conn_timeout.Tick += new EventHandler(tm_Tick); mobile_softap_conn_timeout.Interval = TimeSpan.FromSeconds(30); //mass data logistic m_mass = new MassData.MassDataManager(); m_mass.start(); //upload start times mass data uploadMassData(GlobalDef.MassDataItems.Mass_Start_times, "1"); }