hMailServer.Administrator.ucIPRange.SaveData C# (CSharp) Method

SaveData() public method

public SaveData ( ) : bool
return bool
        public bool SaveData()
        {
            bool newObject = false;
             if (_representedObject == null)
             {
            hMailServer.Application app = APICreator.Application;
            hMailServer.Settings settings = app.Settings;
            hMailServer.SecurityRanges securityRanges = settings.SecurityRanges;
            _representedObject = securityRanges.Add();

            newObject = true;

            Marshal.ReleaseComObject(settings);
            Marshal.ReleaseComObject(securityRanges);
             }

             _representedObject.Name = textName.Text;
             _representedObject.Priority= textPriority.Number;

             _representedObject.LowerIP = textLowerIPAddress.Text;
             _representedObject.UpperIP = textUpperIPAddress.Text;

             _representedObject.AllowSMTPConnections = checkAllowSMTP.Checked;
             _representedObject.AllowPOP3Connections = checkAllowPOP3.Checked;
             _representedObject.AllowIMAPConnections = checkAllowIMAP.Checked;

             _representedObject.RequireSMTPAuthLocalToLocal = checkRequireSMTPAuthLocalToLocal.Checked;
             _representedObject.RequireSMTPAuthLocalToExternal = checkRequireSMTPAuthLocalToExternal.Checked;
             _representedObject.RequireSMTPAuthExternalToLocal = checkRequireSMTPAuthExternalToLocal.Checked;
             _representedObject.RequireSMTPAuthExternalToExternal = checkRequireSMTPAuthExternalToExternal.Checked;

             _representedObject.AllowDeliveryFromLocalToLocal = checkAllowDeliveiesFromL2L.Checked;
             _representedObject.AllowDeliveryFromLocalToRemote = checkAllowDeliveiesFromL2R.Checked;
             _representedObject.AllowDeliveryFromRemoteToLocal = checkAllowDeliveiesFromR2L.Checked;
             _representedObject.AllowDeliveryFromRemoteToRemote = checkAllowDeliveiesFromR2R.Checked;

             _representedObject.EnableSpamProtection = checkSpamProtection.Checked;
             _representedObject.EnableAntiVirus = checkAntiVirus.Checked;

             _representedObject.Expires = checkExpires.Checked;
             _representedObject.ExpiresTime = dateTimeExpiresTime.Value;

             try
             {
            _representedObject.Save();
             }
             catch (Exception e)
             {
            MessageBox.Show(e.Message, EnumStrings.hMailServerAdministrator, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            return false;
             }

             // Refresh the node in the tree if the name has changed.
             IMainForm mainForm = Instances.MainForm;
             mainForm.RefreshCurrentNode(checkExpires.Checked ? Color.Red : Color.Black, textName.Text);

             // Set the object to clean.
             DirtyChecker.SetClean(this);

             if (newObject)
             {
            SearchNodeText crit = new SearchNodeText(_representedObject.Name);
            mainForm.SelectNode(crit);
             }

             return true;
        }