public SafeguardAbilityWindow()
        {
            InitializeComponent();
            this.WebBrowser.MessageHook += WebBrowser_MessageHook;

            //string url = System.Configuration.ConfigurationManager.AppSettings["SafeguardAbility"];
            //url = url.Substring(0, url.LastIndexOf('/'));
            //string baseAddress = url.Substring(0, url.LastIndexOf('/'));
            //HttpClient client = new HttpClient();
            //client.BaseAddress = new Uri(baseAddress);
            bool res = true;

            try
            {
                //var response = client.GetAsync("api/CheckConnection");
                //var result = response.Result.Content.ReadAsStringAsync();
                res = bool.Parse(ApiTools <Object> .ReadAsStringAsync("api/CheckConnection"));
            }
            catch (Exception)
            {
                res = false;
            }
            if (res)
            {
                isOnlineText.Text = "正常";
            }
            else
            {
                isOnlineText.Text = "异常";
            }
        }
Ejemplo n.º 2
0
        private void GetMonitoringMode()
        {
            var model = ApiTools <ApiResultModel <MonitoringModeViewModel> > .ReadAsObjAsync("api/MonitoringMode");

            label.Text = model.Obj.Text;
            Color startcolor, endcolor;

            switch (model.Obj.Text)
            {
            case "告警":
                startcolor = (Color)ColorConverter.ConvertFromString("red");
                endcolor   = (Color)ColorConverter.ConvertFromString("red");
                ball.Fill  = new LinearGradientBrush(startcolor, endcolor, 45);
                break;

            case "预警":
                startcolor = (Color)ColorConverter.ConvertFromString("yellow");
                endcolor   = (Color)ColorConverter.ConvertFromString("yellow");
                ball.Fill  = new LinearGradientBrush(startcolor, endcolor, 45);
                break;

            case "正常":
                startcolor = (Color)ColorConverter.ConvertFromString("green");
                endcolor   = (Color)ColorConverter.ConvertFromString("green");
                ball.Fill  = new LinearGradientBrush(startcolor, endcolor, 45);
                break;

            default:
                break;
            }
            labelScore.Text = model.Obj.Count.ToString();
        }
Ejemplo n.º 3
0
        private void TimeCycle(object sender, EventArgs e)
        {
            var model = ApiTools <ApiResultModel <bool> > .ReadAsObjAsync("api/IsPop");

            if (model.Status)
            {
                if (pollingBroadcastTimer != null)
                {
                    pollingBroadcastTimer.Stop();
                    pollingBroadcastTimer.Dispose();
                    pollingBroadcastTimer = null;
                }
                OpenPopBoxs();
            }
            else
            {
                PollingBroadcast();
            }
            if (isRatingMode)
            {
                GetRatingMode();
            }
            else
            {
                GetMonitoringMode();
            }
        }
Ejemplo n.º 4
0
        private void GetRatingMode()
        {
            var model = ApiTools <ApiResultModel <ViewModels.Y_EngineRoomScoreViewModel> > .ReadAsObjAsync("api/EngineRoomScore");

            label.Text = Enum.GetName(typeof(GradeEnum), model.Obj.ScoreLevel);
            BallBackgroundColor(model.Obj.ScoreLevel);
            labelScore.Text = model.Obj.EngineRoomScore.ToString();
        }
Ejemplo n.º 5
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            IsClose = false;

            var warnFaultModel = ApiTools <ApiResultModel <ViewModels.WarnFaultPopViewModel> > .ReadAsObjAsync("api/Warninng");

            if (warnFaultModel.Status)
            {
                if (warnFaultModel.Obj != null)
                {
                    EWarnText.Text    = warnFaultModel.Obj.EventName;
                    ExpertAdvice.Text = warnFaultModel.Obj.ExpertAdvice;
                    if (warnFaultModel.Obj.IsVoice)
                    {
                        speech = this.EWarnText.Text + ":" + this.ExpertAdvice.Text;
                        InitTimer();
                    }
                    var result = ApiTools <ApiResultModel <bool> > .PostAsync("api/Warninng", warnFaultModel.Obj.ID);

                    if (result.Status == false)
                    {
                        MessageBox.Show(result.Message);
                    }
                    return;
                }
            }
            var earlyWarningModel = ApiTools <ApiResultModel <ViewModels.EarlyWarningPopViewModel> > .ReadAsObjAsync("api/EarlyWarning");

            if (earlyWarningModel.Status)
            {
                if (earlyWarningModel.Obj != null)
                {
                    EWarnText.Text    = earlyWarningModel.Obj.EWarnText;
                    ExpertAdvice.Text = earlyWarningModel.Obj.ExpertAdvice;
                    if (earlyWarningModel.Obj.IsVoice)
                    {
                        speech = this.EWarnText.Text + ":" + this.ExpertAdvice.Text;
                        InitTimer();
                    }

                    var result = ApiTools <ApiResultModel <bool> > .PostAsync("api/EarlyWarning", earlyWarningModel.Obj.ID);

                    if (result.Status == false)
                    {
                        MessageBox.Show(result.Message);
                    }
                }
                else
                {
                    this.Close();
                }
            }
            else
            {
                this.Close();
            }
        }
Ejemplo n.º 6
0
        private void PollingBroadcast()
        {
            var model = ApiTools <ApiResultModel <System.Collections.Generic.List <Y_WarnFaultViewModels> > > .ReadAsObjAsync("api/PollingBroadcastItems");

            var ewModel = ApiTools <ApiResultModel <System.Collections.Generic.List <Y_EarlyWarningViewModels> > > .ReadAsObjAsync("api/EWarningPollingBroadcastItems");

            if ((model.Status && model.Obj.Count > 0) || (ewModel.Status && ewModel.Obj.Count > 0))
            {
                if (pollingBroadcastTimer == null)
                {
                    pollingBroadcastTimer = new System.Timers.Timer();
                    string quartz   = System.Configuration.ConfigurationManager.AppSettings["WarningQuartz"];
                    double interval = int.Parse(quartz.Split('-')[0]) * 24 * 60 * 60 * 1000;
                    interval = interval + (int.Parse(quartz.Split('-')[1]) * 60 * 60 * 1000);
                    interval = interval + (int.Parse(quartz.Split('-')[2]) * 60 * 1000);
                    interval = interval + (int.Parse(quartz.Split('-')[3]) * 1000);
                    pollingBroadcastTimer.Interval  = interval;
                    pollingBroadcastTimer.AutoReset = false;
                    pollingBroadcastTimer.Elapsed  += delegate
                    {
                        System.Collections.Generic.List <string> list = new System.Collections.Generic.List <string>();
                        if (model.Status && model.Obj.Count > 0)
                        {
                            foreach (var item in model.Obj)
                            {
                                list.Add(item.EventName + ":" + item.ExpertAdvice);
                            }
                        }
                        if (ewModel.Status && ewModel.Obj.Count > 0)
                        {
                            foreach (var item in ewModel.Obj)
                            {
                                list.Add(item.EWarnText + ":" + item.ExpertAdvice);
                            }
                        }
                        if (list.Count > 0)
                        {
                            Process[] pro = Process.GetProcessesByName("PollingBroadcastSpeech");
                            if (pro.Length != 1)
                            {
                                System.Diagnostics.Process.Start(System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "PollingBroadcastSpeech.exe"), string.Join(" ", list.ToArray()));
                            }
                        }
                        pollingBroadcastTimer.Stop();
                        pollingBroadcastTimer.Dispose();
                        pollingBroadcastTimer = null;
                    };
                    pollingBroadcastTimer.Start();
                }
            }
        }
Ejemplo n.º 7
0
        private void WindowLoad()
        {
            try
            {
                var model = ApiTools <ApiResultModel <ViewModels.Y_EngineRoomScoreViewModel> > .ReadAsObjAsync("api/EngineRoomScore");

                label.Text = Enum.GetName(typeof(GradeEnum), model.Obj.ScoreLevel);
                BallBackgroundColor(model.Obj.ScoreLevel);
                labelScore.Text = model.Obj.EngineRoomScore.ToString();
            }
            catch (Exception ex)
            {
                this.notifyIcon = new NotifyIcon();
                this.notifyIcon.BalloonTipText = "站点联网异常";
                this.notifyIcon.ShowBalloonTip(2000);
                this.notifyIcon.Text    = "站点联网异常";
                this.notifyIcon.Icon    = System.Drawing.Icon.ExtractAssociatedIcon(System.IO.Path.Combine(System.Windows.Forms.Application.StartupPath, "Images\\notifyIco\\notify-16-4.ico"));
                this.notifyIcon.Visible = true;
                System.Windows.Forms.MenuItem exitex = new System.Windows.Forms.MenuItem("退出");
                exitex.Click += new EventHandler(Close);
                System.Windows.Forms.MenuItem[] childenex = new System.Windows.Forms.MenuItem[] { exitex };
                notifyIcon.ContextMenu     = new System.Windows.Forms.ContextMenu(childenex);
                grid1.ContextMenu          = null;
                this.WindowStartupLocation = WindowStartupLocation.Manual;
                this.Left  = SystemParameters.WorkArea.Width - sideThickness - 150;
                label.Text = "异常";
                Color startcolor = (Color)ColorConverter.ConvertFromString("red");
                Color endcolor   = (Color)ColorConverter.ConvertFromString("red");
                ball.Fill       = new LinearGradientBrush(startcolor, endcolor, 45);
                labelScore.Text = "站点联网";
                return;
            }
            this.notifyIcon = new NotifyIcon();
            this.notifyIcon.BalloonTipText = "系统监控中... ...";
            this.notifyIcon.ShowBalloonTip(2000);
            this.notifyIcon.Text         = "系统监控中... ...";
            this.notifyIcon.Icon         = System.Drawing.Icon.ExtractAssociatedIcon(System.IO.Path.Combine(System.Windows.Forms.Application.StartupPath, "Images\\notifyIco\\notify-16-4.ico"));
            this.notifyIcon.Visible      = true;
            this.notifyIcon.DoubleClick += NotifyIcon_DoubleClick;
            System.Windows.Forms.MenuItem exit = new System.Windows.Forms.MenuItem("退出");
            exit.Click += new EventHandler(Close);
            System.Windows.Forms.MenuItem psew = new System.Windows.Forms.MenuItem("预警系统");
            psew.Click += new EventHandler(psewClick);
            System.Windows.Forms.MenuItem SafeguardAbility = new System.Windows.Forms.MenuItem("打开保镖");
            SafeguardAbility.Click += new EventHandler(SafeguardAbilityClick);
            System.Windows.Forms.MenuItem IsSuspensionWindowShow = new System.Windows.Forms.MenuItem("显示/隐藏悬浮窗体");
            IsSuspensionWindowShow.Click += new EventHandler(IsSuspensionWindowShowClick);
            System.Windows.Forms.MenuItem[] childen = new System.Windows.Forms.MenuItem[] { SafeguardAbility, psew, IsSuspensionWindowShow, exit };
            notifyIcon.ContextMenu     = new System.Windows.Forms.ContextMenu(childen);
            this.WindowStartupLocation = WindowStartupLocation.Manual;
            this.Left = SystemParameters.WorkArea.Width - sideThickness;


            //label.Text = "优";
            //labelScore.Text = "100";

            string quartz = System.Configuration.ConfigurationManager.AppSettings["Quartz"];

            readDataTimer          = new System.Windows.Threading.DispatcherTimer();
            readDataTimer.Tick    += new EventHandler(TimeCycle);
            readDataTimer.Interval = new TimeSpan(int.Parse(quartz.Split('-')[0]), int.Parse(quartz.Split('-')[1]), int.Parse(quartz.Split('-')[2]), int.Parse(quartz.Split('-')[3]));
            readDataTimer.Start();

            string   tipsDoStr = System.Configuration.ConfigurationManager.AppSettings["tips"];
            DateTime tipsTime  = DateTime.Parse(tipsDoStr);

            SchTaskExt.CreateDailyTaskScheduler("CRBB", "TipsMissionPlan", System.Configuration.ConfigurationManager.AppSettings["TipsMissionPlan"], tipsTime.ToString());

            //string weeklyDoStr = System.Configuration.ConfigurationManager.AppSettings["reports"];
            //DateTime weeklyTime = DateTime.Parse(weeklyDoStr);
            //SchTaskExt.CreateDailyTaskScheduler("CRBB", "WeeklyMissionPlan", System.Configuration.ConfigurationManager.AppSettings["WeeklyMissionPlan"], weeklyTime.ToString());

            //string monthlyDoStr = System.Configuration.ConfigurationManager.AppSettings["reports"];
            //DateTime monthlyTime = DateTime.Parse(monthlyDoStr);
            //SchTaskExt.CreateDailyTaskScheduler("CRBB", "MonthlyReportMissionPlan", System.Configuration.ConfigurationManager.AppSettings["MonthlyReportMissionPlan"], monthlyTime.ToString());
            OpenSafeguardAbilitryWindow();
        }