Esempio n. 1
0
        private bool ModifyClient()
        {
            bool ret = false;
            InsertModifyClientDialog dialog = new InsertModifyClientDialog()
            {
                DialogType = InsertModifyClientControlType.Modify
            };

            dialog.ServerSecure        = ServerSecure;
            dialog.ValidateClientData += new EventHandler <ClientInformationEventArgs>(dialog_Validate);
            dialog.Permissions         = Permissions;
            string aeTitle = dataGridView1.SelectedRows[0].Cells[0].Value.ToString();

            if (_clientInformationList.ClientDictionary.ContainsKey(aeTitle))
            {
                ClientInformation ciTemp = new ClientInformation(_clientInformationList.ClientDictionary[aeTitle]);
                dialog.ClientInformation = ciTemp;
                if (DialogResult.OK == dialog.ShowDialog())
                {
                    _clientInformationList.ClientDictionary.Remove(aeTitle);
                    _clientInformationList.ClientDictionary.Add(ciTemp.Client.AETitle, ciTemp);
                    UpdateSelectedRow(dialog.ClientInformation);
                    ret = true;
                }
            }
            return(ret);
        }
Esempio n. 2
0
        private bool InsertClient()
        {
            bool ret = false;
            InsertModifyClientDialog dialog = new InsertModifyClientDialog()
            {
                DialogType = InsertModifyClientControlType.Insert
            };

            dialog.ServerSecure = ServerSecure;
            dialog.Permissions  = Permissions;
            List <string> permissionList = new List <string>();

            foreach (Permission p in NewClientPermissions)
            {
                permissionList.Add(p.Name);
            }
            dialog.ClientInformation   = new ClientInformation(null, permissionList.ToArray());
            dialog.ValidateClientData += new EventHandler <ClientInformationEventArgs>(dialog_Validate);
            if (DialogResult.OK == dialog.ShowDialog())
            {
                AddRow(dialog.ClientInformation);
                _clientInformationList.ClientDictionary.Add(dialog.ClientInformation.Client.AETitle, dialog.ClientInformation);
                ret = true;
            }
            return(ret);
        }
Esempio n. 3
0
        void dialog_Validate(object sender, ClientInformationEventArgs e)
        {
            string error = string.Empty;
            InsertModifyClientDialog dialog = (InsertModifyClientDialog)sender;

            e.IsValid = true;
            // Clear existing errors
            dialog.ValidateAeTitle(string.Empty);
            dialog.ValidateAddress(string.Empty);
            dialog.ValidateMask(string.Empty);
            dialog.ValidatePort(string.Empty);
            dialog.ValidateSecurePort(string.Empty);

            // AETitle
            if (!Utils.IsValidApplicationEntity(e.ClientInformation.Client.AETitle, out error))
            {
                dialog.ValidateAeTitle(error);
                e.IsValid = false;
            }
            else if (e.IsInsert && (ClientInformationList.ClientDictionary.ContainsKey(e.ClientInformation.Client.AETitle.Trim())))
            {
                // insert -- verify AeTile does not already exist
                dialog.ValidateAeTitle("Duplicate Application Entity Title.");
                e.IsValid = false;
            }
            else if (!e.IsInsert && e.IsNewAeTitle && (ClientInformationList.ClientDictionary.ContainsKey(e.ClientInformation.Client.AETitle.Trim())))
            {
                // modify and the aeTitle has changed -- verify the AeTitle does not already exist
                dialog.ValidateAeTitle("Duplicate Application Entity Title.");
                e.IsValid = false;
            }
            else if (e.ClientInformation.Client.VerifyAddress && !Utils.IsValidHostnameOrAddress(e.ClientInformation.Client.Address, out error))
            {
                // Address
                dialog.ValidateAddress(error);
                e.IsValid = false;
            }
            else if (e.ClientInformation.Client.VerifyMask && !Utils.IsValidHostnameOrAddress(e.ClientInformation.Client.Mask, out error))
            {
                // Mask
                dialog.ValidateMask(error);
                e.IsValid = false;
            }
            else if (e.ClientInformation.Client.Port == 0)
            {
                // port
                dialog.ValidatePort("Port must be non-zero");
                e.IsValid = false;
            }
            else if (e.ClientInformation.Client.SecurePort == 0)
            {
                // secure port
                dialog.ValidateSecurePort("Port must be non-zero");
                e.IsValid = false;
            }
        }