public ProtocolChoicePromptHandler(
     IMessageSender messageSender,
     ConsoleService consoleService)
 {
     this.messageSender = messageSender;
     this.consoleService = consoleService;
 }
        public void Run()
        {
            var sut = new ConsoleService("sampleconsole.exe", "");

            var result = sut.Process("a\nb");
            Assert.AreEqual("<<<A\nB>>>\n", result);
        }
        /// <summary>
        /// Starts the session using the provided IConsoleHost implementation
        /// for the ConsoleService.
        /// </summary>
        public void StartSession()
        {
            // Create a workspace to contain open files
            this.Workspace = new Workspace();

            // Initialize all services
            this.PowerShellContext = new PowerShellContext();
            this.LanguageService = new LanguageService(this.PowerShellContext);
            this.AnalysisService = new AnalysisService();
            this.DebugService = new DebugService(this.PowerShellContext);
            this.ConsoleService = new ConsoleService(this.PowerShellContext);
        }
Beispiel #4
0
        public void ShouldReturnCorrectRangeValuesWithStopParameterGreaterThanLastIndex()
        {
            ConsoleService.ClearDatabase();
            // 1) "one" 2) "two" 3) "three" 4) "four"
            var command = $"zadd {PREFIX_KEY} 1 \"one\" 2 \"two\" 3 \"three\" 4 \"four\"";
            var result  = ConsoleService.CommandExecute(command);

            result.Should().Be("4");

            // 1) "one" 2) "two" 3) "three" 4) "four"
            var commandRange = $"zrange {PREFIX_KEY} 0 8";
            var resultRange  = ConsoleService.CommandExecute(commandRange);

            resultRange.Should().Be("1) \"one\"\r\n2) \"two\"\r\n3) \"three\"\r\n4) \"four\"\r\n");
        }
Beispiel #5
0
 protected bool Cache(string targetFolder, Dictionary <string, string> cache)
 {
     try
     {
         var str = JsonConvert.SerializeObject(cache);
         File.WriteAllText(Path.Combine(targetFolder, DictionaryCacheFilename), str);
         return(true);
     }
     catch (Exception ex)
     {
         ConsoleService.WriteToConsole("Cache information could not be written");
         ConsoleService.WriteToConsole("Exception occred while writing cache: " + ex);
     }
     return(false);
 }
Beispiel #6
0
        public MainMenu(IAccountDAO accountDAO, ITransferDAO transferDAO, AuthService authService, ConsoleService consoleService)
        {
            this.accountDAO     = accountDAO;
            this.transferDAO    = transferDAO;
            this.authService    = authService;
            this.consoleService = consoleService;

            AddOption("View your account details", ViewAccount)
            .AddOption("View your past transfers", ViewTransfers)
            .AddOption("View a specific transfer", ViewTransfer)
            .AddOption("Send TE bucks", SendTEBucks)
            //.AddOption("Request TE bucks", RequestTEBucks)
            .AddOption("Log in as different user", Logout)
            .AddOption("Exit", Exit);
        }
 private async Task CutCommandImpl()
 {
     if (ConsoleService.IsEnabled)
     {
         try
         {
             var str = ConsoleService.CutSelectedInput();
             ClipboardService.SetText(str);
         }
         catch (InvalidOperationException e)
         {
             await DialogService.ShowErrorDialogAsync(e.Message, "Exception");
         }
     }
 }
        public ConsoleServiceTests()
        {
            this.powerShellContext = new PowerShellContext();

            this.promptHandlerContext =
                new TestConsolePromptHandlerContext();

            this.consoleService =
                new ConsoleService(
                    this.powerShellContext,
                    promptHandlerContext);

            this.consoleService.OutputWritten += OnOutputWritten;
            promptHandlerContext.ConsoleHost   = this.consoleService;
        }
        public ConsoleServiceTests()
        {
            this.powerShellContext = new PowerShellContext();

            this.promptHandlerContext = 
                new TestConsolePromptHandlerContext();

            this.consoleService =
                new ConsoleService(
                    this.powerShellContext,
                    promptHandlerContext);

            this.consoleService.OutputWritten += OnOutputWritten;
            promptHandlerContext.ConsoleHost = this.consoleService;
        }
Beispiel #10
0
        static int FileCopy(ConsoleService c, string cmdName, string str)
        {
            ConsoleParam[] args =
            {
                new ConsoleParam("[src]", ConsoleService.Prompt, "Src Filename: ", ConsoleService.EvalNotEmpty, null),
                new ConsoleParam("DEST",  ConsoleService.Prompt, "Dst Filename: ", ConsoleService.EvalNotEmpty, null),
            };
            ConsoleParamValueList vl = c.ParseCommandList(cmdName, str, args);

            string destFileName = vl["DEST"].StrValue;
            string srcFileName  = vl.DefaultParam.StrValue;

            IO.FileCopy(srcFileName, destFileName, true, false);

            return(0);
        }
Beispiel #11
0
        private async void InputThread()
        {
            try
            {
                while (true)
                {
                    char ch = await ConsoleService.ReadCharAsync();

                    SerialPortService.Write(ch);
                }
            }
            catch (Exception e)
            {
                await DialogService.ShowErrorDialogAsync(e.Message, "Exception");
            }
        }
Beispiel #12
0
        private void DownloadFile(FtpConnection ftp, FtpFileInfo ftpFileInfo, string remotePath, string localPath)
        {
            ConsoleService.WriteToConsole("Downloading " + ftpFileInfo.Name + " (" + FormatHelper.ConvertToHumanReadbleFileSize(ftp.GetFileSize(remotePath + "/" + ftpFileInfo.Name)) + ")");
            if (!Directory.Exists(localPath))
            {
                Directory.CreateDirectory(localPath);
            }

            var filePath = Path.Combine(localPath, ftpFileInfo.Name);

            if (File.Exists(filePath))
            {
                File.Delete(filePath);
            }
            ftp.GetFile(remotePath + "/" + ftpFileInfo.Name, filePath, false);
        }
 private async Task PasteCommandImpl()
 {
     if (ConsoleService.IsEnabled)
     {
         try
         {
             string text  = ClipboardService.GetText();
             int    index = ConsoleService.SelectionStart;
             await ConsoleService.InsertText(index, text);
         }
         catch (ArgumentException e)
         {
             await DialogService.ShowErrorDialogAsync(e.Message, "Exception");
         }
     }
 }
Beispiel #14
0
        static void Main(string[] args)
        {
            var serverName   = EnvManager.FindArgumentValue("server");
            var configPathes = EnvManager.FindArgumentValues("config");

            if (string.IsNullOrEmpty(serverName) || (configPathes.Count < 1))
            {
                Console.WriteLine("You need to provide serverName and at least one config path!");
                Console.WriteLine("Closing...");
                Console.ReadKey();
                return;
            }

            var loggerFactory = new LoggerFactory();

            if (EnvManager.HasArgument("-console-log"))
            {
                loggerFactory.AddConsole(CustomLogFilter);
            }
            loggerFactory.AddFile("log.txt", false);

            var messageFormat = MessageFormat.LastTaskFailMessage;

            var consoleService = new ConsoleService(loggerFactory, messageFormat);

            var services = new List <IService> {
                consoleService,
                new SlackService(loggerFactory, messageFormat),
                new StatService("stats.xml", loggerFactory, true)
            };

            services.TryAddNotificationService(loggerFactory);

            var    commandFactory = new CommandFactory(loggerFactory);
            var    server         = new BuildServer(commandFactory, loggerFactory, serverName);
            string startUpError   = null;

            if (!server.TryInitialize(out startUpError, services, configPathes))
            {
                Console.WriteLine(startUpError);
                Console.WriteLine("Closing...");
                Console.ReadKey();
                return;
            }
            Console.WriteLine($"{server.ServiceName} started and ready to use.");
            consoleService.Process();
        }
Beispiel #15
0
        private static async Task PlayOnLAN(string[] args)
        {
            string server = null;
            int    port   = default;
            string option = string.Empty;

            if (args != null && args.Length <= 2 && args.Length > 0)
            {
                if (args.Length == 2)
                {
                    option = args[1].ToLower();
                }
                var parts = args[0].Split(":", 2);
                server = parts[0];
                port   = int.Parse(parts[1]);
            }

            ConsoleService.PrintTitle("Console Poker on LAN");
            if (option == string.Empty)
            {
                // TODO: Temporary, should clients be able to host their own servers?
                option = "c";

                // Console.WriteLine("(S)erver or (C)lient");
                // option = ConsoleService.TakeSpecificInputs(caseSensitive: false, "s", "c", "server", "client");
            }

            Console.Clear();
            switch (option)
            {
            case "s":
            case "server":
                ConsoleService.PrintTitle("Console Poker Server");
                var gameServer = new GameServer(port);
                gameServer.Start();
                Console.ReadLine();
                break;

            case "c":
            case "client":
                ConsoleService.PrintTitle("Console Poker Client");
                var gameClient = new GameClient();
                await gameClient.RunAsync(server, port);

                break;
            }
        }
        static bool UserSearch()
        {
            var config     = new ConfigurationService();
            var console    = new ConsoleService(config);
            var apirequest = new ApiRequestService(console, config);
            var spotify    = new SpotifyService(console, config, apirequest);
            var analysis   = new AnalysisService();

            var username = console.PromptForUsername();

            // get all public playlists for the provided username
            var playlists = spotify.GetPlaylists(username, out bool anyFound);

            // if the provided user has no public playlists, ask for another username
            if (!anyFound)
            {
                return(true);
            }

            // get metadata for each public playlist. This will give us a list of tracks.
            var playlistMetadatum = spotify.GetAllPlaylistMetadatum(playlists.items);

            // identify unique tracks from the playlist metadataum
            var tracks = analysis.IdentifyUniqueTracks(playlistMetadatum);

            // identify unique artists from the tracks. This just gets us artist names / IDs
            var artists = analysis.IdentifyUniqueArtists(tracks);

            // get the full artist info, which gets us genres.
            var fullArtists = spotify.GetAllArtists(artists);

            // identify unique genres
            var genres = analysis.IdentifyUniqueGenres(fullArtists);

            var audioFeatures = spotify.GetAudioFeaturesForAllTracks(tracks);

            var avgAudioFeatures = analysis.CalculateAverageAudioFeatures(audioFeatures);

            console.WriteMetrics(
                artists,
                genres,
                audioFeatures,
                avgAudioFeatures);

            return(true);
        }
        /// <summary>
        /// Processo di validazione dei diversi fogli excel presenti all'interno del file in base al formato deciso all'interno del file di configurazioni
        /// </summary>
        /// <returns></returns>
        public static bool STEP2_ValidateSheetOnExcel()
        {
            ConsoleService.GetSeparatoreAttivita();

            // segnalazione inizio STEP 2 di validazione fogli excel
            ConsoleService.STEPS_FromExcelToDatabase.STEP2_InizioValidazioneFogliContenutiInExcel(ServiceLocator.GetUtilityFunctions.GetFileName(Constants.ExcelSourcePath));

            if (ServiceLocator.GetExcelService.GetExcelReaders.RecognizeSheetsOnExcel())
            {
                ConsoleService.STEPS_FromExcelToDatabase.STEP2_FineSorgenteValidatoCorrettamente();
                return(true);
            }
            else
            {
                throw new Exception(ExceptionMessages.ERRORESTEP2_VALIDAZIONEFOGLIEXCEL);
            }
        }
Beispiel #18
0
        private void BuildTCPListener(int portInput = default)
        {
            int port;

            if (portInput == default)
            {
                ConsoleService.PrintTitle("Enter TCP Port to listen on (0 - 65535)");
                port = ConsoleService.TakeIntegerInput();
            }
            else
            {
                port = portInput;
            }

            _tcpListener  = new TcpListener(IPAddress.Loopback, port);
            Console.Title = $"{NetworkService.GetLocalIPAddressString()}:{port}";
        }
Beispiel #19
0
        public void ShouldUpdateValueKey()
        {
            var commandGet = $"get {PREFIX_KEY}0";
            var result     = ConsoleService.CommandExecute(commandGet);

            result.Should().Be("0");

            var commandSet = $"set {PREFIX_KEY}0 1";
            var result2    = ConsoleService.CommandExecute(commandSet);

            result2.Should().Be("OK");

            commandGet = $"get {PREFIX_KEY}0";
            result     = ConsoleService.CommandExecute(commandGet);

            result.Should().Be("1");
        }
        /// <summary>
        /// STEP 1 di apertura del file excel di riferimento e che è trovato come sorgente
        /// per l'import corrente
        /// </summary>
        /// <returns></returns>
        public static bool STEP1_OpenSourceExcel()
        {
            ConsoleService.GetSeparatoreAttivita();

            // segnalazione inizio STEP 1 di apertura excel
            ConsoleService.STEPS_FromExcelToDatabase.STEP1_InizioAperturaFoglioExcelSorgente(ServiceLocator.GetUtilityFunctions.GetFileName(Constants.ExcelSourcePath));

            if (ServiceLocator.GetExcelService.OpenFileExcel(Constants.ExcelSourcePath, Constants.format_foglio_origin, Constants.ModalitaAperturaExcel.READ))
            {
                ConsoleService.STEPS_FromExcelToDatabase.STEP1_FileExcelSorgenteApertoCorrettamente();
                return(true);
            }
            else
            {
                throw new Exception(ExceptionMessages.ERRORESTEP1_APERTURAFILEEXCEL);
            }
        }
Beispiel #21
0
        static int GenerateVersionResource(ConsoleService c, string cmdName, string str)
        {
            ConsoleParam[] args =
            {
                new ConsoleParam("[targetFileName]", ConsoleService.Prompt, "Target Filename: ", ConsoleService.EvalNotEmpty, null),
                new ConsoleParam("OUT",              ConsoleService.Prompt, "Dst Filename: ",    ConsoleService.EvalNotEmpty, null),
                new ConsoleParam("RC"),
            };
            ConsoleParamValueList vl = c.ParseCommandList(cmdName, str, args);

            string targetFilename = vl.DefaultParam.StrValue;
            string outFilename    = vl["OUT"].StrValue;

            Win32BuildUtil.GenerateVersionInfoResource(targetFilename, outFilename, vl["RC"].StrValue);

            return(0);
        }
Beispiel #22
0
        public void ShouldReturnExceptionOfType()
        {
            var commandSet = $"set {PREFIX_KEY}_letter A";
            var resultSet  = ConsoleService.CommandExecute(commandSet);

            resultSet.Should().Be("OK");

            var commandGet = $"get {PREFIX_KEY}_letter";
            var resultGet  = ConsoleService.CommandExecute(commandGet);

            resultGet.Should().Be("A");

            var commandIncr = $"incr {PREFIX_KEY}_letter";
            var resultIncr  = ConsoleService.CommandExecute(commandIncr);

            resultIncr.Should().Be(VALUE_OF_RECORD_NOT_INTEGER);
        }
Beispiel #23
0
        protected void SetupBase(LoadOptionsEnum loadOptionsEnum)
        {
            ConsoleService = new ConsoleService();

            switch (loadOptionsEnum)
            {
            case LoadOptionsEnum.LoadDatabase:
                //Ok
                for (int i = 0; i < 25; i++)
                {
                    ConsoleService.CommandExecute($"set key{i} {i}");
                    ConsoleService.CommandExecute($"set keyEx{i} Ex{i}");
                }

                //Expiradas
                for (int i = 25; i < 50; i++)
                {
                    ConsoleService.CommandExecute($"set key{i} {i} 1");
                    ConsoleService.CommandExecute($"set keyEx{i} Ex{i} 1");
                }

                break;

            case LoadOptionsEnum.LoadOnlyKeysOk:
                //Ok
                for (int i = 0; i < 25; i++)
                {
                    ConsoleService.CommandExecute($"set key{i} {i}");
                    ConsoleService.CommandExecute($"set keyEx{i} Ex{i}");
                }

                break;

            case LoadOptionsEnum.LoadOnlyKeysExpired:
                //Expiradas
                for (int i = 25; i < 50; i++)
                {
                    ConsoleService.CommandExecute($"set key{i} {i} 1");
                    ConsoleService.CommandExecute($"set keyEx{i} Ex{i} 1");
                }
                break;

            default:
                break;
            }
        }
Beispiel #24
0
        public void ShouldReturnInvalidCommand()
        {
            var command = $"zadd";
            var result  = ConsoleService.CommandExecute(command);

            result.Should().Be(INVALID_COMMAND);

            command = $"zadd 1";
            result  = ConsoleService.CommandExecute(command);

            result.Should().Be(INVALID_COMMAND);

            command = $"zadd 1 2";
            result  = ConsoleService.CommandExecute(command);

            result.Should().Be(INVALID_COMMAND);
        }
        /// <summary>
        /// Processo di recupero di tutte le informazioni dai files in lettura corrente per il file excel
        /// </summary>
        /// <returns></returns>
        public static bool STEP3_GetAllInfoExcel()
        {
            ConsoleService.GetSeparatoreAttivita();

            // segnalazione inizio STEP 3 di recupero informazioni per il file excel corrente
            ConsoleService.STEPS_FromExcelToDatabase.STEP3_InizioRecuperoDiTutteLeInformazioniPerExcelCorrente(ServiceLocator.GetUtilityFunctions.GetFileName(Constants.ExcelSourcePath));

            if (ServiceLocator.GetExcelService.GetExcelReaders.ReadExcelInformation())
            {
                ConsoleService.STEPS_FromExcelToDatabase.STEP3_RecuperoDelleInformazioniUltimato(ServiceLocator.GetUtilityFunctions.GetFileName(Constants.ExcelSourcePath));
                return(true);
            }
            else
            {
                throw new Exception(ExceptionMessages.ERRORESTEP3_LETTURAFOGLIOEXCELNONRIUSCITA);
            }
        }
Beispiel #26
0
        /// <summary>
        /// Description : Draw all priority
        /// </summary>
        private void DrawPriority()
        {
            EditorGUILayout.BeginVertical();
            EditorGUILayout.Space(20);
            EditorGUILayout.LabelField("Advanced Settings", EditorStyles.wordWrappedLabel);
            EditorGUILayout.Space(20);
            _feature = GUILayout.Toggle(ConsoleService.GetAdvancedSettings().feature, new GUIContent("Feature"), GUILayout.Width(70));

            _important = GUILayout.Toggle(ConsoleService.GetAdvancedSettings().important, new GUIContent("Important"), GUILayout.Width(70));

            _methods = GUILayout.Toggle(ConsoleService.GetAdvancedSettings().methods, new GUIContent("Methods"), GUILayout.Width(70));

            _loop = GUILayout.Toggle(ConsoleService.GetAdvancedSettings().loop, new GUIContent("Loop"), GUILayout.Width(70));

            _custom = GUILayout.Toggle(ConsoleService.GetAdvancedSettings().custom, new GUIContent("Custom"), GUILayout.Width(70));
            EditorGUILayout.Space(20);
            EditorGUILayout.EndVertical();
        }
        /// <summary>
        /// Description : Drawer for the logs messages in the upper panel  area
        /// </summary>
        private void DrawUpperPanel()
        {
            // design Upper panel area
            upperPanel = new Rect(0, menuBarHeight, position.width, (position.height * sizeRatio) - menuBarHeight);

            GUILayout.BeginArea(upperPanel);

            // Add a scroll
            upperPanelScroll = GUILayout.BeginScrollView(upperPanelScroll);

            // Draw console
            DrawDefaultConsole();
            DrawCustomLogs(ConsoleService.GetAll());

            // CLose Design
            GUILayout.EndScrollView();
            GUILayout.EndArea();
        }
Beispiel #28
0
        static int GenerateVpnWebOcxCab(ConsoleService c, string cmdName, string str)
        {
            ConsoleParam[] args =
            {
                new ConsoleParam("[src]", ConsoleService.Prompt, "Src Filename: ", ConsoleService.EvalNotEmpty, null),
                new ConsoleParam("DEST",  ConsoleService.Prompt, "Dst Filename: ", ConsoleService.EvalNotEmpty, null),
            };
            ConsoleParamValueList vl = c.ParseCommandList(cmdName, str, args);

#if     !BU_OSS
            string destFileName = vl["DEST"].StrValue;
            string srcFileName  = vl.DefaultParam.StrValue;

            Win32BuildUtil.GenerateVpnWebOcxCab(destFileName, srcFileName);
#endif

            return(0);
        }
Beispiel #29
0
        /// <summary>
        /// Description : Display / Hide Warnings message
        /// </summary>
        public void ToggleWarnings()
        {
            if (ConsoleService.GetWarningEvent() == true)
            {
                ConsoleService.SetWarningEvent(false);

                Debug.Log("[DEBUG SERVICE] - [WARNING EVENT] Disable");

                _warning.alpha = 0;
            }
            else
            {
                ConsoleService.SetWarningEvent(true);

                Debug.Log("[DEBUG SERVICE] - [WARNING EVENT] Activate");
                _warning.alpha = 1;
            }
        }
Beispiel #30
0
        public ConsoleAuto(string[] args = null, IServiceCollection serviceBuilder = null)
        {
            config    = new ConsoleAutoConfig();
            this.args = new List <string>(args ?? new string[] { });

            this.serviceBuilder = serviceBuilder ?? new ServiceCollection();

            this.Register <ReflectionService>();
            this.Register <ConsoleService>();

            this.sp = this.serviceBuilder?.BuildServiceProvider() as IServiceProvider;

            this.reflectionService = this.sp.GetService(typeof(ReflectionService)) as ReflectionService;
            this.consoleService    = this.sp.GetService(typeof(ConsoleService)) as ConsoleService;


            deserializer = new Deserializer();
        }
        /// <summary>
        /// 获得 键值对 Dictionary(key,value)
        /// </summary>
        /// <param name="jsonStr"></param>
        /// <returns></returns>
        public static Dictionary <string, object> FromJsonUrlDetail(string jsonStr)
        {
            Dictionary <string, object> mytable = new Dictionary <string, object>();
            int count = 0;

            try
            {
                StringBuilder output = new StringBuilder(jsonStr);
                int           head   = jsonStr.IndexOf("|");
                if (head != 0)
                {
                    count = Convert.ToInt32(jsonStr.Substring(0, head).Trim());
                }
                if (count == 0)
                {
                    return(mytable);
                }
                output.Remove(0, head + 1);
                string[] ps = output.ToString().Split('|');
                foreach (string p in ps)
                {
                    if (p.Length > 0)
                    {
                        string[] names = p.Split('`');
                        if (names.Length == 2)
                        {
                            string fieldname = names[0];
                            string value     = names[1];
                            mytable.Add(fieldname, value);
                            count--;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ConsoleService.Error("FromJsonDetail:" + ex.Message + ex.StackTrace);
            }
            if (count < 0)
            {
                ConsoleService.Warn("FromJson's crc is wrong, count = " + count);
            }
            return(mytable);
        }
Beispiel #32
0
        static void Main(string[] args)
        {
            var consoleService = new ConsoleService();

            while (true)
            {
                Console.Write("smallredis> ");
                var command = Console.ReadLine();

                if (command.Trim().ToLower() == "exit")
                {
                    break;
                }

                var commandReturn = consoleService.CommandExecute(command);

                Console.WriteLine(commandReturn);
            }
        }
        public MonthlyPayslipServiceUnitTest()
        {
            var config = Options.Create(new FileContextSetting()
            {
                DataFile = new DataFileSetting()
                {
                    Directory = "./TestFiles"
                },
                OutputFile = new DataFileSetting()
                {
                    Directory = "./TestFiles"
                }
            });

            var logService     = new ConsoleService();
            var contextService = new FileContextService(config, logService);

            _payslipService = new MonthlyPayslipService(contextService, logService);
        }
        private void OnEnable()
        {
            // load icons
            errorIcon   = EditorGUIUtility.Load("icons/console.erroricon.png") as Texture2D;
            warningIcon = EditorGUIUtility.Load("icons/console.warnicon.png") as Texture2D;
            infoIcon    = EditorGUIUtility.Load("icons/console.infoicon.png") as Texture2D;

            // Load console icons
            errorIconSmall   = EditorGUIUtility.Load("icons/console.erroricon.sml.png") as Texture2D;
            warningIconSmall = EditorGUIUtility.Load("icons/console.warnicon.sml.png") as Texture2D;
            infoIconSmall    = EditorGUIUtility.Load("icons/console.infoicon.sml.png") as Texture2D;

            // init resizer
            resizerStyle = new GUIStyle();
            resizerStyle.normal.background = EditorGUIUtility.Load("icons/d_AvatarBlendBackground.png") as Texture2D;

            // init box log
            boxStyle = new GUIStyle();
            boxStyle.normal.textColor = new Color(0.7f, 0.7f, 0.7f);

            // load unity console style
            boxBgOdd      = EditorGUIUtility.Load("builtin skins/darkskin/images/cn entrybackodd.png") as Texture2D;
            boxBgEven     = EditorGUIUtility.Load("builtin skins/darkskin/images/cnentrybackeven.png") as Texture2D;
            boxBgSelected = EditorGUIUtility.Load("builtin skins/darkskin/images/menuitemhover.png") as Texture2D;

            // set text log style
            textAreaStyle = new GUIStyle();
            textAreaStyle.normal.textColor  = new Color(0.9f, 0.9f, 0.9f);
            textAreaStyle.normal.background = EditorGUIUtility.Load("builtin skins/darkskin/images/projectbrowsericonareabg.png") as Texture2D;

            searchingStyle   = new GUIStyle();
            searchingTexture = new Texture2D(70, 100);

            searchingTexture.SetPixel(70, 100, Color.white);
            searchingStyle.normal.background = searchingTexture;

            // Set Selected Log to null
            ConsoleService.SetSelectedLog(null);

            _logsLoaded = new List <Log>();

            Application.logMessageReceived += LogMessageReceived;
        }
Beispiel #35
0
        static int CopyUnixSrc(ConsoleService c, string cmdName, string str)
        {
            ConsoleParam[] args =
            {
                new ConsoleParam("[destdir]", ConsoleService.Prompt, "Destination directory : ", ConsoleService.EvalNotEmpty, null),
            };
            ConsoleParamValueList vl = c.ParseCommandList(cmdName, str, args);

            ((BuildSoftwareUnix)BuildSoftwareList.vpnbridge_linux_x86_ja).CopyUnixSrc(vl.DefaultParam.StrValue);

            return 0;
        }
Beispiel #36
0
        static int CopyRelease(ConsoleService c, string cmdName, string str)
        {
            ConsoleParam[] args =
            {
            };
            ConsoleParamValueList vl = c.ParseCommandList(cmdName, str, args);

            int build, version;
            string name;
            DateTime date;
            Win32BuildUtil.ReadBuildInfoFromTextFile(out build, out version, out name, out date);

            string baseName = string.Format("v{0}-{1}-{2}-{3:D4}.{4:D2}.{5:D2}",
                                    BuildHelper.VersionIntToString(version),
                                    build,
                                    name,
                                    date.Year, date.Month, date.Day);

            #if !BU_OSS
            string destDirName = Path.Combine(Paths.ReleaseDestDir,
                string.Format(@"{0}-{1}-{2}-{3}",
                    Str.DateToStrShort(BuildSoftwareList.ListCreatedDateTime),
                    baseName,
                    Env.MachineName, Env.UserName));
            #else	// !BU_OSS
            string destDirName = Path.Combine(Paths.ReleaseDestDir,
                string.Format(@"{1}",
                    Str.DateToStrShort(BuildSoftwareList.ListCreatedDateTime),
                    baseName,
                    Env.MachineName, Env.UserName));
            #endif

            #if !BU_OSS
            string publicDir = Path.Combine(destDirName, "Public");
            #else	// !BU_OSS
            string publicDir = destDirName;
            #endif

            #if !BU_OSS
            string filesReleaseDir = Path.Combine(publicDir, baseName);
            #else	// !BU_OSS
            string filesReleaseDir = publicDir;
            #endif

            string autorunReleaseSrcDir = Path.Combine(publicDir, "autorun");

            IO.CopyDir(Paths.ReleaseDir, filesReleaseDir, null, false, true);

            #if !BU_OSS
            IO.CopyDir(Paths.ReleaseSrckitDir, Path.Combine(destDirName, "Private"), null, false, true);
            IO.CopyDir(Path.Combine(Paths.BaseDirName, @"tmp\lib"), Path.Combine(destDirName, @"Private\lib"), null, false, true);
            #endif

            //IO.MakeDir(autorunReleaseSrcDir);

            /*
            File.Copy(Path.Combine(Paths.AutorunSrcDir, "Project1.exe"),
                Path.Combine(autorunReleaseSrcDir, "autorun.exe"), true);

            File.Copy(Path.Combine(Paths.AutorunSrcDir, "autorun.inf"),
                Path.Combine(autorunReleaseSrcDir, "autorun.inf"), true);

            File.Copy(Path.Combine(Paths.AutorunSrcDir, "packetix.ico"),
                Path.Combine(autorunReleaseSrcDir, "autorun.ico"), true);*/

            // Create a batch file
            string batchFileName = Path.Combine(publicDir, "MakeCD.cmd");
            #if !BU_OSS
            StreamWriter w = new StreamWriter(batchFileName);
            #else	// !BU_OSS
            StringWriter w = new StringWriter();
            #endif
            w.WriteLine(@"SETLOCAL");
            w.WriteLine(@"SET BATCH_FILE_NAME=%0");
            w.WriteLine(@"SET BATCH_DIR_NAME=%0\..");
            w.WriteLine(@"SET NOW_TMP=%time:~0,2%");
            w.WriteLine(@"SET NOW=%date:~0,4%%date:~5,2%%date:~8,2%_%NOW_TMP: =0%%time:~3,2%%time:~6,2%");
            w.WriteLine();
            w.WriteLine();

            string[] files = Directory.GetFiles(filesReleaseDir, "*", SearchOption.AllDirectories);

            string cddir = "CD";
                /*string.Format("CD-v{0}.{1}-{2}-{3}-{4:D4}.{5:D2}.{6:D2}",
                version / 100, version % 100, build, name,
                date.Year, date.Month, date.Day);*/

            StringWriter txt = new StringWriter();

            foreach (string filename in files)
            {
                string file = filename;

                BuildSoftware s = new BuildSoftware(file);

                // Software\Windows\PacketiX VPN Server 4.0\32bit (Intel x86)\filename.exe
                string cpustr = string.Format("{0} - {1}", CPUBitsUtil.CPUBitsToString(s.Cpu.Bits), s.Cpu.Title).Replace("/", "or");
                string cpustr2 = cpustr;

                if (s.Cpu == CpuList.intel)
                {
                    cpustr2 = "";
                    cpustr = "Intel";
                }

                string tmp = string.Format(@"{1}\{2}\{3}\{5}{4}",
                    0,
                    s.Os.Title,
                    BuildHelper.GetSoftwareTitle(s.Software),
                    cpustr2,
                    Path.GetFileName(file),
                    ""
                    );

                tmp = Str.ReplaceStr(tmp, "\\\\", "\\");

                tmp = Str.ReplaceStr(tmp, " ", "_");

                w.WriteLine("mkdir \"{1}\\{0}\"", Path.GetDirectoryName(tmp), cddir);
                w.WriteLine("copy /b /y \"{2}\\{0}\" \"{3}\\{1}\"", IO.GetRelativeFileName(file, filesReleaseDir), tmp, baseName, cddir);
                w.WriteLine();

                string txt_filename = tmp;
                txt_filename = Str.ReplaceStr(txt_filename, "\\", "/");

                string txt_description = BuildHelper.GetSoftwareTitle(s.Software);

                string txt_products = BuildHelper.GetSoftwareProductList(s.Software);

                string txt_os = s.Os.Title;

                string txt_cpu = s.Cpu.Title;
                if (s.Cpu.Bits != CPUBits.Both)
                {
                    txt_cpu += " (" + CPUBitsUtil.CPUBitsToString(s.Cpu.Bits) + ")";
                }
                else
                {
                    txt_cpu += " (x86 and x64)";
                }

                string txt_version = BuildHelper.VersionIntToString(version);

                string txt_build = build.ToString();

                string txt_verstr = name;

                string txt_date = Str.DateTimeToStrShortWithMilliSecs(date);

                string txt_lang = "English, Japanese, Simplified Chinese";

                string txt_category = "PacketiX VPN (Commercial)";

            #if BU_SOFTETHER
                txt_category = "SoftEther VPN (Freeware)";
            #endif

                txt.WriteLine("FILENAME\t" + txt_filename);
                txt.WriteLine("DESCRIPTION\t" + txt_description);
                txt.WriteLine("CATEGORY\t" + txt_category);
                txt.WriteLine("PRODUCT\t" + txt_products);
                txt.WriteLine("OS\t" + txt_os);
                txt.WriteLine("OSLIST\t" + s.Os.OSSimpleList);
                txt.WriteLine("CPU\t" + txt_cpu);
                txt.WriteLine("VERSION\t" + txt_version);
                txt.WriteLine("BUILD\t" + txt_build);
                txt.WriteLine("VERSTR\t" + txt_verstr);
                txt.WriteLine("DATE\t" + txt_date);
                txt.WriteLine("LANGUAGE\t" + txt_lang);
                txt.WriteLine("*");
                txt.WriteLine();
            }

            #if BU_OSS
            Con.WriteLine("Installer packages are built on '{0}'. Enjoy it !!", publicDir);

            return 0;
            #endif	// BU_OSS

            /*
            w.WriteLine("mkdir \"{0}\\autorun\"", cddir);
            w.WriteLine("copy /b /y autorun\\autorun.ico \"{0}\\autorun\"", cddir);
            w.WriteLine("copy /b /y autorun\\autorun.exe \"{0}\\autorun\"", cddir);
            w.WriteLine("copy /b /y autorun\\autorun.inf \"{0}\\autorun.inf\"", cddir);
             * */

            string zipFileName = string.Format("VPN-CD-v{0}.{1:D2}-{2}-{3}-{4:D4}.{5:D2}.{6:D2}.zip",
                version / 100, version % 100, build, name,
                date.Year, date.Month, date.Day);
            w.WriteLine("del {0}", zipFileName);
            w.WriteLine("CD {0}", cddir);
            w.WriteLine("zip -r -0 ../{0} *", zipFileName);
            w.WriteLine("cd ..");
            w.WriteLine("move {0} CD\\", zipFileName);
            w.WriteLine("rename CD {0}-tree", baseName);
            w.WriteLine();

            w.Close();

            // Copy of fastcopy
            string fastcopy_dest = Path.Combine(destDirName, @"Private\fastcopy_bin");
            IO.MakeDirIfNotExists(fastcopy_dest);
            File.Copy(Path.Combine(Paths.UtilityDirName, "FastCopy.exe"), Path.Combine(fastcopy_dest, "FastCopy.exe"), true);
            File.Copy(Path.Combine(Paths.UtilityDirName, "FastEx64.dll"), Path.Combine(fastcopy_dest, "FastEx64.dll"), true);
            File.Copy(Path.Combine(Paths.UtilityDirName, "FastExt1.dll"), Path.Combine(fastcopy_dest, "FastExt1.dll"), true);

            string fastcopy_exe = @"..\Private\fastcopy_bin\FastCopy.exe";

            // Create a upload batch
            string uploadBatchFileName = Path.Combine(publicDir, "UploadNow.cmd");
            #if !BU_OSS
            w = new StreamWriter(uploadBatchFileName);
            #endif	// !BU_OSS

            string folder_name = "packetix";
            #if BU_SOFTETHER
            folder_name = "softether";
            #endif
            w.WriteLine(@"mkdir \\download\FILES\{1}\{0}-tree", baseName, folder_name);
            w.WriteLine(@"{0} /cmd=force_copy /exclude={3} /auto_close /force_start /estimate /open_window /error_stop=TRUE /bufsize=128 /disk_mode=diff /speed=full /verify {1}-tree /to=\\download\FILES\{2}\{1}-tree", fastcopy_exe, baseName, folder_name,
                "\"*files.txt*\"");

            w.WriteLine();
            /*
            w.WriteLine(@"mkdir \\downloadjp\FILES\{1}\{0}-tree", baseName, folder_name);
            w.WriteLine(@"{0} /cmd=force_copy /exclude={3} /auto_close /force_start /estimate /open_window /error_stop=TRUE /bufsize=128 /disk_mode=diff /speed=full /verify {1}-tree /to=\\downloadjp\FILES\{2}\{1}-tree", fastcopy_exe, baseName, folder_name,
                "\"*files.txt*\"");

            w.WriteLine();*/

            w.WriteLine(@"copy /y /b {0}-tree\files.txt \\download\FILES\{1}\{0}-tree\files.txt", baseName, folder_name);
            //w.WriteLine(@"copy /y /b {0}-tree\files.txt \\downloadjp\FILES\{1}\{0}-tree\files.txt", baseName, folder_name);

            w.WriteLine();
            w.WriteLine(@"pause");
            w.WriteLine();

            w.Close();

            txt.WriteLine("FILENAME\t" + zipFileName);
            #if BU_SOFTETHER
            txt.WriteLine("DESCRIPTION\t" + "ZIP CD-ROM Image Package of SoftEther VPN (for Admins)");
            txt.WriteLine("CATEGORY\t" + "SoftEther VPN (Freeware)");
            txt.WriteLine("PRODUCT\t" + "ZIP CD-ROM Image Package of SoftEther VPN");
            #else	// BU_SOFTETHER
            txt.WriteLine("DESCRIPTION\t" + "ZIP CD-ROM Image Package of PacketiX VPN (for Admins)");
            txt.WriteLine("CATEGORY\t" + "PacketiX VPN (Commercial)");
            txt.WriteLine("PRODUCT\t" + "ZIP CD-ROM Image Package of PacketiX VPN");
            #endif	// BU_SOFTETHER
            txt.WriteLine("OS\t" + "Any");
            txt.WriteLine("OSLIST\t" + "Any");
            txt.WriteLine("CPU\t" + "CD-ROM");
            txt.WriteLine("VERSION\t" + BuildHelper.VersionIntToString(version));
            txt.WriteLine("BUILD\t" + build.ToString());
            txt.WriteLine("VERSTR\t" + name);
            txt.WriteLine("DATE\t" + Str.DateTimeToStrShortWithMilliSecs(date));
            txt.WriteLine("LANGUAGE\t" + "English, Japanese, Simplified Chinese");
            txt.WriteLine("*");
            txt.WriteLine();

            string src_bindir = Path.Combine(Paths.BaseDirName, "bin");
            string vpnsmgr_zip_filename_relative = @"Windows\Admin_Tools\VPN_Server_Manager_and_Command-line_Utility_Package\";
            vpnsmgr_zip_filename_relative +=
            #if BU_SOFTETHER
                "softether-" +
            #endif	// BU_SOFTETHER
            string.Format("vpn_admin_tools-v{0}.{1:D2}-{2}-{3}-{4:D4}.{5:D2}.{6:D2}-win32.zip",
                version / 100, version % 100, build, name,
                date.Year, date.Month, date.Day);

            string vpnsmgr_zip_filename_full = Path.Combine(Path.Combine(publicDir, cddir), vpnsmgr_zip_filename_relative);

            ZipPacker zip = new ZipPacker();
            zip.AddFileSimple("vpnsmgr.exe", DateTime.Now, FileAttributes.Normal,
                IO.ReadFile(Path.Combine(src_bindir, "vpnsmgr.exe")), true);
            zip.AddFileSimple("vpncmd.exe", DateTime.Now, FileAttributes.Normal,
                IO.ReadFile(Path.Combine(src_bindir, "vpncmd.exe")), true);
            zip.AddFileSimple("hamcore.se2", DateTime.Now, FileAttributes.Normal,
                IO.ReadFile(Path.Combine(src_bindir, @"BuiltHamcoreFiles\hamcore_win32\hamcore.se2")), true);
            zip.AddFileSimple("ReadMeFirst_License.txt", DateTime.Now, FileAttributes.Normal,
                IO.ReadFile(Path.Combine(src_bindir, @"hamcore\eula.txt")), true);
            zip.AddFileSimple("ReadMeFirst_Important_Notices_ja.txt", DateTime.Now, FileAttributes.Normal,
                IO.ReadFile(Path.Combine(src_bindir, @"hamcore\warning_ja.txt")), true);
            zip.AddFileSimple("ReadMeFirst_Important_Notices_en.txt", DateTime.Now, FileAttributes.Normal,
                IO.ReadFile(Path.Combine(src_bindir, @"hamcore\warning_en.txt")), true);
            zip.AddFileSimple("ReadMeFirst_Important_Notices_cn.txt", DateTime.Now, FileAttributes.Normal,
                IO.ReadFile(Path.Combine(src_bindir, @"hamcore\warning_cn.txt")), true);
            zip.Finish();
            byte[] zip_data = zip.GeneratedData.Read();
            IO.MakeDirIfNotExists(Path.GetDirectoryName(vpnsmgr_zip_filename_full));
            IO.SaveFile(vpnsmgr_zip_filename_full, zip_data);

            // ZIP package for VPN Server Manager GUI
            txt.WriteLine("FILENAME\t" + Str.ReplaceStr(vpnsmgr_zip_filename_relative, @"\", "/"));
            #if BU_SOFTETHER
            txt.WriteLine("DESCRIPTION\t" + "ZIP Package of vpnsmgr.exe and vpncmd.exe (without installers)");
            txt.WriteLine("CATEGORY\t" + "SoftEther VPN (Freeware)");
            txt.WriteLine("PRODUCT\t" + "SoftEther VPN Server Manager for Windows, SoftEther VPN Command-Line Admin Utility (vpncmd)");
            #else	// BU_SOFTETHER
            txt.WriteLine("DESCRIPTION\t" + "ZIP Package of vpnsmgr.exe and vpncmd.exe (without installers)");
            txt.WriteLine("CATEGORY\t" + "PacketiX VPN (Commercial)");
            txt.WriteLine("PRODUCT\t" + "PacketiX VPN Server Manager for Windows, PacketiX VPN Command-Line Admin Utility (vpncmd)");
            #endif	// BU_SOFTETHER
            txt.WriteLine("OS\t" + "Windows (.zip package without installers)");
            txt.WriteLine("OSLIST\t" + OSList.Windows.OSSimpleList);
            txt.WriteLine("CPU\t" + "Intel (x86 and x64)");
            txt.WriteLine("VERSION\t" + BuildHelper.VersionIntToString(version));
            txt.WriteLine("BUILD\t" + build.ToString());
            txt.WriteLine("VERSTR\t" + name);
            txt.WriteLine("DATE\t" + Str.DateTimeToStrShortWithMilliSecs(date));
            txt.WriteLine("LANGUAGE\t" + "English, Japanese, Simplified Chinese");
            txt.WriteLine("*");
            txt.WriteLine();

            IO.MakeDirIfNotExists(Path.Combine(publicDir, cddir));
            File.WriteAllText(Path.Combine(Path.Combine(publicDir, cddir), "files.txt"), txt.ToString(), Str.Utf8Encoding);

            // Execution of batch file
            string old_cd = Environment.CurrentDirectory;

            try
            {
                Environment.CurrentDirectory = Path.GetDirectoryName(batchFileName);
            }
            catch
            {
            }

            Win32BuildUtil.ExecCommand(Paths.CmdFileName, string.Format("/C \"{0}\"", batchFileName));

            try
            {
                Environment.CurrentDirectory = old_cd;
            }
            catch
            {
            }

            Con.WriteLine();
            Con.WriteLine("'{0}' に出力されました。", destDirName);

            return 0;
        }
Beispiel #37
0
        static int BuildWin32(ConsoleService c, string cmdName, string str)
        {
            ConsoleParam[] args =
            {
                new ConsoleParam("[yes|no]", ConsoleService.Prompt, "Increments build number (y/n) ? ", ConsoleService.EvalNotEmpty, null),
                new ConsoleParam("NORMALIZESRC", ConsoleService.Prompt, "Normalizes source codes (y/n) ? ", ConsoleService.EvalNotEmpty, null)
            };
            ConsoleParamValueList vl = c.ParseCommandList(cmdName, str, args);

            if (vl.DefaultParam.BoolValue)
            {
                Win32BuildUtil.IncrementBuildNumber();
            }
            if (vl.DefaultParam.BoolValue || vl["NORMALIZESRC"].BoolValue)
            {
                Win32BuildUtil.NormalizeBuildInfo();
            }

            Paths.DeleteAllReleaseTarGz();
            Paths.DeleteAllReleaseExe();
            Paths.DeleteAllReleaseManuals();
            Paths.DeleteAllReleaseAdminKits();

            Win32BuildUtil.BuildMain();
            Win32BuildUtil.SignAllBinaryFiles();
            HamCoreBuildUtil.BuildHamcore();
            Win32BuildUtil.CopyDebugSnapshot();

            return 0;
        }
Beispiel #38
0
        static int BuildHamCore(ConsoleService c, string cmdName, string str)
        {
            ConsoleParam[] args =
            {
            };
            ConsoleParamValueList vl = c.ParseCommandList(cmdName, str, args);

            HamCoreBuildUtil.BuildHamcore();

            return 0;
        }
 public ProtocolInputPromptHandler(
     IMessageSender messageSender,
     ConsoleService consoleService)
         : base(consoleService)
 {
     this.messageSender = messageSender;
     this.consoleService = consoleService;
 }
Beispiel #40
0
        static int GenerateWin8InfFiles(ConsoleService c, string cmdName, string str)
        {
            ConsoleParam[] args =
            {
                new ConsoleParam("[cpu]", ConsoleService.Prompt, "x86 / x64: ", ConsoleService.EvalNotEmpty, null)
            };
            ConsoleParamValueList vl = c.ParseCommandList(cmdName, str, args);

            #if	!BU_OSS

            Win32BuildUtil.GenerateINFFilesForWindows8(vl.DefaultParam.StrValue);

            #endif

            return 0;
        }
Beispiel #41
0
        static int GenerateVersionResource(ConsoleService c, string cmdName, string str)
        {
            ConsoleParam[] args =
            {
                new ConsoleParam("[targetFileName]", ConsoleService.Prompt, "Target Filename: ", ConsoleService.EvalNotEmpty, null),
                new ConsoleParam("OUT", ConsoleService.Prompt, "Dst Filename: ", ConsoleService.EvalNotEmpty, null),
                new ConsoleParam("PRODUCT"),
                new ConsoleParam("RC"),
            };
            ConsoleParamValueList vl = c.ParseCommandList(cmdName, str, args);

            string targetFilename = vl.DefaultParam.StrValue;
            string outFilename = vl["OUT"].StrValue;
            string product_name = vl["PRODUCT"].StrValue;

            Win32BuildUtil.GenerateVersionInfoResource(targetFilename, outFilename, vl["RC"].StrValue, product_name);

            return 0;
        }
Beispiel #42
0
        static int Test(ConsoleService c, string cmdName, string str)
        {
            ConsoleParam[] args =
            {
            };
            ConsoleParamValueList vl = c.ParseCommandList(cmdName, str, args);

            TestClass.Test();

            return 0;
        }
Beispiel #43
0
        static int SignCode(ConsoleService c, string cmdName, string str)
        {
            ConsoleParam[] args =
            {
                new ConsoleParam("[filename]", ConsoleService.Prompt, "Filename: ", ConsoleService.EvalNotEmpty, null),
                new ConsoleParam("DEST"),
                new ConsoleParam("COMMENT", ConsoleService.Prompt, "Comment: ", ConsoleService.EvalNotEmpty, null),
                new ConsoleParam("KERNEL"),
            };
            ConsoleParamValueList vl = c.ParseCommandList(cmdName, str, args);

            string destFileName = vl["DEST"].StrValue;
            string srcFileName = vl.DefaultParam.StrValue;
            if (Str.IsEmptyStr(destFileName))
            {
                destFileName = srcFileName;
            }
            string comment = vl["COMMENT"].StrValue;
            bool kernel = vl["KERNEL"].BoolValue;

            CodeSign.SignFile(destFileName, srcFileName, comment, kernel);

            return 0;
        }
Beispiel #44
0
        static int SetPE4(ConsoleService c, string cmdName, string str)
        {
            ConsoleParam[] args =
            {
                new ConsoleParam("[filename]", ConsoleService.Prompt, "Filename: ", ConsoleService.EvalNotEmpty, null)
            };
            ConsoleParamValueList vl = c.ParseCommandList(cmdName, str, args);

            PEUtil.SetPEVersionTo4(vl.DefaultParam.StrValue);

            return 0;
        }
Beispiel #45
0
        static int PostBuild(ConsoleService c, string cmdName, string str)
        {
            ConsoleParam[] args =
            {
            };
            ConsoleParamValueList vl = c.ParseCommandList(cmdName, str, args);

            Win32BuildUtil.SignAllBinaryFiles();
            HamCoreBuildUtil.BuildHamcore();

            return 0;
        }
        public static int BuildUtil(ConsoleService c, string cmdName, string str)
        {
            Con.WriteLine("");
            Con.WriteLine("Copyright (c) SoftEther VPN Project. All Rights Reserved.");
            Con.WriteLine("");

            ConsoleParam[] args =
            {
                new ConsoleParam("IN", null, null, null, null),
                new ConsoleParam("OUT", null, null, null, null),
                new ConsoleParam("CMD", null, null, null, null),
                new ConsoleParam("CSV", null, null, null, null),
                new ConsoleParam("PAUSEIFERROR", null, null, null, null),
                new ConsoleParam("DT", null, null, null, null),
            };

            ConsoleParamValueList vl = c.ParseCommandList(cmdName, str, args);

            pause = vl["PAUSEIFERROR"].BoolValue;

            string cmdline = vl["CMD"].StrValue;

            if (vl["DT"].IsEmpty == false)
            {
                BuildSoftwareList.ListCreatedDateTime = Str.StrToDateTime(vl["DT"].StrValue);
            }

            ConsoleService cs = c;

            while (cs.DispatchCommand(cmdline, "BuildUtil>", typeof(BuildUtilCommands), null))
            {
                if (Str.IsEmptyStr(cmdline) == false)
                {
                    break;
                }
            }

            return cs.RetCode;
        }
Beispiel #47
0
        static int Count(ConsoleService c, string cmdName, string str)
        {
            ConsoleParam[] args =
            {
                new ConsoleParam("[DIR]", null, null, null, null),
            };
            ConsoleParamValueList vl = c.ParseCommandList(cmdName, str, args);

            string dir = vl.DefaultParam.StrValue;
            if (Str.IsEmptyStr(dir))
            {
                dir = Paths.BaseDirName;
            }

            string[] files = Directory.GetFiles(dir, "*", SearchOption.AllDirectories);

            int numLines = 0;
            int numBytes = 0;
            int numComments = 0;
            int totalLetters = 0;

            Dictionary<string, int> commentsDict = new Dictionary<string, int>();

            foreach (string file in files)
            {
                string ext = Path.GetExtension(file);

                if (Str.StrCmpi(ext, ".c") || Str.StrCmpi(ext, ".cpp") || Str.StrCmpi(ext, ".h") ||
                    Str.StrCmpi(ext, ".rc") || Str.StrCmpi(ext, ".stb") || Str.StrCmpi(ext, ".cs")
                     || Str.StrCmpi(ext, ".fx") || Str.StrCmpi(ext, ".hlsl"))
                {
                    if (Str.InStr(file, "\\.svn\\") == false && Str.InStr(file, "\\seedll\\") == false && Str.InStr(file, "\\see\\") == false && Str.InStr(file, "\\openssl\\") == false)
                    {
                        string[] lines = File.ReadAllLines(file);

                        numLines += lines.Length;
                        numBytes += (int)new FileInfo(file).Length;

                        foreach (string line in lines)
                        {
                            if (Str.InStr(line, "//") && Str.InStr(line, "// Validate arguments") == false)
                            {
                                if (commentsDict.ContainsKey(line) == false)
                                {
                                    commentsDict.Add(line, 1);
                                }
                                numComments++;

                                totalLetters += line.Trim().Length - 3;
                            }
                        }
                    }
                }
            }

            Con.WriteLine("{0} Lines,  {1} Bytes.  {2} Comments ({3} distinct, aver: {4})", Str.ToStr3(numLines), Str.ToStr3(numBytes),
                Str.ToStr3(numComments), commentsDict.Count, totalLetters / numComments);

            return 0;
        }
Beispiel #48
0
        static int FileCopy(ConsoleService c, string cmdName, string str)
        {
            ConsoleParam[] args =
            {
                new ConsoleParam("[src]", ConsoleService.Prompt, "Src Filename: ", ConsoleService.EvalNotEmpty, null),
                new ConsoleParam("DEST", ConsoleService.Prompt, "Dst Filename: ", ConsoleService.EvalNotEmpty, null),
            };
            ConsoleParamValueList vl = c.ParseCommandList(cmdName, str, args);

            string destFileName = vl["DEST"].StrValue;
            string srcFileName = vl.DefaultParam.StrValue;

            IO.FileCopy(srcFileName, destFileName, true, false);

            return 0;
        }
Beispiel #49
0
        static int MakeSoftEtherDir(ConsoleService c, string cmdName, string str)
        {
            ConsoleParam[] args =
            {
            };
            ConsoleParamValueList vl = c.ParseCommandList(cmdName, str, args);

            OpenSourceUtil.MakeSoftEtherDir();

            return 0;
        }
Beispiel #50
0
        static int GenerateVpnWebOcxCab(ConsoleService c, string cmdName, string str)
        {
            ConsoleParam[] args =
            {
                new ConsoleParam("[src]", ConsoleService.Prompt, "Src Filename: ", ConsoleService.EvalNotEmpty, null),
                new ConsoleParam("DEST", ConsoleService.Prompt, "Dst Filename: ", ConsoleService.EvalNotEmpty, null),
            };
            ConsoleParamValueList vl = c.ParseCommandList(cmdName, str, args);

            #if	!BU_OSS
            string destFileName = vl["DEST"].StrValue;
            string srcFileName = vl.DefaultParam.StrValue;

            Win32BuildUtil.GenerateVpnWebOcxCab(destFileName, srcFileName);
            #endif

            return 0;
        }
Beispiel #51
0
        static int All(ConsoleService c, string cmdName, string str)
        {
            ConsoleParam[] args =
            {
            #if !BU_SOFTETHER
                new ConsoleParam("[yes|no]", ConsoleService.Prompt, "Increments build number (y/n) ? ", ConsoleService.EvalNotEmpty, null),
                new ConsoleParam("SEVPN", ConsoleService.Prompt, "Build SoftEther VPN automatically after PacketiX VPN Build (y/n) ? ", ConsoleService.EvalNotEmpty, null),
            #else
                new ConsoleParam("[yes|no]"),
            #endif
                new ConsoleParam("IGNOREERROR"),
                new	ConsoleParam("DEBUG"),
                new ConsoleParam("SERIAL"),
            };
            ConsoleParamValueList vl = c.ParseCommandList(cmdName, str, args);

            DateTime start = Time.NowDateTime;

            Win32BuildUtil.ExecCommand(Env.ExeFileName, string.Format("/CMD:BuildWin32 {0} /NORMALIZESRC:{1}",
                vl["[yes|no]"].BoolValue ? "yes" : "no",
                "yes"));

            Win32BuildUtil.ExecCommand(Env.ExeFileName, string.Format("/CMD:ReleaseWin32 all /IGNOREERROR:{0} /SERIAL:{1}",
                vl["IGNOREERROR"].BoolValue ? "yes" : "no",
                vl["SERIAL"].BoolValue ? "yes" : "no"));

            #if !BU_OSS
            Win32BuildUtil.ExecCommand(Env.ExeFileName, string.Format("/CMD:ReleaseUnix all /IGNOREERROR:{0} /DEBUG:{1} /SERIAL:{2}",
                vl["IGNOREERROR"].BoolValue ? "yes" : "no",
                vl["DEBUG"].BoolValue ? "yes" : "no",
                vl["SERIAL"].BoolValue ? "yes" : "no"));
            #endif

            Win32BuildUtil.ExecCommand(Env.ExeFileName, string.Format("/CMD:CopyRelease"));

            #if !BU_SOFTETHER
            Win32BuildUtil.ExecCommand(Env.ExeFileName, string.Format("/CMD:MakeSoftEtherDir"));

            if (vl["SEVPN"].BoolValue)
            {
                // Build SEVPN
                Win32BuildUtil.ExecCommand(Paths.CmdFileName, string.Format("/C \"{0}\"", Path.Combine(Paths.SoftEtherBuildDir, @"Main\BuildAll.cmd")));
            }

            Win32BuildUtil.ExecCommand(Env.ExeFileName, string.Format("/CMD:MakeOpenSource"));
            #endif

            DateTime end = Time.NowDateTime;

            Con.WriteLine("Taken time: {0}.", (end - start));

            return 0;
        }
Beispiel #52
0
        static int IncrementBuildNumber(ConsoleService c, string cmdName, string str)
        {
            ConsoleParam[] args =
            {
            };
            ConsoleParamValueList vl = c.ParseCommandList(cmdName, str, args);

            Win32BuildUtil.IncrementBuildNumber();

            return 0;
        }
Beispiel #53
0
        static int BuildDriverPackage(ConsoleService c, string cmdName, string str)
        {
            Win32BuildUtil.MakeDriverPackage();

            return 0;
        }
Beispiel #54
0
        static int ReleaseUnix(ConsoleService c, string cmdName, string str)
        {
            ConsoleParam[] args =
            {
                new ConsoleParam("[id]"),
                new ConsoleParam("IGNOREERROR"),
                new	ConsoleParam("DEBUG"),
                new ConsoleParam("SERIAL"),
            };
            ConsoleParamValueList vl = c.ParseCommandList(cmdName, str, args);

            int version, build;
            string name;
            DateTime date;
            Win32BuildUtil.ReadBuildInfoFromTextFile(out build, out version, out name, out date);
            BuildSoftware[] softs = BuildSoftwareList.List;
            bool serial = vl["SERIAL"].BoolValue;

            if (Str.IsEmptyStr(vl.DefaultParam.StrValue))
            {
                Con.WriteLine("IDs:");
                foreach (BuildSoftware soft in softs)
                {
                    if (soft.Os.IsWindows == false)
                    {
                        soft.SetBuildNumberVersionName(build, version, name, date);
                        Con.WriteLine("  {0}", soft.IDString);
                        Con.WriteLine("    - \"{0}\"", soft.OutputFileName);
                    }
                }
            }
            else
            {
                string key = vl.DefaultParam.StrValue;
                bool all = false;

                if ("all".StartsWith(key, StringComparison.InvariantCultureIgnoreCase))
                {
                    all = true;
                }

                if ("clean".StartsWith(key, StringComparison.InvariantCultureIgnoreCase))
                {
                    // Delete the release directory
                    Paths.DeleteAllReleaseTarGz();
                    Con.WriteLine("Clean completed.");
                    return 0;
                }

                List<BuildSoftware> o = new List<BuildSoftware>();

                foreach (BuildSoftware soft in softs)
                {
                    soft.SetBuildNumberVersionName(build, version, name, date);

                    if (soft.Os.IsWindows == false)
                    {
                        if (all || soft.IDString.IndexOf(key, StringComparison.InvariantCultureIgnoreCase) != -1)
                        {
                            o.Add(soft);
                        }
                    }
                }

                if (o.Count == 0)
                {
                    throw new ApplicationException(string.Format("Software ID '{0}' not found.", key));
                }
                else
                {
                    if (all)
                    {
                        // Delete the release directory
                        Paths.DeleteAllReleaseTarGz();
                    }
                    else
                    {
                        IO.MakeDir(Paths.ReleaseDir);
                    }

                    if (serial)
                    {
                        // Build in series
                        int i;
                        for (i = 0; i < o.Count; i++)
                        {
                            Con.WriteLine("{0} / {1}: Executing for '{2}'...",
                                i + 1, o.Count, o[i].IDString);

                            BuildHelper.BuildMain(o[i], vl["DEBUG"].BoolValue);
                        }
                    }
                    else if (o.Count == 1)
                    {
                        // To build
                        BuildHelper.BuildMain(o[0], vl["DEBUG"].BoolValue);
                    }
                    else
                    {
                        // Make a child process build
                        Process[] procs = new Process[o.Count];

                        int i;

                        for (i = 0; i < o.Count; i++)
                        {
                            Con.WriteLine("{0} / {1}: Executing for '{2}'...",
                                i + 1, o.Count, o[i].IDString);

                            procs[i] = Kernel.Run(Env.ExeFileName,
                                string.Format("/PAUSEIFERROR:{1} /DT:{2} /CMD:ReleaseUnix /DEBUG:{3} {0}",
                                o[i].IDString, vl["IGNOREERROR"].BoolValue ? "no" : "yes", Str.DateTimeToStrShort(BuildSoftwareList.ListCreatedDateTime), vl["DEBUG"].BoolValue ? "yes" : "no")
                                );
                        }

                        Con.WriteLine("Waiting child processes...");

                        int numError = 0;

                        for (i = 0; i < o.Count; i++)
                        {
                            procs[i].WaitForExit();

                            bool ok = procs[i].ExitCode == 0;

                            if (ok == false)
                            {
                                numError++;
                            }

                            Con.WriteLine("{0} / {1} ({2}):", i + 1, o.Count, o[i].IDString);
                            Con.WriteLine("       {0}", ok ? "Success" : "* Error *");
                        }

                        Con.WriteLine();
                        if (numError != 0)
                        {
                            throw new ApplicationException(string.Format("{0} Errors.", numError));
                        }
                        Con.WriteLine("No Errors.");
                    }
                }
            }

            return 0;
        }
Beispiel #55
0
        static int SetManifest(ConsoleService c, string cmdName, string str)
        {
            ConsoleParam[] args =
            {
                new ConsoleParam("[filename]", ConsoleService.Prompt, "Target Filename: ", ConsoleService.EvalNotEmpty, null),
                new ConsoleParam("MANIFEST", ConsoleService.Prompt, "Manifest Filename: ", ConsoleService.EvalNotEmpty, null),
            };
            ConsoleParamValueList vl = c.ParseCommandList(cmdName, str, args);

            PEUtil.SetManifest(vl.DefaultParam.StrValue, vl["MANIFEST"].StrValue);

            return 0;
        }