コード例 #1
0
        private void SplitCommandLine()
        {
            var firstQuoteIndex = CommandLine.IndexOf("'", StringComparison.Ordinal);
            var lastQuoteIndex  = CommandLine.LastIndexOf("'", StringComparison.Ordinal);

            if (CommandLine.Contains("'") &&
                firstQuoteIndex != lastQuoteIndex)
            {
                ExePath   = CommandLine.Substring(firstQuoteIndex, lastQuoteIndex - firstQuoteIndex + 1).Trim('\'');
                Arguments = CommandLine.Remove(firstQuoteIndex, lastQuoteIndex - firstQuoteIndex + 1).Trim();
                if (ExePath.Contains("'"))
                {
                    _isCommandLineValid = false;
                }
                else
                {
                    _isCommandLineValid = true;
                }
            }
            else
            {
                var splitArgs = CommandLine.Split(new [] { " " }, StringSplitOptions.RemoveEmptyEntries);
                ExePath = splitArgs.First();
                if (splitArgs.Length > 1)
                {
                    Arguments = string.Join(" ", splitArgs.Skip(1)).Trim();
                }

                _isCommandLineValid = true;
            }
        }
コード例 #2
0
ファイル: GTAPATH.cs プロジェクト: Skylumz/Rage
 public bool HaveFolder()
 {
     if (ExePath != null)
     {
         if (ExePath.Contains(key))
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     else
     {
         return(false);
     }
 }
コード例 #3
0
        internal string GetLogStartupMessage()
        {
            string statusMessage = String.Format(
                "{0} is running {3} {1} ({5}) in ProcessId={2} on OS={4} under {6}"
                , Environment.MachineName
                , Version
                , Process.GetCurrentProcess().Id   // Make it easier to find which service is smashing a server CPU in task manager
                , Name
                , Environment.OSVersion
                , BuildConfigurationText
                , UserName
                );

            if (!ExePath.Contains("ASP.NET") && !string.IsNullOrEmpty(ExePath))
            {
                statusMessage += " from " + ExePath;
            }

            return(statusMessage);
        }
コード例 #4
0
        private void GetWindowStr(object sender, EventArgs e)
        {
            ExeTitle = CurrentWindow.GetTopWindowText();
            ExePath  = CurrentWindow.GetTopWindowName();
            if (GlobalCommon.UsingModel != null)
            {
                //如果名字匹配
                if (ExeTitle.Contains(GlobalCommon.UsingModel.ExeTitleName))
                {
                    //如果已设置程序路径,程序名字和路径双重匹配
                    if ((!string.IsNullOrWhiteSpace(GlobalCommon.UsingModel.ExePathName) && ExePath.Contains(GlobalCommon.UsingModel.ExePathName)) ||
                        string.IsNullOrWhiteSpace(GlobalCommon.UsingModel.ExePathName))
                    {
                        CurrentID      = GlobalCommon.CurrentExeID = GlobalCommon.UsingModel.ExeID; //当前ID
                        LeaveExeSecond = 0;                                                         //重置离开程序时间
                        if (WatchExeSecond == 0)
                        {
                            StageName = ProgramStageConfigServiceBLLService.Instance.GetCurrentState();
                            //插入时间到时间表中
                            CurrentWatchTimeModel.StartTime = System.DateTime.Now;
                            CurrentWatchTimeModel.ExeID     = Convert.ToInt32(GlobalCommon.CurrentExeID);

                            int resultID = WatchTimeBLLService.Instance.InsertWathExeTime(CurrentWatchTimeModel);
                            CurrentWatchTimeModel.TimeID = resultID;
                        }
                        WatchExeSecond += 1;
                    }
                }
                else//离开要监视的程序
                {
                    //更新时间
                    if (LeaveExeSecond == 0 && WatchExeSecond != 0)
                    {
                        CurrentWatchTimeModel.EndTime = System.DateTime.Now;
                        int resultID = WatchTimeBLLService.Instance.UpdateWathExeTime(CurrentWatchTimeModel);
                    }
                    LeaveExeSecond++;
                    CurrentID = GlobalCommon.CurrentExeID = null;
                    //监视类型
                    WatchType = WatchTypeBLLService.Instance.SelectData();
                    //当为间隔时间模式时,重置时间
                    if (WatchExeSecond != 0 && true == WatchType?.IntervalType)
                    {
                        WatchExeSecond = 0;
                    }
                }
            }
        }