public static void InitUppm() { Logging.OnQuestion += HandleOnQuestion; //TODO: Handle progress Logging.ConfigureLogger( logger => logger .MinimumLevel.Is(_arguments.LoggingLevel) .WriteTo.Console(), obslog => obslog.Subscribe(BreakOnError) ); TargetApp.RegisterApps(typeof(TargetApp).Assembly); TargetApp.RegisterApps(typeof(Program).Assembly); foreach (var knownApp in TargetApp.KnownTargetApps.Values) { if (Enum.TryParse <Architecture>(_arguments.AppArchitecture, true, out var arch)) { knownApp.DefaultArchitecture = arch; } } if (!string.IsNullOrWhiteSpace(_arguments.WorkDirOverride)) { Uppm.WorkingDirectory = _arguments.WorkDirOverride; } // TODO: further uppm initialization }
public void ParseFromEntity(TargetApp entity) { Id = entity.Id.ToString(); Name = entity.Name; HealthCheckUrl = entity.HealthCheckUrl; Interval = entity.Interval; }
public void AddNew(TargetApp targetApp) { targetApp.Id = Guid.NewGuid(); _app.Set <TargetApp>().Add(targetApp); _app.SaveChanges(); _scheduler.AddHealthCheckJob(targetApp.Id.ToString(), targetApp.Interval); }
public void Send(TargetApp item, string destinationMailAddress) { try { using (var message = new MailMessage()) { message.To.Add(new MailAddress(destinationMailAddress, destinationMailAddress)); message.From = new MailAddress(_mailSettings.Mail, _mailSettings.DisplayName); message.Subject = "Notification"; message.Body = $"{item.Name} cannot be reached. URL: {item.Url}"; message.IsBodyHtml = _mailSettings.IsBodyHtml; using (var client = new SmtpClient(_mailSettings.Host)) { client.Port = _mailSettings.Port; client.Credentials = new NetworkCredential(_mailSettings.Mail, _mailSettings.Password); client.EnableSsl = _mailSettings.EnableSsl; client.Send(message); } } } catch (Exception) { } }
private async void LaunchButton_Click(object sender, EventArgs e) { object selected = ComponentDropDown.Text; if (selected == null) { return; } var componentName = selected.ToString(); var targetApp = new TargetApp() { Name = componentName }; var context = new Context(new JObject { ["type"] = "fdc3.instrument", ["name"] = DataToSendInput.Text, ["id"] = new JObject { ["ticker"] = DataToSendInput.Text } }); var openError = await _bridge.Clients.Fdc3Client.DesktopAgentClient.Open(targetApp, context); if (openError.HasValue) { MessageBox.Show(openError.ToString()); } }
public static void SetPropsFromDto(TargetApp app, UpdateTargetAppDto updateDto) { app.Name = updateDto.Name; app.Url = updateDto.Url; app.IntervalType = updateDto.IntervalType; app.IntervalValue = updateDto.IntervalValue; app.IsAlive = null; }
public static UpdateTargetAppDto MapToUpdateDto(TargetApp app) { if (app == null) { return(null); } return(new UpdateTargetAppDto { IntervalType = app.IntervalType, IntervalValue = app.IntervalValue, Id = app.Id, Url = app.Url, Name = app.Name }); }
public IActionResult EditUrl(TargetApp t) { var row = context.TargetApps.Find(t.id); row.name = t.name; row.url = t.url; row.interval = t.interval; context.SaveChanges(); return(RedirectToAction("Index")); }
/// <summary> /// Tries to set the current target application to the specified one. /// </summary> /// <param name="sname"></param> /// <param name="app"></param> /// <returns></returns> public static bool TrySetCurrentApp(this PSCmdlet cmdlet, string sname, out TargetApp app) { if (!cmdlet.TryGetKnownApp(sname, out app)) { return(false); } cmdlet.GetPppmState().CurrentTargetApp?.DefaultRepository?.UnregisterDefaultRepository(); cmdlet.GetPppmState().CurrentTargetApp = app; app.DefaultRepository.RegisterDefaultRepository(); return(true); }
public void Add(TargetApp item) { item.UserId = CurrentUserId; db.Add(item); db.SaveChanges(); if (item.Status) { ScheduledJobs.RecurringJobs.AddJob(item, CurrentUserMailAddress); } }
public static TargetAppDto MapToAppDto(TargetApp app) { if (app == null) { return(null); } return(new TargetAppDto { IntervalType = app.IntervalType, IntervalValue = app.IntervalValue, CreatedById = app.CreatedById, Id = app.Id, Url = app.Url, Name = app.Name, IsAlive = app.IsAlive, LastCheck = app.LastCheck }); }
public void LogInsert(TargetApp targetapp, string status) { Log log = new Log(); log.targetid = targetapp.id; log.username = targetapp.User.username; log.url = targetapp.url; log.date = DateTime.Now; log.status = status; context.Logs.Add(log); context.SaveChanges(); }
public bool ShareApp(TargetApp targetApp) { switch (targetApp) { case TargetApp.SkypeEnterprise: return(OpenSkypeEnterprise()); case TargetApp.Email: return(SendEmail()); default: throw new ArgumentOutOfRangeException(nameof(targetApp), targetApp, null); } }
public IActionResult NewUrl(TargetApp targetapp) { var userinfo = JsonConvert.DeserializeObject <User>(HttpContext.Session.GetString("sessionuser")); TargetApp t = new TargetApp(); t.userid = userinfo.userid; t.mail = userinfo.mail; t.name = targetapp.name; t.url = targetapp.url; t.interval = targetapp.interval; context.TargetApps.Add(t); context.SaveChanges(); return(RedirectToAction("Index")); }
public void Update(TargetApp targetApp) { _app.Entry <TargetApp>(targetApp).State = EntityState.Modified; var old = GetById(targetApp.Id.ToString()); if (targetApp.Interval != old.Interval) { _scheduler.UnscheduleJob(new TriggerKey(targetApp.Id.ToString())); _scheduler.AddHealthCheckJob(targetApp.Id.ToString(), targetApp.Interval); } if (targetApp.IsDown && !old.IsDown) { _notificationProvider.NotifyAsync(NotifyTypes.Email, $"<strong>{targetApp.Name}</strong> health check endpoint returned status code different from 2##"); } _app.SaveChanges(); }
public void Contact(TargetApp t) //Mail sınıfından m diye bir değişken tanımlarız { try { SmtpClient client = new SmtpClient("smtp.gmail.com", 587); client.Credentials = new NetworkCredential("*****@*****.**", "******"); client.EnableSsl = true; MailMessage msj = new MailMessage(); msj.From = new MailAddress("*****@*****.**"); msj.To.Add(t.mail); msj.Subject = "Uyarı"; msj.Body = t.url + "adresine erişim yoktur."; client.Send(msj); } catch (Exception ex) { } }
public bool ShareApp(TargetApp targetApp) { switch (targetApp) { case TargetApp.SkypeEnterprise: return(openSkypeEnterprise()); break; case TargetApp.Email: return(openMail()); break; default: return(false); break; } }
public void Update(TargetApp item) { var x = Get(item.Id); if (x != null) { x.Interval = item.Interval; x.Name = item.Name; x.Url = item.Url; x.Status = item.Status; db.SaveChanges(); ScheduledJobs.RecurringJobs.RemoveJob(x); if (x.Status) { ScheduledJobs.RecurringJobs.AddJob(item, CurrentUserMailAddress); } } }
private async void LaunchButton_Click(object sender, EventArgs e) { object selected = ComponentDropDown.Text; if (selected == null) { return; } var componentName = selected.ToString(); if (FSBL.FDC3Client != null) { var targetApp = new TargetApp() { Name = componentName }; var context = new Context(new JObject { ["type"] = "fdc3.instrument", ["name"] = DataToSendInput.Text, ["id"] = new JObject { ["ticker"] = DataToSendInput.Text } }); var openError = await FSBL.FDC3Client.DesktopAgentClient.Open(targetApp, context); if (openError.HasValue) { MessageBox.Show(openError.ToString()); } } else { FSBL.LauncherClient.Spawn(componentName, new JObject { ["addToWorkspace"] = true }, (s, a) => { }); } }
private async void SpawnComponent_Click(object sender, RoutedEventArgs e) { object selected = ComponentSelect.ItemsComboBox.SelectedValue; if (selected != null) { string componentName = selected.ToString(); if (FSBL.FDC3Client is object) { //FDC3 Usage example //open var targetApp = new TargetApp(componentName); var context = new Context(new JObject { ["type"] = "fdc3.instrument", ["name"] = DataToSend.TextBox.Text, ["id"] = new JObject { ["ticker"] = DataToSend.TextBox.Text } }); var openError = await FSBL.FDC3Client.DesktopAgentClient.Open(targetApp, context); if (openError.HasValue) { MessageBox.Show(openError.ToString()); } } else { FSBL.LauncherClient.Spawn(componentName, new JObject { ["addToWorkspace"] = true }, (s, a) => { }); } } }
public void Delete(TargetApp targetApp) { _app.Entry <TargetApp>(targetApp).State = EntityState.Deleted; _scheduler.UnscheduleJob(new TriggerKey(targetApp.Id.ToString())); _app.SaveChanges(); }
public static bool TryGetKnownApp(this PSCmdlet cmdlet, string sname, out TargetApp app) => cmdlet.GetPppmState().KnownTargetApps.TryGetValue(sname, out app);
public IActionResult Logs(TargetApp row) { var list = context.Logs.Where(x => x.targetid == row.id).OrderByDescending(x => x.id).Take(10).ToList(); return(View(list)); }
public IActionResult Save(TargetApp model) { _service.Add(model); return(Ok(true)); }
public IActionResult Update(TargetApp model) { _service.Update(model); return(Ok(true)); }
private async void SpawnComponent_Click(object sender, RoutedEventArgs e) { object selected = ComponentSelect.ItemsComboBox.SelectedValue; if (selected != null) { string componentName = selected.ToString(); if (FSBL.FDC3Client is object) { //FDC3 Usage example //open var context = new Context(new JObject { ["type"] = "fdc3.instrument", ["name"] = DataToSend.TextBox.Text, ["id"] = new JObject { ["ticker"] = DataToSend.TextBox.Text } }); var targetApp = new TargetApp(componentName); await FSBL.FDC3Client.DesktopAgentClient.Open(targetApp, context); //Intent //var context = new Context(new JObject //{ // ["type"] = "fdc3.instrument", // ["name"] = DataToSend.TextBox.Text, // ["id"] = new JObject // { // ["ticker"] = DataToSend.TextBox.Text // } //}); //await FSBL.FDC3Client.DesktopAgentClient.RaiseIntent("ViewChart", context, null); //var intent = await FSBL.FDC3Client.DesktopAgentClient.FindIntent("ViewChart", null); //FSBL.Logger.Log(new JToken[] { "WPF FDC3 Usage Example, findIntent.", JsonConvert.SerializeObject(intent, Formatting.Indented)}); //var intent = await FSBL.FDC3Client.DesktopAgentClient.FindIntent("ViewChart", new Context(new JObject //{ // ["type"] = "fdc3.instrument" //})); //FSBL.Logger.Log(new JToken[] { "WPF FDC3 Usage Example, findIntent.", JsonConvert.SerializeObject(intent, Formatting.Indented) }); //var context = new Context(new JObject //{ // ["type"] = "fdc3.instrument" //}); //var intents = await FSBL.FDC3Client.DesktopAgentClient.FindIntentsByContext(context); //FSBL.Logger.Log(new JToken[] { "WPF FDC3 Usage Example, findIntentsByContext.", JsonConvert.SerializeObject(intents, Formatting.Indented)}); //Context //var channel = await FSBL.FDC3Client.DesktopAgentClient.GetCurrentChannel(); //var context = await channel.GetCurrentContext("fdc3.instrument");, //FSBL.Logger.Log(new JToken[] { "WPF FDC3 Usage Example: getCurrentContext.", context.Value.ToString() }); //Channels //var channel = await FSBL.FDC3Client.DesktopAgentClient.GetOrCreateChannel("test"); //var channels = await FSBL.FDC3Client.DesktopAgentClient.GetSystemChannels(); //foreach (IChannel channel in channels) //{ // FSBL.Logger.Log(new JToken[] { "WPF FDC3 Usage Example: getSystemChannels.", channel.Id }); //} //var channel = await FSBL.FDC3Client.DesktopAgentClient.GetCurrentChannel(); //FSBL.Logger.Log(new JToken[] { "WPF FDC3 Usage Example: getCurrentChannel.", channel.Id }); } else { FSBL.LauncherClient.Spawn(componentName, new JObject { ["addToWorkspace"] = true }, (s, a) => { }); } } }