コード例 #1
0
            public BuildConfigurationViewModel(string assetGuid)
            {
                AssetGuid = assetGuid;
                var assetPath = AssetDatabase.GUIDToAssetPath(assetGuid);

                Name = Path.GetFileNameWithoutExtension(assetPath);

                Asset = BuildConfiguration.LoadAsset(assetPath);
                Asset.OnEnable();

                Target = Asset.TryGetComponent(out ClassicBuildProfile classicBuildProfile) ? classicBuildProfile.Target : BuildTarget.NoTarget;
                OutputBuildDirectory = Asset.GetOutputBuildDirectory();

                var pipeline = Asset.GetBuildPipeline();

                if (pipeline != null)
                {
                    pipeline.OnEnable();
                    IsLiveLinkCompatible = EnumerateBuildSteps(pipeline).Any(s => s is BuildStepBuildClassicLiveLink);
                }
                else
                {
                    IsLiveLinkCompatible = false;
                }

                SelectedStartMode = IsActionAllowed(StartMode.RunLatestBuild, out _) ? StartMode.RunLatestBuild : StartMode.BuildAndRun;
            }
コード例 #2
0
        void OnStart(StartMode startMode, BuildConfigurationViewModel buildConfiguration)
        {
            switch (startMode)
            {
            case StartMode.Build:
            case StartMode.BuildAndRun:
                m_View.SetEnableBuildingState(true);

                EditorApplication.delayCall += () =>
                {
                    var buildResult = buildConfiguration.Asset.Build();
                    buildResult.LogResult();
                    m_View.OnBuildFinished(buildConfiguration, buildResult.Succeeded);

                    m_View.SetEnableBuildingState(false);

                    if (startMode == StartMode.Build && buildResult.Succeeded)
                    {
                        OnRevealBuildInFinder(buildConfiguration);
                    }
                    else if (startMode == StartMode.BuildAndRun)
                    {
                        RunAndCloseWindowIfSuccessful(buildConfiguration);
                    }
                };
                break;

            case StartMode.RunLatestBuild:
                RunAndCloseWindowIfSuccessful(buildConfiguration);
                break;
            }
        }
コード例 #3
0
            public bool IsActionAllowed(StartMode mode, out string reason)
            {
                reason = string.Empty;

                switch (mode)
                {
                case StartMode.RunLatestBuild:
                    if (!HasALatestBuild)
                    {
                        reason = "No previous build has been found for this configuration.";
                        return(false);
                    }
                    else if (!Asset.CanRun(out var canRunReason))
                    {
                        reason = $"Impossible to run latest build: {canRunReason}";
                        return(false);
                    }
                    return(true);

                case StartMode.BuildAndRun:
                case StartMode.Build:
                    if (Asset.CanBuild(out var canBuildReason))
                    {
                        return(true);
                    }

                    reason = $"Impossible to build this configuration: {canBuildReason}";
                    return(false);

                default:
                    throw new ArgumentOutOfRangeException(nameof(mode), mode, null);
                }
            }
コード例 #4
0
ファイル: Tween.cs プロジェクト: vthem/LectureFlash
        /// <summary>
        /// Disposes of the tween and resets all variables.
        /// </summary>
        public void Dispose()
        {
            if (m_TweenData != null)
            {
                if (m_State == State.Run && m_Cancel != CancelMode.Nothing)
                {
                    m_Reversed = false;

                    float curvedPercent = 0;
                    switch (m_Cancel)
                    {
                    case CancelMode.Revert:
                        curvedPercent = Evaluate(0);
                        break;

                    case CancelMode.RevertNoWave:
                        curvedPercent = EvaluateNoWave(0);
                        break;

                    case CancelMode.ForceEnd:
                        curvedPercent = Evaluate(m_Mode == LoopMode.Yoyo || m_Mode == LoopMode.YoyoLoop ? 0 : 1);
                        break;

                    case CancelMode.ForceEndNoWave:
                        curvedPercent = EvaluateNoWave(m_Mode == LoopMode.Yoyo || m_Mode == LoopMode.YoyoLoop ? 0 : 1);
                        break;
                    }
                    m_TweenData.ApplyTween(curvedPercent);
                    if (m_OnUpdate != null)
                    {
                        m_OnUpdate(m_FromMode ? 1 - curvedPercent : curvedPercent);
                    }
                }

                m_TweenData.OnTweenEnd();
                m_TweenData = null;
                TweenPool.Free(this);
            }

            m_Cancel     = CancelMode.Nothing;
            m_Mode       = LoopMode.Single;
            m_Curve      = Curve.Linear;
            m_AnimCurve  = null;
            m_WaveFunc   = default(Wave);
            m_NumLoops   = 0;
            m_OnStart    = null;
            m_OnUpdate   = null;
            m_OnComplete = null;

            m_Reversed    = false;
            m_MirrorCurve = false;
            m_FromMode    = false;
            m_Instant     = false;
            m_StartMode   = StartMode.Restart;
            m_StartTime   = 0;

            m_CurrentPercent   = 0;
            m_PercentIncrement = 0;
            m_State            = State.Begin;
        }
コード例 #5
0
        /// <summary>
        /// Modifies the start mode of a Windows service.
        /// </summary>
        /// <param name="serviceName">The service name.</param>
        /// <param name="startMode">The new start mode.</param>
        /// <param name="retValue">The return value.
        /// Return value Description:
        /// 0 Success
        /// 1 Not Supported
        /// 2 Access Denied
        /// 3 Dependent Services Running
        /// 4 Invalid Service Control
        /// 5 Service Cannot Accept Control
        /// 6 Service Not Active
        /// 7 ervice Request Timeout
        /// 8 Unknown Failure
        /// 9 Path Not Found
        /// 10 Service Already Running
        /// 11 Service Database Locked
        /// 12 Service Dependency Deleted
        /// 13 Service Dependency Failure
        /// 14 Service Disabled
        /// 15 Service Logon Failure
        /// 16 Service Marked For Deletion
        /// 17 Service No Thread
        /// 18 Status Circular Dependency
        /// 19 Status Duplicate Name
        /// 20 Status Invalid Name
        /// 21 Status Invalid Parameter
        /// 22 Status Invalid Service Account
        /// 23 Status Service Exists
        /// 24 Service Already Paused
        /// </param>
        /// <returns>True if succeded; othrwise, false.</returns>
        public static bool SetServiceStartMode(string serviceName, StartMode startMode, out uint retValue)
        {
            if (string.IsNullOrEmpty(serviceName))
            {
                throw new ArgumentNullException("serviceName");
            }

            try {
                ManagementPath myPath = new ManagementPath();
                myPath.Server        = System.Environment.MachineName;
                myPath.NamespacePath = @"root\CIMV2";
                myPath.RelativePath  = "Win32_Service.Name='" + serviceName + "'";

                using (ManagementObject service = new ManagementObject(myPath)) {
                    string   mode      = ConvertStartModeToString(startMode);
                    object[] inputArgs = new object[] { mode };

                    retValue = (uint)service.InvokeMethod("ChangeStartMode", inputArgs);
                    return(retValue == 0);
                }
            } catch (Exception e) {
                retValue = 8;
                Utils.Trace(e, "Unexpected error setting start mode for service {0}.", serviceName);
                return(false);
            }
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: topharley/scrns.ru
 private static void SetStartMode()
 {
     StartMode = Screens.StartMode.Capture;
     var args = Environment.GetCommandLineArgs();
     if (args.Length > 1 && args[1] == "/tray") 
         StartMode = Screens.StartMode.Tray;
 }
コード例 #7
0
        static void SetStartMode(ServiceInstaller installer, StartMode startMode)
        {
            switch (startMode)
            {
            case StartMode.Automatic:
                installer.StartType = ServiceStartMode.Automatic;
                break;

            case StartMode.Manual:
                installer.StartType = ServiceStartMode.Manual;
                break;

            case StartMode.Disabled:
                installer.StartType = ServiceStartMode.Disabled;
                break;

            case StartMode.Delay:
                installer.StartType        = ServiceStartMode.Automatic;
                installer.DelayedAutoStart = true;
                break;

            default:
                break;
            }
        }
コード例 #8
0
ファイル: Form1.cs プロジェクト: weiling103/OSU-Desktop
 private void openFileDialog1_FileOk(object sender, CancelEventArgs e)
 {
     MessageBox.Show("请先将游戏设置为无边框窗口全屏,然后在系统托盘设置壁纸即可~");
     cmode = StartMode.ModeB;
     p     = System.Diagnostics.Process.Start(openFileDialog1.FileName); // 在进程p上运行OSU!
     Hide();                                                             // 隐藏窗口
     notifyIcon1.Visible = true;                                         // 显示托盘图标
 }
コード例 #9
0
 public PoderosaAppContext(StartMode startMode)
 {
     if (startMode == StartMode.StandAlone)
     {
         Application.EnableVisualStyles();
         Application.SetCompatibleTextRenderingDefault(false);
         Application.VisualStyleState = System.Windows.Forms.VisualStyles.VisualStyleState.ClientAndNonClientAreasEnabled;
     }
 }
コード例 #10
0
 private static void SetServiceStartMode(ServiceModel service, StartMode startMode)
 {
     using (ManagementObject wmiService = GetWmiService(service))
     {
         ManagementBaseObject reqParams = wmiService.GetMethodParameters("ChangeStartMode");
         reqParams["StartMode"] = startMode.ToWmiString();
         wmiService.InvokeMethod("ChangeStartMode", reqParams, null);
     }
 }
コード例 #11
0
 public void setStartMode(bool ifStart)
 {
     if (ifStart)
     {
         Start = StartMode.StartAutomaticallty;
         return;
     }
     Start = StartMode.StartManually;
 }
コード例 #12
0
ファイル: FileManagerXR.cs プロジェクト: mhzse/PointcloudXR
    private void ClearSelectedFileName()
    {
        if (_PointCloudManager != null)
        {
            _PointCloudManager.ReadFilenameSet(string.Empty);
            _PointCloudManager.WriteFilenameSet(string.Empty);
        }

        _StartMode = StartMode.NONE;
    }
コード例 #13
0
        public static string GetStartModeString(StartMode startMode)
        {
            switch (startMode)
            {
            case StartMode.Auto:
                return("Automatic");
            }

            return(startMode.ToString());
        }
コード例 #14
0
        private static void SetStartMode()
        {
            StartMode = Screens.StartMode.Capture;
            var args = Environment.GetCommandLineArgs();

            if (args.Length > 1 && args[1] == "/tray")
            {
                StartMode = Screens.StartMode.Tray;
            }
        }
コード例 #15
0
 /// <summary>
 /// Installs and optionally starts the service.
 /// </summary>
 /// <param name="path">The full path of the service exe.</param>
 /// <param name="name">The name of the service.</param>
 /// <param name="displayName">The display name of the service.</param>
 /// <param name="description">The description for the service.</param>
 /// <param name="startMode">The service start mode.</param>
 /// <param name="start">True to start the service after the installation; otherwise, false.
 /// Once the method returns you can use this parameter to check whether the service is running or not.</param>
 /// <returns>True for success. Otherwise, false.</returns>
 public static bool InstallService(
     string path,
     string name,
     string displayName,
     string description,
     StartMode startMode,
     ref bool start)
 {
     return(InstallService(path, name, displayName, description, startMode, null, null, ref start, null));
 }
コード例 #16
0
ファイル: MainWindow.xaml.cs プロジェクト: By-Onex/riel_wpf
        public MainWindow()
        {
            var sm = new StartMode();

            StartMode.Instanse = sm;
            DataContext        = sm;
            InitializeComponent();
            sm.TextState   = "Добро пожаловать!\nС чем работать?";
            sm.PageContent = new StartChangePage().Content;
        }
コード例 #17
0
ファイル: Machine.cs プロジェクト: palzj/VBOX.NET
        public void Start(StartMode mode, Dictionary <String, String> env)
        {
            String uuid        = service.IMachine_getId(auth);
            String sessionType = mode.InternalValue();
            String environment = BuildEnvironment(env);

            String progress = service.IMachine_launchVMProcess(auth, Session, sessionType, environment);

            service.IProgress_waitForCompletion(progress, -1);
        }
コード例 #18
0
 private void Start(StartMode startMode)
 {
     for (int i = 0; i < Framework.PlugIns.Count; i++)
     {
         PlugIns.IPlugIn plugIn = Framework.PlugIns[i];
         if (plugIn.StartMode == startMode)//&& plugIn.State!= PlugInState.Active)
         {
             plugIn.Start();
         }
     }
 }
コード例 #19
0
ファイル: Tree.cs プロジェクト: jlundstocholm/ravendb
		public Tree(Stream reader, Stream writer, StartMode mode)
		{
			this.reader = reader;
			this.writer = writer;
			binaryReader = new BinaryReaderWith7BitEncoding(this.reader);
			binaryWriter = new BinaryWriterWith7BitEncoding(this.writer);

			root = mode == StartMode.Create
				? new TreeNode(null, null, null, null, ReadNode, WriteNodeLazy)
				: ReadNode(new StreamPosition(reader.Position, null));
		}
コード例 #20
0
ファイル: Tree.cs プロジェクト: jlundstocholm/ravendb
        public Tree(Stream reader, Stream writer, StartMode mode)
        {
            this.reader  = reader;
            this.writer  = writer;
            binaryReader = new BinaryReaderWith7BitEncoding(this.reader);
            binaryWriter = new BinaryWriterWith7BitEncoding(this.writer);

            root = mode == StartMode.Create
                                ? new TreeNode(null, null, null, null, ReadNode, WriteNodeLazy)
                                : ReadNode(new StreamPosition(reader.Position, null));
        }
コード例 #21
0
        public static async Task <bool> TipToStartGame(this DEModManager self, StartMode startMode)
        {
            if (startMode != StartMode.StartOnly)
            {
                if (!self.IsValidModPackSelected())
                {
                    MessageBox.Show("请先选择一个模组配置", "警告", MessageBoxButton.OK, MessageBoxImage.Warning);
                    return(false);
                }
                // 弹出提示窗口,避免误操作
                var result = MessageBox.Show($"加载模组将需要一定时间,在此期间请勿关闭本程序。是否继续?",
                                             $"加载模组:{self.CurrentModPack.PackName}",
                                             MessageBoxButton.YesNo,
                                             MessageBoxImage.Question);
                if (result != MessageBoxResult.Yes)
                {
                    return(false);
                }
            }

            self.IsLaunching = true;
            try {
                switch (startMode)
                {
                case StartMode.LoadOnly:
                    await Task.Run(() => { self.LoadMod(); });

                    break;

                case StartMode.LoadAndStart:
                    await Task.Run(() => { self.LaunchMod(); });

                    break;

                case StartMode.StartOnly:
                    await Task.Run(() => { self.LaunchGame(); });

                    break;

                default:
                    break;
                }
                return(true);
            }
            catch (Exception exp) {
                View.InformationWindow.Show(exp.Message, "启动错误", Application.Current.MainWindow);
                return(false);
            }
            finally {
                self.IsLaunching = false;
            }
        }
コード例 #22
0
ファイル: Form1.cs プロジェクト: weiling103/OSU-Desktop
 private void CheckTimer_Tick(object sender, EventArgs e)
 {
     if (GetPIDByPName("MuseDash.exe").Count > 0)
     {
         checkTimer.Enabled = false;
         MessageBox.Show("请先将游戏设置为无边框窗口全屏,然后在系统托盘设置壁纸即可~");
         cmode     = StartMode.ModeA;
         ModeA_PID = GetPIDByPName(ModeA_Name)[0];
         p         = Process.GetProcessById(ModeA_PID);
         Hide();                     // 隐藏窗口
         notifyIcon1.Visible = true; // 显示托盘图标
     }
 }
コード例 #23
0
        private RadioButton addStartMode(string text, StartMode sm, FlowLayoutPanel flp, bool isChecked, string introductionText)
        {
            var rb = new RadioButton()
            {
                Text    = text,
                Tag     = sm,
                Checked = isChecked
            }.addTo(flp);

            new ToolTip().SetToolTip(rb, introductionText);

            return(rb);
        }
コード例 #24
0
        public static string GetUrl(StartMode mode)
        {
            switch (mode)
            {
            case StartMode.VirtualControllers:
                return(Settings.AIRCONSOLE_NORMAL_URL);

            case StartMode.Normal:
                return(Settings.AIRCONSOLE_URL);

            default:
                return("");
            }
        }
コード例 #25
0
        public Bag(Stream reader, Stream writer, StartMode mode)
        {
            this.reader = reader;
            this.writer = writer;

            binaryReader = new BinaryReaderWith7BitEncoding(reader);
            binaryWriter = new BinaryWriterWith7BitEncoding(writer);

            if (mode != StartMode.Open)
            {
                return;
            }
            current = ReadItem(reader.Position);
        }
コード例 #26
0
        public static ProcessWindowStyle AsWindowsStyle(this StartMode mode)
        {
            switch (mode)
            {
            case StartMode.Default: return(ProcessWindowStyle.Normal);

            case StartMode.Maximised: return(ProcessWindowStyle.Maximized);

            case StartMode.Minimised: return(ProcessWindowStyle.Minimized);

            default:
                throw new NotSupportedException($"The 'StartMode' of '{mode}' is not supported. Did you forget to support it?");
            }
        }
コード例 #27
0
 public void Start(StartMode startMode)
 {
     for (int i = 0; i < PlugIns.Count; i++)
     {
         PlugIns.IPlugIn plugIn = PlugIns[i];
         if (plugIn.EnableState == PlugInEnableState.Enable)
         {
             if (plugIn.StartMode == startMode)//&& plugIn.State!= PlugInState.Active)
             {
                 plugIn.Start();
             }
         }
     }
 }
コード例 #28
0
            public BuildConfigurationViewModel(string assetGuid)
            {
                AssetGuid = assetGuid;
                var assetPath = AssetDatabase.GUIDToAssetPath(assetGuid);

                Name = Path.GetFileNameWithoutExtension(assetPath);

                Asset  = BuildConfiguration.LoadAsset(assetPath);
                Target = Asset.TryGetComponent(out ClassicBuildProfile classicBuildProfile) ? classicBuildProfile.Target : BuildTarget.NoTarget;
                OutputBuildDirectory = Asset.GetOutputBuildDirectory();

                IsLiveLinkCompatible = DetermineLivelinkCompatibility();

                SelectedStartMode = IsActionAllowed(StartMode.RunLatestBuild, out _) ? StartMode.RunLatestBuild : StartMode.BuildAndRun;
            }
コード例 #29
0
ファイル: MMExcel.cs プロジェクト: mmeents/MMExcel
        public MMExcel(StartMode aSM, string aFilePathName)
        {
            FilePathName = aFilePathName;
            Sheet        = new List <MMWS>();
            switch (aSM)
            {
            case StartMode.smNew:
                New();
                break;

            case StartMode.smOpen:
                Open(FilePathName);
                break;
            }
        }
コード例 #30
0
ファイル: Queue.cs プロジェクト: jlundstocholm/ravendb
        public Queue(Stream reader, Stream writer, StartMode mode)
        {
            this.reader = reader;
            this.writer = writer;

            binaryReader = new BinaryReaderWith7BitEncoding(reader);
            binaryWriter = new BinaryWriterWith7BitEncoding(writer);

            if (mode == StartMode.Open)
            {
                currentId = binaryReader.Read7BitEncodedInt64();
                var treePos = binaryReader.Read7BitEncodedInt64();
                reader.Position = treePos;
            }
            tree = new Tree(reader, writer, mode);
        }
コード例 #31
0
ファイル: Queue.cs プロジェクト: jlundstocholm/ravendb
		public Queue(Stream reader, Stream writer, StartMode mode)
		{
			this.reader = reader;
			this.writer = writer;

			binaryReader = new BinaryReaderWith7BitEncoding(reader);
			binaryWriter = new BinaryWriterWith7BitEncoding(writer);

			if(mode == StartMode.Open)
			{
				currentId = binaryReader.Read7BitEncodedInt64();
				var treePos = binaryReader.Read7BitEncodedInt64();
				reader.Position = treePos;
			}
			tree = new Tree(reader, writer, mode);
		}
コード例 #32
0
        private static string ConvertStartModeToString(StartMode startMode)
        {
            switch (startMode)
            {
            case StartMode.Auto: return("Automatic");

            case StartMode.Boot: return("Boot");

            case StartMode.System: return("System");

            case StartMode.Manual: return("Manual");

            case StartMode.Disabled: return("Disabled");
            }

            return(String.Empty);
        }
コード例 #33
0
        internal static string ToWmiString(this StartMode startMode)
        {
            switch (startMode)
            {
            case StartMode.Automatic:
                return("Auto");

            case StartMode.Manual:
                return("Manual");

            case StartMode.Disabled:
                return("Disabled");

            default:
                throw new ArgumentOutOfRangeException(nameof(startMode), startMode, null);
            }
        }
コード例 #34
0
        static void SetStartMode(ServiceInstaller installer, StartMode startMode)
        {
            switch (startMode)
            {
                case StartMode.Automatic:
                    installer.StartType = ServiceStartMode.Automatic;
                    break;

                case StartMode.Manual:
                    installer.StartType = ServiceStartMode.Manual;
                    break;

                case StartMode.Disabled:
                    installer.StartType = ServiceStartMode.Disabled;
                    break;

                case StartMode.Delay:
                    installer.StartType = ServiceStartMode.Automatic;
                    installer.DelayedAutoStart = true;
                    break;
            }
        }
コード例 #35
0
ファイル: PlunInRuntime.cs プロジェクト: sunpander/VSDT
 private void Start(StartMode startMode)
 {
     for (int i = 0; i < Framework.PlugIns.Count; i++)
     {
         PlugIns.IPlugIn plugIn = Framework.PlugIns[i];
         if (plugIn.StartMode ==startMode )//&& plugIn.State!= PlugInState.Active)
         {
             plugIn.Start();
         }
     }
 }
コード例 #36
0
        public static ReturnValue InstallService(string svcName, string svcDispName, string svcPath, ServiceType svcType,
            OnError errHandle, StartMode svcStartMode, bool interactWithDesktop, string svcStartName, string svcPassword,
            string loadOrderGroup, string[] loadOrderGroupDependencies, string[] svcDependencies)
        {
            var mc = new ManagementClass("Win32_Service");
            ManagementBaseObject inParams = mc.GetMethodParameters("create");
            inParams["Name"] = svcName;
            inParams["DisplayName"] = svcDispName;
            inParams["PathName"] = svcPath;
            inParams["ServiceType"] = svcType;
            inParams["ErrorControl"] = errHandle;
            inParams["StartMode"] = svcStartMode.ToString();
            inParams["DesktopInteract"] = interactWithDesktop;
            inParams["StartName"] = svcStartName;
            inParams["StartPassword"] = svcPassword;
            inParams["LoadOrderGroup"] = loadOrderGroup;
            inParams["LoadOrderGroupDependencies"] = loadOrderGroupDependencies;
            inParams["ServiceDependencies"] = svcDependencies;

            try
            {
                ManagementBaseObject outParams = mc.InvokeMethod("create", inParams, null);

                return (ReturnValue) Enum.Parse(typeof (ReturnValue), outParams["ReturnValue"].ToString());
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #37
0
ファイル: Framework.cs プロジェクト: sunpander/VSDT
 public void Start(StartMode startMode)
 {
     for (int i = 0; i <  PlugIns.Count; i++)
     {
         PlugIns.IPlugIn plugIn =  PlugIns[i];
         if (plugIn.EnableState == PlugInEnableState.Enable)
         {
             if (plugIn.StartMode == startMode)//&& plugIn.State!= PlugInState.Active)
             {
                 plugIn.Start();
             }
         }
     }
 }
コード例 #38
0
 public void Start()
 {
     sMode = StartMode.started;
 }
コード例 #39
0
        public static ReturnValue ChangeStartMode(string svcName, StartMode startMode)
        {
            string objPath = string.Format("Win32_Service.Name='{0}'", svcName);
            using (var service = new ManagementObject(new ManagementPath(objPath)))
            {
                ManagementBaseObject inParams = service.GetMethodParameters("ChangeStartMode");
                inParams["StartMode"] = startMode.ToString();
                try
                {
                    ManagementBaseObject outParams = service.InvokeMethod("ChangeStartMode", inParams, null);

                    return (ReturnValue) Enum.Parse(typeof (ReturnValue), outParams["ReturnValue"].ToString());
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
コード例 #40
0
        public HostArguments(string[] args)
        {
            var executionMode = ExecutionMode.Run;
            commands = new List<Type> { typeof(RunCommand) };
            startMode = StartMode.Automatic;
            ServiceName = "Particular.ServiceControl";
            DisplayName = "Particular ServiceControl";
            Description = "Particular Software ServiceControl for NServiceBus.";
            ServiceAccount = ServiceAccount.LocalSystem;
            Username = String.Empty;
            Password = String.Empty;

            defaultOptions = new OptionSet
            {
                {
                    "?|h|help", "Help about the command line options.", key => { Help = true; }
                },
                {
                    "d|set={==}", "The configuration {0:option} to set to the specified {1:value}", (key, value) =>
                    {
                        options[key] = value;

                        commands = new List<Type>
                        {
                            typeof(WriteOptionsCommand),
                        };
                    }
                },
                {
                    "restart",
                    @"Restarts the endpoint."
                    , s =>
                    {
                        commands = new List<Type>
                        {
                            typeof(WriteOptionsCommand),
                            typeof(RestartCommand),
                        };
                    }
                },
                {
                    "start",
                    @"Starts the endpoint."
                    , s =>
                    {
                        commands = new List<Type>
                        {
                            typeof(WriteOptionsCommand),
                            typeof(StartCommand),
                        };
                    }
                },
                {
                    "stop",
                    @"Stops the endpoint."
                    , s =>
                    {
                        commands = new List<Type>
                        {
                            typeof(StopCommand),
                        };
                    }
                },
                {
                    "serviceName=",
                    @"Specify the service name for the installed service."
                    , s => { ServiceName = s; }
                },
            };

            var maintenanceOptions = new OptionSet
                                           {
                                               {
                                                   "m|maint|maintenance",
                                                   @"Run RavenDB only - use for DB maintenance",
                                                   s => {
                                                            commands = new List<Type>
                                                                       {
                                                                           typeof(MaintCommand)
                                                                       };
                                                            executionMode = ExecutionMode.Maintenance;
                                                   }
                                               }
                                           };

            uninstallOptions = new OptionSet
            {
                {
                    "?|h|help", "Help about the command line options.", key => { Help = true; }
                },
                {
                    "u|uninstall",
                    @"Uninstall the endpoint as a Windows service."
                    , s =>
                    {
                        commands = new List<Type> {typeof(UninstallCommand)};
                        executionMode = ExecutionMode.Uninstall;
                    }
                },
                {
                    "serviceName=",
                    @"Specify the service name for the installed service."
                    , s => { ServiceName = s; }
                }
            };

            installOptions = new OptionSet
            {
                {
                    "?|h|help",
                    "Help about the command line options.",
                    key => { Help = true; }
                },
                {
                    "i|install",
                    @"Install the endpoint as a Windows service."
                    , s =>
                    {
                        commands = new List<Type>
                        {
                            typeof(WriteOptionsCommand),
                            typeof(CheckMandatoryInstallOptionsCommand),
                            typeof(RunBootstrapperAndNServiceBusInstallers),
                            typeof(InstallCommand)
                        };
                        executionMode = ExecutionMode.Install;
                    }
                },
                {
                    "serviceName=",
                    @"Specify the service name for the installed service."
                    , s => { ServiceName = s; }
                },
                {
                    "displayName=",
                    @"Friendly name for the installed service."
                    , s => { DisplayName = s; }
                },
                {
                    "description=",
                    @"Description for the service."
                    , s => { Description = s; }
                },
                {
                    "username="******"Username for the account the service should run under."
                    , s => { Username = s; }
                },
                {
                    "password="******"Password for the service account."
                    , s => { Password = s; }
                },
                {
                    "localservice",
                    @"Run the service with the local service account."
                    , s => { ServiceAccount = ServiceAccount.LocalService; }
                },
                {
                    "networkservice",
                    @"Run the service with the network service permission."
                    , s => { ServiceAccount = ServiceAccount.NetworkService; }
                },
                {
                    "user",
                    @"Run the service with the specified username and password. Alternative the system will prompt for a valid username and password if values for both the username and password are not specified."
                    , s => { ServiceAccount = ServiceAccount.User; }
                },
                {
                    "delayed",
                    @"The service should start automatically (delayed)."
                    , s => { startMode = StartMode.Delay; }
                },
                {
                    "autostart",
                    @"The service should start automatically (default)."
                    , s => { startMode = StartMode.Automatic; }
                },
                {
                    "disabled",
                    @"The service should be set to disabled."
                    , s => { startMode = StartMode.Disabled; }
                },
                {
                    "manual",
                    @"The service should be started manually."
                    , s => { startMode = StartMode.Manual; }
                },
                {
                    "d|set={==}", "The configuration {0:option} to set to the specified {1:value}", (key, value) =>
                    {
                        options[key] = value;
                    }
                },
            };

            try
            {
                installOptions.Parse(args);
                if (executionMode == ExecutionMode.Install)
                {
                    return;
                }

                uninstallOptions.Parse(args);
                if (executionMode == ExecutionMode.Uninstall)
                {
                    return;
                }
                maintenanceOptions.Parse(args);
                if (executionMode == ExecutionMode.Maintenance)
                {
                    Settings.MaintenanceMode = true;
                    return;
                }

                defaultOptions.Parse(args);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Help = true;
            }
        }
コード例 #41
0
 public void Pause()
 {
     sMode = StartMode.paused;
 }
コード例 #42
0
        public static ReturnValue CreateOrUpdate(string machineName, string impersonationUsername, string impersonationPassword, string serviceName, string displayName, string serviceLocation, StartMode startMode, string username, string password)
        {
            List<WmiService> servicesToChange = WmiService.GetAllServices(machineName, impersonationUsername, impersonationPassword, "Name = '" + serviceName + "'");

            if (servicesToChange.Count > 0)
            {
                ReturnValue result;

                WmiService serviceToChange = servicesToChange[0];

                bool requiresRestart = false;
                if (serviceToChange.State != State.Stopped)
                {
                    requiresRestart = true;
                    result = WmiService.Stop(machineName, impersonationUsername, impersonationPassword, serviceName);

                    if (result != ReturnValue.Success)
                        throw new Exception("Failed to stop " + displayName + " on: " + machineName + ", return code: " + result.ToString());
                }

                object[] parameters = new object[]
                    {
                        displayName, // DisplayName
                        serviceLocation, // Location
                        Convert.ToInt32(ServiceType.OwnProcess), // ServiceType
                        Convert.ToInt32(ErrorControl.Normal), // Error Control
                        GetStartModeString(startMode), // Start Mode
                        false, // Desktop Interaction
                        username, // Username
                        password, // Password
                        null, // Service Order Group
                        null, // Load Order Dependencies
                        null // Service dependencies
                    };

                result = (ReturnValue) Convert.ToInt32(serviceToChange.WmiServiceObject.InvokeMethod("Change", parameters));

                if (result != ReturnValue.Success)
                    throw new Exception("Failed to update " + displayName + " on: " + machineName + ", return code: " + result.ToString());

                Thread.Sleep(3000);

                if (requiresRestart == true)
                {
                    result = WmiService.Start(machineName, impersonationUsername, impersonationPassword, serviceName);

                    if (result != ReturnValue.Success)
                        throw new Exception("Failed to restart " + displayName + " on: " + machineName + ", return code: " + result.ToString());
                }

                return result;
            }
            else
            {
                return Create(machineName, impersonationUsername, impersonationPassword, serviceName, displayName, serviceLocation, startMode, username, password);
            }
        }
コード例 #43
0
 public static ReturnValue Create(string machineName, string impersonationUsername, string impersonationPassword, string serviceName, string displayName, string serviceLocation, StartMode startMode, string username, string password)
 {
     try
     {
         string methodName = "Create";
         object[] parameters = new object[]
             {
                 serviceName, // Name
                 displayName, // Description
                 serviceLocation, // Location
                 Convert.ToInt32(ServiceType.OwnProcess), // ServiceType
                 Convert.ToInt32(ErrorControl.Normal), // Error Control
                 GetStartModeString(startMode), // Start Mode
                 false, // Desktop Interaction
                 username, // Username
                 password, // Password
                 null, // Service Order Group
                 null // Load Order Dependencies
             };
         return (ReturnValue)WmiHelper.InvokeStaticMethod(machineName, impersonationUsername, impersonationPassword, CLASSNAME, methodName, parameters);
     }
     catch
     {
         return ReturnValue.UnknownFailure;
     }
 }
コード例 #44
0
 public static ReturnValue Create(string machineName, string serviceName, string displayName, string serviceLocation, StartMode startMode, string username, string password)
 {
     return Create(machineName, null, null, serviceName, displayName, serviceLocation, startMode, username, password);
 }
コード例 #45
0
		public static string GetUrl (StartMode mode) {

			switch (mode) {
			case StartMode.VirtualControllers:
				return Settings.AIRCONSOLE_NORMAL_URL;
			case StartMode.Normal:
				return Settings.AIRCONSOLE_URL;
			default:
				return "";
			}
		}
コード例 #46
0
        public HostArguments(string[] args)
        {
            var executionMode = ExecutionMode.Run;

            commands = new List<Type> { typeof(UpdateConfigCommand), typeof(UpdateVersionCommand), typeof(RunCommand) };
            startMode = StartMode.Automatic;
            url = "http://*****:*****@"Configures the service control url."
                    , s => { serviceControlUrl = s; }
                },
                {
                    "url=",
                    @"Configures ServicePulse to listen on the specified url."
                    , s => { url = s; }
                }
            };

            extractOptions = new OptionSet
            {
                {
                    "?|h|help", "Help about the command line options.", key => { Help = true; }
                },
                {
                    "e|extract",
                    @"Extract files to be installed in a Web Server."
                    , s =>
                    {
                        commands = new List<Type> { typeof(UpdateConfigCommand), typeof(UpdateVersionCommand), typeof(ExtractCommand) };
                        executionMode = ExecutionMode.Extract;
                    }
                },
                {
                    "serviceControlUrl=",
                    @"Configures the service control url."
                    , s => { serviceControlUrl = s; }
                },
                {
                    "outPath=",
                    @"The output path to extract files to. By default it extracts to the current directory."
                    , s => { OutputPath = s; }
                }
            };

            uninstallOptions = new OptionSet
            {
                {
                    "?|h|help", "Help about the command line options.", key => { Help = true; }
                },
                {
                    "u|uninstall",
                    @"Uninstall the endpoint as a Windows service."
                    , s =>
                    {
                        commands = new List<Type> {typeof(UninstallCommand)};
                        executionMode = ExecutionMode.Uninstall;
                    }
                },
                {
                    "serviceName=",
                    @"Specify the service name for the installed service."
                    , s => { ServiceName = s; }
                }
            };

            installOptions = new OptionSet
            {
                {
                    "?|h|help",
                    "Help about the command line options.",
                    key => { Help = true; }
                },
                {
                    "i|install",
                    @"Install the endpoint as a Windows service."
                    , s =>
                    {
                        commands = new List<Type> { typeof(UpdateConfigCommand), typeof(UpdateVersionCommand), typeof(InstallCommand) };
                        executionMode = ExecutionMode.Install;
                    }
                },
                {
                    "serviceName=",
                    @"Specify the service name for the installed service."
                    , s => { ServiceName = s; }
                },
                {
                    "displayName=",
                    @"Friendly name for the installed service."
                    , s => { DisplayName = s; }
                },
                {
                    "description=",
                    @"Description for the service."
                    , s => { Description = s; }
                },
                {
                    "username="******"Username for the account the service should run under."
                    , s => { Username = s; }
                },
                {
                    "password="******"Password for the service account."
                    , s => { Password = s; }
                },
                {
                    "localservice",
                    @"Run the service with the local service account."
                    , s => { ServiceAccount = ServiceAccount.LocalService; }
                },
                {
                    "networkservice",
                    @"Run the service with the network service permission."
                    , s => { ServiceAccount = ServiceAccount.NetworkService; }
                },
                {
                    "user",
                    @"Run the service with the specified username and password. Alternative the system will prompt for a valid username and password if values for both the username and password are not specified."
                    , s => { ServiceAccount = ServiceAccount.User; }
                },
                {
                    "delayed",
                    @"The service should start automatically (delayed)."
                    , s => { startMode = StartMode.Delay; }
                },
                {
                    "autostart",
                    @"The service should start automatically (default)."
                    , s => { startMode = StartMode.Automatic; }
                },
                {
                    "disabled",
                    @"The service should be set to disabled."
                    , s => { startMode = StartMode.Disabled; }
                },
                {
                    "manual",
                    @"The service should be started manually."
                    , s => { startMode = StartMode.Manual; }
                },
                {
                    "serviceControlUrl=",
                    @"Configures the service control url."
                    , s => { serviceControlUrl = s; }
                },
                {
                    "url=",
                    @"Configures ServicePulse to listen on the specified url."
                    , s => { url = s; }
                }
            };

            try
            {
                installOptions.Parse(args);
                if (executionMode == ExecutionMode.Install)
                {
                    return;
                }

                uninstallOptions.Parse(args);
                if (executionMode == ExecutionMode.Uninstall)
                {
                    return;
                }

                extractOptions.Parse(args);
                if (executionMode == ExecutionMode.Extract)
                {
                    return;
                }

                runOptions.Parse(args);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Help = true;
            }
        }
コード例 #47
0
    /// <summary>
    /// Modifies the start mode of a Windows service. 
    /// </summary>
    /// <param name="serviceName">The service name.</param>
    /// <param name="startMode">The new start mode.</param>
    /// <param name="retValue">The return value.
    /// Return value Description:
    /// 0 Success
    /// 1 Not Supported
    /// 2 Access Denied
    /// 3 Dependent Services Running
    /// 4 Invalid Service Control
    /// 5 Service Cannot Accept Control
    /// 6 Service Not Active
    /// 7 ervice Request Timeout
    /// 8 Unknown Failure
    /// 9 Path Not Found
    /// 10 Service Already Running
    /// 11 Service Database Locked
    /// 12 Service Dependency Deleted
    /// 13 Service Dependency Failure
    /// 14 Service Disabled
    /// 15 Service Logon Failure
    /// 16 Service Marked For Deletion
    /// 17 Service No Thread
    /// 18 Status Circular Dependency
    /// 19 Status Duplicate Name
    /// 20 Status Invalid Name
    /// 21 Status Invalid Parameter
    /// 22 Status Invalid Service Account
    /// 23 Status Service Exists
    /// 24 Service Already Paused
    /// </param>
    /// <returns>True if succeded; othrwise, false.</returns>
    public static bool SetServiceStartMode(string serviceName, StartMode startMode, out uint retValue)
    {
        if (string.IsNullOrEmpty(serviceName)) throw new ArgumentNullException("serviceName");
        
        try
        {
            ManagementPath myPath = new ManagementPath();
            myPath.Server = System.Environment.MachineName;
            myPath.NamespacePath = @"root\CIMV2";
            myPath.RelativePath = "Win32_Service.Name='" + serviceName + "'";
 
            using (ManagementObject service = new ManagementObject(myPath))
            {
                string mode = ConvertStartModeToString(startMode);
                object[] inputArgs = new object[] { mode };
               
                retValue = (uint)service.InvokeMethod("ChangeStartMode", inputArgs);
                return retValue == 0;
            }
        }
        catch (Exception e)
        {
            retValue = 8;
            Utils.Trace(e, "Unexpected error setting start mode for service {0}.", serviceName);
            return false;
        }
    }
コード例 #48
0
        /// <summary>
        /// Installs a windows service. Ensures user has Logon as a service right by calling <see cref="Security.SetLogonAsAService"/>
        /// </summary>
        /// <param name="svcName">Name of the service.</param>
        /// <param name="svcDispName">Display name of the service</param>
        /// <param name="svcPath">The service file path.</param>
        /// <param name="description">The service description.</param>
        /// <param name="username">The username to run the service.</param>
        /// <param name="password">The password of the user running the service.</param>
        /// <param name="svcType">Type of the service.</param>
        /// <param name="errHandle">The error handle type.</param>
        /// <param name="svcStartMode">The service start mode.</param>
        /// <param name="interactWithDesktop">if set to true service can interact with desktop.</param>
        /// <param name="loadOrderGroup">The load order group.</param>
        /// <param name="loadOrderGroupDependencies">The load order group dependencies.</param>
        /// <param name="svcDependencies">Any service dependencies.</param>
        /// <returns><see cref="WMI.ReturnValue"/></returns>
        public ReturnValue InstallService(string svcName,
                                            string svcDispName,
                                            string svcPath,
                                            string description,
                                            string username = null,
                                            string password = null,
                                            ServiceType svcType = ServiceType.OwnProcess,
                                            OnError errHandle = OnError.UserIsNotified,
                                            StartMode svcStartMode = StartMode.Auto,
                                            bool interactWithDesktop = false,
                                            string loadOrderGroup = null,
                                            string[] loadOrderGroupDependencies = null,
                                            string[] svcDependencies = null)
        {
            var service = new ServiceInfo
                {
                    Name = svcName,
                    DisplayName = svcDispName,
                    Description = description,
                    PathName = svcPath,
                    ServiceType = svcType,
                    ErrorHandle = errHandle,
                    StartMode = svcStartMode,
                    InteractWithDesktop = interactWithDesktop,
                    LoadOrderGroup = loadOrderGroup,
                    LoadOrderGroupDependencies = loadOrderGroupDependencies,
                    Dependencies = svcDependencies,
                    Username = ComputerManager.EnsureDomain(username),
                    Password = password
                };
            return InstallService(service);

        }
コード例 #49
0
ファイル: TreeOfQueues.cs プロジェクト: jlundstocholm/ravendb
		public TreeOfQueues(Stream reader, Stream writer, StartMode mode)
		{
			this.reader = reader;
			this.writer = writer;
			queues = new Tree(reader, writer, mode);
		}
コード例 #50
0
ファイル: ServiceInstaller.cs プロジェクト: yuriik83/UA-.NET
        /// <summary>
        /// Installs and optionally starts the service.
        /// </summary>
        /// <param name="path">The full path of the service exe.</param>
        /// <param name="name">The name of the service.</param>
        /// <param name="displayName">The display name of the service.</param>
        /// <param name="description">The description for the service.</param>
        /// <param name="startMode">The service start mode.</param>
        /// <param name="userName">The account name. Null to use the default account (LocalSystem).</param>
        /// <param name="password">The account password.</param>
        /// <param name="start">True to start the service after the installation; otherwise, false. 
        /// Once the method returns you can use this parameter to check whether the service is running or not.</param>
        /// <param name="dependencies">The list of dependencies services. Null if there are no dependencies.</param>
        /// <returns>True for success. Otherwise, false.</returns> 
        public static bool InstallService(
            string    path, 
            string    name, 
            string    displayName, 
            string    description,
            StartMode startMode, 
            string    userName,
            string    password, 
            ref bool  start, 
            string[]  dependencies)
        {
            uint SC_MANAGER_CREATE_SERVICE = 0x0002;

            if (string.IsNullOrEmpty(userName))
            {
                userName = null;
                password = null;
            }

            // check if an existing service needs to uninstalled.
            try
            {
                Service existingService = ServiceManager.GetService(name);

                if (existingService != null)
                {
                    if (existingService.StartMode != StartMode.Disabled && existingService.Path == path)
                    {
                        if (existingService.Status == ServiceStatus.Stopped)
                        {
                            ServiceManager.StartService(name);
                        }

                        return true;
                    }

                    UnInstallService(name);
                }
            }
            catch (Exception e)
            {
                Utils.Trace(e, "CreateService Exception");
            }

            IntPtr svHandle = IntPtr.Zero;
            
            try
            {
                IntPtr scHandle = OpenSCManagerW(null, null, SC_MANAGER_CREATE_SERVICE);

                if (scHandle.ToInt64() != 0)
                {
                    string dependencyServices = string.Empty;
                
                    if(dependencies!=null && dependencies.Length > 0)
                    {
                        for (int i = 0; i < dependencies.Length; i++)
                        {
                            if (!string.IsNullOrEmpty(dependencies[i]))
                            {
                                dependencyServices += dependencies[i].Trim();
                                if (i < dependencies.Length - 1)
                                    dependencyServices += "\0";//add a null char separator
                            }
                        }
                    }
                    
                    if (dependencyServices == string.Empty)
                        dependencyServices = null;

                    // lpDependencies, if not null, must be a series of strings concatenated with the null character as a delimiter, including a trailing one. 

                    svHandle = CreateServiceW(
                        scHandle, 
                        name, 
                        displayName, 
                        (uint)ServiceAccess.AllAccess, 
                        (uint)ServiceType.OwnProcess, 
                        (uint)startMode, 
                        (uint)ServiceError.ErrorNormal, 
                        path, 
                        null, 
                        0, 
                        dependencyServices, 
                        userName,
                        password);
                    
                    if (svHandle.ToInt64() == 0)
                    {          
                        int error = GetLastError();
                        Utils.Trace("CreateService Error: {0}", error);
                        return false;
                    }
                     
                    // set the description.
                    if (!String.IsNullOrEmpty(description))
                    {
                        SERVICE_DESCRIPTION info = new SERVICE_DESCRIPTION();
                        info.lpDescription = description;

                        IntPtr pInfo = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(SERVICE_DESCRIPTION)));
                        Marshal.StructureToPtr(info, pInfo, false);

                        try
                        {
                            int result = ChangeServiceConfig2W(svHandle, SERVICE_CONFIG_DESCRIPTION, pInfo);

                            if (result == 0)
                            {
                                Utils.Trace("Could not set description for service: {0}", displayName);
                            }
                        }
                        finally
                        {
                            Marshal.DestroyStructure(pInfo, typeof(SERVICE_DESCRIPTION));
                            Marshal.FreeCoTaskMem(pInfo);
                        }
                    }

                    // start the service.
                    if (start)
                    {
                        start = ServiceManager.StartService(name, new TimeSpan(0, 0, 0, 60));
                    }

                    return true;
                }
            }
            catch (Exception e)
            {
                Utils.Trace(e, "CreateService Exception");
            }
            finally 
            { 
                SafeCloseServiceHandle(svHandle); 
            }
            
            return false;
        }
コード例 #51
0
        public static string GetStartModeString(StartMode startMode)
        {
            switch(startMode)
            {
                case StartMode.Auto:
                    return "Automatic";
            }

            return startMode.ToString();
        }
コード例 #52
0
 public void Stop()
 {
     sMode = StartMode.stopped;
 }
コード例 #53
0
 private static string ConvertStartModeToString(StartMode startMode)
 {
     switch (startMode)
     {
         case StartMode.Auto: return "Automatic";
         case StartMode.Boot: return "Boot";
         case StartMode.System: return "System";
         case StartMode.Manual: return "Manual";
         case StartMode.Disabled: return "Disabled";
     }
     
     return String.Empty;
 }
コード例 #54
0
ファイル: TreeOfBags.cs プロジェクト: jlundstocholm/ravendb
		public TreeOfBags(Stream reader, Stream writer, StartMode mode)
		{
			this.reader = reader;
			this.writer = writer;
			bags = new Tree(reader, writer, mode);
		}
コード例 #55
0
ファイル: ServiceInstaller.cs プロジェクト: yuriik83/UA-.NET
 /// <summary>
 /// Installs and optionally starts the service.
 /// </summary>
 /// <param name="path">The full path of the service exe.</param>
 /// <param name="name">The name of the service.</param>
 /// <param name="displayName">The display name of the service.</param>
 /// <param name="description">The description for the service.</param>
 /// <param name="startMode">The service start mode.</param>
 /// <param name="userName">The account name. Null to use the default account (LocalSystem).</param>
 /// <param name="password">The account password.</param>
 /// <param name="start">True to start the service after the installation; otherwise, false. 
 /// Once the method returns you can use this parameter to check whether the service is running or not.</param>
 /// <returns>True for success. Otherwise, false.</returns> 
 public static bool InstallService(
     string    path, 
     string    name, 
     string    displayName, 
     string    description,
     StartMode startMode, 
     string    userName, 
     string    password, 
     ref bool  start)
 { 
     return InstallService(path, name, displayName, description, startMode, userName, password, ref start, null);
 }
コード例 #56
0
 public PoderosaAppContext(StartMode startMode)
 {
     if (startMode == StartMode.StandAlone) {
         Application.EnableVisualStyles();
         Application.SetCompatibleTextRenderingDefault(false);
         Application.VisualStyleState = System.Windows.Forms.VisualStyles.VisualStyleState.ClientAndNonClientAreasEnabled;
     }
 }