public ServerThread(TcpClient connection)
        {
            dataBase = new LocalDB();
            fileController = new FileController();
            tcpConnection = connection;
            connectionStream = tcpConnection.GetStream();

            StandardRequestModel request = readStream();
            if (request == null)
            {
                stopConnection();
                return;
            }
            ClientInfoModel Client = request.Client;

            if (Client == null)
            {
                stopConnection();
            }
            loginClient(request);

            //Verarbeitung des Request
            StandardResultModel result = getResult(request);

            sendStringStream(result);

            if (result.type == ResultType.sendPackage)
            {
                List<PackageInfoModel> packageList = (List<PackageInfoModel>)result.result;
                GroupInfoModel group = null;

                if (packageList.Count != 0)
                {
                    ClientInfoModel resultClient = (ClientInfoModel)result.result;

                    if (resultClient != null)
                    {
                        sendFile(group, packageList[0]);
                        dataBase.ClientGetSoftware(resultClient, packageList[0]);
                    }
                }
            }

            if (result.type == ResultType.readPackage)
            {
                string strInfo =(string)request.requestData;
                char[] delimiter1 = new char[] { ',' };

                string[] strArray = strInfo.Split(delimiter1, StringSplitOptions.None);

                if (strArray.Length == 2)
                {
                    readFile(strArray[0], strArray[1]);
                }

            }

            stopConnection();
        }
        private StandardResultModel sendSoftwarePackage(StandardRequestModel request)
        {
            StandardResultModel result = new StandardResultModel();
            //List<ClientInfoModel> clientList = null;
            ClientInfoModel client = null;
            LocalDB dataBase = new LocalDB();

            //clientList = dataBase.Converter.GetClientInfoModels();

            //if (client == null)
            //{
                result.message = "";
                result.successful = true;
                result.type = ResultType.readPackage;
                result.result = client;
                return result;
            //}

            //for (int i = 0; i < clientList.Count; i++)
            //{
            //    if (request.Client.macAddress == clientList[i].macAddress)
            //    {
            //        client = clientList[i];
            //    }
            //}

            //result.message = "";
            //result.successful = true;
            //result.type = ResultType.readPackage;
            //result.result = client;

            //return result;
        }
        private StandardResultModel delDatabaseSoftwarePackage(StandardRequestModel request)
        {
            StandardResultModel result = new StandardResultModel();
            PackageInfoModel packageResult = null;
            GroupInfoModel group = null;

            LocalDB dataBase = new LocalDB();

            packageResult = JsonConvert.DeserializeObject<PackageInfoModel>(request.requestData.ToString());
            group = dataBase.Converter.GetGroupByPackage(packageResult);
            result.successful = dataBase.gbDeletePackage(packageResult);

            fileController.delSoftwarePackage(fileController.getPathFromFile(group.Name, packageResult.Name));

            result.message = "";
            result.result = packageResult;
            result.type = ResultType.delDatabaseSoftwarePackage;

            return result;
        }
        private void loginClient(StandardRequestModel request)
        {
            ClientInfoModel client = request.Client;
            ClientInfoModel newClient = null;
            GroupInfoModel newGroup = null;
            LocalDB oDB = new LocalDB();
            newClient = oDB.gbAddClient(client);
            newGroup = oDB.Converter.GetGroupByClient(newClient);

            string[] lines = Regex.Split(client.macAddress, "\r\n");
            string macAddress = "";

            foreach (string line in lines)
            {
                macAddress += line;
            }

            if (newGroup == null)
            {
                Console.WriteLine("Anmeldung Client:" + macAddress + " " + " Gruppe:" + client.group + " " + " Admin:" + client.admin + "\n" + "Request:" + request.request);
            }
            else
            {
                Console.WriteLine("Anmeldung Client:" + macAddress + " " + " Gruppe:" + newGroup.Name + " " + " Admin:" + client.admin + "\n" + "Request:" + request.request);
            }
        }
        static void Main(string[] args)
        {
            //List<ClientInfoModel> olist = new List<ClientInfoModel>();
            LocalDB oDB = new LocalDB();
            FileController file = new FileController(oDB.Converter.GetGroupInfoModels());

            Controller.Diagnostics.EventName = "Softwareverteilung2013";
            Controller.Diagnostics.WriteToEventLog("Server wird gestartet", System.Diagnostics.EventLogEntryType.Information, 1000);
            Console.WriteLine("starting...");

            connection = new ServerConnection();

            String cmd = "";
            while (cmd.ToLower() != "stop")
            {
                cmd = Console.ReadLine();

                if (cmd.ToLower().Equals("help"))
                {
                    string commands = CommandModel.getCommands();
                    Console.WriteLine(commands);
                }
                else if (cmd.ToLower().Equals("clear"))
                {
                    Console.Clear();
                }
                else if (cmd.ToLower().Equals("delPackage"))
                {
                    Console.WriteLine("Noch nicht Implementiert");
                }
                else if (cmd.ToLower().Equals("delGroup"))
                {
                    Console.WriteLine("Noch nicht Implementiert");
                }
                else if (cmd.ToLower().Equals("packages"))
                {
                    Console.WriteLine("Noch nicht Implementiert");
                }
                else if (cmd.ToLower().Equals("groups"))
                {
                    List<GroupInfoModel> groups = oDB.Converter.GetGroupInfoModels();

                    string groupNames = "";

                    foreach (var group in groups)
                    {
                        groupNames = "ID:" + group.ID + " Name:" + group.Name;
                        Console.WriteLine(groupNames);
                    }
                }
                else if (cmd.ToLower().Equals("groupclients"))
                {
                    List<GroupInfoModel> groups = oDB.Converter.GetGroupInfoModels();

                    for (int i = 0; i < groups.Count; i++)
                    {
                        Console.WriteLine("ID:" + groups[i].ID + " Name:" + groups[i].Name);
                        Console.WriteLine();

                        List<ClientInfoModel> clients = oDB.Converter.GetGroupClients(groups[i]);

                        string groupNames = "";

                        foreach (var client in clients)
                        {
                            groupNames = "ID:" + client.ID + " pcName:" + client.pcName;
                            Console.WriteLine(groupNames);
                        }
                        Console.WriteLine();
                    }

                }
                else if (cmd.ToLower().Equals("clients"))
                {
                    List<ClientInfoModel> oList = oDB.Converter.GetClientInfoModels();

                    for (int i = 0; i < oList.Count; i++)
                    {
                        Console.WriteLine(oList[i].pcName.ToString() + "   " + oList[i].group.ToString());
                    }
                }
                else if (!cmd.ToLower().Equals("stop"))
                    Console.WriteLine("Unbekannter Befehl: " + cmd);
            }

            connection.stopServer();
        }