public KeepAliveWindow() { InitializeComponent(); service = ServiceControl.GetService(); refreshServiceStatusTimer = TimerDispatch.Current.AddInterval((m) => GetServiceStatus(), 10000); this.Closed += (o, e) => Dispose(); this.Hide(); }
private void Initialize() { Runtime = MonitorIoc.Current.Get <MonitorRuntime>(); Runtime.SetUpdateList(DDnsSharpRuntime.AppConfig.UpdateList); service = ServiceControl.GetService(); GetServiceStatus(); serviceStatusCheker = TimerDispatch.Current.AddInterval((m) => GetServiceStatus(), 5000); updateListRefresher = TimerDispatch.Current.AddInterval((m) => RefreshUpdateList(), 15000); currentIpChecker = TimerDispatch.Current.AddInterval((m) => UpdateCurrentIP(), 180000); UpdateCurrentIP(); }
public override void Execute() { ICurrentDocumentWindow win = this.GetServiceForThisTypeKey <ICurrentDocumentWindow>(); ServiceControl serControl = win.EditController.EditorView as ServiceControl; DependencyObject entity = win.EditController.EditorView.DataSource as DependencyObject; DependencyObjectCollection XMO_AA_D2 = entity["XMO_AA_D2"] as DependencyObjectCollection; IFindControlService findSer = serControl.GetService <IFindControlService>(); if (XMO_AA_D2.Count == 0) { DigiwinMessageBox.ShowInfo("无导出数据!"); return; } Control control; if (findSer.TryGet("XdesignerGrid1XMO_AA_D1", out control)) { DigiwinGrid gridControl = control as DigiwinGrid; if (gridControl != null) { BindingSource bs = gridControl.DataSource as BindingSource; DependencyObjectCollection entityDColl = ((DependencyObjectCollectionView <DependencyObjectView>)bs.List).DependencyObjectCollection; using (var form = new ExportExcelForm(gridControl.InnerGridView, this.ResourceServiceProvider, this.ServiceCallContext)) { DialogResult log = form.ShowDialog(); if (log == DialogResult.OK) { DigiwinMessageBox.ShowInfo("资料导出成功!"); } form.Dispose(); } } } return; using (var form = new ExportExcelForm(entity, this.ResourceServiceProvider, this.ServiceCallContext)) { DialogResult log = form.ShowDialog(); if (log == DialogResult.OK) { DigiwinMessageBox.ShowInfo("资料导出成功!"); } form.Dispose(); } }
private void InstallService() { var dialogResult = MessageBox.Show("尚未安装DDNS服务,该服务将会在开机的时候自动运行,并且每30秒自动更新您的最新IP您的指定记录.在安装之前请确保您正在使用管理员权限运行本程序.是否继续?", "", MessageBoxButton.YesNo); if (dialogResult == MessageBoxResult.Yes) { var path = Path.Combine(Directory.GetCurrentDirectory(), "installService.bat"); if (File.Exists(path)) { ShellExecute(IntPtr.Zero, "Open", path, String.Empty, Directory.GetCurrentDirectory(), 0); var task = new Task(() => { System.Threading.Thread.Sleep(5000); try { if (service != null) { service.Dispose(); } service = ServiceControl.GetService(); ServiceStatus = ServiceControl.GetServiceStatus(service); MessageBox.Show("如果左下角的服务状态在1分钟之后还是处于非绿灯状态,请确保您正在使用管理员权限运行本程序,并且程序目录内的文件完整,最后查看程序目录下的DDNSPod.Service.InstallLog和sevice.log日志文件,并向社区求助."); if (service != null) { try { service.Start(); } catch (Exception e) { MessageBox.Show(e.Message); } } } catch (Win32Exception ex) { logger.ErrorException(ex.Message, ex); } }); task.Start(); } else { MessageBox.Show("服务安装脚本丢失,请确保您的DDNSPod的程序目录完整!"); } } }
private void UninstallService() { var dialogResult = MessageBox.Show("您确定这么做吗?", "", MessageBoxButton.YesNo); if (dialogResult == MessageBoxResult.Yes) { var path = Path.Combine(Directory.GetCurrentDirectory(), "uninstallService.bat"); if (File.Exists(path)) { if (service != null) { try { if (service.CanStop) { service.Stop(); } } catch (Exception e) { MessageBox.Show(e.Message); } ShellExecute(IntPtr.Zero, "Open", path, String.Empty, Directory.GetCurrentDirectory(), 0); var task = new Task(() => { System.Threading.Thread.Sleep(5000); if (service != null) { service.Dispose(); service = ServiceControl.GetService(); } ServiceStatus = ServiceControl.GetServiceStatus(service); MessageBox.Show("如果左下角的服务状态在1分钟之后还是处于非红色叉叉状态,请确保您正在使用管理员权限运行本程序,并且程序目录内的文件完整,最后查看程序目录下的DDNSPod.Service.InstallLog和sevice.log日志文件,并向社区求助."); }); task.Start(); } } else { MessageBox.Show("服务安装脚本丢失,请确保您的DDNSPod的程序目录完整!"); } } }