Пример #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Oracle");
            string Serial = ConsoleInfo.GetConsoleSerialNumber();

            Console.WriteLine(Serial);
        }
Пример #2
0
        public void SelfUpdateNewVersionDoesUpdatesExe()
        {
            // Arrange
            var      factory        = new Mock <IPackageRepositoryFactory>();
            var      sourceProvider = new Mock <IPackageSourceProvider>();
            var      repository     = new MockPackageRepository();
            IPackage package        = PackageUtility.CreatePackage("NuGet.CommandLine", "3.0", tools: new[] { "NuGet.exe" });

            repository.Add(package);
            factory.Setup(m => m.CreateRepository(It.IsAny <string>())).Returns(repository);

            ConsoleInfo consoleInfo = GetConsoleInfo();
            var         updateCmd   = new MockUpdateCommand(factory.Object, sourceProvider.Object);

            updateCmd.Console = consoleInfo.Console;

            // Act
            updateCmd.SelfUpdate(@"c:\NuGet.exe", new SemanticVersion("2.0"));

            // Assert
            Assert.True(updateCmd.MovedFiles.ContainsKey(@"c:\NuGet.exe"));
            Assert.Equal(@"c:\NuGet.exe.old", updateCmd.MovedFiles[@"c:\NuGet.exe"]);
            Assert.True(updateCmd.UpdatedFiles.ContainsKey(@"c:\NuGet.exe"));
            Assert.Equal(@"tools\NuGet.exe", updateCmd.UpdatedFiles[@"c:\NuGet.exe"]);
        }
Пример #3
0
        public void Init(ConsoleInfo consoleInfo)
        {
            if (consoleInfo == null) throw new ArgumentNullException(nameof(ConsoleInfo));
            ConsoleInfo = consoleInfo;
            _nextProgressBarId = consoleInfo.ProgressBarId;//初始化

            if (consoleInfo != null && consoleInfo.StartTime == DateTime.MinValue)
            {
                consoleInfo.StartTime = DateTime.UtcNow;
            }
        }
Пример #4
0
        public void Init(ConsoleInfo consoleInfo)
        {
            if (consoleInfo == null)
            {
                throw new ArgumentNullException(nameof(ConsoleInfo));
            }
            ConsoleInfo = consoleInfo;


            if (consoleInfo != null && consoleInfo.StartTime == DateTime.MinValue)
            {
                consoleInfo.StartTime = DateTime.UtcNow;
            }
        }
Пример #5
0
        public void SelfUpdateNoCommandLinePackageOnServerThrows()
        {
            // Arrange
            var factory = new Mock <IPackageRepositoryFactory>();

            factory.Setup(m => m.CreateRepository(It.IsAny <PackageSource>())).Returns(new MockPackageRepository());

            ConsoleInfo consoleInfo = GetConsoleInfo();
            var         updateCmd   = new UpdateCommand(factory.Object);

            updateCmd.Console = consoleInfo.Console;

            // Act
            ExceptionAssert.Throws <CommandLineException>(() => updateCmd.SelfUpdate("c:\foo.exe", new Version("2.0")), "Unable to find 'NuGet.CommandLine' package.");
        }
Пример #6
0
        private UpdateCommand ArrangeForUpdatePackages(out Mock <IProjectManager> projectManager, out MockPackageRepository localRepository)
        {
            var factory        = new Mock <IPackageRepositoryFactory>();
            var sourceProvider = new Mock <IPackageSourceProvider>();

            localRepository = new MockPackageRepository();
            factory.Setup(m => m.CreateRepository(It.IsAny <string>())).Returns(localRepository);

            projectManager = new Mock <IProjectManager>(MockBehavior.Strict);

            ConsoleInfo consoleInfo = GetConsoleInfo();
            var         updateCmd   = new UpdateCommand(factory.Object, sourceProvider.Object);

            updateCmd.Console = consoleInfo.Console;
            return(updateCmd);
        }
Пример #7
0
        public void SelfUpdateNoCommandLinePackageOnServerThrows()
        {
            // Arrange
            var factory = new Mock <IPackageRepositoryFactory>();

            factory.Setup(m => m.CreateRepository(It.IsAny <string>())).Returns(new MockPackageRepository());

            ConsoleInfo consoleInfo = GetConsoleInfo();
            var         selfUpdater = new SelfUpdater(factory.Object)
            {
                Console = consoleInfo.Console
            };

            // Act
            ExceptionAssert.Throws <CommandLineException>(() => selfUpdater.SelfUpdate("c:\foo.exe", new SemanticVersion("2.0")),
                                                          "Unable to find 'NuGet.CommandLine' package.");
        }
Пример #8
0
        public void SelfUpdateNoNuGetExeInNuGetExePackageThrows()
        {
            // Arrange
            var factory    = new Mock <IPackageRepositoryFactory>();
            var repository = new MockPackageRepository();

            repository.Add(PackageUtility.CreatePackage("NuGet.CommandLine", "3.0"));
            factory.Setup(m => m.CreateRepository(It.IsAny <PackageSource>())).Returns(repository);

            ConsoleInfo consoleInfo = GetConsoleInfo();
            var         updateCmd   = new UpdateCommand(factory.Object);

            updateCmd.Console = consoleInfo.Console;
            updateCmd.Console = consoleInfo.Console;

            // Act & Assert
            ExceptionAssert.Throws <CommandLineException>(() => updateCmd.SelfUpdate("c:\foo.exe", new Version("2.0")), "Invalid NuGet.CommandLine package. Unable to locate NuGet.exe within the package.");
        }
Пример #9
0
        static void Main(string[] args)
        {
            ConsoleInfo consoleSettings = ConsoleInfo.CurrentInfo();

            try
            {
                //Create the dependency injection service provider
                serviceProvider = CreateServiceProvider();

                //Parse the arguments from the command line and act in accordance to whether they were parsed
                //successfully or not
                var parseResult = CommandLine.Parser.Default.ParseArguments <CommandLineOptions>(args)
                                  .WithParsed(options =>
                {
                    //Keep track of when the sort operation begins
                    Stopwatch stopwatch = new Stopwatch();
                    stopwatch.Start();

                    //Sort the integers
                    List <string> intermediateFiles = SortIntegers(options);

                    //If the option to keep the intermediate files was not specified, delete them
                    if (!options.KeepIntermediate)
                    {
                        DeleteIntermediateFiles(intermediateFiles);
                    }

                    //Display the amount of time it took to perform the entire sort operation
                    stopwatch.Stop();

                    DisplayElapsedTime(stopwatch.Elapsed);
                })
                                  .WithNotParsed(errors => Environment.ExitCode = -1);
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.Message);
            }
            finally
            {
                ConsoleInfo.RestoreSettings(consoleSettings);
            }
        }
Пример #10
0
        // Insert new console into database
        public void InsertConsole(ConsoleInfo newConsole)
        {
            using (SqlConnection connection = new SqlConnection(connectString))
                using (SqlCommand cmd = new SqlCommand("INSERT INTO Consoles (name,manufacturer,container_id,switchbox_id,switchbox_no) VALUES(@Name,@Manufacturer,@ContainerId,@SwitchboxId,@SwitchboxNo)", connection))
                {
                    // Add parameters
                    cmd.Parameters.AddWithValue("@Name", newConsole.name);
                    cmd.Parameters.AddWithValue("@Manufacturer", newConsole.manufacturer);
                    cmd.Parameters.AddWithValue("@ContainerId", newConsole.containerId);
                    cmd.Parameters.AddWithValue("@SwitchboxId", newConsole.switchBoxId);
                    cmd.Parameters.AddWithValue("@SwitchboxNo", newConsole.switchBoxNo);
                    // Open connection and insert
                    connection.Open();
                    cmd.ExecuteNonQuery();

                    // Disconnect
                    connection.Close();
                }
        }
Пример #11
0
 private void Read()
 {
     try
     {
         using (var inputStream = new FileStream(_inputFile, FileMode.Open))
         {
             while (inputStream.Position < inputStream.Length)
             {
                 _gZipStrategy.Read(inputStream, _queueReader);
                 ConsoleInfo.ShowPercent(inputStream.Position);
             }
             _queueReader.Stop();
         }
     }
     catch (Exception ex)
     {
         HandleException(ex.Message);
     }
 }
Пример #12
0
        /// <summary>Return a list of informations for each console available.</summary>
        public List <ConsoleInfo> GetConsoleList()
        {
            List <ConsoleInfo> data = new List <ConsoleInfo>();
            int    targetCount      = getNumberOfConsoles();
            IntPtr name             = Marshal.AllocHGlobal((int)(512)),
                   ip = Marshal.AllocHGlobal((int)(512));

            for (int i = 0; i < targetCount; i++)
            {
                ConsoleInfo Info = new ConsoleInfo();
                getConsoleInfo(i, name, ip);
                Info.Name = Marshal.PtrToStringAnsi(name);
                Info.Ip   = Marshal.PtrToStringAnsi(ip);
                data.Add(Info);
            }
            Marshal.FreeHGlobal(name);
            Marshal.FreeHGlobal(ip);
            return(data);
        }
Пример #13
0
        /// <summary>
        /// The main entry point for this program
        /// </summary>
        /// <param name="args">The raw command line arguments</param>
        static void Main(string[] args)
        {
            ConsoleInfo consoleSettings = ConsoleInfo.CurrentInfo();

            try
            {
                //Create the dependency injection service provider
                serviceProvider = CreateServiceProvider();

                //Parse the arguments from the command line and act in accordance to whether they were parsed
                //successfully or not
                var parseResult = CommandLine.Parser.Default.ParseArguments <CommandLineOptions>(args)
                                  .WithParsed(options =>
                {
                    //Keep track of when the integer generation operation begins
                    Stopwatch stopwatch = new Stopwatch();
                    stopwatch.Start();

                    //Create the progress bar
                    var progressBar = CreateProgressBar(options.Count);

                    //Generate the integers and pass a method that will update the progress bar
                    GenerateIntegers(options, generatedIntegers => UpdateProgressBar(progressBar, generatedIntegers));

                    OnProgressBarCompleted();

                    //Display the amount of time it took to perform the entire integer generation operation
                    stopwatch.Stop();

                    DisplayElapsedTime(stopwatch.Elapsed);
                })
                                  .WithNotParsed(errors => Environment.ExitCode = -1);
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.Message);
            }
            finally
            {
                ConsoleInfo.RestoreSettings(consoleSettings);
            }
        }
Пример #14
0
        public void SelfUpdateOlderVersionDoesNotUpdate()
        {
            // Arrange
            var factory    = new Mock <IPackageRepositoryFactory>();
            var repository = new MockPackageRepository();

            repository.Add(PackageUtility.CreatePackage("NuGet.CommandLine", "1.0"));
            factory.Setup(m => m.CreateRepository(It.IsAny <PackageSource>())).Returns(repository);

            ConsoleInfo consoleInfo = GetConsoleInfo();
            var         updateCmd   = new UpdateCommand(factory.Object);

            updateCmd.Console = consoleInfo.Console;

            // Act
            updateCmd.SelfUpdate("c:\foo.exe", new Version("2.0"));

            // Assert
            Assert.AreEqual("NuGet.exe is up to date.", consoleInfo.WrittenLines[0]);
        }
Пример #15
0
        // Update console in database
        public void UpdateConsole(ConsoleInfo updateConsole)
        {
            using (SqlConnection connection = new SqlConnection(connectString))
                using (SqlCommand cmd = new SqlCommand("UPDATE Consoles SET name = @Name,manufacturer = @Manufacturer,container_id = @ContainerId,switchbox_id = @SwitchboxId,switchbox_no = @SwitchboxNo WHERE cid = @Cid", connection))
                {
                    // Add parameters
                    cmd.Parameters.AddWithValue("@Cid", updateConsole.cid);
                    cmd.Parameters.AddWithValue("@Name", updateConsole.name);
                    cmd.Parameters.AddWithValue("@Manufacturer", updateConsole.manufacturer);
                    cmd.Parameters.AddWithValue("@ContainerId", updateConsole.containerId);
                    cmd.Parameters.AddWithValue("@SwitchboxId", updateConsole.switchBoxId);
                    cmd.Parameters.AddWithValue("@SwitchboxNo", updateConsole.switchBoxNo);
                    // Open connection and insert
                    connection.Open();
                    cmd.ExecuteNonQuery();

                    // Disconnect
                    connection.Close();
                }
        }
Пример #16
0
        public void SelfUpdateOlderVersionDoesNotUpdate()
        {
            // Arrange
            var factory    = new Mock <IPackageRepositoryFactory>();
            var repository = new MockPackageRepository();

            repository.Add(PackageUtility.CreatePackage("NuGet.CommandLine", "1.0"));
            factory.Setup(m => m.CreateRepository(It.IsAny <string>())).Returns(repository);

            ConsoleInfo consoleInfo = GetConsoleInfo();
            var         selfUpdater = new SelfUpdater(factory.Object)
            {
                Console = consoleInfo.Console
            };

            // Act
            selfUpdater.SelfUpdate("c:\foo.exe", new SemanticVersion("2.0"));

            // Assert
            Assert.Equal("NuGet.exe is up to date.", consoleInfo.WrittenLines[0]);
        }
Пример #17
0
    public List <ConsoleInfo> GetConsoleList()
    {
        List <ConsoleInfo> list = new List <ConsoleInfo>();

        IntPtr name = malloc(512 * sizeof(char));
        IntPtr ip   = malloc(512 * sizeof(char));

        for (int i = 0; i < CCAPIGetNumberOfConsoles(); i++)
        {
            ConsoleInfo c = new ConsoleInfo();
            CCAPIGetConsoleInfo(i, name, ip);
            c.name = ptr2String(name);
            c.ip   = ptr2String(ip);
            list.Add(c);
        }

        free(name);
        free(ip);

        return(list);
    }
Пример #18
0
        static void Main(string[] args)
        {
            var mainService = new MainService();
            var consoleInfo = ConsoleInfo.GetInstance();

            new Thread(o => mainService.Start(100000)).Start();

            var counter = 1;

            while (true)
            {
                Console.WriteLine($"{counter}: {DateTime.Now}.");
                Console.WriteLine($"Sent object count: {consoleInfo.GetSentObjectCount()}.");
                Console.WriteLine($"db object count: {consoleInfo.GetObjectCount()}.");

                Console.WriteLine($"\n \n");
                counter++;

                Thread.Sleep(1000);
            }


            Console.ReadKey();
        }
Пример #19
0
        /* ==========================
         * CONSOLES
         * ==========================*/
        // Get the data for all consoles
        public List<ConsoleInfo> GetAllConsoles()
        {
            // Initialize list
            List<ConsoleInfo> consoleList = new List<ConsoleInfo>();

            // Get all game info and store into list
            using (SqlConnection connection = new SqlConnection(connectString))
            using (SqlCommand cmd = new SqlCommand("SELECT cid, Consoles.name, manufacturer, container_id, switchbox_id, switchbox_no, Switchboxes.name as SName FROM Consoles LEFT JOIN Switchboxes ON Consoles.switchbox_id = Switchboxes.sid ORDER BY Consoles.name asc", connection))
            {
                connection.Open();
                using (SqlDataReader reader = cmd.ExecuteReader())
                {
                    // Check if the reader has any rows at all before starting to read
                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            ConsoleInfo c = new ConsoleInfo();
                            c.cid = reader.GetInt32(reader.GetOrdinal("cid"));

                            c.name = reader.GetString(reader.GetOrdinal("name"));

                            // Make sure to check for nulls
                            int manIndex = reader.GetOrdinal("manufacturer");
                            if (!reader.IsDBNull(manIndex)) c.manufacturer = reader.GetString(manIndex);

                            int containerIndex = reader.GetOrdinal("container_id");
                            if (!reader.IsDBNull(containerIndex)) c.containerId = reader.GetInt32(containerIndex);

                            // Switchbox stuff
                            int sbIDindex = reader.GetOrdinal("switchbox_id");
                            if (!reader.IsDBNull(sbIDindex)) c.switchBoxId = reader.GetInt32(sbIDindex);

                            int sbNoIndex = reader.GetOrdinal("switchbox_no");
                            if (!reader.IsDBNull(sbNoIndex)) c.switchBoxNo = reader.GetInt32(sbNoIndex);

                            int sbNameIndex = reader.GetOrdinal("SName");
                            if (!reader.IsDBNull(sbNameIndex)) c.switchBoxName = reader.GetString(sbNameIndex);

                            consoleList.Add(c);
                        }
                    }
                }
                // Disconnect
                connection.Close();
            }

            // Return list
            return consoleList;
        }
Пример #20
0
 // Обработка исключений с прерыванием работы потоков
 private void HandleException(string errorMsg)
 {
     _status = Status.failed;
     _threadManager.Abort();
     ConsoleInfo.ShowError(errorMsg);
 }
Пример #21
0
 public MainService()
 {
     _redisService = new RedisService();
     _consoleInfo  = ConsoleInfo.GetInstance();
 }
Пример #22
0
        /* ==========================
         * CONSOLES
         * ==========================*/

        // Get the data for all consoles
        public List <ConsoleInfo> GetAllConsoles()
        {
            // Initialize list
            List <ConsoleInfo> consoleList = new List <ConsoleInfo>();

            // Get all game info and store into list
            using (SqlConnection connection = new SqlConnection(connectString))
                using (SqlCommand cmd = new SqlCommand("SELECT cid, Consoles.name, manufacturer, container_id, switchbox_id, switchbox_no, Switchboxes.name as SName FROM Consoles LEFT JOIN Switchboxes ON Consoles.switchbox_id = Switchboxes.sid ORDER BY Consoles.name asc", connection))
                {
                    connection.Open();
                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        // Check if the reader has any rows at all before starting to read
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                ConsoleInfo c = new ConsoleInfo();
                                c.cid = reader.GetInt32(reader.GetOrdinal("cid"));

                                c.name = reader.GetString(reader.GetOrdinal("name"));

                                // Make sure to check for nulls
                                int manIndex = reader.GetOrdinal("manufacturer");
                                if (!reader.IsDBNull(manIndex))
                                {
                                    c.manufacturer = reader.GetString(manIndex);
                                }

                                int containerIndex = reader.GetOrdinal("container_id");
                                if (!reader.IsDBNull(containerIndex))
                                {
                                    c.containerId = reader.GetInt32(containerIndex);
                                }

                                // Switchbox stuff
                                int sbIDindex = reader.GetOrdinal("switchbox_id");
                                if (!reader.IsDBNull(sbIDindex))
                                {
                                    c.switchBoxId = reader.GetInt32(sbIDindex);
                                }

                                int sbNoIndex = reader.GetOrdinal("switchbox_no");
                                if (!reader.IsDBNull(sbNoIndex))
                                {
                                    c.switchBoxNo = reader.GetInt32(sbNoIndex);
                                }

                                int sbNameIndex = reader.GetOrdinal("SName");
                                if (!reader.IsDBNull(sbNameIndex))
                                {
                                    c.switchBoxName = reader.GetString(sbNameIndex);
                                }

                                consoleList.Add(c);
                            }
                        }
                    }
                    // Disconnect
                    connection.Close();
                }

            // Return list
            return(consoleList);
        }
Пример #23
0
        public void ParseConsole(ConsoleInfo cn)
        {
            var con = statedyn["console"];
            var r = (float?) con["background_color"]["r"] ?? 0;
            var g = (float?) con["background_color"]["g"] ?? 0;
            var b = (float?) con["background_color"]["b"] ?? 0;
            var a = (float?) con["background_color"]["a"] ?? 0;
            cn.SetBackgroundColor(r / 255, g / 255, b / 255, a / 255);

            var tmpF = (float?) con["spacing"] ?? 0;
            if (tmpF.IsBetween(CON_MIN_LINE_INTERVAL, CON_MAX_LINE_INTERVAL))
                cn.Spacing = tmpF;

            var tmpI = (ushort?) con["line_size"] ?? 0;
            if (tmpI.IsBetween(CON_MIN_LINE_SIZE, CON_MAX_LINE_SIZE))
                cn.LineSize = tmpI;

            tmpI = (ushort?) con["showing_lines"] ?? 0;
            if (tmpI.IsBetween(CON_MIN_LINES, CON_MAX_LINES))
                cn.VisibleLines = tmpI;

            tmpI = (ushort?) con["log_size"] ?? 0;
            if (tmpI.IsBetween(CON_MIN_LOG, CON_MAX_LOG))
                cn.HistorySize = tmpI;

            tmpI = (ushort?) con["lines_count"] ?? 0;
            if (tmpI.IsBetween(CON_MIN_LOG, CON_MAX_LOG))
                cn.BufferSize = tmpI;

            var tmpB = (bool?) con["show"] ?? false;
            cn.IsVisible = tmpB;

            tmpF = (float?) con["show_cursor_period"] ?? 0;
            cn.BlinkPeriod = tmpF;
        }
Пример #24
0
        // Update console in database
        public void UpdateConsole(ConsoleInfo updateConsole)
        {
            using (SqlConnection connection = new SqlConnection(connectString))
            using (SqlCommand cmd = new SqlCommand("UPDATE Consoles SET name = @Name,manufacturer = @Manufacturer,container_id = @ContainerId,switchbox_id = @SwitchboxId,switchbox_no = @SwitchboxNo WHERE cid = @Cid", connection))
            {
                // Add parameters
                cmd.Parameters.AddWithValue("@Cid", updateConsole.cid);
                cmd.Parameters.AddWithValue("@Name", updateConsole.name);
                cmd.Parameters.AddWithValue("@Manufacturer", updateConsole.manufacturer);
                cmd.Parameters.AddWithValue("@ContainerId", updateConsole.containerId);
                cmd.Parameters.AddWithValue("@SwitchboxId", updateConsole.switchBoxId);
                cmd.Parameters.AddWithValue("@SwitchboxNo", updateConsole.switchBoxNo);
                // Open connection and insert
                connection.Open();
                cmd.ExecuteNonQuery();

                // Disconnect
                connection.Close();
            }
        }
Пример #25
0
        // Insert new console into database
        public void InsertConsole(ConsoleInfo newConsole)
        {
            using (SqlConnection connection = new SqlConnection(connectString))
            using (SqlCommand cmd = new SqlCommand("INSERT INTO Consoles (name,manufacturer,container_id,switchbox_id,switchbox_no) VALUES(@Name,@Manufacturer,@ContainerId,@SwitchboxId,@SwitchboxNo)", connection))
            {
                // Add parameters
                cmd.Parameters.AddWithValue("@Name", newConsole.name);
                cmd.Parameters.AddWithValue("@Manufacturer", newConsole.manufacturer);
                cmd.Parameters.AddWithValue("@ContainerId", newConsole.containerId);
                cmd.Parameters.AddWithValue("@SwitchboxId", newConsole.switchBoxId);
                cmd.Parameters.AddWithValue("@SwitchboxNo", newConsole.switchBoxNo);
                // Open connection and insert
                connection.Open();
                cmd.ExecuteNonQuery();

                // Disconnect
                connection.Close();
            }
        }
Пример #26
0
 public static ConsoleInfo GetInstance()
 {
     return(_consoleInfo ?? (_consoleInfo = new ConsoleInfo()));
 }