App() { var config = ConfigurationManager.OpenMappedMachineConfiguration(new ConfigurationFileMap(@"..\..\ServiceConfiguration.config")); ConfigSection = config.GetSection("serviceSection") as ServiceSection; ConfigSection.Services.ClearAll(); config.Save(ConfigurationSaveMode.Modified); }
public ActionResult DeleteConfirmed(int id) { ServiceSection serviceSection = db.ServiceSections.Find(id); db.ServiceSections.Remove(serviceSection); db.SaveChanges(); return(RedirectToAction("Index")); }
public LambdaMetricsRepository(string functionName) { var config = ConfigurationManager.OpenMappedMachineConfiguration(new ConfigurationFileMap(@"..\..\ServiceConfiguration.config")); ConfigSection = config.GetSection("serviceSection") as ServiceSection; MetricsRepository = GetMetricRepository(functionName); config.Save(ConfigurationSaveMode.Modified); }
public QueueRepository() { var config = ConfigurationManager.OpenMappedMachineConfiguration(new ConfigurationFileMap(@"..\..\ServiceConfiguration.config")); ConfigSection = config.GetSection("serviceSection") as ServiceSection; queueRepository = GetQueueRepository(); config.Save(ConfigurationSaveMode.Modified); }
public JScrambler(string accessKey, string secretKey) { this.serviceConfig = this.serviceConfig ?? new ServiceSection(); this.serviceConfig.Credentials.AccessKey = accessKey; this.serviceConfig.Credentials.SecretKey = secretKey; #if DEBUG this.serviceConfig.ApiPort = 80; #endif }
public ActionResult Edit([Bind(Include = "id,icon,header,deccription")] ServiceSection serviceSection) { if (ModelState.IsValid) { db.Entry(serviceSection).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(serviceSection)); }
public ActionResult Create([Bind(Include = "id,icon,header,deccription")] ServiceSection serviceSection) { if (ModelState.IsValid) { db.ServiceSections.Add(serviceSection); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(serviceSection)); }
public void Execute(IJobExecutionContext context) { var section = ServiceSection.GetSection("quartzservice"); var name = context.JobDetail.Key.Name; var invoker = section.GetJobInvoker(name, JobObjectContainer.Get(name)); if (invoker == null) { throw new NullReferenceException("job服务实例获取失败."); } invoker.Method.Invoke(invoker.Instance, null); }
// GET: AdminPanel/AdminService/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ServiceSection serviceSection = db.ServiceSections.Find(id); if (serviceSection == null) { return(HttpNotFound()); } return(View(serviceSection)); }
static void Main(string[] args) { AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; Console.Title = Process.GetCurrentProcess().ProcessName; LoadAssemblies(); var section = ServiceSection.GetSection("quartzservice"); var invoker = section.GetServerInvoker(); if (invoker == null) { throw new NullReferenceException("scheduler服务实例获取失败."); } invoker.Method.Invoke(invoker.Instance, null); }
public UnitConfiguration ToSystemdConfiguration() { var unit = new UnitSection { Description = Description ?? (Name + " Service") }; string env = Environment != null ? string.Join(" ", Environment.Variables.Select(pair => pair.Key + "=" + pair.Value)) : null; string execStart = Start.FileName.StartsWith("/") ? Start.ToString() : WorkingDirectory + "/" + Start.ToString(); var service = new ServiceSection { WorkingDirectory = WorkingDirectory, ExecStart = execStart, Environment = env, User = User.ToString(), SyslogIdentifier = Name }; if (RestartPolicy != null) { switch (RestartPolicy.Condition) { case RestartCondition.Always: service.Restart = RestartOptions.Always; break; case RestartCondition.OnFailure: service.Restart = RestartOptions.OnFailure; break; case RestartCondition.OnAbormal: service.Restart = RestartOptions.OnAbnormal; break; } if (RestartPolicy.Delay != null) { service.RestartSec = (int)RestartPolicy.Delay.Value.TotalSeconds; } } return(new UnitConfiguration { Unit = unit, Service = service, Install = new InstallSection { WantedBy = "multi-user.target" } }); }
public virtual void InitScheduler() { var section = ServiceSection.GetSection("quartzservice"); var jobConfigs = section.Jobs; ISchedulerFactory factory = new StdSchedulerFactory(); Scheduler = factory.GetScheduler(); foreach (var j in jobConfigs) { var jConfig = (j as ServiceJobElement); object jobObj = Activator.CreateInstance(Type.GetType(jConfig.Type)); JobObjectContainer.Set(jConfig.Name, jobObj); string jobName = jConfig.Name; string triggerName = jobName + "_trigger"; string cron = jConfig.Cron; var job = JobBuilder.Create <DefaultJob>() .WithIdentity(jobName, "jobgroup") .RequestRecovery(true).Build(); ITrigger trigger; if (string.IsNullOrEmpty(cron)) { trigger = TriggerBuilder.Create() .WithIdentity("triggergroup", triggerName) .StartAt(DateTimeOffset.Now) .Build(); } else { trigger = TriggerBuilder.Create() .WithIdentity("localTrigger", triggerName) .StartAt(DateTimeOffset.Now) .WithCronSchedule(cron) .Build(); } if (!Scheduler.CheckExists(job.Key)) { Scheduler.ScheduleJob(job, trigger); } Scheduler.ListenerManager.AddJobListener(new DefaultJobListener(), KeyMatcher <JobKey> .KeyEquals(job.Key)); } Scheduler.ListenerManager.AddSchedulerListener(new DefaultSchedulerListener(this)); }
public ApiGatewayUrl CheckURL(string url) { var Url = new ApiGatewayUrl(); Url.CheckUrl(url); urls.Add(Url); UrlRepository.addNewUrl(url); var config = ConfigurationManager.OpenMappedMachineConfiguration(new ConfigurationFileMap(@"..\..\..\ServiceConfiguration.config")); ConfigSection = config.GetSection("serviceSection") as ServiceSection; ConfigSection.Add(new Service { ServiceType = "ApiGateWay", ServiceName = url, Metric = "url", Value = Url.Code.Description }); config.Save(ConfigurationSaveMode.Modified); return(Url); }
private void Button_Click(object sender, RoutedEventArgs e) { UrlList.Visibility = Visibility.Visible; var url = new ApiGatewayUrl(); url.CheckUrl(UrlTxt.Text); UrlVM.UrlRepository.addNewUrl(UrlTxt.Text); UrlVM.urls.Add(url); var config = ConfigurationManager.OpenMappedMachineConfiguration(new ConfigurationFileMap(@"..\..\ServiceConfiguration.config")); ConfigSection = config.GetSection("serviceSection") as ServiceSection; ConfigSection.Add(new Service { ServiceType = "ApiGateWay", ServiceName = url.Url, Metric = "url", Value = url.Code.Description }); config.Save(ConfigurationSaveMode.Modified); UrlList.Items.Refresh(); }
public JScrambler() { serviceConfig = ConfigurationManager.GetSection(ServiceSection.SectionName) as ServiceSection; }
static void SafeMain(string[] args) { AddERExcludedApplication(Process.GetCurrentProcess().MainModule.ModuleName); Console.WriteLine("TraceSpy Service - " + (Environment.Is64BitProcess ? "64" : "32") + "-bit - Build Number " + Assembly.GetExecutingAssembly().GetInformationalVersion()); Console.WriteLine("Copyright (C) SoftFluent S.A.S 2012-" + DateTime.Now.Year + ". All rights reserved."); var token = Extensions.GetTokenElevationType(); if (token != TokenElevationType.Full) { Console.WriteLine(""); Console.WriteLine("Warning: token elevation type (UAC level) is " + token + ". You may experience access denied errors from now on. You may fix these errors if you restart with Administrator rights or without UAC."); Console.WriteLine(""); } OptionHelp = CommandLineUtilities.GetArgument(args, "?", false); if (!OptionHelp) { OptionHelp = CommandLineUtilities.GetArgument(args, "h", false); if (!OptionHelp) { OptionHelp = CommandLineUtilities.GetArgument(args, "help", false); } } OptionService = CommandLineUtilities.GetArgument(args, "s", false); if (!OptionService) { if (OptionHelp) { Console.WriteLine("Format is " + Assembly.GetExecutingAssembly().GetName().Name + ".exe [options]"); Console.WriteLine("[options] can be a combination of the following:"); Console.WriteLine(" /? Displays this help"); Console.WriteLine(" /i Installs the <name> service"); Console.WriteLine(" /k Kills this process on any exception"); Console.WriteLine(" /u Uninstalls the <name> service"); Console.WriteLine(" /t Displays traces on the console"); Console.WriteLine(" /l:<name> Locale used"); Console.WriteLine(" default is " + CultureInfo.CurrentCulture.LCID); Console.WriteLine(" /name:<name> (Un)Installation uses <name> for the service name"); Console.WriteLine(" default is \"" + DefaultName + "\""); Console.WriteLine(" /displayName:<dname> (Un)Installation uses <dname> for the display name"); Console.WriteLine(" default is \"" + DefaultDisplayName + "\""); Console.WriteLine(" /description:<desc.> Installation ses <desc.> for the service description"); Console.WriteLine(" default is \"" + DefaultDisplayName + "\""); Console.WriteLine(" /startType:<type> Installation uses <type> for the service start mode"); Console.WriteLine(" default is \"" + ServiceStartMode.Manual + "\""); Console.WriteLine(" Values are " + ServiceStartMode.Automatic + ", " + ServiceStartMode.Disabled + " or " + ServiceStartMode.Manual); Console.WriteLine(" /user:<name> Name of the account under which the service should run"); Console.WriteLine(" default is Local System"); Console.WriteLine(" /password:<text> Password to the account name"); Console.WriteLine(" /config:<path> Path to the configuration file"); Console.WriteLine(" /dependson:<list> A comma separated list of service to depend on"); Console.WriteLine(""); Console.WriteLine("Examples:"); Console.WriteLine(Assembly.GetExecutingAssembly().GetName().Name + " /i /name:MyService /displayName:\"My Service\" /startType:Automatic"); Console.WriteLine(Assembly.GetExecutingAssembly().GetName().Name + " /u /name:MyOtherService"); return; } } OptionTrace = CommandLineUtilities.GetArgument(args, "t", false); OptionKillOnException = CommandLineUtilities.GetArgument(args, "k", false); OptionInstall = CommandLineUtilities.GetArgument(args, "i", false); OptionStartType = (ServiceStartMode)CommandLineUtilities.GetArgument(args, "starttype", ServiceStartMode.Manual); OptionLcid = CommandLineUtilities.GetArgument <string>(args, "l", null); OptionUninstall = CommandLineUtilities.GetArgument(args, "u", false); OptionAccount = (ServiceAccount)CommandLineUtilities.GetArgument(args, "user", ServiceAccount.User); OptionPassword = CommandLineUtilities.GetArgument <string>(args, "password", null); OptionUser = CommandLineUtilities.GetArgument <string>(args, "user", null); string dependsOn = CommandLineUtilities.GetArgument <string>(args, "dependson", null); if (!string.IsNullOrEmpty(dependsOn)) { OptionDependsOn = dependsOn.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); } else { OptionDependsOn = null; } OptionConfigPath = CommandLineUtilities.GetArgument <string>(args, "config", null); if (!string.IsNullOrEmpty(OptionConfigPath) && !Path.IsPathRooted(OptionConfigPath)) { OptionConfigPath = Path.GetFullPath(OptionConfigPath); } _configuration = ServiceSection.Get(OptionConfigPath); OptionDisplayName = CommandLineUtilities.GetArgument(args, "displayname", DefaultDisplayName); OptionDescription = CommandLineUtilities.GetArgument(args, "description", DefaultDescription); if (OptionInstall) { ServiceInstaller si = new ServiceInstaller(); ServiceProcessInstaller spi = new ServiceProcessInstaller(); si.ServicesDependedOn = OptionDependsOn; Console.WriteLine("OptionAccount=" + OptionAccount); Console.WriteLine("OptionUser="******"Password cannot be empty if Account is set to User."); return; } spi.Username = OptionUser; spi.Password = OptionPassword; } } else { spi.Account = OptionAccount; } si.Parent = spi; si.DisplayName = OptionDisplayName; si.Description = OptionDescription; si.ServiceName = OptionName; si.StartType = OptionStartType; si.Context = new InstallContext(Assembly.GetExecutingAssembly().GetName().Name + ".install.log", null); string asmpath = Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, AppDomain.CurrentDomain.FriendlyName); // TODO: add instance specific parameters here (ports, etc...) string binaryPath = "\"" + asmpath + "\"" // exe path + " /s" // we run as a service + " /name:" + OptionName; // our name if (!string.IsNullOrEmpty(OptionConfigPath)) { binaryPath += " /c:\"" + OptionConfigPath + "\""; } si.Context.Parameters["assemblypath"] = binaryPath; IDictionary stateSaver = new Hashtable(); si.Install(stateSaver); // see remarks in the function FixServicePath(si.ServiceName, binaryPath); return; } if (OptionUninstall) { ServiceInstaller si = new ServiceInstaller(); ServiceProcessInstaller spi = new ServiceProcessInstaller(); si.Parent = spi; si.ServiceName = OptionName; si.Context = new InstallContext(Assembly.GetExecutingAssembly().GetName().Name + ".uninstall.log", null); si.Uninstall(null); return; } if (!OptionService) { if (OptionTrace) { Trace.Listeners.Add(new ConsoleListener()); } if (!string.IsNullOrEmpty(OptionLcid)) { Extensions.SetCurrentThreadCulture(OptionLcid); } Console.WriteLine("Console Mode"); Console.WriteLine("Service Host name: " + OptionName); WindowsIdentity identity = WindowsIdentity.GetCurrent(); Console.WriteLine("Service Host identity: " + (identity != null ? identity.Name : "null")); Console.WriteLine("Service Host bitness: " + (IntPtr.Size == 4 ? "32-bit" : "64-bit")); Console.WriteLine("Service Host display name: '" + OptionDisplayName + "'"); Console.WriteLine("Service Host event log source: " + _service.EventLog.Source); Console.WriteLine("Service Host trace enabled: " + OptionTrace); Console.WriteLine("Service Host administrator mode: " + IsAdministrator()); string configPath = OptionConfigPath; if (configPath == null) { configPath = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile; } Console.WriteLine("Service Host config file path: " + configPath); Console.WriteLine("Service Host current locale: " + Thread.CurrentThread.CurrentCulture.LCID + " (" + Thread.CurrentThread.CurrentCulture.Name + ")"); Console.Title = OptionDisplayName; ConsoleControl cc = new ConsoleControl(); cc.Event += OnConsoleControlEvent; _service.InternalStart(args); if (!_stopping) { _service.InternalStop(); } else { int maxWaitTime = Configuration.ConsoleCloseMaxWaitTime; if (maxWaitTime <= 0) { maxWaitTime = Timeout.Infinite; } _closed.WaitOne(maxWaitTime, Configuration.WaitExitContext); } return; } ServiceBase[] ServicesToRun; ServicesToRun = new ServiceBase[] { _service }; Run(ServicesToRun); }
public JScrambler(string accessKey, string secretKey, string apiHost, int apiPort) : this(accessKey, secretKey, apiHost) { this.serviceConfig = this.serviceConfig ?? new ServiceSection(); this.serviceConfig.ApiPort = apiPort; }
public JScrambler() { var section = ConfigurationManager.GetSection(ServiceSection.SectionName); serviceConfig = section as ServiceSection; }