Example #1
0
        // Получение списка названий галактик на GRNode
        public static List <string> GetGalaxiesNames(string nodeName = null)
        {
            List <string> result = new List <string>();
            IGalaxies     gRepos = null;

            if (string.IsNullOrWhiteSpace(nodeName))
            {
                gRepos = _grAccessApp.QueryGalaxies("localhost");
            }
            else
            {
                gRepos = _grAccessApp.QueryGalaxies(nodeName);
            }
            if (!_grAccessApp.CommandResult.Successful)
            {
                throw new GalaxyExceptions(_grAccessApp.CommandResult);
            }
            if (gRepos != null)
            {
                foreach (IGalaxy item in gRepos)
                {
                    result.Add(item.Name);
                }
            }
            return(result);
        }
Example #2
0
 private void Form1_Load(object sender, EventArgs e)
 {
     galaxies = grAccess.QueryGalaxies();
     foreach (IGalaxy _galaxy in galaxies)
     {
         galaxyList.Items.Add(_galaxy.Name);
     }
 }
Example #3
0
        private void btnGetExistGalaxys_Click(object sender, EventArgs e)
        {
            list_galaxys.Items.Clear();
            galaxies = grAccess.QueryGalaxies(grNodeName);

            if (!grAccess.CommandResult.Successful)
            {
                list_galaxys.Items.Add("Error or not founded.");
            }
            else
            {
                foreach (IGalaxy galaxy in galaxies)
                {
                    list_galaxys.Items.Add(galaxy.Name);
                }
            }
        }
Example #4
0
        /// <summary>
        /// Attempt to make a connection to the Galaxy
        /// </summary>
        /// <returns></returns>
        public bool Connect(string GRNodeName, string GalaxyName, string UserName, string Password)
        {
            GRAccessApp grAccess;
            IGalaxy     galaxy;
            IGalaxies   galaxies;

            try
            {
                // Instantiate the GR Access App
                grAccess = new GRAccessApp();

                log.Debug("Retrieving Galaxies for " + GRNodeName);

                // Get a list of the available galaxies
                galaxies = grAccess.QueryGalaxies(GRNodeName);

                log.Debug("Getting Galaxy Reference for " + GalaxyName);

                //Get a reference to the Galaxy
                galaxy = galaxies[GalaxyName];

                log.Debug("Checking for Success");

                // Check to make sure we have a good reference to the Galaxy
                if (galaxy == null || !grAccess.CommandResult.Successful)
                {
                    throw new Exception(GalaxyName + " is not a legal Galaxy on " + GRNodeName);
                }

                log.Debug("Logging in with Username " + UserName);

                // Attempt to Login
                galaxy.LoginEx(UserName, Password, false);

                log.Debug("Checking for login success");

                //Check for success
                if (!galaxy.CommandResult.Successful)
                {
                    throw new Exception("Galaxy Login Failed");
                }

                // If we made it to hear we're good!
                log.Info("Login Succeeded");

                // Set the local reference
                this.Galaxy = galaxy;

                // return the connected status
                return(this.Connected);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #5
0
        //получение Galaxy по имени
        public static IGalaxy GetGalaxy(string galaxyName, string nodeName)
        {
            if (string.IsNullOrEmpty(galaxyName))
            {
                throw new ArgumentException(nameof(galaxyName));
            }
            _grAccessApp = null;
            _grAccessApp = new GRAccessApp();
            var galaxies = _grAccessApp.QueryGalaxies(nodeName);

            GalaxyExceptions.ThrowIfNoSuccess(_grAccessApp.CommandResult);
            IGalaxy galaxy = galaxies[galaxyName];

            GalaxyExceptions.ThrowIfNoSuccess(_grAccessApp.CommandResult);
            return(galaxy == null ? throw new GalaxyObjectNotFoundException(galaxyName) : galaxy);
        }
Example #6
0
 private void button1_Click(object sender, EventArgs e)
 {
     toolStripStatusLabel1.Text = "Fetching galaxies...";
     galaxies = grAccess.QueryGalaxies("localhost");
     if (!grAccess.CommandResult.Successful)
     {
         toolStripStatusLabel1.Text = "Failed to fetch galaxies, is this a GR node?";
     }
     else
     {
         foreach (IGalaxy galaxy in galaxies)
         {
             comboGalaxy.Items.Add(galaxy.Name);
         }
         toolStripStatusLabel1.Text = "Completed.";
     }
 }
Example #7
0
 // Получание спика галактик нa GRNode
 public static IGalaxies GetGalaxies(string nodeName = null)
 {
     _grAccessApp = new GRAccessApp();
     return(_grAccessApp.QueryGalaxies(nodeName) ?? throw new GalaxyExceptions($"Отстувуют Galaxy на {nodeName}", _grAccessApp.CommandResult));
 }