private void Page_Loaded(object sender, RoutedEventArgs e)
 {
     //加载图片
     if (LanguageUtils.IsChainese())
     {
         title_pic.Source = new BitmapImage(new Uri(@"\view\Images\bdl.PNG", UriKind.Relative));
         title_pic.Height = 198.4;
     }
     else
     {
         //TODO 英文图片
         title_pic.Source = new BitmapImage(new Uri(@"\view\Images\design.png", UriKind.Relative));
         title_pic.Height = 257;
     }
     try
     {
         if (SetterDAO.getSetter() != null)
         {
             if (SetterDAO.getSetter().Set_Unique_Id != "" && SetterDAO.getSetter().Set_Unique_Id != null)//判断是否激活
             {
                 Status.Content = LanguageUtils.GetCurrentLanuageStrByKey("SettingsView.Activated");
                 Color color = Color.FromArgb(255, 2, 200, 5);
                 Status.Foreground     = new SolidColorBrush(color);
                 BtnActivite.IsEnabled = false;
             }
         }
     }
     catch (InvalidOperationException ee)
     {
     }
     setterList = setterDao.ListAll();
     try { Pk_Set_Id = setterList[0].Pk_Set_Id; }
     catch (ArgumentOutOfRangeException ee)
     {
     }
     try
     {
         List <Auther> AutherList = new List <Auther>();
         auther = authDAO.GetAuther(auth_level);
         AutherList.Add(auther);
         ((this.FindName("DataGrid1")) as DataGrid).ItemsSource = AutherList;
     }
     catch (Exception ee) { }
     try
     {
         DeviceSetList = deviceSetDAO.ListAll();
         ((this.FindName("ComboBox_Device")) as ComboBox).ItemsSource = DeviceSetList;//系列
         int Dset_Id = (int)ComboBox_Device.SelectedValue;
         DeviceSortList = deviceSortDAO.GetDeviceSortBySet(Dset_Id);
         ((this.FindName("DataGrid2")) as DataGrid).ItemsSource = DeviceSortList;//类型
     }
     catch (Exception ee)
     {
     }
 }
示例#2
0
        /// <summary>
        /// 定时器心跳间隔,load时设置
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            //加载图片
            if (LanguageUtils.IsChainese())
            {
                title_pic.Source     = new BitmapImage(new Uri(@"\view\Images\12.PNG", UriKind.Relative));
                DesignerHead4.Source = new BitmapImage(new Uri(@"\view\images\6.png", UriKind.Relative));
            }
            else
            {
                //TODO 英文图片
                title_pic.Source     = new BitmapImage(new Uri(@"\view\Images\12.PNG", UriKind.Relative));
                DesignerHead4.Source = new BitmapImage(new Uri(@"\view\images\6.png", UriKind.Relative));
            }
            ///载入时数据装填到list,默认选中第一个
            users = userService.GetAllUsers();
            UsersInfo.ItemsSource   = users;
            UsersInfo.SelectedIndex = 1;
            selectUser = (User)UsersInfo.SelectedItem;
            Refresh_RecordFrame_Action();
            ///心跳部分

            #region 通知公告   未激活不心跳
            SetterDAO setterDao = new SetterDAO();
            if (timerNotice == null)
            {
                while (setterDao.ListAll() != null)
                {
                    break;
                }
                BindNotice();

                timerNotice          = new System.Timers.Timer();
                timerNotice.Elapsed += new System.Timers.ElapsedEventHandler((o, eea) => { BindNotice(); });

                timerNotice.Interval = CommUtil.GetHeartBeatRate();
                timerNotice.Start();
            }

            #endregion
        }
示例#3
0
 private void image_load(object sender, RoutedEventArgs e)
 {
     //加载图片
     if (LanguageUtils.IsChainese())
     {
         DesignerHead4.Source = new BitmapImage(new Uri("/view/Images/6.png", UriKind.RelativeOrAbsolute));
         DesignerHead4.Margin = new Thickness(10, 0, 0, 0);
         DesignerHead4.Height = 60;
         DesignerHead4.Width  = 225;
         DesignerHead3.Height = 70;
         subhead.FontSize     = 18;
     }
     else
     {
         DesignerHead4.Source = new BitmapImage(new Uri("/view/Images/5_5.png", UriKind.RelativeOrAbsolute));
         DesignerHead4.Margin = new Thickness(97, 18, 0, 0);
         DesignerHead4.Height = 25;
         DesignerHead4.Width  = 136;
         DesignerHead3.Height = 60;
         subhead.FontSize     = 15;
     }
 }
示例#4
0
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            //加载图片
            if (LanguageUtils.IsChainese())
            {
                title_pic.Source = new BitmapImage(new Uri(@"\view\Images\bdl.PNG", UriKind.Relative));
            }
            else
            {
                title_pic.Source = new BitmapImage(new Uri(@"\view\Images\design.png", UriKind.Relative));
            }
            entity.Setter setter = new entity.Setter();
            //setter.Pk_Set_Id = 5;
            //setterList.Add(setterDao.Load(setter.Pk_Set_Id));
            setterList = setterDao.ListAll();
            //初始化版本号
            if (setterList != null && setterList.Count == 1)
            {
                setterList[0].Set_Version = CommUtil.GetCurrentVersion();
            }
            try
            {
                Pk_Set_Id = setterList[0].Pk_Set_Id;
            }
            catch (ArgumentOutOfRangeException ee)
            {
            }

            try { comboBox2.SelectedIndex = setterList[0].Set_Language; }
            catch (ArgumentOutOfRangeException ee)
            {
                comboBox2.SelectedIndex = 1;
            }
            try
            {
                comboBox1.SelectedIndex = int.Parse(setterList[0].Set_OrganizationSort);
            }
            catch (Exception ee)
            {
                comboBox1.SelectedIndex = 1;
            }
            ObservableCollection <entity.Setter> DataCollection = new ObservableCollection <entity.Setter>(setterList);

            textBox1.DataContext  = DataCollection;                               //设置机构团体名称
            textBox2.DataContext  = DataCollection;                               //设置照片保存文档
            textBox3.DataContext  = DataCollection;                               //设置机构电话
            textBox4.DataContext  = DataCollection;                               //设置当前版本
            textBox5.DataContext  = DataCollection;                               //设置备份地址
            ListDataCode          = DataCodeDAO.ListByTypeId("OrganizationSort"); //绑定组织区分
            comboBox1.ItemsSource = ListDataCode;
            ListDataCode          = DataCodeDAO.ListByTypeId("Language");         //绑定语言
            comboBox2.ItemsSource = ListDataCode;
            //下方三个datagrid的实现
            groupList     = customDataService.GetAllObjectByType(CustomDataEnum.Group);
            diseaseList   = customDataService.GetAllObjectByType(CustomDataEnum.Disease);
            diagnosisList = customDataService.GetAllObjectByType(CustomDataEnum.Diagiosis);

            ((this.FindName("DataGrid2")) as DataGrid).ItemsSource = groupList;
            ((this.FindName("DataGrid3")) as DataGrid).ItemsSource = diseaseList;
            ((this.FindName("DataGrid4")) as DataGrid).ItemsSource = diagnosisList;
        }
示例#5
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            //加载图片
            if (LanguageUtils.IsChainese())
            {
                DesignerHead4.Source = new BitmapImage(new Uri(@"\view\images\6.png", UriKind.Relative));
            }
            else
            {
                //TODO 英文图片
                DesignerHead4.Source = new BitmapImage(new Uri(@"\view\images\6.png", UriKind.Relative));
            }
            var hwnd = new System.Windows.Interop.WindowInteropHelper(this).Handle;

            SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) & ~WS_SYSMENU);

            #region 通知公告

            //SetterDAO setterDao = new SetterDAO();

            ////未激活无心跳
            //if (setterDao.ListAll() != null && setterDao.ListAll().Count == 0)
            //{

            //}
            ////没有一般用户无心跳
            //else if (authDao.ListAll() != null && authDao.ListAll().Count == 1)
            //{

            //}
            //else {
            //    if (timerNotice == null)
            //    {

            //        BindNotice();

            //        timerNotice = new System.Timers.Timer();
            //        timerNotice.Elapsed += new System.Timers.ElapsedEventHandler((o, eea) => { BindNotice(); });

            //        timerNotice.Interval = CommUtil.GetHeartBeatRate();
            //        timerNotice.Start();
            //    }
            //}


            #endregion

            //打开时,是否记住密码的勾选,如果是就勾选,并且填充登录名和密码 如果不是就没有操作
            //bool? checkRemind = isRemind.IsChecked;
            String ckeckStr        = CommUtil.GetSettingString("isRemind");
            String ckeckStrName    = CommUtil.GetSettingString("isRemindName");
            bool?  checkRemind     = ckeckStr == "true" ? true : false;
            bool?  checkRemindName = ckeckStrName == "true" ? true : false;
            if (checkRemind == true)
            {
                //UI效果-记住密码,一定记住用户名
                isRemind.IsChecked     = true;
                isRemindName.IsChecked = true;
                //获取用户名
                String name = ConfigUtil.GetEncrypt("userName", "");
                this.User_Name.Text = name;
                //获取密码
                String password = ConfigUtil.GetEncrypt("password", "");;
                this.User_Password.Password = password;
            }
            else if (checkRemindName == true)
            {
                //UI效果-只记住用户名就只显示用户名
                isRemindName.IsChecked = true;
                //界面注入
                String name = ConfigUtil.GetEncrypt("userName", "");
                this.User_Name.Text = name;
            }
        }
示例#6
0
        /// <summary>
        /// 应用启动的时候生命周期
        /// </summary>
        /// <param name="ex"></param>
        protected override void OnStartup(StartupEventArgs ex)
        {
            //全局异常处理机制,UI异常
            Current.DispatcherUnhandledException += App_OnDispatcherUnhandledException;
            //全局异常处理机制,线程异常
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            //加载语言
            LanguageUtils.SetLanguage();

            //启动netty,用于与设备端通信
            Thread th = new Thread(() =>
            {
                try
                {
                    logger.Info("线程启动成功");
                    NettyLuncher.getInstance().Start().Wait();
                }
                catch (AggregateException ee)
                {
                    App.Current.Dispatcher.Invoke(new Action(() =>
                    {
                        MessageBoxX.Info(LanguageUtils.GetCurrentLanuageStrByKey("App.PortOccupy"));
                        System.Environment.Exit(0);
                    }));
                }
            });

            th.Start();


            //启动远程更新
            Thread updateTh = new Thread(() =>
            {
                try
                {
                    Thread.Sleep(1000 * 8);
                    Dictionary <string, string> param = new Dictionary <string, string>();

                    param.Add("version", CommUtil.GetCurrentVersion());
                    var result = HttpSender.GET(HttpSender.URL_UPDATE, param);
                    if (string.IsNullOrEmpty(result))
                    {
                        return;
                    }
                    var info = JsonTools.DeserializeJsonToObject <VersionInfo>(result);
                    if (info == null || info.update == false)
                    {
                        return;
                    }

                    info.language = LanguageUtils.IsChainese() ? 1 : 0;
                    App.Current.Dispatcher.Invoke(new Action(() =>
                    {
                        Boolean dr = MessageBoxX.Question(LanguageUtils.GetCurrentLanuageStrByKey("App.UpdateInfo"));
                        if (dr == true)
                        {
                            Process.Start("AutoUpdater.exe", info.GetProcessString());
                            Environment.Exit(0);
                        }
                    }));
                }
                catch (Exception exc)
                {
                    Console.WriteLine(exc.ToString());
                    return;
                }
            });

            updateTh.Start();



            //大数据线程

            Thread bdth = new Thread(() =>
            {
                try
                {
                    SetterDAO setterDao = new SetterDAO();
                    AuthDAO authDAO     = new AuthDAO();
                    while (true)
                    {
                        if (setterDao.ListAll().Count != 1)
                        {
                            //不激活不开启
                            Thread.Sleep(1000 * 15);
                            continue;
                        }
                        if (authDAO.ListAll().Count == 1)
                        {
                            //Console.WriteLine("-----------------boom shakalaka--------------");
                            //只有admin,不创建用户,不开启,睡个15s
                            Thread.Sleep(1000 * 15);
                            continue;
                        }
                        try
                        {
                            BigDataOfficer bigDataOfficer = new BigDataOfficer();
                            bigDataOfficer.Run();
                            //int heartBeatRate = (int)CommUtil.GetBigDataRate();
                            Thread.Sleep(1000 * 60);
                            //Console.WriteLine("-----------------boom");
                        }
                        catch (Exception e)
                        {
                            logger.Error("大数据线程失败:" + e.StackTrace);
                            Console.WriteLine("大数据线程失败:" + e.Message);
                        }
                    }
                }
                catch (Exception exct)
                {
                    Console.WriteLine(exct.ToString());
                }
            });

            bdth.Start();

            //心跳线程
            Thread hbth = new Thread(() =>
            {
                ProtoBufSocket socket = null;
                try
                {
                    socket = new ProtoBufSocket();
                    socket.Connect();
                }
                catch (Exception exception)
                {
                    Console.WriteLine("连接失败:" + exception.StackTrace);
                    TcpHeartBeatUtils.WriteLogFile("连接失败:" + exception.StackTrace);
                }

                while (true)
                {
                    try
                    {
                        BodyStrongMessage bodyStrongMessage = new BodyStrongMessage
                        {
                            MessageType = BodyStrongMessage.Types.MessageType.Heaerbeatreq,
                            //可能为null
                            HeartbeatRequest = TcpHeartBeatUtils.GetHeartBeatByCurrent()
                        };

                        socket.SendMessage(bodyStrongMessage);
                        Console.WriteLine("发送msg!!");
                        //Thread.Sleep(5000);
                    }
                    catch (Exception eee)
                    {
                        Console.WriteLine("发送msg失败" + eee.StackTrace);
                        TcpHeartBeatUtils.WriteLogFile("发送msg失败" + eee.StackTrace);
                    }
                    finally
                    {
                        Thread.Sleep(5000);
                    }
                }
            });

            hbth.Start();

            base.OnStartup(ex);
        }
示例#7
0
        //按钮:文档输出
        private void Output_Document(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.SaveFileDialog sfd = new Microsoft.Win32.SaveFileDialog
            {
                Filter = LanguageUtils.ConvertLanguage("Excel表格(*.xlsx)|*.xlsx", "Excel Sheet (*.xlsx)|*.xlsx")
            };
            //设置默认文件类型显示顺序
            sfd.FilterIndex = 1;
            //保存对话框是否记忆上次打开的目录
            sfd.RestoreDirectory = true;

            if (selectUser != null)
            {
                if (is_signinformationrecord.IsChecked == true)
                {
                    sfd.FileName = selectUser.User_Name + "-" + LanguageUtils.GetCurrentLanuageStrByKey("SubjectInfoView.VitalHistory") + "-" + DateTime.Now.ToString("yyyyMMddHHmm") + ".xlsx";
                }
                if (is_trainingrecord.IsChecked == true)
                {
                    sfd.FileName = selectUser.User_Name + "-" + LanguageUtils.GetCurrentLanuageStrByKey("SubjectInfoView.TrainingHistory") + "-" + DateTime.Now.ToString("yyyyMMddHHmm") + ".xlsx";
                }
                if (is_physicalevaluation.IsChecked == true)
                {
                    sfd.FileName = selectUser.User_Name + "-" + LanguageUtils.GetCurrentLanuageStrByKey("SubjectInfoView.PhysicalEvaluationHistory") + "-" + DateTime.Now.ToString("yyyyMMddHHmm") + ".xlsx";
                }
            }

            if (sfd.ShowDialog() == true)
            {
                //此处做你想做的事 ...=ofd.FileName;
                //获取当前
                try
                {
                    if (is_signinformationrecord.IsChecked == true)
                    {
                        //导出症状信息记录
                        if (selectUser != null)
                        {
                            //获取用户症状信息
                            List <SymptomInfo> lists = new SymptomService().GetByUserId(selectUser);
                            if (lists.Count > 0)
                            {
                                List <object> symptomInfoDtos = new List <object>();
                                foreach (SymptomInfo symptomInfo in lists)
                                {
                                    symptomInfoDtos.Add(new SymptomInfoExcelVO(symptomInfo));
                                }

                                //存放信息导出的列名
                                if (LanguageUtils.IsChainese())
                                {
                                    string[] colNames = { "训练日期", "血压(前)", "脉搏(前)", "心率(前)", "体温(前)", "血压(后)", "脉搏(后)", "心率(后)", "体温(后)", "身体倦怠", "腹泻", "摇晃", "心跳、气喘", "咳嗽、有痰", "发烧", "胸部、肚子痛", "没有食欲", "持续便秘", "感到头晕", "头痛", "其他", "没有相关症状", "是否参加", "水分摄取", "看护记录" };
                                    ExcelUtil.GenerateOrdinaryExcel(sfd.FileName.ToString(), selectUser, ExcelUtil.ToDataTable("症状信息记录", colNames, symptomInfoDtos));
                                }
                                else
                                {
                                    string[] colNames = { "Training date", "Blood pressure (front)", "Pulse (front)", "Heart rate (front)", "Body temperature (front)", "Blood pressure (after)", "Pulse (after)", "Heart rate (after)", "Body temperature (after)", "Physical exhaustion", "Diarrhea", "Shake", "Heartbeat, asthma", "Cough with phlegm", "Fever", "Chest and stomach pain", "No appetite", "Continuous constipation", "Feeling dizzy", "Headache", "Other", "No related symptoms", "Whether to participate", "Moisture intake", "Care record" };
                                    ExcelUtil.GenerateOrdinaryExcel(sfd.FileName.ToString(), selectUser, ExcelUtil.ToDataTable("Symptom information record", colNames, symptomInfoDtos));
                                }
                            }
                            else
                            {
                                MessageBoxX.Warning(LanguageUtils.ConvertLanguage("抱歉,没有数据", "Sorry, No Data!"));
                            }
                        }
                    }
                    else if (is_trainingrecord.IsChecked == true)
                    {
                        //导出训练记录
                        if (selectUser != null)
                        {
                            List <TrainComprehensive> lists = new ExcelService().ListTrainExcekVOByUserId(selectUser.Pk_User_Id);
                            if (lists.Count > 0)
                            {
                                List <object> excelLists = new List <object>();
                                foreach (TrainComprehensive trainComprehensive in lists)
                                {
                                    excelLists.Add(new TrainExcelVO(trainComprehensive));
                                }
                                //Console.WriteLine(lists.ToString());
                                //存放信息导出的列名
                                if (LanguageUtils.IsChainese())
                                {
                                    string[] colNames = { "实施日期", "使用器械", "组数", "组的个数", "组间隔休息时间", " 砝码", "移乘方法", "自觉运动强度", "时间(秒)", " 距离(mm)", "总工作量(J)", "热量(cal)", "指数", "已完成组数", "时机、姿势", "备忘", "注意点", "利用者感想" };
                                    ExcelUtil.GenerateOrdinaryExcel(sfd.FileName.ToString(), selectUser, ExcelUtil.ToDataTable("训练记录", colNames, excelLists));
                                }
                                else
                                {
                                    string[] colNames = { "Date", "Device name", "Groups", "Number", "Break time", " Weights", "Transfer method", "Conscious exercise intensity", "Time (seconds)", " Distance (mm)", "Total workload (J)", "Calories (cal)", "Index", "Completed groups", "Timing, posture", "Remark", "Be careful", "User feelings" };
                                    ExcelUtil.GenerateOrdinaryExcel(sfd.FileName.ToString(), selectUser, ExcelUtil.ToDataTable("Training record", colNames, excelLists));
                                }
                            }
                            else
                            {
                                MessageBoxX.Warning(LanguageUtils.ConvertLanguage("抱歉,没有数据", "Sorry, No Data!"));
                            }
                        }
                    }
                    else if (is_physicalevaluation.IsChecked == true)
                    {
                        //导出体力评价记录
                        if (selectUser != null)
                        {
                            List <PhysicalPower> lists = new ExcelService().ListPhysicalPowerExcelVO(selectUser.Pk_User_Id);
                            if (lists.Count > 0)
                            {
                                List <object> excelLists = new List <object>();
                                foreach (PhysicalPower physicalPower in lists)
                                {
                                    excelLists.Add(new PhysicaleExcelVO(physicalPower));
                                }

                                //存放信息导出的列名
                                if (LanguageUtils.IsChainese())
                                {
                                    string[] colNames = { "日期", "身高", "体重", "握力", "睁眼单脚站立", "功能性前伸", "坐姿体前屈", "time&up go", "5m步行-通常", "5m步行-最快", "10m步行", "6分钟步行", "2分钟踏步", "2分钟抬腿", "使用用者感想", "工作人员感想" };

                                    ExcelUtil.GenerateOrdinaryExcel(sfd.FileName.ToString(), selectUser,
                                                                    ExcelUtil.ToDataTable("体力评价记录", colNames, excelLists));
                                }
                                else
                                {
                                    string[] colNames = { "Date", "High", "Weight", "Grip", "Wink stand on one foot", "Functional reach", "Sitting body flexion", "time&up go", "5m walk - usually", "5m walk - fastest", "10m walk", "6 minutes walk", "2 String step", "2 minutes leg lift", "User experience", "Staff feelings" };

                                    ExcelUtil.GenerateOrdinaryExcel(sfd.FileName.ToString(), selectUser,
                                                                    ExcelUtil.ToDataTable("Physical Assessment Record", colNames, excelLists));
                                }
                            }
                            else
                            {
                                MessageBoxX.Warning(LanguageUtils.ConvertLanguage("抱歉,没有数据", "Sorry, No Data!"));
                            }
                        }
                    }
                }
                catch (IOException ex)
                {
                    MessageBoxX.Warning(LanguageUtils.ConvertLanguage("文件被占用,请先关闭文件", "The file is occupied. Please close the file first"));
                    return;
                }
                catch (Exception ex)
                {
                    Console.WriteLine("生成普通Excel异常");
                    return;
                }
            }
        }