public int addGroupInfo(ClientInfoModel client, GroupInfoModel addGroup)
        {
            int value = -1;
            StandardResultModel resultInfo = null;

            if (!client.admin)
            {
                return value;
            }

            mRequest = RequestController.creatAddGroupRequest(client, addGroup);

            if (mRequest == null)
            {
                return value;
            }

            resultInfo = mConnection.startConnection(mRequest);
            mConnection.closeConnection();

            if (resultInfo == null)
            {
                return value;
            }

            GroupInfoModel resultGroup = JsonConvert.DeserializeObject<GroupInfoModel>(resultInfo.result.ToString());

            if (resultInfo.successful && resultInfo.type == ResultType.addGroup)
            {
                value = resultGroup.ID;
            }

            mRequest = null;
            return value;
        }
 public static StandardRequestModel creatDelPackageRequest(ClientInfoModel client, PackageInfoModel delPackage)
 {
     StandardRequestModel request = null;
     if (client == null)
     {
         return request;
     }
     request = new StandardRequestModel();
     request.Client = client;
     request.request = RequestTyp.delDatabaseSoftwarePackage;
     request.requestData = delPackage;
     return request;
 }
 public static StandardRequestModel creatAddClientRequest(ClientInfoModel client, ClientInfoModel addClient)
 {
     StandardRequestModel request = null;
     if (client == null)
     {
         return request;
     }
     request = new StandardRequestModel();
     request.Client = client;
     request.request = RequestTyp.addDatabaseClient;
     request.requestData = addClient;
     return request;
 }
 public static StandardRequestModel creatDelGroupRequest(ClientInfoModel client, GroupInfoModel delGroup)
 {
     StandardRequestModel request = null;
     if (client == null)
     {
         return request;
     }
     request = new StandardRequestModel();
     request.Client = client;
     request.request = RequestTyp.delDatabaseGroup;
     request.requestData = delGroup;
     return request;
 }
 private void btnOk_Click(object sender, EventArgs e)
 {
     foreach (TreeNode Node in treeView1.Nodes)
     {
         if (Node.Checked)
         {
             ClientInfoModel CurrentModel = new ClientInfoModel();
             CurrentModel.ID = Convert.ToInt32(Node.Tag);
             CurrentModel.pcName = Node.Text;
             ClientInfoModelArray.Add(CurrentModel);
         }
     }
      frmSoftwareverteilung.ClientInfoModelArray = ClientInfoModelArray;
      this.Close();
 }
        private void ConnectToServer()
        {
            ClientInfoModel InfoModel = new ClientInfoModel();
            InfoModel.arc = GetArchitecture();
            InfoModel.macAddress = GetMacAddress();
            InfoModel.admin = GetAdminBool();

            sendRequest Request = new sendRequest(Properties.Settings.Default.ServerIP);
            if (Request.sendUpdateRequest(InfoModel, Properties.Settings.Default.SavePath))
            {
                foreach (string file in System.IO.Directory.GetFiles(Properties.Settings.Default.SavePath))
                {
                    UnpackZip(file);
                }
                InstallProgramms();
            }
        }
    private void btnDeleteUser_Click(object sender, EventArgs e)
    {
        TreeNode NodeToDelete = new TreeNode();
            for (int i = 0; i < TreeView2.Nodes[0].Nodes.Count; i++)
            {
                if (TreeView2.Nodes[0].Nodes[i].Checked)
                {
                    NodeToDelete = TreeView2.Nodes[0].Nodes[i];
                }
            }
            if (NodeToDelete.TreeView == null)
            {
                MessageBox.Show("Bitte wählen Sie einen zu löschenden Benutzer aus.");
                return;
            }

            if (MessageBox.Show("Möchten Sie den ausgewählten Benutzer aus dieser Gruppe löschen? (Dieser wird automatisch in die Gruppe 'Standard' verschoben)", "Achtung!", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                for (int i = 0; i < TreeView2.Nodes[0].Nodes.Count; i++)
                {
                    if (TreeView2.Nodes[0].Nodes[i].Checked)
                    {
                        ClientInfoModel DelClient = new ClientInfoModel();
                        DelClient.ID = Convert.ToInt32(TreeView2.Nodes[0].Nodes[i].Tag);
                        request.delClientInfo(client, DelClient);

                        TreeView2.Nodes[0].Nodes[i].Parent.Nodes.Remove(TreeView2.Nodes[0].Nodes[i]);
                    }
                }
            }
    }
    private void TreeView2_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
    {
        if (e.Node == TreeView2.Nodes[0])
            {
                return;
            }
            TreeView3.Nodes[0].Nodes.Clear();

            List<PackageInfoModel> softwareList = null;
            ClientInfoModel CurrentClient = new ClientInfoModel();
            CurrentClient.ID = Convert.ToInt32(e.Node.Tag);
            softwareList = request.getClientPackages(client, CurrentClient);

            if (softwareList == null)
            {
                return;
            }
            foreach (PackageInfoModel Package in softwareList)
            {
                TreeNode CurrentNode = new TreeNode(Package.showName);
                CurrentNode.Tag = Package.ID;
                TreeView3.Nodes[0].Nodes.Add(CurrentNode);
                TreeView3.Nodes[0].Text = TreeView3.Nodes[0].Text + " (Clientsoftware)";
                TreeView3.Nodes[0].ForeColor = System.Drawing.Color.Red;

                clsZipFile.Unzip(Server_Client.Properties.Settings.Default.SavePath + "Groups\\" + TreeView1.SelectedNode.Text + "\\" + Package.Name + ".zip", Server_Client.Properties.Settings.Default.SavePath + "Groups\\" + TreeView1.SelectedNode.Text + "\\Temp\\");

                string[] FileArr = System.IO.Directory.GetFiles(Server_Client.Properties.Settings.Default.SavePath + "Groups\\" + TreeView1.SelectedNode.Text + "\\Temp\\");

                for (int d = 0; d < FileArr.Length; d++)
                {
                    System.IO.DirectoryInfo oDir = new System.IO.DirectoryInfo(FileArr[0]);
                    CurrentNode.Nodes.Add(oDir.Name);
                    System.IO.File.Delete(oDir.FullName);
                }
            }
    }
        public bool sendUpdateRequest(ClientInfoModel client, string savePath)
        {
            bool value = false;
            StandardResultModel resultInfo = null;

            if (client.admin)
            {
                return value;
            }

            mRequest = RequestController.creatUpdateRequest(client);

            if (mRequest == null)
            {
                return value;
            }

            resultInfo = mConnection.startConnection(mRequest);

            if (resultInfo == null)
            {
                return value;
            }

            if (resultInfo.successful && resultInfo.type == ResultType.sendPackage)
            {
                value = mConnection.readFile(savePath);
            }

            mConnection.closeConnection();

            mRequest = null;
            return value;
        }
 public static StandardRequestModel creatGetPackagesRequest(ClientInfoModel client)
 {
     StandardRequestModel request = null;
     if (client == null)
     {
         return request;
     }
     request = new StandardRequestModel();
     request.Client = client;
     request.request = RequestTyp.getDatabaseSoftwarePackages;
     request.requestData = null;
     return request;
 }
        public List<PackageInfoModel> getGroupPackages(ClientInfoModel client, GroupInfoModel group)
        {
            List<PackageInfoModel> packageInfo = null;
            StandardResultModel resultInfo = null;

            if (!client.admin)
            {
                return packageInfo;
            }

            mRequest = RequestController.creatGetGrupePackages(client,group);

            if (mRequest == null)
            {
                return packageInfo;
            }

            resultInfo = mConnection.startConnection(mRequest);
            mConnection.closeConnection();

            if (resultInfo == null)
            {
                return packageInfo;
            }

            if (resultInfo.successful && resultInfo.type == ResultType.GrupePackages)
            {
                packageInfo = new List<PackageInfoModel>();
                JArray array = (JArray)resultInfo.result;
                if (array != null)
                {
                    packageInfo = JsonConvert.DeserializeObject<List<PackageInfoModel>>(array.ToString());
                }
            }

            mRequest = null;
            return packageInfo;
        }
        public bool sendFile(ClientInfoModel client, GroupInfoModel group, PackageInfoModel package, string filePath)
        {
            bool value = false;
            StandardResultModel resultInfo = null;

            if (!client.admin)
            {
                return value;
            }

            mRequest = RequestController.creatSendSoftwarePackageRequest(client, group, package);

            if (mRequest == null)
            {
                return false;
            }

            resultInfo = mConnection.startConnection(mRequest);

            if (resultInfo == null)
            {
                return false;
            }

            if (resultInfo.successful && resultInfo.type == ResultType.readPackage)
            {
                value = mConnection.sendFile(filePath);
            }

            mConnection.closeConnection();

            return false;
        }
        public List<ClientInfoModel> getDatabaseClients(ClientInfoModel client)
        {
            List<ClientInfoModel> clientInfo = null;
            StandardResultModel resultInfo = null;

            if (!client.admin)
            {
                return clientInfo;
            }

            mRequest = RequestController.creatGetClientsRequest(client);

            if (mRequest == null)
            {
                return clientInfo;
            }

            resultInfo = mConnection.startConnection(mRequest);
            mConnection.closeConnection();

            if (resultInfo == null)
            {
                return clientInfo;
            }

            if (resultInfo.successful && resultInfo.type == ResultType.ClientInfo)
            {
                clientInfo = new List<ClientInfoModel>();
                JArray array = (JArray)resultInfo.result;
                clientInfo = JsonConvert.DeserializeObject<List<ClientInfoModel>>(array.ToString());
            }

            mRequest = null;
            return clientInfo;
        }
        public List<GroupInfoModel> getDatabaseGroups(ClientInfoModel client)
        {
            List<GroupInfoModel> groupInfo = null;
            StandardResultModel resultInfo = null;

            if (!client.admin)
            {
                return groupInfo;
            }
            mRequest = RequestController.creatGetGroupsRequest(client);

            if (mRequest == null)
            {
                return groupInfo;
            }

            try
            {
                resultInfo = mConnection.startConnection(mRequest);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            mConnection.closeConnection();

            if (resultInfo == null)
            {
                return null;
            }

            if (resultInfo.successful && resultInfo.type == ResultType.GroupInfo)
            {
                groupInfo = new List<GroupInfoModel>();
                 JArray array =(JArray)resultInfo.result;
                 groupInfo = JsonConvert.DeserializeObject<List<GroupInfoModel>>(array.ToString());
            }

            mRequest = null;
            return groupInfo;
        }
        public bool delPackageInfo(ClientInfoModel client, PackageInfoModel delPackage)
        {
            bool value = false;
            StandardResultModel resultInfo = null;

            if (!client.admin)
            {
                return value;
            }

            mRequest = RequestController.creatDelPackageRequest(client, delPackage);

            if (mRequest == null)
            {
                return value;
            }

            resultInfo = mConnection.startConnection(mRequest);
            mConnection.closeConnection();

            if (resultInfo == null)
            {
                return value;
            }

            if (resultInfo.successful && resultInfo.type == ResultType.delDatabaseSoftwarePackage)
            {
                value = true;
            }

            mRequest = null;
            return value;
        }
 public static StandardRequestModel creatGetGrupePackages(ClientInfoModel client, GroupInfoModel group)
 {
     StandardRequestModel request = null;
     if (client == null)
     {
         return request;
     }
     request = new StandardRequestModel();
     request.Client = client;
     request.request = RequestTyp.getGrupePackages;
     request.requestData = group;
     return request;
 }
        public static StandardRequestModel creatGetClientPackages(ClientInfoModel client, ClientInfoModel clientInfo)
        {
            StandardRequestModel request = null;

            if (client == null || clientInfo == null)
            {
                return request;
            }

            request = new StandardRequestModel();
            request.Client = client;
            request.request = RequestTyp.getClientPackages;
            request.requestData = clientInfo;

            return request;
        }
        public static StandardRequestModel creatSendSoftwarePackageRequest(ClientInfoModel client, GroupInfoModel group, PackageInfoModel package)
        {
            StandardRequestModel request = null;
            if (client == null)
            {
                return request;
            }

            string info = group.Name + "," + package.Name;
            request = new StandardRequestModel();
            request.Client = client;
            request.request = RequestTyp.sendSoftwarePackage;
            request.requestData = info;
            return request;
        }
 public static StandardRequestModel creatUpdateRequest(ClientInfoModel client)
 {
     StandardRequestModel request = null;
     if (client == null)
     {
         return request;
     }
     request = new StandardRequestModel();
     request.Client = client;
     request.request = RequestTyp.upDateRequest;
     request.requestData = null;
     return request;
 }