// SETTING UP THE SERVER // private static void SetupServer() { try { Console.WriteLine("Setting up server...\n"); _serverSocket.Bind(new IPEndPoint(IPAddress.Any, PORT)); Console.WriteLine("Done\nListening..."); _serverSocket.Listen(5); _serverSocket.BeginAccept(new AsyncCallback(AcceptCallBack), null); } catch (Exception e) { logger.Log(e.Message); } }
public List <Models.Card> cardCollectionToList() { int ID; string Name; string Type; string Element; int Cost; string Race; string Text; int Power; List <Models.SpecialEffect> SpecialEffects; List <Models.Card> cards = new List <Models.Card>(); try { if (con.State == System.Data.ConnectionState.Closed) { con.Open(); } SqlCommand cmd = new SqlCommand("SELECT * FROM CardCollection", con); using (SqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { // get card data from db ID = Int32.Parse(reader["ID"].ToString()); Name = reader["Name"].ToString(); Type = reader["Type"].ToString(); Element = reader["Element"].ToString(); Cost = Int32.Parse(reader["Cost"].ToString()); Race = reader["Race"].ToString() != string.Empty ? reader["Race"].ToString() : null; Text = reader["Text"].ToString() != string.Empty ? reader["Text"].ToString() : null; Power = reader["Power"].ToString() != string.Empty ? Int32.Parse(reader["Power"].ToString()) : -1; // get card SpecialEffect from db if (reader["Special Effect"].ToString() == string.Empty) { SpecialEffects = null; } else { SpecialEffects = parseDBSpecialEffects(reader); } cards.Add(new Models.Card(ID, Name, Type, Element, Cost, Race, Text, Power, SpecialEffects)); } } } catch (Exception ex) { logger.Log(ex.Message); } finally { con.Close(); } return(cards); }