Exemplo 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;
        }
 public void DeleteProfile(AgentProfile profile)
 {
     DeleteInternal(profile.Id);
     if (OnChanged != null)
     {
         OnChanged(null, EventArgs.Empty);
     }
 }
 public void AddProfile(AgentProfile profile)
 {
     AddInternal(profile);
     if (OnChanged != null)
     {
         OnChanged(null, EventArgs.Empty);
     }
 }
Exemplo n.º 4
0
 public void DeleteProfile(AgentProfile profile)
 {
     DeleteInternal(profile.Id);
     if (OnChanged != null)
     {
         OnChanged(null, EventArgs.Empty);
     }
 }
Exemplo n.º 5
0
 public void AddProfile(AgentProfile profile)
 {
     AddInternal(profile);
     if (OnChanged != null)
     {
         OnChanged(null, EventArgs.Empty);
     }
 }
Exemplo n.º 6
0
 public FormProfile(AgentProfile agent)
 {
     InitializeComponent();
     _profile = agent;
     if (PlatformSupport.Platform == PlatformType.Windows)
     {
         Icon = Properties.Resources.network_server;
     }
 }
Exemplo n.º 7
0
 public FormProfile(AgentProfile agent)
 {
     InitializeComponent();
     _profile = agent;
     if (PlatformSupport.Platform == PlatformType.Windows)
     {
         Icon = Properties.Resources.network_server;
     }
 }
Exemplo 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)
                {
                }
            }
        }
Exemplo 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");
        }
Exemplo 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;
            }
        }
Exemplo 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;
            }
        }
Exemplo 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;
        }
Exemplo 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;
 }
Exemplo 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);
        }