Ejemplo n.º 1
0
        private void LoadDefaultProfile()
        {
            AgentProfile first = AgentProfileFactory.Create(Guid.Empty, VersionCode.V1, new IPEndPoint(IPAddress.Loopback, 161), "public", "private", "localhost", string.Empty, string.Empty, 0, 0, string.Empty, 1000);

            AddProfile(first);
            DefaultProfile = first;
        }
Ejemplo n.º 2
0
 public void DeleteProfile(AgentProfile profile)
 {
     DeleteInternal(profile.Id);
     if (OnChanged != null)
     {
         OnChanged(null, EventArgs.Empty);
     }
 }
Ejemplo n.º 3
0
 public void AddProfile(AgentProfile profile)
 {
     AddInternal(profile);
     if (OnChanged != null)
     {
         OnChanged(null, EventArgs.Empty);
     }
 }
Ejemplo n.º 4
0
 public void DeleteProfile(AgentProfile profile)
 {
     DeleteInternal(profile.Id);
     if (OnChanged != null)
     {
         OnChanged(null, EventArgs.Empty);
     }
 }
Ejemplo n.º 5
0
 public void AddProfile(AgentProfile profile)
 {
     AddInternal(profile);
     if (OnChanged != null)
     {
         OnChanged(null, EventArgs.Empty);
     }
 }
Ejemplo n.º 6
0
 public FormProfile(AgentProfile agent)
 {
     InitializeComponent();
     _profile = agent;
     if (PlatformSupport.Platform == PlatformType.Windows)
     {
         Icon = Properties.Resources.network_server;
     }
 }
Ejemplo n.º 7
0
 public FormProfile(AgentProfile agent)
 {
     InitializeComponent();
     _profile = agent;
     if (PlatformSupport.Platform == PlatformType.Windows)
     {
         Icon = Properties.Resources.network_server;
     }
 }
Ejemplo n.º 8
0
        private void ActEditExecute(object sender, EventArgs e)
        {
            AgentProfile profile = listView1.SelectedItems[0].Tag as AgentProfile;

            using (FormProfile editor = new FormProfile(profile))
            {
                if (editor.ShowDialog() == DialogResult.OK)
                {
                }
            }
        }
Ejemplo n.º 9
0
        private void TxtIpValidating(object sender, CancelEventArgs e)
        {
            IPAddress ip;

            if (AgentProfile.IsValid(txtIP.Text, out ip))
            {
                return;
            }

            e.Cancel = true;
            txtIP.SelectAll();
            errorProvider1.SetError(txtIP, "IP address is not valid");
        }
Ejemplo n.º 10
0
        private void AddInternal(AgentProfile profile)
        {
            if (_profiles.ContainsKey(profile.Id))
            {
                throw new BrowserException("This endpoint is already registered");
            }

            _profiles.Add(profile.Id, profile);

            if (DefaultProfile == null)
            {
                DefaultProfile = profile;
            }
        }
Ejemplo n.º 11
0
        private void AddInternal(AgentProfile profile)
        {
            if (_profiles.ContainsKey(profile.Id))
            {
                throw new BrowserException("This endpoint is already registered");
            }

            _profiles.Add(profile.Id, profile);

            if (DefaultProfile == null)
            {
                DefaultProfile = profile;
            }
        }
Ejemplo n.º 12
0
        private int LoadProfilesFromFile()
        {
            if (!File.Exists(SettingFile))
            {
                return 0;
            }

            Guid defaultId = Guid.Empty;
            using (XmlTextReader reader = new XmlTextReader(SettingFile))
            {
                try
                {
                    while (reader.Read())
                    {
                        switch (reader.NodeType)
                        {
                            case XmlNodeType.Element:
                                {
                                    if (reader.Name == NameAgent)
                                    {
                                        defaultId = new Guid(reader.GetAttribute(NameDefaultAgent));
                                    }
                                    else if (reader.Name == NameAdd)
                                    {
                                        string name = reader.GetAttribute(NameName);
                                        Guid id = new Guid(reader.GetAttribute(NameId));
                                        string[] parts = reader.GetAttribute(NameBinding).Split(new[] { ':' });
                                        IPAddress def = IPAddress.Parse(parts[0]);
                                        int port = int.Parse(parts[1], CultureInfo.InvariantCulture);
                                        VersionCode vc = (VersionCode)int.Parse(reader.GetAttribute(NameVersion), CultureInfo.InvariantCulture);
                                        string get = reader.GetAttribute(NameGetCommunity);
                                        string set = reader.GetAttribute(NameSetCommunity);
                                        string authenticationPassphrase = reader.GetAttribute(NameAuthenticationPassphrase);
                                        string privacyPassphrase = reader.GetAttribute(NamePrivacyPassphrase);
                                        string authenticationMethod = reader.GetAttribute(NameAuthenticationMethod);
                                        string privacyMethod = reader.GetAttribute(NamePrivacyMethod);
                                        string userName = reader.GetAttribute(NameUserName);
                                        int timeout = int.Parse(reader.GetAttribute(NameTimeout), CultureInfo.InvariantCulture);

                                        AgentProfile profile = AgentProfileFactory.Create(
                                            id, 
                                            vc, 
                                            new IPEndPoint(def, port), 
                                            get, 
                                            set, 
                                            name,
                                            authenticationPassphrase, 
                                            privacyPassphrase,
                                            string.IsNullOrEmpty(authenticationMethod) ? 0 : int.Parse(authenticationMethod, CultureInfo.InvariantCulture),
                                            string.IsNullOrEmpty(privacyMethod) ? 0 : int.Parse(privacyMethod, CultureInfo.InvariantCulture),
                                            userName, 
                                            timeout);
                                        if (id == defaultId)
                                        {
                                            DefaultProfile = profile;
                                        }
                                        
                                        AddProfile(profile);
                                    }
                                    
                                    break;
                                }
                                
                            default:
                                break;
                        }
                    }
                }
                catch (Exception ex)
                {
                    Logger.Info(ex.ToString());
                }
                finally
                {
                    reader.Close();
                }
            }

            return _profiles.Count;
        }
Ejemplo n.º 13
0
 private void LoadDefaultProfile()
 {
     AgentProfile first = AgentProfileFactory.Create(Guid.Empty, VersionCode.V1, new IPEndPoint(IPAddress.Loopback, 161), "public", "private", "localhost", string.Empty, string.Empty, 0, 0, string.Empty, 1000);
     AddProfile(first);
     DefaultProfile = first;
 }
Ejemplo n.º 14
0
        private int LoadProfilesFromFile()
        {
            if (!File.Exists(SettingFile))
            {
                return(0);
            }

            Guid defaultId = Guid.Empty;

            using (XmlTextReader reader = new XmlTextReader(SettingFile))
            {
                try
                {
                    while (reader.Read())
                    {
                        switch (reader.NodeType)
                        {
                        case XmlNodeType.Element:
                        {
                            if (reader.Name == NameAgent)
                            {
                                defaultId = new Guid(reader.GetAttribute(NameDefaultAgent));
                            }
                            else if (reader.Name == NameAdd)
                            {
                                string      name  = reader.GetAttribute(NameName);
                                Guid        id    = new Guid(reader.GetAttribute(NameId));
                                string[]    parts = reader.GetAttribute(NameBinding).Split(new[] { ':' });
                                IPAddress   def   = IPAddress.Parse(parts[0]);
                                int         port  = int.Parse(parts[1], CultureInfo.InvariantCulture);
                                VersionCode vc    = (VersionCode)int.Parse(reader.GetAttribute(NameVersion), CultureInfo.InvariantCulture);
                                string      get   = reader.GetAttribute(NameGetCommunity);
                                string      set   = reader.GetAttribute(NameSetCommunity);
                                string      authenticationPassphrase = reader.GetAttribute(NameAuthenticationPassphrase);
                                string      privacyPassphrase        = reader.GetAttribute(NamePrivacyPassphrase);
                                string      authenticationMethod     = reader.GetAttribute(NameAuthenticationMethod);
                                string      privacyMethod            = reader.GetAttribute(NamePrivacyMethod);
                                string      userName = reader.GetAttribute(NameUserName);
                                int         timeout  = int.Parse(reader.GetAttribute(NameTimeout), CultureInfo.InvariantCulture);

                                AgentProfile profile = AgentProfileFactory.Create(
                                    id,
                                    vc,
                                    new IPEndPoint(def, port),
                                    get,
                                    set,
                                    name,
                                    authenticationPassphrase,
                                    privacyPassphrase,
                                    string.IsNullOrEmpty(authenticationMethod) ? 0 : int.Parse(authenticationMethod, CultureInfo.InvariantCulture),
                                    string.IsNullOrEmpty(privacyMethod) ? 0 : int.Parse(privacyMethod, CultureInfo.InvariantCulture),
                                    userName,
                                    timeout);
                                if (id == defaultId)
                                {
                                    DefaultProfile = profile;
                                }

                                AddProfile(profile);
                            }

                            break;
                        }

                        default:
                            break;
                        }
                    }
                }
                catch (Exception ex)
                {
                    Logger.Info(ex.ToString());
                }
                finally
                {
                    reader.Close();
                }
            }

            return(_profiles.Count);
        }