示例#1
0
 private void Btn_Confirm(object sender, RoutedEventArgs e)
 {//MessageBox.Show(LanguageUtils.ConvertLanguage("你确认要保存更改吗", "Are you sure you want to save your changes?"), LanguageUtils.ConvertLanguage("提示:", "Tips"), MessageBoxButton.OKCancel) == MessageBoxResult.OK
     if (MessageBoxX.Question(LanguageUtils.ConvertLanguage("你确认要保存更改吗", "Are you sure you want to save your changes?")))
     {
         string textValue1 = textBox1.Text;                         //机构团体名称
         string textValue2 = textBox2.Text;                         //照片保存文档
         string textValue3 = textBox3.Text;                         //机构电话
         //string textValue4 = textBox4.Text;//版本
         string        textValue5        = textBox5.Text;           //备份
         int           comboBox1Selected = comboBox1.SelectedIndex; //机构区分被选择的index
         int           comboBox2Selected = comboBox2.SelectedIndex; //语言被选择的index
         entity.Setter setter            = new entity.Setter();
         setter.Pk_Set_Id             = Pk_Set_Id;
         setter.Set_OrganizationName  = textValue1;
         setter.Set_PhotoLocation     = textValue2;
         setter.Set_OrganizationPhone = textValue3;
         //setter.Set_Version = textValue4;
         if (textValue5.Contains(" "))
         {
             MessageBoxX.Warning(LanguageUtils.ConvertLanguage("备份路径不能含有空格", "Backup path cannot contain spaces"));
         }
         else
         {
             setter.Back_Up              = textValue5;//备份路径
             setter.Set_Version          = CommUtil.GetCurrentVersion();
             setter.Set_Language         = comboBox2Selected;
             setter.Set_OrganizationSort = comboBox1Selected.ToString();
             setterDao.UpdateSetter(setter);
             //切换语言
             LanguageUtils.SetLanguage();
             GoBack(null, null);
         }
     }
 }
示例#2
0
 /// <summary>
 /// 备份图片
 /// </summary>
 /// <param name="saveDirPath"></param>
 public static void CopyDirectory(string saveDirPath)
 {
     try
     {
         entity.Setter setter = new entity.Setter();
         setter = new SetterDAO().getSetter();
         Console.WriteLine("目标路径:" + saveDirPath);
         string sourceDirPath = setter.Set_PhotoLocation;
         Console.WriteLine("原路径:" + sourceDirPath);
         if (!Directory.Exists(saveDirPath))
         {
             Directory.CreateDirectory(saveDirPath);
         }
         string[] files = Directory.GetFiles(sourceDirPath.Substring(0, sourceDirPath.Length - 1));
         //MessageBox.Show(files.Length.ToString());
         foreach (string file in files)
         {
             string pFilePath = saveDirPath + Path.GetFileName(file);
             if (File.Exists(pFilePath))
             {
                 continue;
             }
             File.Copy(file, pFilePath, true);
         }
     }
     catch (Exception ee)
     {
     }
 }
示例#3
0
 public void UpdateOneSet(entity.Setter setter)
 {
     using (var conn = DbUtil.getConn())
     {
         const string sql = "update bdl_set set Set_Unique_Id=@Set_Unique_Id where Pk_Set_Id = @Pk_Set_Id";
         conn.Execute(sql, setter);
     }
 }
示例#4
0
        public void UpdateSetter(entity.Setter setter)
        {
            using (var conn = DbUtil.getConn())//更新Setter
            {
                conn.Execute("update bdl_set set Set_Language=@Set_Language,Set_OrganizationSort=@Set_OrganizationSort,Set_OrganizationName=@Set_OrganizationName,Set_PhotoLocation=@Set_PhotoLocation,Set_OrganizationPhone=@Set_OrganizationPhone,Back_Up=@Back_Up where Pk_Set_Id=@Pk_Set_Id", setter);
            }
            setter = getSetter();
            //插入至上传表
            UploadManagementDAO uploadManagementDao1 = new UploadManagementDAO();

            uploadManagementDao1.Insert(new UploadManagement(setter.Pk_Set_Id, "bdl_set", 1));
        }
示例#5
0
        public void InsertOneMacAdress(entity.Setter setter)
        {
            using (var conn = DbUtil.getConn())
            {
                const string sql = "insert into bdl_set(set_unique_id, set_language,set_photolocation, set_version,back_up) values(@Set_Unique_Id,@Set_Language, @Set_PhotoLocation, @Set_Version,@Back_Up)";
                conn.Execute(sql, setter);
            }
            setter = getSetter();
            //插入至上传表
            UploadManagementDAO uploadManagementDao1 = new UploadManagementDAO();

            uploadManagementDao1.Insert(new UploadManagement(setter.Pk_Set_Id, "bdl_set", 0));
        }
示例#6
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;
        }
        private void Btn_Activate(object sender, RoutedEventArgs e)
        {
            //InputNonPublicInformationPassword
            InputNonPublicInformationPassword passwordInput = new InputNonPublicInformationPassword
            {
                Owner                 = Window.GetWindow(this),
                ShowActivated         = true,
                ShowInTaskbar         = false,
                WindowStartupLocation = WindowStartupLocation.CenterScreen
            };

            passwordInput.ShowDialog();
            if (ProtocolConstant.USB_SUCCESS == 0) //u盘成功读取 破解状态为0
            {                                      //获取mac地址
                StringBuilder stringBuilder = new StringBuilder();
                //string strMac = CommUtil.GetMacAddress();
                // List<string> Macs = CommUtil.GetMacByWMI();
                List <string> Macs = CommUtil.GetMacByIPConfig();
                foreach (string mac in Macs)
                {
                    string prefix = "物理地址. . . . . . . . . . . . . : ";
                    string Mac    = mac.Substring(prefix.Length - 1);
                    stringBuilder.Append(Mac);
                }
                //Console.WriteLine("==================="+stringBuilder.ToString());
                //MessageBox.Show("===================" + stringBuilder.ToString());
                entity.Setter setter = new entity.Setter();
                //mac地址先变为byte[]再aes加密
                byte[] byteMac = Encoding.GetEncoding("GBK").GetBytes(stringBuilder.ToString());
                byte[] AesMac  = AesUtil.Encrypt(byteMac, ProtocolConstant.USB_DOG_PASSWORD);
                //存入数据库
                //setter.Set_Unique_Id = Encoding.GetEncoding("GBK").GetString(AesMac);
                setter.Set_Unique_Id = ProtocolUtil.BytesToString(AesMac);

                /*AES解密
                 * byte[] a = ProtocolUtil.StringToBcd(setter.Set_Unique_Id);
                 * byte[] b = AesUtil.Decrypt(a, ProtocolConstant.USB_DOG_PASSWORD);
                 * Console.WriteLine(Encoding.GetEncoding("GBK").GetString(b));*/
                //默认照片路径,激活时获取(路径中不要有汉字)
                string basePath = System.AppDomain.CurrentDomain.BaseDirectory;
                string path     = ConfigurationManager.AppSettings["PicPath"];
                setter.Set_PhotoLocation = basePath + path;
                setter.Set_Language      = 1;
                //默认备份路径,激活时获取
                setter.Back_Up      = basePath + @"BackUp\";
                setter.Set_Language = 1;
                //设置版本号
                setter.Set_Version = CommUtil.GetCurrentVersion();
                if (!Directory.Exists(@setter.Set_PhotoLocation))
                {
                    Directory.CreateDirectory(@setter.Set_PhotoLocation);//不存在就创建目录
                }

                /*if (Directory.Exists(@setter.Set_PhotoLocation)) {  //存在就删除
                 *  Directory.Delete(@setter.Set_PhotoLocation, true);
                 *  Directory.CreateDirectory(@setter.Set_PhotoLocation);
                 * }*/
                SetterDAO.InsertOneMacAdress(setter);
                //注释的部分为添加多个mac地址
                // List<entity.Setter> ListMac = CommUtil.GetMacByWMI();
                // SetterDAO.InsertMacAdress(ListMac);



                Status.Content = LanguageUtils.GetCurrentLanuageStrByKey("SettingsView.Activated");
                Color color = Color.FromArgb(255, 2, 200, 5);
                Status.Foreground     = new SolidColorBrush(color);
                BtnActivite.IsEnabled = false;
            }
            else
            {
                MessageBoxX.Error(LanguageUtils.ConvertLanguage("激活失败", "Activation fails"));
            }
        }