static void Main() { FillConfiguration fcfg = new FillConfiguration(); // считывает настройки из файла конфигурации cfg = fcfg.ReadConfigFile(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Settings()); }
public Server() { Console.Title = "GPSTrackingServer"; cfg = fcfg.ReadConfigFile(); Sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); AcceptAsyncArgs = new SocketAsyncEventArgs(); AcceptAsyncArgs.Completed += AcceptCompleted; System.Timers.Timer timer = new System.Timers.Timer(cfg.KeepAliveTime*100); timer.Elapsed += KeepAlive; timer.Enabled = true; IsRun = false; }
public string WriteConfigFile(Configuration cfg) { try { XmlSerializer xmlserialazer = new XmlSerializer(typeof(Configuration)); using (TextWriter myStreamWriter = new StreamWriter(ConfigFilePath)) { xmlserialazer.Serialize(myStreamWriter, cfg); } } catch (Exception ex) { return ex.Message; } return "Writing was successful"; }
public Configuration SetDefault() { Configuration tmp = new Configuration(); tmp.Port = 4505; tmp.MaxClients = 10; tmp.AuthTime = 60 * 5; tmp.KeepAliveTime = 60 * 5; tmp.Log = true; tmp.Console = true; tmp.ShowError = true; tmp.LogError = true; tmp.ShowConnectMessages = true; tmp.LogConnectMessages = true; tmp.ShowClientGPSData = true; tmp.ShowClientGPSData = true; tmp.LogPath = "./Log.txt"; tmp.DBhost = "localhost"; tmp.DB = "GPSTracker"; tmp.DBuser = "******"; tmp.DBpassword = "******"; return tmp; }
public DBConnection(Configuration _cfg) { ConnectionString = "Database=" + _cfg.DB + ";Data Source=" + _cfg.DBhost + ";User Id=" + _cfg.DBuser + ";Password="******";"; Connect(); }