public void SetCi(char separator)
        {
            var commandLine = $"--set-ci --dd-env{separator}TestEnv --dd-service{separator}TestService --dd-version{separator}TestVersion --tracer-home{separator}TestTracerHome --agent-url{separator}TestAgentUrl --env-vars{separator}VAR1=A,VAR2=B";

            using var helper = StartProcess(commandLine, ("TF_BUILD", "1"));

            helper.Process.WaitForExit();
            helper.Drain();

            helper.Process.ExitCode.Should().Be(0);

            var environmentVariables = new Dictionary <string, string>();

            foreach (var line in helper.StandardOutput.Split(Environment.NewLine))
            {
                // ##vso[task.setvariable variable=DD_DOTNET_TRACER_HOME]TestTracerHome
                var match = Regex.Match(line, @"##vso\[task.setvariable variable=(?<name>[A-Z1-9_]+)\](?<value>.*)");

                if (match.Success)
                {
                    environmentVariables.Add(match.Groups["name"].Value, match.Groups["value"].Value);
                }
            }

            environmentVariables["DD_ENV"].Should().Be("TestEnv");
            environmentVariables["DD_SERVICE"].Should().Be("TestService");
            environmentVariables["DD_VERSION"].Should().Be("TestVersion");
            environmentVariables["DD_DOTNET_TRACER_HOME"].Should().Be("TestTracerHome");
            environmentVariables["DD_TRACE_AGENT_URL"].Should().Be("TestAgentUrl");
            environmentVariables["VAR1"].Should().Be("A");
            environmentVariables["VAR2"].Should().Be("B");
        }
        public void LocateTracerHome()
        {
            var commandLine = "--set-ci";

            using var helper = StartProcess(commandLine, ("TF_BUILD", "1"));

            helper.Process.WaitForExit();
            helper.Drain();

            helper.Process.ExitCode.Should().Be(0);
            helper.StandardOutput.Should().NotContainEquivalentOf("error");
            helper.ErrorOutput.Should().BeEmpty();
        }
예제 #3
0
        /// <summary>
        /// 启动服务提供商启动流程
        /// </summary>
        /// <returns>迭代器</returns>
        private IEnumerator StartProviderPorcess()
        {
            process = StartProcess.OnProviderProcess;

            TriggerGlobal(ApplicationEvents.OnProviderProcessing, this).Trigger();

            var providers = new List <ServiceProvider>(serviceProviders.Values);

            providers.Sort((left, right) =>
            {
                var leftPriorities  = GetPriorities(left.GetType(), "OnProviderProcess");
                var rightPriorities = GetPriorities(right.GetType(), "OnProviderProcess");
                return(leftPriorities.CompareTo(rightPriorities));
            });

            foreach (var provider in providers)
            {
                yield return(provider.OnProviderProcess());
            }

            TriggerGlobal(ApplicationEvents.OnProviderProcessed, this).Trigger();

            process = StartProcess.OnComplete;

            TriggerGlobal(ApplicationEvents.OnApplicationStartComplete, this).Trigger();
        }
예제 #4
0
        /// <summary>
        /// 初始化
        /// </summary>
        /// <exception cref="RuntimeException">没有调用<c>Bootstrap(...)</c>就尝试初始化时触发</exception>
        public void Init()
        {
            if (inited)
            {
                return;
            }
            if (!bootstrapped)
            {
                throw new RuntimeException("Must call Bootstrap() first.");
            }

            var providers = new List <ServiceProvider>(serviceProviders.Values);

            process = StartProcess.OnInit;

            TriggerGlobal(ApplicationEvents.OnIniting, this).Trigger();

            foreach (var serviceProvider in providers)
            {
                serviceProvider.Init();
            }

            inited = true;

            TriggerGlobal(ApplicationEvents.OnInited, this).Trigger();

            StartCoroutine(StartProviderPorcess());
        }
예제 #5
0
        /// <summary>
        /// 引导程序
        /// </summary>
        /// <param name="bootstraps">引导程序</param>
        /// <returns>CatLib实例</returns>
        /// <exception cref="ArgumentNullException">当引导类型为null时引发</exception>
        /// <exception cref="RuntimeException">当引导类型没有实现<see cref="IBootstrap"/>时引发</exception>
        public IApplication Bootstrap(params Type[] bootstraps)
        {
            Guard.Requires <ArgumentNullException>(bootstraps != null);

            if (bootstrapped)
            {
                return(this);
            }

            process = StartProcess.OnBootstrap;

            App.Instance = this;

            Instance(typeof(Application).ToString(), this);
            Alias(typeof(IApplication).ToString(), typeof(Application).ToString());
            Alias(typeof(App).ToString(), typeof(Application).ToString());
            Alias(typeof(IContainer).ToString(), typeof(Application).ToString());

            foreach (var t in bootstraps)
            {
                if (!typeof(IBootstrap).IsAssignableFrom(t))
                {
                    throw new RuntimeException("Type [" + t + "] is not implements IBootstrap.");
                }
                var bootstrap = Make(t.ToString()) as IBootstrap;
                bootstrap.Bootstrap();
            }

            bootstrapped = true;

            return(this);
        }
예제 #6
0
        /// <summary>
        /// 启动服务提供商启动流程
        /// </summary>
        /// <returns>迭代器</returns>
        private IEnumerator InitPorcess()
        {
            var providers = new List <ServiceProvider>(serviceProviders.Values);

            providers.Sort((left, right) =>
            {
                var leftPriorities  = GetPriorities(left.GetType(), "Init");
                var rightPriorities = GetPriorities(right.GetType(), "Init");
                return(leftPriorities.CompareTo(rightPriorities));
            });

            foreach (var provider in providers)
            {
                yield return(provider.Init());
            }

            process = StartProcess.Inited;

            Trigger(ApplicationEvents.OnStartComplete, this);

            if (onInited != null)
            {
                onInited.Invoke();
            }
        }
예제 #7
0
        public Boolean startConnection(out String errorMessage)
        {
            errorMessage = String.Empty;

            //Check if application path exist with resolved OS variables
            if (File.Exists(Environment.ExpandEnvironmentVariables(this.application.path)))
            {
                //Overwrite application options if set in keepass entry
                if (this.keepassEntry.Strings.ReadSafe(this.plugin.settings.connectionOptionsField).Length > 0)
                {
                    this.customConnectionOptions = this.keepassEntry.Strings.ReadSafe(this.plugin.settings.connectionOptionsField);
                }

                //Create a thread to allow non gui blocking sleeps
                new Thread(() =>
                {
                    Thread.CurrentThread.IsBackground = true; //Background threads will stop automatically on program close

                    //Fill placeholders in options and start programm
                    StartProcess.Start(fillPlaceholders(this.application.path), fillPlaceholders(this.customConnectionOptions));
                }).Start();


                return(true);
            }
            else
            {
                errorMessage = ("Application '" + application.path + "' not found!");
                return(false);
            }
        }
예제 #8
0
        /// <summary>
        /// 引导程序
        /// </summary>
        /// <param name="bootstraps">引导文件</param>
        /// <returns>CatLib实例</returns>
        public IApplication Bootstrap(Type[] bootstraps)
        {
            process = StartProcess.OnBootstrap;

            App.Instance = this;

            Instance(typeof(Application).ToString(), this);
            Alias(typeof(IApplication).ToString(), typeof(Application).ToString());
            Alias(typeof(App).ToString(), typeof(Application).ToString());
            Alias(typeof(IContainer).ToString(), typeof(Application).ToString());

            IBootstrap bootstrap;

            foreach (var t in bootstraps)
            {
                bootstrap = this.Make <IBootstrap>(t);
                if (bootstrap != null)
                {
                    bootstrap.Bootstrap();
                }
            }

            bootstrapped = true;

            return(this);
        }
예제 #9
0
        /// <inheritdoc cref="Init"/>
        /// <returns>Indicate the initialization progress.</returns>
        protected IEnumerator CoroutineInit()
        {
            if (!bootstrapped)
            {
                throw new CodeStandardException($"You must call {nameof(Bootstrap)}() first.");
            }

            if (inited || Process != StartProcess.Bootstraped)
            {
                throw new CodeStandardException($"Cannot repeatedly trigger the {nameof(Init)}()");
            }

            Process = StartProcess.Init;
            Trigger(ApplicationEvents.OnInit, this);
            Process = StartProcess.Initing;

            foreach (var sorted in serviceProviders)
            {
                foreach (var provider in sorted.Value)
                {
                    yield return(InitProvider(provider));
                }
            }

            inited  = true;
            Process = StartProcess.Inited;
            Trigger(ApplicationEvents.OnInited, this);

            Process = StartProcess.Running;
            Trigger(ApplicationEvents.OnStartCompleted, this);
        }
예제 #10
0
        /// <summary>
        /// 初始化
        /// </summary>
        /// <exception cref="RuntimeException">没有调用<c>Bootstrap(...)</c>就尝试初始化时触发</exception>
        public void Init()
        {
            if (!bootstrapped)
            {
                throw new RuntimeException("You must call Bootstrap() first.");
            }

            if (inited)
            {
                return;
            }

            process = StartProcess.Initing;

            foreach (var provider in serviceProviders)
            {
                Trigger(ApplicationEvents.OnIniting, provider);
                provider.Init();
            }

            inited  = true;
            process = StartProcess.Inited;

            Trigger(ApplicationEvents.OnStartCompleted, this);
        }
예제 #11
0
        /// <summary>
        /// 初始化
        /// </summary>
        public void Init()
        {
            if (inited)
            {
                return;
            }
            if (!bootstrapped)
            {
                return;
            }

            ServiceProvider[] providers = serviceProviders.ToArray();

            process = StartProcess.OnInit;

            Trigger(this).SetEventName(ApplicationEvents.ON_INITING).Trigger();

            foreach (ServiceProvider serviceProvider in providers)
            {
                serviceProvider.Init();
            }

            inited = true;

            Trigger(this).SetEventName(ApplicationEvents.ON_INITED).Trigger();

            StartCoroutine(StartProviderPorcess());
        }
예제 #12
0
        /// <summary>
        /// 引导程序
        /// </summary>
        /// <param name="bootstraps">引导程序</param>
        /// <returns>CatLib实例</returns>
        /// <exception cref="ArgumentNullException">当引导类型为null时引发</exception>
        public void Bootstrap(params IBootstrap[] bootstraps)
        {
            Guard.Requires <ArgumentNullException>(bootstraps != null);

            if (bootstrapped)
            {
                return;
            }

            process = StartProcess.Bootstrap;

            var sorting = new SortSet <IBootstrap, int>();

            foreach (var bootstrap in bootstraps)
            {
                sorting.Add(bootstrap, GetPriority(bootstrap.GetType(), "Bootstrap"));
            }

            foreach (var bootstrap in sorting)
            {
                if (bootstrap != null)
                {
                    bootstrap.Bootstrap();
                }
            }

            process      = StartProcess.Bootstraped;
            bootstrapped = true;
            Trigger(ApplicationEvents.OnBootstraped, this);
        }
예제 #13
0
        private void OpenNotepadMethod()
        {
            string textFile = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\xMenuTools\\Version.txt";

            if (!File.Exists(textFile))
            {
                System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
                FileVersionInfo            fvi      = FileVersionInfo.GetVersionInfo(assembly.Location);
                string version = fvi.FileVersion;

                Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\xMenuTools");
                File.WriteAllText(textFile, version);
            }
            if (HasExecutable(textFile))
            {
                foreach (string filePath in SelectedItemPaths)
                {
                    StartProcess.StartInfo(
                        FindExecutable(textFile), filePath);
                }
            }
            else
            {
                foreach (string filePath in SelectedItemPaths)
                {
                    StartProcess.StartInfo("Notepad.exe", filePath);
                }
            }
        }
 // Methods
 private void OpenNotepadMethod()
 {
     foreach (var filePath in SelectedItemPaths)
     {
         StartProcess.StartInfo("Notepad.exe", filePath);
     }
 }
        /// <summary>
        /// Logs process start
        /// </summary>
        /// <param name="configrec">Configuration record having the information about the process to be started</param>
        /// <param name="pd">Process data</param>
        public void StartProcess(
            ConfigurationRecord configRec,
            ProcessData pd)
        {
            lock (this)
            {
                CheckDamaged();

                XmlSerializer serializer = new XmlSerializer(typeof(StartProcess));
                StartProcess  sp         = new StartProcess();
                sp.ApplicationName      = configRec.m_applicationName;
                sp.StartUpData          = configRec.m_cmdLineArgs;
                sp.SQLServer            = configRec.m_sqlServer;
                sp.Database             = configRec.m_database;
                sp.Schema               = configRec.m_schema;
                sp.Queue                = configRec.m_queue;
                sp.ProcessId            = pd.Pid;
                sp.CreationHighDateTime = pd.CreationHighDateTime;
                sp.CreationLowDateTime  = pd.CreationLowDateTime;

                StringBuilder sb      = new StringBuilder();
                TextWriter    writer  = new StringWriter(sb);
                XmlTextWriter xwriter = new XmlTextWriter(writer);
                xwriter.Formatting = Formatting.None;
                serializer.Serialize(xwriter, sp);
                string xmlStartProcessString = sb.ToString();

                WriteToLog(String.Format("{0}{1}\n{2}", ms_processStart, xmlStartProcessString.Length, xmlStartProcessString));
            }
        }
예제 #16
0
        /// <summary>
        /// 初始化
        /// </summary>
        public void Init()
        {
            if (inited)
            {
                return;
            }
            if (!bootstrapped)
            {
                return;
            }

            var providers = new List <ServiceProvider>(serviceProviders.Values).ToArray();

            process = StartProcess.OnInit;

            TriggerGlobal(ApplicationEvents.ON_INITING, this).Trigger();

            foreach (var serviceProvider in providers)
            {
                serviceProvider.Init();
            }

            inited = true;

            TriggerGlobal(ApplicationEvents.ON_INITED, this).Trigger();

            StartCoroutine(StartProviderPorcess());
        }
예제 #17
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private java.util.Map<String, Object> extractVariables(org.camunda.bpm.engine.cdi.annotation.StartProcess startProcessAnnotation, javax.interceptor.InvocationContext ctx) throws Exception
        private IDictionary <string, object> extractVariables(StartProcess startProcessAnnotation, InvocationContext ctx)
        {
            VariableMap variables = new VariableMapImpl();

            foreach (System.Reflection.FieldInfo field in ctx.Method.DeclaringClass.DeclaredFields)
            {
                if (!field.isAnnotationPresent(typeof(ProcessVariable)) && !field.isAnnotationPresent(typeof(ProcessVariableTyped)))
                {
                    continue;
                }
                field.Accessible = true;

                string fieldName = null;

                ProcessVariable processStartVariable = field.getAnnotation(typeof(ProcessVariable));
                if (processStartVariable != null)
                {
                    fieldName = processStartVariable.value();
                }
                else
                {
                    ProcessVariableTyped processStartVariableTyped = field.getAnnotation(typeof(ProcessVariableTyped));
                    fieldName = processStartVariableTyped.value();
                }

                if (string.ReferenceEquals(fieldName, null) || fieldName.Length == 0)
                {
                    fieldName = field.Name;
                }
                object value = field.get(ctx.Target);
                variables.put(fieldName, value);
            }

            return(variables);
        }
예제 #18
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @AroundInvoke public Object invoke(javax.interceptor.InvocationContext ctx) throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        public virtual object invoke(InvocationContext ctx)
        {
            try
            {
                object result = ctx.proceed();

                StartProcess startProcessAnnotation = ctx.Method.getAnnotation(typeof(StartProcess));

                string key = startProcessAnnotation.value();

                IDictionary <string, object> variables = extractVariables(startProcessAnnotation, ctx);

                businessProcess.startProcessByKey(key, variables);

                return(result);
            }
            catch (InvocationTargetException e)
            {
                Exception cause = e.InnerException;
                if (cause != null && cause is Exception)
                {
                    throw (Exception)cause;
                }
                else
                {
                    throw e;
                }
            }
            catch (Exception e)
            {
                throw new ProcessEngineException("Error while starting process using @StartProcess on method  '" + ctx.Method + "': " + e.Message, e);
            }
        }
예제 #19
0
        /// <summary>
        /// 起動に該当する設定用のパネルコントロールに関するクラスのインスタンスを生成する
        /// </summary>
        /// <param name="exeStartPanel">起動に該当する設定用のパネルコントロール</param>
        /// <param name="setting">プロパティグリッドコントロールに関連付けされている設定情報</param>
        /// <param name="propertyName">対象とする起動に該当する設定情報のプロパティ名</param>
        /// <returns>起動に該当する設定用のパネルコントロールに関するクラスのインスタンス</returns>
        public static SettingPanel CreateInstanceExeStart(
            Panel exeStartPanel, Setting setting, string propertyName)
        {
            return(new SettingPanel(
                       exeStartPanel,
                       () => GetSettingPropertyValue <string>(setting, propertyName),
                       (property) => Path.GetFileName(property),
                       (property) => CheckExeStartProperty(property),
                       (property) => StartProcess.Start(property)));

            // 起動に該当する設定情報のプロパティの設定値についてチェックを行う
            // 引数1:起動に該当する設定情報のプロパティ
            // 戻り値:チェック結果のプロパティ設定のステータス
            PropertySettingStatus CheckExeStartProperty(string property)
            {
                // 起動対象のパスが存在しない場合、未設定を返却
                if (string.IsNullOrWhiteSpace(property))
                {
                    return(PropertySettingStatus.NotSet);
                }

                // 起動対象のパスのファイル又はフォルダが存在するかチェック
                // 起動対象のパスのファイル又はフォルダが存在しない場合、エラーを返却
                // (ショートカットの場合は拡張子「.lnk」を付与して判定する)
                if (!File.Exists(property) &&
                    !Directory.Exists(property) &&
                    !File.Exists(property + ".lnk"))
                {
                    return(PropertySettingStatus.Error);
                }

                // 上記チェックがOKの場合、正常を返却
                return(PropertySettingStatus.Ok);
            }
        }
예제 #20
0
 /// <summary>
 /// 终止CatLib框架
 /// </summary>
 public virtual void Terminate()
 {
     Process = StartProcess.Terminate;
     Trigger(ApplicationEvents.OnTerminate, this);
     Process = StartProcess.Terminating;
     Flush();
     App.Handler = null;
     Process     = StartProcess.Terminated;
     Trigger(ApplicationEvents.OnTerminated, this);
 }
예제 #21
0
 /// <summary>
 /// 构建一个CatLib实例
 /// </summary>
 public Application()
 {
     App.Handler  = this;
     mainThreadId = Thread.CurrentThread.ManagedThreadId;
     RegisterCoreAlias();
     RegisterCoreService();
     OnFindType(finder => { return(Type.GetType(finder)); });
     DebugLevel = DebugLevels.Production;
     Process    = StartProcess.Construct;
 }
 private void OpenGitAsAdminMethod()
 {
     if (FolderPath.Contains(" "))
     {
         StartProcess.StartInfo("C:\\Program Files\\Git\\git-cmd.exe", "--cd=" + "\"" + FolderPath + "\"", false, true);
     }
     else
     {
         StartProcess.StartInfo("C:\\Program Files\\Git\\git-cmd.exe", "--cd=" + FolderPath, false, true);
     }
 }
예제 #23
0
            public async Task ThrowsForNonZeroExitCode()
            {
                // Given
                TestExecutionContext context = new TestExecutionContext();

                context.TestLoggerProvider.ThrowLogLevel = LogLevel.None;
                StartProcess startProcess = new StartProcess("dotnet", "--foo").LogOutput();

                // When, Then
                await Should.ThrowAsync <ExecutionException>(async() => await ExecuteAsync(context, startProcess));
            }
예제 #24
0
        public Test3Layer()
        {
            InitializeComponent();

            //objdataaccess = new DataAccess();
            //FtpTrace.AddListener(new TextWriterTraceListener(objdataaccess.GetFtpLogsPath() + DateTime.Now.ToString("yyyyMMdd_hhmmss") + "FtpLog.txt"));
            //FtpTrace.LogUserName = true;    //f- hide FTP user names
            //FtpTrace.LogPassword = true;    //f- hide FTP passwords
            //FtpTrace.LogIP = true;            //f- hide FTP server IP addresses

            //try
            //{
            //    logger = new Logger();
            //    objdataaccess = new DataAccess();
            //   // stProcessor = new StartProcess(logger, objdataaccess);
            //    stProcessor = new StartProcess();
            //   // objSafeconvert = new SafeConvert();
            //    // timer = new Timer();
            //    //timer.Interval = 60000 * Convert.ToInt32(objdataaccess.GetKeyValue("JobMinutes"));
            //    //this.timer.Elapsed += OnTimer;
            //}
            //catch (Exception ex)
            //{
            //    logger.Log(ex.Message, LogLevel.ERR);
            //    stProcessor.SendMail(ex.Message, ex.StackTrace);
            //}

            try
            {
                // timer = new Timer();
                logger        = new Logger();
                stProcessor   = new StartProcess();
                objdataaccess = new DataAccess();

                // timer.Interval = 2 * 60 * 1000; //2 min

                // timer.Interval = objdataaccess.GetTimeInterval() * 60 * 60 * 1000;      //   12 * 60 * 60 * 1000 (12 hour)

                // timer.Enabled = true;
                // this.timer.Elapsed += OnTimer;
                // timer.Start();

                /*  timer = new Timer();
                 * timer.Interval = 60000 * Convert.ToInt32(objdataaccess.GetKeyValue("JobMinutes"));
                 * timer.Interval = 3600000;  // 60 * 60 * 1000 (1 hour)
                 * timer.Interval = 43200000; // 12 * 60 * 60 * 1000 (12 hour)
                 * timer.Interval = 60 * 1000; //Check every minute ; just for testing                this.timer.Elapsed += OnTimer;
                 */
            }
            catch (Exception ex)
            {
                logger.Log(ex.Message, LogLevel.ERR);
            }
        }
        private void AttributesMenuMethod()
        {
            DirectoryInfo DirectoryPath = new DirectoryInfo(FolderPath);

            if (DirectoryPath.Parent == null)
            {
                StartProcess.StartInfo(AttributesInfo.GetAssembly.AssemblyInformation("directory") + @"\xMenuTools.exe", DirectoryPath + " -attributesmenu");
            }
            else
            {
                StartProcess.StartInfo(AttributesInfo.GetAssembly.AssemblyInformation("directory") + @"\xMenuTools.exe", "\"" + DirectoryPath + "\" " + "-attributesmenu");
            }
        }
        private void OpenTerminalAsAdminMethod()
        {
            string appPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"Microsoft\WindowsApps\Microsoft.WindowsTerminal_8wekyb3d8bbwe\wt.exe");

            if (FolderPath.Contains(" "))
            {
                StartProcess.StartInfo(appPath, "-d " + "\"" + FolderPath + "\"", false, true);
            }
            else
            {
                StartProcess.StartInfo(appPath, "-d " + FolderPath, false, true);
            }
        }
        public Boolean startConnection(out String errorMessage)
        {
            errorMessage = String.Empty;

            //Check if application path exist
            if (File.Exists(Environment.ExpandEnvironmentVariables(RDPConnectionItem.pathToRemoteDesktop)))
            {
                if (File.Exists(Environment.ExpandEnvironmentVariables(RDPConnectionItem.pathToCMDKey)))
                {
                    //Overwrite the default rdp parameter if set in keepass entry
                    if (this.keepassEntry.Strings.ReadSafe(this.plugin.settings.connectionOptionsField).Length > 0)
                    {
                        this.rdpCustomParameter = this.keepassEntry.Strings.ReadSafe(this.plugin.settings.connectionOptionsField);
                    }

                    //Create a thread to allow non gui blocking sleeps
                    new Thread(() =>
                    {
                        Thread.CurrentThread.IsBackground = true; //Background threads will stop automatically on program close

                        //Fill placeholders in options and start programm (cmdkey sets the rdp credentials)
                        StartProcess.Start(RDPConnectionItem.pathToCMDKey, fillPlaceholders(buildAddingCmdkeyParameter()));

                        //Wait before RDP start
                        Thread.Sleep(TimeSpan.FromMilliseconds(500));

                        //Fill placeholders in options and start remote desktop with thread delay
                        StartProcess.Start(RDPConnectionItem.pathToRemoteDesktop, fillPlaceholders(buildRDPParameter()));

                        //Wait before credential remove
                        Thread.Sleep(TimeSpan.FromMilliseconds(5000));

                        //Fill placeholders in options and start programm with thread delay(cmdkey removes the previous set rdp credentials)
                        StartProcess.Start(RDPConnectionItem.pathToCMDKey, fillPlaceholders(buildRemovingCmdkeyParameter()));
                    }).Start();

                    return(true);
                }
                else
                {
                    errorMessage = ("Application '" + RDPConnectionItem.pathToCMDKey + "' not found!");
                    return(false);
                }
            }
            else
            {
                errorMessage = ("Application '" + RDPConnectionItem.pathToRemoteDesktop + "' not found!");
                return(false);
            }
        }
예제 #28
0
        static void Main(string[] args)
        {
            var notAdminUsername = new StartProcess("calc.exe");

            notAdminUsername.Start();

            var json = UnsecureSerializer <StartProcess> .Serialize(notAdminUsername);

            var tamperedJson = json.Replace("calc.exe", "Virus.exe");

            var adminUsername = UnsecureSerializer <StartProcess> .Deserialize(tamperedJson);

            adminUsername.Start();
        }
예제 #29
0
        /// <summary>
        /// 引导程序
        /// </summary>
        /// <param name="bootstraps">引导程序</param>
        /// <returns>CatLib实例</returns>
        /// <exception cref="ArgumentNullException">当引导类型为null时引发</exception>
        public virtual void Bootstrap(params IBootstrap[] bootstraps)
        {
            Guard.Requires <ArgumentNullException>(bootstraps != null);

            if (bootstrapped || Process != StartProcess.Construct)
            {
                throw new CodeStandardException($"Cannot repeatedly trigger the {nameof(Bootstrap)}()");
            }

            Process = StartProcess.Bootstrap;
            Trigger(ApplicationEvents.OnBootstrap, this);
            Process = StartProcess.Bootstrapping;

            var sorting = new List <KeyValuePair <IBootstrap, int> >();
            var existed = new HashSet <IBootstrap>();

            foreach (var bootstrap in bootstraps)
            {
                if (bootstrap == null)
                {
                    continue;
                }

                if (existed.Contains(bootstrap))
                {
                    throw new LogicException($"The bootstrap already exists : {bootstrap}");
                }

                existed.Add(bootstrap);
                sorting.Add(new KeyValuePair <IBootstrap, int>(bootstrap,
                                                               GetPriority(bootstrap.GetType(), nameof(IBootstrap.Bootstrap))));
            }

            sorting.Sort((left, right) => left.Value.CompareTo(right.Value));

            foreach (var kv in sorting)
            {
                var bootstrap = kv.Key;
                var allow     = TriggerHalt(ApplicationEvents.Bootstrapping, bootstrap) == null;
                if (bootstrap != null && allow)
                {
                    bootstrap.Bootstrap();
                }
            }

            Process      = StartProcess.Bootstraped;
            bootstrapped = true;
            Trigger(ApplicationEvents.OnBootstraped, this);
        }
예제 #30
0
            public async Task KeepsDocumentContentsWhenRequested()
            {
                // Given
                TestExecutionContext context = new TestExecutionContext();

                context.TestLoggerProvider.ThrowLogLevel = LogLevel.None;
                StartProcess startProcess = new StartProcess("dotnet", "--info").KeepContent();

                // When
                ImmutableArray <TestDocument> results = await ExecuteAsync(context, startProcess);

                // Then
                results.Single().Content.ShouldNotStartWith(".NET Core SDK");
                ((IDocument)results.Single()).GetInt(StartProcess.ExitCode).ShouldBe(0);
            }
예제 #31
0
        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="provider"></param>
        public void Init()
        {
            if (inited) { return; }
            if (!bootstrapped) { return; }

            ServiceProvider[] providers = serviceProviders.ToArray();

            process = StartProcess.ON_DEPEND;

            Event.Trigger(ApplicationEvents.ON_DEPENDING);

            foreach (ServiceProvider provider in providers)
            {

                foreach (Type type in provider.ProviderDepend)
                {

                    if (!HasDepend(type.ToString()))
                    {
                        throw new Exception("service provider [" + provider.GetType().ToString() + "] depend service provider [" + type.ToString() + "]");
                    }
                }

            }

            Event.Trigger(ApplicationEvents.ON_DEPENDED);

            process = StartProcess.ON_INITED;

            Event.Trigger(ApplicationEvents.ON_INITING);

            foreach (ServiceProvider serviceProvider in providers)
            {
                serviceProvider.Init();
            }

            inited = true;

            Event.Trigger(ApplicationEvents.ON_INITED);

            StartCoroutine(StartProviderPorcess());
        }
예제 #32
0
        /// <summary>
        /// 引导程序
        /// </summary>
        /// <param name="bootstraps">引导文件</param>
        /// <returns></returns>
        public IApplication Bootstrap(Type[] bootstraps)
        {
            process = StartProcess.ON_BOOTSTRAP;

            App.Instance = this;
            Instances(typeof(Application).ToString(), this);
            Alias(typeof(IApplication).ToString(), typeof(Application).ToString());
            Alias(typeof(App).ToString(), typeof(Application).ToString());

            IBootstrap bootstrap;
            foreach (Type t in bootstraps)
            {
                bootstrap = this.Make<IBootstrap>(t);
                if (bootstrap != null)
                {
                    bootstrap.Bootstrap();
                }
            }

            bootstrapped = true;

            return this;
        }
예제 #33
0
        /// <summary>
        /// 启动服务提供商启动流程
        /// </summary>
        /// <returns></returns>
        protected IEnumerator StartProviderPorcess()
        {
            process = StartProcess.ON_PROVIDER_PROCESS;

            Trigger(ApplicationEvents.ON_PROVIDER_PROCESSING);

            List<ServiceProvider> providers = new List<ServiceProvider>(serviceProviders.Values);
            providers.Sort((left, right) => ((int)left.ProviderProcess).CompareTo((int)right.ProviderProcess) );

            foreach(ServiceProvider provider in providers)
            {
                yield return provider.OnProviderProcess();
            }

            Trigger(ApplicationEvents.ON_PROVIDER_PROCESSED);

            process = StartProcess.ON_COMPLETE;

            Trigger(ApplicationEvents.ON_APPLICATION_START_COMPLETE);
        }